Application and Programming of MODBUS Protocol in PLC Communication

Click the ” Technical Training ” above and select “Pin to Top Public Account

160,000+ industrial control professionals follow this WeChat platform: Technical sharing, learning exchange, industrial control videos

Description: Now I will explain the application of MODBUS. Currently, most communication between the upper and lower machines in industrial control uses the MODBUS communication protocol, which highlights the importance of machine-to-machine communication.

1. MODBUS System Framework Diagram

Application and Programming of MODBUS Protocol in PLC Communication

2. Application of MODBUS

The underlying communication of MODBUS uses RS485 signals connected with twisted pairs, allowing for long transmission distances of up to 1000 meters, good anti-interference performance, and low cost. It is widely used in industrial control equipment communication. Many manufacturers’ frequency converters and controllers now use this protocol.

The data transmission formats include HEX code data and ASCII code, known as MODBUS-RTU and MODBUS-ASCII protocols, respectively. The former transmits data directly, while the latter requires conversion to ASCII code before transmission. Therefore, the MODBUS-RTU protocol has higher communication efficiency, is simpler to process, and is used more frequently.

MODBUS uses a master-slave communication method, employing a master query and slave response approach. Each communication is initiated by the master station, with the slave station responding passively. Therefore, controlled devices such as frequency converters typically have a slave protocol built-in, while control devices like PLCs must have both master and slave protocols.

Now, taking the MODBUS-RTU protocol as an example, the typical format of the communication frame is as follows: Request frame format: Slave address + 0x03 + Register starting address + Number of registers + CRC check.

Application and Programming of MODBUS Protocol in PLC Communication

Normal response frame format: Slave address + 0x03 + Byte count + Register value + CRC check

Application and Programming of MODBUS Protocol in PLC Communication

Application and Programming of MODBUS Protocol in PLC Communication

3. Information to Note When Programming PLC:

Slave address: In the master station’s sending frame, this address indicates the target receiving slave’s address; in the slave’s response frame, it indicates its own address. The slave address range is set from 1 to 247, with 0 as the broadcast communication address.

Operation type: Indicates read or write operations; 0x1 = read coil operation; 0x03 = read register operation; 0x05 = write coil operation; 0x06 = write register operation.

For frequency converters, only 0x03 read and 0x06 write operations are supported. Register starting address: Indicates the register address to be accessed in the slave; for MD280 and MD320 series frequency converters, this corresponds to the “function code number”, “command address”, and “operating parameter address”; Number of data: The number of consecutive data to be accessed starting from the “register starting address”, based on register variables in word units.

Register parameters (data): Data to be rewritten (host rewrites) or data to be read (slave responds);

4. Program Writing and Explanation

Application and Programming of MODBUS Protocol in PLC Communication

Application and Programming of MODBUS Protocol in PLC Communication

Conclusion: The above is an example of PLC communication. As long as these special registers are set, communication can be established, especially regarding the application of RS communication instructions and the special registers used in PLC communication.

Share with friends and increase knowledge together!

ClickRead the Original to learn about electrical engineering, PLC, frequency servo, CNC robots, and more.

Leave a Comment