When designing a PLC controlled system, one aspect that should not be overlooked is how the PLC scan will affect your operation. The PLC scan consists of a sequence of operations the CPU will follow repeatedly. The amount of time the CPU needs to complete this sequence is known as scan time and it can adversely affect your process if you are not careful.
It may seem to the naked eye, when an output is set ON in the ladder code that this change is immediately reflected in the output card. Or that when an input is activated, the CPU instantly sees it. But that is not actually the case. The output and the input will only be updated once the PLC scan gets to the appropriate step in the sequence. To us, that seems immediate, but to a computer it may not be. With inputs, the time it takes the CPU to notice a change can vary depending on where the CPU was in the sequence when the input turned on. For outputs, the CPU will completely execute the ladder program before changing the output state on the output card. Although extremely fast, these changes are not instantaneous.
The Sequence
As a programmer, you’re mostly concerned with three main steps in the PLC scan – the Update Inputs, Execute Program and Update Outputs steps. But there are other steps that need to be considered as well. Most PLCs will have similar sequences, some with a few variations, and an example is as follows:
1. Power Up – this is the
starting point when the PLC is first powered
2. Initialize Hardware – at this point, the CPU will verify and initialize the installed hardware
3. Restores Retentive Values – any CPU memory locations that were configured as retentive will be restored to their previous value
4. Updates Inputs – the CPU will now read in the inputs stored in the input table, on the next scan this will be the starting point for the CPU
5. Updates Specialty and Remote Inputs – the CPU will take in any inputs from specialty modules, like high-speed counters, and remote I/O racks
6. Service Peripherals – in this step, the CPU will handle any requests from the serial or Ethernet communication ports
7. Executes Program – if in the RUN mode, the CPU will now execute the ladder program using the updated inputs
8. Updates Outputs – If there were any output state changes from the ladder execution, the CPU will now write them to the output tables and in turn the output cards
9. Diagnostics/Housekeeping – finally the CPU will run a self-check and tie up any loose ends before repeating the scan – returning to the “Update Inputs” step
What to watch for
Modern PLCs can run the scan in milli-seconds and for most applications that’s not a problem. But as your code complexity increases, the time it takes to execute can begin to slow the CPU. This can be greatly alleviated by using program efficiencies like subroutines and task management. Another thing to watch for regarding CPU scan time is the amount of communication requests coming into the CPU. If the application is communication heavy and there’s a lot of polling of information, the CPU scan can be adversely affected.
PLC scan time can be a big issue with high-speed applications. Let’s say you are controlling a high-speed sorting facility, and for packaging tracking purposes your encoders are supplying 1000 pulses per revolution for every foot of a 140-fpm conveyor.
That is over 2,000 pulses per second or over 2 pulses every milli-second. At that rate, it wouldn’t take much for the average CPU to miss a few pulses and in turn cause a swinging diverter arm to miss or crush a box. In these situations, specialty modules like high-speed counters, can be used to ensure no pulses are missed. These counters are designed to work independently from the CPU scan, meaning they have their own processor dedicated to tracking the pulses coming in and nothing else. They then feed the count over to the CPU when it is requested.
We are here to help
Understanding PLC control is becoming more of a demand as our world becomes more automated. PLC scan time is just one of the many topics that anyone new to PLCs needs to have a firm grasp of. To help those who would like to learn more about industrial control, we are offering absolutely free online PLC training.
There is no purchase required for this training and it is available 24/7/365 so you can learn at your pace and at your convenience. Some of the general topics covered include:
• Logic circuits
• Basic switches
• Sinking and sourcing
• I/O fundamentals
• PLC memory addressing
Also available are videos specifically covering AutomationDirect CLICK, Do-more and Productivity controllers.
To get started today with your unlimited access to FREE online PLC training, simply register at www.automationdirect.com/plc-training.
For more informative articles like this one, click here for more issues of Automation Notebook.
Originally Published: October 2018