Message framing and timing, Appendix a – modbus rtu protocol, Power leader modbus monitor – GE Industrial Solutions POWER LEADER ModBus Monitor User Manual

Page 56

Advertising
background image

POWER LEADER Modbus Monitor

Appendix A – Modbus RTU Protocol

50

CRC-16 Algorithm

Once the following algorithm is complete, the working
register “A” will contain the CRC value to be
transmitted. Note that this algorithm requires the
characteristic polynomial to be reverse bit ordered. The
MSBit of the characteristic polynomial is dropped since
it does not affect the value of the remainder. The
following symbols are used in the algorithm:

----->

data transfer

A

16 bit working register

AL

low order byte of A

AH

high order byte of A

CRC

16 bit CRC-16 value

I, j

loop counters

(+)

logical exclusive or operator

Di

i-th data byte (I = 0 to N-1)

G

16 bit characteristic polynomial = 1010000000000001
with MSBit dropped and bit order reversed

shr(x)

shift right (the LSBit of the low order byte of x shifts into
a carry flag, a ‘0’ is shifted into the MSBit of the high
order byte of x, all other bits shift right one location.

Algorithm:

1. FFFF hex -----> A

2. 0 -----> i

3. 0 -----> j

4. Di (+) AL -----> AL

5. j+1 -----> j

6. shr(A)

7. Is there a carry?

No: go to 8.
Yes: G (+) A -----> A

8. Is j = 8?

No: go to 3.
Yes: go to 9.

9. i + 1 -----> I

10. Is i = N?

No: go to 3.
Yes: go to 11.

11. A -----> CRC

Message Framing and Timing

Each 8 bits of data in a Modbus RTU message are sent
as part of a 11-bit byte, with the extra bits used for
framing of each byte transmitted. The master device
should have the port settings set to N-8-1 (no parity, 8
data bits, 1 stop bit).

Per the Modbus RTU standard, all messages must start
with a silent interval of at least 3.5 character times (or
equivalently 38.5 bit times), followed by the device
address. For example, at 19200 baud the minimum delay
between messages is:

(

)(

)

3 5

11

1

19200

2.01

. characters

bits / character

s

bits

ms





=

Modbus RTU messages must be transmitted as a
continuous stream. If a silent interval of more than 3.5
character times occurs before the message is complete,
the receiving device resets the link and assumes that the
next byte received is the start of a new message.
Similarly, if fewer than 3.5 character times elapse
between messages, the receiving device considers the
second message a continuation of the previous one,
resulting in an error.

The Modbus Monitor, upon detecting an appropriate
silent time, readies itself to recognize the next received
byte as the device address. If the device address is the
same as the Monitor address or the equivalent Modbus
address of an attached POWER LEADER device, the
Monitor receives the rest of the query from the master
and responds appropriately.

A typical Modbus RTU message appears as follows (the
3.5 character time silent interval is explicitly shown
below but often implied in other diagrams):

Silent
Interval

Device
Address
(1 byte)

Function
Code
(1 byte)

Data

(n bytes)

CRC-16

(2 bytes)

Advertising