Returns a value clamped to a minimum and maximum range.
Informal Syntax:
Formal Syntax:
LIMIT( MN:=expression, IN:=expression, MX:=expression )
Parameter | Type | Description |
---|---|---|
MN | ANY | The lowest allowed value. |
IN | ANY | The input value. |
MX | ANY | The highest allowed value. |
The value returned is the input parameter In limited to the range defined by parameters Min and Max.
Inputs MN, IN and MX can be any type. The type of the return value is the "highest" type of the inputs MN, IN and MX. For example, the following combination of inputs will result in a return type of DINT:
See Automatic Type Promotion for further information about how types are promoted.
Example | Return Value |
---|---|
LIMIT( 1, 0, 9 ) | DINT#1 |
LIMIT( MN:=-5, IN:=0, MX:=10 ) | DINT#0 |
LIMIT( MN:=-5, IN:=20, MX:=10 ) | DINT#10 |
IEC 61131-3 Second Edition: Table 27.3.
IEC 61131-3 Third Edition: Table 32.5.
To learn about other selection functions.
To learn about the different types supported by Fernhill SCADA.
To learn about other IEC 61131-3 Common Elements.
For the meaning of terms used in Fernhill SCADA.