LIMIT — Range Check
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.
LIMIT(20,Pressure,100)OTE(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:
LIMIT(350,Heading,10)OTE(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.
LIMIT(20,Sensor,80)OTE(InRange);LIMIT(80,Sensor,20)OTE(OutOfRange)
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