PLC Compare Instructions: EQU, NEQ, LES, GRT Explained with Ladder Examples

Share:
DCS and Automation
PLC Compare Instructions: EQU, NEQ, LES, GRT

PLC compare instructions test a condition between two values and return true or false. A PLC compare instruction is one of the most frequently used building blocks in Ladder Logic.

Every alarm setpoint, every process limit, and every conditional output uses a PLC compare instruction to make its decision.

This guide covers EQU, NEQ, LES, and GRT with ladder rung examples, a worked application, and a live compare instruction simulator.

EQU Equal NEQ Not Equal LES Less Than GRT Greater Than

A PLC compare instruction acts like a contact in the rung. It passes power when its condition is true and blocks when false. The difference is that a PLC compare instruction compares numbers, not bit states.

PLC Compare Instructions: What They Do and Why They Matter

Hi everyone! Today we are going through the four most used PLC compare instructions in Ladder Logic -- EQU, NEQ, LES, and GRT. These instructions are behind almost every decision a PLC makes: is the tank full? Is the temperature too high? Has the counter reached its target? By the end of this article, you will know exactly how each one works and when to use it.
PLC Compare Instructions

Each PLC compare instruction sits on a rung exactly like a contact. When the comparison is true, power flows through it. When it is false, power is blocked -- just as a normally open contact blocks power when the bit is off.

The four core PLC compare instructions are EQU (Equal), NEQ (Not Equal), LES (Less Than), and GRT (Greater Than). Click any term to expand its definition.

EQU (Equal): The instruction is true when Source A equals Source B exactly. Used for checking exact count values, comparing register contents, or verifying that a process has reached a specific set value. Beware using EQU with REAL (floating point) values -- floating point arithmetic rarely produces exact equality.
NEQ (Not Equal): The instruction is true when Source A and Source B are different. The logical opposite of EQU. Used to detect a change in value, to keep a process running while a condition has not yet been met, or to guard against division by zero before a DIV rung.
LES (Less Than): The instruction is true when Source A is strictly less than Source B. Order matters -- Source A LES Source B is not the same as Source B LES Source A. Used for low limit alarms, process variable below setpoint checks, and fill to-level logic.
GRT (Greater Than): The instruction is true when Source A is strictly greater than Source B. Used for high limit alarms, overpressure detection, and triggering an action when a counter or accumulator exceeds a threshold.
True/False
A PLC compare instruction returns only true or false -- it does not change any register value
Source A
Must always be a register address -- cannot be a constant
Source B
Can be a register address or a constant (immediate value)
INT / REAL
Use INT for exact comparisons; use REAL with a tolerance band, not exact EQU
Advertisement

The 4 PLC Compare Instructions with Rung Examples

EQU -- Equal To

True when: Source A = Source B Use: exact value check, counter target reached

EQU passes power when Source A and Source B are exactly equal. It is most reliable with integer data types (INT, DINT).

With REAL registers, floating point rounding means two values may differ by a tiny amount. Use a tolerance band (GRT and LES together) instead of EQU for floating point comparisons.

(* Trigger fill valve when batch counter reaches target *) |--[EQU BatchCount = BatchTarget]--+--( FillValve_Open )--|

Practical use: checking a counter has reached its preset, verifying a recipe step number, confirming a position matches a home setpoint. Used alongside PLC counter instructions for end of count actions.

NEQ -- Not Equal To

True when: Source A ≠ Source B Use: change detection, division by zero guard

NEQ is the logical opposite PLC compare instruction to EQU. It passes power whenever the two values are different. It is true for every possible value except the one case where A equals B.

The most important use of NEQ is guarding a DIV rung against division by zero. An NEQ 0 contact before the DIV instruction prevents a PLC major fault.

See PLC memory addressing for how to structure intermediate registers.

(* Only divide when sample count is not zero *) |--[NEQ SampleCount = 0]-----------+[DIV]------------------| | | A: TempSum (REAL)| | | B: SampleCount | | | Dest: AvgTemp |

Practical use: division by zero protection, detecting when a value has changed from its previous scan (by comparing to a shadow register), keeping a process running while a condition is not yet satisfied.

LES -- Less Than

True when: Source A < Source B Use: low limit alarm, fill logic, minimum check

LES passes power when Source A is strictly less than Source B. Strictly means exactly less than -- if A equals B, LES is false. For a less than-or-equal comparison, use the LEQ instruction instead.

Source A is the value being tested. Source B is the limit or threshold.

Getting the order backwards gives opposite logic -- a common mistake on first use. Think of it as reading left to right: Source A is less than Source B.

(* Low level alarm: tank below minimum *) |--[LES TankLevel < LowLevelLimit]-+--( LowLevelAlarm )--|

Practical use: low pressure alarm, low temperature cutout, minimum speed check, confirming a register has not yet reached its target. Also used in pairs with GRT to create a tolerance band around a setpoint -- a technique used in simple bang bang temperature control.

