How does a PLC Work?
Programmable Logic Controller, short for PLC, is a digital electronic device with a microprocessor. The device is a digital logic controller for automatic control, which can load control instructions into the memory at any time for storage and execution. The programmable controller is composed of internal CPU, instruction and data memory, input and output units, power supply modules, digital and analog units.
The PLC is widely used in the field of industrial control. Before the advent of programmable logic controllers, hundreds of relays and counters were generally used to form an automated system with the same functions. Nowadays, simple programmable logic controller modules that have been programmed have basically replaced these large devices. The system program of theĀ PLC controller is generally initialized before leaving the factory. Users can edit corresponding user programs according to their own needs to meet different automated production requirements.
PLC Working Principle
When the PLC is put into operation, its working process is generally divided into three stages, namely input sampling, user program execution and output refresh three stages. Completing the above three stages can be called a scan cycle. During the entire operation, the CPU of PLC repeatedly executes the above three stages at a certain scanning speed.
1. Input and sampling stage
In the input and 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 (input/output) image area. After the input and sampling phase is over, it goes to the user program execution and output refresh phase. In these two stages, 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 period to ensure that the input can be read under any circumstances.
2. User program execution stage
In the user program execution stage, the PLC always scans the user program (ladder diagram) sequentially from top to bottom. When scanning each ladder diagram, it always scans the control circuit formed by the contacts on the left side of the ladder diagram first, and performs logic operations on the control circuit formed by the contacts in the order of left and right, up and down., refresh 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 refresh the state of the corresponding bit of the output coil in the I/O image area; or determine whether to execute the special function instructions specified by 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 image area will not change. The status and data of other output points and soft devices in the I/O image area or system RAM storage area may change. For the ladder diagram at the top, the program execution result will affect the ladder diagrams at the bottom that use these coils or data. On the contrary, for the ladder diagrams listed below, the state or data of the logic coils that are refreshed can only take effect on the programs listed above it in the next scan cycle.
In the process of program execution, if you use immediate I/O instructions, you can directly access I/O points. In other words, if I/O instructions are used, the value of the input process image register will not be updated. The program directly fetches the value from the I/O module, the image register will be updated immediately during the output process, which is somewhat different from the immediate input.
3. Output refreshing stage
When the scanning user program ends, the PLC enters the output refresh phase. During this period, the CPU refreshes all output latch circuits according to the corresponding status and data in the I/O image area, and then drives the corresponding peripherals through the output circuit. At this time, it is the real output of the PLC.