Arithmetic instructions
86
Part II IEC Instructions
LIMIT
Limit value for input variable
To add an enable input and enable output to the instruction, select [With EN/ENO] from the
"Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the
context menu or press <Ctrl>+<Shift>+<v> in the programming window.
PLC types
Availability of LIMIT (see page 1328)
Data type I/O Function
all data types 1st input upper limit
all data types 2nd input value compared to upper and lower limit
all data types 3rd input lower limit
all data types output as input result, 2nd input value if between upper and lower limit,
otherwise the upper or lower limit
Description
In LIMIT the 1st input variable forms the lower and the 3rd input variable the upper limit value. If the
2nd input variable is within this limit, it will be transferred to the output variable. If it is above this
limit, the upper limit value will be transferred; if it is below this limit the lower limit value will be
transferred.
Data types
Example
In this example, the same POU header is used for all programming languages. For an example
using IL (instruction list), please refer to the online help.
POU header
All input and output variables used for programming this function have been declared in the POU
header.
In this example the input variables (lower_limit_val, comparison_value and upper_val) have
been declared. Instead, you may enter a constant directly at the input contact of a function.
Body
Lower_limit_val and upper_limit_val form the range where the comparison_value has to be, if it
has to be transferred to result. If the comparison_value is above the upper_limit_val, the value
of upper_limit_val will be transferred to result. If it is below the lower_limit_val, the value of
lower_limit_val will be transferred to result.
LD
ST
When programming with structured text, enter the following:
result:=LIMIT(MN:=lower_limit_val, IN:=comparison_value,
MX:=upper_limit_val);