CHAPTER 2: MODBUS COMMUNICATION
MODBUS RTU PROTOCOL
UR SERIES – COMMUNICATIONS GUIDE
2-3
2
The ADU is described as follows.
Table 2-2: Modbus TCP/IP format
MBAP header
— This Modbus Application Protocol header contains the following fields:
•
Transaction Identifier: Used for transaction pairing. The Modbus server copies in the response the transaction
identifier of the request.
•
Protocol Identifier: Used for intra-system multiplexing. The Modbus protocol is identified by the value 0.
•
Length: The length field is a byte count of the following fields, including the Unit Identifier and data fields.
–
Unit Identifier: For the purposes of the UR, this field is equivalent to the Modbus RTU SLAVE ADDRESS field. The
client must use the same value here as programmed in the UR setting
MODBUS SLAVE ADDRESS
.
FUNCTION CODE
— This is the same as the Modbus RTU function code field described above.
DATA
— This is the same as the Modbus RTU data field described above.
2.1.5 Modbus RTU CRC-16 algorithm
The Modbus TPC/IP CRC-32 algorithm is universally executed in hardware, so there is no need to describe it here.
The Modbus RTU CRC-16 algorithm essentially treats the entire data stream (data bits only; start, stop and parity ignored)
as one continuous binary number. This number is first shifted left 16 bits and then divided by a characteristic polynomial
(11000000000000101b). The 16-bit remainder of the division is appended to the end of the packet, MSByte first. The
resulting packet including CRC, when divided by the same polynomial at the receiver will give a zero remainder if no
transmission errors have occurred. This algorithm requires the characteristic polynomial to be reverse bit ordered. The
most significant bit of the characteristic polynomial is dropped, since it does not affect the value of the remainder.
A C programming language implementation of the CRC algorithm can be provided upon request.
Table 2-3: Modbus RTU CRC-16 algorithm
Description
Size
MBAP header
Transaction identifier
2 bytes
Protocol identifier
2 bytes
Length
2 bytes
Unit identifier
1 byte
FUNCTION CODE
2 bytes
DATA
N bytes
Symbols
-->
data transfer
A
16 bit working register
Alow
low order byte of A
Ahigh
high order byte of A
CRC
16 bit CRC-16 result
i,j
loop counters
(+)
logical EXCLUSIVE-OR operator
N
total number of data bytes
Di
i-th data byte (i = 0 to N-1)
G
16 bit characteristic polynomial = 1010000000000001 (binary) with MSbit dropped and bit order reversed
shr (x)
right shift operator (th LSbit of x is shifted into a carry flag, a '0' is shifted into the MSbit of x, all other bits
are shifted right one location)
Summary of Contents for UR series
Page 5: ...TABLE OF CONTENTS UR SERIES COMMUNICATIONS GUIDE v INDEX...
Page 6: ...vi UR SERIES COMMUNICATIONS GUIDE TABLE OF CONTENTS...
Page 20: ...1 14 UR SERIES COMMUNICATIONS GUIDE FOR FURTHER ASSISTANCE CHAPTER 1 INTRODUCTION 1...
Page 216: ...2 196 UR SERIES COMMUNICATIONS GUIDE MEMORY MAP CHAPTER 2 MODBUS COMMUNICATION 2...
Page 428: ...A 2 UR SERIES COMMUNICATIONS GUIDE REVISION HISTORY APPENDIX A MISCELLANEOUS A...