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 phases is called a scan cycle. During the entire run, the programmable logic controller's CPU repeatedly performs the above three phases at a certain scan speed.
During the input sampling phase, the programmable logic controller sequentially reads all input states and data in a scan mode and stores them in the corresponding cells in the I/O map area. After the input sampling is finished, it is transferred to the user program execution and output refresh phase. In these two phases, the status and data of the corresponding unit in the I/O map area does not change even if the input status and data change. Therefore, if the input is a pulse signal, the width of the pulse signal must be greater than one scan period to ensure that the input can be read in any case.
During the user program execution phase, the programmable logic controller always scans the user program (ladder) in order from top to bottom. When scanning each ladder diagram, the control lines formed by the contacts on the left side of the ladder diagram are always scanned first, and the control lines formed by the contacts are logically operated in the order of first left, then right, first up and then down. And then refreshing the state of the corresponding bit of the logic coil in the system RAM storage area according to the result of the logic operation; or refreshing the state of the corresponding bit of the output coil in the I/O map area; or determining whether to execute the ladder diagram Special function instructions specified.
That is, during the execution of the user program, only the state and data of the input point in the I/O map area will not change, while other output points and soft devices are in the I/O map area or the system RAM storage area. The status and data are subject to change, and the ladder diagrams listed above, the program execution results will work on the ladder diagrams that use these coils or data below; on the contrary, the ladder diagrams below, The state or data of the refreshed logic coil can only be applied to the program that is listed above in the next scan cycle.
I/O points can be accessed directly if immediate I/O instructions are used during program execution. Even if I/O instructions are used, the value of the input process image register will not be updated. The program will take the value directly from the I/O module, and the output process image register will be updated immediately. This is somewhat different from the immediate input.