GRT -- Greater Than

True when: Source A > Source B Use: high limit alarm, overpressure, max check

GRT passes power when Source A is strictly greater than Source B. It is the mirror of LES. For a greater than-or-equal comparison, use GEQ instead.

GRT is the workhorse PLC compare instruction for high limit alarms. Every high temperature alarm, high pressure trip, and maximum speed limit in a PLC program uses a GRT or GEQ rung to detect when the process variable has exceeded the setpoint.

(* High pressure alarm: process above safe limit *) |--[GRT ProcessPressure > HighPressLimit]+--( HighPressAlarm )--|(* Emergency shutdown if pressure exceeds trip level *) |--[GRT ProcessPressure > TripSetpoint]--+--( ESD_Trip )--------|

Practical use: high temperature alarm, overpressure trip, high level alarm, motor overcurrent detection, maximum batch weight check.

In safety applications, GRT feeds directly into a safety relay or SIL rated output module. See PLC timer instructions for adding a TON delay before the GRT output latches.

Advertisement

PLC Compare Instruction Simulator

Compare Instruction Result Checker
Enter Source A, Source B, and instruction -- see rung state and explanation
-
-

All 6 PLC Compare Instructions: Quick Reference

InstructionTrue WhenFalse WhenCommon Use
EQUA = BA not equal BCounter target reached, recipe step match
NEQA not equal BA = BDivision by zero guard, change detection
LESA strictly less than BA greater than or equal to BLow limit alarm, fill logic
GRTA strictly greater than BA less than or equal to BHigh limit alarm, overpressure trip
LEQA less than or equal to BA greater than BFill complete (reach or exceed target level)
GEQA greater than or equal to BA less than BMinimum speed confirmed, start permissive

Real-World Applications Using PLC Compare Instructions

Temperature Alarm and Control

GRT checks if temperature exceeds the high alarm setpoint. LES checks if it falls below the low alarm.

A tolerance band using both creates simple on off control: heater on when LES lower limit, heater off when GRT upper limit.

Batch Counter Target

EQU compares a batch counter to the target count. When the two are equal, the batch complete bit sets. Used directly with CTU counter instructions -- the counter accumulated value (ACC) is Source A, the preset (PRE) is Source B.

Alarm Delay with Timer

A GRT rung enables a TON timer. The timer output (DN bit) triggers the alarm. This prevents nuisance alarms from momentary spikes. The GRT detect the exceedance; the TON timer holds the condition for a defined period before latching the alarm.

Scaled Signal Quality Check

After scaling a raw ADC count, a PLC compare instruction verifies the result is within the valid engineering range.

A reading below 4 mA equivalent (LES lower limit) or above 20 mA equivalent (GRT upper limit) flags a sensor fault. See shift register patterns.

PLC compare instructions are rung contacts, not coils. They go on the left side of the rung and control whether power reaches a coil or output instruction on the right side. Multiple compare instructions can be placed in series (AND logic) or in parallel (OR logic) on the same rung -- exactly like any other contact. See the Ladder Logic for Beginners guide for how contacts combine in series and parallel.

Watch: PLC Compare Instructions LES, GRT, EQU, NEQ Explained

Advertisement

PLC Compare Instructions Questions

What is the difference between EQU and NEQ in Ladder Logic?
EQU is true when A equals B exactly. NEQ is true when they differ. NEQ is the logical inverse of EQU -- exactly one of them is true at any moment.
Can I use EQU to compare REAL (floating point) values?
Not reliably. Floating point rounding means two values that should be equal may differ at the bit level. Use LES and GRT together as a tolerance band instead of EQU.
Does Source A have to be a register address in a PLC compare instruction?
Yes. Source A must be a register address. Source B can be a register or an immediate constant -- a fixed rule on all major PLC platforms.
What is the difference between LES and LEQ?
LES is true when A is strictly less than B -- equal values return false. LEQ includes the equal case. Choose based on whether the boundary value should trigger the condition.
Where do PLC compare instructions sit on a Ladder Logic rung?
On the left side of the rung, like a contact. They pass power when true and block when false. Coils and outputs go on the right side.

External References

Advertisement

What We Learn Today

  • A PLC compare instruction acts like a contact -- true passes power, false blocks it
  • EQU: true when A = B. Use with INT/DINT; avoid for REAL values (use a tolerance band instead)
  • NEQ: true when A not equal B. Essential as a division by zero guard before any DIV rung
  • LES: true when A strictly less than B. Used for low limit alarms and fill to-level logic
  • GRT: true when A strictly greater than B. Used for high limit alarms and overpressure trips
  • Source A must be a register address. Source B can be a register or an immediate constant
“A PLC compare instruction is the PLC asking a question. The rung that follows is the answer -- and the action it triggers is the decision.”

Leave a Reply

Your email address will not be published. Required fields are marked *