Hone

Lessons · Industrial control · reading a ladder, rung by rung

Left to right, top to bottom

Each rung is read left (conditions) to right (action). The PLC solves the rungs from the top down, one after another, every scan.

Hone is a place to practise programming. This is one of its lessons, written out in full and free to read without an account.

What it is for

The order is not decoration. A rung reads whatever the rungs above it wrote this scan, and whatever the rungs below it wrote last scan. Move a rung and the timing changes.

How to think about it

Put a value's producer above its consumers when they must react in the same scan. When a one-scan delay is intended, put the reader above the writer and say so in a comment.

Worked example

[Sensor] (Seen)
Written first.
[Seen] (Act)
Reads this scan's Seen: Act follows Sensor in the same scan.

Your turn

Make the second rung react in the same scan.

[Sensor] (Seen)
[] (Act)

The trap

Swap the two rungs and Act lags Sensor by one scan. Harmless on a lamp, a real fault on anything counting or timing.

Practise reading a ladder, rung by rung on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.