Three stages to complete the plc user program: 1. Input processing stage, PLC reads the input signals on all input terminals in scanning mode, and stores each input status into the corresponding input image register; 2 , In the program execution stage, the PLC follows the ladder diagram program scanning principle. Execute the program one by one from left to right and top to bottom; 3. In the output processing stage, the PLC sends the output variables in the output image area to the output latch, and then the latch generates the output of this cycle through the output module. Control output.
The operating environment of this tutorial: Windows 7 system, Dell G3 computer.
PLC software system refers to a collection of various programs used by PLC. It includes system programs and user programs.
(1) System program
System programs include monitoring programs, compilers and diagnostic programs, etc. The monitoring program is also called the management program and is mainly used to manage the entire machine. Compilers are used to translate programming language into machine language. Diagnostic programs are used to diagnose machine malfunctions. The system program is provided by the PLC manufacturer and is solidified in EPROM. The user cannot directly access it, so user intervention is not required.
(2) User program
The user program is an application program compiled by the user in the PLC programming language according to the needs of on-site control to achieve various control requirements. The user program is typed into the PLC memory by the user using a programmer. The user program of a small PLC is relatively simple and does not need to be segmented, but is compiled sequentially. The user program of large and medium-sized PLC is very long and relatively complex. In order to make the user program compilation simple and clear, the user program can be divided into various program modules according to the functional structure or purpose of use. A user program is composed of a module structure. Each module is used to solve a certain technical function. It can make a long program easy to understand and make it easy to debug and modify the program.
For CNC machine tools, the user program in the CNC machine tool PLC is provided by the machine tool manufacturer and has been solidified into the user EPROM. The machine tool user does not need to write or modify it. Only when the machine tool fails, Find the fault point and perform repairs according to the ladder diagram and electrical schematic diagram provided by the machine tool factory.
Three stages of completion of plc user program
The completion of PLC user program is divided into three stages: input processing, program execution, and output processing. These three stages are completed in a time-sharing manner using the "cyclic scanning" working method.
(1) Input sampling stage.
In this stage, the PLC reads the input signals on all input terminals in a scanning manner, and stores each input status into the corresponding input image register. At this time, the input image register is flushed. During 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, when it 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 scene, but uses the data input into the image area during this sampling. Generally speaking, the width of the input signal must be greater than one scanning period, otherwise the signal may be lost.
(2) Program execution stage.
In the process of executing the user program, the PLC follows the ladder diagram program scanning principle. Generally speaking, the PLC executes the program 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 based on whether the jump condition is met. During program execution, when the input and output status are involved in the instruction, the PLC "reads" the corresponding input terminal status from the input image register, and "reads" the current status 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. For output image registers, the state of each element ("soft relay") changes as the program executes.
(3) Output refresh stage.
The operation results during the program execution phase are stored in the output image area instead of being sent to the output port. In the output refresh phase, 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 status of all output devices must be maintained for one scan cycle.
For more related knowledge, please visit the FAQ column!
The above is the detailed content of What are the three stages to complete the plc user program?. For more information, please follow other related articles on the PHP Chinese website!