PLC is mainly divided into the following three stages when the program is executed:
1. Input sampling stage: In this stage, the PLC reads the input signal on all input terminals in a scanning manner, and stores each input state into the corresponding input image register. At this point, the input image register is flashed.
During the program execution phase and the output refresh phase, the input image memory is isolated from the outside world, and its contents remain unchanged until the next input scan phase of the scan week, when it is refreshed by the input signal that is re-read.
During program execution, when the input and output states are involved in the instruction, the PLC "reads" the corresponding input terminal state from the input image register and the current state of the corresponding component from the output image register.
The corresponding calculations are then performed, and the results are stored in the output image register.
2. Output refresh stage: The calculation results of the program execution stage are stored in the output image area and not sent to the output port.
In the output refresh phase, the PLC feeds the output variables in the output image area into the output latch, which then generates the control output for this cycle through the output module.