PLC (Programmable Logic Controller) is a computer used in industrial control. Its basic components include power supply, CPU, memory, input unit, output unit, communication interface, and expansion interface.
a) Power Supply: The PLC can be powered by 220VAC or 24VDC, while the CPU processing unit requires a 5VDC power supply.
b) CPU (Central Processing Unit): This includes the controller, arithmetic unit, and registers.
c) Memory: This is a semiconductor circuit with memory functions, capable of storing system programs, user programs, and logical variables. It is divided into ROM (Read Only Memory) for system storage and RAM (Random Access Memory).
i. ROM Storage Area: Divided into system management programs, user program editing and instruction interpretation programs, subroutine calls, and management programs.
ii. RAM Storage Area: Includes user program storage and data storage, used for placing user programs and the ON/OFF status during program execution. User storage area data can be read and written. Typically, CMOS RAM, EPRAM, and EEPRAM materials are used. Capacity is usually measured in “words” (16 bits is 1 word, 8 bits is 1 byte). Therefore, it is recommended to use even-numbered programming.
d) Input Unit: This receives signals, detects incoming information, and converts it into digital signal levels (high and low). (Divided into discrete and analog signals, with analog signals usually converted to digital via an A/D conversion circuit. Digital interfaces include internal DC input (12V or 24V), external AC input (100-120V, 200-240V), AC/DC input, and input circuits connected to signal outputs.)
e) Output Unit: Converts weak signals processed by the CPU into level signals. (Level signal refers to the ratio of output signal power to input signal power, usually represented by P, where P=lgP2/P1. Output interfaces are divided into discrete and analog outputs. Analog interfaces usually convert digital signals to analog via a D/A conversion circuit. Discrete outputs include relay outputs, transistor outputs (PNP, NPN), and triac outputs.)
f) Communication Interface: Allows communication with monitors, printers, other PLCs, and computers.
g) Expansion Interface: Adds specialized function modules to the PLC, such as high-speed counting modules, closed-loop control modules, motion control modules, and interrupt control modules.
Working Principle of PLC
PLC Power On → Internal Processing → Communication Processing → Self-Diagnosis → Input Sampling → User Program Execution → Output Refresh → …
PLC operates in a cyclical scanning mode with centralized input and output.
Advantages: High reliability, strong anti-interference ability.
Disadvantages: Slow response speed, response lag. PLCs use a Watchdog Timer (WDT) to monitor if the scan time exceeds the preset duration.
Internal Self-Processing: Includes hardware initialization, I/O module configuration checks, and power failure protection range settings. During the self-diagnosis phase, the CPU checks the status of each PLC module. If an abnormality is detected, it immediately diagnoses and processes it, while issuing a fault signal and lighting up the LED indicator on the CPU panel. If a fatal error occurs, the CPU is forced to STOP mode, halting program execution. Self-diagnostic testing helps detect or predict system faults, improving reliability.
Communication Processing Stage: PLC communicates with intelligent modules equipped with CPUs and other external devices to complete data transmission and reception, respond to programmer commands, and update the programmer’s display, clock, and special register contents. If there are communication tasks, the CPU calls the appropriate process to handle communication with other devices (e.g., intelligent modules with microprocessors, remote I/O interfaces, programmers, HMI devices) and processes communication data accordingly.
Input Sampling Stage: Scans all input terminals, stores their status (0/1) in the input register (PII), then closes the input channel for the next program. This method is highly reliable but has some delay. In large projects, due to time constraints, periodic input sampling, direct input sampling, interrupt input sampling, and intelligent I/O interface sampling may be used to improve speed.
User Program Execution Stage: Data is retrieved from the input register (PIQ) and internal component registers (internal relays, counters, timers), and the relevant component status and data are extracted. After logical and arithmetic operations in the program, results are written to the output image register and related memory. Therefore, internal component register status in the PLC is constantly changing.
Output Processing Stage: After program execution, all output relay states in the internal component register are transferred to the output latch in one go during the output stage, and then sent to the output terminal after isolation and power amplification to drive the actual load.
Input/Output Delay Time: Also known as system response time, includes input circuit filter time, output circuit delay time, and scan cycle delay time. PLC response delay generally ranges from a few milliseconds to tens of milliseconds, which is insignificant for most systems. For time-sensitive systems, faster scanning PLCs or interrupt measures can be used.
a) Input Circuit Filter Time: External signals may have noise, spike voltage, or jitter affecting input signals. RC filter circuits (using a voltage source and current source driving a capacitor and resistor) and optocouplers (cutting off internal and external circuit electrical connections) are used to eliminate these effects. Filter circuit time constant determines filter duration.
b) Output Module Circuit Delay Time: Depends on the type. Relay output module delay is typically 10ms, triac delay is 1ms-10ms, and transistor delay is below 1ms.
c) Scan Cycle Delay Time: Can reach up to 2-3 scan cycles.