Understanding the PLC scan cycle is foundational to writing reliable control logic. Many automation bugs – from missed pulses to incorrect timing – stem from a misunderstanding of how PLCs execute code.
Four Phases of Every Scan
The Classic Scan Cycle
A traditional PLC executes four steps in a continuous loop:
- Input Scan: Read all physical inputs (DI, AI) into the input image table. This snapshot is used for the entire logic scan.
- Logic Solve: Execute the program from top to bottom, using the input image. Update the output image table as logic executes.
- Output Scan: Write the output image table to physical outputs (DO, AO).
- Housekeeping: Communication with HMI/SCADA, self-diagnostics, watchdog refresh.
The total time for one complete cycle is the scan time. Typical scan times range from 1ms to 50ms depending on program complexity and processor speed.
Why Input Snapshot Matters
Because inputs are read once at the start of the scan, a physical input that transitions ON and OFF within a single scan may be missed entirely. This is the source of the classic fast pulse problem: a proximity sensor triggering a count that the PLC never registers.
Solutions include: reducing scan time, using hardware interrupt inputs (HSC – High Speed Counter), or using physical latch inputs that hold state until the PLC reads them.
Immediate I/O Instructions
Most PLCs provide immediate I/O instructions that read or write a specific I/O point mid-scan, bypassing the normal scan cycle. Use these sparingly – they add scan time and can create logic ordering issues if not carefully managed.
Task-Based Execution
Modern PLCs (Rockwell ControlLogix, Siemens S7-1500, Codesys-based) use task-based execution rather than a fixed scan cycle:
- Periodic tasks: Execute at a fixed interval (e.g., 10ms) regardless of other tasks
- Event tasks: Triggered by a hardware interrupt or software event
- Continuous task: Runs in background, filling remaining CPU time
Task priorities ensure time-critical code (safety interlock, servo control) runs reliably even when background tasks are complex.
Watchdog Timers
Every PLC has a watchdog timer that must be refreshed each scan. If the program hangs or the scan time exceeds the watchdog limit, the PLC faults and sets outputs to their safe state (typically de-energised). Program the watchdog timeout to be 2-3x the normal maximum scan time to avoid nuisance faults while still detecting genuine hangs.


