{"data":{"slug":"plc-scan-cycle-task-execution","title":"PLC Scan Cycle and Task Execution","summary":"The PLC scan cycle is the fundamental execution model of every programmable logic controller.","category":{"slug":"automation-systems","name":"Automation Systems"},"url":"https://wiki.aspotomasyon.com/article/plc-scan-cycle-task-execution","markdown_url":"https://wiki.aspotomasyon.com/article/plc-scan-cycle-task-execution.md","api_url":"https://wiki.aspotomasyon.com/api/v1/articles/plc-scan-cycle-task-execution","published":"2026-08-06T12:26:37+00:00","modified":"2026-09-13T11:07:23+00:00","reading_minutes":5,"word_count":933,"image":"https://wiki.aspotomasyon.com/assets/social/plc-scan-cycle-task-execution-8565376a0721.png","html":"<p>The <strong>PLC scan cycle</strong> is the fundamental execution model of every programmable logic controller. Unlike a general-purpose computer, which runs many programs concurrently under an operating system, a PLC executes a single control program in a continuous, repeating loop. Understanding this loop — what happens in each phase, how long it takes, and how to design logic around it — is essential for writing reliable control programs and for diagnosing timing-related faults on the plant floor.</p><figure class=\"article-figure\"><img src=\"https://wiki.aspotomasyon.com/assets/diagrams/automation-systems-context.svg\" width=\"1100\" height=\"460\" loading=\"lazy\" decoding=\"async\" alt=\"Conceptual control-system layers. Safety functions, communication paths, and redundancy must be designed for the application; the diagram is not a wiring or safety design.\"><figcaption>Conceptual control-system layers. Safety functions, communication paths, and redundancy must be designed for the application; the diagram is not a wiring or safety design. <a href=\"https://wiki.aspotomasyon.com/assets/diagrams/automation-systems-context.svg\" target=\"_blank\" rel=\"noopener\">View full size</a></figcaption></figure>\n\n<h2 id=\"the-four-phases-of-a-scan\">The Four Phases of a Scan</h2>\n\n<p>A typical PLC scan consists of four phases executed in strict order:</p>\n\n<ol>\n  <li><strong>Read inputs</strong> — the CPU copies the physical state of all input modules into an internal input image table in memory.</li>\n  <li><strong>Execute program</strong> — the CPU runs the user program sequentially, reading and writing only to the image tables, never directly to the physical modules.</li>\n  <li><strong>Write outputs</strong> — the output image table is copied to the physical output modules.</li>\n  <li><strong>Housekeeping</strong> — communication with HMI/SCADA, programming tools, and other CPUs; diagnostics; self-test.</li>\n</ol>\n\n<p>Using image tables means that a program reads a <em>consistent snapshot</em> of the inputs for the whole scan. If an input changes mid-scan, the change is not seen until the next scan. This consistency is intentional: it makes program behavior deterministic and much easier to reason about.</p>\n\n<h2 id=\"scan-time-and-its-limits\">Scan Time and Its Limits</h2>\n\n<p>Scan time is the total time for one complete cycle and is typically measured in milliseconds. A small program on a modern PLC may scan in under 1 ms; a large program with extensive analog processing may take 10–50 ms. Key factors that increase scan time:</p>\n\n<ul>\n  <li>Program size and instruction mix (floating-point math and string operations are slower than bit logic)</li>\n  <li>Number of I/O points, especially analog and high-speed modules</li>\n  <li>Communication tasks: HMI polling, SCADA traffic, peer-to-peer messaging, web servers</li>\n  <li>Diagnostics and trend buffers enabled on large tag sets</li>\n</ul>\n\n<p>Every PLC has a configurable <strong>watchdog timer</strong>. If a scan exceeds the watchdog value, the CPU typically stops program execution, sets the outputs to a safe state, and reports a fault. The watchdog is a safety mechanism, not a tuning tool: it should be set generously above the observed maximum scan time so that occasional communication spikes do not trip it.</p>\n\n<h2 id=\"task-models-cyclic-periodic-and-event-driven\">Task Models: Cyclic, Periodic, and Event-Driven</h2>\n\n<p>Modern controllers (IEC 61131-3 based, plus vendor platforms such as Siemens, Rockwell, and ABB) often support several task types instead of a single scan:</p>\n\n<table>\n  <thead>\n    <tr><th>Task type</th><th>Execution trigger</th><th>Typical use</th></tr>\n  </thead>\n  <tbody>\n    <tr><td>Cyclic (free-running)</td><td>Continuously, as fast as possible</td><td>Main machine logic</td></tr>\n    <tr><td>Periodic (fixed interval)</td><td>Every configured time, e.g. 10 ms, 100 ms</td><td>Analog control loops, sequence steps</td></tr>\n    <tr><td>Event-driven</td><td>On a hardware or software event</td><td>Fast counting, interrupts, motion sync</td></tr>\n  </tbody>\n</table>\n\n<p>Periodic tasks are important for control loops because the sample time becomes deterministic: a PID loop executed in a 100 ms periodic task always samples every 100 ms regardless of what the cyclic task is doing. Mixing tasks requires care with shared data — use <em>handshakes, semaphores, or synchronized copies</em> when a fast task and a slow task access the same tag.</p>\n\n<h2 id=\"determinism-and-io-response-time\">Determinism and I/O Response Time</h2>\n\n<p>The worst-case response time from a physical input change to a physical output change is roughly <em>two scan cycles</em>: the input is captured at the start of scan N, the program reacts, and the output is written at the end of scan N (or the input arrives just after the input read, pushing the response to scan N+1). This figure matters for safety and for fast processes. When a response must be faster than the scan allows, use:</p>\n\n<ul>\n  <li>Hardware interrupt inputs or high-speed counters that bypass the scan</li>\n  <li>Dedicated fast tasks (periodic or event-driven)</li>\n  <li>Outputs with hardware interlocking (e.g., a hardwired e-stop chain)</li>\n</ul>\n\n<p>For safety-related functions, always use certified safety controllers and hardwired safety circuits — do not rely on scan timing for personnel protection.</p>\n\n<h2 id=\"design-practices-around-the-scan\">Design Practices Around the Scan</h2>\n\n<ul>\n  <li><strong>Keep the critical path short.</strong> Move slow operations (string formatting, large data moves, file access) into slower tasks or background routines.</li>\n  <li><strong>Use edge detection consistently.</strong> A one-shot (rising-edge) instruction is evaluated once per scan; verify the scan rate matches your expectation of \"once\".</li>\n  <li><strong>Monitor scan time in the HMI.</strong> Trending scan time over weeks reveals creeping load from added logic or tags.</li>\n  <li><strong>Watch communication-induced jitter.</strong> Heavy HMI traffic can stretch scans; use scheduled/cyclic communication where the platform supports it.</li>\n  <li><strong>Document the task model.</strong> The maintenance engineer who inherits the machine needs to know which task runs what.</li>\n</ul>\n\n<h2 id=\"summary\">Summary</h2>\n\n<p>The scan cycle is the heartbeat of PLC operation. Designing programs that respect the read–execute–write model, choosing the right task type for each function, and monitoring scan time are basic but high-value habits. They prevent the classic field problems of intermittent timing faults, missed events, and control loops that behave differently in simulation than on the machine.</p><section class=\"engineering-check\"><h2 id=\"apply-this-to-your-project\">Apply this to your project</h2><ul><li>Define the process states, timing requirements, and permitted behavior after a controller or communication failure.</li><li>List controller, I/O, network, software, and license dependencies before choosing an architecture.</li><li>Record acceptance results and prove that the delivered configuration can be restored from the handover package.</li></ul><p><a href=\"https://wiki.aspotomasyon.com/guides\">Follow an ASP project guide</a> to connect the fundamentals with implementation and acceptance.</p></section><figure class=\"article-figure\"><img src=\"https://wiki.aspotomasyon.com/assets/diagrams/automation-systems-review.svg\" width=\"1100\" height=\"460\" loading=\"lazy\" decoding=\"async\" alt=\"Engineering review sequence: Requirements → Engineering → Acceptance → Handover. Keep the recorded evidence with the accepted configuration.\"><figcaption>Engineering review sequence: Requirements → Engineering → Acceptance → Handover. Keep the recorded evidence with the accepted configuration. <a href=\"https://wiki.aspotomasyon.com/assets/diagrams/automation-systems-review.svg\" target=\"_blank\" rel=\"noopener\">View full size</a></figcaption></figure><h2 id=\"primary-references-and-further-reading\">Primary references and further reading</h2><p>Use the original specifications and product documentation for implementation details. The examples in this guide are illustrative engineering scenarios, not published project results.</p><ul><li><a href=\"https://new.abb.com/control-systems/system-800xa\" rel=\"noopener noreferrer\" target=\"_blank\">ABB — System 800xA architecture and product documentation</a></li><li><a href=\"https://csrc.nist.gov/pubs/sp/800/82/r3/final\" rel=\"noopener noreferrer\" target=\"_blank\">NIST SP 800-82 Rev. 3 — OT architecture and security guidance</a></li></ul><!-- asp-editorial-202609 -->","markdown":"# PLC Scan Cycle and Task Execution\n\n> The PLC scan cycle is the fundamental execution model of every programmable logic controller.\n\n- Canonical URL: https://wiki.aspotomasyon.com/article/plc-scan-cycle-task-execution\n- Publisher: ASP OTOMASYON A.Ş. (ASP OTOMASYON Wiki)\n- Category: Automation Systems\n- Published: 2026-08-06 · Updated: 2026-09-13\n- Reading time: 5 min · Language: English\n\nThe **PLC scan cycle** is the fundamental execution model of every programmable logic controller. Unlike a general-purpose computer, which runs many programs concurrently under an operating system, a PLC executes a single control program in a continuous, repeating loop. Understanding this loop — what happens in each phase, how long it takes, and how to design logic around it — is essential for writing reliable control programs and for diagnosing timing-related faults on the plant floor.\n\n![Conceptual control-system layers. Safety functions, communication paths, and redundancy must be designed for the application; the diagram is not a wiring or safety design.](https://wiki.aspotomasyon.com/assets/diagrams/automation-systems-context.svg)\n\n*Conceptual control-system layers. Safety functions, communication paths, and redundancy must be designed for the application; the diagram is not a wiring or safety design.*\n\n## The Four Phases of a Scan\n\nA typical PLC scan consists of four phases executed in strict order:\n\n1. **Read inputs** — the CPU copies the physical state of all input modules into an internal input image table in memory.\n2. **Execute program** — the CPU runs the user program sequentially, reading and writing only to the image tables, never directly to the physical modules.\n3. **Write outputs** — the output image table is copied to the physical output modules.\n4. **Housekeeping** — communication with HMI/SCADA, programming tools, and other CPUs; diagnostics; self-test.\n\nUsing image tables means that a program reads a *consistent snapshot* of the inputs for the whole scan. If an input changes mid-scan, the change is not seen until the next scan. This consistency is intentional: it makes program behavior deterministic and much easier to reason about.\n\n## Scan Time and Its Limits\n\nScan time is the total time for one complete cycle and is typically measured in milliseconds. A small program on a modern PLC may scan in under 1 ms; a large program with extensive analog processing may take 10–50 ms. Key factors that increase scan time:\n\n- Program size and instruction mix (floating-point math and string operations are slower than bit logic)\n- Number of I/O points, especially analog and high-speed modules\n- Communication tasks: HMI polling, SCADA traffic, peer-to-peer messaging, web servers\n- Diagnostics and trend buffers enabled on large tag sets\n\nEvery PLC has a configurable **watchdog timer**. If a scan exceeds the watchdog value, the CPU typically stops program execution, sets the outputs to a safe state, and reports a fault. The watchdog is a safety mechanism, not a tuning tool: it should be set generously above the observed maximum scan time so that occasional communication spikes do not trip it.\n\n## Task Models: Cyclic, Periodic, and Event-Driven\n\nModern controllers (IEC 61131-3 based, plus vendor platforms such as Siemens, Rockwell, and ABB) often support several task types instead of a single scan:\n\n| Task type | Execution trigger | Typical use |\n| --- | --- | --- |\n| Cyclic (free-running) | Continuously, as fast as possible | Main machine logic |\n| Periodic (fixed interval) | Every configured time, e.g. 10 ms, 100 ms | Analog control loops, sequence steps |\n| Event-driven | On a hardware or software event | Fast counting, interrupts, motion sync |\n\nPeriodic tasks are important for control loops because the sample time becomes deterministic: a PID loop executed in a 100 ms periodic task always samples every 100 ms regardless of what the cyclic task is doing. Mixing tasks requires care with shared data — use *handshakes, semaphores, or synchronized copies* when a fast task and a slow task access the same tag.\n\n## Determinism and I/O Response Time\n\nThe worst-case response time from a physical input change to a physical output change is roughly *two scan cycles*: the input is captured at the start of scan N, the program reacts, and the output is written at the end of scan N (or the input arrives just after the input read, pushing the response to scan N+1). This figure matters for safety and for fast processes. When a response must be faster than the scan allows, use:\n\n- Hardware interrupt inputs or high-speed counters that bypass the scan\n- Dedicated fast tasks (periodic or event-driven)\n- Outputs with hardware interlocking (e.g., a hardwired e-stop chain)\n\nFor safety-related functions, always use certified safety controllers and hardwired safety circuits — do not rely on scan timing for personnel protection.\n\n## Design Practices Around the Scan\n\n- **Keep the critical path short.** Move slow operations (string formatting, large data moves, file access) into slower tasks or background routines.\n- **Use edge detection consistently.** A one-shot (rising-edge) instruction is evaluated once per scan; verify the scan rate matches your expectation of \"once\".\n- **Monitor scan time in the HMI.** Trending scan time over weeks reveals creeping load from added logic or tags.\n- **Watch communication-induced jitter.** Heavy HMI traffic can stretch scans; use scheduled/cyclic communication where the platform supports it.\n- **Document the task model.** The maintenance engineer who inherits the machine needs to know which task runs what.\n\n## Summary\n\nThe scan cycle is the heartbeat of PLC operation. Designing programs that respect the read–execute–write model, choosing the right task type for each function, and monitoring scan time are basic but high-value habits. They prevent the classic field problems of intermittent timing faults, missed events, and control loops that behave differently in simulation than on the machine.\n\n## Apply this to your project\n\n- Define the process states, timing requirements, and permitted behavior after a controller or communication failure.\n- List controller, I/O, network, software, and license dependencies before choosing an architecture.\n- Record acceptance results and prove that the delivered configuration can be restored from the handover package.\n\n[Follow an ASP project guide](https://wiki.aspotomasyon.com/guides) to connect the fundamentals with implementation and acceptance.\n\n![Engineering review sequence: Requirements → Engineering → Acceptance → Handover. Keep the recorded evidence with the accepted configuration.](https://wiki.aspotomasyon.com/assets/diagrams/automation-systems-review.svg)\n\n*Engineering review sequence: Requirements → Engineering → Acceptance → Handover. Keep the recorded evidence with the accepted configuration.*\n\n## Primary references and further reading\n\nUse the original specifications and product documentation for implementation details. The examples in this guide are illustrative engineering scenarios, not published project results.\n\n- [ABB — System 800xA architecture and product documentation](https://new.abb.com/control-systems/system-800xa)\n- [NIST SP 800-82 Rev. 3 — OT architecture and security guidance](https://csrc.nist.gov/pubs/sp/800/82/r3/final)\n\n---\n\nCite the canonical article: https://wiki.aspotomasyon.com/article/plc-scan-cycle-task-execution (PLC Scan Cycle and Task Execution, ASP OTOMASYON, updated 2026-09-13).\n","headings":[{"id":"the-four-phases-of-a-scan","title":"The Four Phases of a Scan"},{"id":"scan-time-and-its-limits","title":"Scan Time and Its Limits"},{"id":"task-models-cyclic-periodic-and-event-driven","title":"Task Models: Cyclic, Periodic, and Event-Driven"},{"id":"determinism-and-io-response-time","title":"Determinism and I/O Response Time"},{"id":"design-practices-around-the-scan","title":"Design Practices Around the Scan"},{"id":"summary","title":"Summary"},{"id":"apply-this-to-your-project","title":"Apply this to your project"},{"id":"primary-references-and-further-reading","title":"Primary references and further reading"}],"faq":[],"references":[{"name":"ABB — System 800xA architecture and product documentation","url":"https://new.abb.com/control-systems/system-800xa"},{"name":"NIST SP 800-82 Rev. 3 — OT architecture and security guidance","url":"https://csrc.nist.gov/pubs/sp/800/82/r3/final"}],"related":[{"slug":"virtual-plc-iec-61499-software-defined-automation","title":"Virtual PLCs and IEC 61499: What Software-Defined Automation Changes","summary":"Virtual PLCs run control logic on standard computing hardware, and IEC 61499 replaces the scan cycle with events, so both need an explicit timing, redundancy…","category":{"slug":"automation-systems","name":"Automation Systems"},"url":"https://wiki.aspotomasyon.com/article/virtual-plc-iec-61499-software-defined-automation","markdown_url":"https://wiki.aspotomasyon.com/article/virtual-plc-iec-61499-software-defined-automation.md","api_url":"https://wiki.aspotomasyon.com/api/v1/articles/virtual-plc-iec-61499-software-defined-automation","published":"2026-10-11T11:46:21+00:00","modified":"2026-10-11T11:46:21+00:00","reading_minutes":9,"word_count":1820,"image":"https://wiki.aspotomasyon.com/assets/social/virtual-plc-iec-61499-software-defined-automation-1d23170d2c5a.png"},{"slug":"plc-capacity-planning","title":"PLC Capacity Planning: I/O, Memory, Communications, and Scan Time","summary":"PLC spare capacity is more than unused I/O terminals. A controller can have physical expansion room while memory, network connections, execution time, or power…","category":{"slug":"automation-systems","name":"Automation Systems"},"url":"https://wiki.aspotomasyon.com/article/plc-capacity-planning","markdown_url":"https://wiki.aspotomasyon.com/article/plc-capacity-planning.md","api_url":"https://wiki.aspotomasyon.com/api/v1/articles/plc-capacity-planning","published":"2026-09-13T11:07:23+00:00","modified":"2026-09-13T11:07:23+00:00","reading_minutes":2,"word_count":357,"image":"https://wiki.aspotomasyon.com/assets/social/plc-capacity-planning-e83b63106172.png"},{"slug":"pac-vs-plc-selection","title":"PAC vs PLC: Selecting the Right Controller Platform","summary":"The Programmable Automation Controller (PAC) emerged in the early 2000s as vendors crossed PLC reliability with PC-style capability: multi-tasking, larger…","category":{"slug":"automation-systems","name":"Automation Systems"},"url":"https://wiki.aspotomasyon.com/article/pac-vs-plc-selection","markdown_url":"https://wiki.aspotomasyon.com/article/pac-vs-plc-selection.md","api_url":"https://wiki.aspotomasyon.com/api/v1/articles/pac-vs-plc-selection","published":"2026-08-11T13:05:19+00:00","modified":"2026-09-13T11:07:23+00:00","reading_minutes":4,"word_count":787,"image":"https://wiki.aspotomasyon.com/assets/social/pac-vs-plc-selection-70d53334deb5.png"},{"slug":"ics-penetration-testing","title":"ICS Penetration Testing: Planning and Safe Execution","summary":"A penetration test on an industrial control system is fundamentally different from an IT pentest: the target is a live production environment where a scan can…","category":{"slug":"industrial-cybersecurity","name":"Industrial Cybersecurity"},"url":"https://wiki.aspotomasyon.com/article/ics-penetration-testing","markdown_url":"https://wiki.aspotomasyon.com/article/ics-penetration-testing.md","api_url":"https://wiki.aspotomasyon.com/api/v1/articles/ics-penetration-testing","published":"2026-08-11T13:05:24+00:00","modified":"2026-09-13T11:07:23+00:00","reading_minutes":5,"word_count":947,"image":"https://wiki.aspotomasyon.com/assets/social/ics-penetration-testing-bc5050365e65.png"}],"citation":"ASP OTOMASYON. PLC Scan Cycle and Task Execution. Updated 2026-09-13. https://wiki.aspotomasyon.com/article/plc-scan-cycle-task-execution"}}