A lightweight implementation method of cross-correlation algorithm in ultrasonic flow measurement

By adopting a lightweight designed cross-correlation algorithm in the ultrasonic flowmeter, and utilizing frequency domain processing and cubic spline interpolation, the problems of low flight time difference measurement accuracy and insufficient anti-noise capability in the existing technology are solved, and higher measurement accuracy is achieved. accuracy and a wider range of applications.

CN114254253BActive Publication Date: 2024-09-20DALIAN UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111148649.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-29
Publication Date
2024-09-20
Estimated Expiration
2041-09-29

AI Technical Summary

Technical Problem

When existing ultrasonic flowmeters measure the time of flight difference, due to the resonance characteristics of the ultrasonic transducer and the attenuation and noise interference during ultrasonic propagation, the measurement accuracy is low, the applicable occasions are limited, and the repeatability is poor, making it difficult to accurately determine the threshold voltage of the received signal. , the waveform signal cross-wave phenomenon occurs.

Method used

Using a lightweight design cross-correlation algorithm, the microcontroller alternately outputs pulse signals in time to drive the ultrasonic transducer, samples the echo signal, and performs fast Fourier transform, band-pass filtering, frequency domain cross-correlation operation and cubic spline Interpolation, calculating time-of-flight differences to improve accuracy and immunity to noise interference.

Benefits of technology

It improves the measurement accuracy and anti-clutter signal interference ability of the ultrasonic flowmeter, expands the application scenarios, reduces the computational complexity of the algorithm, reduces the requirements for hardware performance, and ensures accurate estimation of flight time difference.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114254253B
    Figure CN114254253B
Patent Text Reader

Abstract

The present invention discloses a lightweight implementation method of a cross-correlation algorithm in ultrasonic flow measurement, comprising the following steps: arranging a pair of ultrasonic transducers at two positions, upstream and downstream, of a fluid pipeline, wherein the ultrasonic transducers have the functions of sending and receiving ultrasonic waves; sampling the two groups of echo signals respectively to obtain discrete digital signals; converting the signals from the time domain to the frequency domain, and then performing bandpass filtering processing; performing discrete cross-correlation operations on the two groups of signals in the frequency domain; performing inverse Fourier transform on the discrete cross-correlation function; performing cubic spline interpolation processing on the discrete cross-correlation function, fitting the key part curve, obtaining the maximum value point, and obtaining the flight time difference accordingly; thereby calculating the instantaneous and cumulative flow values. The present invention improves the anti-interference capability of measurement, greatly reduces the amount of calculation, realizes the lightweight of the cross-correlation algorithm, enables the calculation results of the cross-correlation algorithm to be used for actual measurement, and improves the measurement accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of flow detection, and relates to the application of a cross-correlation algorithm on an ultrasonic flow meter, in particular to an ultrasonic flow meter based on the principle of a time difference method. Background Art

[0002] Measurement is the eye of the industrial production process. It can accurately and real-timely know the changes of various parameters in the production process, and plays an important role in the safety and quality control of industrial production. Flow measurement is one of the components of measurement science and technology, and it is closely related to the national economy, national defense construction, and scientific research. Nowadays, the rapid development of chip technology and fluid mechanics has brought flow measurement technology to a new level. It no longer requires stability in the measurement process, but pursues the accuracy of the measurement results. Therefore, the measurement accuracy and stability of the instrument have attracted much attention.

[0003] It is urgent to innovate flow measurement methods and improve instrument accuracy and stability.

[0004] The key to ultrasonic flowmeter based on time difference method lies in the accuracy of the difference between the downstream flight time and the upstream flight time of the ultrasonic wave, that is, the flight time difference. Only when the flight time difference is accurate can the corresponding flow value be calculated based on the relationship between it and the flow velocity and flow rate of the measured fluid.

[0005] At present, the method for measuring the flight time difference is mainly based on the threshold comparison method. The arrival time of the first wave is determined by comparing the time when the front edge of the upstream and downstream echo signals reaches a certain threshold voltage. During this period, a high-precision time digital chip is used to calculate the time to obtain the upstream and downstream flight times, and then the flight time difference is calculated based on this. In actual ultrasonic flow meter applications, this method is difficult to accurately determine when the received signal reaches the threshold voltage due to the resonant characteristics of the ultrasonic transducer and the attenuation and noise interference of the ultrasonic wave during the propagation process. In addition, waveform signal stringing may occur, resulting in a series of problems such as limited application occasions of the flow meter, poor repeatability, and low measurement accuracy. Summary of the invention

[0006] In view of the defects existing in the prior art of time-difference ultrasonic flowmeter, the purpose of the present invention is to provide a more lightweight cross-correlation algorithm to calculate the flight time difference, thereby avoiding the large error in measuring the flight time difference by the threshold comparison method of the prior art. The present invention adopts a lightweight digital correlation method to calculate the flight time difference, thereby improving the accuracy and anti-noise interference ability of the ultrasonic flowmeter.

