Lessons · Industrial control · set and reset in the same scan
Set and reset in the same scan
When a latch and its unlatch both fire in one scan, both run, in order, and the lower one wins.
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
It decides what the machine does when a set and a reset arrive together, which on a real machine happens more often than anybody expects.
How to think about it
Choose it deliberately and write a comment saying you did. Putting the safe result last means a simultaneous set and reset lands safe.
Worked example
[A] (L Lamp) [B] (U Lamp)A and B both true, one scan. Lamp: 0
[B] (U Lamp) [A] (L Lamp)The same two, swapped. Lamp: 1
Your turn
Of a latch and an unlatch firing together, which wins?
the one
Run a rung and watch the scan
The trap
Deciding this by accident is how a machine ends up choosing the dangerous option when two things go wrong at once.
Practise set and reset in the same scan on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.