A time-of-flight difference calculation method for an ultrasonic flow meter and related apparatus
By dividing the local wave in the ultrasonic flowmeter and performing eigenvalue sequence alignment and matching difference calculation, the calculation error caused by echo signal amplitude attenuation and waveform distortion under complex working conditions is solved, achieving higher measurement accuracy and wider application.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 杭州先锋电子技术股份有限公司
- Filing Date
- 2026-01-22
- Publication Date
- 2026-05-05
AI Technical Summary
Under complex operating conditions, the calculation method of time difference of flight of ultrasonic flow meters has large calculation errors due to the attenuation of echo signal amplitude and waveform distortion, which affects the accuracy of fluid flow measurement and limits its application scenarios.
The time-of-flight difference is determined by dividing local waves from the uplink and downlink echo signals of the ultrasonic flow meter, extracting feature value sequences, and performing translational alignment and matching difference calculations within the integer local wave shift range.
It improves the accuracy of time-of-flight difference calculation, ensures the accuracy of fluid flow measurement, and expands the applicable scenarios of ultrasonic flow meters.
Smart Images

Figure CN121558137B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of ultrasonic metering technology, and in particular to a method for calculating the time difference of flight of an ultrasonic flowmeter and related equipment. Background Technology
[0002] Ultrasonic flow meters (such as ultrasonic gas meters and ultrasonic water meters) calculate fluid flow by measuring the time difference of ultrasonic waves propagating in the forward and reverse directions. They have advantages such as small size, no mechanical wear, and high measurement accuracy.
[0003] However, accurately extracting time-of-flight difference (TOF) under complex real-world operating conditions presents significant challenges. Factors such as bubbles, particulate matter, impurity deposition in fluids, as well as temperature and pressure changes and transducer performance drift, often lead to amplitude attenuation and waveform distortion in the received echo signal. Traditional TOF calculation methods, such as the fixed threshold method or zero-crossing detection method, heavily rely on the single-point amplitude of the signal or the waveform characteristics of the characteristic wave. When the signal amplitude is insufficient or local distortion occurs, these methods are prone to failure to trigger, false triggering, or characteristic point drift, resulting in significant errors in TOF calculation.
[0004] There is currently no effective solution to the aforementioned problems in the relevant technologies. Summary of the Invention
[0005] The present invention provides a method and related equipment for calculating the time difference of flight of an ultrasonic flow meter, which at least partially solves the problem that the calculation of the time difference of flight of related technologies often suffers from amplitude attenuation and waveform distortion of the echo signal under actual working conditions, resulting in large errors in the calculation of the time difference of flight, which in turn leads to deviations in the accuracy of fluid flow measurement and narrows the application scenarios of ultrasonic flow meters.
[0006] To address the aforementioned problems, one aspect of this invention provides a method for calculating the time-of-flight difference of an ultrasonic flowmeter, comprising:
[0007] Multiple continuous local waves are obtained from the upward and downward echo signals corresponding to the ultrasonic flow meter. Feature values characterizing the amplitude range of each local wave are extracted. The feature values are sorted according to the sampling time of the local wave to obtain an upward feature value sequence and a downward feature value sequence. Each local wave includes a trough and a peak adjacent to the trough.
[0008] Within a preset integer local wave shift range, for each preset shift number: the downlink feature value sequence is shifted and aligned relative to the uplink feature value sequence according to the preset shift number to obtain an aligned downlink feature value subsequence;
[0009] Calculate the matching difference degree between each of the downlink feature value subsequences and the uplink feature value sequence, determine the target local wave shift number based on the matching difference degree, and determine the time-of-flight difference of the ultrasonic flowmeter based on the target local wave shift number.
[0010] In some embodiments, prior to the step of calculating the matching difference between each of the downlink feature value subsequences and the uplink feature value sequence, the method further includes:
[0011] The maximum eigenvalue of the uplink and the maximum eigenvalue of the downlink are determined from the uplink eigenvalue sequence and the downlink eigenvalue sequence, respectively. The ratio between the maximum eigenvalue of the uplink and the maximum eigenvalue of the downlink is calculated as the ratio of the maximum eigenvalues of the uplink and downlink.
[0012] The amplitude correction parameters are determined based on the preset eigenvalue ratio range and the maximum uplink / downlink eigenvalue ratio.
[0013] Based on the amplitude correction parameters, the downlink feature value subsequence is updated with amplitude correction to obtain the corrected and updated downlink feature value subsequence.
[0014] In some embodiments, the step of extracting feature values characterizing the amplitude range of each local wave includes:
[0015] Determine the local maximum amplitude and local minimum amplitude for each of the local waves;
[0016] The difference between the local maximum amplitude and the local minimum amplitude is calculated as the feature value; or, a nonlinear curve is fitted based on the local maximum amplitude and the local minimum amplitude of each local wave to determine the peak amplitude and trough amplitude of the local wave, and the difference between the peak amplitude and the trough amplitude is calculated as the feature value.
[0017] In some embodiments, the step of determining the amplitude correction parameter based on the preset eigenvalue ratio range and the uplink / downlink maximum eigenvalue ratio includes:
[0018] Determine whether the ratio of the maximum uplink to downlink eigenvalue is within the preset eigenvalue ratio range;
[0019] If the maximum eigenvalue ratio of uplink and downlink is within the preset eigenvalue ratio range, then the amplitude correction parameter is determined based on the maximum eigenvalue ratio of uplink and downlink.
[0020] If the maximum uplink-to-downlink eigenvalue ratio is outside the preset eigenvalue ratio range, the amplitude correction parameter is determined by a fitting function based on the corresponding parts of the uplink eigenvalue sequence and the downlink eigenvalue subsequence.
[0021] In some embodiments, the step of calculating the matching difference degree between each of the downlink eigenvalue subsequences and the uplink eigenvalue sequence, and determining the target local wave shift number based on the matching difference degree, includes:
[0022] For each preset shift number: calculate the difference between the uplink feature value sequence and the corresponding feature value in the downlink feature value subsequence corresponding to the preset shift number, and sum the absolute values of each difference to obtain a first summation;
[0023] The preset shift number that minimizes the first cumulative sum is determined as the target local wave shift number.
[0024] In some embodiments, the step of calculating the matching difference degree between each of the downlink eigenvalue subsequences and the uplink eigenvalue sequence, and determining the target local wave shift number based on the matching difference degree, includes:
[0025] For each preset shift number: calculate the ratio of the corresponding feature value in the uplink feature value sequence and the corresponding feature value in the downlink feature value subsequence corresponding to the preset shift number; determine the maximum uplink feature value and the maximum downlink feature value in the uplink feature value sequence and the downlink feature value sequence respectively; calculate the ratio of the maximum uplink and downlink feature values; accumulate the absolute values of the differences between each ratio and the ratio of the maximum feature value to obtain a second accumulated sum.
[0026] The preset shift number that minimizes the second sum is determined as the target local wave shift number.
[0027] In some embodiments, the step of determining the time-of-flight difference of the ultrasonic flowmeter based on the target local wave shift number includes:
[0028] Based on the target local wave shift number, determine one or more target feature value pairs in the uplink feature value sequence and the downlink feature value subsequence corresponding to the target local wave shift number;
[0029] Based on any one of the target feature values, the corresponding ascending and descending peak times in the local wave are used to calculate the peak time difference; or, based on any one of the target feature values, the corresponding ascending and descending trough times in the local wave are used to calculate the trough time difference, and the peak time difference or the trough time difference is used as the flight time difference; or...
[0030] Based on multiple target feature value pairs, multiple peak time differences and / or multiple trough time differences are calculated respectively, and the average value of the multiple peak time differences and / or the multiple trough time differences is used as the flight time difference.
[0031] To address the aforementioned problems, one aspect of the present invention provides a time-of-flight difference calculation device for an ultrasonic flowmeter, comprising:
[0032] The signal processing module is used to divide the upstream echo signal and downstream echo signal corresponding to the ultrasonic flow meter into multiple continuous local waves, extract feature values representing the amplitude range of each local wave, and sort the feature values according to the sampling time of the local wave to obtain an upstream feature value sequence and a downstream feature value sequence; wherein, each local wave includes a trough and a peak adjacent to the trough;
[0033] The shift processing module is used to, within a preset integer local wave shift range, for each preset shift number: shift and align the downlink feature value sequence relative to the uplink feature value sequence according to the preset shift number to obtain an aligned downlink feature value subsequence;
[0034] The time-of-flight difference determination module is used to calculate the matching difference degree between each of the downlink feature value subsequences and the uplink feature value sequences, determine the target local wave shift number based on the matching difference degree, and determine the time-of-flight difference of the ultrasonic flowmeter based on the target local wave shift number.
[0035] To address the aforementioned problems, one aspect of this invention provides an electronic device, including: a processor and a memory storing a program, the program including instructions that, when executed by the processor, cause the processor to perform any of the above-described ultrasonic flowmeter time-of-flight difference calculation methods.
[0036] To address the aforementioned problems, one aspect of this invention provides a non-transient machine-readable medium storing computer instructions for instructing a computer to execute any of the above-described ultrasonic flowmeter time-of-flight difference calculation methods.
[0037] The beneficial effects of this invention are as follows: By dividing the upstream and downstream echo signals corresponding to the ultrasonic flowmeter into multiple continuous local waves, extracting feature values representing the amplitude range of each local wave, and sorting the feature values according to the sampling time of the local waves, an upstream feature value sequence and a downstream feature value sequence are obtained. Each local wave includes a trough and an adjacent peak. Within a preset integer local wave shift interval, for each preset shift, the downstream feature value sequence is shifted relative to the upstream feature value sequence according to the preset shift, resulting in an aligned downstream feature value subsequence. The matching difference between each downstream feature value subsequence and the upstream feature value sequence is calculated, and the target local wave shift is determined based on the matching difference. The time-of-flight difference of the ultrasonic flowmeter is then determined based on the target local wave shift. This overcomes the time-of-flight difference problem of related technologies. The calculation method suffers from significant errors in calculating the time-of-flight difference (TOF), due to the frequent amplitude attenuation and waveform distortion of echo signals under actual operating conditions. This leads to deviations in the accuracy of fluid flow measurement, limiting the application scenarios of ultrasonic flow meters. To address this, a solution is implemented that extracts characteristic values representing the amplitude range of local waves from the continuous local waves corresponding to the uplink and downlink echo signals. This determines the uplink and downlink characteristic value sequences, thereby quantifying the waveform energy and amplitude transformation degree of the local waves. Furthermore, by performing shift alignment and matching difference comparison of the uplink and downlink characteristic value sequences within integer local wave shift intervals, waveform misalignment within integer periods can be accurately identified and corrected, avoiding interference from amplitude attenuation and waveform distortion. This significantly improves the accuracy of TOF calculation, ensures the accuracy of fluid flow measurement, and further expands the application scenarios of ultrasonic flow meters.
[0038] Details of one or more embodiments of the present invention are set forth in the following drawings and description, so that other features, objects and advantages of the invention will be more readily understood. Attached Figure Description
[0039] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other embodiments can be obtained based on these drawings without creative effort.
[0040] Figure 1 This is a schematic diagram of the main flow of a method for calculating the time difference of flight of an ultrasonic flowmeter, which is an embodiment of the present invention.
[0041] Figure 2This is a schematic diagram of the local wave division of the echo signal in one embodiment of the present invention.
[0042] Figure 3 This is a schematic diagram of the frame of the time-of-flight difference calculation device for an ultrasonic flow meter, which is an embodiment of the present invention.
[0043] Figure 4 This is a schematic diagram of the electronic device of the present invention. Detailed Implementation
[0044] Embodiments of the present invention will now be described in more detail with reference to the accompanying drawings. While some embodiments of the invention are shown in the drawings, it should be understood that the invention can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the invention. It should be understood that the accompanying drawings and embodiments are for illustrative purposes only and are not intended to limit the scope of protection of the invention.
[0045] Related technologies have also proposed methods for determining time of flight based on signal envelope processing. For example, by extracting the envelope arrays of uplink and downlink echo signals and shifting them within an integer number of waveform periods, the optimal alignment is determined by comparing the differences in the envelope arrays under different shifts, thereby calculating the time difference. This method improves noise tolerance to some extent. However, it still has certain problems when applied in actual working conditions: when the uplink and downlink signals have significantly different amplitude attenuation levels and inconsistent envelope shapes due to propagation path or medium inhomogeneity, directly comparing the envelope difference will couple the time misalignment error with the inherent differences in amplitude / shape. This coupling interference will seriously confuse the judgment of the alignment relationship. In complex working conditions such as bubbles, impurities, etc., which cause asymmetry in the characteristics of uplink and downlink signals, it is still easy to make incorrect judgments about the correspondence between uplink and downlink waveforms, ultimately affecting the accuracy of time difference calculation and the stability and reliability of flow measurement.
[0046] To address the aforementioned problems, embodiments of the present invention provide a method for calculating the time-of-flight difference of an ultrasonic flowmeter, such as... Figure 1 As shown, the method for calculating the time difference of flight of this ultrasonic flowmeter mainly includes:
[0047] Step S101: From the upward echo signal and downward echo signal corresponding to the ultrasonic flow meter, multiple continuous local waves are obtained respectively. Feature values representing the amplitude range of the local wave are extracted from each local wave. The feature values are sorted according to the sampling time of the local wave to obtain the upward feature value sequence and the downward feature value sequence. The local wave includes a trough and a peak adjacent to the trough.
[0048] The ultrasonic flow meter's upstream and downstream echo signals are transmitted and received by ultrasonic transducers in the downstream and upstream directions, respectively, and acquired via an analog-to-digital converter (ADC). The echo signal waveform is actually composed of multiple discrete sampling signal points. When sampling the downstream ultrasonic echo signal, the obtained data is a series of downstream sampling points arranged in chronological order, forming a downstream sampling sequence. Therefore, the corresponding downstream echo signal is actually multiple discrete sampling signal points in a downstream sampling sequence. When sampling the upstream ultrasonic echo signal, the obtained data is a series of upstream sampling points ordered in chronological order, forming a downstream sampling sequence. Therefore, the corresponding upstream echo signal is actually multiple discrete sampling signal points in a downstream sampling sequence. Each sampling point represents the amplitude of the ultrasonic signal at a specific moment.
[0049] Based on the above setup, by dividing local waves, extracting eigenvalues, and constructing eigenvalue sequences, the susceptible and unstable echo signal is creatively transformed into a sequence of discrete eigenvalues characterizing the energy intensity of local waves. This transformation method significantly suppresses the impact of random noise and local irregular distortions in the signal on subsequent processing. At the same time, by focusing on the eigenvalues characterizing the amplitude range of each local wave, the core criterion for finding the correspondence between uplink and downlink waveforms (target local wave shift) is the energy intensity distribution pattern of each local wave. This provides the entire method with high-quality input data (eigenvalue sequences) that can withstand interference from complex operating conditions, and serves as the data foundation for achieving high-precision, robust alignment and accurate time-of-flight difference calculation.
[0050] In one specific embodiment of the present invention, since one purpose of dividing local waves is to extract characteristic values representing the amplitude range of the local wave, the division range of the local waves is not particularly limited. It is sufficient that the local wave includes a trough and a peak adjacent to the trough. Specifically, the entire uplink or downlink echo signal can be divided into continuous, interconnected local waves, or only a local segment including a trough-peak pair can be extracted for each wave. It is known that the echo signal waveform is actually composed of multiple discrete sampling signal points. By comparing the amplitudes of adjacent sampling points, local maxima and local minima in the echo signal can be quickly detected. The positions of peaks and troughs are within the range adjacent to the local maxima and local minima, thus multiple continuous local waves can be obtained accordingly.
[0051] For example, the local wave provided by the present invention includes a trough and a peak adjacent to the trough, and can be implemented using methods such as... Figure 2 As shown, the band corresponding to local wave 1 contains both a local minimum 1 and a local maximum 1, and therefore must include a trough and an adjacent peak. It should be noted that... Figure 2 The local wave division shown is merely an example and is not intended to limit the invention.
[0052] Exemplarily, according to an embodiment of the present invention, firstly, the ultrasonic waves excited by the ultrasonic transducer propagate and reflect in the fluid. The received echo signal is essentially a damped oscillation signal, whose waveform exhibits continuous, decaying periodic fluctuations. A "trough-crest" pair constitutes a basic periodic unit of this oscillation (i.e., the aforementioned local wave). Using this natural period as the dividing unit ensures that the extracted feature values strictly correspond to the physical essence of the local wave. Compared to data windows of arbitrary length or abstract intervals based on envelopes, using the local wave as the unit can most accurately pinpoint the energy center of each oscillation cycle, laying a physically correct foundation for subsequent periodic alignment. Secondly, for an oscillation cycle, the amplitude difference between its peaks and troughs directly reflects the intensity of the signal oscillation within that cycle, serving as a robust indicator of the energy carried by the local wave. In actual complex operating conditions, individual sampling points may exhibit abnormalities (glitching) due to interference, or localized depressions or bulges may appear in the waveform. However, the method for calculating the amplitude range of the entire local wave provided by the embodiments of the present invention is insensitive to outliers at individual points. Even if the peaks or troughs shift slightly due to noise, as long as the approximate location and magnitude of the extreme points are maintained, the difference can remain relatively stable. This significantly enhances the anti-interference capability compared to relying on "point features" such as the amplitude of a single peak or the time of zero crossing. On the other hand, the aforementioned feature values mainly reflect the signal strength level, while having less dependence on the specific shape of the waveform within a period (such as symmetry, differences between rising and falling edges). When the signal undergoes non-uniform attenuation or distortion due to differences in the propagation path, the shapes of the corresponding local waves in the uplink and downlink may differ, but their energy (amplitude range) change trends may still maintain a certain correlation, thereby suppressing the effects of amplitude attenuation and waveform distortion. Finally, the time-ordering ensures that the order of elements in the feature value sequence is completely consistent with the order in which the local waves appear in the original waveform. The index of the sequence implies time information, and the i-th feature value in the sequence corresponds to the center time region of the i-th local wave. By compressing the original, high-dimensional continuous waveform into a one-dimensional numerical sequence, a large amount of high-frequency details and redundant information that are irrelevant to period alignment are discarded, while the trend of signal energy evolution over time is preserved. Based on this trend, it is a sufficient and more effective feature for identifying the overall structure of the waveform, especially for discovering the overall integer period offset (misalignment) between the up and down waveforms caused by flow velocity.
[0053] It is also understandable that discrete numerical sequences (i.e., eigenvalue sequences) are well-suited for mature computational operations in digital signal processing, such as translation, differencing, and correlation. This invention transforms the complex and difficult-to-model waveform similarity comparison problem into a clear discrete sequence similarity matching problem. Subsequently, by performing translations on integer indices (corresponding to the translation alignment of an integer number of local waves) and calculating the matching difference, the optimal waveform alignment method can be systematically searched and determined. This effectively improves the accuracy of the target local wave shift while simplifying the data processing flow.
[0054] In some embodiments, the step of extracting feature values characterizing the amplitude range of each local wave includes: determining the local maximum amplitude and local minimum amplitude of each local wave; calculating the difference between the local maximum amplitude and the local minimum amplitude as a feature value; or, performing nonlinear curve fitting based on the local maximum amplitude and the local minimum amplitude of each local wave to determine the peak amplitude and trough amplitude of the local wave, and calculating the difference between the peak amplitude and the trough amplitude as a feature value.
[0055] Local maxima and local minima in a local wave can be determined by comparing the amplitudes of adjacent sampling points.
[0056] Based on the above settings, two specific implementation methods for feature extraction are provided, which offer a highly robust solution for the energy / intensity quantization of local waves that can flexibly balance accuracy and efficiency.
[0057] According to a specific embodiment of the present invention, after determining the local maximum and minimum amplitudes of a local wave, their difference is directly calculated as a characteristic value. This method requires only two extreme value searches and one subtraction operation, making the calculation process extremely simple and introducing almost no additional delay, perfectly meeting the needs of embedded systems or real-time processing requiring high-frequency calculations. Although a single extreme point may be shifted due to noise, considering both a peak and a trough simultaneously and calculating their difference can, to some extent, offset the effects of baseline drift or partially correlated noise in the same direction. Therefore, as long as the approximate position and relative relationship of the extreme points remain unchanged, the difference can still effectively reflect the amplitude fluctuation of the local wave, meeting the basic robustness requirements.
[0058] According to another specific embodiment of the present invention: nonlinear curve fitting is performed based on the local maximum amplitude and local minimum amplitude of each local wave to determine the peak amplitude and trough amplitude of the local wave, and the difference between the peak amplitude and the trough amplitude is calculated as a characteristic value. The actual peaks and troughs may fall between two sampling points. Directly using the maxima / minimum values at the sampling points will introduce inherent quantization errors due to sampling rate limitations. By modeling continuous sampling points near the extreme points through nonlinear curve fitting (such as parabolic fitting or cosine fitting), an approximate representation of the continuous waveform can be reconstructed from discrete data. This allows for the analytical determination of extreme amplitudes located between sampling intervals that are closer to the theoretical values, significantly reducing quantization errors. Furthermore, noise in the actual signal may cause abnormal amplitudes at individual sampling points, resulting in detected extreme points that are not the true peaks of the waveform. Therefore, the fitting process is equivalent to smoothing and denoising the local waveform. Peaks and troughs are determined based on the overall trend of multiple sampling points, making them insensitive to individual abnormal sampling points. This suppresses extreme point distortion caused by noise, and the fitted peak and trough amplitudes are more stable and reliable than the maxima and minima directly selected from the original sampling points. In other words, the peak and trough amplitudes obtained through fitting are a better estimate of the energy of the idealized local waveform. Calculating their differences yields eigenvalues that better represent the theoretical energy range of the local wave under noise-free or low-noise conditions. This makes the eigenvalue sequence clearer and more regular, laying a better data foundation for subsequent high-precision sequence matching.
[0059] In the step of determining the peak and trough amplitudes of a local wave by performing nonlinear curve fitting based on the local maximum and minimum amplitudes of each local wave, nonlinear curve fitting can be performed using parabolic fitting, sine or cosine curve fitting, etc., to reduce the influence of noise and local distortion on the single-point extreme values.
[0060] In practical applications, a trade-off must be struck between computational accuracy and resource consumption (time, computing power). The feature extraction scheme provided in the first specific implementation method described above is suitable for standard operating conditions or cost-sensitive designs; the feature extraction scheme provided in the second specific implementation method described above is suitable for high-precision measurement, complex and harsh operating conditions, or platforms with stronger processing capabilities. In specific applications, different feature extraction schemes can be flexibly selected according to actual application requirements.
[0061] Step S102: Within the preset integer local wave shift range, for each preset shift: the downlink eigenvalue sequence is shifted and aligned relative to the uplink eigenvalue sequence according to the preset shift, to obtain the aligned downlink eigenvalue subsequence.
[0062] Specifically, by actively and systematically searching all possible integer shifts of the downlink eigenvalue sequence relative to the uplink eigenvalue sequence, the search for the correct alignment is ensured to be complete, preventing the omission of the true optimal alignment position due to initial estimation errors or local optima. Each shift operation generates an aligned downlink eigenvalue subsequence that strictly corresponds to the uplink eigenvalue sequence in terms of index. This generates a set of candidate alignment schemes for fair and consistent comparison in subsequent steps, with each candidate alignment scheme representing a specific assumption about the correspondence between the uplink and downlink waveforms.
[0063] Based on the above settings, in order to accurately identify and correct the integer period waveform misalignment (i.e., waveform misalignment) between the uplink and downlink echo signals caused by physical factors such as flow velocity, the downlink feature value sequence is shifted and aligned relative to the uplink feature value sequence within a limited and preset integer local waveform shift range. All possible candidate alignment relationships are systematically generated to provide an objective and quantitative standard form for subsequent matching difference calculation.
[0064] According to an embodiment of the present invention, in an ultrasonic flow meter, due to the influence of fluid velocity, the dominant time difference between the ultrasonic echo signals propagating in the downstream and upstream directions manifests as an advance or lag of the entire waveform period (i.e., an integer number of local waves). Therefore, limiting the preset integer local wave shift interval to an integer displacement directly addresses the essence of the core physical problem of misaligned waves, avoiding inefficient or misleading searches in unnecessary continuous phase space. It can be understood that since each element in the eigenvalue sequence corresponds to a complete local wave, shifting the eigenvalue sequence by an integer number of units physically means matching the j-th local wave in the downstream echo signal with the i-th local wave in the upstream echo signal. Based on the above design, consistency between the data processing level and the physical level is maintained.
[0065] In some examples, the preset integer local wave shift number range is not infinite, but is based on the estimation of prior knowledge such as the maximum possible flow rate and circuit delay. This transforms the theoretically infinite search problem into a finite and controllable cyclic computation problem, ensuring the feasibility and real-time performance of the algorithm in actual embedded systems.
[0066] In practical applications, the design of the preset integer local wave shift interval [-N, N] can achieve a balance between search completeness and computational burden. For example, N can be set to 2 or 3, and the interval between each preset shift number is 1, that is, a difference of one local wave. When the preset shift number is negative, the downlink eigenvalue sequence is right-shifted relative to the uplink eigenvalue sequence for alignment; when the preset shift number is positive, the downlink eigenvalue sequence is left-shifted relative to the uplink eigenvalue sequence for alignment.
[0067] Among them, the aligned downlink eigenvalue subsequence provided in the embodiments of the present invention can include at least the following three forms: (1) a shift alignment form with reduced length, that is, in the downlink eigenvalue subsequence obtained after shift alignment, only the elements of the completely overlapping parts of the uplink and downlink eigenvalue sequences after shift alignment are retained. (2) a shift alignment form with unchanged sequence length - zero-padding alignment, that is, in the aligned downlink eigenvalue subsequence: on the one hand, the elements of the completely overlapping parts of the uplink and downlink eigenvalue sequences after shift alignment are retained, and on the other hand, the eigenvalue of the elements of the downlink eigenvalue sequence aligned with the uplink eigenvalue sequence after shift alignment but without corresponding values is assigned to 0, thereby obtaining the downlink eigenvalue subsequence. (3) a shift alignment form with unchanged sequence length - alignment form with supplementing front / back local wave eigenvalues, that is, in the aligned downlink eigenvalue subsequence: on the one hand, the elements of the completely overlapping parts of the uplink and downlink eigenvalue sequences after shift alignment are retained, and on the other hand, for the elements of the downlink eigenvalue sequence aligned with the uplink eigenvalue sequence after shift alignment but without corresponding values, the eigenvalue of the downlink local wave at the corresponding position is found as a supplement, thereby obtaining the downlink eigenvalue subsequence.
[0068] According to a specific embodiment of the present invention, after shifting the downlink feature value sequence D by k positions relative to the uplink feature value sequence U and aligning its elements, for the downlink feature value sequence D: only the elements overlapping with the uplink feature value sequence U after shifting and alignment can be retained to obtain the aligned downlink feature value subsequence. For this type of downlink feature value subsequence, when subsequently calculating the matching difference between the uplink feature value sequence and the corresponding downlink feature value subsequence, it is also only necessary to calculate the matching difference between the feature values of the overlapping portion of the two sequences.
[0069] According to another specific embodiment of the present invention, after shifting the downlink eigenvalue sequence D by k positions relative to the uplink eigenvalue sequence U and aligning its elements, for the downlink eigenvalue sequence D: the portion overlapping with the uplink eigenvalue sequence U is extracted, the portion not overlapping with the uplink eigenvalue sequence U is discarded, and the portion aligned with the uplink eigenvalue sequence but whose corresponding element has no value is set to eigenvalue 0, thereby generating an aligned downlink eigenvalue subsequence. For this type of downlink eigenvalue subsequence, on the one hand, when calculating the matching difference between the uplink eigenvalue sequence and the corresponding downlink eigenvalue subsequence, the matching difference between the eigenvalues of the overlapping portion of the two sequences can still be calculated; on the other hand, amplitude correction processing can be performed on this type of downlink eigenvalue subsequence, and then the matching difference of all elements (all eigenvalue pairs) is performed on the uplink eigenvalue sequence and the corrected downlink eigenvalue subsequence.
[0070] According to another specific embodiment of the present invention, after shifting the downlink eigenvalue sequence D by k positions relative to the uplink eigenvalue sequence U and aligning its elements, for the downlink eigenvalue sequence D: the portion overlapping with the uplink eigenvalue sequence U is extracted, the portion not overlapping with the uplink eigenvalue sequence U is discarded, and for the portion aligned with the uplink eigenvalue sequence but where the corresponding element has no value, the corresponding newly added local wave is found, and the eigenvalue corresponding to the newly added local wave is used as the value of the corresponding element, thereby generating the aligned downlink eigenvalue subsequence. For this type of downlink eigenvalue subsequence, on the one hand, when calculating the matching difference between the uplink eigenvalue sequence and the corresponding downlink eigenvalue subsequence, the matching difference of all elements (all eigenvalue pairs) is performed; on the other hand, amplitude correction processing can be performed on this type of downlink eigenvalue subsequence, and then the matching difference of all elements (all eigenvalue pairs) is performed again for the uplink eigenvalue sequence and the corrected downlink eigenvalue subsequence.
[0071] In some embodiments, after the step of aligning the downlink feature value sequence relative to the uplink feature value sequence according to a preset shift number to obtain the aligned downlink feature value subsequence, that is, before the step of calculating the matching difference between each downlink feature value subsequence and the uplink feature value sequence, the method further includes: determining the uplink maximum feature value and the downlink maximum feature value from the uplink feature value sequence and the downlink feature value sequence respectively; calculating the ratio between the uplink maximum feature value and the downlink maximum feature value as the uplink-downlink maximum feature value ratio; determining the amplitude correction parameter according to the preset feature value ratio interval and the uplink-downlink maximum feature value ratio; and updating the downlink feature value subsequence with amplitude correction according to the amplitude correction parameter to obtain the corrected and updated downlink feature value subsequence.
[0072] Based on the above settings, before calculating the matching difference between each downlink eigenvalue subsequence and the uplink eigenvalue sequence, and then determining the target local wave shift number based on the matching difference, an amplitude correction parameter determined based on the ratio of the maximum uplink and downlink eigenvalues is introduced to correct and update the downlink eigenvalue subsequence. This eliminates or reduces the interference of systematic amplitude differences between uplink and downlink echo signals caused by asymmetric factors such as propagation path differences and uneven attenuation on the matching judgment. This further ensures that the matching difference obtained in subsequent calculations can more purely reflect the time alignment error, thereby improving the accuracy of the target local wave shift number.
[0073] In ultrasonic echo signals, the maximum eigenvalue usually corresponds to the main wave or the first few waves with the most concentrated signal energy and the highest signal-to-noise ratio. It is not sensitive to local and sporadic amplitude fluctuations (such as individual wavelets) in the eigenvalue sequence, and can more stably reflect amplitude changes caused by systematic factors such as propagation path attenuation and transducer efficiency differences. It can effectively characterize the peak intensity of the echo signal and is an ideal indicator for measuring the overall amplitude relationship between uplink and downlink signals. At the same time, considering the possibility of wave errors, the maximum eigenvalue of the uplink is found from the uplink eigenvalue sequence and the maximum eigenvalue of the downlink is found from the downlink eigenvalue sequence, and the ratio of the two is used as the ratio of the maximum eigenvalues of the uplink and downlink.
[0074] According to an embodiment of the present invention, the correction update operation is applied to the downlink eigenvalue subsequence that has been shifted and aligned according to the current assumption. This means that the amplitude correction parameters are determined based on the assumption that they are data of corresponding waves, enabling the correction to optimize the amplitude relationship under this specific alignment assumption. Simultaneously, since the correction update operation only adjusts the amplitude of the eigenvalues in the sequence, without changing their position (index) or corresponding time information in the sequence, the correction update process does not disrupt the temporal correspondence established by the aforementioned shift alignment, does not introduce additional phase confusion, and ensures the correctness of subsequent time difference calculations.
[0075] Meanwhile, each downlink eigenvalue subsequence under a preset shift number is independently corrected and updated to match the uplink eigenvalue sequence as closely as possible on the amplitude scale. This ensures that when calculating the matching difference of all candidate schemes, the comparison is made on the same standard of eliminating amplitude system errors, so that the judgment and comparison focus on the matching degree of waveform structure.
[0076] In some embodiments, the step of determining the amplitude correction parameter based on the preset eigenvalue ratio interval and the uplink / downlink maximum eigenvalue ratio includes: determining whether the uplink / downlink maximum eigenvalue ratio is within the preset eigenvalue ratio interval; if the uplink / downlink maximum eigenvalue ratio is within the preset eigenvalue ratio interval, then determining the amplitude correction parameter based on the uplink / downlink maximum eigenvalue ratio; if the uplink / downlink maximum eigenvalue ratio is outside the preset eigenvalue ratio interval, then determining the amplitude correction parameter by fitting a function based on the corresponding parts of the uplink eigenvalue sequence and the downlink eigenvalue subsequence.
[0077] The preset feature value ratio range provided in this embodiment of the invention is derived from statistical analysis of a large amount of normal operating data, and its boundary defines a reasonable range in which the uplink and downlink amplitudes are basically consistent. Based on the above settings, the system intelligently switches between correction strategies of different complexities according to the severity of the difference between the uplink and downlink signal amplitudes. While ensuring computational efficiency, it achieves accurate amplitude adaptation for different attenuation conditions, thereby improving the accuracy and robustness of the overall alignment judgment.
[0078] According to a specific embodiment of the present invention, if the ratio of the maximum uplink and downlink eigenvalues falls within the preset eigenvalue ratio range, it means that the signal attenuation symmetry is good and it belongs to the normal working condition with basically consistent amplitude. At this time, simple global scaling is sufficient to compensate for the small amplitude difference (in this case, the amplitude correction parameter can also be directly defined as 1, and the downlink eigenvalue subsequence can be corrected based on parameter 1 (in this case, it can also be understood as not correcting or updating the downlink eigenvalue subsequence); the actual uplink and downlink eigenvalue ratio can also be used as the amplitude correction coefficient to fine-tune the downlink eigenvalue subsequence), and the calculation is simple, which can effectively improve the correction efficiency.
[0079] According to another specific embodiment of the present invention, when the ratio of the maximum eigenvalues of the uplink and downlink exceeds a preset eigenvalue ratio range, it indicates a severe asymmetry in the uplink and downlink attenuation, possibly accompanied by nonlinear factors (such as strong local scattering caused by bubbles), which is an abnormal operating condition with significant amplitude differences. In this case, by converting to a fitting function (such as fitting correction based on least squares methods), an amplitude correction parameter (linear or nonlinear) can be adaptively learned and established, thereby eliminating amplitude differences more precisely and achieving adaptive and high-precision correction optimization for the downlink eigenvalue subsequence. Determining the amplitude correction parameter through the fitting function may include: determining the correction parameter for linear amplitude correction through least squares fitting; or using monotonic nonlinear functions such as polynomial mapping and piecewise linear mapping to obtain the corresponding nonlinear amplitude correction parameter.
[0080] Step S103: Calculate the matching difference degree between each downlink feature value subsequence and the uplink feature value sequence, determine the target local wave shift number based on the matching difference degree, and determine the time-of-flight difference of the ultrasonic flowmeter based on the target local wave shift number.
[0081] Based on the above settings, the waveform alignment pattern recognition problem is transformed into a numerical optimization problem by using the matching difference degree as the criterion. By performing global optimization, a unique and reliable optimal waveform correspondence (i.e., the target local waveform shift number) is reliably locked, thus solving the core problem of waveform misalignment. Finally, by accurately mapping the optimal waveform correspondence back to the original time domain, a high-precision time difference of flight is obtained.
[0082] According to embodiments of the present invention, the matching dissimilarity is a scalar value (e.g., the sum of absolute differences or ratio deviations between sequences), which provides a unified and numerically comparable metric for all candidate alignment schemes. The calculation of the matching dissimilarity is typically based on the overall error (e.g., cumulative sum) of a local sequence segment (the overlapping portion of the downlink eigenvalue sequence after translation and alignment with the uplink eigenvalue sequence) or the entire sequence segment. This holistic measure is insensitive to local fluctuations and random noise in the sequence, but rather focuses on reflecting the degree of similarity between the two sequences in their overall shape and trend. Under correct alignment, the uplink eigenvalue sequence and the downlink eigenvalue subsequence should exhibit highly similar shapes (consistent amplitude fluctuation patterns), thus producing minimal matching dissimilarity; while incorrect alignment leads to disordered sequence shapes and a significantly increased dissimilarity.
[0083] For example, determining the target local wave shift based on the matching difference is essentially a global optimization decision, directly embodying a fundamental idea in signal processing—the most similar alignment is the most likely correct alignment. By traversing the search and selecting the extreme value of the matching difference, this method achieves a globally optimal decision within a given search range, ensuring that the found alignment is the most reliable under the current data. Simultaneously, the determined target local wave shift itself has clear physical meaning: it directly indicates how many complete local waves (i.e., integer periods) the downlink waveform needs to shift forward or backward to achieve the best structural match with the uplink waveform. This quantitative result is precisely the core parameter required to correct misaligned waveforms.
[0084] According to an embodiment of the present invention, the step of determining the time difference of flight based on the target local wave shift number completes the precise mapping from alignment relationship to physical quantity. It utilizes the determined target local wave shift number to find corresponding eigenvalue pairs in the uplink and downlink eigenvalue sequences. Since element i in the eigenvalue sequence is strictly bound to the timing information (peak / trough time) of the i-th local wave in the original waveform, determining the correspondence of eigenvalue pairs based on the target local wave shift number (e.g., the i-th uplink local wave corresponds to the (i+k)-th downlink local wave, where k is the assumed target local shift number) can be directly and unambiguously mapped to specific local waves. By locating the original local waves that generate these eigenvalues and calculating the peak or trough time difference of these corresponding local waves, the time difference of flight can be obtained.
[0085] In some embodiments, the step of determining the flight time difference of the ultrasonic flowmeter based on the target local wave shift number includes: determining one or more target feature value pairs in the upward feature value sequence and the downward feature value subsequence corresponding to the target local wave shift number; calculating the peak time difference based on the upward wave peak time and the downward wave peak time corresponding to the local wave to which any target feature value pair belongs; or, calculating the trough time difference based on the upward wave trough time and the downward wave trough time corresponding to the local wave to which any target feature value pair belongs, and using the peak time difference or the trough time difference as the flight time difference; or, calculating multiple peak time differences and / or multiple trough time differences based on multiple target feature value pairs, and using the average of the multiple peak time differences and / or multiple trough time differences as the flight time difference.
[0086] Based on the above settings, and ensuring the correct correspondence between uplink and downlink waveforms by using the target local wave shift number, multiple time-of-flight difference (TOF) calculation strategies are provided, which can adapt to different signal qualities and ultimately output a highly reliable and accurate TOF value.
[0087] Specifically, firstly, using the calculated target local wave shift, one or more corresponding target eigenvalue pairs are determined in the uplink eigenvalue sequence and its corresponding downlink eigenvalue subsequence. Since each eigenvalue in the sequence is uniquely associated with an original local wave, and each local wave contains precisely extractable peak and trough times, determining the correspondence of eigenvalue pairs is equivalent to determining the time anchor points of the two specific waveform segments for which the time difference of flight is to be calculated.
[0088] In time-domain waveforms, peaks and troughs are points where the rate of change of amplitude crosses zero, exhibiting significant characteristics. Interpolation algorithms (such as parabolic fitting) can determine the precise timing of their occurrence with accuracy higher than the sampling interval. Furthermore, under certain interference, peaks may become rounded and difficult to pinpoint precisely, while troughs may remain sharp; and vice versa. Based on the above, this approach provides two options (i.e., determining the time of flight based on peak time and determining the time of flight based on trough time), essentially offering backup solutions for different local waveform distortions. In practical applications, the phase point with the higher signal-to-noise ratio and greater stability can be selected for calculation based on preset rules or real-time judgment, enhancing the method's adaptability.
[0089] According to specific embodiments of the present invention, the final time difference can be calculated directly using a single target feature value pair, or it can be the average of the time differences calculated using multiple target feature value pairs. When the signal quality is good and the characteristics are clear, for example, directly selecting the feature value pair with the largest amplitude (usually corresponding to the main wave) for calculation is the most direct and efficient method. This is because the main wave usually has the strongest energy, is less affected by noise, and its peak / trough time measurement is the most accurate. However, when there is random noise in the signal or slight distortion in the local waveform, a single time difference measurement may have random errors. Calculating the arithmetic average of the time differences calculated from multiple (e.g., 3-5) consecutive and matched target feature value pairs can effectively smooth out these random errors using statistical laws, making the final result closer to the true value and significantly improving the robustness and repeatability of the measurement.
[0090] In some embodiments, the steps of calculating the matching difference between each downlink feature value subsequence and the uplink feature value sequence, and determining the target local wave shift number based on the matching difference, include: for each preset shift number: calculating the difference between the corresponding feature values in the uplink feature value sequence and the downlink feature value subsequence corresponding to the preset shift number, accumulating the absolute values of each difference to obtain a first cumulative sum; and determining the preset shift number with the smallest first cumulative sum as the target local wave shift number.
[0091] Based on the above settings, this invention provides a specific implementation method for calculating the matching difference degree. With extremely low computational complexity and a clear optimization objective, it achieves a reliable and robust judgment of the optimal alignment relationship between uplink and downlink feature value sequences. By calculating the sum of the absolute values of the differences between corresponding feature values, this specific implementation method transforms the overall similarity of two sequences into a single scalar value (the first sum). This value intuitively reflects the cumulative deviation of the two sequences at each corresponding point. The calculation process is simple and direct, making it very suitable for efficient execution in environments with limited computing resources, such as embedded systems.
[0092] Specifically, firstly, the difference between corresponding eigenvalues directly measures the numerical deviation of the two sequences at each specific corresponding position. Under ideal alignment, the corresponding eigenvalues should be nearly equal, with the difference close to zero; however, under misalignment, irrelevant eigenvalues are paired, resulting in a larger difference. Secondly, the operation of taking the absolute value of each difference ensures that positive and negative deviations contribute equally to the overall matching difference. Finally, the operation of summing the absolute values of each difference aggregates the absolute deviations at all positions into a sum (i.e., the first sum mentioned above). This sum measures the overall mismatch between the two sequences over the entire comparison interval. The smaller the first sum, the closer the values of the two sequences are at all corresponding points, and the higher the overall matching degree.
[0093] For example, the step of determining the minimum preset shift value of the first accumulated sum as the target local wave shift value embodies an explicit optimal decision. In signal processing and pattern recognition, minimizing the difference is a classic and effective criterion for finding the best match. In the example above, the minimum value of the first accumulated sum, as the matching difference, directly corresponds to the integer offset that makes the overall uplink and downlink feature value sequences closest, and its physical meaning is the correct misalignment value to be found.
[0094] According to a specific embodiment of the present invention, in the step of calculating the difference between the corresponding feature values in the uplink feature value sequence and the downlink feature value subsequence corresponding to the preset shift number, the difference between the feature values corresponding to the overlapping parts of the two sequences can be directly calculated. In this case, the downlink feature value subsequence corresponding to the preset shift number can be uncorrected. It is understood that if a corrected and updated downlink feature value subsequence is used, the difference can be calculated for the feature values corresponding to all elements in the two sequences.
[0095] In some embodiments, the step of calculating the matching difference between each downlink feature value subsequence and the uplink feature value sequence, and determining the target local wave shift number based on the matching difference, further includes: for each preset shift number: calculating the ratio of the corresponding feature value in the uplink feature value sequence and the downlink feature value subsequence corresponding to the preset shift number; determining the maximum uplink feature value and the maximum downlink feature value in the uplink feature value sequence and the downlink feature value sequence respectively, to calculate the ratio of the maximum uplink and downlink feature values; summing the absolute values of the differences between each ratio and the maximum feature value ratio to obtain a second sum; and determining the preset shift number with the smallest second sum as the target local wave shift number.
[0096] Based on the above settings, this invention provides another specific implementation method for calculating the matching difference, which avoids measuring the absolute amplitude difference and instead examines the overall synergy of the uplink and downlink signal amplitude ratios. By using the global maximum eigenvalue ratio as a benchmark, it checks the consistency of local ratios (the proportional relationship of individual eigenvalue pairs), achieving a precise measurement of the matching degree of the uplink and downlink signal amplitude variation patterns. This provides a more sensitive and accurate alignment judgment criterion in scenarios where amplitudes exhibit approximately proportional changes. This implementation method is particularly suitable for scenarios where the uplink and downlink signal attenuation has an approximately linear relationship, and can identify with high sensitivity the alignment method that makes the amplitude variation patterns of the two signals most coordinated. It provides an important tool for determining the target local wave shift number of this invention, complementing the sum of absolute differences and sometimes even being more discriminative, further enhancing the adaptability and robustness of the method under different signal characteristics.
[0097] Specifically, according to the specific implementation of the embodiments of the present invention, firstly, for each pair of aligned eigenvalues in the two sets of sequences, their ratio (uplink eigenvalue / downlink eigenvalue) is calculated. This ratio directly reflects the relative amplitude relationship between the two sequences at corresponding positions. If the uplink and downlink signals have undergone consistent attenuation or have a constant gain difference, this ratio should remain relatively constant at all points. Simultaneously, calculating the ratio is equivalent to performing a local normalization on the data, transforming the absolute amplitude difference into a dimensionless scaling factor, making subsequent comparisons insensitive to the overall absolute gain difference between the two signals, and focusing more on whether this scaling relationship is stable in the sequence. Secondly, the maximum values are found from the original uplink and downlink eigenvalue sequences respectively, and their ratio is calculated as the uplink-downlink maximum eigenvalue ratio. The maximum eigenvalue usually corresponds to the part of the signal with the strongest energy (such as the main wave), is less affected by noise, and is robust in estimation. The uplink-downlink maximum eigenvalue ratio can most reliably represent the overall amplitude scaling relationship of the uplink and downlink signals at peak energy, and is an ideal global reference anchor point. Thirdly, the absolute deviation of each ratio from the global reference ratio is calculated and accumulated to obtain a second sum. The magnitude of the second sum directly reflects the degree of fluctuation in the local amplitude ratio around the global reference. Under the correct alignment assumption, since the corresponding local waves in the uplink and downlink undergo similar physical processes, their amplitude ratios should be highly consistent, with all local ratios closely revolving around the global reference, resulting in a small second sum. If the alignment is incorrect, the forcibly paired local waves are physically unrelated, and their amplitude ratios will be random, with large and chaotic deviations from the global reference, causing the second sum to increase sharply. This makes the second sum an effective indicator for distinguishing between correct and incorrect alignment. Finally, the second sum corresponding to all preset shift values is compared, and the smallest one is selected as the target local wave shift value.
[0098] According to a specific embodiment of the present invention, in the step of calculating the ratio of corresponding feature values in the uplink feature value sequence and the downlink feature value subsequence corresponding to the preset shift, the ratio of feature values corresponding to the overlapping portion of the two sequences can be directly calculated. In this case, the downlink feature value subsequence corresponding to the preset shift can be uncorrected. It is understood that if a corrected and updated downlink feature value subsequence is used, the ratio can be calculated for the feature values corresponding to all elements in the two sequences.
[0099] The time-of-flight difference (TOF) calculation method for ultrasonic flowmeters provided in this embodiment of the invention overcomes the limitations of related technologies by dividing the upstream and downstream echo signals of the ultrasonic flowmeter into multiple continuous local waves, extracting feature values representing the amplitude range of each local wave, and sorting the feature values according to the sampling time of the local waves to obtain an upstream feature value sequence and a downstream feature value sequence. Each local wave includes a trough and an adjacent peak. Within a preset integer local wave shift interval, for each preset shift, the downstream feature value sequence is shifted and aligned relative to the upstream feature value sequence according to the preset shift, resulting in an aligned downstream feature value subsequence. The matching difference degree between each downstream feature value subsequence and the upstream feature value sequence is calculated, and the target local wave shift degree is determined based on the matching difference degree. Finally, the time-of-flight difference of the ultrasonic flowmeter is determined based on the target local wave shift degree. The current method for calculating the time-of-flight difference (TOF) in ultrasonic flow meters suffers from significant errors due to amplitude attenuation and waveform distortion in echo signals under actual operating conditions. This leads to deviations in the accuracy of fluid flow measurement and limits the application scenarios of ultrasonic flow meters. To address this, a new method is implemented. This method extracts characteristic values representing the amplitude range of local waves from the continuous local waves corresponding to the uplink and downlink echo signals, respectively, to determine the uplink and downlink characteristic value sequences. This quantifies the waveform energy and amplitude transformation degree of the local waves. Furthermore, by performing shift alignment and matching difference comparison of the uplink and downlink characteristic value sequences within integer local wave shift intervals, the method can accurately identify and correct waveform misalignment within integer periods, avoiding interference from amplitude attenuation and waveform distortion. This significantly improves the accuracy of TOF calculation, ensures the accuracy of fluid flow measurement, and further expands the application scenarios of ultrasonic flow meters.
[0100] Based on the above-described method for calculating the time-of-flight difference of an ultrasonic flowmeter provided in the embodiments of the present invention, the embodiments of the present invention also provide a device for calculating the time-of-flight difference of an ultrasonic flowmeter, such as... Figure 3 As shown, the time-of-flight difference calculation device 300 of the ultrasonic flow meter includes:
[0101] The signal processing module 301 is used to divide the upstream echo signal and downstream echo signal corresponding to the ultrasonic flow meter into multiple continuous local waves, extract feature values representing the amplitude range of each local wave, and sort the feature values according to the sampling time of the local wave to obtain an upstream feature value sequence and a downstream feature value sequence; wherein, the local wave includes a trough and a peak adjacent to the trough.
[0102] Based on the above setup, by dividing local waves, extracting eigenvalues, and constructing eigenvalue sequences, the susceptible and unstable echo signal is creatively transformed into a sequence of discrete eigenvalues characterizing the energy intensity of local waves. This transformation method significantly suppresses the impact of random noise and local irregular distortions in the signal on subsequent processing. At the same time, by focusing on the eigenvalues characterizing the amplitude range of each local wave, the core criterion for finding the correspondence between uplink and downlink waveforms (target local wave shift) is the energy intensity distribution pattern of each local wave. This provides the entire method with high-quality input data (eigenvalue sequences) that can withstand interference from complex operating conditions, and serves as the data foundation for achieving high-precision, robust alignment and accurate time-of-flight difference calculation.
[0103] In some embodiments, the signal processing module 301 is further configured to: determine the local maximum amplitude and local minimum amplitude of each local wave; calculate the difference between the local maximum amplitude and the local minimum amplitude as a feature value; or, perform nonlinear curve fitting based on the local maximum amplitude and the local minimum amplitude of each local wave to determine the peak amplitude and trough amplitude of the local wave, and calculate the difference between the peak amplitude and the trough amplitude as a feature value.
[0104] Based on the above settings, two specific implementation methods for feature extraction are provided, which offer a highly robust solution for the energy / intensity quantization of local waves that can flexibly balance accuracy and efficiency.
[0105] The shift processing module 302 is used to, within a preset integer local wave shift range, for each preset shift number: shift and align the downlink feature value sequence relative to the uplink feature value sequence according to the preset shift number to obtain the aligned downlink feature value subsequence.
[0106] Based on the above settings, in order to accurately identify and correct the integer period waveform misalignment (i.e., waveform misalignment) between the uplink and downlink echo signals caused by physical factors such as flow velocity, the downlink feature value sequence is shifted and aligned relative to the uplink feature value sequence within a limited and preset integer local waveform shift range. All possible candidate alignment relationships are systematically generated to provide an objective and quantitative standard form for subsequent matching difference calculation.
[0107] In some embodiments, the time-of-flight difference calculation device 300 of the ultrasonic flowmeter further includes a correction and update module. After the step of aligning the downlink feature value sequence relative to the uplink feature value sequence according to a preset shift number to obtain the aligned downlink feature value subsequence, that is, before the step of calculating the matching difference degree between each downlink feature value subsequence and the uplink feature value sequence, the correction and update module is used to: determine the uplink maximum feature value and the downlink maximum feature value from the uplink feature value sequence and the downlink feature value sequence respectively; calculate the ratio between the uplink maximum feature value and the downlink maximum feature value as the uplink-downlink maximum feature value ratio; determine the amplitude correction parameter according to the preset feature value ratio range and the uplink-downlink maximum feature value ratio; and perform amplitude correction update on the downlink feature value subsequence according to the amplitude correction parameter to obtain the corrected and updated downlink feature value subsequence.
[0108] Based on the above settings, before calculating the matching difference between each downlink eigenvalue subsequence and the uplink eigenvalue sequence, and then determining the target local wave shift number based on the matching difference, an amplitude correction parameter determined based on the ratio of the maximum uplink and downlink eigenvalues is introduced to correct and update the downlink eigenvalue subsequence. This eliminates or reduces the interference of systematic amplitude differences between uplink and downlink echo signals caused by asymmetric factors such as propagation path differences and uneven attenuation on the matching judgment. This further ensures that the matching difference obtained in subsequent calculations can more purely reflect the time alignment error, thereby improving the accuracy of the target local wave shift number.
[0109] In some embodiments, the above-mentioned correction update module is further configured to: determine whether the ratio of the maximum uplink and downlink eigenvalues is within a preset eigenvalue ratio range; if the ratio of the maximum uplink and downlink eigenvalues is within the preset eigenvalue ratio range, then determine the amplitude correction parameter based on the ratio of the maximum uplink and downlink eigenvalues; if the ratio of the maximum uplink and downlink eigenvalues is outside the preset eigenvalue ratio range, then determine the amplitude correction parameter based on the corresponding parts in the uplink eigenvalue sequence and the downlink eigenvalue subsequence by using a fitting function.
[0110] Based on the above settings, the system intelligently switches between correction strategies of varying complexity according to the severity of the difference between uplink and downlink signal amplitudes. This ensures computational efficiency while achieving precise amplitude adaptation for different attenuation conditions, thereby improving the accuracy and robustness of the overall alignment judgment.
[0111] The time-of-flight difference determination module 303 is used to calculate the matching difference degree between each downlink feature value subsequence and the uplink feature value sequence, determine the target local wave shift number based on the matching difference degree, and determine the time-of-flight difference of the ultrasonic flowmeter based on the target local wave shift number.
[0112] Based on the above settings, the waveform alignment pattern recognition problem is transformed into a numerical optimization problem by using the matching difference degree as the criterion. By performing global optimization, a unique and reliable optimal waveform correspondence (i.e., the target local waveform shift number) is reliably locked, thus solving the core problem of waveform misalignment. Finally, by accurately mapping the optimal waveform correspondence back to the original time domain, a high-precision time difference of flight is obtained.
[0113] In some embodiments, the flight time difference determination module 303 is further configured to: determine one or more target feature value pairs in the uplink feature value sequence and the downlink feature value subsequence corresponding to the target local shift number based on the target local wave shift number; calculate the peak time difference based on the uplink peak time and downlink peak time corresponding to the local wave to which any target feature value pair belongs; or, calculate the trough time difference based on the uplink trough time and downlink trough time corresponding to the local wave to which any target feature value pair belongs, and use the peak time difference or trough time difference as the flight time difference; or, calculate multiple peak time differences and / or multiple trough time differences based on multiple target feature value pairs, and use the average of the multiple peak time differences and / or multiple trough time differences as the flight time difference.
[0114] Based on the above settings, and ensuring the correct correspondence between uplink and downlink waveforms by using the target local wave shift number, multiple time-of-flight difference (TOF) calculation strategies are provided, which can adapt to different signal qualities and ultimately output a highly reliable and accurate TOF value.
[0115] In some embodiments, the flight time difference determination module 303 is further configured to: for each preset shift number: calculate the difference between the corresponding feature value in the uplink feature value sequence and the downlink feature value subsequence corresponding to the preset shift number, accumulate the absolute values of each difference to obtain a first sum; and determine the preset shift number with the smallest first sum as the target local wave shift number.
[0116] Based on the above settings, this invention provides a specific implementation method for calculating the matching difference degree. With extremely low computational complexity and a clear optimization objective, it achieves a reliable and robust judgment of the optimal alignment relationship between uplink and downlink feature value sequences. By calculating the sum of the absolute values of the differences between corresponding feature values, this specific implementation method transforms the overall similarity of two sequences into a single scalar value (the first sum). This value intuitively reflects the cumulative deviation of the two sequences at each corresponding point. The calculation process is simple and direct, making it very suitable for efficient execution in environments with limited computing resources, such as embedded systems.
[0117] In some embodiments, the flight time difference determination module 303 is further configured to: for each preset shift number: calculate the ratio of the corresponding eigenvalue in the uplink eigenvalue sequence and the downlink eigenvalue subsequence corresponding to the preset shift number; determine the maximum uplink eigenvalue and the maximum downlink eigenvalue in the uplink eigenvalue sequence and the downlink eigenvalue sequence respectively; calculate the ratio of the maximum uplink and downlink eigenvalues; accumulate the absolute values of the differences between each ratio and the ratio of the maximum eigenvalue to obtain a second sum; and determine the preset shift number with the smallest second sum as the target local wave shift number.
[0118] Based on the above settings, this invention provides another specific implementation method for calculating the matching difference, which avoids measuring the absolute amplitude difference and instead examines the overall synergy of the uplink and downlink signal amplitude ratios. By using the global maximum eigenvalue ratio as a benchmark, it checks the consistency of local ratios (the proportional relationship of individual eigenvalue pairs), achieving a precise measurement of the matching degree of the uplink and downlink signal amplitude variation patterns. This provides a more sensitive and accurate alignment judgment criterion in scenarios where amplitudes exhibit approximately proportional changes. This implementation method is particularly suitable for scenarios where the uplink and downlink signal attenuation has an approximately linear relationship, and can identify with high sensitivity the alignment method that makes the amplitude variation patterns of the two signals most coordinated.
[0119] The time-of-flight difference (TOF) calculation device for the ultrasonic flowmeter provided in this embodiment of the invention, through a signal processing module, divides multiple continuous local waves from the uplink and downlink echo signals corresponding to the ultrasonic flowmeter, extracts feature values representing the amplitude range of each local wave, and sorts the feature values according to the sampling time of the local wave to obtain an uplink feature value sequence and a downlink feature value sequence; wherein, each local wave includes a trough and a peak adjacent to the trough; a shift processing module is used to, within a preset integer local wave shift range, for each preset shift number: shift and align the downlink feature value sequence relative to the uplink feature value sequence according to the preset shift number to obtain an aligned downlink feature value subsequence; a time-of-flight difference (TOF) determination module is used to calculate the matching difference degree between each downlink feature value subsequence and the uplink feature value sequence, determine the target local wave shift number according to the matching difference degree, and determine the TOF of the ultrasonic flowmeter according to the target local wave shift number. This technology quantifies the waveform energy and amplitude transformation of local waves. By performing shift alignment and matching difference comparison of the up and down characteristic value sequences within the integer local wave shift range, it can accurately identify and correct waveform misalignment of integer periods, avoiding interference from amplitude attenuation and waveform distortion. This significantly improves the accuracy of time-of-flight calculation, ensures the accuracy of fluid flow measurement, and further expands the application scenarios of ultrasonic flow meters.
[0120] This invention also provides a non-transitory machine-readable medium storing a computer program, wherein the computer program, when executed by a computer's processor, is used to cause the computer to perform a method according to an embodiment of this invention.
[0121] This invention also provides a computer program product, including a computer program, wherein the computer program, when executed by a computer's processor, is used to cause the computer to perform the methods of embodiments of this invention. The computer program product should be understood as a software product that primarily implements the methods of this invention through a computer program.
[0122] This invention also provides an electronic device, including: at least one processor, and a memory storing a computer program executable by the at least one processor, the computer program including instructions that, when executed by the processor, cause the processor to perform the time-of-flight difference calculation method of any of the above-described ultrasonic flow meters.
[0123] refer to Figure 4 The present invention will now be described in the form of a structural block diagram of an electronic device that can serve as an embodiment of the present invention, which is an example of a hardware device that can be applied to various aspects of the present invention. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0124] like Figure 4As shown, the electronic device includes a processor unit 401, which can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor unit 401 include, but are not limited to, MCUs, CPUs, graphics processing units (GPUs), various special-purpose artificial intelligence (AI) computing units, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any suitable processor, controller, microcontroller, etc. Processor unit 401 is used to perform the various methods and processes described above. For example, in some embodiments, the method embodiments of the present invention may be implemented as a computer program tangibly contained in a machine-readable medium, such as external storage unit 407. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device via local storage unit 402 and / or communication unit 408. In some embodiments, processor unit 401 may be configured to perform the methods described above by any other suitable means (e.g., by means of firmware).
[0125] Specifically, the processor unit 401 can perform various appropriate actions and processes based on computer programs stored in the local storage unit 402 (which can be a ROM storage unit or other storage-enabled devices) or computer programs loaded into the local storage unit 402 (such as random access memory RAM) from the external storage unit 407. The local storage unit 402 can also store various programs and data required for the operation of the electronic device. The processor unit 401 and the local storage unit 402 are interconnected via a bus 403. The input / output (I / O) interface 404 is also connected to the bus 403.
[0126] Multiple components in the electronic device are connected to I / O interface 404, including: input unit 405, output unit 406, external storage unit 407, and communication unit 408. Input unit 405 can be any type of device capable of inputting information into the electronic device. Input unit 405 can receive input digital or character information and generate key signal inputs related to user settings and / or function control of the electronic device. Output unit 406 can be any type of device capable of presenting information and may include, but is not limited to, a display, speaker, video / audio output terminal, vibrator, and / or printer. External storage unit 407 may include, but is not limited to, disks and optical discs. Communication unit 408 allows the electronic device to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks, and may include, but is not limited to, modems, network cards, infrared communication devices, and / or wireless communication transceivers, such as Bluetooth devices, WiFi devices, WiMax devices, cellular communication devices, and / or the like.
[0127] Computer programs for implementing the methods of embodiments of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0128] In the context of embodiments of the present invention, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable signal medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, or infrared systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0129] It should be noted that the term "comprising" and its variations used in the embodiments of the present invention are open-ended, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The modifications of "one" and "multiple" mentioned in the embodiments of the present invention are illustrative and not restrictive. Those skilled in the art should understand that, unless explicitly indicated otherwise in the context, they should be understood as "one or more".
[0130] The information and data involved in the embodiments of this invention (including but not limited to information and data used for analysis, stored information and data, displayed information and data, etc.) are all information and data that have been permitted by the user or fully agreed by all parties. Furthermore, the collection, use and processing of such information and data must comply with relevant laws, regulations and standards, and corresponding operation entry points are provided for users to choose to agree or refuse.
[0131] The steps described in the method embodiments provided by this invention can be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of protection of this invention is not limited in this respect.
[0132] The term "embodiment" in this specification refers to a specific feature, structure, or characteristic described in connection with an embodiment that may be included in at least one embodiment of the invention. The appearance of this phrase in various places in the specification does not necessarily imply the same embodiment, nor does it imply independence or alternativeity from other embodiments. The various embodiments in this specification are described in a related manner, with reference to each other for similar or identical parts. In particular, for apparatus, device, and system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, and relevant details are referred to in the description of the method embodiments.
[0133] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of protection. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these all fall within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the appended claims.
Claims
1. A method for calculating the time difference of flight of an ultrasonic flowmeter, characterized in that, include: Multiple continuous local waves are obtained from the upward and downward echo signals corresponding to the ultrasonic flow meter. Feature values characterizing the amplitude range of each local wave are extracted. The feature values are sorted according to the sampling time of the local wave to obtain an upward feature value sequence and a downward feature value sequence. Each local wave includes a trough and a peak adjacent to the trough. Within a preset integer local wave shift range, for each preset shift number: the downlink feature value sequence is shifted and aligned relative to the uplink feature value sequence according to the preset shift number to obtain an aligned downlink feature value subsequence; Calculate the matching difference degree between each of the downlink feature value subsequences and the uplink feature value sequence, determine the target local wave shift number based on the matching difference degree, and determine the time-of-flight difference of the ultrasonic flowmeter based on the target local wave shift number.
2. The method according to claim 1, characterized in that, Prior to the step of calculating the matching difference between each of the downlink feature value subsequences and the uplink feature value sequence, the method further includes: The maximum eigenvalue of the uplink and the maximum eigenvalue of the downlink are determined from the uplink eigenvalue sequence and the downlink eigenvalue sequence, respectively. The ratio between the maximum eigenvalue of the uplink and the maximum eigenvalue of the downlink is calculated as the ratio of the maximum eigenvalues of the uplink and downlink. The amplitude correction parameters are determined based on the preset eigenvalue ratio range and the maximum uplink / downlink eigenvalue ratio. Based on the amplitude correction parameters, the downlink feature value subsequence is updated with amplitude correction to obtain the corrected and updated downlink feature value subsequence.
3. The method according to claim 1, characterized in that, The step of extracting feature values characterizing the amplitude range of each local wave includes: Determine the local maximum amplitude and local minimum amplitude for each of the local waves; The difference between the local maximum amplitude and the local minimum amplitude is calculated as the feature value; or, a nonlinear curve is fitted based on the local maximum amplitude and the local minimum amplitude of each local wave to determine the peak amplitude and trough amplitude of the local wave, and the difference between the peak amplitude and the trough amplitude is calculated as the feature value.
4. The method according to claim 2, characterized in that, The step of determining the amplitude correction parameter based on the preset eigenvalue ratio range and the maximum uplink / downlink eigenvalue ratio includes: Determine whether the ratio of the maximum uplink to downlink eigenvalue is within the preset eigenvalue ratio range; If the maximum eigenvalue ratio of uplink and downlink is within the preset eigenvalue ratio range, then the amplitude correction parameter is determined based on the maximum eigenvalue ratio of uplink and downlink. If the maximum uplink-to-downlink eigenvalue ratio is outside the preset eigenvalue ratio range, the amplitude correction parameter is determined by a fitting function based on the corresponding parts of the uplink eigenvalue sequence and the downlink eigenvalue subsequence.
5. The method according to claim 1, characterized in that, The step of calculating the matching difference degree between each of the downlink eigenvalue subsequences and the uplink eigenvalue sequence, and determining the target local wave shift number based on the matching difference degree, includes: For each preset shift number: calculate the difference between the uplink feature value sequence and the corresponding feature value in the downlink feature value subsequence corresponding to the preset shift number, and sum the absolute values of each difference to obtain a first summation; The preset shift number that minimizes the first cumulative sum is determined as the target local wave shift number.
6. The method according to claim 1, characterized in that, The step of calculating the matching difference degree between each of the downlink eigenvalue subsequences and the uplink eigenvalue sequence, and determining the target local wave shift number based on the matching difference degree, includes: For each preset shift number: calculate the ratio of the corresponding feature value in the uplink feature value sequence and the corresponding feature value in the downlink feature value subsequence corresponding to the preset shift number; determine the maximum uplink feature value and the maximum downlink feature value in the uplink feature value sequence and the downlink feature value sequence respectively; calculate the ratio of the maximum uplink and downlink feature values; accumulate the absolute values of the differences between each ratio and the ratio of the maximum feature value to obtain a second accumulated sum. The preset shift number that minimizes the second sum is determined as the target local wave shift number.
7. The method according to claim 1, characterized in that, The step of determining the time-of-flight difference of the ultrasonic flowmeter based on the target local wave shift number includes: Based on the target local wave shift number, determine one or more target feature value pairs in the uplink feature value sequence and the downlink feature value subsequence corresponding to the target local wave shift number; Based on the rising peak time and falling peak time of the corresponding local wave corresponding to any one of the target feature values, the peak time difference is calculated; or, based on the rising trough time and falling trough time of the corresponding local wave corresponding to any one of the target feature values, the trough time difference is calculated, and the peak time difference or the trough time difference is used as the flight time difference; or, Based on multiple target feature value pairs, multiple peak time differences and / or multiple trough time differences are calculated respectively, and the average value of the multiple peak time differences and / or the multiple trough time differences is used as the flight time difference.
8. A time-of-flight calculation device for an ultrasonic flow meter, characterized in that, include: The signal processing module is used to divide the upstream echo signal and downstream echo signal corresponding to the ultrasonic flow meter into multiple continuous local waves, extract feature values representing the amplitude range of each local wave, and sort the feature values according to the sampling time of the local wave to obtain an upstream feature value sequence and a downstream feature value sequence; wherein, each local wave includes a trough and a peak adjacent to the trough; The shift processing module is used to, within a preset integer local wave shift range, for each preset shift number: shift and align the downlink feature value sequence relative to the uplink feature value sequence according to the preset shift number to obtain an aligned downlink feature value subsequence; The time-of-flight difference determination module is used to calculate the matching difference degree between each of the downlink feature value subsequences and the uplink feature value sequences, determine the target local wave shift number based on the matching difference degree, and determine the time-of-flight difference of the ultrasonic flowmeter based on the target local wave shift number.
9. An electronic device, comprising: A processor and a memory storing a program, characterized in that the program includes instructions that, when executed by the processor, cause the processor to perform the method according to any one of claims 1-7.
10. A non-transitory machine-readable medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-7.
Citation Information
Patent Citations
Method for determining flight time of ultrasonic flowmeter and related equipment
CN120352015A
Echo signal detection method of ultrasonic flowmeter and related equipment
CN120446924A