Skip to main content

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

alt text

Parameter description

Interface variableDeclarationData typeDescription
MNVar_InputANY_ELEMENTARYLower limit
INVar_InputANY_ELEMENTARYInput value
MXVar_InputANY_ELEMENTARYUpper limit
Function nameReturn valueANY_ELEMENTARYOutput 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:

alt text

  • 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);