[0007] In order to achieve the above object, the present invention provides a lightweight implementation method of a cross-correlation algorithm in ultrasonic flow measurement, comprising the following steps:

[0008] S1. A pair of ultrasonic transducers are arranged at two positions, upstream and downstream, of the straight pipe type fluid pipeline, respectively, and the ultrasonic transducers have the functions of sending and receiving ultrasonic waves;

[0009] Among them, the two position points alternately send out ultrasonic signals in time, propagate through the fluid in the pipeline, and receive echo signals at the corresponding position points respectively; the echo signals are electrical signals. More specifically, the two position points drive the ultrasonic transducer and then excite the ultrasonic signals through the pulse signals output by the microcontroller in time and in time; the ultrasonic signals are alternately sent out in time and in time, propagate through the fluid in the pipeline, and receive echo signals at the corresponding position points respectively; the echo signals are electrical signals.

[0010] This pair of transducers, through the pulse driving signal output by the microcontroller to the upstream ultrasonic transducer, the upstream transducer will excite the ultrasonic signal, and the downstream transducer will receive the upstream echo signal; after that, the two are exchanged, the microcontroller's driving signal is given to the downstream transducer, the downstream transducer excites the ultrasonic signal, and the upstream transducer will receive the downstream echo signal, thus obtaining the upstream and downstream echo signals.

[0011] S2, sampling the two groups of echo signals respectively to obtain discrete digital signals;

[0012] S3, performing fast Fourier transform on the digital signal to convert the two groups of echo signals from the time domain to the frequency domain;

[0013] S4, performing bandpass filtering on the two groups of echo signals obtained in step S3 in the frequency domain to obtain a downstream filtered discrete frequency domain signal Y′(n) and an upstream filtered discrete frequency domain signal X′(n);

[0014] S5, performing a discrete cross-correlation operation in the frequency domain on the two groups of echo signals obtained in step S4;

[0015] Specifically, the conjugate operation is performed on the downstream filtered discrete frequency domain signal Y′(n) to obtain the conjugate output Then perform a product operation with the upstream filtered discrete frequency domain signal X′(n) to obtain a frequency domain discrete output sequence of the cross-correlation function;

[0016] S6, performing inverse Fourier transform on the discrete cross-correlation function, and inversely transforming the two groups of echo signals obtained in step S5 from the frequency domain back to the time domain;

[0017] Specifically, the frequency domain discrete output sequence of the cross-correlation function is subjected to inverse fast Fourier transform to obtain the time domain discrete output sequence R of the cross-correlation function. yx (τ);

[0018] S7, performing cubic spline interpolation processing on the discrete cross-correlation function, fitting the key part curve, finding the maximum value point, and obtaining the flight time difference based on it;

[0019] Specifically, the method of cubic spline interpolation is used to interpolate and fit the time-domain discrete output sequence of the cross-correlation function to obtain the time-domain continuous output polynomial of the cross-correlation function, and then the displacement time corresponding to the zero second-order derivative of the cubic fitting polynomial is calculated, that is, the displacement time corresponding to the maximum output point of the cross-correlation function, so as to obtain an accurate estimate of the flight time difference;

[0020] S8, based on the relationship between the flight time difference and the fluid flow rate, and according to the flow definition, the instantaneous and cumulative flow values ​​are calculated.

[0021] In a preferred embodiment, the method of step S2 is: using a high-speed analog-to-digital converter to perform high-speed sampling on the received upstream echo signal x(t) and downstream echo signal y(t), respectively, to obtain the upstream original discrete echo time domain signal x(n) and the downstream original discrete echo time domain signal y(n).

[0022] The method of step S3 is: using fast Fourier transform to transform the upstream and downstream original discrete echo time domain signals to obtain the upstream and downstream discrete echo frequency domain signals X(n) and Y(n).

[0023] The method of step S4 is: bandpass filtering X(n) and Y(n) in the frequency domain to filter out clutter signals, thereby obtaining an upstream filtered discrete frequency domain signal X′(n) and a downstream filtered discrete frequency domain signal Y′(n).

[0024] The method of step S8 is: according to the flight time difference estimation, the fluid flow rate, instantaneous flow rate and cumulative flow rate are calculated in sequence. Specifically, the method of this document <<Research on Mono-channel Gas Ultrasonic Flowmeter Based on Time Difference Method>> can be referred to (Wei Eyuan. Research on Mono-channel Gas Ultrasonic Flowmeter Based on Time Difference Method [D]. Zhejiang University, 2014.). Calculate the relationship between the flight time difference and the fluid flow rate: And calculate the instantaneous flow value according to the flow definition And cumulative flow value

[0025] In the best mode, the ultrasonic transducer for emitting and receiving ultrasonic signals is of integrated design, that is, an ultrasonic transducer capable of both emitting and receiving ultrasonic signals is located at the same position.

