KFMH Coriolis Mass Flow Meter Modbus Protocol
KFMH Coriolis Mass Flow Meter Modbus Protocol
In MODBUS network, there can be 2 ~ 248 devices, i.e. 1 master device and
247 slave devices (at most).Each slave device is assigned an address in the
range of 1 to 247.Modbus communication is always initiated by the master device,
and the slave device will never send data when it does not receive a request from
the master device.Slave devices never communicate with each other.The master
device can only initiate one MODBUS transaction at the same time.
The master device addresses the slave device by putting the address of the
slave device into the address field of the message.When the slave device returns
the reply, it puts its own address into the address field of the reply message to let
the master device know which slave device is answering.
Communication parameters
Transmission mode: RTU mode
Baud rate: 9600 (default) (modifiable)
Check bit: no check (default) (modifiable)
Start bit: 1
Data bits: 8
Stop bit: 1 (default) (modifiable)
TX / RX mode: half duplex supports RTS, CTS, DTR, DSR and DCD
Steering time: > = 150ms
Communication process
Modbus protocol defines the message structure that a controller can
recognize, no matter what network they communicate through.It describes the
process of the controller requesting access to other devices, how to respond to
requests from other devices, and how to detect and record errors.It establishes the
common format of message domain pattern and content.
Using RTU mode, message sending should start with a pause interval of at
least 3.5 characters.Under the character time of various network baud rates, this is
the easiest to achieve (as shown in t1-t2-t3-t4 in the following table).The address of
the first transport device is.The transmission characters that can be used are
hexadecimal 0... 9, a... F.Network equipment continuously detects the network bus,
including the pause interval.When the first domain (address domain) is received,
each device decodes to determine whether it is sent to its own.After the last
transmitted character, a pause of at least 3.5 characters marks the end of the
message.A new message can start after this pause.
The entire message frame must be transmitted as a continuous stream.If
there is a pause time of more than 3.5 characters before the frame is completed,
the receiving device will refresh the incomplete message and assume that the next
byte is the address field of a new message.Similarly, if a new message starts with
the previous message within less than 3.5 characters, the receiving device will
consider it a continuation of the previous message.This will cause an error because
the value in the last CRC field cannot be correct.Typical message frames are as
follows:
start:
3.5Interval of characters
Address field:
The address field of the message frame contains 8bits
(RTU).Possible slave addresses are 0 to 247 (decimal).The address
range of a single device is 1 ~ 247.The master device selects the slave
device by putting the address of the slave device to be contacted into the
address field in the message.When the slave device sends a response
message, it puts its address into the address field of the response so that
the master device knows which device responded.
Address 0 is used as a broadcast address so that all slave devices can
recognize it.When Modbus protocol is used in higher level networks,
broadcasting may not be allowed or replaced in other ways.
Function code:
The function code field in the message frame contains two
characters (ASCII) or 8bits (RTU).The possible code range is 1 ~ 255 in
decimal system.Of course, some codes are applicable to all controllers,
some are applicable to certain controllers, and some are reserved for
future use.
When a message is sent from the master device to the slave device, the
function code field will tell the slave device what behavior to perform.For
example, to read the input switch state, read the data content of a group
of registers, read the diagnostic state of the slave device, and allow the
program in the slave device to be transferred, recorded and verified.
When the slave device responds, it uses the function code field to
indicate whether it is a normal response (no error) or an error occurs
(called abnormal response).For normal response, the slave device only
responds to the corresponding function code.For abnormal response,
the slave device returns a code equivalent to the normal code, but the
highest bit is logic 1.
Data field:
The data field is composed of a series of two 8-bit byte sets, ranging
from 0000 to ffff.The data field of the message sent by the master device
to the slave device contains additional information. The slave device
must be used to perform the actions defined by the function code.This
includes, for example, discontinuous register addresses, the number of
items to be processed, and the number of actual data bytes in the field.
If no error occurs, the data field returned from the device contains the
requested data.If an error occurs, this field contains the exception code,
which can be used by the master device application to determine the
next action.
In a message, the data field may not exist (0 length).The function
code is sufficient to declare the content of the command.
CRC verification:
When the RTU mode is selected as the character frame, the error
detection field contains a 16bits value (realized by two 8-bit
characters).The content of the error detection domain is obtained by
circular verbosity detection of the message content.The CRC field is
attached at the end of the message. When adding, the low byte is first
followed by the high byte.Therefore, the high byte of CRC is the last byte
of the message sent.
end:
3.5Interval of characters
function code
Response: every two bytes of the response information data field represent a register,
and the binary contents of each byte are aligned to the right.
Slave device Function Bytes (n) Data domain CRC check
address code 0x04
8 bits 8 bits 8 bits (N)*8 bits 16 bits
Note: data type F32: use 32bit to store floating-point numbers in single precision IEEE754
format.Each floating-point number contains 4 bytes, which are defined as follows:
SEEEEEEE EMMMMMMM MMMMMMMM MMMMMMMM
S: Sign bit 0- > positive 1 - > negative
E: Order code
M: Decimal part of the tail
For example: 0.4148 million = 12.5,
Note: the IEEE754 data used in our program is represented by reverse order (3-2-1-0),
that is, 00004841 for 12.5.
The data in this example is the data frame reading instantaneous mass flow rate, and
the instrument address is 1 (hex code is 0x01).
Note: register starting address of instantaneous mass flow rate = 247-1 = 246 (hex code is
0xf6).
Request frame: upper computer - > instrument
Data field name RTU sample data (HEX)
Frame head NONE
Instrument address 01
Function code 04
Register start address 00,F6
Number of registers 00,02
CRC verification 91,F9
Frame end NONE
Response frame: instrument > upper computer
Data field name RTU sample data (HEX)
Frame head NONE
Instrument address 01
Function code 04
Bytes 04
Data domain 00,00,48,41
CRC verification 0D,B4
Frame end NONE
The response frame returns the instantaneous flow data in IEEE754 format
00004841=12.5
Mass flow (32-bit integer address 247) 01 04 00 F6 00 02 91 F9
sent
Return (instantaneous flow rate 30.0t/h) 01 04 04 00 00 F0 41 7F B4
Density (32-bit integer address 249) send 01 04 00 F8 00 02 F0 3A
Return (1.000) 01 04 04 BC 02 80 3F 5E 04
Temperature (32-bit integer address 251) 01 04 00 FA 00 02 51 FA
sent
Return (12.5 ℃) 01 04 04 00 00 48 41 0D B4
Volume flow rate (32-bit integer address 01 04 00 FC 00 02 B1 FB
253) sent
Test code Return (9.999442m3/h) 01 04 04 B7 FD 1F 41 85 C0
Total quality (32-bit integer address 259) 01 04 01 02 00 02 D1 F7
sent
Return (1000000t) 01 04 04 00 24 74 49 5D 79
Total volume (32-bit integer address 261) 01 04 01 04 00 02 31 F6
sent
Return (1000000t) 01 04 04 00 24 74 49 5D 79
The above integer variable (address from 01 04 00 F6 00 10 11 F4
247-261, six variables, 12 registers, 4
registers with empty middle)