Flight time measurement method and device based on wavelet transform and adaptive Kalman filtering
By combining wavelet transform and adaptive Kalman filtering, the non-Gaussian noise problem of ultrasonic flow meters in complex water environments is solved, achieving high-precision and low-cost flow measurement, which is suitable for embedded platforms such as STM32F407.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HEBEI UNIV OF ENG
- Filing Date
- 2026-03-06
- Publication Date
- 2026-05-15
AI Technical Summary
Existing low-cost ultrasonic flow meters suffer from non-Gaussian impulse noise in complex aquatic environments due to interference from bubbles, sediment, and other factors. Traditional filtering algorithms struggle to balance smooth noise reduction with dynamic tracking, resulting in system response lag and decreased measurement accuracy.
A method combining wavelet transform and adaptive Kalman filtering is adopted. High-frequency singular noise is removed by wavelet threshold denoising algorithm, and an adaptive Kalman filter model is constructed. The model parameters are adjusted in real time to adapt to steady-state and sudden water flow conditions, so as to achieve high-precision flow measurement.
It significantly reduces measurement lag time, improves the accuracy of dynamic measurement, and is suitable for real-time operation on low-end embedded microprocessors such as STM32F407, reducing hardware costs and power consumption.
Smart Images

Figure CN122041998A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of time-of-flight (ToF) measurement technology, and more specifically, to a time-of-flight measurement method and apparatus based on wavelet transform and adaptive Kalman filtering. Background Technology
[0002] With the advancement of smart water conservancy and water-saving irrigation projects in agriculture, higher requirements are being placed on the accuracy of flow measurement in open channels, box culverts, and water pipelines. Time-of-flight ultrasonic flow meters, due to their advantages such as non-contact measurement, no pressure loss, convenient installation and maintenance, and wide rangeability, have become the mainstream choice in the field of water resource measurement. Their basic working principle involves measuring the propagation time (Time-of-Flight, ToF) of ultrasonic pulses in the fluid in both the upstream and downstream directions, calculating the time difference, and then using acoustic principles to deduce the average flow velocity and instantaneous flow rate of the fluid.
[0003] At the hardware implementation level, to balance cost and performance, the industry and academia widely adopt an architecture of "general-purpose MCU microcontroller + high-precision TDC time-to-digital converter chip". A typical solution uses an STM32 series microcontroller as the main controller, in conjunction with AMS's TDC-GP22 or TDC-GP21 chip for time measurement. The TDC-GP22 chip employs internal logic gate delay technology, enabling it to provide picosecond (ps) level time resolution and achieve extremely high measurement accuracy in an ideal laboratory environment with clean water.
[0004] In actual field flow measurement of natural water bodies, the aforementioned low-cost hardware solution faces significant challenges, mainly in the following aspects: Complex multiphase flow environments can lead to signal distortion and measurement outliers. Water in canals is typically not an ideal single-phase fluid; it often contains large amounts of suspended sediment, tiny air bubbles introduced due to water flow or pump pressurization, and aquatic plants. When the ultrasonic beam encounters air bubbles or solid particles, Rayleigh scattering or attenuation occurs, resulting in significant amplitude reduction or severe waveform distortion of the echo signal at the receiver. The TDC-GP22 chip typically relies on "first-wave detection" or "zero-crossing detection" techniques to determine the echo arrival time. When the waveform is distorted due to interference from impurities, the comparator is prone to false triggering, leading to inaccurate measurements of the time of flight. or The appearance of irregular, high-frequency, large-amplitude jumps, this non-Gaussian impulse noise, is usually called "outliers." Outliers often deviate from the true value by several times, severely compromising the accuracy of flow rate calculations.
[0005] Traditional filtering algorithms struggle to strike a balance between steady-state smoothing and dynamic tracking. To suppress measurement noise, existing ultrasonic flowmeters typically employ moving average filtering, median filtering, or standard first-order hysteresis filtering algorithms. However, these linear filters have inherent drawbacks: to filter out large outliers, the filtering time constant often needs to be increased or the sliding window lengthened, directly slowing down the system's response to flow changes. During irrigation gate regulation or pump station start-up and shutdown, flow rates can change abruptly, and lagging measurement data can lead to control system oscillations or metering errors. Furthermore, traditional Kalman filtering is based on the minimum mean square error criterion, assuming that both system noise and observation noise follow a Gaussian distribution. However, bubble interference in river flow is a typical non-Gaussian, heavy-tailed noise distribution. In the presence of strong outliers, the estimates of the standard Kalman filter can be severely skewed, even leading to filter divergence.
[0006] The computational limitations of embedded platforms restrict the application of complex algorithms. While advanced algorithms such as deep learning (e.g., LSTM, CNN) and wavelet packet analysis can theoretically solve the aforementioned problems effectively, these algorithms have extremely high computational complexity and typically require a PC or high-performance DSP to run. However, flow meters used in the field are usually battery-powered and based on STM32F4 or lower-end MCU platforms, with limited computing power and storage resources, making it difficult to support complex neural network models.
[0007] In summary, there is an urgent need for a lightweight and robust signal processing method that, with limited MCU computing power, can accurately remove outliers caused by bubbles by utilizing the multi-resolution characteristics of wavelet transform, and can solve the dynamic response lag problem by using an improved adaptive Kalman filter, thereby achieving high-precision real-time flow monitoring under complex operating conditions. This invention is proposed against this backdrop.
[0008] No effective solutions have yet been proposed to address the problems in the relevant technologies. Summary of the Invention
[0009] (a) Technical problems to be solved To address the shortcomings of existing technologies, this invention provides a time-of-flight measurement method and device based on wavelet transform and adaptive Kalman filtering. It has the advantage of accurately identifying and eliminating high-frequency singularities mixed in with useful signals, thereby solving the problems of non-Gaussian impulse noise in measurement data caused by interference such as bubbles and silt in existing low-cost ultrasonic flow meters used in agricultural irrigation areas and complex industrial sites, as well as the difficulty of traditional filtering algorithms in balancing smoothing and dynamic tracking, which leads to system response lag and decreased measurement accuracy.
[0010] (II) Technical Solution To achieve the aforementioned advantages of accurately identifying and eliminating high-frequency singularities mixed in with useful signals, the specific technical solution adopted by this invention is as follows: In a first aspect, the present invention provides a time-of-flight measurement method based on wavelet transform and adaptive Kalman filtering, comprising: The main control module configures the registers of the time-to-digital converter module, sets the first wave detection mode and the number of pulses emitted, and completes the initialization settings. After initialization, the time-to-digital converter module is used to drive the ultrasonic transducer group to transmit and receive ultrasonic waves and obtain the current raw flight time measurement value. A sliding time window is constructed, and the original flight time measurements within the sliding time window are processed by wavelet transform. High-frequency singular noise in the original flight time measurements is then removed to obtain the processed flight time measurements. An adaptive Kalman filter model was constructed, and the processed flight time measurements were observed using the adaptive Kalman filter model to calculate the statistical characteristics of the observation residuals. Based on the statistical characteristics of the observation residuals, the process noise covariance matrix and measurement noise covariance matrix of the adaptive Kalman filter are corrected in real time, and the optimal flight time estimate is output through prior prediction and posterior correction. Based on the optimal flight time estimate, the time difference between downstream and upstream flight time is calculated, and the instantaneous flow rate is output by combining the preset flow channel geometry parameters and flow channel cross-section.
[0011] Furthermore, after the initialization settings are completed, the ultrasonic transducer group is driven by the time-to-digital converter module to perform ultrasonic transceiver operations, and the current raw time-of-flight measurement value is obtained, including: The main control module sends initialization and start measurement commands to the time-to-digital converter module via the SPI bus, driving the state machine inside the time-to-digital converter module to start working; The state machine is used to measure the ultrasonic transducer sequentially by transmitting upstream and receiving downstream, and transmitting downstream and receiving upstream. The measurement actions are received by the signal conditioning module, and the received measurement actions are processed by analog filtering and amplification. The data in the result register of the time-to-digital converter is read. Combined with the measurement actions, the downstream flight time and the upstream flight time are obtained. Calculate the average flight time of the downstream flight time and the upstream flight time, and use the average flight time of a single measurement as the current original flight time measurement value.
[0012] Furthermore, the process of constructing a sliding time window, performing wavelet transform processing on the original flight time measurements within the sliding time window, and removing high-frequency singular noise from the original flight time measurements, yields processed flight time measurements including: The wavelet thresholding denoising algorithm is used to separate the original flight time measurements to isolate abrupt noise from the original flight time measurements; The denoising threshold is calculated based on the Donoho universal threshold criterion, and the high-frequency detail coefficients of each layer are quantized based on the denoising threshold. Using the processed high-frequency detail coefficients and low-frequency approximation coefficients, wavelet reconstruction is performed layer by layer in order from deep to shallow, and the processed time-of-flight measurement is output.
[0013] Furthermore, the step of using a wavelet thresholding denoising algorithm to separate the original flight time measurements, and separating the abrupt noise in the original flight time measurements, includes: Given the original time-of-flight signal, the Mallat tower algorithm is used to perform convolution and downsampling on the original time-of-flight signal through low-pass and high-pass filters respectively, and the low-frequency approximation coefficients and high-frequency detail coefficients are calculated. Based on the Symlet6 wavelet basis function, the layer is decomposed into three layers, so that the energy of the effective flow signal is mainly concentrated in the low-frequency approximation coefficients, while random noise and anomalous singular values are mainly concentrated in the high-frequency detail coefficients of each layer.
[0014] Furthermore, the denoising threshold is calculated based on the Donoho universal threshold criterion, and the high-frequency detail coefficients of each layer are quantized based on the denoising threshold to preserve the edge features of the signal, including: The noise standard deviation is estimated using the median absolute deviation (MAD) of the first layer detail coefficients, and the noise standard deviation is output. The noise reduction threshold is calculated based on the noise standard deviation and the Donoho general threshold formula. A soft thresholding function is used to perform nonlinear shrinkage on the high-frequency detail coefficients of each layer to achieve a smoother denoising effect, which facilitates subsequent Kalman filtering.
[0015] Furthermore, by utilizing the processed high-frequency detail coefficients and low-frequency approximation coefficients, layer-by-layer wavelet reconstruction is performed in descending order of depth, and the output processed time-of-flight measurement values include: The second-layer low-frequency approximation coefficients are obtained by reconstructing the third-layer low-frequency approximation coefficients and the processed third-layer high-frequency detail coefficients through wavelet inverse transform. The first-level low-frequency approximation coefficients are obtained by reconstructing the second-level low-frequency approximation coefficients and the processed second-level high-frequency detail coefficients through wavelet inverse transform. The first-level low-frequency approximation coefficients and the processed first-level high-frequency detail coefficients are reconstructed by inverse wavelet transform, and the processed time-of-flight measurement value is finally obtained.
[0016] Furthermore, the construction of the adaptive Kalman filter model, and the application of the adaptive Kalman filter model to the processed flight time measurements, yields the following statistical characteristics of the observation residuals: The processed flight time measurements are input into the Kalman filter for observation processing, and an adaptive Kalman filter model is constructed by combining the state transition equation and the observation equation. The estimated flight time and the actual observed time were calculated using the state transition equation and the observation equation, respectively. The residuals between the estimated flight time and the actual observed time are calculated to obtain the statistical characteristics of the observation residuals.
[0017] Furthermore, the process noise covariance matrix and measurement noise covariance matrix of the adaptive Kalman filter are corrected in real time based on the statistical characteristics of the observation residuals, and the optimal flight time estimate is output through prior prediction and posterior correction, including: An adaptive mechanism based on the statistical characteristics of observation residuals calculates the degree of deviation between the current observation and the prior state estimate, and outputs the observation residuals. The residual variance of the observed residual sequence is calculated in real time using the sliding window method, and the real-time calculated residual variance is compared with the preset empirical steady-state threshold to implement a graded adjustment strategy. When the residual variance is less than or equal to the preset empirical steady-state threshold, the flow rate is in a stable phase. The process noise covariance matrix and the measurement noise covariance matrix are kept at their initial values, and Kalman filtering is used to suppress random noise. When the residual variance exceeds the preset empirical steady-state threshold, it is in the flow change stage. The process noise covariance matrix is adaptively increased by a linear amplification function to improve the tracking rate of flight time changes. An adaptive Kalman filter model is used to make a priori prediction of the optimal flight time estimate of the previous time step, and the priori state estimate and prior error covariance of the current time step are output. By calculating the Kalman gain matrix, the initial value and the increased process noise covariance matrix are posteriorly corrected respectively, and the prior state estimate is corrected using the current observation value to obtain the optimal flight time estimate. Based on the prior error covariance, the Kalman gain matrix is updated in conjunction with the identity matrix for the next iteration update.
[0018] Furthermore, based on the optimal flight time estimate, the time difference between downstream and upstream flight times is calculated, and combined with preset channel geometry parameters and channel cross-sections, the instantaneous flow rate is output, including: The main control module uses the optimal flight time estimate, combined with the preset flow channel geometric parameters and fluid dynamics model, to calculate the instantaneous flow rate of the fluid, and calculates the linear average flow velocity of the fluid in the sound channel based on the time difference method ultrasonic flow measurement principle. The linear average velocity that is not equal to the cross-sectional average velocity is corrected using fluid dynamics correction factors; The current instantaneous flow rate is obtained by multiplying the cross-sectional area of the flow channel by the corrected linear average velocity. Based on the current instantaneous volumetric flow rate, the cumulative flow rate is obtained by integrating the time using the main control module. The instantaneous and cumulative traffic flow is displayed on an LCD screen using the main control module and uploaded to a remote monitoring center via an RS485 or LoRa interface.
[0019] Secondly, the present invention also provides a time-of-flight measurement device based on wavelet transform and adaptive Kalman filtering, the device comprising: The main control module is used to execute data processing algorithms, control the acquisition timing, and perform data interaction. The time-to-digital conversion module is communicatively connected to the main control module. It is used to transmit ultrasonic excitation signals and receive echo signals, convert analog echo signals into digital flight time data, and transmit the digital flight time data to the main control module. The signal conditioning module is connected to the signal input terminal of the time-to-digital converter module and is used to perform analog filtering and amplification on the received echo signal. An ultrasonic transducer assembly, connected to the signal conditioning module and the time-to-digital converter module, is used to realize the electroacoustic conversion of ultrasonic signals; The power supply module is electrically connected to the main control module and the time-to-digital converter module, and is used to provide power to the main control module and the time-to-digital converter module.
[0020] (III) Beneficial Effects Compared with existing technologies, the present invention provides a time-of-flight measurement method and apparatus based on wavelet transform and adaptive Kalman filtering, which has the following advantages: (1) To address the problem of measurement data jumps caused by turbid water environments, this invention introduces wavelet threshold transformation as a pre-filter. By utilizing the localization characteristics of wavelet analysis in the time and frequency domain, it is possible to accurately identify and remove high-frequency singularities mixed in with useful signals, solving the problem that traditional filters cannot handle non-Gaussian noise, and providing a high signal-to-noise ratio data foundation for subsequent processing.
[0021] (2) This invention improves upon the traditional Kalman filter algorithm by proposing a parameter adaptive adjustment strategy based on residual statistical characteristics. The system can intelligently identify two operating conditions: "steady-state flow" and "sudden flow change." In steady-state conditions, it maintains a strong filtering effect and smooth output; in sudden flow changes, it rapidly adjusts the model parameters to quickly follow the changes in the actual flow velocity. Experiments show that this method significantly reduces the measurement lag time and improves the accuracy of dynamic measurement.
[0022] (3) The algorithm provided by this invention is reasonably designed to avoid complex deep learning models and is suitable for real-time operation on low-end embedded microprocessors with floating-point units, such as STM32F407. While ensuring high-precision measurement, it does not require an expensive external host computer or high-performance DSP, which significantly reduces the hardware cost and power consumption of intelligent ultrasonic flow measurement equipment and has extremely high engineering promotion value. Attached Figure Description
[0023] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0024] Figure 1 This is a flowchart of a time-of-flight measurement method based on wavelet transform and adaptive Kalman filtering according to an embodiment of the present invention; Figure 2 This is a hardware structure block diagram of a time-of-flight measurement device based on wavelet transform and adaptive Kalman filtering according to an embodiment of the present invention; Figure 3 This is a detailed logic flowchart of the cascaded filtering algorithm in a time-of-flight measurement method based on wavelet transform and adaptive Kalman filtering according to an embodiment of the present invention; Figure 4 This is a comparison chart of signal processing effects under simulated operating conditions containing bubble interference and sudden flow changes according to an embodiment of the present invention.
[0025] In the picture: 1. Main control module; 2. Time-to-digital conversion module; 3. Signal conditioning module; 4. Ultrasonic transducer group; 5. Power supply module. Detailed Implementation
[0026] To further illustrate the various embodiments, the present invention provides accompanying drawings, which are part of the disclosure of the present invention. These drawings are mainly used to illustrate the embodiments and can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these drawings, those skilled in the art should be able to understand other possible implementation methods and the advantages of the present invention. The components in the drawings are not drawn to scale, and similar component symbols are generally used to represent similar components.
[0027] According to an embodiment of the present invention, a time-of-flight measurement method based on wavelet transform and adaptive Kalman filtering is provided.
[0028] The present invention will now be further described in conjunction with the accompanying drawings and specific embodiments, such as... Figure 1 As shown, a time-of-flight measurement method based on wavelet transform and adaptive Kalman filtering according to an embodiment of the present invention includes: Step S1: Configure the registers of the time-to-digital converter module 2 through the main control module 1, and set the first wave detection mode and the number of pulses emitted to complete the initialization settings; Step S2: After initialization is completed, the ultrasonic transducer group 4 is driven by the time-to-digital converter module 2 to transmit and receive ultrasonic waves and obtain the current original flight time measurement value. Step S3: Construct a sliding time window, perform wavelet transform processing on the original flight time measurements within the sliding time window, and remove high-frequency singular noise from the original flight time measurements to obtain the processed flight time measurements. Step S4: Construct an adaptive Kalman filter model and use the adaptive Kalman filter model to perform observation processing on the processed flight time measurement values, and calculate the statistical characteristics of the observation residuals; Step S5: Based on the statistical characteristics of the observation residuals, the process noise covariance matrix Q and the measurement noise covariance matrix R of the adaptive Kalman filter are corrected in real time, and the optimal flight time estimate is output through prior prediction and posterior correction. Step S6: Based on the optimal flight time estimate, calculate the time difference between downstream flight time and upstream flight time, and combine it with the preset flow channel geometric parameters and flow channel cross-section to calculate and output the instantaneous flow rate.
[0029] Specifically, after the system is powered on, the main control module 1 writes 32-bit configuration words to the TDC-GP22 sequentially via the SPI bus to complete the fine-tuning of the chip's operating mode. The specific configuration logic is as follows: Configure register REG0: Set DIV_CLKHS=0 to disable high-speed clock division; set START_CLKHS to a startup delay of 480μs to ensure clock stability; set ANZ_PER_CALRES=2 to select eight 32.768kHz cycles as the calibration reference; set MESSB2=1 to enable measurement range 2, between 500ns and 4ms, to accommodate long-distance ultrasonic transmission in the box-shaped flow channel; set NO_CAL_AUTO=0 to enable automatic calibration after measurement; set the number of pulses emitted ANZ_FIRE=20 to enhance ultrasonic signal energy.
[0030] Configure register REG1: Enable HITIN1=1 (Start) and HITIN2=2 (Stop1); set HIT1=1 and HIT2=2 to directly obtain the flight time from the Start transmission time to the Stop1 reception time using the ALU calculation formula; enable SEL_START_FIRE=1 to trigger the Start signal using the internal Fire pulse, simplifying the external circuit; set EN_START=1 to allow the output Start signal for oscilloscope observation.
[0031] Configure register REG2: Enable EN_INT_ALU=1 and EN_INT_TIMEOUT=1 to allow ALU calculation completion interrupt and timeout interrupt, so that the main control module 1 can respond in a timely manner; set the DELVAL1 window delay time to shield the direct wave interference after transmission and ensure that only the real echo is detected.
[0032] Configure register REG3: Enable EN_AUTOCAL_MB=1 to enable ALU automatic calibration and result averaging function in measurement range 2; enable EN_FIRST_WAVE=1 to activate intelligent first wave detection function; set SEL_TIMO_MB=3 to set an overflow time of 4096μs; finely configure the echo sampling points after the first wave detection: set DELREL1, DELREL2, and DELREL3 to be the 8th, 9th, and 10th echoes after the first wave, respectively, and use multi-pulse averaging technology to improve measurement accuracy.
[0033] Configure register REG4: Enable OFFS=15, which, together with the internal comparator's OFFS_RANG1, sets the total comparator bias voltage to +30mV, thereby improving the noise immunity threshold of zero-crossing detection and preventing false triggering by minor noise.
[0034] Configuration register REG5: Set CONF_FIRE=0 to configure an alternating mode of performing downlink measurements first and then uplink measurements; disable REPEAT_FIRE to prevent repetition during a single trigger, thus reducing power consumption.
[0035] Configure register REG6: Set EN_ANALOG=1 to enable the analog measurement front end. At this time, the STOP1 and STOP2 channels will automatically switch to analog input mode and directly connect to the ultrasonic transducer; set DA_KORR=7 to fine-tune the comparator offset voltage; set the highest bit of START_CLKHS to 1 to keep the high-speed crystal oscillator on and ensure measurement response speed.
[0036] like Figure 3 As shown, the cascaded filtering algorithm includes steps S3, S4 and S5.
[0037] In this optional embodiment, after the initialization settings are completed, the time-to-digital converter module 2 drives the ultrasonic transducer group 4 to perform ultrasonic transceiver operations, and the current raw time-of-flight measurement value is obtained, including: The main control module 1 sends initialization and start measurement commands to the time-to-digital converter module 2 via the SPI bus, driving the state machine inside the time-to-digital converter module 2 to start working; The state machine is used to measure the ultrasonic transducer sequentially by transmitting upstream and receiving downstream and transmitting downstream and receiving upstream. The measurement actions are received by the signal conditioning module 3, and the received measurement actions are processed by analog filtering and amplification. The data of the result register of the time-to-digital converter module 2 is read. Combined with the measurement actions, the downstream flight time and the upstream flight time are obtained. Calculate the average flight time of the downstream flight time and the upstream flight time, and use the average flight time of a single measurement as the current original flight time measurement value.
[0038] Specifically, the main control module 1 sends an initialization command (Opcode 0x70) and a measurement start command (Opcode 0x01) to the TDC-GP22 via the SPI bus, driving the internal state machine of the TDC-GP22 to start working and sequentially perform upstream transmission and downstream reception measurement actions.
[0039] Read the TDC-GP22 result register to obtain the downstream flight time. and reverse flight time The average flight time of a single measurement As of the present moment The original observations. Due to the scattering effect of air bubbles and suspended matter in the river water, the original sequence... It contains a mixture of non-Gaussian distributed impulse noise and Gaussian distributed random white noise.
[0040] In this optional embodiment, the process of constructing a sliding time window, performing wavelet transform processing on the original flight time measurements within the sliding time window, and removing high-frequency singular noise from the original flight time measurements to obtain processed flight time measurements includes: The wavelet thresholding denoising algorithm is used to separate the original flight time measurements to isolate abrupt noise from the original flight time measurements; The denoising threshold is calculated based on the Donoho universal threshold (VisuShrink) criterion, and the high-frequency detail coefficients of each layer are quantized based on the denoising threshold to preserve the edge features of the signal. Using the processed high-frequency detail coefficients and low-frequency approximation coefficients, wavelet reconstruction is performed layer by layer in order from deep to shallow, and the processed time-of-flight measurement is output.
[0041] Specifically, Symlets or Daubechies wavelet systems are selected as basis functions to decompose the original time-of-flight measurement into N levels, where N is a positive integer. The wavelet decomposition coefficients of each level are obtained, and the noise standard deviation is estimated based on the statistical characteristics of the first level detail coefficients, and a general threshold is calculated accordingly. A soft thresholding function or a hard thresholding function is used to quantize the high-frequency detail coefficients of each level using the general threshold. Wavelet reconstruction is performed using the processed high-frequency detail coefficients and low-frequency approximation coefficients to output the processed time-of-flight measurement.
[0042] In this optional embodiment, the step of using a wavelet thresholding algorithm to separate the original time-of-flight measurements to remove abrupt noise from the original time-of-flight measurements includes: Given the original time-of-flight signal, the Mallat tower algorithm is used to perform convolution and downsampling on the original time-of-flight signal through low-pass and high-pass filters respectively, and the low-frequency approximation coefficients and high-frequency detail coefficients are calculated. Based on the Symlet6 wavelet basis function, the layer is decomposed into three layers, so that the energy of the effective flow signal is mainly concentrated in the low-frequency approximation coefficients, while random noise and anomalous singular values are mainly concentrated in the high-frequency detail coefficients of each layer.
[0043] Specifically, in order to remove high-frequency singular outliers caused by bubble scattering and circuit interference under turbid water conditions, this embodiment uses a wavelet thresholding denoising algorithm to denoise the original measurement sequence. The process is then performed. Compared to the traditional Fourier transform, the wavelet transform has excellent time-frequency localization characteristics, which can effectively separate abrupt noise in non-stationary signals. The specific derivation and implementation steps are as follows: Let the original flight time signal be The Mallat pyramid algorithm is used to perform J-level multi-resolution decomposition on the signal. The decomposition process can be represented as the signal passing through a series of low-pass filters. and high-pass filter The convolution and downsampling process of the j-th layer. Low-frequency approximation coefficients. and high frequency detail coefficient The recursive formula is: ; In the formula, Indicates the low-frequency approximation coefficient; represents the high-frequency detail coefficients; j represents the current decomposition level, with a value range of j=1,2,...,J; k represents the discrete-time index; This indicates that the input signal is initialized to its original state. This represents the decomposed low-pass filter coefficients corresponding to the selected wavelet basis; ) represents the decomposed high-pass filter coefficients corresponding to the selected wavelet basis, and .
[0044] In this embodiment, the Symlet6 wavelet basis function is selected, and the number of decomposition levels is set to J=3. Under this parameter setting, the energy of the effective flow signal is mainly concentrated in the low-frequency approximation coefficients. In the meantime, random noise and anomalous singular values are mainly distributed in the high-frequency detail coefficients of each layer. middle.
[0045] In this optional embodiment, the calculation of the denoising threshold based on the Donoho universal threshold criterion, and the quantization of the high-frequency detail coefficients of each layer based on the denoising threshold to preserve the edge features of the signal, includes: The noise standard deviation is estimated using the median absolute deviation (MAD) of the first layer detail coefficients, and the noise standard deviation is output. The noise reduction threshold is calculated based on the noise standard deviation and the Donoho general threshold formula. A soft thresholding function is used to perform nonlinear shrinkage on the high-frequency detail coefficients of each layer to achieve a smoother denoising effect, which facilitates subsequent Kalman filtering.
[0046] Specifically, in order to preserve the edge features of the signal as much as possible while denoising, this embodiment uses the denoising threshold calculated based on the Donoho universal threshold (VisuShrink) criterion. This criterion considers noise in the wavelet domain to primarily manifest as high-frequency coefficients with small amplitudes, and its calculation process consists of two steps: Step 1: Estimate the noise standard deviation using the first-level detail coefficients. Robust estimation of the median absolute deviation (MAD) is performed using the following formula: ; Step 2: Perform a general threshold calculation based on the estimated noise standard deviation mentioned above. The final threshold is calculated according to the Donoho general threshold formula. The calculation formula is: ; In the formula, This represents the data length of the current sliding time window; in this embodiment, it is taken as... =32. This formula ensures that Gaussian white noise is eliminated with a high probability, retaining only the main features of the signal.
[0047] Traditional hard thresholding function The presence of discontinuities at certain points can easily lead to pseudo-Gibbs oscillations in the reconstructed signal. To achieve a smoother denoising effect and facilitate subsequent Kalman filtering, this embodiment uses a soft thresholding function for the detail coefficients of each layer. Perform nonlinear shrinkage processing.
[0048] The mathematical expression for the soft threshold function is: ; In the formula, Indicates the first step before processing The k-th detail coefficient of the layer; This represents the coefficients after threshold quantization. Indicates a general threshold; This function represents the sign of a variable; it takes the value 1 when the variable is greater than 0, -1 when the variable is less than 0, and 0 when the variable is equal to 0. This function assigns values less than 0 to the absolute values of variables. Setting the coefficient to zero is used to filter out noise, and the coefficient with an absolute value greater than 0.5 is used to filter out noise. The coefficients shrink to zero to suppress the amplitude of singular values, and have good continuity and derivative properties.
[0049] In this optional embodiment, the process of using the processed high-frequency detail coefficients and low-frequency approximation coefficients to perform layer-by-layer wavelet reconstruction in a deep-to-shallow order, and outputting the processed time-of-flight measurement values, includes: The second-layer low-frequency approximation coefficients are obtained by reconstructing the third-layer low-frequency approximation coefficients and the processed third-layer high-frequency detail coefficients through wavelet inverse transform. The first-level low-frequency approximation coefficients are obtained by reconstructing the second-level low-frequency approximation coefficients and the processed second-level high-frequency detail coefficients through wavelet inverse transform. The first-level low-frequency approximation coefficients and the processed first-level high-frequency detail coefficients are reconstructed by inverse wavelet transform, and the processed time-of-flight measurement value is finally obtained.
[0050] Specifically, using the processed detail coefficients (where j=1,2,3) and the third-level approximation coefficients The reconstruction is performed layer by layer, from deepest to shallowest. The specific steps are as follows: Step 1: Utilizing the third-level approximation coefficients and the processed level 3 detail coefficient The second-level approximation coefficients are obtained by reconstructing using inverse wavelet transform. ; Step 2: Utilize the results obtained from the reconstruction and the processed second layer detail coefficient The first-level approximation coefficients are obtained by reconstructing using inverse wavelet transform. ; Step 3: Utilize the results obtained from reconstruction and the processed first layer detail coefficient The final denoised signal is obtained by reconstructing the signal through inverse wavelet transform.
[0051] The reconstructed recursive formula is uniformly expressed as: ; in, This represents the approximation coefficients for higher resolution layers; This represents the detail coefficients of the j-th layer after thresholding. This represents the reconstructed low-pass filter coefficients corresponding to the selected wavelet basis; This represents the reconstruction high-pass filter coefficients corresponding to the selected wavelet basis. The final reconstructed... This refers to the time-of-flight measurement after denoising preprocessing; j represents the current decomposition layer number; k represents the discrete-time index of the reconstructed signal; and n represents the shift variable during the convolution summation process.
[0052] The final reconstructed result This is the flight time measurement after noise reduction. .
[0053] In this optional embodiment, the construction of the adaptive Kalman filter model and the application of the adaptive Kalman filter model to the processed time-of-flight measurements, and the calculation of the statistical characteristics of the observation residuals, include: The processed flight time measurements are input into the Kalman filter for observation processing, and an adaptive Kalman filter model is constructed by combining the state transition equation and the observation equation. The estimated flight time and the actual observed time were calculated using the state transition equation and the observation equation, respectively. The residuals between the estimated flight time and the actual observed time are calculated to obtain the statistical characteristics of the observation residuals.
[0054] Specifically, the denoised flight time measurement value An adaptive Kalman filter model for a linear discrete system is constructed using the observed inputs to the Kalman filter. The adaptive Kalman filter model consists of two parts: the state transition equation and the observation equation, which can be expressed as: ; In the formula, the first row of state transition equations describes the evolution of the system state over time. Wherein... This represents the actual flight time state of the system at time k, which is determined by the state at the previous time. It is derived from the state transition matrix A and superimposed with process noise. This embodiment assumes that the flow velocity can be considered constant or uniformly changing within a very short sampling period, therefore A=1 is chosen.
[0055] The second line of the observation equation describes the mapping relationship between the measured values and the true state. Wherein... This represents the actual observation value acquired by the sensor at time k, which is determined by the true state. Observation matrix It is mapped and superimposed with measurement noise. In this embodiment, H=1 is used, representing the direct observation flight time. Process noise represents the random fluctuations in the system's true state caused by environmental disturbances. It is assumed to follow a Gaussian distribution with a mean of 0 and a covariance of Q. ; To measure noise, we represent the random error introduced by the sensor, which is assumed to follow a Gaussian distribution with a mean of 0 and a covariance of R. .
[0056] In this optional embodiment, the process noise covariance matrix Q and measurement noise covariance matrix R of the adaptive Kalman filter are corrected in real time based on the statistical characteristics of the observation residuals, and the optimal flight time estimate is output through prior prediction and posterior correction, including: An adaptive mechanism based on the statistical characteristics of observation residuals calculates the degree of deviation between the current observation and the prior state estimate, and outputs the observation residuals. The residual variance of the observed residual sequence is calculated in real time using the sliding window method, and the real-time calculated residual variance is compared with the preset empirical steady-state threshold to implement a graded adjustment strategy. When the residual variance is less than or equal to the preset empirical steady-state threshold, the flow rate is in a stable phase. The process noise covariance matrix Q and the measurement noise covariance matrix R are kept at their initial values, and Kalman filtering is used to suppress random noise. When the residual variance exceeds the preset empirical steady-state threshold, it is in the flow change stage. The process noise covariance matrix Q is adaptively increased by a linear amplification function to improve the tracking rate of flight time changes. An adaptive Kalman filter model is used to make a priori prediction of the optimal flight time estimate of the previous time step, and the priori state estimate and prior error covariance of the current time step are output. By calculating the Kalman gain matrix, the initial value and the increased process noise covariance matrix Q are posteriorly corrected respectively, and the prior state estimate is corrected using the current observation value to obtain the optimal flight time estimate. Based on the prior error covariance, the Kalman gain matrix is updated in conjunction with the identity matrix for the next iteration update.
[0057] Specifically, in traditional Kalman filtering, the process noise covariance Q and the measurement noise covariance R are usually set as fixed constants. This results in good filtering performance when the fluid is in a steady state, but the algorithm cannot track changes in flow velocity in time, leading to severe phase lag. To resolve this contradiction, this embodiment introduces an adaptive mechanism based on the statistical characteristics of the observation residual sequence to dynamically adjust the process noise covariance Q.
[0058] Observation residuals reflect the degree of deviation between actual observed values and prior predicted values: ; In the formula, The observation residual at any given moment; This represents the observation input at the current moment; This represents the estimated value of the prior state; This represents the observation matrix.
[0059] To assess the stability of the flow velocity at the current moment, a sliding window method is used to calculate the local variance of the residual sequence in real time. A sliding window of length 5 is constructed, and the variance estimation formula is as follows: ; In the formula, The variance estimate of the time-residuals; The sliding window length represents the number of historical residuals involved in the variance calculation; Indicates from the current moment Calculate forward the first The observation residual value at each time point.
[0060] Set a preset empirical steady-state threshold The variance will be calculated in real time. Compared with a preset empirical steady-state threshold, the following graded adjustment strategy is executed: When the residual variance is less than or equal to the preset empirical steady-state threshold At this point, the system is determined to be in a stable flow phase. The process noise covariance is maintained at this time. The initial minimum value At this point, the Kalman gain... The smaller the value, the more the filter trusts the "predicted value," thus powerfully smoothing measurement noise and ensuring the stability of the output curve.
[0061] When the residual variance exceeds the preset empirical steady-state threshold At this point, a sudden change in flow rate was detected in the system. Continuing to use a small Q value at this time would lead to slow tracking. This embodiment uses a linear amplification function to adaptively increase the value. The formula is: ; in, As the adjustment coefficient, this embodiment takes... =10; with The significant increase in prediction error covariance This increases accordingly, leading to a Kalman gain. It rapidly approaches 1. Mathematically, this means the filter removes historical information and instead highly trusts the current observation. This eliminates hysteresis and enables millisecond-level rapid tracking of flow velocity changes. Through this strategy, the algorithm can seamlessly and automatically switch between "steady-state filtering" and "dynamic rapid tracking."
[0062] The standard Kalman filter consists of two stages: time update and measurement update. The specific calculation steps are as follows: Based on the optimal flight time estimate from the previous moment, a priori prediction is made, and the formula for predicting the state at the current moment is: ; The formula for predicting the error covariance at the current moment is: ; In the formula, This represents the prior state estimate; This represents the posterior best estimate from the previous time step. This represents the prior error covariance; This represents the posterior error covariance of the previous time step; The superscript T in the matrix indicates the transpose operation; in this embodiment, A represents the scalar 1, and its transpose value is still 1.
[0063] Next, posterior correction is performed. The formula for calculating the Kalman gain is: ; The formula for revising the predicted values using the current observations to obtain the optimal flight time estimate is as follows: ; The formula for updating the error covariance in preparation for the next iteration is: ; In the formula, This represents the Kalman gain matrix, which determines the weight of the observations in the final estimate; Let represent the identity matrix, which is scalar 1 in this embodiment. Through the above iterations, the filter can output the optimal time-of-flight estimate in the sense of minimum mean square error. .
[0064] In this optional embodiment, the calculation of the time difference between downstream and upstream flight times based on the optimal flight time estimate, combined with preset channel geometry parameters and channel cross-section, outputs the instantaneous flow rate, including: The main control module 1 uses the optimal flight time estimate, combined with the preset flow channel geometric parameters and fluid dynamics model, to calculate the instantaneous flow rate of the fluid, and calculates the linear average flow velocity of the fluid in the sound channel according to the time difference method ultrasonic flow measurement principle. The linear average velocity that is not equal to the cross-sectional average velocity is corrected using fluid dynamics correction factors; The current instantaneous flow rate is obtained by multiplying the cross-sectional area of the flow channel by the corrected linear average velocity. Based on the current instantaneous volumetric flow rate, the cumulative flow rate is obtained by integrating the time using the main control module 1. The instantaneous and cumulative traffic flow is displayed on the LCD screen using the main control module 1 and uploaded to the remote monitoring center via RS485 or LoRa interface.
[0065] Specifically, the main control module 1 uses the output optimal flight time estimate. By combining preset flow channel geometry parameters and a fluid dynamics model, the instantaneous flow rate is calculated and accumulated. Based on the time-of-flight ultrasonic flow measurement principle, the linear average velocity of the fluid in the sound channel is... The calculation formula is: ; In the formula, This indicates the length of the propagation path of an ultrasonic wave in a fluid. , These represent the downstream and upstream flight times after filtering, respectively.
[0066] Because fluids in pipes or culverts have a velocity distribution profile, the line-average velocity is not equal to the cross-sectional average velocity. Therefore, a fluid dynamics correction factor is introduced. The formula for its correction is as follows: ; In the formula, This is the velocity distribution correction factor, which is related to the Reynolds number Re and the roughness of the flow channel. It is usually obtained through actual flow calibration and its value is generally between 0.92 and 0.98.
[0067] Calculate the current instantaneous volumetric flow rate using the cross-sectional area S of the flow channel. : ; To achieve water resource metering and settlement, the main control module 1 integrates the instantaneous flow rate over time to obtain the cumulative flow rate. : ; In the formula, This represents the cumulative flow from the previous moment. This is the system sampling period.
[0068] Finally, the main control module 1 will calculate the instantaneous flow rate. and cumulative traffic The data is displayed on an LCD screen and uploaded to a remote monitoring center via an RS485 or LoRa interface.
[0069] like Figure 2 As shown, according to another embodiment of the present invention, a time-of-flight measurement device based on wavelet transform and adaptive Kalman filtering is also provided, the device comprising: Main control module 1 is used to execute data processing algorithms, control the acquisition timing, and perform data interaction; The time-to-digital conversion module 2 is communicatively connected to the main control module 1. It is used to transmit ultrasonic excitation signals and receive echo signals, convert analog echo signals into digital flight time data, and transmit the digital flight time data to the main control module 1. Signal conditioning module 3 is connected to the signal input terminal of time-to-digital converter module 2 and is used to perform analog filtering and amplification processing on the received echo signal; The ultrasonic transducer group 4 is connected to the signal conditioning module 3 and the time-to-digital converter module 2 to realize the electroacoustic conversion of ultrasonic signals. The power module 5 is electrically connected to the main control module 1 and the time-to-digital converter module 2, and is used to provide power to the main control module 1 and the time-to-digital converter module 2.
[0070] The main control module 1 is equipped with a cascaded filtering processing unit. The cascaded filtering processing unit performs wavelet transform and adaptive Kalman filtering on the raw flight time measurement values collected by the time-to-digital conversion module 2 in sequence to output the optimal flight time estimate.
[0071] Specifically, the main control module 1 uses an STM32F407ZGT6 microcontroller. This chip is based on the ARM Cortex-M4 core, with a main frequency of up to 168MHz, and has a built-in single-precision floating-point unit (FPU) and DSP instruction set, which can meet the millisecond-level real-time computing requirements of complex filtering algorithms in this embodiment.
[0072] The time-to-digital converter module 2 uses the AMS TDC-GP22 chip. This chip is specifically designed for ultrasonic flow meters and features intelligent first-wave detection.
[0073] In the communication connection, the STM32F407 connects to SCK via PB3, MISO via PB4, and MOSI via PB5 in the SPI1 interface, and communicates with the TDC-GP22; the PB12 pin of the STM32F407 is connected to the TDC-GP22 as the CSN chip select signal; the PB0 pin of the STM32F407 is configured as an external interrupt input and connected to the INIT pin of the TDC-GP22 to receive the measurement completion interrupt signal.
[0074] The ultrasonic transducer group 4 includes transducer A installed upstream of the water flow channel and transducer B installed downstream, which are respectively connected to the analog input channel of TDC-GP22.
[0075] Specifically, the main control module 1 adopts any one of the STM32 series microcontrollers, GD32 series microcontrollers, or FPGA programmable logic devices; the time-to-digital conversion module 2 adopts any one of the TDC-GP22 chip, TDC-GP21 chip, or MS1022 chip; the main control module 1 and the time-to-digital conversion module 2 communicate in full-duplex via the SPI bus.
[0076] To verify the effectiveness of the proposed time-of-flight measurement method based on wavelet transform and adaptive Kalman filtering, a practical experimental platform based on STM32F407+TDC-GP22 was built. Three typical operating conditions were selected for testing, and the method of this invention was compared and analyzed with traditional moving average filtering and standard Kalman filtering.
[0077] The stability of the time measurement system was tested under static water (zero flow velocity) conditions. The main sources of interference were circuit thermal noise and TDC quantization error. Raw data: The standard deviation (STD) of the raw data directly output by the TDC-GP22 was 185 ps, exhibiting random jitter. Traditional method: After applying a moving average filter with a window length of 10, the STD decreased to 82 ps. Invention method: After processing with the algorithm of this invention, the STD decreased to 24 ps.
[0078] In the anti-interference test under turbid water conditions containing air bubbles, compressed air was injected into the circulating water circuit to simulate air bubble interference, while a small amount of sediment was mixed in to simulate a turbid water environment. At this time, the original echo signal was distorted, and large-amplitude impulse noise (singular values) appeared in the measurement data. For example... Figure 4 As shown, the original flight time series, i.e., the gray curve, frequently exhibits sharp peak jumps that deviate from the true value by more than ±2ns, which is a typical characteristic caused by bubble interference.
[0079] Comparative analysis: Since bubble noise belongs to a heavy-tailed non-Gaussian distribution, the mean square error criterion of the standard Kalman filter causes the estimated value to be significantly skewed by outliers, resulting in obvious spikes in the filter curve and an inability to effectively remove singular values.
[0080] The method of this invention utilizes Symlet6 wavelet soft thresholding denoising as a preprocessing step, successfully identifying and eliminating over 98% of high-frequency singularities. The data input to the Kalman filter has been freed from outlier contamination, resulting in a smooth and stable red solid line output with a significantly reduced root mean square error (RMSE) compared to the standard Kalman filter.
[0081] In the dynamic response test under the condition of sudden flow change, the flow velocity was simulated to rise linearly from 10 m / s to 15 m / s by rapidly adjusting the opening of the pipeline valve, and the dynamic tracking capability of the algorithm was tested.
[0082] Test phenomena such as Figure 4 As shown, within the sampling point range of k=200 to k=300, the actual flow velocity, represented by the black dashed line, experienced a rapid linear increase.
[0083] Comparative analysis: Although the gray curve generally follows the trend of flow velocity change, it is superimposed with serious random noise and cannot accurately reflect the starting and ending points of flow velocity change.
[0084] The method of this invention: When the flow velocity changes instantaneously, this algorithm detects in real time that the variance of the observation residual exceeds a threshold, and immediately adaptively increases the process noise covariance Q. As shown in the figure, the red solid line closely follows the black dashed line, which not only smooths the noise, but also shows no obvious overshoot or lag at the starting point of k=200 and the stable point of k=300, proving the algorithm's millisecond-level tracking capability under dynamic flow velocity conditions.
[0085] Experimental data show that although the computation time of the method of the present invention is slightly longer than that of the traditional linear algorithm, it is still within the real-time processing capability of STM32F4. Moreover, it has achieved significant advantages in measurement accuracy, anti-bubble interference capability and dynamic response speed, and fully meets the complex flow measurement needs of agricultural irrigation areas and industrial sites.
[0086] In summary, with the aid of the above-mentioned technical solution of the present invention, a time-of-flight measurement device based on wavelet transform and adaptive Kalman filtering includes a main control module 1, a time-to-digital conversion module 2, a signal conditioning module 3, and an ultrasonic transducer group 4. The main control module 1 controls the working timing of the time-to-digital conversion module 2 through a communication interface. The time-to-digital conversion module 2 drives the ultrasonic transducer group 4 to emit ultrasonic signals and receives echo signals after propagation through the fluid, converting the analog echo signals into digital raw time-of-flight data and transmitting it to the main control module 1. The main control module 1 internally runs a cascaded filtering algorithm and is configured to perform the following operations: acquire the raw time-of-flight sequence output by the time-to-digital conversion module 2; perform wavelet threshold denoising on the raw time-of-flight sequence, using the multi-resolution characteristics of wavelet transform to identify and remove high-frequency singular noise, and reconstruct preprocessed time data; construct an adaptive Kalman filter model, inputting the preprocessed time data as the observation value into the model; calculate the statistical characteristics of the observation residuals in real time, and dynamically adjust the process noise covariance matrix Q of the Kalman filter model according to the statistical characteristics, outputting the optimal estimated time-of-flight value.
[0087] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A time-of-flight measurement method based on wavelet transform and adaptive Kalman filtering, characterized in that, include: The main control module configures the registers of the time-to-digital converter module, sets the first wave detection mode and the number of pulses emitted, and completes the initialization settings. After initialization, the time-to-digital converter module is used to drive the ultrasonic transducer group to transmit and receive ultrasonic waves and obtain the current raw flight time measurement value. A sliding time window is constructed, and the original flight time measurements within the sliding time window are processed by wavelet transform. High-frequency singular noise in the original flight time measurements is then removed to obtain the processed flight time measurements. An adaptive Kalman filter model was constructed, and the processed flight time measurements were observed using the adaptive Kalman filter model to calculate the statistical characteristics of the observation residuals. Based on the statistical characteristics of the observation residuals, the process noise covariance matrix and measurement noise covariance matrix of the adaptive Kalman filter are corrected in real time. Through prior prediction and posterior correction, the optimal flight time estimate is output to achieve the measurement of flight time. Based on the optimal flight time estimate, the time difference between downstream and upstream flight time is calculated, and the instantaneous flow rate is output by combining the preset flow channel geometry parameters and flow channel cross-section.
2. The time-of-flight measurement method based on wavelet transform and adaptive Kalman filtering according to claim 1, characterized in that, After the initialization settings are completed, the ultrasonic transducer group is driven by the time-to-digital converter module to perform ultrasonic transceiver operations and obtain the current raw time-of-flight measurement value, including: The main control module sends initialization and start measurement commands to the time-to-digital converter module via the SPI bus, driving the state machine inside the time-to-digital converter module to start working; The state machine is used to measure the upstream transmission and downstream reception of the ultrasonic transducer and the downstream transmission and upstream reception in sequence. The measurement actions are received by the signal conditioning module and the data in the result register of the time-to-digital converter is read. Combined with the measurement actions, the downstream flight time and the upstream flight time are obtained. Calculate the average flight time of the downstream flight time and the upstream flight time, and use the average flight time of a single measurement as the current original flight time measurement value.
3. The time-of-flight measurement method based on wavelet transform and adaptive Kalman filtering according to claim 1, characterized in that, The process involves constructing a sliding time window, performing wavelet transform on the original flight time measurements within the window, and removing high-frequency singular noise from the original flight time measurements. The resulting processed flight time measurements include: The wavelet thresholding denoising algorithm is used to separate the original flight time measurements to isolate abrupt noise from the original flight time measurements; The denoising threshold is calculated based on the Donoho universal threshold criterion, and the high-frequency detail coefficients of each layer are quantized based on the denoising threshold. Using the processed high-frequency detail coefficients and low-frequency approximation coefficients, wavelet reconstruction is performed layer by layer in order from deep to shallow, and the processed time-of-flight measurement is output.
4. The time-of-flight measurement method based on wavelet transform and adaptive Kalman filtering according to claim 3, characterized in that, The wavelet threshold denoising algorithm is used to separate the original flight time measurements, and the resulting abrupt noise is separated from the original flight time measurements, including: Given the original time-of-flight signal, the Mallat tower algorithm is used to perform convolution and downsampling on the original time-of-flight signal through low-pass and high-pass filters respectively, and the low-frequency approximation coefficients and high-frequency detail coefficients are calculated. Based on the Symlet6 wavelet basis function, the layer is decomposed into three layers.
5. The time-of-flight measurement method based on wavelet transform and adaptive Kalman filtering according to claim 4, characterized in that, The calculation of the denoising threshold based on the Donoho universal threshold criterion, and the quantization processing of the high-frequency detail coefficients of each layer based on the denoising threshold, includes: The noise standard deviation is estimated using the median absolute deviation (MAD) of the first layer detail coefficients, and the noise standard deviation is output. The noise reduction threshold is calculated based on the noise standard deviation and the Donoho general threshold formula. The high-frequency detail coefficients of each layer are nonlinearly shrunk using a soft thresholding function.
6. The time-of-flight measurement method based on wavelet transform and adaptive Kalman filtering according to claim 5, characterized in that, The process involves using the processed high-frequency detail coefficients and low-frequency approximation coefficients to perform layer-by-layer wavelet reconstruction in a deep-to-shallow order. The output processed time-of-flight measurements include: The second-layer low-frequency approximation coefficients are obtained by reconstructing the third-layer low-frequency approximation coefficients and the processed third-layer high-frequency detail coefficients through wavelet inverse transform. The first-level low-frequency approximation coefficients are obtained by reconstructing the second-level low-frequency approximation coefficients and the processed second-level high-frequency detail coefficients through wavelet inverse transform. The first-level low-frequency approximation coefficients and the processed first-level high-frequency detail coefficients are reconstructed by inverse wavelet transform, and the processed time-of-flight measurement value is finally obtained.
7. The time-of-flight measurement method based on wavelet transform and adaptive Kalman filtering according to claim 1, characterized in that, The construction of the adaptive Kalman filter model, and the application of the adaptive Kalman filter model to the processed flight time measurements, yields statistical characteristics of the observation residuals, including: The processed flight time measurements are input into the Kalman filter for observation processing, and an adaptive Kalman filter model is constructed by combining the state transition equation and the observation equation. The estimated flight time and the actual observed time were calculated using the state transition equation and the observation equation, respectively. The residuals between the estimated flight time and the actual observed time are calculated to obtain the statistical characteristics of the observation residuals.
8. The time-of-flight measurement method based on wavelet transform and adaptive Kalman filtering according to claim 7, characterized in that, The statistical characteristics based on the observation residuals are used to correct the process noise covariance matrix and measurement noise covariance matrix of the adaptive Kalman filter in real time. Through prior prediction and posterior correction, the optimal flight time estimate is output, including: An adaptive mechanism based on the statistical characteristics of observation residuals calculates the degree of deviation between the current observation and the prior state estimate, and outputs the observation residuals. The residual variance of the observed residual sequence is calculated in real time using the sliding window method, and the real-time calculated residual variance is compared with the preset empirical steady-state threshold to implement a graded adjustment strategy. When the residual variance is less than or equal to the preset empirical steady-state threshold, the flow rate is in a stable phase. The process noise covariance matrix and the measurement noise covariance matrix are kept at their initial values, and Kalman filtering is used to suppress random noise. When the residual variance exceeds the preset empirical steady-state threshold, it is in the flow change stage. The process noise covariance matrix is adaptively increased by a linear amplification function to improve the tracking rate of flight time changes. An adaptive Kalman filter model is used to make a priori prediction of the optimal flight time estimate of the previous time step, and the priori state estimate and prior error covariance of the current time step are output. By calculating the Kalman gain matrix, the initial value and the increased process noise covariance matrix are posteriorly corrected respectively, and the prior state estimate is corrected using the current observation value to obtain the optimal flight time estimate. Based on the prior error covariance, the Kalman gain matrix is updated in conjunction with the identity matrix for the next iteration update.
9. The time-of-flight measurement method based on wavelet transform and adaptive Kalman filtering according to claim 1, characterized in that, The time difference between downstream and upstream flight times is calculated based on the optimal flight time estimate, and then combined with preset channel geometry parameters and channel cross-sections to calculate and output instantaneous flow rates, including: The main control module uses the optimal flight time estimate, combined with the preset flow channel geometric parameters and fluid dynamics model, to calculate the instantaneous flow rate of the fluid, and calculates the linear average flow velocity of the fluid in the sound channel based on the time difference method ultrasonic flow measurement principle. The linear average velocity that is not equal to the cross-sectional average velocity is corrected using fluid dynamics correction factors; The current instantaneous flow rate is obtained by multiplying the cross-sectional area of the flow channel by the corrected linear average velocity. Based on the current instantaneous volumetric flow rate, the cumulative flow rate is obtained by integrating the time using the main control module. The instantaneous and cumulative traffic flow is displayed on an LCD screen using the main control module and uploaded to a remote monitoring center via an RS485 or LoRa interface.
10. A time-of-flight measurement device based on wavelet transform and adaptive Kalman filtering, used to implement the time-of-flight measurement method based on wavelet transform and adaptive Kalman filtering as described in any one of claims 1-9, characterized in that, include: The main control module is used to execute data processing algorithms, control the acquisition timing, and perform data interaction. The time-to-digital conversion module is communicatively connected to the main control module. It is used to transmit ultrasonic excitation signals and receive echo signals, convert analog echo signals into digital flight time data, and transmit the digital flight time data to the main control module. The signal conditioning module is connected to the signal input terminal of the time-to-digital converter module and is used to perform analog filtering and amplification on the received echo signal. An ultrasonic transducer assembly, connected to the signal conditioning module and the time-to-digital converter module, is used to realize the electroacoustic conversion of ultrasonic signals. The power supply module is electrically connected to the main control module and the time-to-digital converter module, and is used to provide power to the main control module and the time-to-digital converter module.