[0026] The present invention realizes the application of the cross-correlation algorithm. Different from the traditional threshold comparison method, the accuracy of the calculation result of the cross-correlation method is only related to the similarity of the two groups of upstream and downstream echo signals. In addition, the upstream and downstream echo signals are subjected to high-speed sampling, filtering and other processing, which will not be affected by signal distortion and distortion, thereby improving the measurement anti-interference ability. The present invention can be applied in high flow rate environments and occasions with relatively complex electromagnetic environments, and greatly improves the stability of the flow meter.

[0027] The present invention adopts a lightweight cross-correlation method to calculate the flight time difference. The cross-correlation function is calculated in the time domain. The actual amount of calculation is very large, which is difficult to implement on the hardware platform of the ultrasonic flow meter. In order to achieve a lightweight design and avoid convolution operations in the time domain, the two sets of echo signals are converted to the frequency domain for multiplication operations to obtain the frequency domain output of the cross-correlation function. By converting the convolution operation in the time domain to the frequency domain for multiplication processing, the amount of calculation of the cross-correlation function is greatly reduced, the operation efficiency is improved, and a basis is provided for implementing the algorithm in embedded devices.

[0028] From the above, it can be seen that the obtained cross-correlation function is actually a discrete sequence, so it is difficult to distinguish the maximum value of the cross-correlation function. The true maximum value of the cross-correlation function is more likely to fall between two discrete points. Therefore, it is necessary to perform cubic spline interpolation on the discrete sequence of the cross-correlation function to fit the discrete sequence data into a continuous curve. The maximum value of the cross-correlation function can be determined, and the displacement time corresponding to the second-order derivative of the cubic fitting polynomial is zero, that is, the displacement time corresponding to the maximum value point of the cross-correlation function output, thereby obtaining an accurate estimate of the flight time difference, so that the calculation results of the cross-correlation algorithm can be used for actual measurement, and the instrument accuracy is greatly improved.

[0029] The invention discloses a lightweight implementation and application method of a cross-correlation algorithm in ultrasonic flow measurement, which specifically includes the following contents: a microcontroller outputs a pulse electrical signal to drive an ultrasonic transducer to generate an ultrasonic signal, which propagates through a fluid and reaches a receiving transducer to be converted into an echo electrical signal, wherein the time for the ultrasonic signal to travel from an upstream transducer to a downstream transducer is the upstream flight time, and the time for the ultrasonic signal to travel from a downstream transducer to an upstream transducer is the downstream flight time, and the difference between the two is the flight time difference; a high-speed analog-to-digital converter is used to sample the echo signals received from the upstream and downstream, respectively, to obtain the original discrete echo time domain signals of the upstream and downstream; a fast Fourier transform is used to obtain the discrete echo frequency domain signals of the upstream and downstream, and frequency domain bandpass filtering is performed respectively to obtain the discrete echo frequency domain filtered signals of the upstream and downstream, and the ultrasonic signal is transmitted to the receiving transducer through the receiving transducer. The anti-interference ability of measurement is improved; the conjugate of the downstream discrete echo frequency domain filter signal is taken, and then the product operation is performed with the upstream discrete echo frequency domain filter signal to obtain the frequency domain output of the cross-correlation function, and then the fast Fourier inverse transform is used to obtain the time domain discrete output of the cross-correlation function, which greatly reduces the amount of calculation and realizes the lightweight of the cross-correlation algorithm; the cubic spline interpolation method is used to fit the time domain discrete output of the cross-correlation function to obtain the time domain continuous output of the cross-correlation function, and then the displacement time corresponding to the second-order derivative of the cubic fitting polynomial is zero, that is, the displacement time corresponding to the maximum output point of the cross-correlation function, so as to obtain an accurate estimate of the flight time difference, so that the calculation result of the cross-correlation algorithm can be used for actual measurement, realize the application of the cross-correlation algorithm, and improve the measurement accuracy. The present invention converts the discrete echo time domain signal obtained by high-speed sampling into a frequency domain signal, performs frequency domain bandpass filtering, improves the measurement anti-interference ability, and obtains the frequency domain output of the cross-correlation function through conjugate and product operations in the frequency domain, which greatly reduces the amount of calculation and realizes the lightweight of the cross-correlation algorithm. The cubic spline interpolation method is further adopted to fit the continuous output of the cross-correlation function, thereby obtaining an accurate flight time difference estimation, so that the calculation result of the cross-correlation algorithm can be used for actual measurement and the measurement accuracy is improved.

[0030] In summary, the beneficial effects of the present invention are:

[0031] The present invention uses a lightweight cross-correlation algorithm to calculate the flight time difference of the ultrasonic flowmeter. Compared with the traditional threshold comparison method, it not only improves the accuracy of the flight time difference, but also improves the ultrasonic flowmeter's ability to resist interference from clutter signals, making the application more diverse. At the same time, the amount of calculation of the correlation algorithm is greatly reduced, thereby reducing the requirements for the performance of hardware such as microcontrollers. The introduction of the cubic spline interpolation function makes the maximum point of the cross-correlation function more accurate, and thus the estimation of the flight time difference is more realistic. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0033] Figure 1 It is an ultrasonic flow meter measurement model;

[0034] Figure 2 It is the echo signal diagram received upstream and downstream;

[0035] Figure 3 It is a schematic diagram of the upstream and downstream flight time difference;

[0036] Figure 4 is the cross-correlation function graph;

[0037] Figure 5 It is a system flow chart for the implementation of lightweight cross-correlation algorithm;

[0038] Figure 6 It is the continuous output fitting curve graph after cubic spline interpolation of discrete cross-correlation sequence;

[0039] Figure 7 It is the time domain image of the original discrete echo signals of upstream and downstream;

[0040] Figure 8 It is the frequency domain image of the original discrete echo signals of upstream and downstream;

[0041] Fig. 9 It is the time domain image of the upstream and downstream discrete echo signals after frequency domain bandpass filtering;

[0042] Fig.10 It is the frequency domain image of the upstream and downstream discrete echo signals after frequency domain bandpass filtering;

[0043] Fig.11 It is the time-domain discrete sequence output image of the cross-correlation function. DETAILED DESCRIPTION

[0044] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, other embodiments obtained by ordinary technicians in this field without creative work are all within the scope of protection of the present invention.

[0045] Ultrasonic flow meter measurement model Figure 1As shown, the ultrasonic transducer has the functions of both signal sending and receiving. When sending sound wave signals, it is called a sending transducer, and when receiving echo signals, it is called a receiving transducer. During the measurement process, the microcontroller outputs a pulse electrical signal to alternately drive the upstream and downstream transducers to generate ultrasonic signals. After propagating through the fluid, it reaches the receiving transducer and is converted into an echo signal. The time it takes for the ultrasonic signal to travel from the upstream transducer to the downstream transducer is the upstream flight time, and the time it takes from the downstream transducer to the upstream transducer is the downstream flight time. The flight time difference is the subtraction of the upstream flight time from the downstream flight time.

[0046] The two sets of echo signal images actually received are as follows Figure 2 As shown, it can be seen that the upstream echo signal and the downstream echo signal are very similar. They are both sinusoidal signals received after the corresponding ultrasonic transducer emits the ultrasonic signal of the same frequency and propagates through the fluid in the pipeline. The only difference is that the upstream signal propagates downstream, while the downstream signal propagates upstream. Therefore, the biggest difference between them is that there is a certain time delay on the time axis, and the time delay is the flight time difference between the corresponding downstream echo signal and the upstream echo signal.

[0047] The schematic diagram of the upstream and downstream flight time difference is as follows: Figure 3 As shown, the driving signals of the microcontroller are all square wave pulse signals, and the upstream and downstream echo signals x(t) and y(t) received by the receiving transducer are sinusoidal signals. It can be found that the waveform curves of x(t) and y(t) are almost exactly the same, but there is a certain time delay Δt between the two sets of signals.

[0048] The cross-correlation function can well characterize the correlation between two groups of signals. When the cross-correlation function value reaches the maximum value, the corresponding horizontal coordinate is the time delay between the two groups of signals. Therefore, the flight time difference can be obtained by calculating the cross-correlation function of the downstream echo signal and the upstream echo signal.

[0049] Using the cross-correlation function R yx (τ) describes the similarity between the upstream echo signal x(t) and the downstream echo signal y(t) at different time displacements τ. The cross-correlation function R of the upstream echo signal x(t) and the downstream echo signal y(t) is yx (τ) can be defined as

[0050]

[0051] Where τ represents the time displacement;

[0052] The cross-correlation function curve is as follows Figure 4 As shown, when R yxWhen the horizontal axis time displacement τ of (τ) reaches the time displacement τ0, and the maximum value of the cross-correlation function output curve appears at this time, it means that the upstream echo signal x(t) and the downstream echo signal y(t) are most similar at this time, and the time displacement τ0 is the flight time difference Δt between the two echo signals.

[0053] The high-speed analog-to-digital converter is used to sample the received upstream echo signal x(t) and downstream echo signal y(t) at high speed, respectively, to obtain discrete digital signals that are easy to process: the upstream original discrete echo time domain signal x(n) and the downstream original discrete echo time domain signal y(n). Therefore, the discrete signals are actually processed during the measurement process, and the discrete cross-correlation function R yx (m) is defined as:

[0054] Where m = 0, 1, ..., M-1 (2)

[0055] Among them, m is the number of data displacements between the two discrete signal sequences x(n) and y(n), M is the number of sampling points, and n is the data sequence number.

[0056] According to Formula 2, we can know that R yx (m) Discrete cross-correlation function operation, requiring M 2 times multiplication and M 2 -M addition operations, the amount of calculation is very large, so the calculation of the cross-correlation function is implemented in the frequency domain.

[0057] According to the discrete convolution theorem, the M-point convolution operation of discrete signal sequences y(n) and x(n) can be expressed as:

