Message Formats 2-13
CRC-16 Calculations
The last two bytes of a message contain the CRC-16 (Cyclical Redundancy Check). The CRC-16 is one method for verifying the validity of the
message contents and is part of the protocol. The CRC-16 field checks the contents of the entire message, regardless of any parity check method
used for the individual characters of the message.
The CRC-16 field is a 16-bit binary value consisting of two 8 bit bytes. The CRC-16 value is calculated by the transmitting device, which
appends the CRC-16 to the message. The receiving device recalculates a CRC-16 during receipt of the message, and compares this calculated
value to the value received in the transmitted CRC-16 field. If the two values are not equal, the entire message is invalid.
Detailed examples of a CRC-16 generation using Quick Basic and C are shown below.
►
CRC-16 Calculation Example in Basic
crcsum# = &HFFFF&
crcshift# = &H0&
crcconst# = &HA001&
CLS
PRINT “***************************************************”
PRINT “ CRC-16 calculator”
PRINT “***************************************************”
PRINT “If entering data in hex, preceed the data with ‘&H’”
PRINT “ Example: 32decimal = 20hex = &H20”
PRINT “***************************************************”
INPUT “Enter the number of bytes in the message: “, maxbyte
FOR bytenum = 1 TO maxbyte STEP 1
PRINT “Enter byte “; bytenum; “:”:
INPUT byte&
byte& = byte& AND &HFF&
crcsum# = (crcsum# XOR byte&) AND &HFFFF&
FOR shift = 1 TO 8 STEP 1
crcshift# = (INT(crcsum# / 2)) AND &H7FFF&
IF crcsum# AND &H1& THEN
crcsum# = crcshift# XOR crcconst#
ELSE
crcsum# = crcshift#
END IF
NEXT shift
NEXT bytenum
lower& = crcsum# AND &HFF&
upper& = (INT(crcsum# / 256)) AND &HFF&
PRINT “Lower byte (1
st
) = “, HEX$(lower&)
PRINT “Upper byte (2
nd
) = “, HEX$(upper&)
Figure 2.1 – CRC-16 Calculation in Quick Basic
Содержание CIMR-E7U Series
Страница 1: ...E7 Drive Parameter Access Technical Manual Drive Models CIMR E7U Document Number TM E7 11...
Страница 2: ......
Страница 6: ...iv This page intentionally left blank...
Страница 8: ...Connections 1 2 This page intentionally left blank...
Страница 10: ...Connections 1 4 This page intentionally left blank...
Страница 19: ...Connections 1 13 This page intentionally left blank...
Страница 21: ...Message Formats 2 2 This page intentionally left blank...
Страница 35: ...Troubleshooting 3 2 This page intentionally left blank...
Страница 43: ...Troubleshooting 3 10 This page intentionally left blank...
Страница 45: ...E7 Drive Parameters 4 2 This page intentionally left blank...
Страница 71: ...E7 Drive Parameters 4 28 This page intentionally left blank...
Страница 73: ...User Notes 5 3 This page intentionally left blank...
Страница 81: ...User Notes 5 11 Notes Enter the current application parameter data and any relevant notes...