PLC hardware architecture (CPU, I/O, power supply) in PLC Programming - Time & Space Complexity
We want to understand how the time it takes for a PLC to process inputs and outputs changes as the number of I/O points grows.
How does adding more devices affect the speed of the PLC's work?
Analyze the time complexity of the following PLC scan cycle code snippet.
// Simplified PLC scan cycle
FOR i := 1 TO NumberOfInputs DO
ReadInput(i);
END_FOR;
ExecuteLogic();
FOR j := 1 TO NumberOfOutputs DO
WriteOutput(j);
END_FOR;
This code reads all inputs one by one, runs the control logic once, then writes all outputs one by one.
Look for loops or repeated steps in the scan cycle.
- Primary operation: Reading inputs and writing outputs in loops.
- How many times: Each loop runs once per scan, repeating for all input and output points.
As the number of inputs and outputs increases, the time to read and write grows proportionally.
| Input/Output Count (n) | Approx. Operations |
|---|---|
| 10 | About 20 (10 reads + 10 writes) |
| 100 | About 200 (100 reads + 100 writes) |
| 1000 | About 2000 (1000 reads + 1000 writes) |
Pattern observation: The total operations grow directly with the number of I/O points.
Time Complexity: O(n)
This means the time to complete one scan grows in a straight line as you add more inputs and outputs.
[X] Wrong: "Adding more inputs won't affect scan time much because the CPU is fast."
[OK] Correct: Even a fast CPU must read each input and write each output, so more points mean more work and longer scan time.
Understanding how scan time grows with I/O count helps you design efficient PLC systems and shows you grasp real-world control challenges.
What if the PLC used parallel input reading instead of a loop? How would the time complexity change?
Practice
Solution
Step 1: Understand the role of CPU in PLC
The CPU processes instructions and controls the PLC operation.Step 2: Compare with other parts
Power supply provides energy, input modules receive signals, output modules send commands.Final Answer:
CPU -> Option CQuick Check:
CPU = Brain of PLC [OK]
- Confusing power supply with CPU
- Thinking input module processes data
- Mixing output module with CPU
Solution
Step 1: Identify common PLC diagram symbols
Power supply is usually shown as a box labeled 'PS' or 'Power Supply'.Step 2: Eliminate other options
CPU is labeled 'CPU', I/O is not a circle, arrows show signal flow not power supply.Final Answer:
A box labeled 'PS' or 'Power Supply' -> Option AQuick Check:
Power supply symbol = Box labeled PS [OK]
- Choosing CPU box as power supply
- Confusing arrows with power supply
- Thinking I/O is power supply symbol
Solution
Step 1: Understand I/O points
I/O points are the sum of input points and output points connected to the PLC.Step 2: Calculate total I/O points
8 inputs + 6 outputs = 14 total I/O points.Final Answer:
14 -> Option DQuick Check:
8 + 6 = 14 I/O points [OK]
- Counting only inputs
- Counting only outputs
- Multiplying inputs by outputs
Solution
Step 1: Analyze symptoms
PLC not powering on means no power is reaching the system.Step 2: Identify hardware responsible for power
The power supply provides energy; if disconnected or faulty, PLC won't start.Final Answer:
Disconnected power supply -> Option BQuick Check:
No power = Power supply issue [OK]
- Blaming CPU when no power
- Assuming output module stops power
- Ignoring power supply connection
Solution
Step 1: Identify hardware for sensors and actuators
Sensors connect to input modules; actuators connect to output modules.Step 2: Determine what to add
To handle more devices, add input modules for sensors and output modules for actuators.Step 3: Consider CPU and power supply
CPU usually handles more modules without replacement; power supply may need upgrade but not always.Final Answer:
Add input and output modules -> Option AQuick Check:
More devices = Add I/O modules [OK]
- Thinking CPU must be replaced
- Adding only power supplies
- Adding CPU units instead of modules
Ready to prove it?
Pass the test and this pattern moves unknown