[0058]

[0059]

[0060] Where x(m) represents the discrete signal sequence x(n), y(m) represents the discrete sequence obtained by flipping the discrete signal sequence y(n) and shifting it to the right by m points, and y(-m) represents the discrete sequence after flipping the discrete sequence y(m).

[0061] Discrete cross-correlation function R yx (m) and R xy The relationship between (m) is:

[0062] R yx (m) = R xy (-m) (5)

[0063] According to formula 4 and 5, the discrete cross-correlation function R yx The relationship between the convolution of (m) and y(n) and x(n) is:

[0064]

[0065] The discrete cross-correlation function can be calculated by discrete convolution. According to Equation 6 and the conjugate property that the convolution in the time domain corresponds to the product in the frequency domain and the flip in the time domain corresponds to the frequency domain, the convolution operation of y(n) and x(n) can be converted into the product operation of the frequency domain signal to simplify the operation. The specific process of implementing the cross-correlation algorithm of lightweight design is as follows: Figure 5 As shown in the figure, the original discrete echo time domain signals of the upstream and downstream are transformed by fast Fourier transform to obtain the upstream and downstream discrete echo frequency domain signals X(n) and Y(n); X(n) and Y(n) are bandpass filtered in the frequency domain to filter out the clutter signal, thereby obtaining the upstream filtered discrete frequency domain signal X′(n) and the downstream filtered discrete frequency domain signal Y′(n); the conjugate operation is performed on the downstream filtered discrete frequency domain signal Y′(n) to obtain the conjugate output Then, the product operation is performed with the upstream filtered discrete frequency domain signal X′(n) to obtain the frequency domain discrete output sequence of the cross-correlation function; the frequency domain discrete output sequence of the cross-correlation function is subjected to inverse fast Fourier transform to obtain the time domain discrete output sequence R of the cross-correlation function yx (τ).

[0066] To complete the cross-correlation operation of M points in the above process, a total of 2 M-point fast Fourier transform operations, M complex multiplication operations and 1 M-point inverse fast Fourier transform operation are required. With the help of the fast Fourier transform function and the inverse fast Fourier transform function, the cross-correlation operation only needs complex multiplications and 3Mlog2M complex additions, compared to the R yx (m) Discrete cross-correlation function operation, a total of M 2 times multiplication and M 2 -M addition operations, especially when M is larger, it can be obviously found that the computational complexity of the lightweight cross-correlation algorithm is greatly reduced. The algorithm is more lightweight, improves computational efficiency, and reduces hardware requirements and instrument costs.

[0067] The cross-correlation function calculated above is actually a discrete cross-correlation function sequence. Since the maximum value point of the discrete output of the cross-correlation function and the maximum value point of the continuous output of the cross-correlation function may not coincide by chance, the delay times corresponding to the two generally have a slight deviation. If the time delay corresponding to the maximum value point of the discrete sequence of the cross-correlation function is directly used as the measurement result of the flight time difference Δt, a certain degree of measurement error will occur.

[0068] In order to find the true maximum value of the cross-correlation function, the cubic spline interpolation function can be used to fit the discrete sequence points to obtain the continuous output of the cross-correlation function. The cross-correlation function continuous output fitting curve is as follows: Figure 6 As shown in the figure, since the amount of calculation for the 1024-point cubic spline interpolation function is also relatively large, in order to further reduce the amount of calculation of the microcontroller, the function interpolation operation is only performed in the key part, and it is only necessary to find the maximum discrete output point C0 of the cross-correlation function and its left neighbor point C -1 , and the right adjacent point C1. There is a certain distance between them. It is only necessary to perform two cubic spline interpolation operations at these three key points. According to the cross-correlation function graph, it can be seen that the continuous output maximum points of the cross-correlation function will be distributed within the interval of these three points.

[0069] According to the definition of cubic spline interpolation function and C -1 , C0 and C1 three interpolation node information to calculate the interval and The unique polynomials S1(x) and S2(x) on the cross-correlation function are obtained, and the discrete output sequence of the cross-correlation function is curve-fitted at the key point position to obtain the continuous output curve of the key part of the cross-correlation function.

[0070] Depend on Figure 6 It can be seen that the actual continuous cross-correlation function curve maximum point C0′ is different from the original discrete sequence C0 point. yx (τ0) reaches its maximum value at C0′, and then the displacement time corresponding to the second-order derivative of the cubic fitting polynomial is zero is obtained, that is, the time displacement τ0 corresponding to the point C0′ is the estimated value Δt of the flight time difference between the upstream continuous echo signal and the downstream continuous echo signal. By introducing the cubic spline interpolation function, the estimation result of the flight time difference is more accurate. Finally, the relationship between the flight time difference and the fluid flow rate can be obtained, and the instantaneous and cumulative flow values ​​can be calculated according to the flow definition.

