In order to meet the requirements of industrial logic control, combined with the characteristics of computer control, PLC adopts the continuous cycle sequential scanning mode. The time of each scan is called scan cycle or work cycle. The CPU starts from the execution of the first instruction, executes the user program one by one in order until the end of the user program, and then returns to the first instruction to start a new round of scanning. PLC is such a cycle to repeat the above cycle scanning. The whole working process of PLC can be represented by the operation block diagram shown in the figure. The whole process can be divided into the following parts:

The first part is power on processing. After the PLC is powered on, the system is initialized once, including hardware initialization and software initialization, power failure holding range setting and other initialization processing.

The second part is self diagnosis processing. Every time the PLC scans, it carries out a self diagnostic check to determine whether the PLC’s action is normal. For example, whether the CPU, battery voltage, program memory, I / O and communication are abnormal or wrong. If the abnormality is detected, the LED and abnormal relay on the CPU panel will be turned on, and the error code will be stored in the special register. When a fatal error occurs, the CPU is forced to stop, and all scans are stopped.

Working process diagram of PLC

Figure PLC operation block diagram

The third part is communication service. PLC enters the communication service process after the completion of diagnosis. First, check whether there are communication tasks, if there are, call the corresponding process to complete the communication with other devices, and process the communication data accordingly; Then the clock and special register are updated.

The fourth part is the process of program scanning. After the power on processing, self diagnosis and communication service of PLC are completed, if the work selection switch is in the run position, it will enter the program scanning stage. First, the input processing is completed, that is, the status of the input terminal is read into the input image register, then the user program is executed, and finally the output processing result is refreshed into the output latch.

In the above parts, communication service and program scanning process are the main parts of PLC, and its working cycle is called scanning cycle. It can be seen that the scanning cycle directly affects the real-time and correctness of the control signal. In order to ensure that the control can be carried out correctly and in real time, in each scanning cycle, the operation time of the communication task must be controlled within a certain range. When PLC is running normally, the length of program scanning cycle is related to the operation speed of CPU, I / o point, user application program and programming. Usually, the time required for PLC to execute LKB instruction is used to describe its scanning speed, which is generally from 0.0 MS to hundreds of MS. It is worth noting that the execution time of different instructions is different, from a few minutes μ S to hundreds μ S, so the scanning time will be different for different commands. For some signals that need high-speed processing, special software and hardware measures are needed.

When the PLC is in normal operation, it will continue to repeat the scanning process. If the remote I / O, special modules and other communication services are not considered, the scanning process will only have three stages: “input sampling”, “program execution” and “output refresh”. These three stages are the central content of PLC working process. Understanding these three stages of PLC working process is the basis of learning PLC well. The following is a detailed analysis of these three stages.

(1) Input sampling phase

In the input sampling stage, PLC first scans all input endpoints and stores each input status in the corresponding input image register. At this time, the input image register is refreshed. Then, the program execution phase and the output refresh phase are entered. In this phase, the input image register is isolated from the outside world. No matter how the input situation changes, its content remains unchanged until the input sampling phase of the next scanning cycle. Therefore, generally speaking, the width of input signal should be greater than one scan cycle, otherwise it is likely to cause signal loss.

It can be seen that the data of the input image register completely depends on the on and off status of each input point on the input terminal during the last refresh period.

(2) Program execution phase

According to the principle of PLC ladder program scanning, generally speaking, PLC executes the program from left to right and from top to bottom. When the input and output states are involved in the instruction, PLC will “read” the corresponding input terminal state collected from the input image register, and “read” the current state of the corresponding component (“soft relay”) from the component image register. Then, the corresponding operation is carried out, and the operation results are stored in the component image register. For a component image register, the state of each component (soft relay) changes with the execution of the program.

(3) Output refresh phase

After all the instructions are executed, the status of all the output relays (on / off) in the component image register is transferred to the output latch in the output refresh stage, and the external load is driven by the output terminal and external power supply.

It can be seen that the data of the output image register depends on the execution result of the output instruction, the data in the output latch is determined by the data in the output image register during the last output refresh, and the on and off states of the output terminals are completely determined by the output latch.

Tagged:

Leave a Reply

Your email address will not be published. Required fields are marked *