100BBasic instructions
7.5 Math
S7-1200 Programmable controller
192
System Manual, 11/2011, A5E02486680-05
7.5.8
Limit instruction
Table 7- 56 LIMIT instruction
LAD / FBD
SCL
Description
LIMIT(MIN:=_variant_in_,
IN:=_variant_in_,
MAX:=_variant_in_,
OUT:=_variant_out_);
The Limit instruction tests if the value of parameter IN is inside the
value range specified by parameters MIN and MAX and if not,
clamps the value at MIN or MAX.
1
For LAD and FBD: Click the "???" and select a data type from the drop-down menu.
Table 7- 57 Data types for the parameters
Parameter
Data type
1
Description
MIN, IN, and MAX
SInt, Int, DInt, USInt, UInt, UDInt, Real, LReal, Constant
Math operation inputs
OUT
SInt, Int, DInt, USInt, UInt, UDInt, Real, LReal
Math operation output
1
The MIN, IN, MAX, and OUT parameters must be the same data type.
If the value of parameter IN is within the specified range, then the value of IN is stored in
parameter OUT. If the value of parameter IN is outside of the specified range, then the OUT
value is the value of parameter MIN (if the IN value is less than the MIN value) or the value
of parameter MAX (if the IN value is greater than the MAX value).
Table 7- 58 ENO status
ENO
Description
1
No error
0
Real: If one or more of the values for MIN, IN and MAX is NaN (Not a Number), then NaN is returned.
0
If MIN is greater than MAX, the value IN is assigned to OUT.
SCL examples:
●
MyVal := LIMIT(MIN:=10,IN:=53, MAX:=40); //Result: MyVal = 40
●
MyVal := LIMIT(MIN:=10,IN:=37, MAX:=40); //Result: MyVal = 37
●
MyVal := LIMIT(MIN:=10,IN:=8, MAX:=40); //Result: MyVal = 10
7.5.9
Floating-point math instructions
You use the floating point instructions to program mathematical operations using a Real or
LReal data type:
●
SQR: Square (IN
2
= OUT)
●
SQRT: Square root (√IN = OUT)
●
LN: Natural logarithm (LN(IN) = OUT)