Dynamic multi-threshold and PSO + BP temperature compensation method for external clamping type ultrasonic fluid flowmeter

By using dynamic multi-threshold and PSO+BP temperature compensation methods, the flow measurement error problem of clamp-on ultrasonic flow meters in a wide temperature range is solved, achieving high-precision and real-time flow measurement, which is suitable for small and medium diameter flow meters in industrial circulating water and urban water supply scenarios.

CN121521213APending Publication Date: 2026-02-13CHINA JILIANG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511787911.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-01
Publication Date
2026-02-13

AI Technical Summary

Technical Problem

External clamp-on ultrasonic liquid flow meters have large flow measurement errors over a wide temperature range. Existing technologies struggle to meet the requirements for high accuracy and real-time performance, especially since errors caused by differences in temperature conduction characteristics between different pipe diameters are difficult to compensate for effectively.

Method used

A dynamic multi-threshold and PSO+BP temperature compensation method is adopted. The temperature range is divided by K-means clustering, and a sub-model is constructed by combining particle swarm optimization (PSO) and backpropagation (BP) algorithms to achieve fine fitting of flow error and adapt to nonlinear characteristics under multiple pipe diameters.

Benefits of technology

It achieves a flow measurement relative error of ≤±1% within a temperature range of 0.1~50℃, is compatible with small and medium pipe diameters of DN20~DN100, and has a single compensation time of ≤1.2ms, meeting the requirements of high precision and real-time performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121521213A_ABST
    Figure CN121521213A_ABST
Patent Text Reader

Abstract

The invention discloses a dynamic multi-threshold combined PSO + BP temperature compensation method for an external clamping type ultrasonic fluid flowmeter, relates to the technical field of flow metering, and aims to solve the problems that the external clamping type ultrasonic fluid flowmeter is insufficient in metering precision in a wide temperature range and multi-pipe-diameter scene, and an embedded system is poor in adaptability. According to the method, temperature subintervals are divided through dynamic multiple thresholds, a compensation submodel is constructed by optimizing a BP neural network through PSO, and high-precision real-time temperature compensation is achieved. According to the method, within the flow interval of 1-40 m < 3 > / h and the range of small and medium pipe diameters, the relative error of flow measurement after compensation is smaller than or equal to + / -1.0%, the consumed time of single compensation calculation is smaller than or equal to 1.2 ms, STM32 series embedded hardware is adapted, the metering requirement of an external clamping type ultrasonic fluid flowmeter is met, and the method can be widely applied to heat supply, water supply and other scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of flow measurement technology, specifically to a dynamic multi-threshold and PSO+BP temperature compensation method for clamp-on ultrasonic liquid flow meters, which is suitable for high-precision flow measurement of small and medium diameter clamp-on ultrasonic liquid flow meters in scenarios such as industrial circulating water, urban water supply, and centralized heating. Background Technology

[0002] Clamp-on ultrasonic flow meters are widely used in both civilian and industrial applications due to their advantages such as non-invasive installation, no pressure loss, and compatibility with multiple pipe diameters. Their core measurement principle is the V-type time-of-flight method, which calculates the flow velocity by detecting the time difference between the forward and reverse flow of ultrasonic waves in the fluid, and then derives the flow rate. However, two major technical challenges exist in practical applications: First, the propagation speed of ultrasonic waves in liquids exhibits a significant non-linear change with temperature, with fluctuations exceeding 5% within the temperature range of 0.1–50℃, directly leading to flow measurement errors. Second, clamp-on installation cannot directly acquire the internal temperature of the fluid; it can only be indirectly estimated through the temperature of the pipe's outer wall, and the differences in temperature conduction characteristics between different pipe diameters further exacerbate the error.

[0003] In existing technologies, temperature compensation often focuses on fixed compensation at the hardware level or single algorithm fitting. For example, some flowmeters use PT1000 for simple linear temperature correction, which cannot handle nonlinear errors. Some solutions introduce neural network algorithms, but fail to address the need for piecewise fitting across multiple pipe diameters and wide temperature ranges, making it difficult to meet the high accuracy and real-time requirements of flowmeters. Therefore, there is an urgent need for a temperature compensation method that combines "piecewise fine compensation and intelligent algorithm optimization" to solve the temperature interference problem of clamp-on ultrasonic liquid flowmeters. Summary of the Invention

[0004] This invention aims to provide a dynamic multi-threshold and PSO+BP temperature compensation method for clamp-on ultrasonic liquid flow meters, achieving the following objectives: ① Adapting to a wide temperature range of 0.1~50℃ and small and medium pipe diameters of DN20~DN100, with a relative error of flow measurement ≤±1.0% after compensation; ② Reducing the complexity of model calculation, adapting to STM32 series embedded hardware, and a single compensation time ≤1.2ms.

