Compare Instructions
Compare two numeric values and pass power along the rung if the relationship holds. Compare instructions act like contacts — place them on the left side of a rung.
Available Compare Instructions
| Instruction | Symbol | Purpose |
|---|---|---|
| EQ | EQ Source A sourceA Source B sourceB | Passes power when sourceA equals sourceB. |
| NE | NE Source A sourceA Source B sourceB | Passes power when sourceA does not equal sourceB. |
| GT | GT Source A sourceA Source B sourceB | Passes power when sourceA is greater than sourceB. |
| GE | GE Source A sourceA Source B sourceB | Passes power when sourceA is greater than or equal to sourceB. |
| LT | LT Source A sourceA Source B sourceB | Passes power when sourceA is less than sourceB. |
| LE | LE Source A sourceA Source B sourceB | Passes power when sourceA is less than or equal to sourceB. |
Operands
| Name | Type |
|---|---|
sourceA | DINT | REAL |
sourceB | DINT | REAL |
Compare instructions do not operate on BOOL — use XIC / XIO for boolean checks.
Example — Temperature Alarm
Turn on a cooling fan when temperature exceeds the setpoint.
GT(Temperature,75)OTE(Fan)
Example — Value in Range
Energize InRange only when Pressure is between 20 and 100 inclusive.
GE(Pressure,20)LE(Pressure,100)OTE(InRange)
Common Mistakes
- Comparing a
BOOLtag — useXIC/XIOinstead. - Using
EQonREALvalues — fragile due to floating-point rounding. PreferGE/LEwith a small tolerance, orLIMIT.
Related
- LIMIT — range check in a single instruction
- Math instructions — compute values before comparing them
- MOVE — copy a value into a destination
- Bit instructions — boolean examine