I. What is a PLC?
PLC stands for Programmable Logic Controller. As the name suggests, it's a logic controller that takes devices that previously used relay circuits and allows for the implementation of their functions. A program is written manually and downloaded to the PLC, which then executes the designed functionality. PLCs are fundamental to basic automation.
PLCs have a very low failure rate and comprehensive self-diagnostic and display functions. When a PLC, external input device, or actuator malfunctions, the cause of the fault can be easily identified based on the information provided by the LEDs on the PLC or the programmer. The fault can be quickly eliminated by replacing the module.
PLC control systems require far less wiring than relay control systems, thus saving a significant amount of wiring and accessories, reducing installation and wiring time, and allowing for smaller switch cabinets, resulting in substantial cost savings.
PLCs have the following distinctive features.
(1) The system is flexible in structure and easy to expand, with switch control as its specialty; it can also perform PID loop control of continuous processes; and it can form complex control systems with the host computer, such as DDC and DCS, to realize the comprehensive automation of the production process.
(2) It is easy to use and simple to program, employing concise ladder diagrams, logic diagrams, or statement lists as programming languages, without requiring computer knowledge. Therefore, the system development cycle is short and on-site debugging is easy. In addition, the program can be modified online to change the control scheme without disassembling the hardware.
(3) It can adapt to various harsh operating environments, has strong anti-interference ability and high reliability, which is far superior to other models.
II. PLC Working Principle
Once a programmable logic controller (PLC) is put into operation, its operation generally consists of three stages: input sampling, user program execution, and output refresh. The completion of these three stages constitutes one scan cycle. Throughout the entire operation, the PLC's CPU repeatedly executes these three stages at a certain scan rate.
1. Input sampling
During the input sampling phase, the programmable logic controller (PLC) sequentially reads all input states and data in a scanning manner and stores them in the corresponding cells of the I/O image area. After input sampling is completed, the process transitions to the user program execution and output refresh phases. During these two phases, even if the input states and data change, the states and data of the corresponding cells in the I/O image 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 under any circumstances.
2. User program execution
During the user program execution phase, the programmable logic controller (PLC) always scans the user program (ladder diagram) sequentially from top to bottom. When scanning each ladder diagram, it always first scans the control circuit composed of each contact on the left side of the ladder diagram, and performs 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, it refreshes the state of the corresponding bit in the system RAM storage area of the logic coil; or refreshes the state of the corresponding bit in the I/O image area of the output coil; or determines whether to execute the special function instruction specified by the ladder diagram.
That is, during the execution of the user program, only the state and data of the input points in the I/O image area will not change, while the state and data of other output points and soft devices in the I/O image area or system RAM storage area may change. Moreover, the program execution result of the ladder diagram above will affect the ladder diagram below that uses these coils or data; conversely, the state or data of the logic coils of the ladder diagram below can only affect the program above it in the next scan cycle.
During program execution, if immediate I/O instructions are used, I/O points can be accessed directly. Even when using I/O instructions, the value of the input process image register is not updated; the program directly retrieves values from the I/O module. The output process image register is updated immediately, which is somewhat different from immediate input.
3. Output refresh
After the user program scan is complete, the programmable logic controller (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. This is when the PLC actually outputs.