[0005] The specific technical solution adopted in this invention is as follows:

[0006] A dynamic multi-threshold and PSO+BP temperature compensation method for clamp-on ultrasonic liquid flow meters is disclosed. This invention employs a two-layer technical architecture combining dynamic multi-threshold segmentation with a PSO+BP sub-model. Segmentation reduces the difficulty of nonlinear fitting, while intelligent optimization improves accuracy. The specific scheme is as follows. Its main processes include:

[0007] (1) Sample collection and preprocessing, and experimental platform construction: Using a volumetric water flow standard device (including a 0.5-class electromagnetic flowmeter with a measurement uncertainty of 0.05%) conforming to the "JJG1030-2007 Ultrasonic Flowmeter Verification Procedure" as a benchmark, four typical small and medium-diameter pipes of DN20, DN50, DN80, and DN100 were selected, and clamp-on ultrasonic liquid flowmeters were installed on each pipe diameter respectively; the fluid temperature was adjusted (0.1~50℃) by heating the water tank, and 1, 2, 10, 16, 28, and 40 m were set. 3 For six typical flow points, 10 sets of data were collected under each operating condition. After outliers were removed using the 3σ criterion, 48 valid samples were retained, forming a sample set covering multiple pipe diameters, wide temperatures, and the entire flow range. Sample normalization: Min-Max normalization was used to normalize the temperature T and the uncompensated flow rate Q. pre Flow error Δ Q Mapping to the [0,1] interval eliminates the impact of differences in units and data magnitudes on model training. The normalization formula is: Where x is the original data, x min x max These represent the minimum and maximum values ​​of the corresponding data.

[0008] (2) Dynamic multi-threshold temperature range division: K-means clustering algorithm is used to achieve adaptive temperature range division. The core is to match the influence of temperature on flow error under different pipe diameters through "dynamic thresholds": ① Cluster index design: "Euclidean distance between temperature T and flow error ΔQ" is used as the cluster index to ensure that the influence trend of temperature on flow error is consistent within the same range, and to avoid range division deviation caused by pipe diameter differences; ② Determination of optimal cluster number: The rationality of different cluster numbers K is verified by the silhouette coefficient (the closer the silhouette coefficient is to the value of K, the better). 1. The better the clustering effect), when K=6, the silhouette coefficient reaches 0.82, and 6 temperature sub-intervals are obtained: [0.1,8)℃, [8,16)℃, [16,24)℃, [24,32)℃, [32,40)℃, [40,50]℃; ③ Threshold storage and retrieval: The threshold boundaries (8℃, 16℃, 24℃, 32℃, 40℃) of the 6 intervals are stored in the Flash of the STM32F103 main control chip. During real-time measurement, the current temperature interval is quickly located by threshold comparison.

[0009] (3) Construction of PSO+BP compensation sub-model: For each temperature sub-interval, an independent PSO+BP compensation sub-model is constructed to achieve fine fitting of temperature-error within the interval and adapt to the local nonlinear characteristics under multiple pipe diameters: ① BP neural network structure design: Input layer: 2 nodes, namely the pipe outer wall temperature T and the flow rate Q before compensation. preThe core influencing factors of temperature compensation are directly related, and no additional pipe diameter parameters need to be collected, simplifying hardware design; Hidden layer: 8 nodes, using the Sigmoid activation function, whose nonlinear mapping capability can accurately fit the complex relationship between temperature and flow error within the range; Output layer: 1 node, representing the flow error ΔQ, using a linear activation function to ensure a linear correspondence between the predicted and actual error values, avoiding the introduction of additional errors by the activation function. ② PSO parameter optimization strategy, with 30 particles, balancing global optimization capability and computational efficiency; Inertia weight w: linearly decreasing from 0.8 to 0.2, with large weights in the early stage to achieve global parameter search, and small weights in the later stage to focus on local optimal parameter convergence, avoiding getting trapped in local optima; Learning factor: c1=c2=2, balancing the particle's "individual cognition" (relying on its own historical optimal solution) and "group cooperation" (relying on the group's historical optimal solution) capabilities; Fitness function: f=1 / MSE, where (m is the number of training samples). The smaller the MSE, the higher the fitness, and the better the corresponding parameter combination. ③ Model training and validation: Initialize the BP neural network with the optimal initial weights and thresholds obtained by PSO search, and train the model using momentum gradient descent (momentum coefficient 0.9) until the output error is ≤1e-6; test the model using the test set S. k-test To verify the model performance, the mean square error (RMSE) of the test set for each sub-model was ensured to be ≤0.1, resulting in six PSO+BP compensation sub-models M1 to M6.

