LIMIT - Clamp a value within a defined minimum and maximum

Help Contents


Returns a value clamped to a minimum and maximum range.

Informal Syntax:


Formal Syntax:

LIMIT( MN:=expression, IN:=expression, MX:=expression )


MNANYThe lowest allowed value.
INANYThe input value.
MXANYThe highest allowed value.

Return 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.


ExampleReturn 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

Standards Compliance

Table 27.3 - IEC 61131-3 Second Edition.

Table 32.5 - IEC 61131-3 Third Edition.

Further Information

Selection Functions

To learn about other selection functions.

Elementary Data Types

To learn about the different types supported by Fernhill SCADA.

Common Elements

To learn about other IEC 61131-3 Common Elements.


For the meaning of terms used in Fernhill SCADA.