Hub van Doorneweg 8 • 2171 KZ Sassenheim – NL •
T
+31(0)252 228850 •
F
+31(0)252 228235 •
E
sales@euronorm.nl •
I
euronormdrives.com
76
77
NEURN030000_220_A
NEURN030000_220_A
I-2 Check mode
Check mode - CRC mode: CRC (Cyclical Redundancy Check) adopts RTU frame format, the message includes an
error-checking field that is based on CRC method. The CRC field checks the whole content of message. The CRC field
has two bytes containing a 16-bit binary value. The CRC value calculated by the transmitting device will be added into to
the message. The receiving device recalculates the value of the received CRC, and compares the calculated value to the
Actual value of the received CRC field, if the two values are not equal, then there is an error in the transmission.
The CRC firstly stores 0xFFFF and then calls for a process to deal with the successive eight-bit bytes in message and the
value of the current register. Only the 8-bit data in each character is valid to the CRC, the start bit and stop bit, and parity
bit are invalid.
During generation of the CRC, each eight-bit character is exclusive OR(XOR) with the register contents separately, the
result moves to the direction of least significant bit(LSB), and the most significant bit(MSB) is filled with 0. LSB will be
picked up for detection, if LSB is 1, the register will be XOR with the preset value separately, if LSB is 0, then no XOR
takes place. The whole process is repeated eight times. After the last bit (eighth) is completed, the next eight-bit byte will
be XOR with the register’s current value separately again. The final value of the register is the CRC value that all the bytes
of the message have been applied.
When the CRC is appended to the message, the low byte is appended firstly, followed by the high byte. CRC simple
functions 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^=*dat+;
for(i=0;i<8;i++)
{
if(Crc_value&0x0001)
{
c r c _ v a l u e = (C r c _ v a l u e > > 1 )^0xa001;
}
else
{
crc_value=crc_value>>1;
}
}
}
return(Crc_value);
}