Intelligent flow totalizer
By working together with multi-level data processing modules and detection units, and combining RS485 communication modules and Modbus RTU frame format, the problems of nonlinearity adaptability and data security of traditional flow totalizers under complex operating conditions are solved, achieving high-precision flow measurement and reliable data management.
Patent Information
- Application Number
- CN202511686827.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-18
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2045-11-18
AI Technical Summary
Traditional flow totalizers cannot adapt to the nonlinear characteristics of media such as gas and steam under complex operating conditions. They have large density calculation errors, lack dynamic models, have insufficient correction for mixed media, and are prone to tampering with trade settlement data. Furthermore, the lack of dynamic compensation for nonlinear errors affects the accuracy of totalization.
The system employs a multi-level data processing module, detection unit, and intelligent totalization module working in tandem. Through auxiliary and main channels designed with Y-shaped or S-shaped flow paths, combined with microscale oscillation cavities and PZT elements, it achieves dynamic compensation and flow inversion. Data transmission and management are carried out using RS485 communication modules and Modbus RTU frame format to ensure data security.
It improves the accuracy and stability of flow measurement, realizes high-precision flow metering and reliable data management, and is suitable for high-value fluid trade settlement and remote monitoring of offshore platforms in complex industrial environments.
Smart Images

Figure CN121140895B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of instrumentation technology, specifically to an intelligent flow totalizer. Background Technology
[0002] Traditional flow totalizers currently have the following shortcomings under complex operating conditions:
[0003] 1. The compensation method is limited to single-parameter compensation of temperature or pressure, which cannot adapt to the nonlinear characteristics of media such as gases and steam, resulting in large density calculation errors; 2. There is a lack of dynamic models for density correction of mixed media such as multi-component gases and gas-liquid two-phase flows, relying on empirical formulas, which limits accuracy; 3. Trade settlement data is easily tampered with, and key parameter configurations such as media type and compensation mode lack access control; 4. Insufficient nonlinear error correction: the inherent nonlinear errors of flow meters such as differential pressure and velocity flow meters are not dynamically compensated, affecting the accuracy of integration.
[0004] To address the aforementioned issues, this invention proposes an intelligent flow totalizer that integrates software and hardware dynamic calibration and verification, enabling high-precision flow measurement and reliable data management. Summary of the Invention
[0005] The purpose of this invention is to overcome the shortcomings of the prior art and provide an intelligent flow totalizer. This flow totalizer solves the technical problems in the background art through the collaborative efforts of multi-level data processing modules, detection unit totalizer and intelligent totalizer module.
[0006] An intelligent flow totalizer includes a main control module, which comprises a security module and a trade settlement management module. Specifically, the main control module further includes an intelligent totalizing module, a dynamic compensation module, and a detection unit. The main control module connects a main channel and an auxiliary channel. The intelligent totalizing module receives signals from the main channel and performs dynamic compensation to total instantaneous and cumulative flow. The detection unit receives signals from the auxiliary channel and performs instantaneous flow totalizing. Specifically, the fluid flow paths of the auxiliary channel and the main channel adopt a Y-shaped symmetrical design or an S-shaped parallel design.
[0007] The auxiliary channel is equipped with a microscale oscillation cavity and a piezoelectric excitation unit on the fluid flow path. PZT elements are attached to both sides of the microscale oscillation cavity. The piezoelectric excitation unit applies a high-frequency sinusoidal voltage to the microscale oscillation cavity to drive the cavity wall to vibrate, causing the PZT elements to generate reverse charge. The detection unit senses the change in reverse charge and inversely calculates the instantaneous flow rate.
[0008] The main control module and the flow meter communicate via an RS485 communication module. The RS485 communication module uses Modbus RTU frame format to assign a unique ID to each flow meter. The Modbus register is segmented according to the ID to read and write the parameters of each flow meter separately.
[0009] The main channel connects to the sensors of each flow meter. The main control module is configured with multiple timer channels to receive the signal output of each flow meter. It constructs a Modbus instruction frame containing the device ID in memory and sends the frame data one by one to the RS485 bus. After receiving the bus data, the flow meter matches the device ID, parses the register ID in the Modbus register, packs it into a response frame, and returns it to the main control module. After receiving the response frame, the main control module parses out the instantaneous flow value and the cumulative flow data.
[0010] Furthermore, the RS485 communication module includes a receive interrupt service. After interrupting data reception via the UART interface, the receive interrupt service configures the RS485 to receive mode, stores the interrupted data in the receive buffer, and records the length. The main control module has an EEPROM module with a Modbus register backup area; data from the receive buffer is backed up to the EEPROM module. The Modbus register includes a coil, discrete input, holding register, and input register. For instantaneous flow, the holding register is readable and writable; for cumulative flow, the input register is read-only. The main control module uses function code encapsulation functions to assemble instruction frames from commonly used Modbus function codes.
[0011] Furthermore, the detection unit includes the following modules:
[0012] a1 Charge-to-Voltage Conversion Module: The charge-to-voltage conversion module includes a charge amplifier, which is connected to a feedback capacitor and a feedback resistor to convert the charge signal output by the PZT element into a processable voltage signal;
[0013] A2 Lock-in Amplification Module: The lock-in amplification module includes a signal extraction unit, a digital processing unit, and a noise suppression unit. The signal extraction unit extracts a sinusoidal driving signal from the piezoelectric excitation source as a reference signal and locks its frequency and phase through a phase-locked loop to eliminate phase jitter between the excitation source and the detection path. The converted voltage signal is sampled by the ADC and then enters the digital processing unit for quadrature demodulation: the voltage signal is multiplied by the cosine and sine components of the reference signal to obtain the in-phase channel signal I and the quadrature channel signal Q. Each signal is then passed through a low-pass filter to filter out high-frequency components and retain only the DC component. The amplitude A is calculated from I and Q. and phase difference The noise suppression unit employs wavelet basis to perform multi-level decomposition of the filtered signal, performs hard thresholding on the high-frequency noise figure, preserves effective signal characteristics, and obtains accurate A and B values highly correlated with the fluid state. ;
[0014] a3 Parameter Decoupling and Flow Inversion Module: The parameter decoupling module extracts A, Converted to amplitude attenuation Phase shift , , , The baseline value is set for a zero-flow or zero-point condition, and an automatic fluid shutdown update is performed every 24 hours. , Zero-point calibration; the flow inversion module uses a model to invert the flow rate at different stages according to different flow velocity ranges, including the medium-to-high flow velocity range: Low flow velocity region: , The cavity structure constant is... Viscosity, The density is then calculated, and the instantaneous flow rate is output using a 4-20mA analog signal and an RS485 digital signal.
[0015] Furthermore, the detection unit and the intelligent totalization module verify each other. The original value output by the detection unit and the accurate value output by the intelligent totalization module satisfy the condition that the original value × the interval compensation coefficient ≈ the accurate value. The main control module compares the two sets of values in real time. If the deviation is within the preset threshold, the data is determined to be valid. If the deviation exceeds the threshold, the security module alarm is triggered, and the trade settlement data is locked to avoid incorrect measurement.
[0016] Furthermore, the main control module includes a main program and subroutine execution. The main control module includes a backup battery and a clock system. The backup battery powers the RTC clock system, Modbus register backup, and subroutine execution. When the main program detects an external signal interruption, it packages the data into the subroutine execution in the form of serialized data frames. The data of the subroutine execution is saved to the Modbus register backup area. Before the main program restarts, it reads the running parameters from the Modbus register backup area.
[0017] Furthermore, the RTC clock system includes an internal crystal oscillator and an external crystal oscillator. The external crystal oscillator includes a low-speed crystal oscillator circuit and a high-speed crystal oscillator circuit. The low-speed crystal oscillator circuit provides a clock signal to the RTC clock system module, and the high-speed crystal oscillator circuit improves the operating efficiency of the main control module.
[0018] Furthermore, the main control module includes a program data storage module, a static data storage module, and a peripheral FLASH data storage module. Each module's data has a fixed mapped address range within the main control module. The peripheral FLASH data storage module stores the original data of external devices. The static data storage module extends external memory via FSMC. The peripheral FLASH data storage is mapped to the unified address space of the main control module after being connected via FSMC. The main control module includes a BOOT circuit and a reset circuit. When the main control module powers on and resets, it detects the level state of the BOOT circuit and reads the program's start ID from the corresponding data storage area.
[0019] Furthermore, the peripheral FLASH data storage module communicates synchronously with the main control module via an SPI interface. This synchronous serial communication includes an SCK clock signal, an NSS chip select signal, and a MOSI / MISO transmission signal. The SCK clock signal is generated by the main control module, and the external device synchronously follows the clock signal to ensure the timing consistency of data transmission. The MOSI / MISO signal is responsible for bidirectional data transmission between the main control module and the external device, with MOSI from main to external and MISO from external to main. The NSS chip select signal is controlled by the main control module to select the external device currently being communicated. The main control module reads the sensor data from the external device via the SPI interface and sends this data to the flow meter for dynamic compensation calculation.
[0020] Furthermore, the dynamic compensation calculation includes temperature compensation, pressure compensation, density compensation, temperature-pressure compensation, natural gas compressibility coefficient compensation, and flow coefficient nonlinearity compensation. The detection unit and intelligent totalization module verify the results and then optimize the dynamic compensation coefficients. The intelligent totalization module finally outputs dynamically compensated, accurate flow data, which is then encrypted, stored, and sent to the trade settlement management module. The trade settlement management module ensures the integrity and tamper-proof nature of the flow data during internal storage and external communication through encrypted data transmission.
[0021] Furthermore, the security module is connected to the interface on the main control module to implement dual password verification for key operations, including: flow meter type selection, signal type setting, media parameter configuration, compensation mode switching, and trade settlement data export.
[0022] Furthermore, the power module includes a voltage regulator circuit and an input switching circuit. The voltage regulator circuit stably outputs 3.3V from the input voltage to power the main control module. The input switching circuit has a 2-pin header. When only USB is connected, a jumper cap can be used to determine whether to use USB VBUS power supply.
[0023] Furthermore, the UART baud rate of the main control module is consistent with the communication baud rate of the RS485 communication module, which can be selected from 1200 to 9600 bps. The data format of the RS485 communication module adopts hexadecimal, and for data with a large range, floating-point representation in IEEE-754 standard 32-bit data format is used.
[0024] Furthermore, based on the channel, a main channel energy-saving mode, a main-auxiliary dual-channel fusion mode, and an auxiliary channel diagnostic mode can be designed; when an excessive deviation is detected, it automatically switches to the auxiliary channel diagnostic mode.
[0025] Furthermore, the main channel supports multiple flow sensor signals, can receive frequency signals and multiple analog current signals, and the pulse input supports a frequency range of 0-10KHz, and can process rectangular, sine or triangular waves; the intelligent totalization module has built-in standard formulas to support the totalization and control of flow and heat of various liquids, single or mixed gases and steam; the detection unit has built-in a general theoretical framework and typical formulas for piezoelectric vibration detection, including amplitude shift, phase shift and frequency shift.
[0026] The beneficial effects of this invention are:
[0027] 1. This intelligent flow totalizer improves the accuracy and stability of flow measurement through two distinct processes: flow inversion calculation by the detection unit and segmented totalization by the intelligent module. The flow inversion calculation by the detection unit, which assists in acquiring flow information at the hardware level, and the segmented totalization by the intelligent module, further process and optimize the acquired data through intelligent compensation calculations to obtain more accurate flow measurement results. The results of both processes can be mutually verified, together forming a precise intelligent flow totalizer system.
[0028] 2. The unified address space of the main control module of the intelligent flow totalizer is mapped to the Modbus register address of RS485. At the same time, the mapping relationship and the running status are backed up and saved. When the main control module loses power and restarts, the communication with external devices is quickly re-established by loading the mapping table and restoring the status, thereby realizing normal operation after power failure and restart.
[0029] 3. The microcavity vibration sensing technology and subroutine operation mode of this intelligent flow totalizer are particularly suitable for high-value fluid trade settlement and remote monitoring of offshore platforms in complex industrial environments. Attached Figure Description
[0030] Figure 1 This is a general block diagram of the present invention;
[0031] Figure 2 This is a schematic diagram of the fluid channel of the present invention;
[0032] Figure 3This is a flowchart of the detection unit of the present invention;
[0033] Figure 4 This is the charge-voltage conversion diagram of the present invention;
[0034] Figure 5 This is a diagram of the main control module of the present invention;
[0035] Figure 6 These are diagrams of the crystal oscillator module and power supply module of the present invention;
[0036] Figure 7 This is a diagram of the data storage module of the present invention;
[0037] Figure 8 This is the SPI interface diagram of the present invention;
[0038] Figure 9 This is a schematic diagram of the MODBUS frame format of the present invention;
[0039] Figure 10 This is the terminal wiring diagram of the present invention. Detailed Implementation
[0040] The present invention will now be described in further detail with reference to the accompanying drawings. It should be noted that this description is only for clearer illustration and explanation. The description in this section is exemplary and explanatory in nature and should not be construed as limiting the scope of protection of the invention.
[0041] An intelligent flow totalizer is disclosed. Its main control module utilizes a smart microcontroller, which integrates a temperature sensor, a VBAT monitoring channel, and an ADC analog-to-digital converter. It supports an ultra-high sampling rate of 5Msps and multi-channel synchronous sampling, meeting the analog signal acquisition requirements of current, voltage, and temperature sensor signals. It is particularly suitable for scenarios with multiple flow meters connected in parallel. Furthermore, the flow totalization standard formulas and standardized models ISO5167, AGA3, and IAPWS-IF97 are embedded in the intelligent totalizer module through C language programming. The detection unit's inversion formula supports instantaneous flow inversion calculation according to industry standards, including: ISO11631 standardization of amplitude-flow relationship for vibrating flow meters; IEC62884-2:2017 measurement techniques for piezoelectric, piezoelectric and electrostatic oscillators—part 2: methods for measuring phase jitter; and OIMLR137 multi-parameter compensation requirements for gas flow meters.
[0042] like Figure 1The overall block diagram shown indicates that the main control module has multiple pins and interfaces. The main control module has a CRYP security module to encrypt data transmitted through various interfaces. The main control module includes a main channel and an auxiliary channel. An intelligent totalizer module on the main control module receives dynamic compensation data from the main channel and performs instantaneous flow totalization and cumulative flow totalization. A detection unit on the main control module receives piezoelectric excitation signals from the auxiliary channel and performs instantaneous flow totalization.
[0043] The detection unit and the intelligent totalization module verify each other. The raw value output by the detection unit and the accurate value output by the intelligent totalization module satisfy the condition that the raw value × the interval compensation coefficient ≈ the accurate value. The main control module compares the two sets of values in real time. If the deviation is within the preset threshold, the data is deemed valid. If the deviation exceeds the threshold, the security module alarm is triggered, and the trade settlement data is locked to avoid incorrect measurement.
[0044] like Figure 2 As shown, the fluid flow channels of the auxiliary channel (A1) and the main channel (A2) adopt a Y-shaped symmetrical design. The acquisition point (A21) of the main channel (A2) and the microscale oscillation cavity (A11) of the auxiliary channel (A1) are designed at the furthest point of the symmetrical Y-shaped intersection. An elastic sealing ring can also be designed at the Y-shaped intersection of the auxiliary channel (A1) to reduce vibration transmission to the main channel (A2). The flow input to the main channel (A2) can receive frequency signals and various analog current signals. The auxiliary channel (A1) and the main channel (A2) can also adopt an S-shaped parallel design, with a continuous bend design between the main channel (A2) and the auxiliary channel (A1) to lengthen the distance and reduce signal interference. A piezoelectric excitation unit (A12) is located on the microscale oscillation cavity (A11) of the auxiliary channel (A1). PZT elements (A13) are attached to both sides of the microscale oscillation cavity (A11). The piezoelectric excitation unit (A12) applies a high-frequency sinusoidal voltage to the microscale oscillation cavity (A11) to drive the cavity wall to vibrate, causing the PZT elements (A13) to generate a reverse charge. The detection unit senses the change in reverse charge and performs charge amplification, signal extraction, ADC sampling, wavelet denoising, lock-in amplification, and extraction of A and B. The process of traffic inversion accumulates traffic.
[0045] like Figure 3 As shown, the detection unit includes the following modules:
[0046] A1 Charge-to-Voltage Conversion Module: The charge-to-voltage conversion module includes a charge amplifier. The charge amplifier is connected to a feedback capacitor and a high-resistance feedback resistor to form a high-pass filter, converting the charge signal output by the PZT element into a processable voltage signal. Specifically... Figure 4 Add two filter capacitors C1, C2, C3, and C4 after the power supply pin shown, R1 is the input resistor, R2 reduces output noise, R3 is the balancing resistor, and Rw is the zero potential to make the output voltage 0.
[0047] A2 Lock-in Amplifier Module: The lock-in amplifier module includes a signal extraction unit, a digital processing unit, and a noise suppression unit. The signal extraction unit extracts a sinusoidal drive signal from the piezoelectric excitation source as a reference signal and locks its frequency and phase using a phase-locked loop (PLL) to eliminate phase jitter between the excitation source and the detection path. The converted voltage signal is sampled by the ADC and then enters the digital processing unit. The digital processing unit performs quadrature demodulation, multiplying the voltage signal by the cosine and sine components of the reference signal to obtain the in-phase channel signal I and the quadrature channel signal Q. Each signal is then passed through a low-pass filter to remove high-frequency components, retaining only the DC component. Simultaneously, I and Q are calculated to obtain the amplitude A. and phase difference The noise suppression unit uses the Daubechies9 wavelet basis to perform multi-level decomposition on the filtered signal, performs hard thresholding on the high-frequency noise figure, preserves effective signal characteristics, and obtains accurate A and B values that are highly correlated with the fluid state. ;
[0048] a3 Parameter Decoupling and Flow Inversion Module: The parameter decoupling module extracts A, Converted to amplitude attenuation Phase shift The flow inversion module uses a fluid dynamics model to invert the flow rate at different stages based on different flow velocity ranges, specifically in the medium-to-high flow velocity range: Low flow velocity region: , The cavity structure constant is... Viscosity, The density is then calculated, and the final flow rate is output using a 4-20mA analog signal and an RS485 digital signal.
[0049] like Figure 5 The main control module diagram shown includes the Code bus for data program access, the ABH system bus for access to the clock system, reset circuit, and peripherals, the DMA line for channel access, and the DMA line bridged with the ABH system bus. UART2, mounted on APB1, is used for Modbus communication and can receive data via the DMA1 channel, reducing the CPU load. UART1, mounted on APB2, is used for external charge signals and can quickly read data via the DMA2 channel, enabling large-capacity caching with an external SD card on the AHB bus. The DMA1 channel also simultaneously connects to peripherals such as I2C and SPI, and the ABH system bus accesses these peripherals through the DMA1 channel. The Code bus, ABH system bus, and DMA line are then connected to the main control CPU via a bus matrix.
[0050] like Figure 1 and 6As shown, the core hardware components of the main control module include power supply circuit, reset circuit, BOOT circuit, crystal oscillator circuit, and other module designs. Details are as follows:
[0051] Crystal oscillator circuit: The external crystal oscillator for the RTC clock system uses an LSE low-speed 32.768kHz crystal oscillator as the RTC clock source, and an HSE high-speed crystal oscillator to ensure system timing and calculation accuracy. The low-speed crystal oscillator is connected to the PC14 / OSC32_IN and PC15 / OSC32_OUT pins of the main control microcontroller chip. The high-speed crystal oscillator is connected to the PH0 / OSC_IN and PH1 / OSC_OUT pins of the main control microcontroller chip.
[0052] Backup battery circuit: When the device loses power, the main control module and RTC clock will stop. Therefore, a backup battery circuit is designed and connected to the VBAT pin of the main control module to support the RTC clock and the continued operation of the main control module in the event of a power failure.
[0053] BOOT Circuit: When the main control module powers on or resets, it first detects the level state of the BOOT circuit and then reads the program's start ID from the corresponding storage area. The BOOT circuit is designed with different startup modes for BOOT0 and BOOT1. When BOOT0 is set to low, the program's start ID is started from the main control module's FLASH; when BOOT0 is set to high and BOOT1 is set to low, the program's start ID is started from system memory; when both BOOT0 and BOOT1 are set to high, the program's start ID is started from external memory such as SRAM or external SPI FLASH / EEPROM modules. During normal operation, the main program of the flow totalizer is started from the internal FLASH; during program upgrades, BOOT0 is manually set to high and BOOT1 is set to 0, and after reset, the main program of the flow totalizer is started from system memory.
[0054] Reset Circuit: An external reset circuit is designed on the NRST pin. Pressing it once in case of a fault will restart the system. After reset, the main control module will initialize the main CPU core and Modbus registers, returning them to their initial state. Low-Power Reset: The main program of the main control module can switch to a subroutine (power-down or low-power mode). If a power failure triggers a reset during subroutine execution, the main control module will re-detect the BOOT pin level. The current level of BOOT0 / BOOT1 at the moment of reset determines the startup mode of the main program.
[0055] Power supply circuit: An AMS1117-3.3 linear regulator is used. A 10μF electrolytic capacitor is designed at the regulator input to filter out high-frequency noise in the input voltage and avoid affecting the stability of the regulator. A 100nF ceramic capacitor is designed at the output to suppress the output voltage ripple and ensure the purity of the 3.3V power supply.
[0056] like Figure 1 and 7 As shown in Figure 8, the main control module is also connected to an EEPROM module and multiple peripheral storage modules to expand memory space and ensure efficient operation of the device. EEPROM is a type of memory that does not lose data after power failure. Therefore, this module can run after the main control module loses power. The EEPROM has a Modbus register backup area. After the main program loses power, the data of the subroutine is saved to the Modbus register backup area. Before the main program restarts, it reads the running parameters of the Modbus register in the backup area. The EEPROM module uses the AT24C02C-SSHM-T chip and transmits data via the I2C bus protocol. The serial data line SDA and the serial clock line SCL correspond to the PB9 and PB8 pins on the main control module MCU, respectively.
[0057] The main control module includes categorized data storage spaces, classifying data into program data storage, static data storage, and peripheral FLASH data storage modules. Each module's data has a fixed mapped address range within the main control module; the program and static data storage modules are built-in. However, in addition to retrieving built-in parameters and programs, the intelligent integrator also needs external environmental sensor data, flow meter data, etc., during operation. The main control module's serial peripheral interface (SPI) allows for half-duplex synchronous serial communication with external devices. Therefore, a peripheral FLASH data storage module was designed to store the raw data from external devices.
[0058] SPI Interface: The main control module reads raw data from external devices such as temperature, humidity, pressure, air pressure, and infrared sensors through the SPI interface. It also works with external FLASH memory to store this raw data, which is then used by an intelligent flow totalizer for dynamic compensation calculations. For example... Figure 8 The synchronous serial communication lines shown are the SCK clock signal line, the NSS chip select signal line, and the MOSI / MISO line. The SCK clock signal is generated by the master control module, and external devices synchronously follow the clock signal to ensure the timing consistency of data transmission. The MOSI / MISO line is responsible for bidirectional data transmission between the master control module and external devices, with MOSI from master to external and MISO from external to master. The NSS chip select signal is controlled by the master control module to select the external device currently in communication. SPI can connect to one or multiple external devices, in which case the NSS chip select signal is needed to control which external device is in communication mode.
[0059] SDIO Interface: Intelligent flow totalizers with trade settlement functions need to retain at least 365 days of daily cumulative values and 12 months of monthly cumulative values. High-capacity SD cards are the preferred choice. Assuming one record per day and 100 bytes per record, only about 36KB is needed for 365 days, about 12KB for 12 months, and less than 500KB for 10 years. Therefore, data is not lost after power failure, meeting the requirements for tamper-proof and long-term preservation of trade settlement data. Adding an SDIO interface to the main control module enables powerful storage capabilities: 5 years of daily records, 5 years of monthly records, 16 years of annual records, and 200,000 timed records.
[0060] The SDIO interface circuit design incorporates a 47kΩ pull-up resistor and a 100nF ceramic filter capacitor. The pull-up resistor stabilizes the idle levels of the SDIO data and command lines, suppressing noise interference. The ceramic filter capacitor filters out high-frequency power supply noise, ensuring stable power supply to the SD card. In industrial environments, this effectively enhances anti-interference capabilities.
[0061] FSMC Interface: The totalization of intelligent flow meters requires built-in formula algorithms in the main control module, such as flow compensation formulas, cumulative flow calculations, instantaneous flow calculations, and tools like built-in density-temperature lookup tables and pressure correction tables. Interpolation lookups commonly used in flow totalization require storing a large amount of discrete data. If the algorithm requires frequent table lookups during operation, it will cause the MCU to crash and restart repeatedly. Therefore, it is necessary to expand the SRAM running memory to cache temporary calculation data, indirectly supporting the efficient operation of the totalization algorithm. The static data storage module SRAM is extended to external memory through FSMC, and peripheral FLASH data storage is mapped to the unified address space of the main control module after being connected through FSMC. This mapping allows the main control module to read and write through a unified address without distinguishing between internal and external storage, simplifying software design. This allows the main program of the main control module to start the program from external storage and directly read data upon restart, balancing program scalability and data continuity.
[0062] For example, in the interpolation lookup table of a flow totalizer, if the table data exceeds the internal RAM capacity, it can be stored in external SRAM and quickly read during runtime via FSMC. If 1000 instantaneous flow points are collected per second, the data volume for one minute is 240KB, exceeding the internal limit. This data can be temporarily stored in external SRAM for batch processing or written to an SD card via the SDIO interface. If the intermediate variables in the iterative calculation of the flow compensation algorithm require a large array cache, causing insufficient internal RAM, it can be allocated to external SRAM. In this solution, the IS62WV51216BLL was selected as the external expansion SRAM, which was soldered to the bottom of the PCB board and connected to the top layer through multiple vias to enhance anti-interference capabilities.
[0063] RS485 Communication Module: The main control module and the flowmeters communicate via an RS485 communication module. The RS485 module uses Modbus RTU frame format to assign a unique ID to each flowmeter. Modbus registers are segmented and mapped according to ID for individual reading and writing of flowmeter parameters. The UART baud rate of the main control module is consistent with the communication baud rate of the RS485 communication module, selectable at 1200, 2400, 4800, or 9600 bps. The data transmission format is 1 start bit, 8 data bits, 1 stop bit, and no parity bit. The instrument data format is floating-point numbers using IEEE-754 format, byte order: 3-4-1-2, low byte first. Instrument communication frame format: DE: Device address (1-254) single byte, hexadecimal; CRC: Check byte using CRC-16 cyclic redundancy check.
[0064] The data format is hexadecimal. For data with a large range, floating-point representation in the IEEE-754 standard 32-bit data format is used.
[0065] Modbus RTU is divided into a master module and a slave (flowmeter) module at the protocol layer. These modules implement core functions such as frame parsing, function code processing, and CRC checksums. The slave (flowmeter) module uses four register models according to the Modbus specification: Coil: Read / Write, bit operation 0x01 for function code read, 0x05 / 0x0F for function code write. Discrete Input: Read-only, bit operation 0x02 for function code read. Holding Register: Read / Write, stores instantaneous flow rate, 16-bit operation 0x03 for function code read, 0x06 / 0x10 for function code write. Input Register: Read-only, stores cumulative flow rate, 16-bit operation 0x04 for function code read.
[0066] The main control module uses function code encapsulation functions to assemble instruction frames from commonly used Modbus function codes, as detailed below:
[0067] The host module (mbhost) functions include: MB_ReadCoil_01H() encapsulates the instruction to read the coil (0x01); MB_WriteHoldingReg_06H() encapsulates the instruction to write to a single holding register (0x06); MB_CRC16() calculates the CRC16 checksum of the data frame; WaitTimeOut() waits for the slave (flowmeter) response function, and if a timeout occurs, communication is considered a failure; MB_ReadHoldingReg_03H() encapsulates the input register instruction; the MB_RSP_03H() subroutine; and the data packing buffer: MB_TX_BUF.
[0068] Slave module (mbslave) functions: MB_Parse_Data() encapsulates the parsing of frames sent by the master from the receive buffer, MB_Analyze_Execute() verifies the validity of the command, MB_RSP() is a general response frame generation function, MB_Exception_RSP() is an exception response frame generation function, and the receive buffer is RS485_RX_BUF.
[0069] The slave (flow meter) module passively receives commands from the master control module, parses them, and returns a response frame. The slave (flow meter) parsing process is as follows:
[0070] S1 data frame parsing: MB_Parse_Data() extracts key information such as slave (flow meter) address, function code, register address, and data length from the receive buffer.
[0071] S2 instruction verification: MB_Analyze_Execute() verifies the validity of the function code, the register address range, and the data length to ensure they conform to the protocol specifications. If any exception is found, the corresponding exception code is returned.
[0072] S3 Response Generation: MB_RSP() calls the corresponding processing function such as MB_RSP_03H() based on the function code to process the reading holding register, assemble the response frame and attach CRC check.
[0073] S4 Exception Response: MB_Exception_RSP() generates an exception frame when an instruction is invalid.
[0074] The communication process between the master control module and the slave (flow meter) module is as follows:
[0075] The S1 master control module sends the following: It calls MB_ReadHoldingReg_03H() to assemble a frame: [Slave (flowmeter) address, 0x03, high 8 bits of start address, low 8 bits of start address, high 8 bits of quantity, low 8 bits of quantity, CRC low, CRC high]. The frame is then sent via RS485_Send_Data(), switching RS-485 to transmit mode.
[0076] S2 Slave (Flow Meter) Receive and Parse: The slave (flow meter) receives frames via UART interrupt and stores them in the RS485_RX_BUF receive interrupt service area. MB_Parse_Data() parses the frame, extracting the function code (0x03), starting address, and register count. MB_Analyze_Execute() verifies the validity of the address and count to ensure they do not exceed the register range.
[0077] S3 slave (flowmeter) response: If valid, MB_RSP_03H() reads data from the holding register and assembles a response frame: [slave (flowmeter) address, 0x03, number of data bytes, high 8 bits of register value 1, low 8 bits of register value 1, ..., CRC]. If invalid, MB_Exception_RSP() returns an exception frame.
[0078] S4 main control module receives: The main control module waits for a response via WaitTimeOut(), verifies the CRC after receiving the data, parses the data, and outputs the instantaneous flow value and cumulative flow data.
[0079] In the above process, after the receive interrupt service interrupts data reception via the hardware UART interface, it configures the RS485 to receive mode, stores the interrupted data in the receive buffer RS485_RX_BUF, and records the length. The data in the receive buffer can be directly backed up to the EEPROM module and read directly after the main control module is powered on again. When the main program detects an external signal interrupt, it packages the data into a serialized data frame and executes it in a subroutine. (Reference) Figure 9 The MODBUS protocol frame format and parsing example: The main program serializes data into a data frame conforming to the Modbus holding register (function code 0x03) interaction specification according to the following logic:
[0080] Assuming that after an external signal interruption such as a sensor or flow pulse trigger is triggered, the main program reads the real-time data of the corresponding sensor or module and maps it to the preset holding register address (40001~40031): for example, if the flow sensor is interrupted, it reads the instantaneous flow value, corresponding to registers 40001-40002; if the temperature sensor is interrupted, it reads the temperature value, corresponding to registers 40009-40010.
[0081] The main program converts data such as instantaneous flow rate of 123.45 m³ / h and temperature of 25.3℃ into register storage format. The 32-bit parameter is split into two 16-bit registers, keeping the most significant bit first and the least significant bit last. The numerical amplification factor is fixed: the temperature of 25.3℃ is amplified to 2530, and stored as an integer for easy representation in the 16-bit registers.
[0082] After data format conversion, the data is packaged according to the Modbus response frame structure, including the following key fields:
[0083] Slave (flow meter) address (DE): Fixed to device address 0x01;
[0084] Function code: Fixed at 0x03, read holding register;
[0085] Byte count: Number of registers read × 2 is equivalent to 1 register = 2 bytes;
[0086] Register data: 16-bit data arranged in address order: 40001 data first, 40002 data last;
[0087] CRC check: The checksum of the frame is calculated using MB_CRC16() and appended to the end of the frame. The serialized data frame is now assembled.
[0088] The assembled fields are concatenated in sequence into a continuous byte array. For example, when reading the instantaneous flow 40001-40002, the data frame byte stream is [DE, 0x03, 0x04, register 1 high bit, register 1 low bit, register 2 high bit, register 2 low bit, CRC low, CRC high].
[0089] The serialized byte stream is passed to the subroutine MB_RSP_03H() through buffers MB_TX_BUF and RS485_RX_BUF.
[0090] like Figure 10 The wiring diagram for the input / output terminals of the intelligent flow totalizer is as follows: 1. Flow current input; 8. Pressure current input; 2 and 3 are RS-485 (A); 9 and 10 are RS-485 (B), corresponding to DMA1 and DMA2 lines on the main control module. 5, 6, and 7 are Pt100 inputs; 4 and 11 are analog voltage outputs; 12 and 14 are common ground; 13 is flow pulse input; 15 is temperature current input; 16 is empty (spare); 17 and 18 are battery; 19 is ground; 20 is neutral; 21 is live; 22 and 23 are current outputs; 25 and 26 are pulse outputs; 27, 28, and 29 are alarm channels.
[0091] The above are merely preferred embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. An intelligent flow totalizer, comprising a main control module, wherein the main control module and the flow meter communicate via an RS485 communication module, characterized in that: The main control module includes an intelligent accumulation module, a dynamic compensation module, and a detection unit. The main control module connects the main channel and the auxiliary channel. The intelligent totalization module receives the main channel signal and performs dynamic compensation to accumulate instantaneous flow and cumulative flow. The detection unit receives the auxiliary channel signal and performs instantaneous flow accumulation. The detection unit and the intelligent totalization module verify each other. The main control module compares the two sets of values in real time. If the deviation exceeds the threshold, the security module alarm is triggered, and the trade settlement data is locked. The auxiliary channel and the main channel adopt a Y-shaped symmetrical design or an S-shaped parallel design for fluid flow. The auxiliary channel has a microscale oscillation cavity and a piezoelectric excitation unit. PZT elements are attached to both sides of the microscale oscillation cavity. The piezoelectric excitation unit applies a high-frequency sinusoidal voltage to the microscale oscillation cavity to drive the cavity wall to vibrate, causing the PZT elements to generate reverse charge. The detection unit senses the change in reverse charge and inversely calculates the instantaneous flow rate. The RS485 communication module is equipped with a receive interrupt service, which stores the data after the interruption in the receive buffer and records the length. The main control module has an EEPROM module, which has a Modbus register backup area. The data in the receive buffer is backed up to the EEPROM module. The main control module includes a main program and subroutines. When the main program detects an external signal interruption, it packages the data into a serialized data frame and runs it into the subroutines. The data of the subroutines is saved to the Modbus register backup area. Before the main program restarts, it reads the running parameters from the Modbus register backup area. The detection unit includes the following modules: a1 Charge-to-Voltage Conversion Module: The charge-to-voltage conversion module includes a charge amplifier, which is connected to a feedback capacitor and a feedback resistor to convert the charge signal output by the PZT element into a processable voltage signal; A2 Lock-in Amplification Module: The lock-in amplification module includes a signal extraction unit, a digital processing unit, and a noise suppression unit. The signal extraction unit extracts a sinusoidal driving signal from the piezoelectric excitation source as a reference signal and locks its frequency and phase through a phase-locked loop to eliminate phase jitter between the excitation source and the detection path. The converted voltage signal enters the digital processing unit after ADC sampling, where quadrature demodulation is performed. The voltage signal is multiplied by the cosine and sine components of the reference signal to obtain the in-phase channel signal I and the quadrature channel signal Q. Each signal is then passed through a low-pass filter to remove high-frequency components and retain only the DC component. The amplitude A is calculated from I and Q. and phase difference ; The noise suppression unit employs wavelet basis to perform multi-level decomposition of the filtered signal, performs hard thresholding on the high-frequency noise figure, preserves effective signal characteristics, and obtains accurate A and B values highly correlated with the fluid state. ; a3 Parameter Decoupling and Flow Inversion Module: The parameter decoupling module extracts A, Converted to amplitude attenuation Phase shift , , , The baseline value is set for a zero-flow or zero-point condition, and an automatic fluid shutdown update is performed every 24 hours. , Zero-point calibration; the flow inversion module uses a model to invert the flow rate at different stages according to different flow velocity ranges, including the medium-to-high flow velocity range: Low flow velocity region: , The cavity structure constant is... Viscosity, The density is then calculated, and the instantaneous flow rate is output using a 4-20mA analog signal or an RS485 digital signal.
2. The intelligent flow totalizer according to claim 1, characterized in that: The RS485 communication module uses the Modbus RTU frame format to assign a unique ID to each flow meter. The Modbus register is segmented and mapped according to the ID to read and write the parameters of each flow meter separately. The main channel connects to the sensors of each flow meter. The main control module is configured with multiple timer channels to receive the signal output of each flow meter and construct a Modbus command frame containing the device ID. The flow meter matches the device ID, parses it in the Modbus register, and packages it into a response frame to be returned to the main control module. After receiving the response frame, the intelligent totalization module parses out the instantaneous flow value and the cumulative flow data.
3. The intelligent flow totalizer according to claim 2, characterized in that: The Modbus register includes a coil, discrete input, holding register, and input register. The holding register is readable and writable for instantaneous flow, while the input register is readable only for cumulative flow. The main control module uses function code encapsulation functions to assemble instruction frames using commonly used Modbus function codes.
4. The intelligent flow totalizer according to claim 1, characterized in that: The main control module includes a backup battery and an RTC clock system. The backup battery powers the RTC clock system, Modbus register backup, and subroutine operation.
5. The intelligent flow totalizer according to claim 1, characterized in that: The main control module includes a program data storage module, a static data storage module, and a peripheral FLASH data storage module. The data of each module has a fixed mapped address range in the main control module. The peripheral FLASH data storage module stores the original data of external devices. The static data storage module extends external memory through FSMC. The peripheral FLASH data storage is mapped to the unified address space of the main control module after being connected through FSMC.
6. The intelligent flow totalizer according to claim 1, characterized in that: The main control module includes a BOOT circuit and a reset circuit. When the main control module is powered on and reset, it detects the level state of the BOOT circuit and then reads the program's start ID from the corresponding data storage area.
7. The intelligent flow totalizer according to claim 1, characterized in that: The UART baud rate of the main control module is consistent with the communication baud rate of the RS485 communication module. The data format is hexadecimal. For data with a large range, floating-point numbers in the IEEE-754 standard 32-bit data format are used.
8. The intelligent flow totalizer according to claim 4, characterized in that: The RTC clock system includes an internal crystal oscillator and an external crystal oscillator. The external crystal oscillator includes a low-speed crystal oscillator circuit and a high-speed crystal oscillator circuit. The low-speed crystal oscillator circuit provides a clock signal to the RTC clock system module, and the high-speed crystal oscillator circuit improves the operating efficiency of the main control module.
9. The intelligent flow totalizer according to claim 5, characterized in that: The peripheral FLASH data storage module communicates synchronously with the main control module via an SPI interface. This synchronous serial communication includes an SCK clock signal, an NSS chip select signal, and a MOSI / MISO transmission signal. The SCK clock signal is generated by the main control module, and the external device synchronously follows the clock signal to ensure the timing consistency of data transmission. The MOSI / MISO signal is responsible for bidirectional data transmission between the main control module and the external device, with MOSI from main to external and MISO from external to main. The NSS chip select signal is controlled by the main control module to select the external device currently being communicated.
Citation Information
Patent Citations
Fluid flow accumulating system
CN104748810A
Flow integrating instrument
CN109682437A