Design and Implementation of a Variable Frequency Speed Control System Based on MODBUS Bus
2026-04-06 04:19:52··#1
Abstract: This paper discusses the application of MODBUS bus in variable frequency speed control systems. The basic specifications of the MODBUS communication protocol are introduced, and variable frequency speed control technology in motor control systems is briefly described. Based on the Yaskawa VS606-V7 inverter and the 89S52 microcontroller, a variable frequency speed control system based on MODBUS communication is developed, and the hardware composition and related software development of the system are explained. Keywords: MODBUS, variable frequency speed control system Introduction Modern industrial automatic control systems are developing towards intelligence, networking, and open architecture. Utilizing fieldbus technology to unify various intelligent devices conforming to the same standard completely realizes decentralized control of the entire monitoring system, improving system integration and data transmission efficiency, extending the effective control distance, and enhancing system anti-interference performance and expanding system functionality. In the low-level control of equipment, variable frequency speed control has become an important development direction of modern motor control technology. Unifying bus communication with variable frequency control technology will promote the development of AC motor group control technology and remote equipment monitoring technology. MODBUS, as a universal fieldbus, has been widely used, and many manufacturers' industrial controllers, PLCs, frequency converters, intelligent I/O, and A/D modules have MODBUS communication interfaces. This article, based on the explanation of the MODBUS communication protocol, constructs a MODBUS-based variable frequency speed control system and discusses its application in an automatic mooncake filling production line. 1. Technical Characteristics of the MODBUS Bus Control System The MODBUS communication protocol is an industrial fieldbus communication protocol. It defines an information frame structure that a device controller can recognize and use, independent of the physical layer medium, and can be carried in various network types. The MODBUS protocol defines communication participants as "Master" and "Slave". Data and information communication follows the master/slave mode. When applied to a standard MODBUS network, information is transmitted directly. The various intelligent devices in the MODBUS bus network are connected through an asynchronous serial bus. Only one controller is allowed as the master, and the remaining intelligent devices are slaves. A command/response communication method is used. The master sends a request, and the slave responds to the request and sends back data or status information. Slaves cannot send information themselves. The MODBUS protocol defines various information frame formats that describe the process of a master controller accessing slave devices, specify how slave devices should respond, and check and report transmission errors. Each slave device in the network must be assigned a unique address, and only slave devices that meet the address requirements will respond to commands issued by the master device. Because the MODBUS bus system is low-cost to develop, easy to use, and now has many industrial controllers, PLCs, frequency converters, displays, etc., with MODBUS communication interfaces, it has become a recognized communication standard. Through the MODBUS bus, control devices from different manufacturers can be easily connected into an industrial network for centralized monitoring. MODBUS was originally designed for PLC communication, using 24 bus commands to exchange information between the PLC and the outside world. The communication functions corresponding to these bus commands mainly include AI/AO and DI/DO data transmission. However, many MODBUS devices only use a few of these commands and do not respond to the others. 1.1 MODBUS Communication Format The MODBUS protocol defines two transmission modes: RTU (Remote Terminal Unit) and ASCII. In RTU mode, one byte of information is sent as an 8-bit character, while in ASCII mode it is sent as two ASCII characters. For example, sending the character "20" in RTU mode is "00100000", but in ASCII mode it becomes "00110010" + "00110000" (ASCII characters "2" and "0"). Therefore, when sending the same amount of data, RTU mode is approximately twice as efficient as ASCII mode. Generally, ASCII is used when the data volume is small and mainly text; RTU mode is more commonly used when the communication data volume is large and consists of binary values. The master station can send communication requests (or instructions) to one or all slave stations at a time. The master device selects the slave device through the address field of the message frame. The content and order of the message frame sent by the master station are: slave address, function code, data field (data start address, data volume, data content), and CRC checksum; the content and order of the slave station's response are basically the same as the master station's message frame. In addition to defining communication function codes, MODBUS also defines error codes to indicate error information. After receiving the error code, the master station takes appropriate measures based on the cause of the error. The slave station responds with data based on the function code; for example, function code 03 requests the reading of the holding register in the slave device. 1.2 Implementation of CRC Check In MODBUS communication's RTU mode, the last two bytes of the information frame are designated to transmit the CRC (Cyclic Redundancy Check) code. The sender shifts all bytes of the address field, function code, and data field in the information frame according to a specified method and performs an XOR operation to obtain a 2-byte CRC code. The information frame containing the CRC checksum is then transmitted as a continuous stream. When the receiver receives the information frame, it performs the same calculation and compares the result with the received two-byte CRC code. If they match, the communication is considered correct; otherwise, the communication is considered incorrect, and the slave station sends a CRC error response. RTU mode generally uses the CRC-16 redundancy check method. The CRC-16 checksum is 16 bits (2 bytes), with the low byte first and the high byte last. There are two methods to implement CRC checksums: calculation based on the definition formula of CRC checksums, or establishing a CRC checksum table in the program. The former is easier to implement in the program, requiring the use of the CRC generator polynomial X¹⁶ + X¹⁵ + X² + 1. The code group coefficients corresponding to this polynomial are 18005H (hexadecimal). Removing the most significant bit, the corresponding 16-bit remainder is 8005H, which is the CRC-16 constant. The CRC-16 checksum process is as follows: Preset each bit of the CRC register to 1; XOR the register value with the 8-bit information frame data, and store the result in the register; shift the CRC register from high to low, padding the most significant bit (MSB) with zeros, and if the least significant bit (LSB, which has been shifted out of the CRC register) is 1, then XOR the register with the CRC-16 constant; otherwise, if the LSB is zero, no XOR is needed. Repeat the high-to-low shift process 8 times. After the first 8 bits of data are processed, XOR the current register value with the next 8 bits of data and perform the same 8-shift process. The value in the CRC register after all characters are processed is the final CRC value. When adding the CRC to the message, the low byte is added first, followed by the high byte. 1.3 Link Characteristics The physical layer of the MODBUS standard can use RS-232 serial communication, but RS-422 or RS-485 is often used instead in long-distance communication. Only RS-485 is used in multi-point communication, so MODBUS systems in RTU mode use shielded twisted-pair cables, and the communication distance can reach 1000m. A maximum of 31 slave devices can be configured on a single bus. Information exchange on the transmission line is half-duplex, meaning only one device can send information at a time. The master station waits for the slave station's response before sending the next instruction, thus avoiding line collisions. The RTU mode transmission format is 1 data bit, 2 stop bits, and no parity bit. Communication data security is guaranteed by the CRC-16 code control parameter. The RTU receiving device determines the start of a frame based on the elapsed time between received characters. If no new character or frame is completed after 3.5 character intervals, the receiving device will abandon the frame and set the next character as the start of a new frame. 1.4 Data Flow of MODBUS Bus Communication In a SCADA system built using the MODBUS bus, the control devices in both the master and slave stations must implement the MODBUS communication protocol. The communication protocol implementation process of the master controller can be represented as shown in Figure 1. 2 Basic Principles of Variable Frequency Control According to the principles of motor theory, the formula for the speed of an AC motor is: n = (1-s) n0 = 60f(1-s) /p Where: n is the motor speed; n0 is the synchronous speed; f is the power supply frequency; p is the number of pole pairs of the motor; s is the slip rate. As shown in the above formula, when p and slip s remain constant, the motor rotor speed n is directly proportional to the stator power supply frequency f. By continuously changing the frequency of the asynchronous motor's power supply, the motor speed can be continuously and smoothly adjusted. This is the working principle of a frequency converter. General-purpose frequency converters basically adopt a V/F control method, meaning that the frequency F and amplitude U of the output voltage are simultaneously controlled, ensuring a constant V/F value. During operation, the frequency converter's main circuit performs AC-DC-AC conversion. The internal microcontroller adjusts the PWM output frequency according to the field setting signal, controlling the conduction time of the MOSFET transistors and changing the output frequency of the main circuit to adjust the motor's output speed. The frequency converter has comprehensive protection functions, such as overcurrent, overvoltage, undervoltage, overheating, and overload protection. When the motor experiences a stall fault, the frequency converter should reliably trip to protect the motor. The frequency converter has a fault memory for each fault, recording the latest fault for operators to analyze. Many frequency converters now come with PID functionality, accepting speed sensor signals and completing closed-loop control within the converter. The frequency of the power output from the frequency converter can be adjusted manually via the knob on the operation panel, or a control signal (voltage, current, frequency, or digital quantity) can be connected to the frequency setting input terminal to achieve remote control mode. Remote control methods for frequency converters include: (1) 0-10V voltage input; (2) 4-20mA current input; (3) pulse frequency control; (4) bus communication control. Most frequency converters now support bus control such as Modbus and Profibus. The frequency converter can also freely switch between manual and automatic working modes. In automatic mode, the above analog or digital inputs need to be implemented by the controller; when switching to manual mode, the control voltage of 0-10V can be obtained by adjusting the external potentiometer to divide the reference voltage. 3. Implementation of a MODBUS-based Variable Frequency Speed Control System 3.1 System Composition A variable frequency drive with a built-in MODBUS bus interface is selected. A PLC, microcontroller, or PC is integrated as the master controller to build an automatic control system for the production line. This leverages the excellent performance of MODBUS bus control and variable frequency speed control to achieve centralized control of the equipment. The system's composition principle is shown in Figure 2. 120-ohm resistors need to be configured at both ends of the bus. The Yaskawa VS606 V7 AC variable frequency drive, in addition to voltage, current, pulse input, and knob control, also supports point-to-point MODBUS protocol communication. Its hardware interface uses RS422/485 serial communication; the software interface protocol uses MODBUS RTU mode, and each 8-bit byte in the message frame contains two 4-bit hexadecimal numeric characters. The AT89S52 microcontroller in Figure 2 expands two communication ports: one is a reserved RS232 serial port, and the other is an RS485 interface expanded via the MAX485 chip. As the master microcontroller, the AT89S52 connects multiple V7 frequency converters and intelligent slave stations with MODBUS RTU interfaces to form a digital communication control network via RS485 bus. The AT89S52 can send parameter setting, start/stop, and data query commands to the slave frequency converters, and the frequency converters control the motor system according to the command requirements and return information. This system can not only realize remote control of AC motors, but also connect to the human-machine interface through the 89S52 to complete the start-up, speed-up, speed-down and stop operations and monitoring of the entire production line (simulation diagram display, parameter setting and browsing of historical data). The advantages of this system are: (1) The 89S52 directly uses the MODBUS protocol to read and write AC frequency converters without the need for other accessories for configuration, which simplifies the hardware and can obtain the working status of each frequency converter in real time, including operating status, operating parameters, fault alarms, etc. (2) The connection between the master station controller and the slave station inverter only requires two communication lines, which greatly reduces the complexity of the line connection and improves the system reliability; (3) It extends the control distance of the system; (4) It collects various motor operating parameters and displays them on the LCD, eliminating the need for various field intelligent instruments and greatly reducing the complexity of the line connection; (5) It can easily exchange information with high-precision networks, thereby achieving a high degree of factory automation. The system operating parameters can be designed through the setting button of the master station controller. Some important parameters are directly stored in the 32K-byte EEPROM chip AT24C32. By setting the inverter parameters, the system can be operated in manual or automatic program control mode and can be switched freely. 3.2 System Software Design The microcontroller program is written in C51 language and adopts a top-down modular design method. The entire program includes sub-modules for system initialization, serial port transmission, serial port interrupt reception, 485 communication, LCD display, keyboard reception, alarm and other functions. In the application, MODBUS protocol communication is implemented by the communication sub-module, which includes CRC-16 calculation and verification, information frame compilation and decomposition. Each instruction can operate on the inverter at a specified address; the information frame includes the number of bytes of data, the starting address, etc. The V7 inverter uses only three function codes: 03H, 08H, and 10H, which respectively implement the functions of data reading, loop feedback testing, and data writing, as described in Table 1. To implement MODBUS bus control, the inverter's operating parameters need to be preset: n003=2 (device start/stop controlled via bus), n004=6 (output frequency controlled via bus communication), and communication parameters are set in n151 to n157. In this system, the inverter is set to no timeout detection, frequency command unit of 0.01Hz, communication baud rate of 9600bps, no parity check, 8 data bits, 1 stop bit, and RS control, while the inverter address can be set from 0 to 32. After setting the inverter parameters, the controller can send communication commands via the RS485 bus. The communication process can be represented by Figure 3. There is a certain time interval between the microcontroller's master station command and the inverter/intelligent device's response signal, which needs to be implemented in the program using a loop delay statement. 4. Conclusion We applied the MODBUS bus-controlled variable frequency speed regulation system developed in this paper to an automatic mooncake filling production line. On this production line, the controller, with a microcontroller as its core, controls four V7 inverters via the MODBUS bus. These four inverters control the amount of outer filling, inner filling, skin volume, and the closing frequency of the cutting disc of a mooncake through a speed-changing mechanism and a motor, respectively. Practice shows that the application of MODBUS bus communication, variable frequency speed regulation, and LCD display technology reduces the number of wiring in the control system, improves system integration and reliability, allows for arbitrary adjustment of mooncake ingredients within a wide range, and its user-friendly interface greatly improves the operational performance of the equipment and enhances the product's market competitiveness. Therefore, directly utilizing the MODBUS protocol for network monitoring is a good way to achieve low cost and high performance in mechanical equipment control systems. References: 1. Yan Wensheng, Yang Wei, Chen Shiquan, et al. Application of variable frequency speed controller in the transformation of speed control system of powder feeder. Journal of Electric Power, 2000(2). 2. Zhang Shaodong. Principle and design of general frequency converter. Electronic Quality, 2003(12). 3. Lu Wenjun, Leng Shan, Yang Jianjun. Remote monitoring system of controller based on MODBUS protocol. Electric Power Automation Equipment, 2003, 23(6). 4. Xu Tao, Yan Ke, Zhao Jinglin. Serial interface implementation and DCS communication based on MODBUS protocol. Industrial Control Computer, 2002, 15(3). 5. Pan Hongyue. Design and implementation of communication based on MODBUS protocol. Metrology Technology, 2002, (4). 6. Wang Youqing, Tian Yongtao, Li Congxin. Communication between industrial control computer and frequency converter in Modbus RTU mode. Machine Tool & Hydraulics, 2002, (6). 7. Liang Wei. Modbus protocol communication software for intelligent devices written using C51. Chemical Automation and Instrumentation, 2004, 31 (1).