The PLC Scan Cycle: Why Rung Order Changes What Your Program Does

The cycle
A PLC does the same four things forever:
- Read inputs. Every physical input is sampled and copied into an internal image table.
- Execute the program. Rung 1 to the last rung, top to bottom, left to right. The logic reads the image table, not the physical terminals.
- Write outputs. The output image table is copied to the physical output cards, all at once.
- Housekeeping. Communications, diagnostics, watchdog.
Then it starts again. One pass is a scan; the time it takes is the scan time, typically a few milliseconds.
Almost every confusing PLC behaviour comes from one of two facts about this cycle.
Fact one: the program reads a snapshot, not the wire
Your logic does not look at the input terminal. It looks at a copy taken at the start of the scan.
So if an input changes halfway through the program, nothing in that scan sees it. Rung 5 and rung 500 both see the value that was true when the scan began. The change is picked up next scan.
This is deliberate, and it is a feature: it means the input cannot change under your feet partway through the logic, which would make behaviour depend on where in the program you happened to read it. Consistency within a scan is worth more than immediacy.
The practical consequence: a pulse shorter than one scan time can be missed entirely. If a proximity sensor sees a part for 2 ms and your scan is 8 ms, some parts will not register. The fixes are a high-speed input, a hardware latch, or an interrupt, not more rungs.
Fact two: the last write wins
Outputs are written at the end of the scan, so only the final state of each output bit in the image table reaches the field.
If rung 1 sets Motor and rung 50 resets it, the motor is off. Rung 50 ran later and overwrote the bit. The output card never sees the intermediate state.
This is why:
- Duplicate coils are a bug. Two rungs both writing the same output means one of them is decorative and you will not notice which until the machine misbehaves. Most engineering tools warn about duplicate coils. Take the warning seriously.
- Rung order is design, not layout. Moving a rung can change behaviour. Ordering is part of the program, not cosmetics.
- Interlocks belong late or in series. If a safety condition must dominate, it must either be in series with the coil or applied after any rung that could set it.
Scan time, and what changes it
Scan time is not constant. It grows with:
- Program length actually executed. Skipped branches and unexecuted function blocks cost little.
- Expensive instructions: floating point maths, PID, string handling, communications blocks.
- Communications load, especially lots of SCADA polling.
Most controllers expose the current, minimum and maximum scan time. Watch the maximum, not the average: a program that averages 4 ms but peaks at 60 ms when a recipe loads will produce faults that only happen at changeover, which is the worst kind to diagnose.
The watchdog trips the processor if a scan exceeds a configured limit, on the reasonable assumption that a program stuck in a loop is more dangerous than a stopped machine.
Where this shows up in interviews
"Explain the scan cycle" is a standard opener. The definition is easy and everybody has it. What distinguishes an answer is the consequence:
Read inputs to an image table, execute top to bottom, write outputs, then housekeeping. Because the logic reads a snapshot, an input changing mid-scan is not seen until the next scan, so pulses shorter than the scan time can be missed. And because outputs are written at the end, if the same coil is written on two rungs the later one wins, which is why duplicate coils are a bug and why rung order is part of the design.
That answer takes twenty seconds and tells the interviewer you have debugged something real.
Our free interview question prep tool has this under PLC fundamentals with the follow-ups interviewers use.
Structured Text and other languages
The scan model is the same regardless of language. Structured Text executes in order, function blocks execute in the order they are called, and the same last-write-wins rule applies. Choosing ST over ladder does not exempt you from thinking about execution order. See Structured Text vs ladder.
See it happen
Watching a scan is hard to imagine and easy to observe: put a watch table on a bit set in one rung and reset in a later one, and see that the field device never moves. On the Automation Engineer Program you spend the first phase online with real controllers doing exactly this, which is why the concept stops being abstract.
Related: The seal-in circuit, PLC timer types.


