LIMIT — Range Check
LIMIT in rungs.dev passes power when a test value is inside [lowLimit, highLimit]; if lowLimit is greater than highLimit, the bounds reverse to outside-the-band.
LIMIT
Low Limit
lowLimit
Test
test
High Limit
highLimit
Passes power when test is inside the inclusive range [lowLimit, highLimit]; bounds reverse to outside-the-band when lowLimit > highLimit.
Operands
| Name | Type |
|---|---|
lowLimit | DINT | REAL |
test | DINT | REAL |
highLimit | DINT | REAL |
How It Works
- When
lowLimit≤highLimit(the usual case): the rung passes whenlowLimit≤test≤highLimit. Bounds are inclusive. - When
lowLimit>highLimit(wraparound): the rung passes whentest≥lowLimitortest≤highLimit. Useful for ranges that span a wrap boundary, e.g. an angle check across0°. - If any operand is
NaN, the rung is blocked.
Example — Value in Range
Energize InRange while Pressure is between 20 and 100.
0
LIMIT
Low Limit
20
Test
Pressure
High Limit
100
InRange
Equivalent to GE(Pressure, 20) LE(Pressure, 100) OTE(InRange) but in one instruction.
Example — Wraparound
Energize NearHome when a heading is within ±10° of 0°. Use the wraparound form:
0
LIMIT
Low Limit
350
Test
Heading
High Limit
10
NearHome
Here lowLimit = 350 and highLimit = 10, so the rung passes when Heading ≥ 350 or Heading ≤ 10.
Example — Out of Range
Swap the bounds to get "outside the band". LIMIT(20, Sensor, 80) passes when Sensor is between 20 and 80; LIMIT(80, Sensor, 20) passes when it is below 20 or above 80.
0
LIMIT
Low Limit
20
Test
Sensor
High Limit
80
InRange
1
LIMIT
Low Limit
80
Test
Sensor
High Limit
20
OutOfRange
Boundaries overlap
Both forms are inclusive, so at the exact bounds (Sensor = 20 or Sensor = 80) InRange and OutOfRange are both 1. If the two must be mutually exclusive, use GT / LT on one side instead of a second LIMIT.
Common Mistakes
- Using
LIMITon aBOOLtag — numeric operands only. For boolean gating, useXIC/XIO. - Forgetting that a single-band check with
low > highflips to wraparound semantics. If you just want "between", always passlow ≤ high.
Related
- Compare instructions —
GE/LEpair with more flexibility - Math instructions — compute values to compare
- Bit instructions — boolean examine
Compare — EQ / NE / GT / GE / LT / LE
Reference for Ladder Logic compare instructions in rungs.dev — EQ, NE, GT, GE, LT, LE — that pass power along a rung when the numeric relationship holds.
Math — ADD / SUB / MUL / DIV / MOD
Reference for Ladder Logic math instructions in rungs.dev — ADD, SUB, MUL, DIV, MOD — performing arithmetic on two sources and writing the result to a destination tag.