When plc is put into operation, its working process is generally divided into three phases, namely, input sampling, user program execution and output refresh. Completing the above three phases is called a scan cycle. During the entire run, the CPU of the programmable logic controller repeatedly performs the above three phases at a certain scan speed. 1. Input Sampling Phase In 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 image 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. The PLC adopts the "sequential scanning, continuous cycling" working mode: (1) each scanning process, centralized collection of input signals, centralized refreshing of the output signal; (2) input refresh process, when the input port is closed, the program is input during the execution phase There is a new state at the end and the new state cannot be read in. Only when the program performs the next scan, the new state is read; (3) one scan cycle is divided into input sample, program execution, and output refresh; (4) the content of the component map register changes as the program execution changes. (5) The length of the scan cycle is determined by three: 1) the speed at which the CPU executes the command; 2 refers to the time occupied by itself; 3 the number of instructions, the current PLC scan speed is very fast. (6) Due to the centralized sampling and centralized output mode, there is a phenomenon of input/output lag, that is, input/output response delay. Installation Accessory,Encoder Sensor With Coupling,Encoder Sensor Wheel,Sensor Encoder Yuheng Optics Co., Ltd.(Changchun) , https://www.yhencoder.com
2. User Program Execution Phase In 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 composed of 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 The specified special function instructions.
That is, during the execution of the user program, only the status and data of the input point in the I/O map area will not change, and the status of other output points and soft devices in the I/O map area or the system RAM storage area. And the data may 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 are The state or data of the refreshed logic coil can only go to the next scan cycle to work on the program that is listed above.
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 values ​​directly from the I/O module. The output process image registers will be updated immediately, which is somewhat different from the immediate input.
3. Output refresh phase When the scanning user program ends, the programmable logic controller enters the output refresh phase. During this time, the CPU refreshes all the output latch circuits according to the corresponding state and data in the I/O map area, and drives the corresponding peripherals through the output circuit. At this time, it is the real output of the programmable logic controller.
The PLC originally developed and produced is mainly used to replace the traditional control device composed of relay contactors, but the operation modes of the two are different:
(1) The relay control device adopts the way of parallel operation of hard logic, that is, if the coil of this relay is energized or de-energized, at which position of the relay control line all contacts of the relay (including its normally open or normally closed contact) Will act immediately at the same time.
(2) The CPU of the PLC uses sequential logic to scan the operation mode of the user program, that is, if an output coil or logic coil is turned on or off, all contacts of the coil (including its normally open or normally closed contacts) are not It will act immediately and must wait until the contact is scanned.
In order to eliminate the difference between the two due to different operating modes, considering that the action time of various contacts of the relay control device is generally above 100ms, and the time for PLC scanning user program is generally less than 100ms, therefore, the PLC adopts one. It is different from the operation mode of a general microcomputer---scanning technology. Thus, in the case where the I/O response is not high, there is no difference in the processing results between the PLC and the relay control device.
1. Scanning technology When the PLC is put into operation, its working process is generally divided into three stages, namely, input sampling, user program execution and output refreshing. Completing the above three phases is called a scan cycle. During the entire operation, the CPU of the PLC repeatedly executes the above three stages at a certain scanning speed.
(1) Input sampling phase In the input sampling phase, the PLC sequentially reads all input states and data in a scanning manner and stores them in the corresponding units in the I/O mapping 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.
(2) User program execution phase In the user program execution phase, the PLC 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 composed of 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 The specified special function instructions. 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; instead, 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.
(1) Output refresh phase When the scanning user program ends, the PLC enters the output refresh phase. During this time, the CPU refreshes all the output latch circuits according to the corresponding state and data in the I/O map area, and drives the corresponding peripherals through the output circuit. At this time, it is the real output of the PLC.
2. PLC I/O response time In order to enhance the anti-interference ability of PLC and improve its reliability, each switch input end of PLC adopts photoelectric isolation technology. In order to realize the hard logic parallel control of the relay control circuit, the PLC adopts a different operation mode (scanning technology) than the general microcomputer. The above two main reasons make the PLC get more I/O response than the industrial control system composed of general microcomputers, and the response time is at least equal to one scan period, generally more than one scan period or even longer. The so-called I/O response time refers to the time required from the change of a certain input signal of the PLC to the change of the signal of the relevant output of the system.