Compare (input instruction)
LES: Less Than
Passes power while A is less than B.
Also called: less than contact, compare contact, < test.
LES(a, b)What it does
LES is the mirror of GRT and the instruction behind most low alarms: low level, low stock, low pressure, below minimum speed. It passes power while the first value is strictly below the second.
Because it is strict, LES and GEQ make a clean pair around one threshold. LES(Level, 200) and GEQ(Level, 200) can never both be true and can never both be false, so two rungs written that way cover the whole range with no gap and no overlap. Pairing LES with LEQ, or GRT with GEQ, is what leaves a value that satisfies both.
A register holds 0 before anything has written to it, and 0 is less than almost everything. A low alarm built on LES is therefore true on the very first scan, before the sensor has been read, which is why real programs gate it.
A rung you can run
Two thresholds off one value
LES(Parts_Left,20)XIC(Level_Valid)OTE(Low_Stock_Lamp)
LES(Parts_Left,5)XIC(Level_Valid)OTE(Feeder_Stop)One measurement, two actions at two thresholds: warn at 20, stop at 5. Level_Valid is the gate that keeps both quiet until the reading means something. Turn Level_Valid on and wind Parts_Left down to watch the lamp come on first and the stop follow.
Run this rung in the simulatorWhat it is called on other controllers
| Platform | Equivalent |
|---|---|
| Rockwell (Studio 5000) | LES |
| Siemens (TIA Portal) | The comparator box, set to CMP < |
| Mitsubishi (GX Works) | LD< / AND< / OR< |
| CODESYS and IEC 61131-3 | LT, or < in structured text |
Common mistakes
- Letting a low alarm fire at power up. The register is 0 until the analog input updates, so LES sees a value below every threshold and the alarm latches before the machine has read anything. Gate it with a bit that says the readings are valid, or with a short TON.
- Using LES on a value that can go negative when you meant magnitude. A deviation of -30 is less than 5, so the rung passes when the error is large in the wrong direction. Take ABS first if what you mean is how far off it is.
Practise it
Interactive exercises that use LES. Each one checks your ladder against a real scan.
