Compare (input instruction)

LEQ: Less Than or Equal

Passes power while A is less than or equal to B.

Also called: less than or equal contact, compare contact, <= test.

LEQ(a, b)

What it does

LEQ passes power while the first value has not yet gone past the second. It is the natural way to write a call for heat, a call for fill, or any output that should keep running until the process value has reached its target.

Written as LEQ(Oven_Temp, Setpoint), the heater stays on right up to the setpoint and drops out the moment the temperature exceeds it. That is deliberately different from LES, which would drop out one unit early, and it is why on and off thresholds in real control are usually two different numbers rather than one.

Where LEQ bites is in pairs. LEQ and GEQ against the same number are both true when the value lands on it, so two rungs written that way can energise together for a scan. If the two outputs must never be on at once, one of the pair has to be strict.

A rung you can run

Call for heat up to the setpoint, with a hard limit above it

RUNG 1Oven_Temp≤ Temp_SetpointHeat_EnableHeater_ContactorRUNG 2Oven_Temp> Max_Safe_TempLOver_Temp_FaultRUNG 3Over_Temp_FaultUHeat_Enable
LEQ(Oven_Temp,Temp_Setpoint)XIC(Heat_Enable)OTE(Heater_Contactor)
GRT(Oven_Temp,Max_Safe_Temp)OTL(Over_Temp_Fault)
XIC(Over_Temp_Fault)OTU(Heat_Enable)

The heater runs while the temperature is at or below setpoint. Above the safe maximum a separate rung latches a fault and drops the enable, and because it is latched the fault stays after the oven has cooled, which is what you want from a trip. Set Temp_Setpoint and Max_Safe_Temp, turn on Heat_Enable, then drive Oven_Temp up through both.

Run this rung in the simulator

What it is called on other controllers

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

Common mistakes

  • Pairing LEQ with GEQ on the same threshold for two outputs that must never overlap, such as heat and cool. At the boundary both compares are true and both outputs come on. Make one of them strict, LES or GRT, or separate the thresholds.
  • Using a single threshold for on and off. Even when it is correct, it makes the output chatter around the setpoint. Real control turns on at one value and off at another, and the gap between them is the deadband.

Practise it

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

Related instructions

All ladder logic instructions