When the programmable logic controller is put into operation, its working process is generally divided into three stages, namely input sampling, user program execution and output refresh. Completing the above three stages is called a scan cycle. During the entire operation period, the CPU of the programmable logic controller repeatedly executes the above three stages at a certain scan speed.
Input sampling
In the input sampling stage, the programmable logic controller reads all input states and data in sequence in a scanning manner and stores them in the corresponding units in the I/O image area. After the input sampling is completed, it enters the user program execution and output refresh stages. In these two stages, even if the input state and data change, the state and data of the corresponding units in the I/O image area will not change. Therefore, if the input is a pulse signal, the width of the pulse signal must be greater than one scan cycle to ensure that the input can be read in any case.
User program execution
In the user program execution stage, the programmable logic controller always scans the user program (ladder diagram) in sequence from top to bottom. When scanning each ladder diagram, the control circuit composed of the contacts on the left side of the ladder diagram is always scanned first, and the control circuit composed of the contacts is logically operated in the order of left first, right second, top first, bottom second. Then, according to the result of the logical operation, the state of the corresponding bit of the logic coil in the system RAM storage area is refreshed; or the state of the corresponding bit of the output coil in the I/O image area is refreshed; or it is determined whether to execute the special function instruction specified by the ladder diagram.
That is, during the execution of the user program, only the state and data of the input point in the I/O image area will not change, while the state and data of other output points and soft devices in the I/O image area or the system RAM storage area may change, and the program execution results of the ladder diagram arranged above will affect all the ladder diagrams arranged below that use these coils or data; on the contrary, the state or data of the refreshed logic coils of the ladder diagram arranged below can only take effect on the program arranged above it in the next scanning cycle.
If the immediate I/O instruction is used during the execution of the program, the I/O point can be directly accessed. If the I/O instruction is used, the value of the input process image register will not be updated. The program directly takes the value from the I/O module, and the output process image register will be updated immediately, which is somewhat different from immediate input.
Output refresh
After scanning the user program, the programmable logic controller enters the output refresh phase. During this period, the CPU refreshes all output latch circuits according to the corresponding status and data in the I/O image area, and then drives the corresponding peripherals through the output circuit. At this time, it is the real output of the programmable logic controller.
How PLC Works
Aug 06, 2024
Leave a message

