CODESYS LIMIT

LIMIT is an IEC selection operator in the CODESYS development system that limits a value to a range. It is written as OUT := LIMIT(Min, IN, Max) and is equivalent to OUT := MIN(MAX(IN, Min), Max), so a value above Max returns Max and a value below Min returns Min. The source gives the example Var1 := LIMIT(30,90,80); which returns 80.

Source checked13/13 values · 2026-10-26

Specification

2 sources
Languagestructured text
CodeLIMIT
Groupselection operator
SyntaxOUT := LIMIT(Min, IN, Max)
DialectCODESYS

Parameters

NameDescriptionData type
MinLower limit for the result.
INValue to be limited.all
MaxUpper limit for the result.
OUTResult of the limiting operation.all

Study notes

  • LIMIT is described as an IEC selection operator and is used for limiting.
  • The call form is OUT := LIMIT(Min, IN, Max).
  • It is equivalent to OUT := MIN(MAX(IN, Min), Max).
  • Max is the upper limit of the result; if IN is above Max, LIMIT yields Max.
  • Min is the lower limit of the result; if IN is below Min, the result is Min.
  • Permitted data types for IN and OUT: all.
  • Example: Var1 := LIMIT(30,90,80); gives the result 80 in Var1.
↑↓ navigate↵ openesc close