The PLC Scan Cycle Explained
Short answer
- A PLC scan cycle is the loop in which the controller reads the inputs, executes the program once from top to bottom, writes the outputs, then handles housekeeping and communications before starting again.
- The program works from a frozen snapshot of the inputs, so every instruction sees the same picture of the plant and the logic stays predictable and testable.
- Rung order changes behaviour, scan time depends on program size, instructions, I/O points and communications load, and a watchdog timer faults the controller if a scan runs longer than its configured limit.
The scan cycle is the loop a PLC runs over and over: read the inputs, execute the program once from top to bottom, write the outputs, then do housekeeping and communications. One trip around that loop is a scan, and how long it takes is the scan time.
What are the four steps of a PLC scan?
- Read inputs. The controller copies the state of every physical input into an internal image table. From this point until the next scan, the program sees that frozen snapshot, not the live terminals.
- Execute the program. The logic runs in order, usually rung by rung or line by line. Results are written to the output image table and to internal memory as it goes.
- Update outputs. The output image table is copied to the physical output cards, and relays, contactors and valves change state.
- Housekeeping and communications. The controller services its programming port, network messages, HMI requests, diagnostics and any background tasks. Then it starts again.
Real controllers differ in detail. Some run communications in a separate time slice, some in parallel on a second processor, and some let you set how much of each scan is reserved for it. The pattern above is the one to hold in your head when something behaves oddly.
Why does a PLC use a snapshot instead of live inputs?
If the program read terminals directly, a sensor could change halfway through a scan and the same input would be true in one rung and false in the next. Two lines of logic that should agree would disagree. The input image prevents that. Every instruction in the scan sees the same picture of the plant, which makes the logic predictable and testable.
What is scan time and what does the watchdog do?
Scan time depends on the size of the program, the instructions used, the number of I/O points and the load from communications. Small programs on current processors scan in a few milliseconds or less. Large programs with heavy maths or lots of messaging take longer. Typical figures are only a guide, so read the actual value from the controller's status data or diagnostics.
Most controllers run a watchdog timer. If a scan takes longer than the configured limit, the controller assumes the program is stuck in a loop, faults and drops its outputs to a safe state. That is a feature. It is also why an unbounded loop or a very large array operation in the main routine can stop a machine.
Why does rung order matter in a PLC program?
Because the program runs top to bottom once per scan, the order of logic changes what happens. If rung 10 sets a bit and rung 4 reads it, rung 4 sees the new value on the next scan, not this one. Move them the other way round and the response is one scan faster. Usually that is harmless. It becomes a problem in a few places:
- Sequencers and state machines where several steps can fire in the same scan if the order allows it.
- One-shots and edge detection that compare a bit with its previous value.
- Counters and timers whose enable and reset rungs are placed in the wrong order.
- Double coils, where the same output is written in two places and only the last write before the output update wins.
The double-coil case causes more confused fault-finding than almost anything else. The first rung energises the output, the second de-energises it, the outputs update, and the machine behaves as if the first rung did nothing. Write each output once.
How long is PLC input-to-output latency in scans?
Worst-case response from a real-world change to a real-world output is longer than one scan. The signal can change just after the input read and wait almost a full scan before it is seen. Then it is processed, then the outputs update at the end of that scan. Add input filtering on the card, which is often a few milliseconds by default, and the output card's own switching time. A good working rule is to count roughly two scans plus filter time, then check against the datasheet.
| Source of delay | What it is | What you can do |
|---|---|---|
| Input filter | Debounce time set on the input card | Shorten it for fast sensors, if the card allows |
| Wait for next input read | Signal arrives just after the snapshot | Shorten scan time or use a fast task |
| Program execution | Logic is evaluated rung by rung | Keep time-critical logic early and simple |
| Output update | Image table written at end of scan | Use an immediate output instruction if supported |
| Output device | Relay or transistor switching time | Choose a faster output type where needed |
How do interrupts and immediate I/O speed up response?
When a normal scan is too slow, controllers offer ways around it. Immediate or "force-read" instructions read a physical input or write a physical output in the middle of the scan, bypassing the image table. Periodic tasks run a small routine on a fixed timer, interrupting the main program. Event tasks run when a particular input changes. High-speed counter inputs count pulses in hardware, so a fast encoder or flow pulse is not lost between scans.
Use these sparingly. Every interrupt breaks the clean snapshot idea, and shared data between the main program and an interrupt routine can be read half-updated. Keep interrupt code short and touch as little shared memory as possible.
What slows a PLC scan down?
- Large loops or indirect-addressed array operations in the continuous task.
- Too many string and file operations running every scan instead of on demand.
- Heavy communications load from HMIs, historians and other controllers polling at once.
- Slot-by-slot I/O updates over a slow remote I/O network.
- Online edits and constant program monitoring in some software.
The fix is usually to do less work per scan. Run calculations only when their inputs change, split slow jobs across several scans, and move non-urgent logic to a slower periodic task.
What do people commonly ask about PLC scans?
Does the PLC scan the whole program every time?
Normally yes, every enabled routine called from the main task. Instructions that are not true still take a little time to evaluate. Some routines can be skipped with jump or call logic, which saves scan time.
Is a faster scan always better?
Not always. It improves response, but past a point the limit is the input filter, the field device or the network. Measure where the delay really is before spending effort on it.
Why did my output flicker for one scan?
Often a double coil or a rung order issue, where a bit is set and cleared within the same scan. Search for every place the output or its controlling bit is written.
Can I read the scan time?
Yes. Most platforms report last, average and maximum scan time in status data. The maximum is the one to watch, because it shows the worst case.
Further reading on this site: what a PLC is; PLC I/O signal types; learning PLC programming; motion control vs PLC logic; industrial Ethernet protocols.
If you are replacing a PLC or I/O card and want to match the I/O type and response, send us what is on the nameplate and the application, and we can help find an equivalent.
Need a quote on a specific part?
Request a QuoteFrequently asked questions
What are the steps of a PLC scan cycle?
A scan has four steps. The controller reads inputs into an image table, executes the program in order, usually rung by rung, then updates outputs by copying the output image table to the physical output cards. Finally it services housekeeping and communications, such as the programming port, network messages, HMI requests and diagnostics, and starts again.
Why does a PLC use an input image table instead of live inputs?
The input image keeps every instruction in a scan working from the same picture of the plant. If the program read terminals directly, a sensor could change halfway through a scan and the same input would be true in one rung and false in the next. The snapshot makes the logic predictable and testable.
Why does rung order matter in a PLC program?
Rung order matters because the program runs top to bottom once per scan. If a later rung sets a bit that an earlier rung reads, the earlier rung sees the new value on the next scan, not the current one. It becomes a problem in sequencers, one-shots, counters and timers, and double coils, where only the last write before the output update wins.
What happens if a PLC scan takes too long?
Most controllers run a watchdog timer. If a scan takes longer than the configured limit, the controller assumes the program is stuck in a loop, faults and drops its outputs to a safe state. That is why an unbounded loop or a very large array operation in the main routine can stop a machine. The fix is usually to do less work per scan.
Industrial Automation & MRO Parts