4 selection operators, 1 sel, 2 max – Lenze DDS v2.3 User Manual
Page 278: Drive plc developer studio
![background image](/manuals/565964/278/background.png)
Drive PLC Developer Studio
IEC 61131-3 Operators
12-8
l
DDS EN 2.3
12.4
Selection operators
All selection operations can also be carried out on variables.
For better understanding, the examples below use constants as operands.
12.4.1
SEL
Binary selection
OUT := SEL(G, IN0, IN1)
means:
IF G THEN
OUT:=IN1;
ELSE
OUT:=IN0;
END_IF
IN0
,
IN1
and
OUT
can be of any type,
G
must be of type BOOL.
The result of the selection is
•
IN0
if
G
is FALSE,
•
IN1
if
G
is TRUE.
Examples
IL
ST
FBD
LD
TRUE
SEL 3,4
(*IN0=3, IN1=4*)
ST
Var1
(*Result=4 *)
LD
FALSE
SEL 3,4
ST
Var1
(*Result=3*)
Var1:=SEL(TRUE,3,4);
(*Result Var1=4*)
Tip!
Processing is as follows for runtime optimization.
An expression attached to the input side of IN0 will be computed only if G = FALSE.
An expression attached to the input side of IN1 will be computed only if G = TRUE.
Simulation will compute all branches.
12.4.2
MAX
Maximum function
Returns the greater of two values.
OUT := MAX(IN0, IN1)
IN0
,
IN1
and
OUT
can be of any type.
Examples
IL
ST
FBD
LD
90
MAX 30
MAX 40
MAX 77
ST
Var1
(* Var1 = 90 *)
Show/Hide Bookmarks