7.7.4 LIMIT
Function
The limiting function limits the value input in IN to between MN and MX and outputs it at OUT. If IN is greater than MN and less than MX, then OUT := IN; if IN is less than MN, then OUT := MN; if IN is greater than MX, then OUT := MX
LD graphics
Parameter description
| Interface variable | Declaration | Data type | Description |
|---|---|---|---|
| MN | Var_Input | ANY_ELEMENTARY | Lower limit |
| IN | Var_Input | ANY_ELEMENTARY | Input value |
| MX | Var_Input | ANY_ELEMENTARY | Upper limit |
| Function name | Return value | ANY_ELEMENTARY | Output result |
warning
- ANY_ELEMENTARY includes all basic types (bit strings, integers, floating point numbers, characters and strings, times and dates)
- The parameter types of parameters MN, IN, MX and OUT must be the same, otherwise the function cannot be executed
- MN must not be larger than MX
Example
- LD sample animation is as follows:

- ST example is shown in the following code:
OUT:=LIMIT(MN:=10,IN:=100,MX:=10000);
OUT2:=LIMIT(MN:=10,IN:=10,MX:=10000);
OUT3:=LIMIT(MN:=10,IN:=20000,MX:=10000);