Flexim ModBus Gateway Getting...

19
Flexim ModBus Gateway Getting Started Guide “A Gentle On-Ramp for your Learning Curve” Flexim Americas Corporation Engineering Department August 2012

Transcript of Flexim ModBus Gateway Getting...

Page 1: Flexim ModBus Gateway Getting Startedquotation.flexim.com/sales-docs/Useful-Technical-Documentation/Fl… · Flexim ModBus Gateway Getting Started Guide “A Gentle On-Ramp for your

Flexim ModBus Gateway

Getting Started Guide

“A Gentle On-Ramp for your Learning Curve”

Flexim Americas Corporation

Engineering Department August 2012

Page 2: Flexim ModBus Gateway Getting Startedquotation.flexim.com/sales-docs/Useful-Technical-Documentation/Fl… · Flexim ModBus Gateway Getting Started Guide “A Gentle On-Ramp for your

1. Introduction Flexim’s ModBus Gateway is a flexible and robust means of extracting full resolution and complete data from the 7407 flow transmitter. Its behavior and organization are well described by the Flexim ModBus Supplement document. However, over the years we have noticed that users sometimes experience a steep early phase in their learning curve which can be frustrating. Add to this the often precarious field environments (noise, weather, access, comms links etc.), and you have a good recipe for futile hours on the phone before the gear is up and running properly. This document has been prepared as a kind of gentler on-ramp up that learning curve. It will first do a step-by-step description of the 7407/Gateway setup. All hardware and software options and settings will be described and commented on. Although this may be tedious to some, it turns out that the more elements of the system you can put in the ‘known-good’ box; the easier it is to identify and solve issues that might be preventing operation. After this, we will provide practical advice on register addresses and organization. A full memory map for the most common channel variables is also provided. Since the ModBus protocol is quite old and has been expanded and interpreted over the years by various manufacturers’ implementations, a certain amount of what one might call ‘ambiguous uncertainty’ has grown up in certain areas of its use. I will try to cast what light I can on these areas and suggest ways to determine whether they can be an issue in your particular deployment. Although Flexim distributes an applet (MBMaster.exe and MBMaster_Main.exe), in the interest of uniformity and objectivity, this document will also provide examples based on the widely-used ModScan32 master station simulator available from Wintech http://www.win-tech.com/html/modscan32.htm

2. Setting up your transmitter:

It is comforting to make sure that your 7407 is actually equipped with a ModBus gateway before getting started. The best way to do this is to enter the HotCode: 485000. In Flexim usage, a HotCode is entered by being in command mode (not measurement mode) and then keying the ‘C’ key followed by the HotCode. You may need to do this more than once as the sequence is somewhat timing dependent.

The user menu will respond with a menu entry (RS485 Interface) that indicates either ‘Sender’ or ‘ModBus’. Please make sure ‘ModBus’ is selected since sender will place the transmitter into a state where it simply outputs datalogger reports from the RS485 port at user-selected intervals.

The next menu location you will need to access is Special Functions/System Settings/Network. This entry is only present if your 7407 contains a ModBus (or BACnet) gateway. It is here that you will assign your transmitter a unique (on your network) slave or network address. This is a number from 1 to 240 in the Flexim case. Be sure you remember it since your master needs to know it in order to compose a proper polling message for the meter. Press <enter> to accept this and obtain access to a menu location that is entitled ‘RS485 Protocol’. This cell really means ‘Communication Parameters’ and is defaulted to 9600, Even Parity, 1 Stop Bit. The Flexim ModBus serial message always contains 8 bits (the gateway protocol is ModBus RTU). Many master stations are set up for 9600/No Parity/1 Stop Bit, so you may wish to confirm what yours needs before proceeding. If the comms parameters don’t match or the station address is wrong, you will not obtain successful polling operation.

When you press <enter> here, the transmitter stores these new parameters into the gateway’s non-volatile memory for safe keeping and is now ready to communicate. The gateway is constantly being fed updated information—generally every 1 or 2 seconds. However, for the data to be ‘interesting’ it is handy to have some sort of operation active in channel(s). This can be done in a two ways:

Page 3: Flexim ModBus Gateway Getting Startedquotation.flexim.com/sales-docs/Useful-Technical-Documentation/Fl… · Flexim ModBus Gateway Getting Started Guide “A Gentle On-Ramp for your

• By using some sort of standpipe, pipe simulator or even an air-test arrangement with the

transducers and obtaining actual operation. In this way, you will have a fully operating channel to observe. Even at zero flow, the gateway provides access to sound speed and signal strength data.

• Being installed on the target application and having the transmitter fully active and functional. This is clearly the most authentic way of testing your equipment.

3. Connecting your RS485 cable:

There is quite a lot of contradictory and ambiguous information out there concerning the correct nomenclature for the ‘2-wire’ RS485 connection.

