PLC architecture, I/O modules and scan cycle
PLC hardware architecture, digital, analog and special I/O modules, sinking vs sourcing, and the scan cycle with scan-time, response-time and pulse-detection calculations.
Drafted with Aria, reviewed by the AiCanCode.org team. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
The programmable logic controller (PLC) is the workhorse of factory automation — conveyors, packaging machines, presses, pumps and process skids all run on one. Knowing what is inside it, how its I/O modules connect to real sensors and actuators, and how the scan cycle limits response time is essential for selecting hardware, wiring panels correctly and explaining why a fast event was "missed".
Key ideas
What a PLC is. An industrial computer built for harsh environments (electrical noise, vibration, 0–55 °C, 24 V DC or 230 V AC supply) that runs a user program cyclically and deterministically. It replaced hard-wired relay panels: logic changes are now software edits rather than rewiring.
Hardware architecture.
- Power supply: converts mains to the internal DC rails; often also gives 24 V DC for field sensors.
- CPU: executes the user program, manages communication and runs diagnostics, supervised by a watchdog that faults the PLC if a scan takes too long.
- Memory: firmware (ROM/flash), user program (flash), and data memory for the input/output image tables, internal bits (markers/flags), timers, counters and data registers. Retentive areas keep their values through power loss (battery-backed or non-volatile).
- I/O modules on a backplane (modular PLC) or built in (compact/brick PLC); remote I/O sits near the machine and connects over a fieldbus.
- Communication ports: programming port, Ethernet, serial, fieldbus.
- Programming device: a PC with IEC 61131-3 software (languages: Ladder Diagram, Function Block Diagram, Structured Text, Instruction List, Sequential Function Chart).
I/O modules.
- Discrete (digital) inputs: 24 V DC (most common) or 120/230 V AC, optically isolated, with a filter delay (typically a few ms, adjustable) that rejects contact bounce and noise. Sinking and sourcing describe the direction of current: a PNP (sourcing) sensor is wired to a sinking input module, an NPN (sinking) sensor to a sourcing input module.
- Discrete outputs: relay (AC or DC, a few A, slow and limited life — about 10⁵ to 10⁶ operations depending on load), transistor (DC only, fast, long life) and triac (AC only, silent).
- Analog inputs/outputs: 4–20 mA, 0–10 V, thermocouple and RTD modules, typically 12–16-bit, converting to an integer range defined by the manufacturer.
- Special modules: high-speed counters for encoders, positioning/motion, PID, weighing, and communication modules.
The scan cycle. The PLC operating system repeats:
- Input scan: read all input modules and copy their states into the input image table.
- Program execution: solve the program using the image tables — in ladder logic, rung by rung from top to bottom, each rung left to right — writing results to the output image table.
- Output scan: copy the output image table to the output modules.
- Housekeeping: communication, diagnostics, watchdog reset. Because inputs are frozen during execution, a single scan sees a consistent snapshot; but an input change is seen only at the next input scan, and an output changes only at the next output scan.
Timing consequences.
- Scan time is typically 1–50 ms, mainly set by program size and CPU speed.
- An input pulse shorter than one scan (plus filter time) may never be seen. Fast signals go to high-speed counter modules or interrupt inputs.
- Response time from input change to output change lies between about one scan and two scans, plus input-filter and output-device delays.
- Many PLCs offer immediate I/O instructions, periodic (time-driven) tasks and event tasks for faster or fixed-interval work.
Formulas
t_scan = t_in + t_prog + t_out + t_hk
- Scan time (s): input scan, program execution, output scan and housekeeping times.
t_prog ≈ N_instr × t_instr
- N_instr = instructions executed per scan; t_instr = average time per instruction (s).
t_resp,max ≈ t_filter + 2 × t_scan + t_out,dev and t_resp,min ≈ t_filter + t_scan + t_out,dev
- t_filter = input filter delay (s); t_out,dev = output device delay (relay pick-up, etc.) (s). The exact best case depends on where in the cycle the input changes; take these as the standard estimates.
t_pulse,min > t_scan + t_filter
- Minimum input ON (and OFF) time for reliable detection by normal scanning.
f_max ≈ 1 / (2 × (t_scan + t_filter))
- Highest pulse rate a normal input plus counter instruction can count reliably (equal on and off times) (Hz).
t_pulse = L / v
- Time an object of length L (m) blocks a sensor when moving at speed v (m/s).
Worked examples
Example 1 (standard). A PLC executes 20 000 instructions per scan at 0.4 µs each. Input scan 0.5 ms, output scan 0.5 ms, housekeeping 1 ms. The input filter is 3 ms and the relay output takes 10 ms to close. Find the scan time and the worst- and best-case response.
t_prog = 20 000 × 0.4 µs = 8 ms.t_scan = 0.5 + 8 + 0.5 + 1 = 10 ms.t_resp,max = 3 + 2 × 10 + 10 = 33 ms.t_resp,min = 3 + 10 + 10 = 23 ms.
Answer: t_scan = 10 ms; response between about 23 ms and 33 ms.
Example 2 (GATE level). Bottles 60 mm in diameter, spaced 60 mm apart, pass a photo-sensor on a conveyor. The PLC scan time is 20 ms and the input filter 3 ms. (a) At 1.2 m/s, can a normal input count them? (b) At 3 m/s? (c) What is the maximum reliable count rate?
- At 1.2 m/s:
t_pulse = 0.060 / 1.2 = 50 ms(gap also 50 ms). - Requirement:
t_scan + t_filter = 20 + 3 = 23 ms. 50 ms > 23 ms ✓ — counted reliably. - At 3 m/s:
t_pulse = 0.060 / 3 = 20 ms< 23 ms ✗ — bottles can be missed. f_max ≈ 1 / (2 × 0.023) = 21.7 Hz(bottles per second); at 3 m/s the rate is 3 / 0.12 = 25 bottles/s, which exceeds it.
Answers: (a) yes (50 ms ≫ 23 ms); (b) no — use a high-speed counter or interrupt input; (c) about 21.7 Hz.
Common mistakes
- Assuming outputs change the instant a rung becomes true — they change at the output scan.
- Forgetting that response time can approach two scans plus device delays.
- Counting fast pulses with ordinary inputs; use high-speed counter modules.
- Wiring a PNP sensor to an input module that needs an NPN (sinking) device.
- Using relay outputs for high-frequency switching (they wear out) or transistor outputs for AC loads.
- Ignoring input filter time in timing calculations.
- Writing the same output coil in several places in the program — only the last rung executed wins.
For GATE ME
PLCs appear in the mechatronics/automation portion as MCQs on architecture, input/output module types, sinking vs sourcing, IEC 61131-3 languages and the order of the scan cycle, and as short numericals on scan time, response time and whether a pulse of given length is detected. Practise adding times in consistent units and reasoning about where in the cycle an input changes.
Quick check
- List the four phases of a PLC scan in order.
- Which output type suits a 10 Hz solenoid on 24 V DC?
- A PLC scans in 15 ms with a 5 ms input filter. Can it reliably see a 12 ms pulse?
- What is the purpose of the watchdog timer in a PLC CPU?
- Name the five IEC 61131-3 languages.
Answers: 1. Input scan, program execution, output scan, housekeeping 2. Transistor output 3. No (12 ms < 20 ms) 4. To fault the PLC safely if the scan exceeds its limit 5. LD, FBD, ST, IL, SFC
Interview questions
All Microcontrollers, PLC and Industrial Automation interview questionsTry answering each one aloud before you open it.
1.What is a PLC and what are its main components?Concept
A Programmable Logic Controller (PLC) is an industrial digital computer designed for the control of manufacturing processes. Its main components include the CPU (Central Processing Unit), memory, power supply, input/output (I/O) modules, and communication interfaces. The CPU executes control instructions stored in the memory, while I/O modules interface with external devices to receive inputs and send outputs.
2.Explain the role of I/O modules in a PLC system.Concept
I/O modules in a PLC system serve as the interface between the PLC and the external environment. Input modules receive signals from sensors and convert them into a form that the PLC can process. Output modules take control signals from the PLC and convert them into actions, such as turning on a motor or opening a valve. They ensure that the PLC can interact with the physical world effectively.
3.Describe the PLC scan cycle and its importance.Concept
The PLC scan cycle is the process by which a PLC reads inputs, executes the control program, and updates outputs. It consists of three main steps: reading inputs, executing the program logic, and writing outputs. The scan cycle is important because it determines how quickly the PLC can respond to changes in the system, affecting the overall performance and reliability of the control process.
4.Why are PLCs preferred over traditional relay-based control systems in industrial automation?Application
PLCs are preferred over traditional relay-based systems because they offer greater flexibility, reliability, and ease of programming. They can handle complex logic operations, are easier to troubleshoot, and can be reprogrammed without changing the physical wiring. Additionally, PLCs can integrate with other digital systems and provide better scalability for future expansions.
5.What happens if a PLC's scan cycle time is too long for a given application?Application
If a PLC's scan cycle time is too long, it may not be able to respond quickly enough to changes in the system, leading to delays in control actions. This can result in decreased system performance, potential safety hazards, and reduced efficiency. In time-critical applications, a long scan cycle can cause the system to miss important events or fail to maintain desired control parameters.
6.How does the choice of I/O modules affect the performance of a PLC system?Application
The choice of I/O modules affects the performance of a PLC system by determining the types of signals that can be processed and the speed at which they can be handled. High-speed I/O modules are necessary for applications requiring rapid response times, while specialized modules may be needed for specific types of sensors or actuators. The compatibility and capacity of I/O modules also influence the scalability and flexibility of the system.
7.Explain how redundancy in PLC systems enhances reliability.Application
Redundancy in PLC systems enhances reliability by providing backup components that can take over in case of a failure. This can include redundant CPUs, power supplies, and communication paths. By having redundant systems, the PLC can continue to operate without interruption, minimizing downtime and ensuring continuous control of critical processes.
8.Calculate the scan cycle time for a PLC that takes 5 ms to read inputs, 10 ms to execute the program, and 5 ms to update outputs.Numerical
The scan cycle time for the PLC can be calculated by summing the time taken for each step of the cycle: reading inputs, executing the program, and updating outputs. Scan cycle time = 5 ms (input) + 10 ms (execution) + 5 ms (output) = 20 ms.
9.A PLC system has a scan cycle time of 50 ms, but the application needs a response within 30 ms. What can be done?Application
With normal scanning the worst-case response is roughly two scans plus input-filter and output-device delays, so here it could exceed 100 ms. Options: shorten the scan by optimising or splitting the program, run the critical logic in a fast periodic or event (interrupt) task, use immediate I/O instructions, reduce the input filter time, use transistor rather than relay outputs, move fast functions to a high-speed counter or dedicated module, or use a faster CPU.
10.What are the potential consequences of using an incorrect I/O module in a PLC system?Application
Using an incorrect I/O module in a PLC system can lead to several issues, such as incompatible signal processing, incorrect data interpretation, and potential damage to the module or connected devices. It may also result in system malfunctions, reduced performance, and increased maintenance costs. Ensuring the correct I/O module is used is crucial for the proper functioning and reliability of the PLC system.
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?