[0010] (4) Real-time temperature compensation process: When the flow meter is working, temperature compensation is performed in real time through the following steps: ① Data acquisition: The PT1000 temperature sensor acquires the temperature T of the outer wall of the pipeline. real (Accuracy ±0.1℃), the TDC-GP22 timing chip acquires the ultrasonic transducer's upstream and downstream transit times (nanosecond resolution), and the STM32F103 main control chip calculates the pre-compensation flow rate Q based on the V-type time difference formula (combined with pipe diameter parameters). pre-real ② The main control chip calls the temperature threshold stored in Flash and makes a conditional judgment (such as T). real ≥24℃ and T real When the temperature is ≤32℃, it is determined to be within the range [24,32)℃. real For the corresponding sub-interval, call the corresponding PSO+BP compensation sub-model M. k ;

[0011] (5) Error prediction and compensation calculation: The normalized T real With Q pre-real Input sub-model M k The model outputs the predicted flow error; the actual flow error is obtained by inverse normalization (restoring to the actual error level), and the compensated actual flow is calculated: Q real =Q pre-real -ΔQpred ③ Data output and display: Compensated Q real On the one hand, it uploads data to the host computer via a LoRa module (which supports the Modbus protocol) to achieve remote monitoring; on the other hand, it displays instantaneous and cumulative traffic flow on a local LCD screen to meet on-site operation requirements.

[0012] The advantages and positive effects of this invention are as follows:

[0013] (1) High precision and multi-scenario adaptation: Dynamic multi-threshold segmentation transforms the strong nonlinear problem in a wide temperature range into a weak nonlinear problem in a narrow range. The PSO+BP sub-model achieves fine compensation under multiple pipe diameters. After compensation, the relative error of the full-range flow measurement is ≤±1%. It is compatible with small and medium pipe diameters from DN20 to DN100 and meets the metering requirements of Class 1.0 flow meters on the market.

[0014] (2) Low complexity and embedded adaptation: The PSO algorithm simplifies the parameter optimization process and shortens the model training time to less than 45s; the 6 sub-models occupy only 8KB Flash storage, and the single compensation calculation takes ≤1.2ms. It is fully compatible with the hardware resources of the STM32F103 series embedded chip (64KB SRAM, 256KB Flash) and does not require additional hardware expansion.

[0015] (3) Strong engineering practicality: No complex dynamic optimization mechanism is required. High-precision real-time compensation can be achieved through pre-trained PSO+BP sub-model, which simplifies the development and maintenance of embedded programs and makes it easier to implement in industrial scenarios. Attached Figure Description

[0016] To more clearly illustrate the technical solution of the present invention, the accompanying drawings, as part of the embodiments, are used to further describe the present invention, wherein:

[0017] Figure 1 This is a flowchart of the dynamic multi-threshold and PSO+BP temperature compensation method for the external clamp-on ultrasonic liquid flow meter of the present invention.

[0018] Figure 2 This is a flowchart illustrating the training and application framework of the PSO+BP sub-model for the external clamp-on ultrasonic liquid flow meter of the present invention. Detailed Implementation

[0019] The present invention will be further illustrated below with reference to the accompanying drawings and embodiments. However, these embodiments are merely illustrative, and the scope of protection of the present invention is not limited to these embodiments.

[0020] Combination Figure 1 , Figure 2 The dynamic multi-threshold and PSO+BP temperature compensation method of the clamp-on ultrasonic liquid flow meter of the present invention are described in detail below: Figure 1 As shown, after the flow meter starts running, the PT1000 temperature sensor first collects the temperature T of the outer wall of the pipe. real The TDC-GP22 timing chip acquires the trans- and trans-current transit times of the ultrasonic waves, and then the STM32F103 main control chip calculates the pre-compensation flow rate Q based on the V-type time difference formula and pipe diameter parameters. pre-real Subsequently, the main control chip calls the temperature threshold pre-stored in Flash and uses conditional judgment to locate T. real The corresponding temperature sub-range is then used to call the corresponding PSO+BP compensation sub-model M. k Next, the normalized T real With Q pre-real Inputting this sub-model, the predicted flow error is obtained, then inversely normalized to restore it to the actual error, and finally calculated using the formula Q. real =Q pre-real -ΔQ pred Calculate the actual flow rate after compensation; then calculate the Q after compensation. real On the one hand, remote monitoring can be achieved by uploading data to a host computer through a LoRa module that supports the Modbus protocol. On the other hand, the instantaneous and cumulative traffic flow can be displayed on the local LCD screen. After completing this data processing, the next sampling cycle will begin and continue until the process ends.