A+ and B-: Flexim has labeled the terminal blocks in accordance with the usage defined by the driver chip used: the Maxim 1480 device. The device’s outputs are labeled A and B and Flexim added + and - signs (reminders of actual polarity) to these. Thus, internally, A+ is connected to A and B- is connected to B. The reference connection (the third wire) is connected to the chip’s isolated ground and coupled to the meter’s safety ground through an appropriate R/C network. Here’s a sketch:

Needless to say, it is very handy to minimize doubts about whether the pair from your master

is correctly connected to the 7407’s terminal block positions. Use a voltmeter set for DC volts to measure the voltage between A+ and B- (red on A+ and black on B-). You will find it to be a bit under +3 volts. The twisted pair coming from your USB-to-RS485 converter or PLC or other master will (most likely) also show a DC voltage and you should connect positive lead to A+ and the more negative lead to B-. Here’s a photo:

Page 4: Flexim ModBus Gateway Getting Startedquotation.flexim.com/sales-docs/Useful-Technical-Documentation/Fl… · Flexim ModBus Gateway Getting Started Guide “A Gentle On-Ramp for your

Comments on the Daisy-Chain: Wiser and more experienced hands than this writer have

extensively published on the requirements and recommendations for RS-485 2-wire operation. Here are a few citations to get you started: http://pdfserv.maxim-ic.com/en/an/AN763.pdf http://www.bb-elec.com/bb-elec/literature/tech/485appnote.pdf

For a short, single station connection from desktop to your transmitter, you can use a simple twisted pair with no shield at all. Once you have a multi-drop network, longer line lengths and higher data rates, you’ll have to provide the correct resistive terminations at the two ends of your daisy chain and perhaps even biasing resistors as described in the papers cited above. The 2-wire designator, by the way, is a misnomer in that a reference wire is needed even in modest-sized deployments. Let’s assume for our purposes, however, that the twisted pair, positive-to-positive, negative-to-negative, is now connected between your polling entity (master, PLC, PC running our applet or ModScan) and the slave device, the 7407.

What Now?

Ok, we are in some measurement mode as suggested above, the serial parameters are set, and you’re wired up. Now it’s time to invoke the master station simulator applet: ModScan or MBMaster or the like. Before you trigger the polling activity, navigate to the menu where the comms parameters are defined. Be sure that the serial port being used corresponds to the one that will communicate with the RS485 line. [You may need to go to your PC device manager to make sure of this.] Then set the baud rate (speed), parity, number of stop bits, and slave address to match those selected by you at the transmitter earlier.

Assuming that you are using our MBMaster applet and default parameters (network address

1), your setup screen should look like this:

This USB-to-RS485 converter maps to COM6 as you can see.

For older PCs it may be necessary to change the silent interval setting (lower right) to 40 character times. You can see that in this example, the meter was set for 9600/no parity/1 stop bit.

Page 5: Flexim ModBus Gateway Getting Startedquotation.flexim.com/sales-docs/Useful-Technical-Documentation/Fl… · Flexim ModBus Gateway Getting Started Guide “A Gentle On-Ramp for your

Once this is set up correctly, click ‘OK’ and go to the main screen and set in the network ID (slave address) like this:

In this screen shot, the MBMaster applet has been triggered to collect Fluid temperature information by keying the ‘Connect to Modbus’ button after entering (1) as the slave address. The applet will then permit to you examine any of the available data items and display their attributes in the Current Measuring Value window.

Once you get to this point, you are sure the wiring is correct, the meter is set up and operating, the ModBus gateway is getting data, your communications parameters and slave address are correct and your PC is addressing the RS485 device correctly. Not Bad!

4. Some ModScan32 Screens:

Although the above exercise demonstrates basic operation, it is even more useful to use an applet that is more industry standard (and possibly less self-serving!). We have selected ModScan for this purpose due to its ubiquity and flexibility. It will allow you to examine registers and data types directly and actually look at the ModBus data traffic, should that be of interest. One other source for an excellent ModBus master simulator (free as a demo) is http://www.azeotech.com/downloads

Here is the ModScan serial parameters setup screen. Once you set up the parameters and click <ok>, the applet starts polling immediately.

Page 6: Flexim ModBus Gateway Getting Startedquotation.flexim.com/sales-docs/Useful-Technical-Documentation/Fl… · Flexim ModBus Gateway Getting Started Guide “A Gentle On-Ramp for your

No other settings are required to obtain operation. Assuming that your meter and 485 device are wired up, the main ModScan screen looks like this:

