PLC Working Principle and PLC Scan Cycle

PLC is an industrial control computer, and its working principle is based on the computer working principle, that is, it is completed by executing a user program reflecting the control requirements.

Basic PLC working principle

PLC takes microprocessor as the core and has many characteristics of microcomputer, but its working method is very different from microcomputer.

Microcomputers generally work in a waiting mode.

The PLC works by centralized input, centralized output and periodic cyclic scanning. The time used for each cyclic scan is called a scan cycle.

For each program, the CPU starts execution from the first instruction, and executes the instructions one by one in sequence to perform periodic program loop scanning. If there is no jump instruction, the user program is executed sequentially from the first instruction to the end. Return to the first instruction, and so on.

In addition to executing the user program during each scan, the PLC must also complete internal processing, input sampling, communication services, program execution, self-diagnosis, and output refresh.

The whole process of PLC work includes three parts, namely power-on processing, scanning process and error handling. The whole process of PLC work can be represented by the operation block diagram shown in Figure

In Figure after the PLC is powered on, the CPU first performs internal processing under the control of the system program, including hardware initialization, I/O module configuration check, power failure retention range setting, and other initialization processing.

The PLC has a strong self-diagnosis function. The PLC performs a self-diagnosis check every scan to determine whether the PLC’s own actions are normal, such as power supply detection, whether the internal hardware is normal, and whether the program syntax is wrong.

If an abnormality is detected, the LED and abnormal relay of the CPU panel will be turned on, and an error code will be stored in the special register

The CPU can send a signal according to the type and degree of error, and even perform corresponding error processing to stop the PLC from scanning or forcing. It becomes the STOP state.

When the PLC is operating normally, the length of the scan cycle is related to the length of the user application, the calculation speed of the CPU, and the status of the I / O points.

Usually the time required for the PLC to execute the 1KB instruction to explain its scanning speed (generally 1-10ms /KB).

It is worth noting that the execution time of different instructions is different, so the scan time used for different instructions will be different.

If it is used in a high-speed system to shorten the scan cycle, it can be considered from both hardware and software. The salient features of the PLC’s periodic cyclic scanning working mode are: high reliability and strong anti-interference ability, but the response is lagging and the speed is slow.

PLC Scanning Cycle

PLC Scanning Cycle

The process of PLC program execution is divided into three stages, namely input sampling stage, program execution stage, and output refresh stage. The scanning process of PLC is shown in Figure

Input sampling stage

At this stage, the PLC reads the input signals on all input terminals in a scanning manner, and stores each input state in the corresponding input image register.

At this time, the input image register is erased. In the program execution phase and the output refresh phase, the input image memory is isolated from the outside world, and its content remains unchanged until the input scan phase of the next scan cycle is refreshed by the re-read input signal.

It can be seen that when the PLC executes the program and processes the data, it does not directly use the input signal at the time at the scene, but uses the data input into the image area during this sampling.

In general, the width of the input signal should be greater than one scan period, otherwise it may cause the loss of the signal.

The program execution stage

The program execution stage. During the execution of the user program, the PLC scans according to the ladder program scanning principle.

Generally speaking, the PLC executes the programs one by one from left to right and from top to bottom. However, when a program jump instruction is encountered, the program jump address is determined according to whether the jump condition is satisfied.

During the execution of the program, when the input and output states are involved in the instruction, the PLC will “read in” the corresponding input terminal state from the input image register, and “read in” the current state of the corresponding component (“soft relay”) from the output image register .

Then the corresponding operation is performed, and the operation result is stored in the output image register again. For the output image register, the state of each component (“soft relay”) changes with the execution of the program.

Output refresh stage

The operation results of the program during the execution phase are stored in the output image area, and are not sent to the output port.

In the output refresh stage, the PLC sends the output variables in the output image area to the output latch, and then the latch generates the control output of this cycle through the output module.

If the status of the internal output relay is “1”, the output relay contact is closed and the external load is driven through the output terminal. The state of all output devices should be maintained for one scan cycle.

Input / output lag problem:

When the input signal of the PLC input changes, the PLC output needs a period of time to react to the input change. This phenomenon is called the PLC input / output response lag.

It can be seen from the above analysis that the length of the scan cycle depends mainly on the length of the program. The longer the scan period, the slower the response speed. Because I/O refresh is only performed once per scan cycle, that is, the PLC only updates the input and output status registers once per scan cycle, so the system has input and output lags, which reduces the system’s responding speed.

The interference on the industrial site is often pulsed and short-term, and the PLC input / output response is lagging, which is completely allowed for general industrial control requirements and can also enhance the anti-interference ability of the system.

However, for systems with strict control time requirements and fast response speeds, measures must be taken to reduce the adverse effects of input / output hysteresis

Leave a Comment