
Modbus communication protocol
85
The new value of revised parameter.
Checksum
:
From “slave address” to the character before checksum, the LRC
checksum of the character string.
The followings are the example of command frame and return frame, all the
Data are ASCII character.
Inquiry frame:
: 0 1 0 6 0 1 0 1 1 3 8 8 5 C \n\r
(The detail introduction of every byte)
“:”: beginning symbol
0 1
: Slave address
0 6
:write command
0 1 0 1:
storage address of writing parameter
1 3 8 8:
the value of writing parameter
5 C:
{
0 1 0 6 0 1 0 1 1 3 8 8
} for LRC checksum.
0x5C = 0x100 - (0x01 + 0x06 + 0x01 + 0x01 + 0x13 + 0x88)
Response frame:
: 0 1 0 6 0 1 0 1 1 3 8 8 5 C \n\r
(Detail introduction of every byte)
“:”: beginning symbol
0 1
: Slave address
0 6
:write command
0 1 0 1:
storage address of writing parameter
1 3 8 8:
the value of writing parameter
5 C:
{
0 1 0 6 0 1 0 1 1 3 8 8
} for LRC checksum.
0x5C = 0x100 - (0x01 + 0x06 + 0x01 + 0x01 + 0x13 + 0x88)
A.9 CRC checkout mode
CRC checkout value calculating function written by C language is as follows:
unsigned int cal_crc_value (unsigned char *pval, unsigned char len)
{
unsigned int crc_value=0xFFFF;
unsigned int i;
while(len--)
{
crc_value ^= *pval++;
for(i=0; i<8;
i++)
{
if(crc_value
&
0x0001)
{
Note
(1) ASCII frame realizes transform by that 8Bit hexadecimal is divided as different 2
character of 4, and then grouped ashexadecimal of one 8Bit when reaching the
destination.
(2) Frame header, add“:”, frame footer adds“\n\r” the enter line break character.
(3) The valid character in the protocol is:,0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,Fand
hexadecimal 0DH, lower case ASCII letter a, b, c, d, e, f is invalid
(4) The subject data volume is the 2 times as RTU, checksum adopt LRC check.
(5) For the other information, please refer to the official standard
ENC