Appendix B Communication Protocol
Shenzhen Hpmont Technology Co., Ltd.
- 150 -
HD3N Series User Manual V1.1
6.
CRC checking
Code of online calculating CRC is shown below:
unsigned int crc_check(unsigned char *data,unsigned char length)
{
int i;
unsigned crc_result = 0xffff;
while(length--)
{
crc_result^ = *data++;
for(i = 0;i<8;i++)
{
if(crc_result&0x01)
crc_result = (crc_result>>1)^0xa001;
else
crc_result = crc_result>>1;
}
}
return (crc_result = ((crc_result&0xff)<<8)|(crc_result>>8));
}
7.
Application Case
Remarks: Please verify all the hardware equipments are connected well before controlling the
controller via communication. In addition, please preset the communication data format, baud rate
and communication address.
1. To read max. output frequency of address 2(to read command Frame F00.06), response Frame =
50.00Hz
Command
Frame
Address
Code
Register address
Word no. of read
Checksum
0x02
0x03
0x00
0x06
0x00
0x01
0x64
0x38
Response
Frame
Address
Code
Answer byte
Register content
Checksum
0x02
0x03
0x02
0x13
0x88
0xF1
0x12
2. To read the DC bus voltage of address 2 ( group d00), corresponding answer Frame = 537V)
Command
Frame
Address
Code
Register address
Word no. of read
Checksum
0x02
0x03
0x33
0x19
0x00
0x01
0x5A
0xBA
Response
Frame
Address
Code
Answer byte
Register content
Checksum
0x02
0x03
0x02
0x02
0x19
0x3C
0xEE