A complete orientation on the functions and feature of the ModScan applet is beyond the scope of this document but in this screen we see that the Device ID (Slave Address) is correctly set to 1. The point type is Holding Register which (for some reason) has a prefix of 4 in the ModBus universe. The particular register that has been selected for display is a utility register that we call the Heartbeat. It indicates that the ModBus gateway is operating and is simply an integer count that increases once per second and finally rolls over when its 16 bit capacity is exceeded. Since this is a simple integer register, its length is 1 (2 8-bit bytes). And finally its register address is 0002. Interestingly, Flexim defines this register location as 1, since our register allocation rules are zero based. Most master stations begin counting registers at 1, so get used to this offset of one. All register addresses will be defined in the tables provided later in this document.

The next screen is the first temperature of channel A. It allows us to see this floating point variable, represented by two ModBus registers. The construction details of the register address will be explained in detail later. For now, suffice it to say that the first temperature (32.2231 deg) of Ch A is displayed as a floating point number (select in Setup/Diplay Options in the ModScan32 main screen).

Page 7: Flexim ModBus Gateway Getting Startedquotation.flexim.com/sales-docs/Useful-Technical-Documentation/Fl… · Flexim ModBus Gateway Getting Started Guide “A Gentle On-Ramp for your

It makes no sense to proceed any further unless you are able to obtain the results shown to this point. If your meter does not provide a temperature input, you can look at another variable, such a flow rate or totals (make sure the totalizer is activated in the meter; use the Qon key, keypad numeral 8).

We will examine one more ModScan screen, showing the register region provided by the meter where all principle meter variables are available as a block. This region for Cha A begins at register location 15001 and reports 25 variables.

The actual identity of each variable is defined in Flexim’s ModBus Supplement (page 30) but will also be covered in detail below.

Ok, I can read a variable, now where is everything else?

In the pages and tables that follow, we will review, summarize, and comment on all of the variables which the Flexim ModBus Gateway supports. Much of the information contained here comes from Flexim document: “SUFluxus_Modbusv2-3.pdf” which is the primary reference source of information for the gateway.

Most ModBus register definitions below will be cited with an already included offset of +1. This

is not the case in the Flexim ModBus Supplement document.

Page 8: Flexim ModBus Gateway Getting Startedquotation.flexim.com/sales-docs/Useful-Technical-Documentation/Fl… · Flexim ModBus Gateway Getting Started Guide “A Gentle On-Ramp for your

ModBus Memory Map Geography

5. Gateway Primary Register Structure:

Before we get into this, a short remark on the transmitter’s channel structure is appropriate:

If you have a single channel transmitter much of this will not be of interest, however many 7407’s are purchased as dual channel machines. As such they also provide 2 calculated channels that allow the physical channels, A and B, to be combined in a variety of ways to create channels Y and Z. The calculated channel is frequently set up as an averaging channel, combining the two physical channels and providing improved flow stability and sensor redundancy. In other applications, the calculated channel may be used as a sum or difference channel as well.

The ModBus register memory map geography reflects the transmitter’s channel structure by providing a characteristic offset for each channel as follows: Channel Offset A 1001 B 2001 Z 9001 Y 10001

Since some masters are unable to address regions beyond 9999, we recommend that ModBus-equipped transmitters using calculated channels be set up for channel Z operation. The above base locations include the +1 offset previously noted for most masters.

Note that the calculated channels do not support all of the variables that the physical channels do. The table in Section 7 graphically shows this by blanking those register addresses.

Page 9: Flexim ModBus Gateway Getting Startedquotation.flexim.com/sales-docs/Useful-Technical-Documentation/Fl… · Flexim ModBus Gateway Getting Started Guide “A Gentle On-Ramp for your

6. Composition of the Parameter Block:

Each transmitter parameter reported by the ModBus gateway is supported by 16 registers. This register organization allows the user to assess the state of the variable before confidently using it. For example, each parameter block contains a status register and a ‘seconds since last update’ register. If either of these appears ‘off normal’, the master station can be set up to alarm rather than display or record false or stale data. The currently selected units are also available here as an ASCII string. The structure of each parameter block is as follows:

Register content Offset Explanation Data format Status 0 Status of the measured variable

Integer 16 bit 0=not available-never set up 1=ok 2=failed Variable in default units, Hi word 1

Variable Expressed in meter's default measurement units

32 bit Floating point Variable in default units, Lo

word 2 User Units Code * 3 See Supplement for detailed description 16 bit Integer Variable in User Units, Hi word 4 Variable Expressed in units defined by

previous preceding user units code 32 bit Floating

point Variable in User Units, Lo word 5 Selected User Units, ASCII part 1 6

These 6 bytes read as ASCII spell out the user units selected by the User Units Code ASCII Selected User Units, ASCII part

2 7 Selected User Units, ASCII part 3 8 Seconds since last update 9 Typically varies between 1 and 3 seconds Integer 16 bit reserved 10 reserved 11 reserved 12 reserved 13 reserved 14 reserved 15 * See Appendix for Code Table

