Compare (input instruction)

EQU: Equal

Passes power while A exactly equals B.

Also called: equal contact, compare contact, = test, == test.

EQU(a, b)

What it does

EQU tests for one exact value. That makes it the wrong instruction for anything measured and the right instruction for anything your own program wrote.

The place it belongs is a step register. A sequence built as a number, where one rung runs at step 10, the next at step 20 and so on, is the clearest structure a beginner can put on a machine, and every one of those rungs starts with EQU(Step, 20). It can be exact because your own MOV instructions put those numbers there, so they land on the values you test for.

The place it does not belong is a measurement. A position that reads 28, then 31, then 34 never equals 30, and a rung waiting for EQU(Position, 30) waits for ever. Nothing looks wrong: the logic is correct, the value simply steps over the one number you asked about. Use GEQ for anything that arrives from the field.

A rung you can run

A step sequence, the one place EQU is exactly right

RUNG 1Step= 0Start_PBMOV Step:= 10RUNG 2Step= 10TON Dwell3000 msRUNG 3Step= 10Dwell.DNMOV Step:= 20RUNG 4Step= 20Eject_SolRUNG 5Step= 20Eject_DoneMOV Step:= 0
EQU(Step,0)XIC(Start_PB)MOV(Step,10)
EQU(Step,10)TON(Dwell,3000)
EQU(Step,10)XIC(Dwell.DN)MOV(Step,20)
EQU(Step,20)OTE(Eject_Sol)
EQU(Step,20)XIC(Eject_Done)MOV(Step,0)

Step is 0 at power up, so the machine is idle and waiting. Press Start_PB and it moves to 10, where a timer runs for three seconds; then to 20, where the eject solenoid is on until Eject_Done comes back; then home to 0. Exactly one step is active at a time, and every value in the register was written by a MOV in this program, which is why EQU can be trusted here.

Run this rung in the simulator

What it is called on other controllers

PlatformEquivalent
Rockwell (Studio 5000)EQU
Siemens (TIA Portal)The comparator box, set to CMP ==
Mitsubishi (GX Works)LD= / AND= / OR=
CODESYS and IEC 61131-3EQ, or = in structured text

Common mistakes

  • Testing a measured value for equality. Analog values, encoder counts and anything scaled move in jumps larger than one and can skip your number entirely. This is the classic machine that gets to within a whisker of the target and then just stops. Use GEQ or LIM.
  • Writing the step number from more than one place. If two rungs can both move the sequence on, the step register lands somewhere neither of them expected, and every EQU in the routine goes false at once.

Practise it

Interactive exercises that use EQU. Each one checks your ladder against a real scan.

Related instructions

All ladder logic instructions