Modbus Rtu Crc-16 Algorithm; Modbus Tcp/Ip Format - GE UR Series Manual

Hide thumbs Also See for UR Series:
Table of Contents

Advertisement

CHAPTER 2: MODBUS COMMUNICATION
The ADU is described as follows.
Table 2-2: Modbus TCP/IP format
Description
MBAP header
Transaction identifier
Protocol identifier
Length
Unit identifier
FUNCTION CODE
DATA
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
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
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)
UR SERIES – COMMUNICATIONS GUIDE
Size
2 bytes
2 bytes
2 bytes
1 byte
2 bytes
N bytes
MODBUS RTU PROTOCOL
.
MODBUS SLAVE ADDRESS
2
2-3

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents