0% found this document useful (0 votes)
51 views

KFMH Electromagnetic Flowmeter Modbus Communication Protocol LS

Uploaded by

Surya Freekz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views

KFMH Electromagnetic Flowmeter Modbus Communication Protocol LS

Uploaded by

Surya Freekz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

L-MAG Electromagnetic Flowmeter Standard

MODBUS Communication Protocol

(Version number:LMAGMODRTUV77)

2013.6.14
L-MAG Electromagnetic Flowmeter Standard MODBUS Communication Protocol

Catalogue
1. Introduction........................................................................................................... - 2 -
2. L-mag network structure and wiring..................................................................... - 2 -
3. RTU frame format of modbus protocol................................................................. - 3 -
1) Master order frame structure...........................................................- 3 -
2) Slave response frame structure........................................................- 3 -
4. Code definition of MODBUS protocol order........................................................- 4 -
5. MODBUS register definition of electromagnetic flowmeter................................ - 5 -
1) MODBUS register definition of electromagnetic flowmeter.......... - 5 -
2) PLC address set illustration............................................................. - 5 -
6. Communication data analysis................................................................................- 7 -
1) Read instantaneous flow.................................................................. - 7 -
2) Read instantaneous velocity.............................................................- 8 -
3) Read cumulative flow.......................................................................- 9 -
4) Read instantaneous flow unit........................................................ - 10 -
5) Read the unit of the total amount of flow......................................- 10 -
6) Read alarm status...........................................................................- 10 -

Remark: The routine of this protocol’s application example only provide reference.
Some parameters in the routine are different from the address definition of MODBUS
register. Please subject to the address definition of MODBUS register.

-1-
L-MAG Electromagnetic Flowmeter Standard MODBUS Communication Protocol

1. Introduction

L-mag electromagnetic flowmeter has the standard MODBUS communication


interface supporting baud rate 1200, 2400, 4800, 9600, 19200. Through MODBUS
communication network, host can collect instantaneous flow, instantaneous velocity
and accumulative flow.
L-mag electromagnetic flowmeter uses serial port parameters: 1 start bit, 8 data
bits, 1 stop bit, none parity bit.
L-mag electromagnetic flowmeter MODBUS communication port uses electric
isolation mode in physical structure. The isolation voltage is 1500V and it owns ESD
protection. Thus it can overcome various interferences from industrial scene to ensure
the reliability service of communication network.

2. L-mag network structure and wiring

L-mag electromagnetic flowmeter’s standard MODBUS communication network


is bus network. It can support 1-99 electromagnetic flowmeters to network
organization. As the farthest electromagnetic flowmeter in the network, it usually
needs a 120  matched termination resistor to connect the two ports of
communication wire in parallel. The standard communication connection media is
shielded twisted pair.

Resistor

Flow meter Flow meter Flow meter


#1 #2 #99

Figure-1 Electromagnetic flowmeter network structure


L-mag electromagnetic flowmeter communication wiring is shown in
electromagnetic flowmeter in detail.
-2-
L-MAG Electromagnetic Flowmeter Standard MODBUS Communication Protocol

3. RTU frame format of modbus protocol

MODBUS protocol is a kind of master-slave communication. Every


communication is started from master and slave responds master’ order through
passing back data.
L-mag electromagnetic flowmeter uses the MODBUS RTU frame format
(hexadecimal format). Its frame format is shown in figure2.
1) Master order frame structure

Device Function Register Register


Start CRC Stop
address code address length

T1-T2-T3-T4 8Bits 8Bits 16Bits 16Bits 16Bits T1-T2-T3-T4

Fiture-2 Master RTU message frame


2) Slave response frame structure

Device Function
Start Data CRC Stop
address code

T1-T2-T3-T4 8Bits 8Bits n 8Bits 16Bits T1-T2-T3-T4

Figure-3 Slave RTU message frame

Remark:
 T1-T2-T3-T4 is start or stop frame. MODBUS protocol sets that every two
frames must have 3.5 char delay at least. It is shown in figure-4.

Figure-4 MODBUS frame interval


 Device address: It is electromagnetic flowmeter’s communication address. It
couldn’t have two same address in a network.
-3-
L-MAG Electromagnetic Flowmeter Standard MODBUS Communication Protocol

 Function code: It is set by MODBUS protocol. L-mag electromagnetic


flowmeter uses the function code 4 which realize the collecting function
through reading input register.
 Register address and register number: The start address of register which
restore data. Register number is the number that is used to store data.
 Slave response data: Byte number and N bytes data.
They are all shown in MODBUS protocol in detail.

4. Code definition of MODBUS protocol order

