A PLC does not react to an input the instant it changes. It works in a loop called the scan cycle. Once you understand the scan, a lot of confusing behaviour suddenly makes sense.
The four steps
- Read inputs. The CPU copies the state of every physical input into an area of memory called the input image table. From now until the next scan, the program uses this snapshot.
- Execute the program. The CPU solves the logic from the first rung to the last, left to right, top to bottom. Results go into the output image table in memory, not straight to the terminals.
- Write outputs. The output image is copied to the physical output terminals all at once.
- Housekeeping. Communication with the laptop and HMI, self-diagnostics, and updating the clock.
Then it starts again. A small program on a modern compact PLC scans in around 1 ms; big programs take 10–50 ms. To a human pressing a button, that feels instant.
Why the snapshot matters
Because inputs are read once per scan, the program sees a stable picture. If an input flickered halfway through the logic, two rungs could otherwise disagree about whether a button was pressed. The image table prevents that.
The flip side: an input pulse shorter than one scan can be missed completely. A sensor that sees a fast-moving bottle for 0.5 ms may never be noticed by a 5 ms scan. That is why PLCs have special high-speed counter and interrupt inputs for fast events.
Rung order changes behaviour
Since rungs are solved top to bottom in one scan, a bit written on rung 5 is already updated when rung 6 reads it, but rung 4 will only see the new value on the next scan.
Here is a small example. Bit M0 is set by rung 1 and used by rung 2:
LD X0 ; rung 1: X0 copies to M0
OUT M0
LD M0 ; rung 2: M0 copies to Y0
OUT Y0
When X0 turns on, M0 and Y0 both turn on in the same scan. Swap the two rungs and Y0 turns on one scan later, because rung 2 runs before M0 is updated. One scan is only milliseconds, so this rarely matters for lamps, but it matters for pulses that last exactly one scan, which you will use for counters and sequences.
Rule of thumb: write your program in the order things happen on the machine, and write each output coil only once. If two rungs drive the same coil, the last rung in the scan always wins, which is a common source of “my output won’t turn on” calls.
Scan time and the watchdog
The PLC measures how long each scan takes. The watchdog is a timer that trips if one scan takes too long, usually because of an endless loop in the program. When it trips, the CPU goes to STOP and turns the outputs off. That is a safety feature: a frozen controller with outputs stuck on is far more dangerous than a stopped one.
Your programming software shows the current, minimum and maximum scan time. It is worth checking on any machine you commission.
See it in the simulator
The Ladder Lab below scans every 50 ms. Hold START and watch the rung turn teal as power flows; the motor output follows in the same scan. Release START and the motor stays on: that is the seal-in contact you will build yourself in lesson 7.
Program listing (IL)
LD X0
OR Y0
ANI X1
OUT Y0Frequently asked questions
What is a typical PLC scan time?
For small and medium programs on modern compact PLCs, about 1 to 20 milliseconds. Very large programs or slow older CPUs can take 50 ms or more.
Can a PLC miss an input?
Yes, if the input turns on and off again within one scan. Use high-speed counter inputs, interrupts or input pulse catch features for very short signals.
