- Definition
Modbus communication protocol, the most important ones are Modbus RTU (RS-485 bus) to 232 connection ABB COM port, Modbus ASCII and Modbus TCP (Ethernet).
Modbus RTU protocol, generally speaking, Modbus communication protocol based on serial communication refers to Modbus RTU communication protocol.
The Modbus RTU communication protocol for ABB robots is a widely – used serial communication standard. It operates in a master – slave mode over a two – wire serial link. The master sends requests, and the slave (ABB robot) responds. Data is transmitted in a binary format, packed into RTU frames. This protocol enables efficient exchange of control commands and status information, facilitating seamless integration with other industrial devices.
Modbus ASCII protocol: Messages use ASCII characters. ASCII format uses longitudinal redundancy checksum.
Modbus ASCII messages start with a colon (“:”) and end with a line break (CR/LF). The Modbus TCP protocol adds an MBAP message header to the RTU protocol, and because TCP is a service based on reliable connections, the CRC checksum in the RTU protocol is no longer needed, so there is no CRC checksum in the Modbus TCP protocol. Therefore, a more popular saying is often used: the Modbus TCP protocol is the ModbusRTU protocol with five 0s and a 6 in front, and then the two CRC checksum bytes are removed.
Communication mode: polling (read 0.1s, write 0.1s)
- Protocol
Storage area
Register address range
Communication format
Baud rate: 4800 9600 19200
Data bit: 8 Check bit: O/E/N
Stop bit: 1
Odd check ODD (odd number of 1 is 0)
Even check EVEN (even number of 1 is 0)
No check NONE
Send format
Send format: device address + function code + data (starting register + number of registers) + check (CRC
)
Receive format: device address + function code + data (byte count + specific data) + check (CRC)
Function code
Modbus function code uses hexadecimal
Read output coil 0X01
Read input coil 0X02
Read output register 0X03
Read input register 0X04
Write single coil 0X05
Write single register 0X06
Write multiple coils 0X0F
Write multiple registers 0X10
III. CRC Check
In RTU mode, it contains an error check field based on the cyclic redundancy check (CRC) algorithm for the entire message content. The CRC field checks the content of the entire message. This check is performed regardless of whether the message has a parity check. The CRC contains a 16-bit value consisting of two 8-bit bytes. The CRC field is attached to the message as the last field of the message. After calculation, the low byte is attached first, followed by the high byte. The CRC high byte is the last sub-byte sent by the message.
The value of the CRC attached to the message is calculated by the sending device. The receiving device recalculates the CRC value when receiving the message and compares the calculated result with the actual received CRC value. If the two values are not equal, it is an error. The calculation of the CRC starts by pre-loading all 1s to a 16-bit register. Then the subsequent calculations are performed on the consecutive 8-bit sub-bytes in the message. Only the 8 data bits in the character are involved in the CRC calculation. The start bit, stop bit and check bit are not involved in the CRC calculation.
During the CRC generation process, each 8-bit character is XORed with the value in the register. The result is then shifted (shifted) 1 bit in the direction of the least significant bit (LSB), and the most significant bit (MSB) position is filled with zero. The LSB is then extracted and checked: if the LSB is 1, the value in the register is XORed with a fixed preset value; if the LSB is 0, no XOR operation is performed. This process will be repeated until 8 shifts are performed. After the last (8th) shift and related operations are completed, the next 8-bit byte is XORed with the current value of the register, and then repeated 8 times as described above. The final value of the register obtained after all sub-bytes in the message are calculated is the CRC.