May 28, 2018

Cyclical Program Execution

Cyclical Program Execution 

In a Programmable Logic Controller (PLC), the logic written by the programmer does not run randomly or continuously by itself. Instead, the PLC follows a repetitive, continuous cycle known as the scan cycle or cyclical program execution. This cycle ensures that all input signals are read, processed by the logic, and the appropriate outputs are updated in a predictable and deterministic manner.

This concept is fundamental to understanding how PLCs behave and how control logic executes in real-time industrial systems.




What Is Cyclical Program Execution?

Cyclical program execution refers to the method by which a PLC constantly repeats a sequence of operations. The PLC reads all input values, executes the program, updates output signals, performs system tasks, and then starts again—continuously and cyclically.

This loop happens very fast, usually in milliseconds, ensuring the system responds to changes almost instantly.


The PLC Scan Cycle (Step-by-Step)

A standard PLC scan cycle consists of the following stages:

Step 1: Input Scan (Reading Inputs)

  • The PLC reads the status of all input devices connected to digital or analog input modules.

  • These include:

    • Sensors (proximity, limit switches, photoelectric)

    • Push-buttons (Start/Stop)

    • Analog sensors (temperature, pressure, flow)

  • Input values are stored in a memory area called the Input Image Table (or simply Input Memory).

Key point:
PLC uses the stored input memory during the entire scan, not the real-time input state—inputs are locked in for that cycle.


Step 2: Program Execution (Logic Scan)

  • The PLC executes the user program line-by-line, rung-by-rung.

  • It uses the input values stored during the input scan.

  • Instructions such as:

    • Contacts (XIC, XIO)

    • Coils (OTE)

    • Timers, counters, comparison

    • Mathematical and logical operations

  • The results of the logic execution are stored in the Output Image Table (output memory), not directly written to the physical outputs yet.

Key point:
Outputs during execution are still virtual—they are not actuated until the next stage.

Step 3: Output Scan (Updating Physical Outputs)

  • After executing the logic, the PLC updates the actual physical output modules.

  • Output devices include:

    • Motors

    • Valves

    • Relays

    • Indicators

  • The PLC writes the values from the Output Image Table to the output terminals.

Key point:
Only after this step do real devices respond to logic changes.

Step 4: Housekeeping and Communication Tasks

The PLC performs internal tasks such as:

  • Diagnostics (checking module or CPU faults)

  • Communication with HMI, SCADA, PCs

  • Updating internal clock

  • Memory management

  • Background tasks, interruptions, high-priority operations

After completing these tasks, the PLC returns to Step 1 and repeats the cycle.

Why Cyclical Execution Is Important

✔️ Predictability and Determinism

Industrial systems need predictable timing. The scan cycle ensures consistent system behavior.

✔️ Fast Response

Scan times are typically 1–10 ms, ensuring real-time response.

✔️ Simplified Programming

Engineers can assume that logic executes in a consistent loop.

✔️ Reliable Automation

Input → Logic → Output happens in the same order for every scan, ensuring stable and safe operation.

Example of Cyclical Execution (Motor Control)

Consider a Start push-button (I0.0) and Motor (Q0.0):

  1. Input Scan:
    PLC reads Start = 1 (pressed).

  2. Logic Execution:
    Rung evaluates true → Motor coil (Q0.0) = 1.

  3. Output Scan:
    Motor output physically turns ON.

  4. Housekeeping:
    Communications with HMI updated, etc.

Next scan begins; even if Start is released, the latch holds Q0.0.

Factors Affecting Scan Time

  • Program size (number of rungs, function blocks)

  • Number of instructions (math, PID, communication-heavy)

  • Amount of I/O

  • Communication load (Modbus, EtherNet/IP, HMI, SCADA)

  • CPU performance of the PLC

Scan time can be viewed in diagnostics tools in PLC software such as CCW.

Special Cases: Interrupts & Immediate Instructions

While PLCs normally follow cyclical scanning, some operations break this rule:

Immediate Input/Output Instructions

  • Read/write physical I/O directly, bypassing scan tables.

Interrupt Routines

  • Triggered by events such as:

    • High-speed counters

    • Communication triggers

    • Timed interrupts

  • Run outside the normal cyclic scan.

These ensure high-speed or time-critical operations.

Summary

Cyclical program execution is the core method by which PLCs operate. Each scan cycle includes:

  1. Input Scan – Read inputs

  2. Program Execution – Execute logic

  3. Output Scan – Update outputs

  4. Housekeeping – System tasks

This predictable, repetitive cycle makes PLC-based automation stable, reliable, and responsive.

No comments:

Post a Comment