Compare (input instruction)
NEQ: Not Equal
Passes power while A does not equal B.
Also called: not equal contact, compare contact, <> test, != test.
NEQ(a, b)What it does
NEQ is how a program notices that two things have drifted apart. The selected recipe against the loaded recipe, the commanded position against the actual one, the mode the operator asked for against the mode the machine is in: while they match the rung is quiet, and the moment they differ it acts.
It is also the honest way to write a catch-all. A step machine whose register somehow holds a number none of the steps expect does nothing at all, silently, which is the hardest kind of fault to find. One rung that faults on a step value outside the known set turns that silence into a message.
Like every compare it is level sensitive. NEQ stays true for as long as the two values differ, so if what you want is to act once when they start differing, put a ONS after it.
A rung you can run
The loaded recipe does not match the selected one
NEQ(Recipe_Loaded,Recipe_Selected)XIC(Cycle_Idle)OTE(Reload_Needed)
XIC(Reload_Needed)ONS(Load_PB)MOV(Recipe_Loaded,Recipe_Selected)While the two recipe numbers differ and the machine is idle, the reload prompt is on. Pressing Load_PB copies the selection into the loaded register, the two values match, NEQ goes false and the prompt clears itself. Change Recipe_Selected from the tag panel to watch the prompt appear.
Run this rung in the simulatorWhat it is called on other controllers
| Platform | Equivalent |
|---|---|
| Rockwell (Studio 5000) | NEQ |
| Siemens (TIA Portal) | The comparator box, set to CMP <> |
| Mitsubishi (GX Works) | LD<> / AND<> / OR<> |
| CODESYS and IEC 61131-3 | NE, or <> in structured text |
Common mistakes
- Comparing against a register that has not been loaded yet. Before the first recipe is written the stored value is 0, so NEQ is true and the mismatch alarm is on from power up. Gate it on the machine having run once.
- Expecting NEQ to fire once. It passes power the whole time the values differ, so an alarm counter driven straight off it counts every scan. Follow it with a one-shot.
Practise it
Interactive exercises that use NEQ. Each one checks your ladder against a real scan.
