5 mod, 6 indexof, Indexof – Lenze DDS v2.3 User Manual
Page 273: Drive plc developer studio
![background image](/manuals/565964/273/background.png)
Drive PLC Developer Studio
IEC 61131-3 Operators
12-3
l
DDS EN 2.3
Implementing CheckDivReal
Declaration part
FUNCTION CheckDivReal:REAL
VAR_INPUT
divisor:REAL;
END_VAR
Instruction part
IF divisor = 0 THEN
CheckDivReal:=1;
ELSE
CheckDivReal:=divisor;
END_IF;
The operator DIV uses the result of function CheckDivReal as divisor. In the program example
illustrated below, this prevents a division by 0 by setting the divisor (d) from 0 to 1. The result erg of
the division is therefore 799.
12.1.5
MOD
Modulo division
Modulo division of a variable of type BYTE; WORD; DWORD; SINT; USINT; INT; UINT; DINT; UDINT with
another variable of one of these types. The result of this function is an integer remainder of the
division.
Examples
IL
ST
FBD
LD
9
MOD 2
ST
Var1
(* Var1 = 1 *)
Var1 := 9 MOD 2;
12.1.6
INDEXOF
The result of this function is the internal index of an organization unit.
Examples
IL
ST
FBD
Var1 :=
INDEXOF(organization
unit2);
Show/Hide Bookmarks