Shenzhen Hpmont Technology Co., Ltd Appendix B Communication Protocol
HD5L Series Controller User Manual -141-
0xC07B,0x807A,0x41BA,0x01BE,0xC07E,0x807F,0x41BF,0x007D,0xC1BD,0x81BC,0x407C,
0x01B4,0xC074,0x8075,0x41B5,0x0077,0xC1B7,0x81B6,0x4076,0x0072,0xC1B2,0x81B3,
0x4073,0x01B1,0xC071,0x8070,0x41B0,0x0050,0xC190,0x8191,0x4051,0x0193,0xC053,
0x8052,0x4192,0x0196,0xC056,0x8057,0x4197,0x0055,0xC195,0x8194,0x4054,0x019C,
0xC05C,0x805D,0x419D,0x005F,0xC19F,0x819E,0x405E,0x005A,0xC19A,0x819B,0x405B,
0x0199,0xC059,0x8058,0x4198,0x0188,0xC048,0x8049,0x4189,0x004B,0xC18B,0x818A,
0x404A,0x004E,0xC18E,0x818F,0x404F,0x018D,0xC04D,0x804C,0x418C,0x0044,0xC184,
0x8185,0x4045,0x0187,0xC047,0x8046,0x4186,0x0182,0xC042,0x8043,0x4183,0x0041,
0xC181,0x8180,0x4040}
It takes a comparatively long time to online calculate the CRC checksum of each byte, but it will
save program space. 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));
}
10. 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. In the following examples the communication address is “2”.
1. To read the M-key function of address 2 (to read the command frame of F00.06)
Address Code Register address Word no. of read Checksum
0x02 0x03 0x00 0x06 0x00 0x01 0x64 0x38
Corresponding answer frame (F00.06=1):
Address Code Answer byte Register content Checksum
0x02 0x03 0x02 0x00 0x01 0X3D 0x84
B