![Satec PM130 series Скачать руководство пользователя страница 7](http://html.mh-extra.com/html/satec/pm130-series/pm130-series_reference-manual_1200366007.webp)
6
Code
(decimal)
Meaning in Modbus
Action
06
Preset single register
Write single register
16
Preset multiple registers
Write multiple registers
08
Loop-back test
Communications test
NOTE
Broadcast mode available only for functions code 06 and 16.
2.5 Data Field
The data field contains information needed by the instrument to perform a specific function, or
data collected by the instrument in response to a query.
IMPORTANT
Fields composed of two bytes are sent in the order high byte first, low byte
second.
2.6 Error Check Field
The error check field contains the Cyclical Redundancy Check (CRC) word. The start of the
message is ignored in calculating the CRC. The CRC-16 error check sequence is implemented
as described in the following paragraphs.
The message (data bits only, disregarding start/stop and optional parity bits) is considered one
continuous binary number whose most significant bit (MSB) is transmitted first. The message is
pre-multiplied by x
16
(shifted left 16 bits), and then divided by x
16
+ x
15
+ x
2
+ 1 expressed as a
binary number (11000000000000101). The integer quotient digits are ignored and the 16-bit
remainder (initialized to all ones at the start to avoid the case of all zeros being an accepted
message) is appended to the message (MSB first) as the two CRC check bytes. The resulting
message including CRC, when divided by the same polynomial (x
16
+ x
15
+ x
2
+ 1) at the
receiver will give a zero remainder if no errors have occurred. (The receiving unit recalculates
the CRC and compares it to the transmitted CRC). All arithmetic is performed modulo two (no
carries).
The device used to serialize the data for transmission will send the conventional LSB or right-
most bit of each character first. In generating the CRC, the first bit transmitted is defined as the
MSB of the dividend. For convenience, and since there are no carries used in the arithmetic,
let's assume while computing the CRC that the MSB is on the right. To be consistent, the bit
order of the generating polynomial must be reversed. The MSB of the polynomial is dropped
since it affects only the quotient and not the remainder. This yields 1010 0000 0000 0001 (Hex
A001). Note that this reversal of the bit order will have no effect whatever on the interpretation
or bit order of characters external to the CRC calculations.
The step by step procedure to form the CRC-16 check bytes is as follows:
1. Load a 16-bit register with all 1's.
2. Exclusive OR the first 8-bit byte with the low order byte of the 16-bit register, putting the
result in the 16-bit register.
3. Shift the 16-bit register one bit to the right.
4a. If the bit shifted out to the right (flag) is one, exclusive OR the generating polynomial 1010
000 000 0001 with the 16-bit register.
4b. If the bit shifted out to the right is zero, return to step 3.
5. Repeat steps 3 and 4 until 8 shifts have been performed.
6. Exclusive OR the next 8-bit byte with the 16-bit register.
7. Repeat step 3 through 6 until all bytes of the message have been exclusive ORed with the
16-bit register and shifted 8 times.
8. When the 16-bit CRC is transmitted in the message, the low order byte will be transmitted
first, followed by the high order byte.
For detailed information about CRC calculation, refer to the Modbus Protocol Reference Guide.