Water level measurement method and system, electronic equipment and storage medium
By acquiring water level measurement signals using millimeter-wave radar, performing signal preprocessing and Fourier transform, and combining this with Kalman filtering algorithms, the accuracy and cost issues of radar water level gauges in complex hydrological scenarios were resolved, achieving high-precision water level measurement.
Patent Information
- Application Number
- CN202511201268.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-26
- Publication Date
- 2025-11-11
AI Technical Summary
Existing radar level gauges do not fully meet the requirements in terms of ranging accuracy, blind zone control, and cost balance in complex hydrological scenarios. Millimeter-wave radars have technical shortcomings in signal processing in water level measurement scenarios, which affects measurement accuracy.
Millimeter-wave radar is used for water level measurement. By acquiring the echo analog signal, signal preprocessing and fast Fourier transform are performed to extract the amplitude spectrum and phase spectrum. Peak detection and phase difference calculation are then performed. Combined with adaptive Kalman filtering and dynamic weighted averaging, high-precision water level measurement is achieved.
It achieves high-precision water level measurement in complex hydrological scenarios, overcomes interference from harsh environments, reduces maintenance costs, and improves measurement stability through multi-level anti-fluctuation processing.
Smart Images

Figure CN120927097A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of water level measurement technology, and in particular to a water level measurement method and system, electronic device and storage medium. Background Technology
[0002] In the fields of hydrological monitoring and smart city ecological sensing, accurate measurement of elements such as water level and flow velocity is crucial for ensuring flood control and disaster reduction, water resource management, and urban waterlogging prevention. With technological advancements, radar level gauges have gradually become a research hotspot due to their advantages such as non-contact operation and strong anti-interference capabilities; however, their performance still has room for improvement. Existing radar level gauges do not yet fully meet the needs of complex hydrological scenarios (such as urban pipelines and turbulent rivers) in terms of ranging accuracy, blind zone control, and cost balance. Millimeter-wave frequency-modulated continuous wave (FMCW) radar, as an emerging ranging technology, possesses characteristics such as high accuracy, small blind zone, simple structure, and low cost, effectively compensating for the shortcomings of traditional technologies. It achieves distance detection through continuously frequency-modulated radio waves, overcoming interference from harsh environments in water level measurement, and does not require direct contact with the water body, significantly reducing maintenance costs. However, the application of millimeter-wave radar in water level measurement scenarios is not yet mature, and there are technical shortcomings in signal processing, which adversely affect measurement accuracy. Summary of the Invention
[0003] This invention provides a water level measurement method and system, electronic device and storage medium, which can achieve high-precision water level measurement using millimeter-wave radar.
[0004] In a first aspect, embodiments of the present invention provide a water level measurement method applied to a water level measurement system, wherein the water level detection system includes a main control chip and a millimeter-wave radar, and the method includes:
[0005] Acquire simulated echo signals from the target water area detected by millimeter-wave radar;
[0006] The echo analog signal is preprocessed to obtain a preprocessed signal;
[0007] Perform a Fast Fourier Transform on the preprocessed signal to obtain the signal spectrum;
[0008] The amplitude and phase of the signal spectrum are extracted to obtain the amplitude spectrum and phase spectrum;
[0009] Peak detection and neighbor selection are performed based on the amplitude spectrum to determine the location of the main peak and the location of neighboring points.
[0010] Based on the phase spectrum, the phase difference between the main peak position and the adjacent point position is calculated and fine interpolation is performed to obtain a finely estimated frequency.
[0011] Based on the finely estimated frequency, the analog-to-digital conversion acquisition rate of the millimeter-wave radar, and the linear frequency modulation bandwidth, the preliminary water level measurement value is calculated.
[0012] The target water level is obtained by performing dynamic weighted averaging and adaptive Kalman filtering on the preliminary water level measurement and historical water level measurement.
[0013] In some embodiments, prior to acquiring the echo signal of the target water level detected by the millimeter-wave radar, the method further includes:
[0014] Initialize the operating parameters of the water level detection system;
[0015] Calibrate the analog-to-digital converter voltage of the millimeter-wave radar;
[0016] After the analog-to-digital converter voltage is calibrated, the millimeter-wave radar is controlled by the state machine running on the main control chip to transmit linear frequency modulated continuous waves toward the target water area.
[0017] When the time for transmitting the linear frequency modulated continuous wave and the detection of the linear frequency modulated continuous wave reflected back from the target water area meet preset conditions, the acquisition of the echo analog signal is triggered.
[0018] In some embodiments, after acquiring the simulated echo signal of the target water area detected by the millimeter-wave radar, the method further includes:
[0019] The echo analog signal is stored in the target memory space of the water level measurement system using a grouped data transfer (DMA) channel, and the target memory space is isolated from other data memory spaces.
[0020] In some embodiments, the preprocessing of the echo analog signal to obtain a preprocessed signal includes:
[0021] Exclude abrupt changes in the echo analog signal that exceed a set threshold range, which is determined based on the measurement range set by the installation height of the millimeter-wave radar itself.
[0022] The echo analog signal is filtered to remove high-frequency noise using a wavelet transform algorithm to obtain the preprocessed signal.
[0023] In some embodiments, the step of performing dynamic weighted averaging and adaptive Kalman filtering on the preliminary water level measurement and historical water level measurement to obtain the target water level measurement includes:
[0024] The preliminary water level measurement and the historical water level measurement are dynamically weighted and averaged to obtain a multi-frame weighted fused measurement value;
[0025] The water level value is obtained by iterative calculation after performing adaptive Kalman filtering on the multi-frame weighted fused measurement values.
[0026] In some embodiments, the step of performing Kalman filtering on the multi-frame weighted fused measurement values and iteratively calculating the water level value includes:
[0027] A state vector is generated by using the water level height of the target water area at a certain moment as the core estimator and the water level change rate as the auxiliary estimator.
[0028] Construct the Kalman filter measurement equation based on the state vector;
[0029] The predicted value is determined based on the multi-frame weighted fusion measurement value and the Kalman filter measurement equation;
[0030] The noise covariance matrix is adjusted based on the measurement residuals of the predicted values and the multi-frame weighted fused measurement values. The noise covariance matrix includes a process noise variance matrix and a measurement noise variance matrix.
[0031] Calculate the Kalman gain based on the process noise variance matrix and the measurement noise variance matrix;
[0032] The water level value is obtained by iterative calculation based on the updated state estimate and error covariance using the Kalman gain.
[0033] In some embodiments, the operating states of the water level measurement system include full-speed operation, standby, and sleep states. When the water level measurement system is first powered on, it is in standby mode. When the water level measurement system starts detection, it switches from standby mode to full-speed operation mode. After the water level measurement system completes target detection and data reporting, it switches from full-speed operation mode to sleep state. When the water level measurement system meets the detection frequency setting, it switches from sleep state to standby mode until periodic detection is completed.
[0034] Secondly, embodiments of the present invention also provide a water level measurement system, the system comprising:
[0035] The acquisition module is used to acquire the simulated echo signal of the target water area detected by the millimeter-wave radar;
[0036] The preprocessing module is used to perform signal preprocessing on the echo analog signal to obtain a preprocessed signal;
[0037] The transformation module is used to perform a fast Fourier transform on the preprocessed signal to obtain the signal spectrum;
[0038] The extraction module is used to extract the amplitude and phase of the signal spectrum to obtain the amplitude spectrum and phase spectrum;
[0039] The selection module is used to perform peak detection and neighbor selection based on the amplitude spectrum, and to determine the position of the main peak and the position of the neighboring points.
[0040] The interpolation module is used to calculate the phase difference and perform fine interpolation on the main peak position and the adjacent point position based on the phase spectrum to obtain a finely estimated frequency.
[0041] The calculation module is used to calculate the preliminary water level measurement value based on the finely estimated frequency, the analog-to-digital conversion acquisition rate of the millimeter-wave radar, and the linear frequency modulation bandwidth.
[0042] The output module is used to perform dynamic weighted averaging and adaptive Kalman filtering on the preliminary water level measurement value and the historical water level measurement value to obtain the target water level measurement value.
[0043] Thirdly, embodiments of the present invention also provide an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the water level measurement method as described in the first aspect.
[0044] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing computer-executable instructions for performing the water level measurement method as described in the first aspect.
[0045] According to embodiments of the present invention, a water level measurement method, system, electronic device, and storage medium are provided. The water level measurement method is applied to a water level measurement system, which includes a main control chip and a millimeter-wave radar. The water level measurement method includes: acquiring an echo analog signal from a target water area detected by the millimeter-wave radar; performing signal preprocessing on the echo analog signal to obtain a preprocessed signal; performing a fast Fourier transform on the preprocessed signal to obtain a signal spectrum; extracting amplitude and phase from the signal spectrum to obtain an amplitude spectrum and a phase spectrum; performing peak detection and neighbor selection based on the amplitude spectrum to determine the main peak position and neighbor positions; performing phase difference calculation and fine interpolation on the main peak position and neighbor positions based on the phase spectrum to obtain a finely estimated frequency; calculating a preliminary water level measurement value based on the finely estimated frequency, the analog-to-digital conversion acquisition rate of the millimeter-wave radar, and the linear frequency modulation bandwidth; and performing dynamic weighted averaging and adaptive Kalman filtering on the preliminary water level measurement value and historical water level measurement values to obtain the target water level measurement value. Based on this, the embodiments of the present invention introduce frequency estimation errors and use a frequency interpolation algorithm to process the signal spectrum. By processing the amplitude spectrum and phase spectrum of the signal separately in the frequency domain, fine interpolation is performed using the phase periodicity characteristics while preserving the energy distribution characteristics of the amplitude spectrum, thereby achieving high-precision frequency estimation. Based on the finely estimated frequency, the analog-to-digital conversion acquisition rate of the millimeter-wave radar, and the linear frequency modulation bandwidth, a preliminary water level measurement value is calculated. Then, multiple frames of historical water level measurements and the preliminary water level measurement value are weighted, and the filter strength is dynamically adjusted. Finally, an adaptive Kalman filter is used for optimal state estimation, and the final water level measurement value is output through multi-stage anti-fluctuation processing. Based on this, the embodiments of the present invention can achieve high-precision water level measurement using millimeter-wave radar. Attached Figure Description
[0046] Figure 1 This is a main flowchart of a water level measurement method provided in one embodiment of the present invention;
[0047] Figure 2 This is a flowchart of steps S201 to S204 provided in one embodiment of the present invention;
[0048] Figure 3 This is a sub-flowchart of step S102 provided in one embodiment of the present invention;
[0049] Figure 4 This is a sub-flowchart of step S108 provided in one embodiment of the present invention;
[0050] Figure 5 This is a sub-flowchart of step S402 provided in one embodiment of the present invention;
[0051] Figure 6 This is a schematic diagram of a water level measurement system provided in one embodiment of the present invention;
[0052] Figure 7 This is a schematic diagram of an electronic device provided in one embodiment of the present invention. Detailed Implementation
[0053] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0054] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the following drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0055] In this embodiment of the invention, the terms "furthermore," "exemplarily," or "optionally" are used as examples, illustrations, or descriptions and should not be construed as being more preferred or advantageous than other embodiments or designs. The use of the terms "furthermore," "exemplarily," or "optionally" is intended to present the relevant concepts in a specific manner.
[0056] First, let's analyze some of the terms used in this invention:
[0057] FMCW: (Frequency Modulated Continuous Wave)
[0058] DMA: (Direct Memory Access) group data transfer;
[0059] ADC: (analog-to-digital converter)
[0060] SPI: (Serial Peripheral interface) Serial Peripheral Interface;
[0061] FFT: (Fast Fourier Transform)
[0062] To facilitate a more convenient description of the working principle of the embodiments of the present invention, the following introduction of relevant technical scenarios is given first.
[0063] In the fields of hydrological monitoring and smart city ecological sensing, accurate measurement of elements such as water level and flow velocity is crucial for ensuring flood control and disaster reduction, water resource management, and urban waterlogging prevention. With technological advancements, radar level gauges have gradually become a research hotspot due to their advantages such as non-contact operation and strong anti-interference capabilities; however, their performance still has room for improvement. Existing radar level gauges do not yet fully meet the needs of complex hydrological scenarios (such as urban pipelines and turbulent rivers) in terms of ranging accuracy, blind zone control, and cost balance. Millimeter-wave frequency-modulated continuous wave radar, as an emerging ranging technology, possesses characteristics such as high accuracy, small blind zone, simple structure, and low cost, effectively compensating for the shortcomings of traditional technologies. It achieves distance detection through continuously frequency-modulated radio waves, overcoming harsh environmental interference in water level measurement and eliminating the need for direct contact with water, significantly reducing maintenance costs. However, the application of millimeter-wave radar in water level measurement scenarios is not yet mature, and there are technical shortcomings in signal processing, adversely affecting measurement accuracy.
[0064] Based on this, the present invention provides a water level measurement method and system, electronic device, and storage medium. The water level measurement method is applied to a water level measurement system, which includes a main control chip and a millimeter-wave radar. The water level measurement method includes: acquiring an echo analog signal from a target water area detected by the millimeter-wave radar; preprocessing the echo analog signal to obtain a preprocessed signal; performing a fast Fourier transform on the preprocessed signal to obtain a signal spectrum; extracting amplitude and phase from the signal spectrum to obtain an amplitude spectrum and a phase spectrum; performing peak detection and neighbor selection based on the amplitude spectrum to determine the main peak position and neighbor positions; calculating the phase difference and performing fine interpolation on the main peak position and neighbor positions based on the phase spectrum to obtain a finely estimated frequency; calculating a preliminary water level measurement value based on the finely estimated frequency, the analog-to-digital conversion acquisition rate of the millimeter-wave radar, and the linear frequency modulation bandwidth; and performing dynamic weighted averaging and adaptive Kalman filtering on the preliminary water level measurement value and historical water level measurement values to obtain the target water level measurement value. Based on this, the embodiments of the present invention introduce frequency estimation errors and use a frequency interpolation algorithm to process the signal spectrum. By processing the amplitude spectrum and phase spectrum of the signal separately in the frequency domain, fine interpolation is performed using the phase periodicity characteristics while preserving the energy distribution characteristics of the amplitude spectrum, thereby achieving high-precision frequency estimation. Based on the finely estimated frequency, the analog-to-digital conversion acquisition rate of the millimeter-wave radar, and the linear frequency modulation bandwidth, a preliminary water level measurement value is calculated. Then, multiple frames of historical water level measurements and the preliminary water level measurement value are weighted, and the filter strength is dynamically adjusted. Finally, an adaptive Kalman filter is used for optimal state estimation, and the final water level measurement value is output through multi-stage anti-fluctuation processing. Based on this, the embodiments of the present invention can achieve high-precision water level measurement using millimeter-wave radar.
[0065] The embodiments of the present invention will be further described below with reference to the accompanying drawings.
[0066] like Figure 1 As shown, Figure 1 This is a flowchart of a water level measurement method provided in an embodiment of the present invention. The water level measurement method can be applied to a water level measurement system. The water level detection system includes a main control chip and a millimeter-wave radar. The water level measurement method may include, but is not limited to, steps S101 to S108.
[0067] Step S101: Acquire the simulated echo signal of the target water area detected by the millimeter-wave radar;
[0068] Step S102: Perform signal preprocessing on the echo analog signal to obtain a preprocessed signal;
[0069] Step S103: Perform a Fast Fourier Transform on the preprocessed signal to obtain the signal spectrum;
[0070] Step S104: Extract amplitude and phase from the signal spectrum to obtain the amplitude spectrum and phase spectrum;
[0071] Step S105: Based on the amplitude spectrum, perform peak detection and neighbor selection to determine the location of the main peak and the location of neighboring points;
[0072] Step S106: Calculate the phase difference and perform fine interpolation on the main peak position and neighboring point positions based on the phase spectrum to obtain a finely estimated frequency;
[0073] Step S107: Based on the finely estimated frequency, the analog-to-digital conversion acquisition rate of the millimeter-wave radar, and the linear frequency modulation bandwidth, the preliminary water level measurement value is calculated;
[0074] Step S108: Perform dynamic weighted averaging and adaptive Kalman filtering on the preliminary water level measurement value and the historical water level measurement value to obtain the target water level measurement value.
[0075] It is understandable that the acquired noisy echo analog signal is filtered to remove high-frequency noise, resulting in a preprocessed signal x′(n). The noise reduction can be achieved using a Haar wavelet transform algorithm with a window size of 64. Based on this wavelet transform algorithm, the echo analog signal is decomposed into sub-bands of different frequencies. High-frequency noise is removed through thresholding, and the signal is then reconstructed to obtain the preprocessed signal.
[0076] It is understandable that a 512-point fast Fourier transform is performed on the preprocessed signal x′(n) to obtain the signal spectrum X(k), and the amplitude and phase are extracted from the signal spectrum X(k) to obtain the amplitude spectrum A(k) and the phase spectrum φ(k), where the amplitude spectrum A(k) = |X(k)| and the phase spectrum φ(k) = arg[X(k)].
[0077] Understandably, the amplitude spectrum is processed, and the frequency peak corresponding to the distance of the relevant target in the amplitude spectrum is determined by the defined threshold and constant false alarm rate detection algorithm. The main peak position k0 is found, and the left and right neighboring points k0-1 and k0+1 of the main peak position k0 are determined.
[0078] It is understandable that, for the main peak position k0 and its left and right neighboring points (k0-1, k0+1), the interpolation direction is determined by combining the amplitude comparison results of A(k0+1) and A(k0-1), and the frequency offset δ is calculated based on the phase difference of Δφ(k0-1) and Δφ(k0), and the fine estimated frequency f = f0 + δ is obtained, where f0 is the coarse estimated frequency of the fast Fourier transform.
[0079] Understandably, based on the obtained finely estimated frequency f, and using the ranging principle in linear frequency modulation (LFM), the formula for calculating the intermediate frequency and actual distance is r = c * f * T / 2 * B, to calculate the preliminary water level measurement value. Here, r is the target distance, c is a constant (typically the speed of light, 3 * 10^9), T is the actual acquisition time (the analog-to-digital conversion acquisition rate of millimeter-wave radar is 4 MHz, which is 0.25 microseconds; acquiring 512 points requires 128 microseconds), and B is the bandwidth of the linear frequency modulation, set according to the actual deployment scenario.
[0080] Understandably, the system weights multiple frames of historical water level measurements and preliminary water level measurements, dynamically adjusts the filtering intensity, and finally uses adaptive Kalman filtering for optimal state estimation. Through multi-level anti-fluctuation processing, it outputs the final target water level measurement.
[0081] This invention, through the introduction of frequency estimation error, employs a frequency interpolation algorithm to process the signal spectrum. By processing the amplitude and phase spectra of the signal separately in the frequency domain, fine interpolation is performed using the phase periodicity characteristics while preserving the energy distribution characteristics of the amplitude spectrum, thereby achieving high-precision frequency estimation. Based on the finely estimated frequency, the analog-to-digital conversion acquisition rate of the millimeter-wave radar, and the linear frequency modulation bandwidth, a preliminary water level measurement value is calculated. Then, multiple frames of historical water level measurements and the preliminary water level measurement value are weighted, and the filter strength is dynamically adjusted. Finally, an adaptive Kalman filter is used for optimal state estimation, and the final water level measurement value is output through multi-stage anti-fluctuation processing. Based on this, this invention enables high-precision water level measurement using millimeter-wave radar.
[0082] like Figure 2 As shown, prior to step S101, the water level measurement method of the present invention may also include, but is not limited to, steps S201 to S204:
[0083] Step S201: Initialize the operating parameters of the water level detection system;
[0084] Step S202: Calibrate the analog-to-digital converter voltage of the millimeter-wave radar;
[0085] Step S203: After the analog-to-digital converter voltage calibration is completed, the millimeter-wave radar is controlled to transmit linear frequency modulated continuous waves toward the target water area through the state machine running on the main control chip.
[0086] Step S204: When the time for transmitting the linear frequency modulated continuous wave and the linear frequency modulated continuous wave reflected back from the target water area meet the preset conditions, the acquisition of the echo simulation signal is triggered.
[0087] Understandably, the water level detection system includes a main control chip and a millimeter-wave radar. The main control chip is connected to the millimeter-wave radar via an SPI interface. The main control chip can be a microcontroller. After the microcontroller is powered on, the program will automatically start running. The microcontroller peripherals are initialized first, and then various operating parameters are read from the flash memory in the microcontroller and initialized. If the default parameters are not yet stored in the flash memory, they will be rewritten. Then the millimeter-wave radar function is initialized, and finally the structure, global variables, and other configurations related to the millimeter-wave radar are initialized.
[0088] Understandably, the water level detection system can be controlled by a state machine running on the main control chip. When the state machine is in the ready state, it first calibrates the basic voltage of the millimeter-wave radar's built-in ADC to prevent inaccurate voltage from causing incorrect detection results. After the ADC self-calibrates, the state machine controls the main control chip to control the millimeter-wave radar to transmit a linear frequency modulated continuous wave through the SPI interface. When the transmission time of the linear frequency modulated continuous wave coincides with the detection of the target object and the electromagnetic wave reflected back, and the electromagnetic wave meets the preset conditions, the ADC is quickly triggered to collect the echo analog signal at this time.
[0089] Understandably, when the water level detection system is working, it uses a state machine to control radio frequency transmission and reception and distance detection. When the state machine reaches the signal processing and logic judgment process, if there is a target within the measurement range, it will output an accurate water level result according to a specific protocol. If there is no target, it will jump back to the original state of the state machine to continue detection.
[0090] In one embodiment, after step S101, the water level measurement method of the present invention may further include the following steps:
[0091] The echo analog signal is stored in the target memory space of the water level measurement system using a grouped data transfer (DMA) channel, and the target memory space is isolated from other data memory spaces.
[0092] Understandably, to accelerate the operation cycle of the water level detection system, a grouped data transfer (DMA) channel can be used to quickly transfer the collected data from the ADC register to a specific target memory space. This target memory space is pre-allocated to prevent other data from entering this area and contaminating the collected data. After the data is saved, the echo analog signal undergoes appropriate signal processing. First, interference signals are removed, and then the approximate position of the target is calculated. Next, a high-precision algorithm is used to refine the target's accurate position, and finally, the measurement result is output according to a specific communication protocol.
[0093] like Figure 3 As shown, step S102 may include, but is not limited to, steps S301 to S302:
[0094] Step S301: Eliminate abrupt changes in the echo analog signal that exceed the set threshold range. The set threshold range is determined based on the measurement range set by the millimeter-wave radar's own installation height.
[0095] Step S302: High-frequency noise is filtered out from the echo analog signal using a wavelet transform algorithm to obtain a preprocessed signal.
[0096] It is understandable that when millimeter-wave radar measures water levels, surface fluctuations (such as wind waves and rapid currents) can cause high-frequency jitter in the measured values, resulting in unstable water level readings. To obtain stable results, this invention employs a multi-level anti-fluctuation processing strategy. First, the measurement range is set based on the installation height of the radar water level gauge. Physical constraints are used to eliminate abrupt changes in the echo analog signal that exceed a set threshold range. The set threshold range is determined based on the measurement range set by the millimeter-wave radar's own installation height. Then, the echo analog signal is filtered for high-frequency noise using a wavelet transform algorithm to effectively remove high-frequency random noise (such as surface ripples and electromagnetic interference) in the millimeter-wave radar measurement, resulting in a pre-processed signal.
[0097] like Figure 4 As shown, step S108 may include, but is not limited to, steps S401 to S402:
[0098] Step S401: Perform dynamic weighted averaging on the preliminary water level measurement value and the historical water level measurement value to obtain multi-frame weighted fused measurement value;
[0099] Step S402: Perform adaptive Kalman filtering on the weighted fused measurement values of multiple frames, and iteratively calculate to obtain the water level value.
[0100] Understandably, by dynamically weighting and averaging historical and preliminary water level measurements, and dynamically adjusting the filtering intensity, multi-frame weighted fused measurement values are obtained. Then, adaptive Kalman filtering is used to process the multi-frame weighted fused measurement values. Through an iterative "prediction-update" process, the predicted and actual measurement values are fused to obtain a better state estimate. After multi-level anti-fluctuation processing, the final water level measurement value is output.
[0101] like Figure 5 As shown, step S402 may include, but is not limited to, steps S501 to S506:
[0102] Step S501: Using the water level height of the target water area at a certain moment as the core estimator and the water level change rate as the auxiliary estimator, a state vector is generated.
[0103] Step S502: Construct the Kalman filter measurement equation based on the state vector;
[0104] Step S503: Determine the predicted value based on the multi-frame weighted fusion measurement value and the Kalman filter measurement equation;
[0105] Step S504: Adjust the noise covariance matrix based on the measurement residuals of the predicted value and the multi-frame weighted fusion measurement value. The noise covariance matrix includes the process noise variance matrix and the measurement noise variance matrix.
[0106] Step S505: Calculate the Kalman gain based on the process noise variance matrix and the measurement noise variance matrix;
[0107] Step S506: Update the state estimate and error covariance based on the Kalman gain, and iteratively calculate the water level value.
[0108] Understandably, this invention applies the Kalman filter algorithm in radar water level measurement to improve measurement accuracy, suppress noise, smooth data, and estimate water level change trends. The Kalman filter algorithm is particularly suitable for handling inherent noise in radar sensors (such as water surface fluctuations, electromagnetic interference, multipath effects, etc.) and the dynamic characteristics of the water level measurement system itself. The Kalman filter is a recursive optimal estimation algorithm that combines a measurement model to describe the dynamic process of water level change (such as uniform velocity, uniform acceleration, or more complex fluid dynamics models). For example, the measurement model describes the relationship between radar measurements and the actual water level (which typically includes noise). Through an iterative "prediction-update" process, the model predictions and actual measurements are fused to obtain a better state estimate.
[0109] This invention employs adaptive Kalman filtering, which can adapt to different scenarios by adjusting Q (process noise variance matrix) and R (measurement noise variance matrix): for example, in a calm water scenario, R is reduced (trust measurement) and Q is reduced (trust model); for another example, in a turbulent river scenario, R is increased (high measurement noise) and Q is increased (high model uncertainty).
[0110] In this invention, Kalman filtering mainly consists of the following steps:
[0111] 1. State transition
[0112] X_{k|k-1}=F*X_{k-1}+w_k
[0113] Wherein, the state vector X_k = [h_k, v_k]^T, h_k: water level height at time k (core estimate), v_k: water level change rate at time k (auxiliary estimate, improving tracking capability), F: state transition matrix (describing how the state evolves over time), and w_k: process noise (following a Gaussian distribution N(0,Q)), representing model uncertainty (such as sudden changes in water flow).
[0114] 2. Construct the Kalman filter measurement equation:
[0115] Z_k=H*X_k+v_k
[0116] Where Z_k: the original measurement value (water level) of the radar at time k. H: the observation matrix (mapping the state to the measurement space). If the water level is measured directly: H = [1,0] (ignoring the velocity component). v_k: measurement noise (following a Gaussian distribution N(0,R)), representing the random error of the radar.
[0117] 3. Recursive steps of Kalman filtering:
[0118] (1) Prediction phase:
[0119] Predicted state: X_{k|k-1}=F*X_{k-1}
[0120] Prediction error covariance: P_{k|k-1}=F*P_{k-1}*F^T+Q
[0121] P: Uncertainty in state estimation (covariance matrix).
[0122] (2) Update phase:
[0123] Calculate the Kalman gain K_k:
[0124] K_k=P_{k|k-1}*H^T*(H*P_{k|k-1}*H^T+R)^{-1}
[0125] Gain K balances the confidence level between "predicted values" and "measured values" (the model is trusted more when there is a lot of noise).
[0126] Updated state estimate:
[0127] X_k=X_{k|k-1}+K_k*(Z_k-H*X_{k|k-1})
[0128] (Z_k-H*X_{k|k-1}) is called the new information, i.e., the measurement residual.
[0129] Update error covariance:
[0130] P_k=(I-K_k*H)*P_{k|k-1}
[0131] It is understood that the operating states of the water level measurement system of the present invention include full-speed operation, standby, and sleep states. When the water level measurement system is first powered on, it is in standby mode. When the water level measurement system starts detection, it switches from standby mode to full-speed operation mode. After the water level measurement system completes target detection and data reporting, it switches from full-speed operation mode to sleep state. When the water level measurement system meets the detection frequency setting, it switches from sleep state to standby mode until the periodic detection is completed, thereby achieving low power consumption control while ensuring the operating speed of the water level measurement system.
[0132] The water level measurement method of this invention employs a multi-level anti-wave processing strategy. First, the measurement range is set based on the installation height of the radar water level gauge. Physical constraints are used to eliminate abrupt changes in the echo analog signal that exceed a set threshold range. This threshold range is determined based on the measurement range set by the millimeter-wave radar's installation height. Then, the echo analog signal is filtered for high-frequency noise using a wavelet transform algorithm to effectively remove high-frequency random noise (such as water surface ripples and electromagnetic interference) in the millimeter-wave radar measurement, resulting in a pre-processed signal. Frequency estimation errors are introduced, and a frequency interpolation algorithm is used to process the signal spectrum. By processing the amplitude and phase spectra of the signal separately in the frequency domain, fine interpolation is performed using the phase periodicity characteristics while preserving the energy distribution characteristics of the amplitude spectrum, thereby achieving high-precision frequency estimation. Based on the finely estimated frequency, the analog-to-digital conversion acquisition rate of the millimeter-wave radar, and the linear frequency modulation bandwidth, a preliminary water level measurement value is calculated. Next, multiple frames of historical water level measurements and the preliminary water level measurement value are weighted, and the filtering intensity is dynamically adjusted. Finally, an adaptive Kalman filter is used for optimal state estimation, and the final water level measurement value is output through multi-level anti-wave processing. Based on this, embodiments of the present invention can use millimeter-wave radar to achieve high-precision water level measurement.
[0133] In addition, such as Figure 6As shown, one embodiment of the present invention also discloses a water level measurement system, the system comprising:
[0134] The acquisition module 110 is used to acquire the echo simulation signal of the target water area detected by the millimeter-wave radar;
[0135] The preprocessing module 120 is used to preprocess the echo analog signal to obtain a preprocessed signal;
[0136] The transformation module 130 is used to perform a fast Fourier transform on the preprocessed signal to obtain the signal spectrum;
[0137] Extraction module 140 is used to extract amplitude and phase from the signal spectrum to obtain amplitude spectrum and phase spectrum;
[0138] Select module 150 is used to perform peak detection and neighbor selection based on amplitude spectrum, and to determine the position of the main peak and the position of the neighboring points.
[0139] Interpolation module 160 is used to calculate the phase difference and perform fine interpolation on the main peak position and neighboring point positions based on the phase spectrum to obtain a finely estimated frequency.
[0140] The calculation module 170 is used to calculate the preliminary water level measurement value based on the finely estimated frequency, the analog-to-digital conversion acquisition rate of the millimeter-wave radar, and the linear frequency modulation bandwidth.
[0141] The output module 180 is used to perform dynamic weighted averaging and adaptive Kalman filtering on the preliminary water level measurement value and the historical water level measurement value to obtain the target water level measurement value.
[0142] The water level measurement system of this invention is used to execute the water level measurement method in the above embodiments. Its specific processing procedure is the same as that of the water level measurement method in the above embodiments, and will not be described in detail here.
[0143] In addition, such as Figure 7 As shown, one embodiment of the present invention also discloses an electronic device, including: at least one processor 210; at least one memory 220 for storing at least one program; and when the at least one program is executed by the at least one processor 210, it implements the water level measurement method as described in any of the preceding embodiments.
[0144] In addition, one embodiment of the present invention discloses a computer-readable storage medium storing computer-executable instructions for performing the water level measurement method as described in any of the preceding embodiments.
[0145] The system architecture and application scenarios described in the embodiments of this invention are for the purpose of more clearly illustrating the technical solutions of the embodiments of this invention, and do not constitute a limitation on the technical solutions provided by the embodiments of this invention. As those skilled in the art will know, with the evolution of system architecture and the emergence of new application scenarios, the technical solutions provided by the embodiments of this invention are also applicable to similar technical problems.
[0146] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.
[0147] In hardware implementations, the division between functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, as is known to those skilled in the art, communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.
[0148] The terms “component,” “module,” “system,” etc., used in this specification are used to refer to computer-related entities, hardware, firmware, combinations of hardware and software, software, or software in execution. For example, a component can be, but is not limited to, a process running on a processor, a processor, an object, an executable file, an execution thread, a program, or a computer. As illustrated, applications running on computing devices and computing devices can both be components. One or more components may reside in a process or execution thread, and components may be located on a single computer or distributed among two or more computers. Furthermore, these components can be executed from various computer-readable media on which various data structures are stored. Components can communicate, for example, via local or remote processes based on signals having one or more data packets (e.g., data from two components interacting with another component between a local system, a distributed system, or a network, such as the Internet interacting with other systems via signals).
Claims
1. A water level measurement method, applied to a water level measurement system, the water level detection system including a main control chip and a millimeter-wave radar, the method comprising: Acquire simulated echo signals from the target water area detected by millimeter-wave radar; The echo analog signal is preprocessed to obtain a preprocessed signal; Perform a Fast Fourier Transform on the preprocessed signal to obtain the signal spectrum; The amplitude and phase of the signal spectrum are extracted to obtain the amplitude spectrum and phase spectrum; Peak detection and neighbor selection are performed based on the amplitude spectrum to determine the location of the main peak and the location of neighboring points. Based on the phase spectrum, the phase difference between the main peak position and the adjacent point position is calculated and fine interpolation is performed to obtain a finely estimated frequency. Based on the finely estimated frequency, the analog-to-digital conversion acquisition rate of the millimeter-wave radar, and the linear frequency modulation bandwidth, the preliminary water level measurement value is calculated. The target water level is obtained by performing dynamic weighted averaging and adaptive Kalman filtering on the preliminary water level measurement and historical water level measurement.
2. The method according to claim 1, characterized in that, Before acquiring the echo signal of the target water level detected by the millimeter-wave radar, the method further includes: Initialize the operating parameters of the water level detection system; Calibrate the analog-to-digital converter voltage of the millimeter-wave radar; After the analog-to-digital converter voltage is calibrated, the millimeter-wave radar is controlled by the state machine running on the main control chip to transmit linear frequency modulated continuous waves toward the target water area. When the time for transmitting the linear frequency modulated continuous wave and the detection of the linear frequency modulated continuous wave reflected back from the target water area meet preset conditions, the acquisition of the echo analog signal is triggered.
3. The method according to claim 1, characterized in that, After acquiring the simulated echo signal of the target water area detected by the millimeter-wave radar, the method further includes: The echo analog signal is stored in the target memory space of the water level measurement system using a grouped data transfer (DMA) channel, and the target memory space is isolated from other data memory spaces.
4. The method according to claim 1, characterized in that, The step of preprocessing the echo analog signal to obtain a preprocessed signal includes: Exclude abrupt changes in the echo analog signal that exceed a set threshold range, which is determined based on the measurement range set by the installation height of the millimeter-wave radar itself. The echo analog signal is filtered to remove high-frequency noise using a wavelet transform algorithm to obtain the preprocessed signal.
5. The method according to claim 1, characterized in that, The process of dynamically weighting and adaptively Kalman filtering the preliminary water level measurement and historical water level measurement to obtain the target water level measurement includes: The preliminary water level measurement and the historical water level measurement are dynamically weighted and averaged to obtain a multi-frame weighted fused measurement value; The water level value is obtained by iterative calculation after performing adaptive Kalman filtering on the multi-frame weighted fused measurement values.
6. The method according to claim 5, characterized in that, The step of performing Kalman filtering on the weighted fused measurement values from multiple frames and iteratively calculating the water level value includes: A state vector is generated by using the water level height of the target water area at a certain moment as the core estimator and the water level change rate as the auxiliary estimator. Construct the Kalman filter measurement equation based on the state vector; The predicted value is determined based on the multi-frame weighted fusion measurement value and the Kalman filter measurement equation; The noise covariance matrix is adjusted based on the measurement residuals of the predicted values and the multi-frame weighted fused measurement values. The noise covariance matrix includes a process noise variance matrix and a measurement noise variance matrix. Calculate the Kalman gain based on the process noise variance matrix and the measurement noise variance matrix; The water level value is obtained by iterative calculation based on the updated state estimate and error covariance using the Kalman gain.
7. The method according to any one of claims 1 to 6, characterized in that, The water level measurement system operates in three states: full-speed operation, standby, and hibernation. When the system is first powered on, it is in standby mode. When detection begins, the system switches from standby to full-speed operation. After target detection and data reporting are completed, the system switches from full-speed operation to hibernation. Once the detection frequency is set, the system switches from hibernation to standby, continuing this process until periodic detection is complete.
8. A water level measurement system, characterized in that, The system includes: The acquisition module is used to acquire the simulated echo signal of the target water area detected by the millimeter-wave radar; The preprocessing module is used to perform signal preprocessing on the echo analog signal to obtain a preprocessed signal; The transformation module is used to perform a fast Fourier transform on the preprocessed signal to obtain the signal spectrum; The extraction module is used to extract the amplitude and phase of the signal spectrum to obtain the amplitude spectrum and phase spectrum; The selection module is used to perform peak detection and neighbor selection based on the amplitude spectrum, and to determine the position of the main peak and the position of the neighboring points. The interpolation module is used to calculate the phase difference and perform fine interpolation on the main peak position and the adjacent point position based on the phase spectrum to obtain a finely estimated frequency. The calculation module is used to calculate the preliminary water level measurement value based on the finely estimated frequency, the analog-to-digital conversion acquisition rate of the millimeter-wave radar, and the linear frequency modulation bandwidth. The output module is used to perform dynamic weighted averaging and adaptive Kalman filtering on the preliminary water level measurement value and the historical water level measurement value to obtain the target water level measurement value.
9. An electronic device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor, when executing the computer program, implements the water level measurement method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing computer-executable instructions for performing the water level measurement method as described in any one of claims 1 to 7.
Citation Information
Cited By
Method for determining amount of liquid carried by target vehicle and unmanned vehicle
CN121453156A