When the PLC controller is put into operation, its working process is generally divided into three stages, namely input sampling, user program execution and output refresh. The completion of the above three phases is called a scan cycle. During the entire operation, the PLC controller's CPU repeatedly performs the above three phases at a certain scanning speed.
Folding input sampling stage
In the input sampling phase, the PLC controller sequentially reads all input states and data in scan mode and stores them in the corresponding cells in the I/O map area. After the input sampling ends, it goes to the user program execution and output refresh phase. During these two phases, even if the input status and data change, the status and data of the corresponding unit in the I/O map 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.
Folding user program execution phase
During the execution of the user program, the PLC controller always scans the user program (ladder) in order from top to bottom. When scanning each ladder diagram, it is always to scan the control circuit formed by each contact on the left side of the ladder diagram, and logically operate the control circuit formed by the contacts in the order of left, right, first, upper, and lower. Then, according to the result of the logic operation, the state of the corresponding bit in the system RAM memory area of the logic coil is refreshed; or the status of the corresponding bit in the I/O image area is refreshed; or it is determined whether to execute the ladder diagram. Specified special function instructions.