Lessons · Industrial control · what a PLC does
What a PLC does
A PLC reads its inputs, runs the whole program top to bottom, writes its outputs, and immediately does it all again, many times a second, forever.
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
Everything surprising about PLC programming follows from that loop: a rung is not 'run once', it is re-evaluated every scan, and the last write to an output is the one the world sees.
How to think about it
Picture the loop: read, solve every rung, write, repeat. When a rung misbehaves, ask what it does on the scan after this one, and the one after that.
Worked example
[StartButton] (Motor)Every scan: read StartButton, set Motor to match. Release the button and the next scan turns the motor off.
Your turn
A lamp that follows a switch, every scan.
[Switch] ()
Run a rung and watch the scan
The trap
Nothing in a PLC program runs once. A rung that sets a value keeps setting it on every scan, which is why a plain coil cannot remember anything.