Limit (LIMIT)

The LIMIT instruction tests if the Test value is within the range of the Low and High Limits as indicated in the LIMIT Flow Chart (True).
If any operand is Not A Number (NAN), the .EnableOut is cleared to false.
TIP: The mnemonic for this instruction has changed from LIM to LIMIT.
Available Languages
Ladder Diagram
LIMIT ladder instruction
Operands
There are data conversion rules for mixing numeric data types within an instruction. See Data conversions.
Ladder Diagram
Operand
Data Type
Format
Description
Low Limit
SINT
INT
DINT
LINT
USINT
UINT
UDINT
ULINT
REAL
LREAL
immediate
tag
Value of lower limit.
Test
SINT
INT
DINT
LINT
USINT
UINT
UDINT
ULINT
REAL
LREAL
immediate
tag
Value to test against limits.
High Limit
SINT
INT
DINT
LINT
USINT
UINT
UDINT
ULINT
REAL
LREAL
immediate
tag
Value of upper limit.
Operation
This section illustrates the operation for the LIMIT instruction.
RSL5K_LIM_description for v30
If Low Limit:
And if the test value is:
Then the EnableOut is:
< or = to High Limit
equal to or between limits
not equal to or outside limits
true
false
> High Limit
equal to or outside limits
not equal to or inside limits
true
false
Signed integers transition from the maximum positive number to the maximum negative number when the most significant bit is true. For example, in 16-bit integers (INT type), the maximum positive integer is 32,767, which is represented in hexadecimal as 16#7FFF (bits 0 through 14 are all true). If that number increments by one, the result is 16#8000 (bit 15 is true). For signed integers, hexadecimal 16#8000 is equal to -32,768 decimal. Incrementing from this point on until all 16 bits are set ends up at 16#FFFF, which is equal to -1 decimal.
This can be shown as a circular number line. The LIMIT instruction starts at the Low Limit and increments clockwise until it reaches the High Limit. Any Test value in the clockwise range from the Low Limit to the High Limit sets the EnableOut to true. Any Test value in the clockwise range from the High Limit to the Low Limit clears the EnableOut to false.
If any operand is Not A Number (NAN), the .EnableOut is cleared to false.
Affects Math Status Flags
No
Major/Minor Faults
None specific to this instruction. See Index through arrays for array-indexing faults.
Execution
Ladder Diagram
Condition/State
Action Taken
Prescan
N/A
Rung-condition-in is false
Set Rung-condition-out to Rung-condition-in.
Rung-condition-in is true
See
LIMIT Flow Chart (True)
If output is true
Set Rung-condition-out to true.
else
Clear Rung-condition-out to false.
LIMIT Flow Chart (True)
RSL5K_LIMIT Flow Chart True_v31
Examples
Example 1: Low Limit <= High Limit
When Test value is equal to or greater than Low Limit, and Test value is less than or equal to High Limit, light_1 is set.
Ladder Diagram
LIMIT ladder instruction example less than
Example 2: Low Limit > High Limit
Ladder Diagram
LIMIT ladder instruction example greater than low limit
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.