5-5
IM 77C01H01-10EN
MODBUS Communication
5
RTU Mode
In the RTU mode, errors are checked by means of a CRC-16 cyclic redundancy check. The
CRC-16 value is the 16-bit remainder when the value obtained by concatenating the 8 bits
of all blocks (from the station number to the last data item) of a message, excluding the start
bit, stop bit and parity bit, is divided by a predetermined 17-bit binary number.
Example of CRC-16 Calculation
When executing function code 03 (read the status of the specific coil) to read the status from
the slave at station number 11 (0Bh), send the 0B03002A0004 command.
[1] The default is FFFF. Find the XOR value of this default and the first character (=
station number 11).
[2] Refer to the lower byte of the result of executing the function code (or the upper
byte, if the result is regarded as a block of text). From the table, obtain the value
corresponding to that byte. Since the result is F4h in this example, you refer to the
244th value in the table and obtain 8701h.
[3] Find the XOR value of the upper byte of the XOR operation in step [1] and the result
of step [2]. This value is the first character of the CRC-16 calculation.
[4] Using the result of step [3] (remainder) as the next initial value, make the same
calculation to evaluate the second character (function code 03).
050104E.EPS
Initial value
FF FF
Station number
0B
---------
XOR
FF F4
Reference to table
87 01
--------
XOR
87 FE
Function code
03
--------
XOR
87 FD
Reference to table
81 C1
--------
XOR
•
•
•
•
•
•
81 46
XOR
E5 9E
Last character
04
--------
XOR
E5 9A
Reference to table 6B 80
--------
Resulting error
6B 65
Convert the hex value to a decimal value,
find the corresponding number in Table
5.2, and substitute the number into the
formula.
In the example shown on the left,
hex value F4 is converted to decimal value
244. From Table 5.2, the number
corresponding to 244 proves to be 8701.
This number is substituted into the formula.
[5] Repeat steps [1] to [4] to perform the calculation up to the last character string “04”.
[6] Reverse the order of the upper and lower bytes of 6B65 and append 656B to the end
of the character string as the error code.
0B03002A0004656B
First reverse the order of the upper and lower bytes of the calculated result, then compare the
value with the received data or store the value in the transmission buffer.
5.1 Overview
Содержание UPM100
Страница 2: ......
Страница 14: ...Blank ...
Страница 58: ...Blank ...
Страница 74: ...Blank ...
Страница 82: ...Blank ...
Страница 86: ...Blank ...
Страница 100: ...Blank ...
Страница 102: ...Blank ...
Страница 103: ......
Страница 104: ......