[0071] The specific implementation of the present invention takes the pipe section DN100 as an example for experiment, the fluid medium is pure water, the flow velocity v is 2.0m / s, and the ultrasonic transducer adopts the direct-radiation Z-type installation method. Figure 1 As shown, a pair of ultrasonic transducers are installed facing each other at an installation angle of θ of 45°. The theoretical resonance point is 1MHz. The driving signal is 20 square wave pulse signals. The echo signal is sampled by a high-speed analog-to-digital converter. The sampling frequency is f s The frequency is 7.2MHz and the number of sampling points is 1024. According to the above requirements, the experimental test is carried out and a set of test data of sampling signals is derived. The sampling data is simulated with the help of MATLAB software and combined with the actual flow meter hardware equipment for data analysis.

[0072] According to Shannon sampling theorem, in order to ensure that the sampled discrete signal can completely retain the information of the original echo signal and restore the original waveform signal without distortion, the sampling frequency f must be guaranteed. sHigher than the highest frequency f in the effective frequency sequence of the measured signal nmax The sampling frequency used is 7.2MHz, while the frequency of the driving pulse signal is 1MHz, which fully meets the requirements of the sampling theorem.

[0073] The time domain diagrams of the upstream and downstream original discrete echo signals obtained by sampling with a high-speed analog-to-digital converter are shown in Figure 6 As shown in Figure 1, in order to improve the computational efficiency of the algorithm, the upstream original discrete echo signal x(n) and the downstream original discrete echo signal y(n) are first converted from the time domain to the frequency domain using the fast Fourier transform function. The frequency domain diagrams corresponding to the upstream and downstream original discrete echo signals are shown in Figure 1. Figure 8 shown.

[0074] exist Figure 7 In the figure, we can see that the original discrete echo time domain signals of the upstream and downstream have received 20 waveforms, the echo signal reception is relatively complete, and the discrete sampling signal can accurately restore the continuous echo signal curve. Figure 8 It can be seen that there are some noise interference signals in the frequency domain signals of the upstream and downstream original discrete echoes between 0.8MHz-0.9MHz and 1.1MHz-1.2MHz. In order to enhance the anti-interference ability of the measurement, it is necessary to perform bandpass filtering on the sampled upstream original discrete echo signals and downstream original discrete echo signals in the frequency domain to eliminate the interference of clutter signals.

[0075] Frequency domain bandpass filtering is to reduce all clutter signals outside the bandpass filtering range to zero, and only retain the signals within the bandpass frequency, that is, f1≤|f n The signal in the frequency band |≤f2 remains unchanged, but all other signals are reset to zero. Among them, f1 and f2 are the lower cutoff frequency and upper cutoff frequency of the bandpass filter respectively; the sampling frequency is recorded as f s , f n is the effective frequency sequence of the measured signal.

[0076] The upper cutoff frequency of the bandpass filter is set to 1.08MHz, and the lower cutoff frequency is set to 0.92MHz. The upstream discrete echo frequency domain signal X(n) and the downstream discrete echo frequency domain signal Y(n) output by the fast Fourier transform are multiplied by the ideal bandpass filter spectrum function, thereby completing the frequency domain filtering. The time domain diagrams corresponding to the upstream and downstream filtered discrete echo signals are shown in Figure 1. Fig. 9 As shown in the figure, the frequency domain diagram of the discrete echo signal after upstream and downstream filtering is as follows Fig.10 As shown, by observing the signal in the frequency domain, it can be found that the interference signal has been almost eliminated.

[0077] The conjugate output of the upstream filtered discrete frequency domain signal X′(n) and the downstream filtered discrete frequency domain signal Y′(n) is taken as the frequency domain output. By performing a multiplication operation, the frequency domain discrete output of the cross-correlation function can be obtained, and then the inverse fast Fourier transform function is used to convert the frequency domain discrete output of the cross-correlation function into the time domain discrete output of the cross-correlation function. Thus, the cross-correlation function operation of the upstream discrete echo signal x(n) and the downstream discrete echo signal y(n) is completed, and the time domain discrete output of the cross-correlation function is obtained as follows: Fig.11 shown.

[0078] exist Fig.11 In the equation, the horizontal coordinate time displacement τ corresponding to the discrete output of the cross-correlation function is equal to the discrete time displacement m between the upstream discrete echo signal x(n) and the downstream discrete echo signal y(n) in equation 2 divided by the sampling frequency f s What you get.

[0079] When the cross-correlation function reaches its maximum value, the two sets of echo signals x(n) and y(n) have the greatest similarity, and the corresponding time displacement That is, the flight time difference Δt between the downstream discrete echo signal y(n) and the upstream discrete echo signal x(n). With the help of MATLAB software, the flight time difference Δt calculated by the discrete sequence of the cross-correlation function can be calculated to be 277.778ns. Three interpolation nodes C -1 The coordinate values ​​of C0, C1 are (0.138889, 2674), (0.277778, 3420), (0.4166667, 1719), respectively. According to the definition of cubic spline interpolation, the intervals can be calculated respectively. and The only cubic polynomials (i.e. fitting curves) S1(x) and S2(x) on the surface are calculated as follows:

[0080] S1(x)=-742444x 3 +431888x 2 -74326x+6655.3

[0081] S2(x)=1034600x 3 -1049000x 2 +337022x-31432 (7)

[0082] like Figure 6The figure shows that the key discrete points of the cross-correlation function are fitted as a continuous curve based on S1(x) and S2(x). It can be seen that the new peak C0′ point is the maximum point of the continuous curve of the cross-correlation function after cubic spline interpolation. The displacement time τ0 corresponding to the second-order derivative of the cubic fitting polynomial is zero, which is the flight time difference Δt between the downstream continuous echo signal and the upstream continuous echo signal. According to the cubic spline interpolation result, the time displacement corresponding to the maximum value of the continuous curve of the cross-correlation function (i.e., the flight time difference) can be recalculated as 252.689ns. By comparing the flight time difference results before and after cubic spline interpolation, it can be seen that the two are not equal, and there is indeed a certain deviation, which is 25.089ns more accurate in value. Therefore, a more accurate flight time difference estimate is obtained, and the flow value is correspondingly more accurate.

[0083] According to the actual metrological verification test experiment and compared with the standard table, the absolute value of the maximum relative error of the experimental table recorded is 0.77%, the experimental error is within 1.0%, and the repeatability error of the experimental results is between 0.25% and 0.5%. This shows that the ultrasonic flowmeter based on the lightweight design cross-correlation algorithm has higher measurement accuracy and more stable measurement repeatability.

[0084] In summary, the present invention provides a lightweight implementation and application method of a cross-correlation algorithm in ultrasonic flow measurement, which specifically includes the following steps:

[0085] S1, the microcontroller drives the ultrasonic transducer to excite an ultrasonic signal, which is converted into an echo signal by the corresponding receiving transducer after passing through the pipeline fluid;

[0086] S2, sampling the received echo signal to obtain a discrete digital signal that is easy to store and process;

[0087] S3, performing fast Fourier transform on the sampled digital signal, thereby converting the upstream and downstream echo signals from the time domain to the frequency domain;

[0088] S4, performing bandpass filtering on the upstream and downstream echo signals in the frequency domain;

[0089] S5, performing discrete cross-correlation operation on the upstream and downstream echo signals in the frequency domain;

[0090] S6, performing inverse Fourier transform on the discrete cross-correlation function, and inversely transforming the upstream and downstream echo signals from the frequency domain back to the time domain;

[0091] S7, performing cubic spline interpolation processing on the discrete cross-correlation function, fitting the key part curve, finding the maximum point, and obtaining an estimate of the flight time difference based on the maximum point;

[0092] S8, based on the relationship between the flight time difference and the fluid flow rate, and according to the flow definition, the instantaneous and cumulative flow values ​​are calculated.

[0093] Step S1: The microcontroller drives the ultrasonic transducer to excite an ultrasonic signal, which is converted into an echo signal by the corresponding receiving transducer after passing through the pipeline fluid. Specifically, the microcontroller of the time-difference ultrasonic flowmeter outputs a set of pulse signals of a certain frequency, and drives the upstream and downstream ultrasonic transducers alternately in time to generate an ultrasonic transmission signal. The ultrasonic signal propagates through the fluid in the pipeline and reaches the corresponding receiving transducer, which is then converted into an echo signal by the receiving transducer. The echo signal is an electrical signal.

[0094] Step S2 samples the received echo signal to obtain a discrete digital signal that is easy to store and process. Specifically, it refers to: using a high-speed analog-to-digital converter to perform high-speed sampling on the received upstream echo signal x(t) and downstream echo signal y(t), respectively, to obtain the upstream original discrete echo time domain signal x(n) and the downstream original discrete echo time domain signal y(n).

[0095] Step S3 performs fast Fourier transform on the sampled digital signal. The upstream and downstream echo signals are converted from the time domain to the frequency domain. Specifically, the upstream and downstream original discrete echo time domain signals are transformed by fast Fourier transform to obtain the upstream and downstream discrete echo frequency domain signals X(n) and Y(n).

[0096] Step S4 of performing bandpass filtering on the upstream and downstream echo signals in the frequency domain specifically refers to:

[0097] X(n) and Y(n) are bandpass filtered in the frequency domain to filter out clutter signals, thereby obtaining an upstream filtered discrete frequency domain signal X′(n) and a downstream filtered discrete frequency domain signal Y′(n).

[0098] Step S5 performs discrete cross-correlation calculation on the upstream and downstream echo signals in the frequency domain, specifically referring to:

[0099] Take the conjugate operation on the downstream filtered discrete frequency domain signal Y′(n) to obtain the conjugate output Then, a product operation is performed with the upstream filtered discrete frequency domain signal X′(n) to obtain a frequency domain discrete output sequence of the cross-correlation function.

