Field fix / guideProcedureVendor-agnosticInstrumentationindustrial-automation

Modbus TCP Flow Meter Integration — Engineering Guide

Shared by TSIMEREZIVO Team · 4 Oct 2026 · 51 views

# Modbus TCP Flow Meter Integration Read live flow rate and totalized volume from a Modbus TCP flow meter, scale the raw register values to engineering units, implement a totalization accumulator in Structured Text, and configure high/low alarms — all within TSIMEREZIVO. 20 min ## Modbus TCP Quick Reference ### Key Function Codes | fc | name | obj | |---|---|---| | FC01 | Read Coils | Discrete output — DO | | FC02 | Read Discrete Inputs | Discrete input — DI | | FC03 | Read Holding Registers | Analog / process data ← used here | | FC04 | Read Input Registers | Analog input (read-only device) | | FC06 | Write Single Register | Write one holding register | | FC16 | Write Multiple Registers | Write block of holding registers | ### Modbus Addressing Modbus register addresses are 16-bit (0–65535). There are two notations: Protocol address: 0-indexed (0x0000–0xFFFF) PLC/HMI address: 40001-based (add 40001) Example: Protocol 0x006B (107) → PLC address 40108 TSIMEREZIVO uses **0-indexed protocol addresses** in the connection wizard. ## Step 1 — Add Modbus TCP Connection in TSIMEREZIVO ### Step 1 — Open Connection Wizard Navigate to **Connections → New Connection**. Select protocol **Modbus TCP**. - **Host**: IP address of the flow meter (e.g. `192.168.1.50`) - **Port**: 502 (Modbus TCP standard — do not change unless device specifies otherwise) - **Unit ID**: 1 (or the device's configured slave address — check meter nameplate) - **Poll Interval**: 1000 ms (1 second — adequate for flow, minimum 500 ms per RULE-P3) - **Timeout**: 5000 ms ## Step 2 — Register Map Each flow meter model has a different register layout. Below are the registers for two common meters. Always verify against the device's Modbus communication manual. ### Endress+Hauser Promag (IEEE 754 Float, Big-Endian) FC03 · Holding Registers · Unit ID 1 | addr | plc | type | scale | egu | name | desc | |---|---|---|---|---|---|---| | 0x0000 | 40001–40002 | FLOAT32 BE | ×1 | m³/h | FT_101_RATE | Volumetric flow rate | | 0x0002 | 40003–40004 | FLOAT32 BE | ×1 | kg/h | FT_101_MASS | Mass flow rate | | 0x0004 | 40005–40006 | FLOAT32 BE | ×1 | kg/m³ | FT_101_DENS | Process fluid density | | 0x0006 | 40007–40008 | FLOAT32 BE | ×1 | °C | FT_101_TEMP | Process temperature | | 0x0008 | 40009–40010 | FLOAT32 BE | ×1 | m³ | FT_101_TOT | Positive totaliser | | 0x0010 | 40017 | UINT16 | bit mask | — | FT_101_STATUS | Device status word | ### Yokogawa ROTAMASS (INT16, ×0.1 scale factor) FC03 · Holding Registers · Unit ID configurable (default 1) | addr | type | scale | egu | name | desc | |---|---|---|---|---|---| | 0x0001 | INT16 | ÷10 | t/h | FT_101_RATE | Mass flow rate (signed, ×0.1 t/h per LSB) | | 0x0002 | INT16 | ÷10 | g/cm³ | FT_101_DENS | Density (×0.001 g/cm³ per LSB) | | 0x0003 | INT16 | ÷10 | °C | FT_101_TEMP | Temperature (×0.1 °C per LSB) | | 0x0010 | UINT32 | ÷1000 | t | FT_101_TOT_H | Totaliser high word | | 0x0011 | UINT32 | ÷1000 | t | FT_101_TOT_L | Totaliser low word | | 0x0020 | UINT16 | bits | — | FT_101_DIAG | Diagnostic register — bit 0: device fault | ## Step 3 — Engineering Unit Scaling Older analog flow meters output a 4–20 mA signal that is wired to an AI module and read as a raw 0–65535 count. Convert to engineering units using the linear scale formula: Linear scale — raw AI count to engineering value: ` EGU = (Raw − RawLo) × (EGU_Hi − EGU_Lo) / (RawHi − RawLo) + EGU_Lo ` **Standard 12-bit AI module** RawLo = 819 (4 mA), RawHi = 4095 (20 mA) EGU_Lo = 0.0 m³/h, EGU_Hi = 500.0 m³/h **Result for Raw = 2457** EGU = (2457 − 819) × 500.0 / (4095 − 819) + 0.0 = 249.8 m³/h ```st (* ============================================================ SCALE_AI — Scale raw AI count to engineering units Handles 4–20mA standard AI modules (12-bit or 16-bit) ============================================================ *) FUNCTION_BLOCK SCALE_AI VAR_INPUT Raw : REAL; (* Raw AI value from Modbus / AI module *) RawLo : REAL; (* Raw value at 4 mA (e.g. 819 for 12-bit) *) RawHi : REAL; (* Raw value at 20 mA (e.g. 4095 for 12-bit) *) EGU_Lo : REAL; (* Engineering value at 4 mA *) EGU_Hi : REAL; (* Engineering value at 20 mA *) Clamp : BOOL; (* TRUE: clamp output to [EGU_Lo, EGU_Hi] *) END_VAR VAR_OUTPUT Value : REAL; (* Scaled engineering value *) UnderRng : BOOL; (* Below 4 mA — sensor fault or open circuit *) OverRng : BOOL; (* Above 20 mA — sensor fault or overflow *) END_VAR VAR Span : REAL; END_VAR Span := RawHi - RawLo; IF ABS(Span) (RawHi + 50.0); (* Tolerance: 50 counts above 20mA *) IF Clamp THEN IF Value EGU_Hi THEN Value := EGU_Hi; END_IF; END_IF; END_FUNCTION_BLOCK ``` ## Step 4 — Totalisation Accumulator When the meter does not provide a hardware totaliser register (or you need a batch total that resets per shift/batch), implement a software totaliser in Structured Text. The totaliser integrates flow rate over scan time using the rectangle method. ```st (* ============================================================ FLOW_TOTALISER — Integrates flow rate to total volume Method: rectangle (Euler) integration over PLC scan time ============================================================ *) FUNCTION_BLOCK FLOW_TOTALISER VAR_INPUT FlowRate : REAL; (* Instantaneous flow — engineering units per hour *) ScanTime_ms : REAL; (* PLC scan time in milliseconds *) Reset : BOOL; (* Rising edge resets total to zero *) Enable : BOOL; (* TRUE: accumulate; FALSE: hold *) END_VAR VAR_OUTPUT Total : REAL; (* Accumulated total (same EGU, e.g. m³) *) TotalToday : REAL; (* Total since midnight reset *) Overflow : BOOL; (* TRUE: Total > 999999.9 — display wraps *) END_VAR VAR Reset_Prev : BOOL; ScanTime_h : REAL; (* Scan time converted to hours *) OVERFLOW_LIMIT : REAL := 999999.9; END_VAR (* Detect rising edge on Reset *) IF Reset AND (NOT Reset_Prev) THEN Total := 0.0; END_IF; Reset_Prev := Reset; (* Integrate: Volume = FlowRate (units/h) × time (h) *) ScanTime_h := ScanTime_ms / 3_600_000.0; IF Enable AND (NOT Reset) AND (FlowRate > 0.0) THEN Total := Total + (FlowRate * ScanTime_h); END_IF; (* Overflow guard *) IF Total > OVERFLOW_LIMIT THEN Total := 0.0; Overflow := TRUE; ELSE Overflow := FALSE; END_IF; END_FUNCTION_BLOCK ``` > **Scan Time in TSIMEREZIVO** — TSIMEREZIVO reads the PLC scan time from the controller diagnostic registers where available. For Modbus TCP devices, set `ScanTime_ms` to match your poll interval (e.g. 1000 for 1-second polling). The accumulator will have a maximum integration error of ±1 poll interval per reading. ## Step 5 — Alarm Setpoints Configure four-level alarming (HH/HI/LO/LL) for the flow tag in TSIMEREZIVO. Navigate to **Tags → FT_101_RATE → Edit → Alarms**. FT_101_RATE — Alarm Configuration (m³/h, full scale 500 m³/h) | level | value | priority | action | |---|---|---|---| | HH | 480 | Critical | Close inlet valve XV-101 automatically. Trigger shutdown permissive. | | HI | 450 | High | Operator alert. Check downstream restrictions. | | LO | 50 | High | Operator alert. Check inlet valve, pump running. | | LL | 20 | Critical | Low flow cutoff. Shutdown pump to prevent cavitation. | ```st (* ============================================================ FLOW_ALARM — 4-level alarm block with hysteresis deadband Prevents alarm chattering near setpoint boundaries ============================================================ *) FUNCTION_BLOCK FLOW_ALARM VAR_INPUT PV : REAL; (* Process variable — flow rate m³/h *) HH_SP : REAL; (* High-High setpoint — default 480.0 *) HI_SP : REAL; (* High setpoint — default 450.0 *) LO_SP : REAL; (* Low setpoint — default 50.0 *) LL_SP : REAL; (* Low-Low setpoint — default 20.0 *) Deadband : REAL; (* Hysteresis — default 2.0 (2 m³/h) *) Inhibit : BOOL; (* TRUE: suppress all alarms (e.g. during startup) *) END_VAR VAR_OUTPUT ALM_HH : BOOL; (* High-High alarm — critical *) ALM_HI : BOOL; (* High alarm *) ALM_LO : BOOL; (* Low alarm *) ALM_LL : BOOL; (* Low-Low alarm — critical *) ANY_ALARM : BOOL; (* OR of all four — for beacon/hooter *) END_VAR IF Inhibit THEN ALM_HH := FALSE; ALM_HI := FALSE; ALM_LO := FALSE; ALM_LL := FALSE; ANY_ALARM := FALSE; RETURN; END_IF; (* Hysteresis: alarm sets at SP, clears at SP ∓ Deadband *) IF PV >= HH_SP THEN ALM_HH := TRUE; END_IF; IF PV = HI_SP THEN ALM_HI := TRUE; END_IF; IF PV LO_SP + Deadband THEN ALM_LO := FALSE; END_IF; IF PV LL_SP + Deadband THEN ALM_LL := FALSE; END_IF; ANY_ALARM := ALM_HH OR ALM_HI OR ALM_LO OR ALM_LL; END_FUNCTION_BLOCK ``` ## Step 6 — TSIMEREZIVO Tag Configuration ### Step 6 — Create Tags in TSIMEREZIVO Tag Manager Navigate to **Tags → Import Tags → Manual Entry** and add the following: | tag | addr | dt | egu | desc | |---|---|---|---|---| | FT_101_RATE | 0x0000 | FLOAT32 | m³/h | Volumetric flow rate — E+H Promag | | FT_101_TOT | 0x0008 | FLOAT32 | m³ | Positive totaliser — hardware register | | FT_101_TOT_SW | — | REAL | m³ | Software totaliser (TSIMEREZIVO internal) | | FT_101_STATUS | 0x0010 | UINT16 | — | Device status word — bit 0: fault | | FT_101_ALM_HH | — | BOOL | — | High-High alarm (computed) | | FT_101_ALM_LL | — | BOOL | — | Low-Low alarm (computed) | ## Common Issues | problem | fix | |---|---| | TSIMEREZIVO shows Connection Timeout | Verify IP address, port 502, and that the meter is powered. Some meters require the Modbus TCP server to be enabled in device config. Ping the meter from the engineering PC first. | | Registers return 0x0000 for all values | Wrong Unit ID. Most flow meters default to Unit ID 1 — check nameplate or device configuration menu. Some Modbus TCP gateways use ID 255. | | Flow rate value appears 10× too high/low | Scale factor mismatch. Yokogawa INT16 registers require ÷10. Verify against the device communication manual. The SCALE_AI function block handles this via the RawLo/RawHi inputs. | | Totaliser resets unexpectedly | Hardware totaliser wraps at its counter limit. Use the software FLOW_TOTALISER block for batch/shift totals. Handle the Overflow output. | | ALM_HH fires immediately on startup | Flow tag may read 0.0 during Modbus handshake. Use the Inhibit input of FLOW_ALARM during startup — suppress alarms for the first 5 seconds after connection established. | ### Related Guides | href | label | desc | |---|---|---| | /dashboard/docs/live-connection | Live Connection | Connect any Modbus device to TSIMEREZIVO step by step | | /dashboard/docs/tag-import | Tag Import | Bulk import Modbus register maps via CSV | | /dashboard/docs/pid-control | PID Control | Use flow rate as process variable in a flow loop PID |

More like this

Rate, comment, and get full access

Members can download files, rate contributions, and discuss fixes with the engineers who posted them — free.

Join the library