Table-1
Function code name function

01 Read coil status reservation

02 Read input status reservation

03 Read holding registers reservation

read Electromagnetic Flowmeter


04 Read input register
real-time information

05 Strong set single coil reservation

06 Preset single register reservation

07 read abnormal status reservation

08 Loopback diagnostic check reservation

09 Program(only used for 484) reservation

10 Control exercise(only used for 484) reservation

11 Read events count reservation

12 Read communication events record reservation

13 Program(184/384 484 584) reservation

14 Inquire(184/384 484 584) reservation

15 Strong multi-coil set reservation

-4-
L-MAG Electromagnetic Flowmeter Standard MODBUS Communication Protocol

5. MODBUS register definition of electromagnetic

flowmeter

1) MODBUS register definition of electromagnetic flowmeter

Table-2
Protocol
Protocol Addresses
Addresses Data format Resister definition
(HEX)
(Decimal)
Instantaneous flow
4112 0x1010 Float Inverse
float representation
Instantaneous velocity
4114 0x1012 Float Inverse
float representation
Float representation of the
flow percentage
4116 0x1014 Float Inverse
(reservation for
battery-powered
Floating representation of
4118 0x1016 Float Inverse
fluid conductivity ratio
Integer part of the cumulative
4120 0x1018 Long Inverse
positive value
Decimal part of the
4122 0x101A Float Inverse
cumulative positive value
Integer part of the cumulative
4124 0x101C Long Inverse
negative value
Decimal part of the
4126 0x101E Float Inverse
cumulative negative value
Instantaneous flow unit
4128 0x1020 Unsigned short
(table-3)
Cumulative total units
4129 0x1021 Unsigned short
(table-4 or table-5)

4130 0x1022 Unsigned short Upper limit alarm

4131 0x1023 Unsigned short Lower limit alarm


4132 0x1024 Unsigned short Empty pipe alarm
4133 0x1025 Unsigned short System alarm

2) PLC address set illustration

If there isn’t function code setting options when we configure PLC, you should

-5-
L-MAG Electromagnetic Flowmeter Standard MODBUS Communication Protocol

add 3 in front of register address when you use function code 04. If PLC register
address’s basic address is from 1, you should add 1 to original address when
configuring register address.
Example: L-mag electromagnetic flowmeter MODBUS register address is
4112(0x1010) and MODBUS function code is 4. So PLC register address is 34113.
The detailed configuration is seen in example chapter 2.
3) Address configuration illustration of KingView software
There isn’t option of configuring function code. Different drivers have different
configuration methods.
Take PLC- Modicon-MODBUS (RTU) driver for a example. You should add 8 in
front of register address when using function code 04. KingView register address’s
basic address is 1, so the original address should be added 1 when configuring
KingView register address.
L-mag electromagnetic flowmeter MODBUS register address is 4112(0x1010)
and MODBUS function code is 4. So PLC register address is 84113.
The detailed configuration is seen in example chapter 4.
4) Illustration of data’s meaning
 Float format:
L-mag electromagnetic flowmeter MODBUS uses IEEE754 which is 32 bits
float format. Its structure is shown as follows: (take Instantaneous flow for a example)

0X1010(34113) 0x1011(34114)

BYTE1 BYTE2 BYTE3 BYTE4

S EEEEEEE E MMMMMMM MMMMMMMM MMMMMMMM

S- Mantissa symbol; 1=negative, 0=positive.


E- Exponent; expressed by the difference with decimal number 127.
M- Mantissa; low 23 bits and the decimal part.
When not all of the E is “0” and “1”, the conversion formula between float and
the decimal number is:

V  (1) S 2 ( E 127) (1  M )
-6-
L-MAG Electromagnetic Flowmeter Standard MODBUS Communication Protocol

 Instantaneous flow unit


Code Unit Code Unit Code Unit Code Unit

0 L/S 3 M3/S 6 T/S 9 GPS

1 L/M 4 M3/M 7 T/M 10 GPM

2 L/H 5 M3/H 8 T/H 11 GPH

 Cumulative flow unit


Table 4 ( It is suit for B type and 511 type electromagnetic flowmeter converter)

Code 0 1 2 3

Cumulative unit L M3 T USG

Table 5 ( It is suit for C type electromagnetic flowmeter converter)

Code 0 1 2 3 4 5
Cumulative unit L L L M3 M3 M3
Code 6 7 8 9 10 11
Cumulative unit T T T USG USG USG

 Alarm
Upper limit alarm, lower limit alarm, empty pipe alarm, system alarm:
0 ------ No alarm; 1------ Alarm

6. Communication data analysis

