Summary of ModBus RTU Issues

Click↑↑Technical Training, follow and pinto subscribe for free long-term

200,000+Industrial control professionals follow this WeChat platform: technical sharing, learning exchange, industrial control videos
1. What is the difference between ModBus RTU communication protocol and ModBus communication protocol?
The ModBus protocol is an application layer message transmission protocol (OSI model layer 7), which defines a Protocol Data Unit (PDU) independent of the communication layer, i.e., PDU = function code + data field.
The ModBus protocol can be applied in different types of buses or networks. For different buses or networks, the ModBus protocol introduces additional fields mapped to the Application Data Unit (ADU), i.e., ADU = additional fields + PDU. Currently, ModBus has the following three communication methods:
1. Ethernet, corresponding communication mode is MODBUS TCP.
2. Asynchronous serial transmission (various media such as wired RS-232/422/485; fiber optics, wireless, etc.), corresponding communication modes are MODBUS RTU or MODBUS ASCII.
3. High-speed token passing network, corresponding communication mode is Modbus PLUS.
2. Questions about the ModBus RTU communication protocol?
ModBus mainly consists of station address (one byte) + function code (one byte) + starting address (two bytes) + number of registers (two bytes) + checksum (CRC16 or LRC two bytes) totaling 8 bytes. Programming in VB is quite simple by adding the MSComm component; the difficulty lies in the checksum.
3. What are ModBus, RTU, and ModBus RTU?
The ModBus protocol is the standard protocol in the industrial control industry, originally written by Modicon and now acquired by Schneider.
ModBus is divided into two protocols: serial protocol (ModBus RTU) and network protocol (ModBus TCP). Generally, industrial control machines only support RS232 or RS485 serial modes, at which point the protocol stack of the industrial control machine only contains the ModBus RTU protocol. When it receives data from the serial port, it directly controls based on the data in the message. If ModBus TCP protocol is needed for transmission, a PLC with a network port must be used.
The specific frame formats are as follows:
ModBus RTU address field function code data error check
ModBus TCP destination address protocol ID length unit number function code data
In simple terms, TCP is processed from RTU, while RTU is another concept that is not included in the ModBus protocol, but is a shorthand for monitoring devices in the industrial control industry.
4. Questions about commands sent by the ModBus RTU protocol master
01 Read coil status (Read coil status)
02 Read input status (Read input status)
03 Read holding register (Read holding register)
04 Read input register (Read input register)
05 Write single coil (Force single coil)
06 Write single register (Preset single register)
15 Write multiple coils (Force multiple coils)
16 Write multiple registers (Preset multiple registers)
What do these mean?
Answer: 01 Read the status of the logical coil group
02 Read the status of the discrete coil group
03 Read the binary value of one or more holding registers
04 Read the binary value of one or more input registers
05 Change the status of the logical coil
06 Change the binary value of a single register
15 Change the binary value of multiple registers
16 Specify the binary values of multiple holding registers
5. How to connect OPC to ModBus RTU?
Protocols such as Profibus, Fielbus, Modbus, CC-link, etc., are communication protocols supported by various PLC hardware, which are the hardware attributes of various manufacturers. Computer configuration software now supports many types of PLC protocols. You have misunderstood.
Protocols like Profibus, Fielbus, Modbus, and CC-link are communication protocols that generally do not require programming, just like you do not need to write IP protocols when using a computer; you just need to follow them.
Following means that you must set the hardware according to the communication protocol supported by the manufacturer when configuring the PLC or DCS hardware. This is actually quite simple. Here, simple means that when you learn programming, the focus is on writing programs for executing control actions, while hardware communication protocols do not require you to write them yourself.
6. What is a ModBus RTU master?
This refers to selecting RTU mode, as MODBUS is divided into ASCII mode and RTU mode. MASTER is set as the master station, generally the PLC side, while the frequency converter is set as the slave station. You should also pay attention to the address settings of the master and slave stations.
7. Why does ModBus RTU not have start and end markers?
Because each byte of the Modbus RTU frame is a hexadecimal number, with a value range of 00~FF. If start and end markers like 02 and 03 are used as in Modbus ASCII, it would conflict with values 2 and 3, making it impossible to determine whether they are markers or values, thus preventing data unpacking.
8. Conversion from ModBus TCP to RTU?
Please carefully review the frame format:
modbus RTU address field function code data error check
modbus TCP destination address protocol ID length unit number function code data
Write a TCP to RTU conversion program and place it in the device to create a ModBus bridge.
9. What if the communication line of ModBus RTU is burned?
Use a multimeter to measure the voltage of the communication line; it should not exceed 5V. Generally, it should not burn anything. When connecting, distinguish between positive and negative. Many products have B as positive; check it out.
10. How to set up a touch screen for ModBus RTU?
Generally, this is achieved through macro instructions programmed by oneself; of course, there are also options that support RTU in the communication type menu.
11. How is a floating-point number stored in the MODBUS RTU protocol, and how is the value read from the floating-point register converted to the required floating-point number?
The byte format for saving floating-point numbers is as follows:
Address +0 +1 +2 +3
Content SEEE EEEE EMMM MMMM MMMM MMMM MMMM MMMM
Here, S represents the sign bit, 1 is negative, and 0 is positive.
E is the exponent offset by 127, where binary exponent = (EEEEEEEE) – 127.
M is a 24-bit mantissa stored in 23 bits, with the highest bit fixed at 1. This method achieves a high effective bit count with the least number of bits, improving accuracy. Zero is a specific value, and both exponent and mantissa are zero.
The floating-point number -12.5 is stored in the memory as a hexadecimal number 0xC1480000, as follows:
Address +0 +1 +2 +3
Content 0xC1 0x48 0x00 0x00
The conversion between floating-point and hexadecimal equivalent values is quite simple. The following example illustrates how the above value -12.5 is converted. The floating-point stored value is not in a direct format; to convert it into a floating-point number, the bits must be separated according to the floating-point storage format table listed above.
For example:
Address +0 +1 +2 +3
Format SEEEEEEE EMMM MMMM MMMM MMMM MMMM
Binary 11000001 01001000 00000000 00000000
Hexadecimal C1 48 00 00
From this example, the following information can be obtained:
The sign bit is 1, indicating a negative number; the exponent is binary 10000010 or decimal 130, and 130 minus 127 equals 3, which is the actual exponent.
The mantissa is the following binary number 10010000000000000000000.
There is an omitted decimal point and 1 to the left of the mantissa; this 1 is often omitted in floating-point storage. Adding a 1 and a decimal point to the beginning of the mantissa gives:
1.10010000000000000000000
Next, adjust the mantissa according to the exponent. A negative exponent shifts the decimal point to the left, while a positive exponent shifts it to the right. Since the exponent is 3, the mantissa adjusts as follows:
1100.10000000000000000000
The result is a binary floating-point number, where the binary number to the left of the decimal point represents the power of 2 at that position.
For example, 1100 represents:
(1*2^3) + (1*2^2) + (0*2^1) + (0*2^0) = 12.
The binary number to the right of the decimal point also represents the power of 2 at that position, but the exponent is negative. For example, .100… represents (1*2^(-1)) + (0*2^(-2)) + (0*2^(-2))… = 0.5.
The sum of these values is 12.5. Since the set sign bit indicates that this number is negative, the hexadecimal value 0xC1480000 represents -12.5.
12. How to read information from RS-485 devices that comply with the MODBUS-RTU protocol using a computer?
Use the computer’s serial port, connect a 485 converter to the device’s 485 interface, and then find a serial port software to send modbus messages according to the register address on the device’s documentation. The modbus message is sent via serial port software, with the message format: 0103 00 00 00 01 840A to read the register command.
13. How to send data from vbmodbus to modScan32rtu?
Determine which of the two software is the master and which is the slave. Then confirm whether the communication protocol is RTU, ASCII, or TCP. If it is TCP, use the socket control; for RTU/ASCII, use the COM control. Then send and receive data according to the protocol and parse it accordingly.
14. What is the difference between ModBus RTU communication protocol and ModBus communication protocol?
The ModBus protocol includes MODBUS RTU.
15. How to determine timeout in the ModBus RTU communication protocol?
Set a flag to indicate whether there is a timeout; then use a timer with a duration equal to the time for sending 3.5 characters (of course, to be safe, the time can be longer); set the timeout flag in the timer; in the serial port interrupt, reset the timer whenever a byte is received; in the main program, handle according to the timeout flag.
16. How to understand the 1.5 and 3.5 character intervals in MODBUS protocol RTU mode?
There must be a certain time interval between sending two frames of data to ensure that the receiving UART can distinguish them. This time interval in MODBUS RTU mode is required to be 1.5 and 3.5 character intervals, i.e., the time for transmitting 1.5 and 3.5 characters, which is related to the communication parameters set. It is calculated as follows:
If the serial communication parameters are set as follows (note: the start bit is fixed at 1): data bits 8, parity bit 1, stop bit 1, baud rate 9600 bps, then the time to transmit one character (i.e., 1 byte) is: (1+8+1+1)/9600 = 0.00114583s = 1.1454583ms
1.5 character interval = 1.5 x 1.1454583ms = 1.71818745ms
3.5 character interval = 3.5 x 1.1454583ms = 4.00910405ms
17. Recommended software for testing ModBus RTU?
Recommended: modscan32 and the latest modbus poll.
18. In the ModBus RTU protocol, why do the parameters written to the instrument get lost after power loss, even though both reading and writing data are correct? How to save?
Two possibilities:
1. If the parameters set on the instrument cannot be saved after power loss, it can be determined to be an instrument issue;
2. Some instruments require writing confirmation parameters to a fixed register after writing parameters to ensure that the written parameters are correct. It is necessary to check the communication section of the instrument documentation for this.
Source: Internet, copyright belongs to the original author, infringement will be deleted
Remember to click “View
Summary of ModBus RTU Issues
TapRead the original text,MoreElectrical, PLC content available for free learning

Leave a Comment