Design of a Modbus-based intelligent industrial controller monitoring system
2026-04-06 07:28:25··#1
Abstract: This design includes a lower-level intelligent industrial controller and a higher-level monitoring program developed using KingSCADA 6.51 software. The two communicate via the popular Modbus protocol. The former uses an intelligent expert PID control algorithm to control physical quantities such as temperature, pressure, and liquid level, while the latter is used for reading and writing parameters from the lower-level controller, displaying data, issuing alarms, and printing reports, thus realizing a complete and reliable industrial monitoring system. The system has shown satisfactory results in manufacturer use and has broad application prospects. Keywords: Intelligent industrial controller; KingSCADA 6.51; Modbus protocol; Intelligent expert PID; Industrial monitoring system Introduction With the development of modern industry, the control of industrial equipment is gradually evolving from single, independent systems to distributed control and monitoring systems. Therefore, this paper designs an intelligent industrial controller monitoring system based on the Modbus protocol. Utilizing the intelligent expert PID control algorithm, it can accurately control parameters such as temperature, pressure, liquid level, and humidity in the industrial field. Furthermore, the higher-level configuration software can be used to read and write field parameters, display data, issue alarms for exceeding limits, and print reports, thus realizing a complete industrial monitoring system. 1 System Composition and Working Principle of Intelligent Industrial Controller 1.1 Hardware System The system block diagram of the intelligent industrial controller is shown in Figure 1. It uses AT89C55WD microcontroller as CPU[1] and serial data acquisition is performed by ICL7135 dual-slope A/D converter. The rising edge of the Busy signal of ICL7135 triggers timer T0 to start counting pulses. When the conversion is completed, the falling edge of the Busy signal triggers INT0 interrupt to read the count value of timer T0. After a simple conversion, the A/D conversion value can be obtained. The analog switch 4051 controls the on/off state of 8 channels. The CPU configures the signal processing circuit and the selection status of the multiplexer. The reference clock signal of the 12-stage serial frequency divider CD4040 uses the ALE signal of the AT89C55WD microcontroller. Since the MOVX instruction is not used in the program, the ALE output frequency is fixed at fosc/6. After 2 stages of frequency division (fosc/24=250KHz) and 11 stages of frequency division (fosc/12288=500Hz), it is input to the CLK terminal of the ICL7135 and the INT1 terminal of the microcontroller, respectively, serving as the clock reference for the ICL7135 and the external 2ms timer interrupt for the microcontroller. Ports P0, P2, and P1.3 are used to scan the four buttons and eight common-anode LEDs. The 24C02 is a 256-byte non-volatile EEPROM memory based on a two-wire IIC bus, used to store important system parameters. The TOP221P is a wide voltage input (85~260V), low power (5W) switching power management chip, so the controller can directly use 220V AC mains power. Input modules can be selected from: (1) thermocouples and RTDs, such as K, Pt100, Cu50, etc.; (2) linear voltage/current: 0~5V, 4~20 mA, etc.; (3) others: sensors that can be specified by the user according to actual needs. Output modules can be selected from: (1) relay contact switch output; (2) thyristor contactless switch output; (3) SSR voltage output; (4) thyristor trigger output; (5) linear current output; (6) current transmitter output. The alarm module is: 2-channel relay switch output (AL1 and AL2). [align=center] Figure 1 System block diagram[/align] 1.2 Software system The system program block diagram is shown in Figure 2. When the industrial controller starts, it first enters the initialization program to perform a self-test on the system. Then, the relevant system setting parameters are read from the EEPROM into the internal RAM. The input specification parameter SN is read to determine whether the input is a thermocouple or RTD. If so, linear compensation is performed according to the corresponding linear compensation table; otherwise, the input is a linear current or voltage and no compensation is needed. The program then reads the key value of the keyboard after debouncing processing from the 2ms external timer interrupt service routine, and uses state analysis to determine the corresponding parameters and LED display interface. The A/D sample value is read, and the digital filter setting parameter DL is adjusted according to the actual field situation to perform relevant filtering processing, so that the resulting measurement data PV is relatively smooth and stable. The setpoint SV is then read, and the measured value PV is sent to the LED display respectively. The control mode parameter CTRL is read. If it is 0, it is basic on-off control: the output is determined by judging the relationship between the measured value PV and the setpoint SV. Hysteresis DF is used to avoid frequent on-off adjustment or frequent alarm generation/deactivation due to fluctuations in the measured input value. When SV-PV>DF, the output is the maximum allowed output OPH of the system; otherwise, the minimum allowed output OPL of the system is used. If CTRL is 1, it is intelligent expert PID control. [align=center] Figure 2 System Program Flowchart[/align] 1.3 Intelligent Expert PID Control Intelligent expert PID control [2] is based on the knowledge of the control law of the controlled object, and uses this knowledge in an intelligent way to design a PID controller. The principle of intelligent expert PID control is shown in Figure 3. Among them, the error amount e(k) = SV-PV(k), the error change; U(k) is the output of the controller for the kth time. [align=center] Figure 3 Intelligent Expert PID Control Flowchart[/align] The expert rules formulated according to e(k) and □e(k) are as follows: (where A and B are the set error limits, A>B; k[sub]1[/sub] is the gain amplification coefficient, k[sub]1[/sub]>1; k[sub]2[/sub] is the suppression coefficient, 0 When |e(k)| < ε, it indicates a large error, and the system should output at its maximum (or minimum) allowable value. When e(k)/□e(k) > 0, it indicates the absolute value of the error is increasing, and the PID control parameters should be adjusted based on the value of |e(k)|. When e(k)/□e(k) < 0, and □e(k)/□e(k-1) > 0 or e(k) = 0, it indicates the absolute value of the error is decreasing, and the output can be kept constant. When e(k)/□e(k) < 0, the PID derivative parameters should be adjusted based on the value of |e(k)|. When |e(k)| < ε, it indicates a very small absolute value of the error, and the PID integral parameters should be adjusted to reduce the steady-state error. All constants in this rule set are positive real numbers, and these parameters can be set on the controller setting mechanism after simulation and experimental tuning. Alternatively, these parameters can also be read and written via a host computer. During control, the controller performs intelligent control of the controlled object according to expert rules. Verification shows that the control accuracy is high and the effect is good. The system program reads the corresponding setting parameters according to the output module type, converts the previously calculated values into corresponding output values, such as current and voltage, and sends them to the output module for output. Then the program judges the upper limit, lower limit, positive deviation, negative deviation, input over-range and other alarm parameters. If there are any, they are sent to the alarm output module for output; otherwise, no response is made. The system then parses the received data and performs corresponding processing according to the Modbus communication protocol, including data CRC verification, data packaging, reading and writing related parameters, etc. 2 Modbus fieldbus communication protocol Generally, the monitoring system based on Modbus fieldbus[3] adopts the master-slave query-response interaction mode. This system uses RTU (remote terminal device) mode. The message is sent with a pause of more than 3.5 characters. The master sends the address of the slave to be accessed. Each slave device decodes to determine whether it is sent to itself. The function code tells the selected slave what function to perform. The data segment contains additional information: which register to start reading from and the number of registers to be read. The slave device's response message uses its local address as the device address, the function code is a response to the function code in the master's query message, and the data segment includes the slave's register information. If an error occurs, the function code and data segment contain codes describing the error information, and the error detection field is used by the master to confirm whether the slave's response message is usable. A pause of more than 3.5 characters after the last transmitted character marks the end of the message frame. The entire message frame must be transmitted as a continuous data stream. If there is a pause of more than 1.5 characters before the frame is completed, the receiving device will determine that the data has timed out and is unavailable, refresh the incomplete message, and assume that the next byte is the address field of a new message. Similarly, if a new message continues from the previous message in less than 3.5 characters, the receiving device will consider it a continuation of the previous message, both of which will lead to CRC check errors. 3 Monitoring System Based on Modbus Fieldbus 3.1 Communication Module of Intelligent Industrial Controller 3.1.1 Hardware Interface The physical layer of the Modbus protocol generally uses RS-485 half-duplex structure as the communication interface standard. RS-485 uses two-wire differential level transmission and reception, effectively overcoming common-mode interference and suppressing line noise, with a transmission distance of up to 1.2km. Since the microcontroller's logic levels need to be isolated by an optocoupler 6N137 and converted into RS-485 differential signals for transmission on the bus, the TI SN75LBC184 RS-485 transceiver can be used. This transceiver features transient voltage suppression to prevent damage from electrostatic discharge (ESD). Furthermore, the SN75LBC184 limits the slope of signal changes, reducing electromagnetic interference. At least 64 such transceivers can be connected to the bus, achieving a maximum communication rate of 250kbps. The Modbus communication module principle is shown in Figure 4. [align=center] Figure 4 Communication Module[/align] 3.1.2 Software Programming Modbus Communication Data Parsing and Processing Program[4] Block diagram is shown in Figure 5. According to the Modbus communication protocol, the lower-level program detects the slave address accessed by the host. If it is the local machine, it performs CRC verification. If it is correct, it performs function code parsing program. According to the function code, it enters the corresponding subroutine, performs data packaging and corresponding parameter processing, and then sends Modbus data packets. [align=center] Figure 5 Modbus Communication Data Parsing and Processing Program[/align] 3.2 Upper-level Monitoring System Since the Modicon Modbus (RTU) driver in the KingSCADA 6.51 software[5] is based on the Modbus communication protocol, when using it, you only need to refer to the manual of the KingSCADA software to operate. By compiling the monitoring screen, setting the baud rate, verification method, communication method, lower-level address, I/O variables and types used for communication, variable registers and sampling frequency, etc., communication with the lower-level machine can be realized. Figure 6 is a monitoring system screen of 10 industrial controllers connected by KingSCADA 6.51 software. The baud rate is set to 4800, with no parity, Modbus (RTU) unpack mode, address 1-10, and data acquisition frequency of 400ms. Since only the first industrial controller is connected to the actual monitoring system, the remaining screens display "???". This host computer monitoring system can realize functions such as reading and writing data from the slave devices, saving and querying historical data, alarms, and report printing, thus realizing the design of a host computer monitoring system for intelligent industrial controllers based on the Modbus fieldbus. [align=center] Figure 6 Monitoring Screen[/align] 4 Conclusion The intelligent industrial controller monitoring system based on the Modbus protocol can connect at least 64 intelligent industrial controller slave devices, and the KingSCADA host computer monitoring program can be used by making corresponding adjustments according to actual needs. Moreover, with appropriate modifications, this intelligent industrial controller program can also be used as a twenty-segment programmable process curve controller; by reasonably selecting sensor input modules, it can meet the control requirements of various industrial field parameters. This monitoring system is low-cost, high-performance, and easy to use. Actual use by the manufacturer has verified that the effect is quite ideal, with broad application prospects and an estimated economic benefit of over 1 million yuan. References: 1. Zhao De'an. Principles and Applications of Single-Chip Microcomputers. Beijing: Machinery Industry Press, 2004. 2. Liu Jinkun. Advanced PID Control and its MATLAB Simulation. Beijing: Electronic Industry Press, 2003.1. 3. MODICON INC. Industrial Automation Systems, "Modicon Modbus Protocol Reference Guide", June 1996. 4. Zhu Yi, Jiang Nianping. Application of Modbus Protocol in Industrial Control Systems. Microcomputer Information, 2006, 10: 118-120. 5. Beijing Yacon Technology Development Co., Ltd. "KingSCADA 6.51 User Manual", 2006. Design of Intelligent Industrial Controller Monitoring System Based on Modbus