Instantaneous flow, instantaneous velocity, flow percentage, fluid conductivity


ratio, decimal part of the cumulative positive and negative value, format conversion of
float, integer part of the cumulative positive and negative value, transmission of long.
1) Read instantaneous flow

Master sends command (hexadecimal number)


01 04 10 10 00 02 74 CE

Device Function Register Register Register Register CRC CRC


high high high low
address code high low
address address length length

-7-
L-MAG Electromagnetic Flowmeter Standard MODBUS Communication Protocol

Data that master receives


01 04 04 C4 1C 60 00 2F 72

Device Function Data 4 bytes float CRC CRC


address code length (instantaneous flow) high low

Float: C4 1C 60 00
1100 0100 0001 1100 0110 0000 0000 0000
float byte 1 float byte 2 float byte 3 float byte 4
S=1: if mantissa symbol is 1, it is a negative.
E=10001000: Exponent is 136
M=001 1100 0110 0000 0000 0000, The mantissa is :
1 1 1 1 1
V  (1)1 2(136 127) (1      )
8 16 32 512 1024
= -625.5
2) Read instantaneous velocity

Master sends command (hexadecimal number)


01 04 10 12 00 02 D5 0E

Device Function Register Register Register Register CRC CRC


high high high low
address code high low
address address length length

Data that master receives


01 04 04 C1 B0 80 00 A6 5F

Device Function Data 4 bytes float CRC CRC


address code length (instantaneous velocity) high low

Float: C1 B0 80 00
1100 0001 1011 0000 1111 1000 0000 0000
S=1
E= 10000011
M= 011 0000 1111 1000 0000 0000
1 1 1
V  (1)1 2(131127) (1    )
4 8 256
= -22.0625

-8-
L-MAG Electromagnetic Flowmeter Standard MODBUS Communication Protocol

3) Read cumulative flow

To express the 9 bits cumulative value of electromagnetic flowmeter totally,


integer part and decimal part of cumulative flow are expressed respectively. The
integer part uses long variable and the decimal uses float variable.
Cumulative flow is 1578m3
Master sends command to collect the integer value of cumulative flow
01 04 10 18 00 02 F5 0C

Device Function Register Register Register Register CRC CRC


high high high low
address code high low
address address length length

Data that master receives


01 04 04 00 00 70 71 1E 60

Device Function Data 4 bytes float CRC CRC


address code length (integer value of cumulative flow) high low

Integer value of cumulative flow is 28785


Master sends command to collect the decimal value of cumulative flow
01 04 10 1A 00 02 54 CC

Device Function Register Register Register Register CRC CRC


high high high low
address code high low
address address length length

Data that master receives


01 04 04 3F 00 00 00 3B 90

Device Function Data 4 bytes float CRC CRC


address code length (decimal value of cumulative flow) high low

Float: 3F 00 00 00
0011 1111 0000 0000 0000 0000 0000 0000
S=0
E= 0111111 126
M= 000 0000 0000 0000 0000 0000

V  (1)1 2(126 127)  0.5

-9-
L-MAG Electromagnetic Flowmeter Standard MODBUS Communication Protocol

4) Read instantaneous flow unit

Master sends 8 bytes command to read instantaneous flow unit


01 04 10 20 00 01 34 C0

Device Function Register Register Register Register CRC CRC


high high high low
address code high low
address address length length

7 bytes data that master receives from slave


01 04 02 00 05 79 33

Device Function Data 2 bytes integer CRC CRC


address code length (instantaneous flow unit) high low

Flow unit is M3/H from table-3.


5) Read the unit of the total amount of flow

Master sends 8 bytes command to read instantaneous flow unit


01 04 10 21 00 01 65 00

Device Function Register Register Register Register CRC CRC


high high high low
address code high low
address address length length

7 bytes data that master receives from slave


01 04 02 00 01 78 F0

Device Function Data 2 bytes integer CRC CRC


address code length (cumulative flow unit) high low

Flow unit of B type and 511 type is M3 from table-4.


Flow unit of C type is L from table-5.
6) Read alarm status

Master sends 8 bytes command to read instantaneous flow unit


01 04 10 24 00 01 75 01

Device Function Register Register Register Register CRC CRC


high high high low
address code high low
address address length length

- 10 -
L-MAG Electromagnetic Flowmeter Standard MODBUS Communication Protocol

7 bytes data that master receives from slave


01 04 02 00 01 78 F0

Device Function Data 2 bytes integer CRC CRC


address code length (alarm) high low

Empty pipe is in alarm status if status is 1.


Other alarm status is the same and so on.

- 11 -

You might also like