beautypg.com

Calculation of error check code (crc-16), 5 calculation of error check code (crc-16), Bulletin f-107-uxf3-s – Dwyer UXF3 User Manual

Page 16

background image

- 12 -

5.5

Calculation of Error Check Code (CRC-16)

CRC-16 is the 2-byte (16-bits) error check code. From the top of the message (station No.) to the end of the data

field are calculated.

The slave station calculates the CRC of the received message, and does not respond if the calculated CRC is

different from the contents of the received CRC code.

Fig. 5-3 shows the flow of the CRC-16 calculation system.

NO

NO

YES

YES

NO

YES

Start

Set FFFF

H

(hexadecimal number) in CR.

Set 1 in I.

Exclusive logical sum (XOR) is executed
with CR and one character (1 byte) of the I
characters, and the result is set in CR.

Set 1 in J.

Bit at right end
of CR is 1?

Shift CR to right by 1 bit, and A001

H

and

exclusive logical sum (XOR) are executed
and the result is set in CR.

Shift CR to right by 1 bit.

Add 1 to J.

Calculation (8 times)
is finished?

J>8

Add 1 to I.

End

Explanation of variables

CR

:

CRC error check data (2 bytes)

I : Digits of calculation characters

in command message

J : Check on the number of times

of CR calculation

(Calculation is executed in the order
of command message station No.,
function code and data.)

CR calculation result shall be added
to the last command message in the
order of LOW byte and HIGH byte.

Calculation of all characters is
completed?

I>All characters

Fig. 5-3 Flow of CRC-16 calculation

Bulletin F-107-UXF3-S