[0100] Step S6 performs inverse Fourier transform on the discrete cross-correlation function, and the upstream and downstream echo signals are inversely transformed from the frequency domain to the time domain. Specifically, the frequency domain discrete output sequence of the cross-correlation function is subjected to inverse fast Fourier transform to obtain the time domain discrete output sequence R of the cross-correlation function. yx (τ).

[0101] Step S7 performs cubic spline interpolation processing on the discrete cross-correlation function, fits the key part curve, obtains the maximum point, and obtains the estimate of the flight time difference based on this. Specifically, it means: using the cubic spline interpolation method to interpolate and fit the time-domain discrete output sequence of the cross-correlation function to obtain the time-domain continuous output polynomial of the cross-correlation function, and then obtains the displacement time corresponding to the second-order derivative of the cubic fitting polynomial being zero, that is, the displacement time corresponding to the maximum point of the cross-correlation function output, so as to obtain an accurate estimate of the flight time difference.

[0102] Step S8 calculates the instantaneous and cumulative flow values ​​based on the relationship between the flight time difference and the fluid flow rate and the flow definition, specifically referring to: finally, the fluid flow rate, instantaneous flow rate and cumulative flow rate are calculated in sequence based on the flight time difference estimate.

[0103] Matters not covered by the present invention are known technologies.

[0104] The above embodiments are only for illustrating the technical concept and features of the present invention, and their purpose is to enable people familiar with the technology to understand the content of the present invention and implement it accordingly, and they cannot be used to limit the protection scope of the present invention. Any equivalent changes or modifications made according to the spirit of the present invention should be included in the protection scope of the present invention.

Claims

1. A lightweight implementation method of a cross-correlation algorithm in ultrasonic flow measurement, characterized in that: The steps include: S1. A pair of ultrasonic transducers are arranged at two positions, upstream and downstream, of the straight pipe type fluid pipeline, respectively, and the ultrasonic transducers have the functions of sending and receiving ultrasonic waves; The two positions send out ultrasonic signals alternately at different times, propagate through the fluid in the pipeline, and receive echo signals at the corresponding positions respectively; the echo signals are electrical signals; S2, sampling the two groups of echo signals respectively to obtain discrete digital signals; S3, performing fast Fourier transform on the digital signal to convert the two groups of echo signals from the time domain to the frequency domain; S4, performing bandpass filtering on the two groups of echo signals obtained in step S3 in the frequency domain to obtain a downstream filtered discrete frequency domain signal Y′(n) and an upstream filtered discrete frequency domain signal X′(n); S5, performing a discrete cross-correlation operation in the frequency domain on the two groups of echo signals obtained in step S4; Specifically, the conjugate operation is performed on the downstream filtered discrete frequency domain signal Y′(n) to obtain the conjugate output Then perform a product operation with the upstream filtered discrete frequency domain signal X′(n) to obtain a frequency domain discrete output sequence of the cross-correlation function; S6, performing inverse Fourier transform on the discrete cross-correlation function, and inversely transforming the two groups of echo signals obtained in step S5 from the frequency domain back to the time domain; Specifically, the frequency domain discrete output sequence of the cross-correlation function is subjected to inverse fast Fourier transform to obtain the time domain discrete output sequence R of the cross-correlation function. yx (τ); S7, performing cubic spline interpolation processing on the discrete cross-correlation function, fitting the key part curve, finding the maximum value point, and obtaining the flight time difference based on it; Specifically, the method of cubic spline interpolation is used to interpolate and fit the time-domain discrete output sequence of the cross-correlation function to obtain the time-domain continuous output polynomial of the cross-correlation function, and then the displacement time corresponding to the zero second-order derivative of the cubic fitting polynomial is calculated, that is, the displacement time corresponding to the maximum output point of the cross-correlation function, so as to obtain an accurate estimate of the flight time difference; S8, based on the relationship between the flight time difference and the fluid flow rate, and according to the flow definition, the instantaneous and cumulative flow values ​​are calculated.

2. The lightweight implementation method of the cross-correlation algorithm in ultrasonic flow measurement according to claim 1 is characterized in that: The method of step S2 is: The received upstream echo signal x(t) and downstream echo signal y(t) are sampled at high speed using a high-speed analog-to-digital converter to obtain the upstream original discrete echo time domain signal x(n) and the downstream original discrete echo time domain signal y(n).

3. The lightweight implementation method of the cross-correlation algorithm in ultrasonic flow measurement according to claim 1 is characterized in that: The method of step S3 is: Fast Fourier transform is used to transform the original discrete echo time domain signals of the upstream and downstream into the discrete echo frequency domain signals X(n) and Y(n) of the upstream and downstream, respectively.

4. The lightweight implementation method of the cross-correlation algorithm in ultrasonic flow measurement according to claim 1 is characterized in that: The method of step S4 is: X(n) and Y(n) are bandpass filtered in the frequency domain to filter out clutter signals, thereby obtaining an upstream filtered discrete frequency domain signal X′(n) and a downstream filtered discrete frequency domain signal Y′(n).