VD520 Series Inverter User Manual Communication Protocol
- 201 -
is to Keeping the parity of the data unchanged.
Odd parity check: add a Bit
of odd parity check before data transmission, to express the number of “1”
in the transmission data is odd or even, if the number is odd, check Bit
is “0”, otherwise it “1”. This is
to Keeping the parity of the data unchanged.
For example, the transmitting data “11001110”, there is 5 “1” in the data, if using even parity check,
the even check Bit
is “1”, if using odd parity check, the odd check Bit is “0”, when transmitting, the
parity check Bit will be processed and put at the position of format check Bit. And the receiving device
will also do parity check, if it found the parity of the received data is not the same as pre-set, then it
decides that communication was in error.
9.6.3.2 CRC check method
In RTU frame format, format include format error-checking field that is based on CRC method
calculation. The CRC field checks the contents of the entire format. The CRC field has two bytes ,
containing a 16-Bit binary value. The CRC value is calculated by the transmitting device, which adds
the CRC to the format. The receiving device recalculates the received CRC format, and compares the
value of CRC field received, if the two value of CRC is not equal, then there is error in transmission.
The CRC saves 0xFFFF at first, then call a process to deal with the successive 6 bytes of the format
and the value of present register. Only the 8Bit data of each byte is Enabled for CRC, the starting Bit
and the end Bit and parity check Bit is all Disabled.
During generation of the CRC, each eight-Bit character is separately do XOR with the register
contents, the results is shifting towards the lowest Enabled Bit, the highest Enabled Bit is filled with 0.
LSB is extracted to be checked, if LSB is 1, the register will be separately do XOR with pre-set value;
if LSB is 0, then no need. The complete process will be repeated for 8times. After completing of the
last Bit (the 8
th
Bit), the next 8Bit byte will be separately XOR with present register value. The final
value of register is the CRC value of the all Bit executed of the frame.
The calculation of CRC, adopting the international standard CRC check regulation, when user is
editing CRC calculation, can refer to related CRC calculation.
Here providing a CRC calculation simple function for user reference.
unsigned int crc_cal_value(unsigned char *data_value, unsigned char data_length)
{
int i;
unsigned int crc_value=0xffff; while(data_length--)
{
crc_value^=*dat+;
for(i=0; i<8; i++)
{
if(crc_value&0x0001)
crc_value=(crc_value>>1)^0xa001;
else
crc_value=crc_value>>1;
}
}
return(crc_value);
}
In logic ladder, CKSM calculates CRC value according to frame content, adopting table look-up
method, this method is simple in program, quick calculating speed, but with big occupying ROM
space. Please consider carefully in application with requirement on program space.