Page 10: Flexim ModBus Gateway Getting Startedquotation.flexim.com/sales-docs/Useful-Technical-Documentation/Fl… · Flexim ModBus Gateway Getting Started Guide “A Gentle On-Ramp for your

7. Layout of the Various Parameter Blocks:

Reviewing, each measurement parameter is reported on by the 16-register block defined above and whose base location is shown as an offset from the beginning of the channel shown in the table below. The table also includes useful columns showing the exact register locations for each floating point variable expressed in user units. For ModScan use, you need not enter the ‘4’ prefix.

Variable Name O

ffse

t

default unit

Comment Address of Ch A Variable

(User Units)

Address of Ch B

Variable (User Units)

Address of Ch Y

Variable (User Units)

Address of Ch Z

Variable (User Units) Ext Inputs

Note: Calculated channels do not report Ext Input Data such a temp or pressure

medium temperature (return/supply) 0 °C In the BTU meter version of the firmware the

supply/return mapping of the temperature and pressure variables inverts depending upon

where the flow transducers are installed

41005 42005 medium temperature (supply/return) 16 41021 42021

medium pressure (return/supply) 32 bar

41037 42037

medium pressure (supply/return) 48 41053 42053

Basic Sensing Variables

signal amplitude 64 - Larger number=stronger signal 41069 42069 sound speed 80 m/s speed of sound in medium 41085 42085 410085 49085 flow velocity 96 m/s speed of the medium displacement 41101 42101 410101 49101

Flow Rates and Totals

volumetric flow rate (gross) 112 m3/h uncorrected for temp/pressure 41117 42117 410117 49117 gross positive totalizer 128

m3 negative totalizer is not signed

41133 42133 410133 49133 gross negative totalizer 144 41149 42149 410149 49149 standard flow rate (net) 160 m3/h corrected for temp/pressure 41165 42165 410165 49165 net positive totalizer 176

m3 negative totalizer is not signed

41181 42181 410181 49181 net negative totalizer 192 41197 42197 410197 49197 mass flow 208 kg/s 41213 42213 410213 49213 mass positive totalizer 224 kg 41229 42229 410229 49229 mass negative totalizer 240 41245 42245 410245 49245 energy flow 256 W 41261 42261 410261 49261 energy positive totalizer 272

MW/h 41277 42277 410277 49277

energy negative totalizer 288 41293 42293 410293 49293

Ancillary Variables concentration 304 - Units depend on liquid file 41309 42309 410309 49309 medium temperature (supply) 320 °C

These register locations are the same regardless of location of flow transducers

(supply/return)

41325 42325 medium temperature (return) 336 41341 42341 medium pressure (supply) 352

bar 41357 42357

medium pressure (return) 368 41373 42373 compressibility correction factor (gas) 384 - 41389 42389 410389 49389 density 400 g/cm3 41405 42405 410405 49405

diagnostic values

SNR 700 dB Wide band signal-to-noise ratio 41705 42705 SCNR 716 dB Synchronoujs signal-to-noise ratio 41721 42721 VariAmp 732 % Signal Amplitude Flutter 41737 42737 VariTime 748 % Signal Arrival Time jitter 41753 42753 detection rate 764 % 41769 42769 diagnostic error bits 780 bit See details in ModBus Supplement 41785 42785

Please observe that the prior table, listing the offsets of each of the parameters from the beginning of the channel location, shows the location of each parameter expressed in floating point format and in user units. It already contains the offset required for proper display by most masters as well and thus can be used ‘as is’. To look at Ch B, simply use the 2001 offset instead of 1001 and similarly for Ch Z, 9001. Parameters directly associated with physical flow sensing and/or analog inputs which are associated with each physical channel are not supported in the calculated channels. This completes the explanation of the meter’s primary register structure. Over the years, and in response to requests that the gateway provide a more compact and convenient way of accessing the main registers of interest, three additional register regions have been

Page 11: Flexim ModBus Gateway Getting Startedquotation.flexim.com/sales-docs/Useful-Technical-Documentation/Fl… · Flexim ModBus Gateway Getting Started Guide “A Gentle On-Ramp for your

implemented. All of these allow polling for multiple variables as a single block and some contain status register support as well.

8. Block Oriented Register Structures: “I’ll take everything---all at once!”

To reduce system bus load, it is possible to read all physical quantities of one channel (IEEE floating point format, 32 bit) with only one Modbus request from the master. The measured values are reported in user-selected units of measurement. The starting addresses of these register blocks are:

Meter Channel

Start Adress

Meter Channel

Start Adress offset of +1

A 15001 D 18001 B 16001 Z 19001 C 17001 Y 20001

The arrangement of the floating point registers within these starting addresses is:

physical quantity Offset from Start

High Word

Low Word

medium temperature (return/supply) 0 1 medium temperature (supply/return) 2 3 medium pressure (return/supply) 4 5 medium pressure (supply/return) 6 7 signal amplitude 8 9 sound speed 10 11 flow velocity 12 13 volumetric flow rate (gross) 14 15 (gross) positive totalizer 16 17 (gross) negative totalizer 18 19 standard volumetric flow rate (net) 20 21 (net) positive totalizer 22 23 (net) negative totalizer 24 25 mass flow 26 27 mass positive totalizer 28 29 mass negative totalizer 30 31 energy flow rate 32 33 energy positive totalizer 34 35 energy negative totalizer 36 37 concentration 38 39 medium temperature (supply) 40 41 medium temperature (return) 42 43 medium pressure (supply) 44 45 medium pressure (return) 46 47 compressibility correction factor 48 49 density 50 51 Unfortunately, Master stations that are unable to address registers above 9999 will not be able to exploit this block oriented region.

9. Special HPI Register Set: Floating point representation of total data sometimes presents problems. The resolution of the numbers become poor when the number gets large and, particularly if ‘totals since the last update’ or

Page 12: Flexim ModBus Gateway Getting Startedquotation.flexim.com/sales-docs/Useful-Technical-Documentation/Fl… · Flexim ModBus Gateway Getting Started Guide “A Gentle On-Ramp for your

‘daily totals’ are posted by a PLC, the data can become distressingly ‘chunky’. To remedy this, a series of totalizers and other registers have been implemented that provide the data as double precision integer numbers. Although of limited capacity (2^32 is about 4.3 billion), they preserve full resolution throughout their dynamic range. The only problem is that the meter’s internal totalizer rolls over at over twice this (10 9’s or 1 less than 10 billion). A special auto-clear totalizer bit has been established for those to whom this presents a problem. Its behavior is described later in this document. The HPI register set contains a number of variables that are only supported by the HPI version of the flow meter. Non-HPI units will find no data there for variables that are unique to that instrument. The units used in this register set are as per the User Units Code register noted above and defined in the Appendix. The listed register locations include the +1 offset. The register map for this region is:

value (grey = HPI only) Off

set

Format ChA

location ChB

location ChZ

location Channel Status Items

measuring channel status2 600 16 bit int 41601 42601 49601 time since last update 601 16 bit int 41602 42602 49602 volumetric flow rate

positive flow direction 602 32 bit float 41603 42603 49603

negative flow direction 604 32 bit float 41605 42605 49605

positive totalizer 606 32 bit int 41607 42607 49607 negative totalizer 608 32 bit int 41609 42609 49609

status3 610 16 bit int 41611 42611 49611 standard volumetric flow rate

positive flow direction 611 32 bit float 41612 42612 49612

negative flow direction 613 32 bit float 41614 42614 49614

positive totalizer 615 32 bit int 41616 42616 49616 negative totalizer 617 32 bit int 41618 42618 49618

status3 619 16 bit int 41620 42620 49620 mass flow rate

positive flow direction 620 32 bit float 41621 42621 49621

negative flow direction 622 32 bit float 41623 42623 49623

positive totalizer 624 32 bit int 41625 42625 49625 negative totalizer 626 32 bit int 41627 42627 49627

status3 628 16 bit int 41629 42629 49629 API-gravity (API-value)

status4 629 16 bit int 41630 42630 49630

value 630 32 bit float 41631 42631 49631

sound speed at Base Temperature (Sonic ID)

status4 632 16 bit int 41633 42633 49633

value 633 32 bit float 41634 42634 49634

specific gravity

status4 635 16 bit int 41636 42636 49636

value 636 32 bit float 41637 42637 49637

density at standard conditions (Density at BC)

Page 13: Flexim ModBus Gateway Getting Startedquotation.flexim.com/sales-docs/Useful-Technical-Documentation/Fl… · Flexim ModBus Gateway Getting Started Guide “A Gentle On-Ramp for your

status4 638 16 bit int 41639 42639 49639

value 639 32 bit float 41640 42640 49640

volume correction factor (VCF-value)

status4 641 16 bit int 41642 42642 49642

value 642 32 bit float 41643 42643 49643

number of the current liquid (Current liquid)

status4 644 16 bit int 41645 42645 49645

value 645 32 bit float 41646 42646 49646

rate of change of sound speed (Slope soundspeed)

status4 647 16 bit int 41648 42648 49648

value 648 32 bit float 41649 42649 49649

rate of change of API gravity (Slope API-value)

status4 650 16 bit int 41651 42651 49651

value 651 32 bit float 41652 42652 49652

medium temperature (only available in physical channel)

status4 653 16 bit int 41654

value 654 32 bit float 41655

kinematic viscosity

status4 656 16 bit int 41657 42657 49657