[0021] like Figure 2 As shown in the flowchart, this is a zonal compensation method for temperature-flow error of ultrasonic flowmeters. The specific operation is as follows: First, sample collection and preprocessing are performed. Using a volumetric water flow standard device that conforms to the regulations as a benchmark, four types of small and medium diameter pipes are selected to install external clamp-on ultrasonic liquid flowmeters. The fluid temperature is adjusted to 0.1~50℃ and six typical flow points are set. Ten sets of data are collected for each operating condition. After outliers are removed by the 3σ criterion, 48 sets of valid samples are retained. Then, Min-Max normalization is used to compare the temperature T and the flow rate Q before compensation. pre The flow error ΔQ is mapped to the [0,1] interval to eliminate the influence of differences in units and data magnitude. Next, dynamic multi-threshold temperature interval division is performed, using the "Euclidean distance between temperature T and flow error ΔQ" as the clustering index. Adaptive division is achieved through the K-means clustering algorithm, and the optimal number of clusters K=6 is determined by silhouette coefficient verification, resulting in 6 temperature sub-intervals. Simultaneously, the interval threshold boundaries are stored in the Flash memory of the STM32F103 main control chip for quick location of the current temperature interval during real-time measurement. Then, a PSO+BP compensation sub-model is constructed, building an independent sub-model for each temperature sub-interval: first, a BP neural network structure is designed, using the distance between temperature T and the pre-compensation flow rate Q... preThe model consists of 8 input layer nodes, 8 hidden layer nodes (using the Sigmoid activation function), and the flow error ΔQ output layer nodes (using the linear activation function). PSO parameters are then set, optimized with 30 particles, linearly decreasing inertia weights, and learning factors c1 = c2 = 2. The fitness function is the reciprocal of MSE. Particle fitness is calculated, individual and global optimal solutions are updated, and particle velocity and position are iteratively adjusted. After convergence, the globally optimal initial BP weights and thresholds are output. These optimal parameters are then used to initialize the BP neural network, and the model is trained using momentum gradient descent until the output error is ≤1e-6. The model is validated on a test set to ensure that the mean square error of each sub-model is ≤0.1, ultimately resulting in 6 PSO+BP compensation sub-models M. k Complete the entire process.

[0022] The above examples are only for the purpose of helping to understand the core idea of ​​the present invention; at the same time, those skilled in the art will know that there will be changes in the specific implementation methods and application scope based on the idea of ​​the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A dynamic multi-threshold with PSO+BP temperature compensation method for an external clamp-on ultrasonic liquid flowmeter, characterized in that: Comprise the following steps: S1, temperature-flow sample collection and pretreatment, the pipe outer wall temperature T, the compensated flow Q of the external clamp type ultrasonic liquid flowmeter under different temperature and flow conditions pre And standard flow Q std Collect, calculate flow error ΔQ = Q pre -Q std , form temperature-flow-error sample set, and normalize the sample set; S2, dynamic multi-threshold temperature interval division, the temperature T in the sample set is segmented by clustering algorithm, a plurality of continuous and non-overlapping temperature subintervals are obtained, and the threshold boundary of each temperature subinterval is stored in the flowmeter main control chip; S3, PSO+BP compensation submodel construction: for each temperature subinterval, the temperature T and the compensated flow Q pre As input, the flow error as output to establish a BP neural network, and the initial weight and threshold of the BP neural network are optimized by using particle swarm algorithm, and the PSO+BP temperature compensation submodel M k Corresponding to the temperature subinterval is trained; S4, when the flowmeter works, the current pipe outer wall temperature T real And the compensated flow Q pre-real Are collected in real time, the temperature T real Subinterval is determined according to the stored temperature threshold, and the corresponding submodel M k Is called, the predicted flow error ΔQ pred Is obtained by forward calculation, and the compensated actual flow Q real Is calculated according to Q pre-real = Q pred -ΔQ real .

2. The method of claim 1, wherein: The pipe diameter range in step 1 is DN20 to DN100, and the abnormal values in the sample set are removed by the 3σ criterion.

3. The method of claim 1, wherein: In step 2, the optimal cluster number K is 6, and the corresponding temperature sub-intervals are [0.1, 8) ℃, [8, 16) ℃, [16, 24) ℃, [24, 32) ℃, [32, 40) ℃ and [40, 50] ℃.

4. The method of claim 1, wherein: In step 3, the activation function of the hidden layer of the BP network is Sigmoid, and the activation function of the output layer is a linear function.

5. The method of claim 1, wherein: The master chip in step 4 is an STM32F103 series microcontroller, which communicates with the TDC-GP22 timing chip through an SPI interface, and communicates with the PT1000 temperature sensor through a C interface 2 The C interface communicates with the PT1000 temperature sensor, and the single temperature compensation calculation takes ≤1.2 ms.

6. An external clamp-on ultrasonic liquid flow meter characterized by: The dynamic multi-threshold temperature compensation method according to any one of claims 1-5 is adopted; the flow meter comprises an STM32F103 main control module, a TDC-GP22 timing module, a PT1000 temperature acquisition module, a LoRa communication module, a boost driving module and an echo signal processing module, and each module cooperates to realize flow measurement and the above real-time temperature compensation.