EasyManua.ls Logo

Inovance MD500T75G - Page 231

Inovance MD500T75G
322 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
MD500 User Manual 8. Interfaces and Communication
- 231 -
Ƶ
CRC check
In the Modbus-RTU mode, a message includes a CRC-based error-check field. The CRC field checks the content of the entire
PHVVDJH7KH&5&ÀHOGLVWZRE\WHVFRQWDLQLQJDELWELQDU\YDOXH7KH&5&ÀHOGLVFDOFXODWHGE\WKHWUDQVPLWWLQJGHYLFH
and then added to the message. The receiving device recalculates a CRC value after receiving the message, and compares the
FDOFXODWHGYDOXHZLWKWKH&5&YDOXHLQWKHUHFHLYHG&5&ÀHOG
7KH&5&LVÀUVWVWRUHGWR[))))7KHQDSURFHGXUHLVLQYRNHGWRSURFHVVWKHVXFFHVVLYHELWE\WHLQWKHPHVVDJHDQGWKHYDOXH
in the register. Only the eight bits in each character are used for the CRC. The start bit, stop bit and the parity bit do not apply to
the CRC.
During generation of the CRC, each eight-bit character is in exclusive-OR (XOR) with the content in the register. Then the result
LVVKLIWHGLQWKHGLUHFWLRQRIWKHOHDVWVLJQLÀFDQWELW/6%ZLWKD]HURÀOOHGLQWRWKHPRVWVLJQLÀFDQWELW06%SRVLWLRQ7KH/6%
is extracted and examined. If the LSB was a 1, the register then performs XOR with a preset value. If the LSB was a 0, no XOR is
performed. This process is repeated until eight shifts have been performed. After the last (eighth) shift, the next eight-bit byte is
LQ;25ZLWKWKHUHJLVWHUVFXUUHQWYDOXHDQGWKHSURFHVVUHSHDWVIRUHLJKWPRUHVKLIWVDVGHVFULEHGDERYH7KHÀQDOYDOXHRIWKH
register, after all the bytes of the message have been applied, is the CRC value.
The CRC is added to the message from the low-order byte followed by the high-order byte. The CRC simple function is as follows:
unsigned int crc_chk_value
unsigned char *data_value,unsigned char length
{
unsigned int crc_value=0xFFFF;
int i;
while
length--
{
crc_value^=*data_value++;
for
L LL
{
if
crc_value&0x0001
{
crc_value=
crc_value>>1
^0xa001;
}
else
{
crc_value=crc_value>>1;
}
}
}
return
crc_value
;
}
efesotomasyon.com

Table of Contents

Related product manuals