value 657 32 bit float 41658 42658 49658

Page 14: Flexim ModBus Gateway Getting Startedquotation.flexim.com/sales-docs/Useful-Technical-Documentation/Fl… · Flexim ModBus Gateway Getting Started Guide “A Gentle On-Ramp for your

10. Special HPI Dual-Beam Register Cluster

The gateway supports an additional, highly specific register cluster which provides access to Channel Y data. This is typically used for dual beam transmitters providing data for leak detection in hydrocarbon product pipelines.

Item Location Type Comment

Status 7000 Binary (0=fault 1=normal 2=not installed)

[Uses ChY fault flag]

Heartbeat 7001 16 bit integer (1 second upcount) Net (Normalized) Flow Rate 7002 Float Gross (Actual) Flow Rate 7004 Float Temperature (ChA) 7006 Float From ChA Pressure (ChA) 7008 Float From ChA API# @ Ref Cond 7010 Float [Unitless] Net (Norm) Positive Totalizer 7012 32 bit integer unsigned Gross (Actual) Positive Totalizer 7014 32 bit integer unsigned

11. Special Purpose Utility Registers: ModBus Register 1- contains the current Modbus module firmware version. The first byte

contains the major part and the second byte the minor part of the version number. In ModScan it looks like this:

This is best observed as a hexadecimal number. The first byte is 1 and the second is

18 (16+2). The firmware revision number is thus 1.18. The register is not writable.

ModBus Register 2- contains the heartbeat (16 bit). When the transmitter is switched on, the register will be set to 0. The register value will be incremented by 1 every second. If 65 535 is reached, a register overflow occurs and counting restarts with 0. The first ModScan example displayed this register. This register is not writable.

Modbus register 11- contains the response delay in ms. Although it is a 16 bit register, only values in the range 0 to 1000 will be accepted by the gateway. Default is 10 ms. This register is provided for older PLCs needing a time delay between poll request and response. This is a read/write register.

ModBus Register 18- Contains the byte/word order control for readable/writeable modbus registers. It is unlikely that you will be needing this since the gateway defaults to the byte/word order which most master stations use. See Appendix B for further details.

ModBus Register 21- If this register contains 0x01, automatic totalizer reset is activated, if not, it is deactivated. This control is provided to force a reset of the totalizers if their value exceeds the capacity of a long integer (2^32 or almost 4.3 million). If you use the long integer totalizers, consider activating this to prevent the totalizers from exceeding the capacity of the long integer to contain their value. Long integer totalizers will be described later in this document. This is a read-write register.

Page 15: Flexim ModBus Gateway Getting Startedquotation.flexim.com/sales-docs/Useful-Technical-Documentation/Fl… · Flexim ModBus Gateway Getting Started Guide “A Gentle On-Ramp for your

12. Totalizer Reset Controls:

ModBus Register 101- Contains the channel identifier for an totalizer reset (e.g. Ch A � ‘A’=decimal 65/hex 41, Ch B ‘B’=decimal 66/hex 42 , All (*)=decimal 42/hex 2A. You have to figure out the proper prefix to issue an integer register write command.

You need to do this every time you issue a reset command.

ModBus Register 102- contains the sign of the totalizer register to be reset selected above. This is also written as an integer, not a float. You write a hex 2B (decimal 43-a plus sign) to act on the positive totalizer, a hex 2D (decimal 45-a minus sign) to act on the negative totalizer and a hex 2A (decimal 42-there's that asterisk again) to zero both.

ModBus Register 221- Write 0x01 to this register in order to execute the totalizer clear command set up above. This must be done after the two setup writes. This more or less gives you the specifics of resetting the positive totalizer of Channel A. Probably the simplest way to do this is just zero all totalizers of all channels at once by picking the asterisk code for both channel and totalizer sign control.

13. Slope and Offset factor control – **** Use with caution as this will affect meter’s primary function****

ModBus Register 111- Channel selector register for slope calibration factor write command. The syntax as identical to totalizer control described above. Only channels A and B are valid selections for this functionality. For dual beam meters, both channels must be handled separately.

ModBus Register 113- Contains the value of the slope calibration factor (meter factor) to be written. The value of this factor can vary between –2.000 and+ 2.000 and possesses floating point resolution. It is written as a floating point number.

ModBus Register 115- Contains the offset of the calibration factor (-128 to 127). This is a signed integer register. The units here are mm/sec of flow velocity. The flow meter has excellent zero behaviour and we suggest that this register be left at its default state of zero.

ModBus Register 121- Calibration factor (slope & offset) is activated if a 0x01 is written to this register. This corresponds to register 221 for totalizer reset and works like a trigger. The slope and offsets are only visible in the transmitter’s menu when SuperUser mode is invoked.

14. Reading of Device Specific Information The transmitter supports the Modbus function Report Slave ID (Function Code 17) allowing it

to read out device specific in formation (see Modbus specification). The response is: • first byte: slave address (network ID) • second byte: Modbus function code • third byte: total number of bytes following • next 40 bytes: slave ID byte stream containing:

- 1 byte with the Run Indicator Status (0x00=OFF, 0xFF=ON) - ASCII byte stream with further device information - CRC16 check sum (last 2 bytes)

A data block like this can be constructed from the contents of this message:

Page 16: Flexim ModBus Gateway Getting Startedquotation.flexim.com/sales-docs/Useful-Technical-Documentation/Fl… · Flexim ModBus Gateway Getting Started Guide “A Gentle On-Ramp for your

15. Date/Time of last series of measurement Modbus registers 3...8 contain the start date and time of the last series of measurements. This

is the last time the channel was started up either by a power cycle or user intervention in the MEASurement menu. Register Address Contents 3 day 4 month 5 year 6 hour 7 minute 8 second

Here is a ModScan dump of these registers (note offset of +1) on the third of August of 2012 when the last ModBus report had been posted at 10:08:13. The registers are read as 16 bit integers for this function.

Page 17: Flexim ModBus Gateway Getting Startedquotation.flexim.com/sales-docs/Useful-Technical-Documentation/Fl… · Flexim ModBus Gateway Getting Started Guide “A Gentle On-Ramp for your

Appendix A Unit Codes For ModBus Gateway

Here is the form we ask customers to fill out so we can pre-program the units in their ModBus gateway. A few things to keep in mind:

• A units code is provided for all unit types supported by the flow meter. 0 is the default. • Each 16 register parameter block contains three registers that report, in ASCII, the

current user selected units for that variable. • All special register blocks report parameters in user-selected codes.

Code Volumetric Rate Units Code Volumetric Total Units Code Mass FlowRate Units 0 cubic meter per hour (m3/h) 0 cubic meter (m3) 0 kilogram per second (kg/s) 1 cubic meter per day (m3/d) 1 megaliter (Ml) 1 gram per second (g/s) 2 cubic meter per hour (m3/h) 2 cubic meter (m3) 2 tons per day (t/d) 3 cubic meter per minute (m3/min) 3 hectoliter (hl) 3 tons per hour (t/h) 4 cubic meter per second (m3/s) 4 liter (l) 4 kilogram per hour (kg/h) 5 100 liter per hour (hl/h) 5 US gallons (USgal) 5 kilogram per minute (kg/min) 6 100 liter per minute (hl/min) 6 barrel (bbl) 6 kilogram per second (kg/s) 7 liter per hour (l/h) 7 US MGAL 7 US pound per day (lb/d) 8 liter per minute (l/min) 8 US kGAL 8 US pound per hour (lb/h) 9 liter per second (l/s) 9 milliliter (ml) 9 US pound per minute (lb/min) 10 Millions US gal per day (MGD) 10 Cubic feet (CF) 10 US pound per second (lb/sec) 11 US gallons per day (USgpd) 11 Millions Cubic Feet (MMCF) 11 US kilopound per hour (klb/h) 12 US gallons per hour (USgph) 12 Thousands Cubic Feet (MCF) 12 US kilopound per min (klb/m)

13 US gallons per minute (USgpm) Mass Units Energy Rate Units 14 US gallons per second (Usgps) 0 kilogram (kg) 0 watt (W) 15 barrel per day (bbl/d) 1 gram (g) 1 kilowatt (kW) 16 barrel per hour (bbl/h) 2 kilogram (kg) 2 megawatt (MW) 17 barrel per minute (bbl/m) 3 tons (t) 3 kBTU/m 18 barrel per second (bbl/s) 4 US pounds (lb) 4 kBTU/h 19 Millions liter per day (Ml/d) 5 US kilopounds (klb) 5 MBTU/h

20 milliliter per minute (ml/min) Energy Total Units 6 MBTU/d

21 cubic feet per day (CFD) 0 megawatt-hour (MWh) 7 TON 22 cubic feet per hour (CFH) 1 watt-hour (Wh) 8 kTON 23 cubic feet per minute (CFM) 2 kilowatt-hour (kWh) 9 GigaWatt (GW) 24 cubic feet per second (CFS) 3 megawatt-hour (MWh) 10 kBTU/d 25 Millions cubic ft/day (MMCFD) 4 joule (J) 15 BTU/m

26 Millions cubic ft/hour (MMCFH) 5 kilojoule (kJ) Pressure Units 27 Thousands gal / minute (USkgpm) 6 megajoule (MJ) 0 bar(a) (bar absolute) 28 100 liter/sec (hl/s) 7 kBTU 1 millibar (mbar absolute) 29 Thousands cubic feet / day (MCFD) 8 MBTU 2 megapascal (MPa)

30 Thousands cubic feet / hour (MCFH) 9 TONhrs 3 pounds per square inch (psia)

Velocity Units - Flow 10 kTONd 4 Meters head of water (mW)

0 meter per second (m/s) 11 TONd 5 mmHg 1 centimeter per second (cm/s) 12 kTonh 6 bar(g) 2 inch per second (in/s) 13 GWd 7 psi(g)

3 feet per second (ft/s) 14 BTU Sound Speed Units

Temperature Units Density Units 0 meter per second (m/s)

0 degree Celsius (deg C) 0 grams per cubic centimeter(g/cm3) 1 centimeter per second (cm/s) 1 degree Fahrenheit (deg F) 1 kilograms per cubic meter (kg/m3) 2 inch per second (in/s) 2 pounds per cubic foot (lb/ft3) 3 feet per second (ft/s)

Page 18: Flexim ModBus Gateway Getting Startedquotation.flexim.com/sales-docs/Useful-Technical-Documentation/Fl… · Flexim ModBus Gateway Getting Started Guide “A Gentle On-Ramp for your

Appendix B

Word/Byte Order Control Register

Certain, usually older, master stations and PLCs sometimes do not obey IEEE conventions for the word or byte order of ModBus communications. This is particularly true for floating point numbers. The gateway contains a control register which is provided to accommodate these infrequently encountered situations. If you do not alter the default contents of this register, the gateway will properly order the data for the majority of masters. Please use this function with caution as it can make the output of the gateway frustratingly unintelligible if configured incorrectly.

The Flexim ModBus Gateway has been equipped with a facility that permits user selection of byte/word order for 16 and 32-bit registers. These are the 4 possible byte orders for 32-bit variable (floats or long integers):

32-bit variables:

Case 1 (Flexim default) _____A_______ ______B_______ ______C_________ ____D________

Case 2: _____B_______ ______A_______ ______D_________ ____C________

Case 3: _____C_______ ______D_______ ______A_________ ____B________

Case 4: _____D_______ ______C_______ ______B_________ ____A________

Flexim’s control scheme allows independent control of floats and long integers.

Some Modbus masters require Case 2, but to provide more flexibility Case 3 and 4 are implemented also.

Additionally it is possible to swap the byte order of 16-bit (one Modbus register).

16-bit variables:

Case 1 (Flexim default): _____A_____ _____B_____

Case 2: _____B_____ _____A_____

Thus there are 4 conditions of byte/word order for 32-bit variables and 2 conditions of byte order for 16-bit variables.

To select one of these modes for 16-bit variables (1 Modbus register), 32-bit integer variables and 32-bit float variables, one modbus register is used for selection. Since it is desirable that this register be immune to the user selection for 16-bit variables, the two bytes (LSB and MSB) of this register must be identical making the byte order irrelevant. This writable register resides at address 17 (or 18 with +1 offset).

Page 19: Flexim ModBus Gateway Getting Startedquotation.flexim.com/sales-docs/Useful-Technical-Documentation/Fl… · Flexim ModBus Gateway Getting Started Guide “A Gentle On-Ramp for your

Layout of Modbus byte/word order selection register:

BIT15 BIT14 BIT13 BIT12 BIT11 BIT10 BIT9 BIT8

Reserved Reserved Reserved Byte/Word order for 32-bit floats

Byte/Word order for 32-bit integers

Byte order for 16-bit variables

BIT7 BIT6 BIT5 BIT4 BIT3 BIT2 BIT1 BIT0

Reserved Reserved Reserved Byte/Word order for 32-bit floats

Byte/Word order for 32-bit integers

Byte order for 16-bit variables

BIT0 / BIT 8 � 0: Case 1 for 16-bit variables (default) 1: Case 2 for 16-bit variables (reversed) BIT1 / BIT9 � 0: Case 1 for 32-bit integers (default) BIT2 / BIT10 1: Case 2 for 32-bit integers (reversed bytes) 2: Case 3 for 32-bit integers (reversed words) 3: Case 4 for 32-bit integers (reversed both) BIT3 / BIT11 � 0: Case 1 for 32-bit floats (default) BIT4 / BIT12 1: Case 2 for 32-bit floats (reversed bytes) 2: Case 3 for 32-bit floats (reversed words) 3: Case 4 for 32-bit floats (reversed both)

The state of Register 17, defaulted to zero, globally affects all gateway register byte/word orders. Integers, 16 and 32 bit, and floats are controlled independently, allowing good flexibility for various requirements.

Note that this control word is built up out of a series of bits so be sure the variable you pass is correctly cast as binary, hexadecimal or decimal. For example, if you wish to simply reverse the byte order (case 2) of long integers and leave everything else unchanged, the control word written should be hexadecimal 0202 or decimal 514 (2 greater than 512).