8.6
Selection
Admissible data types
Argument: UINT, UDINT, REAL (with SEL, additionally BOOL for the selector)
Result: UINT, UDINT, REAL
MAX
Returns the biggest argument as a result.
Example:
OUT := MAX(8, 9, 10, 11, 12); (* OUT := 12 *)
MIN
Returns the smallest argument as a result.
Example:
OUT := MIN(8, 9, 10, 11, 12); (* OUT := 8 *)
LIMIT
Checks whether a value (IN) is within a certain range (MIN, MAX). If the value is within the range, the
value itself is returned. If the value is below the range, the lower range limit is returned. If the value is
above the range, the upper range limit is returned.
Examples:
OUT := LIMIT(IN, MIN, MAX);
OUT := LIMIT(15, 10, 20); (* OUT = 15 *)
OUT := LIMIT(5, 10, 20); (* OUT = 10 *)
OUT := LIMIT(25, 10, 20); (* OUT = 20 *)
SEL
Selects one of two values (IN0, IN1) depending on a Boolean variable (G). The data type of the values
IN0 and IN1 must be identical.
Examples:
OUT := SEL(G, IN0, IN1);
OUT := SEL(G, 10, 20); (* G = FALSE: OUT = 10 *)
OUT := SEL(G, 10, 20); (* G = TRUE: OUT = 20 *)
8 Functions
43