Comparison instructions and the analog value that is never equal
EQU, GRT, LES and the reason comparing analog values for equality does not work.
By the LADX engineering team
Short answer
Comparison instructions sit on the condition side and pass rung power when the comparison is true. EQU tests equality, NEQ inequality, GRT and LES magnitude, GEQ and LEQ inclusive magnitude. Testing an analog value for exact equality almost never works, because a measured value passes through the target between scans rather than landing on it.
Comparison instructions go on the condition side of a rung and pass power when the comparison holds. The instructions themselves are simple. Applying them to measured values is where the problems live.
Never compare an analog value for equality
A temperature rising through 80 degrees is sampled once per scan. It might read 79.6, then 80.4. It never reads exactly 80, so an equality test never fires and the machine waits forever.
Use greater-than or less-than for anything measured. Reserve equality for values your own program set, such as a step number or a mode.
Add a deadband
A value sitting near the threshold crosses it repeatedly, and an output driven directly from the comparison chatters at scan rate. Contactors do not enjoy this.
Turn on above 80 and off below 78. The two degrees of hysteresis costs nothing and turns a chattering output into a stable one.
Watch the data types
Comparing a REAL against an INT works on most platforms and quietly converts one of them first. Comparing a scaled REAL against a raw count compiles fine and is meaningless. Name the tags so the mismatch is visible in the rung.
Sources and further reading
- Rockwell Logix 5000 General Instructions referenceliterature.rockwellautomation.com
- Deadband and hysteresis in control (Wikipedia)en.wikipedia.org
Common questions
- Why does my equality comparison on an analog value never trigger?
- Because the value is sampled once per scan and rarely lands exactly on the target. A temperature rising through 80 degrees might read 79.6 on one scan and 80.4 on the next, never 80. Use a greater-than comparison, and add a deadband so the result does not chatter at the threshold.
- What is a deadband and why do I need one?
- A deadband is a gap between the point where a condition turns on and the point where it turns off. Without one, a value hovering at the threshold toggles the output every scan. Turning on at 80 and off at 78 gives two degrees of hysteresis and a stable output.
Keep reading
- Instructions
Studio 5000 MSG instruction: path, setup and error codes
How to set up a Studio 5000 MSG instruction: message types, the communication path, connected and cached messages, and what each .ERR and .EXERR code means.
- Instructions
Sequencer instructions, and the state machine that replaced them
SQO, SQI and SQL, what they were for, why they are rare in new code, and what to write instead.
- Instructions
FIFO and LIFO: tracking parts that are already moving
Load, unload, and the shift register they compete with. Where a queue is the right model, and where it silently loses a part.