35
3.
MODBUS protocol function code 0x06
Information frame format of the write-in single register sent by the host (function code 0
x
06):
Slave address
Operation
function code
Register’s first
address
Number of
registers
Check code
1 byte
1 byte
2 bytes
2 bytes
2 bytes
0x01~0xF7
0x06
0x0000~0xFFFF
X0000 ~ 0xFFFF
CRC Check code
Slave feedback data frame format (function code 0x06):
Slave address
Operation
function code
Register’s first
address
Number of
registers
Check code
1 byte
1 byte
2 bytes
2 bytes
2 bytes
0x01~0xF7
0x06
0x0000~0xFFFF
X0000~0xFFFF
CRC Check code
Flowmeter’s address
Value range is 1~247 (hexadecimal system: 0x01~0xF7), the address could be viewed in Menu 30;
if the decimal digit displayed in Menu
30 is 11, the flowmeter’s address in
MODBUS protocol is:
0x0 B.
The flowmeter’s
CRC check code is calculated through CRC-16-IBM (multinomial is X16+X15+X2 +
1, mask word is 0xA001) cyclic redundancy algorithms, low byte of the check code is in front,
followed by the high byte.
For example, transient flow per hour (m3/h) of the flowmeter with 1 (0x01) read address in RTU
mode, i.e. data of two read registers 40005 and 40006, the read commands are shown below:
0x01 0x03 0x00 0x04 0x00 0x02 0x85 0xCA
Flowmeter’s address function code/First address register/Number of registers/
CRC check code
Flowmeter’s feedback data
(Assuming the current flow=1.234567m3/h):
0x01 0x03 0x04 0x06 0x51 0x3F 0x9E 0x3B 0x32
Flowmeter’s ad
dress function code/Number of data bytes/Data/CRC check code
In which, four bytes 3F, 9E, 06 and 51 is1.2345678, which is the single precision float form in
IEEE754 format.
Please pay attention to the order of data in the above example. When explaining the value with C
language, you could use the pointer to directly input the data required to related address of
variable, the common storage order in general is that the low byte is in front. Taking the above
1.2345678m/s example, the storage order of 3F, 9E, 06 and 51 data is 51, 06, 9E and 3F. For
example, in RTU mode, alter the address of flowmeter 1 (0x01) to 2 (0x02), i.e. write the data of
44100 register in 0x02,