Input module: Monitor external input signals (such as sensor signals).
CPU (Central Processing Unit): Interprets input signals, executes program logic, and sends output signals to output modules.
Output module: Generate corresponding output signals based on CPU instructions to control the operation of external devices (such as starting and stopping motors, opening and closing valves, etc.).
Programming software: used to write program logic and download programs to PLC controllers.
One. scanning technique
After the PLC 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 scanning cycle. During the entire operation, the CPU of the PLC repeatedly executes the above three stages at a certain scanning speed.
- The input sampling stage is in the input sampling stage
The PLC sequentially reads in 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 completed, it enters the user program execution and output refresh phase. In these two stages, even if the input state and data change, the state and data of the corresponding unit in the I/O mapping area will not change. Therefore, if the input is a pulse signal, the width of the pulse signal must be greater than one scanning period to ensure that the input can be read in under any circumstances.
- User program execution phase
During the execution phase of the user program, the PLC always scans the user program in a top-down order (ladder diagram). When scanning each ladder diagram, always scan the control circuit composed of each contact on the left side of the ladder diagram first, and perform logical operations on the control circuit composed of contacts in the order of left to right and top to bottom. Then, based on the result of the logical operation, refresh the corresponding bit status of the logical coil in the system RAM storage area; Or refresh the status of the corresponding bit of the output coil in the I/O mapping area; Or determine whether to execute the special functional instructions specified in 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 mapping area will not change, while the state and data of other output points and software devices in the I/O mapping area or system RAM storage area may change. Moreover, the ladder diagram at the top will have an effect on any ladder diagram below that uses these coils or data; On the contrary, in the ladder diagram below, the status or data of the refreshed logic coil can only affect the program above it in the next scanning cycle.
If immediate I/O instructions are used during program execution, I/O points can be directly accessed. If I/O instructions are used, the value of the input process image register will not be updated. The program directly takes values from the I/O module, and the output process image register will be updated immediately, which is somewhat different from immediate input.
- Output refresh phase
After scanning the user program, the PLC enters the output refresh phase. During this period, the CPU refreshes all output latch circuits according to the corresponding states and data in the I/O image area, and then drives the corresponding peripherals through the output circuits. At this point, it is the true output of the PLC.
In practical applications, PLC controllers often need to be used in conjunction with other devices (such as human-machine interfaces, sensors, actuators, etc.) to form a complete automation control system. PLC controllers have the advantages of programmability, high reliability, easy scalability, and good flexibility, and are widely used in the field of automation control.