What is Scan Time?
Each control system takes some time to implement. Similarly, PLCs also take time to perform a task. Simply put, PLCs have three main components:
Input modules,
Output modules, and
Processor (CPU).
The input modules read the status of the switches and transmitters and provide data to the processor.
Processor logic is performed according to the user program. Processor command is given to the process output modules.
The output modules are connected to the final control components such as control valves and motor control feeders.
Inputs and output can be in the form of NO, NC, 4-20mA or a bit / pulse. Therefore, all the steps mentioned above require some time in the PLC, i.e., some time is required for reading the inputs, resolving the logic and writing the output, which is nothing but PLC scan time.
Definition of PLC Scan Time
The time taken by the PLC to read the inputs, solve the logic and write the write output is called the PLC scan time.
These functions work in a loop, the execution time can vary from 0ms to 150ms large and up to 1000ms.
The difference in scan time depends on the following factors:
Number of inputs
The length of the logic / loops in the program
Number of outputs
We can illustrate the point with the following example;
At PLC, we have an analog input card, which converts these analog signals into digital format so that the processor can read it and perform an operation.
If 1 channel normally requires 3ms time, the scan time would be 4 X 3 = 12ms if we used 4 channels to PLC.
What if I have already a PLC whose scan time is greater than an encoder?
There are instructions in the PLC software that can help you avoid the above problem; they are as follows;
• Immediate Instruction – Immediate Input, Immediate Output
• Interrupts instruction
These instructions are most commonly found in Siemens Old PLCs.
PLC Scan Cycle
Now that we understand the basic concept, we can move on to the maximum function of the scan time and how it works.
A scan time has four main tasks - reading input, executing logic, writing write output, and working with other priority tasks during the remaining time.
See image below for reference.
Input values are written values in the memory of the input variables. After this, the program written by the user is executed. Accordingly, variable output variables update values output values in memory.
These output values are updated in the physical output of the PLC. During the rest, PLC performs firmware system processing and other low-priority tasks.
Types of Scan Time
Let’s study some universal types of scan times used.
Cyclic Time
A cyclic time is a fixed interval time. This means that the maximum time allotted for each of the functions discussed will be split internally by the PLC.
This ensures that the PLC will try to complete all the work within the stipulated time. Compare this with the satellite example we discussed earlier. Similar to this time.
This time is periodic.
Freewheeling time
A freewheeling time is not given a fixed break time. This means that the PLC will perform the next task only after completing the previous task.
This time is periodic.
Event Task
Performs an event task on the trigger of any event. Any memory variable can be used as a trigger.
In the trigger, tasks are performed within a single scan time, only once; In freewheel type mode (that is, the next step will continue after the previous step is completed).
This time is of a conditional nature.
External Event Task
Performs this task on the trigger of any external event. This trigger can be a digital input, any system function block output (not from the program, but the configuration system block of any task), etc.
Tasks are done once in a single scan time in the trigger; in freewheel mode, this implies the next step will begin when the previous step is completed.
This time is of a conditional nature.
Important notes during the scan
Let us consider some important notes when discussing the scan time in a PLC.
Scan time selection
When you start writing a program, by default the set time in the software works best anyway, and you do not need to check it. It can be between 10-20 ms.
Two types of programs look at the scan time - one is faster and the other is longer.
For a program that requires faster output output from Logic, set the minimum scan time. But don’t underestimate it, it misses a job. The typical example would be 5 ms.
Set a high scan time for a long program of multiple areas and categories; So all the work can be done. It can be between 100-150 ms. Such lengthy programs are used where there are many IoTs, cycles / processes.
Watchdog
Watchdog is an important term related to scan time. Basically, it is the user-defined time to check if the PLC is performing all the tasks within or around the specified scan time.
Assume the scan time is 20 ms; The watchdog timer can be up to 100 ms. If the program contains an infinite loop, the watchdog plc enters stop mode until the problem is resolved.
Infinite loop can occur due to any hardware malfunction or incorrectly written program. The PLC is forced to go into stop mode to prevent unnecessary damage to the system from the program. It can only be restarted by PLC power cycling or by re-downloading the program on the PLC.
Event Triggered Tasks
In the case of event-enabled tasks, the maximum number of events per millisecond is defined.
It can be like 7 events in a millisecond. If the trigger rate occurs at a very high frequency and exceeds 7 events, the PLC will go into stop mode.
Scanning
The PLC program always scans a section from left to right and from top to bottom.
So, suppose six sections are written, and then the numbered first part is executed in a line from left to right; Then from top to bottom until the sixth part. Then, the cycle repeats.