A programmable logic controller (PLC) is a digital electronic system designed for industrial applications. It utilizes programmable memory to store instructions for performing logical operations, sequential control, timing, counting, and arithmetic operations. Through digital and analog inputs and outputs, it controls various types of machinery or production processes. PLCs and their peripherals should be designed to easily integrate with industrial control systems and facilitate functional expansion.
2. Classification of PLCs
PLC products come in a wide variety, with varying specifications and performance. PLCs are generally classified based on their structural form, functional differences, and the number of I/O points.
2.1. Classification by structural form
Based on their structural form, PLCs can be divided into two categories: integrated and modular.
(1) Integrated PLC
An integrated PLC integrates the power supply, CPU, I/O interfaces, and other components into a single chassis, as shown in the figure. It features a compact structure, small size, and low price. Small PLCs generally adopt this integrated structure. An integrated PLC consists of basic units (also called the main unit) with varying numbers of I/O points and expansion units. The basic unit contains the CPU, I/O interfaces, expansion ports connecting to I/O expansion units, and interfaces connecting to a programmer or EPROM writer; the expansion units only contain I/O and power supplies, but no CPU. The basic unit and expansion units are generally connected by flat cables. Integrated PLCs can also be equipped with special function units, such as analog units and position control units, to expand their functionality.
(2) Modular PLC
Modular PLCs separate their components into several individual modules, such as CPU modules, I/O modules, power supply modules (sometimes included within the CPU module), and various functional modules. A modular PLC consists of a frame or base plate and various modules, which are mounted in sockets on the frame or base plate, as shown in the figure. The advantages of this type of PLC are flexible configuration, allowing for the selection of systems of different sizes as needed, easy assembly, and convenient expansion and maintenance. Large and medium-sized PLCs generally adopt a modular structure.
Some PLCs combine the features of integrated and modular designs, forming what are known as stacked PLCs. In a stacked PLC, the CPU, power supply, I/O interfaces, etc., are also independent modules, but they are connected by cables, and these modules can be stacked layer by layer. This allows for flexible system configuration and a compact size.
2.2. Classification by Function
Based on their different functions, PLCs can be divided into three categories: low-end, mid-range, and high-end.
(1) Low-end PLC
Low-end PLCs have basic functions such as logic operation, timing, counting, shifting, self-diagnosis, and monitoring. They can also have a small number of analog input/output, arithmetic operation, data transmission and comparison, and communication functions. They are mainly used in single-machine control systems with logic control, sequential control, or a small number of analog control functions.
(2) Mid-range PLC
In addition to the functions of low-end PLCs, mid-range PLCs also have strong analog input/output, arithmetic operations, data transmission and comparison, number system conversion, remote I/O, subroutines and communication networking functions; some can also add interrupt control, PID control and other functions, making them suitable for complex control systems.
(3) High-end PLC
High-end PLCs, in addition to the functions of mid-range PLCs, also include functions for signed arithmetic operations, matrix operations, bit logic operations, square root operations, and other special functions, as well as tabulation and table transmission capabilities. High-end PLCs have enhanced communication and networking capabilities, enabling them to be used for large-scale process control or to form distributed network control systems, thereby achieving factory automation.
2.3. Classification by I/O points
Based on the number of I/O points, PLCs can be divided into three categories: small, medium, and large.
(1) Small PLC
Small PLCs have fewer than 256 I/O points, a single CPU, and an 8-bit or 16-bit processor, with user memory capacity of less than 4KB. For example, the Mitsubishi FX0S series.
(2) Medium-sized PLC
Medium-sized PLCs have 256 to 2048 I/O points, dual CPUs, and user memory capacity of 2 to 8KB.
(3) Large PLC
Large PLCs have more than 2048 I/O points, multiple CPUs and 16-bit or 32-bit processors, and user memory capacity of 8 to 16 KB.
Globally, PLC products can be divided into three main categories based on region: American, European, and Japanese. American and European PLC technologies were independently researched and developed in isolation, resulting in significant differences between their products. Japanese PLC technology, on the other hand, was introduced from the US and inherits some aspects of American PLC products, but Japan primarily focuses on small PLCs. While the US and Europe are known for their large and medium-sized PLCs, Japan is renowned for its small PLCs.
Common PLCs are shown in the table.
II. Functions and Application Areas of PLC
PLCs are designed, manufactured, and developed by combining the advantages of relay and contactor control with the flexibility and convenience of computers, which gives PLCs many features that other controllers cannot match.
1. Functions of PLC
A PLC (Programmable Logic Controller) is a general-purpose industrial automatic control device that integrates computer technology, automatic control technology, and communication technology, with a microprocessor as its core. It boasts a series of advantages, including high reliability, small size, powerful functions, simple programming, flexibility, versatility, and convenient maintenance. Therefore, it is widely used in metallurgy, energy, chemical industry, transportation, and power industries, becoming one of the three pillars of modern industrial control (PLC, robots, and CAD/CAM). Based on the characteristics of PLCs, their functional forms can be summarized into the following types.
(1) Switch logic control
PLCs possess powerful logic operation capabilities, enabling them to implement various simple and complex logic controls. This is the most basic and widespread application area of PLCs, as they have replaced traditional relay and contactor control.
(2) Analog control
The PLC is equipped with A/D and D/A conversion modules. The A/D module can convert analog quantities such as temperature, pressure, flow rate, and speed in the field into digital quantities, which are then processed by the microprocessor in the PLC (the microprocessor can only process digital quantities) and then used for control; or the D/A module can convert them into analog quantities, which can then be used to control the controlled object. This allows the PLC to control analog quantities.
(3) Process control
Modern large and medium-sized PLCs are generally equipped with PID control modules, enabling closed-loop process control. When a variable deviates during the control process, the PLC can calculate the correct output according to the PID algorithm, thereby controlling and adjusting the production process to keep the variable at its set value. Currently, many small PLCs also have PID control functionality.
(4) Timing and counting control
PLCs possess powerful timing and counting capabilities, providing users with dozens, hundreds, or even thousands of timers and counters. The timing and count values can be arbitrarily set by the user when writing the user program, or by operators in the industrial field via a programmer, thus achieving timing and counting control. If users need to count high-frequency signals, a high-speed counting module can be selected.
(5) Sequence control
In industrial control, sequential control can be achieved by using PLC step instruction programming or shift register programming.
(6) Data processing
Modern PLCs can not only perform arithmetic operations, data transmission, sorting, and table lookup, but also data comparison, data conversion, data communication, data display, and printing, demonstrating their strong data processing capabilities.
(7) Communication and networking
Most modern PLCs employ communication and networking technologies, featuring RS-232 or RS-485 interfaces for remote I/O control. Multiple PLCs can be networked and communicate with each other. External devices can exchange programs and data with the signal processing units of one or more programmable controllers, enabling functions such as program transfer, data transfer, monitoring, and diagnostics. Communication interfaces or processors utilize standard hardware interfaces or proprietary communication protocols to transfer programs and data.
2. Application areas of PLC
Currently, PLCs are widely used in various industries both domestically and internationally, including steel, petroleum, chemical, power, building materials, machinery manufacturing, automobiles, light textiles, transportation, environmental protection, and cultural entertainment. Their usage can be broadly categorized as follows.
(1) Logic control of switching quantities
This is the most basic and widespread application area of PLC. It replaces the traditional relay circuit to realize logic control and sequential control. It can be used for the control of a single device, as well as for the group control of multiple machines and automated production lines, such as injection molding machines, printing machines, stapling machines, combination machine tools, grinding machines, packaging production lines and electroplating production lines.
(2) Analog control
In industrial production processes, many continuously changing quantities, such as temperature, pressure, flow rate, liquid level, and speed, are analog quantities. To enable PLCs to process analog quantities, analog-to-digital (A/D) and digital-to-analog (D/A) conversions must be implemented. PLC manufacturers produce matching A/D and D/A conversion modules to enable PLCs for analog control.
(3) Motion control
PLCs can be used to control circular or linear motion. In terms of control mechanism configuration, early PLCs directly connected position sensors and actuators via digital I/O modules. Now, dedicated motion control modules are generally used, including single-axis or multi-axis position control modules that can drive stepper motors or servo motors. Almost all major PLC manufacturers worldwide offer products with motion control capabilities, and they are widely used in various machinery, machine tools, robots, elevators, and other applications.
(4) Process control
Process control refers to the closed-loop control of analog quantities such as temperature, pressure, and flow rate, and it has a wide range of applications in metallurgy, chemical engineering, heat treatment, and boiler control. As an industrial control computer, a PLC can program various control algorithms to complete closed-loop control. PID control is a commonly used method in general closed-loop control systems; large and medium-sized PLCs all have PID modules, and many small PLCs now also have this function. PID processing typically involves running a dedicated PID subroutine.
(5) Data processing
Modern PLCs possess mathematical operations (including matrix operations, function operations, and logical operations), data transmission, data conversion, sorting, table lookup, and bit manipulation functions, enabling them to acquire, analyze, and process data. This data can be compared with reference values stored in memory to perform specific control operations; it can also be transmitted to other intelligent devices via communication functions or printed into tables. Data processing is generally used in large-scale control systems, such as unmanned flexible manufacturing systems; it can also be used in process control systems, such as some large-scale control systems in the paper, metallurgical, and food industries.
(6) Communication and networking
PLC communication includes communication between PLCs and communication between PLCs and other intelligent devices. With the development of computer control, factory automation networks are developing rapidly, and PLC manufacturers are paying close attention to the communication capabilities of their PLCs, launching their own network systems. Newly manufactured PLCs all have communication interfaces, making communication very convenient.
III. Basic Structure and Working Principle of PLC
As a type of industrial control computer, PLC has a similar structure to ordinary computers; however, due to different usage scenarios and purposes, there are some differences in structure.
1. Hardware components of a PLC
The basic structural block diagram of the PLC hardware system is shown in the figure.
In the diagram, the PLC main unit consists of a CPU, memory (EPROM, RAM), input/output units, peripheral I/O interfaces, communication interfaces, and a power supply. For an integrated PLC, all these components are housed in the same casing. For a modular PLC, each component is independently packaged, called a module, and these modules are connected together via a frame and cables. All parts within the main unit are connected via power buses, control buses, address buses, and data buses. Depending on the needs of the actual controlled object, certain external devices are added to form different PLC control systems. Commonly used external devices include programmers, printers, and EPROM writers. A PLC can be configured with a communication module to communicate with a host computer and other PLCs, forming a distributed PLC control system.
The following sections introduce the components of a PLC and their functions to help users further understand the control principles and working process of a PLC.
(1) CPU
The CPU is the control center of the PLC. Under the control of the CPU, the PLC works in an orderly and coordinated manner to control various devices in the field. The CPU consists of a microprocessor and a controller. It can perform logical and mathematical operations and coordinate the work of various parts within the control system.
The role of the controller is to control the various components of the entire microprocessor to work in an orderly manner. Its basic function is to read instructions from memory and execute instructions.
(2) Memory
PLCs are equipped with two types of memory: system memory and user memory. System memory stores the system management program, and users cannot access or modify its contents. User memory stores the programmed application programs and operating data status. The user memory section storing operating data status is also called the data storage area, and it includes an input/output data image area, a data area for timer/counter presets and current values, and a buffer for storing intermediate results.
The main types of PLC memory include the following.
(1) Read-only memory
(2) Programmable Read-Only Memory
(3) Erasable programmable read-only memory
(4) Electrically erasable programmable read-only memory
(5) Random Access Memory
(3) Input/Output (I/O) Module
① Switch input module
Digital input devices include various switches, buttons, sensors, etc. PLC input types typically include DC, AC, and AC/DC. The power supply for the input circuits can be externally supplied, or sometimes internally provided by the PLC.
② Switch output module
The function of the output module is to convert the TTL level control signals output by the CPU when executing the user program into signals required in the production site to drive specific equipment and thus drive the actuator.
(4) Programmer
A programmer is an important external device for a PLC. It allows users to load their programs into the PLC's user program memory, debug the program, and monitor its execution. Programmers can be structurally classified into three types.
(1) Simple programmer
(2) Graphical programmer
(3) General-purpose computer programmer
(5) Power supply
The power supply unit converts external power (220V AC) into the internal operating voltage. External power supplies are converted from AC/DC to the operating voltage (DC 5V, ±12V, 24V) required by the PLC's internal circuitry via a dedicated switching voltage regulator within the PLC. It also provides 24V DC power to external input components (such as proximity switches) (for input terminals only). The power supply driving the PLC load is provided by the user.
(6) Peripheral interface
The peripheral interface circuit is used to connect handheld programmers or other graphical programmers and text displays, and can form a control network for the PLC through the peripheral interface. The PLC uses a PC/PPI cable or MPI card to connect to a computer through an RS-485 interface, which can realize programming, monitoring, networking and other functions.
2. PLC Software Components
The software of a PLC consists of system programs and user programs.
The system program is designed and written by the PLC manufacturer and stored in the PLC's system memory. Users cannot directly read, write, or modify it. The system program generally includes system diagnostic programs, input processing programs, compilers, information transmission programs, and monitoring programs.
A PLC user program is a program written by the user using the PLC's programming language according to control requirements. In PLC applications, the most important aspect is writing the user program using the PLC's programming language to achieve the control objectives. Since PLCs are devices specifically developed for industrial control, their primary users are electrical technicians. To accommodate their traditional habits and proficiency, the main programming language for PLCs is a specialized language that is relatively simpler, easier to understand, and more intuitive than computer languages.
1. Graphical instruction structure
2. Explicit variable constants
3. Simplified program structure
4. Simplify the application software generation process
5. Strengthen debugging methods
III. Basic Working Principles of PLC
The PLC scanning process mainly consists of three stages: the input sampling stage, the user program execution stage, and the output refresh stage, as shown in the figure.
1. Input sampling stage
During the input sampling phase, the PLC sequentially reads all input states and data in a scanning manner and stores them in the corresponding units 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 in the corresponding units of 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 phase
During the user program execution phase, the PLC always scans the user program (ladder diagram) sequentially from top to bottom. When scanning each ladder diagram, it first scans the control circuit formed by the contacts on the left side of the ladder diagram, performing logical operations on the control circuit in a left-to-right, top-to-bottom order. Then, based on the result of the logical operation, it refreshes the state of the corresponding bit in the system RAM storage area for that logic coil, or refreshes the state of the corresponding bit in the I/O image area for that output coil, or determines whether to execute the special function instruction specified by that ladder diagram. That is, during user program execution, only the state and data of input points in the I/O image area remain unchanged, 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. Furthermore, the program execution result of the ladder diagram above will affect any ladder diagram below that uses those coils or data; conversely, the refreshed state or data of the logic coils in a lower ladder diagram will only affect the ladder diagram above it in the next scan cycle.
3. Output refresh phase
After the user program scan is complete, 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. This is when the PLC actually outputs data.
Input/output lag
From the working process of the PLC, we can summarize the following conclusions.
When a program is executed in a scanning manner, there is an inherent lag in the logical relationships between its input/output signals. The longer the scan cycle, the more severe the lag.
The scan cycle includes the time taken up by the three main working stages: input sampling, user program execution, and output refresh, as well as the time taken up by system management operations. The program execution time depends on the program length and the complexity of the instructions, while other aspects remain relatively constant. The scan cycle is typically in the nanosecond range.
• When executing the program for the nth scan, the input data is the scan value X from the sampling phase of this scan cycle. The output data includes the output value Y(n-1) from the previous scan and the output value Yn from the current scan. The signal sent to the output terminal is the final result Yn after all the operations are performed.
Input/output response lag is not only related to the scanning method, but also to the program design.