An off-line echo detection method for ultrasonic liquid level measuring and control instrument
By employing continuous ultrasonic pulse transmission, dynamic noise calibration, and temperature compensation, the problems of weak echo signals, large noise interference, and errors caused by temperature changes in ultrasonic liquid level detection have been solved, achieving high-precision liquid level measurement.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUNAN UNISPLENDOUR DAORAN ELECTRICAL APP
- Filing Date
- 2026-04-27
- Publication Date
- 2026-07-21
AI Technical Summary
Existing ultrasonic liquid level detection methods suffer from problems in offline scenarios, such as weak echo signals, large environmental noise interference, large measurement errors due to temperature changes, lack of self-recovery capability, and lack of independent processing modules, resulting in insufficient detection accuracy and reliability.
The system acquires raw sampling data by continuously transmitting multiple ultrasonic pulses, dynamically calibrates background noise, adjusts the echo search range by combining temperature compensation, and achieves adaptive tracking of environmental noise and accurate identification of echoes through filtering calculations and closed-loop feedback of abnormal states.
It significantly enhances the echo signal strength, improves the accuracy of environmental noise tracking and echo identification, enhances the system's adaptive recovery capability and measurement accuracy in complex environments, and solves the problems of cumulative error and false echo interference in long-range measurements.
Smart Images

Figure CN122085257B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of liquid level measurement technology, specifically to an offline echo detection method for an ultrasonic liquid level measuring and control instrument. Background Technology
[0002] Ultrasonic level measuring instruments utilize the principle of ultrasonic waves propagating in the air and reflecting off the liquid surface to measure liquid levels. They are widely used in hydrological monitoring and industrial control. In offline detection scenarios, the instrument cannot rely on a network for real-time data transmission and must independently complete data acquisition, processing, and storage.
[0003] Existing ultrasonic liquid level detection methods suffer from several drawbacks: They mostly employ a single-wave emission mode, resulting in weak echo signals that are easily drowned out by ambient noise in long-range or complex environments; they use fixed thresholds to process background noise, which fluctuates significantly due to changes in temperature and humidity, leading to misjudgments; temperature changes alter the speed of sound in the air, and existing methods suffer from insufficient temperature compensation accuracy, resulting in increased cumulative errors over long distances; current echo recognition relies solely on a single threshold, which cannot distinguish between real and false echoes caused by ripples or obstacles; they lack a system-level anomaly feedback mechanism, causing continuous anomalies in measurement data during offline operation, as existing equipment cannot self-recover, leading to long-term data loss; and the processing modules in existing technologies operate independently, with background noise calibration, echo recognition, and filtering calculations forming a simple serial pipeline structure that cannot cope with dynamic changes in complex environments. Summary of the Invention
[0004] This invention overcomes the shortcomings of existing technologies and provides an offline echo detection method for ultrasonic level measuring and control instruments. Addressing the problems of existing offline level detection technologies, such as background noise benchmarks being easily contaminated by abnormal interference, temperature fluctuations causing inaccurate search interval positioning, and echo recognition and data filtering being isolated and lacking self-healing capabilities, this invention constructs a complete detection system integrating dynamic noise benchmark calibration, temperature-driven interval adaptive adjustment, and closed-loop feedback collaborative filtering. It acquires raw sampling data containing environmental characteristics by continuously transmitting multiple ultrasonic pulses; in the background noise dynamic calibration stage, historical noise extraction and preset empirical threshold lower limit protection are completed to ensure the stable establishment of the dynamic threshold benchmark; when setting the echo search interval, the real-time sound velocity calculated by temperature compensation is used, and physical propagation constraints are introduced in the interval boundary expansion and contraction calculation, so that the search interval maintains strict alignment with the actual physical distance while adapting to temperature changes; in the filtering calculation and abnormal state closed-loop feedback steps, the data fluctuation state is transmitted back to the background noise dynamic calibration step; and deviation comparison collaborative constraints are introduced in the benchmark locking and unlocking logic, which suppresses the amplification of abnormal interference while maintaining the ability to track slow environmental changes, achieving accurate offline high-precision level detection. The innovation of the method lies in the deep coupling of the data fluctuation state calculated by the extreme value filtering with the update logic of the comprehensive background noise value through the "filter deviation closed-loop feedback locking and unlocking" mechanism. This improves the system's adaptive recovery capability against violent liquid surface rolling or sudden strong interference in offline scenarios, as well as the accuracy of environmental noise tracking and the reliability of echo recognition, providing a new technical approach for high-precision ultrasonic offline measurement and control.
[0005] The technical solution adopted by this invention is as follows: This solution provides an offline echo detection method for an ultrasonic liquid level measuring and control instrument, the specific steps of which include: Step S1: Perform multi-wave emission settings: The ultrasonic level measuring and control instrument has a built-in transducer. Based on the center frequency corresponding to the transducer's range, the transducer is controlled to continuously emit multiple ultrasonic pulses. The emission interval and measurement interval are set. The measurement interval is divided into a background noise measurement stage and a multi-wave data measurement stage. By controlling the transducer to continuously emit multiple ultrasonic pulses, raw sampling data is acquired. The raw sampling data includes environmental noise characteristics.
[0006] Step S2: Perform dynamic background noise calibration: Calculate the historical maximum background noise value based on the original sampled data. Calculate the comprehensive background noise value based on the historical maximum background noise value. Add a preset empirical threshold to the comprehensive background noise value. Use the generated comprehensive background noise value as the dynamic threshold benchmark. The dynamic threshold benchmark is used for subsequent echo identification and anomaly detection.
[0007] Step S3: Perform temperature acquisition and sound velocity compensation: Acquire the current ambient temperature. Obtain the measured temperature value using a lookup table based on the current ambient temperature. Calculate the compensated current sound velocity based on the measured temperature value.
[0008] Step S4: Set the echo search interval: Obtain the preset dead zone distance corresponding to the transducer's range; calculate the sampling interval based on the transducer's range. Calculate the starting echo search point based on the preset dead zone distance, current sound velocity, and sampling interval. Obtain the maximum measurement distance corresponding to the transducer's range. Calculate the ending echo search point based on the preset dead zone distance, maximum measurement distance, current sound velocity, and sampling interval. Calculate the unified echo point count benchmark based on the preset dead zone distance. Dynamically adjust the echo search interval using the current sound velocity, making the interval boundary adaptively change with the current ambient temperature.
[0009] Step S5: Perform echo array identification: Within the echo search interval, use the overall background noise value as a judgment threshold. Extract the echo array using start, duration, and end conditions. Execute special judgment rules for echo arrays located at the boundary of the echo search interval. Record the echo point and echo value of each echo array. Perform secondary filtering on echo arrays near the preset dead zone distance using the overall background noise value.
[0010] Step S6: Perform dual-echo comparison filtering: Extract the maximum and second-largest echo values from the echo array. Calculate the ratio of the second-largest echo value to the maximum echo value. Based on the ratio and the distance relationship between the two echo values, determine the final valid echo point. Calculate the instantaneous altitude value based on the final valid echo point. If no valid echo is detected, set the instantaneous altitude value to zero.
[0011] Step S7: Perform filtering calculation and abnormal state closed-loop feedback: Continuously acquire multiple instantaneous height values to form a filtering queue. Perform extreme value removal and averaging filtering calculation on the filtering queue to obtain the average height value. Calculate the maximum deviation of the remaining data after removing extreme values from the filtering queue relative to the average height value. Compare the maximum deviation with the preset dead zone distance. If the maximum deviation is greater than the preset dead zone distance, it is determined to be a sampling abnormal state. In the sampling abnormal state, trigger a sampling abnormality alarm, feed back to step S2, lock the comprehensive background noise value, and prohibit updating the historical maximum background noise value. Lock the limit alarm for liquid level exceeding the preset safety range, and keep the average height value obtained from the previous filtering calculation as the current output. If the maximum deviation is less than or equal to the preset dead zone distance, it is determined to be a data valid state. In the data valid state, use the average height value as the current output, feed back to step S2, update the historical maximum background noise value, and recalculate the comprehensive background noise value.
[0012] Furthermore, in step S1, the number of continuously emitted ultrasonic pulses is a preset fixed value. The emission interval is set via the parameter configuration menu. The background noise measurement stage is performed before the multi-wave data measurement stage.
[0013] Further, in step S2, the historical maximum background noise value is the average of the maximum preset number of background noise values during the previous measurement. The calculated result of the comprehensive background noise value is compared with a preset empirical threshold. When the calculated result is less than the preset empirical threshold, the preset empirical threshold is used as the comprehensive background noise value. When the calculated result is greater than or equal to the preset empirical threshold, the calculated result is used as the comprehensive background noise value.
[0014] Further, in step S3, temperature is acquired using a thermistor. The thermistor is connected in series with a standard resistor. The voltage drop between the thermistor and ground is collected as the sample value. When calculating the actual thermistor resistance, a protection resistor with a preset resistance value inside the transducer is included. The measured temperature value is calculated based on the actual thermistor resistance value using interpolation. When the actual thermistor resistance value exceeds the preset resistance range, a temperature anomaly alarm is triggered.
[0015] Furthermore, in step S4, the termination echo search point is subject to a maximum point limit in the microprocessor data storage queue. The unified echo point count benchmark is a fixed number of points corresponding to a preset multiple of the preset dead zone distance.
[0016] Further, in step S5, the starting condition is that the echo value is less than or equal to the overall background noise value. The continuing condition is that the echo value is greater than the overall background noise value. The ending condition is that the echo value is less than or equal to the overall background noise value. Special judgment rules include: if the echo value at the starting echo search point is greater than the overall background noise value, then directly enter the continuing stage, and take the echo value at the starting echo search point as the first echo value. If the echo value at the ending echo search point is greater than the overall background noise value, then directly determine that the current echo array has ended. The secondary screening rule is: when the echo points of the echo array are less than or equal to a unified echo point count benchmark, if the maximum echo value of the echo array is less than or equal to the product of the overall background noise value and a preset coefficient, then discard the echo array.
[0017] Further, in step S6, the ratio of the second largest echo value to the largest echo value is calculated. When the ratio is less than or equal to a preset ratio threshold, the echo point corresponding to the largest echo value is selected as the final valid echo point. When the ratio is greater than the preset ratio threshold, a first distance is calculated based on the echo point corresponding to the largest echo value, and a second distance is calculated based on the echo point corresponding to the second largest echo value. If the second distance is within a preset distance ratio range of the first distance, the echo point corresponding to the second largest echo value is selected as the final valid echo point. If the second distance is not within a preset distance ratio range of the first distance, the echo point corresponding to the largest echo value is selected as the final valid echo point.
[0018] Further, in step S7, the extreme value removal average filtering calculation process is as follows: Extreme value data with a preset extreme value removal ratio are removed from the filtering queue to obtain the remaining data. The average value of the remaining data is calculated to obtain the average height value. When the average height value is zero, the average height value obtained from the previous filtering calculation is maintained. When the average height value is not zero, the maximum deviation is calculated.
[0019] Further, in step S7, the abnormal alarms include sampling abnormal alarms and temperature abnormal alarms. The trigger condition for a sampling abnormal alarm is that the instantaneous height value is zero for a consecutive preset number of times, or the maximum deviation for a consecutive preset number of times is greater than a preset dead zone distance. The trigger condition for a temperature abnormal alarm is that the measured temperature value exceeds a preset temperature range for a consecutive preset number of times. Under the status of a sampling abnormal alarm or a temperature abnormal alarm, all over-limit alarms are locked. During the preset initial measurement period after the equipment is powered on, all alarms are locked.
[0020] Compared with the prior art, the beneficial effects of the present invention are: (1) Control the transducer to continuously emit multiple ultrasonic pulses to obtain the original sampling data, so that the echo energy can be effectively accumulated. This solves the problem that the echo signal is weak in the existing single-wave transmission mode and the signal is easily submerged in the environmental noise in the long range or complex environment, and significantly enhances the echo signal strength. (2) The historical maximum background noise value is calculated based on the original sampling data, and a comprehensive background noise value is generated by combining the preset empirical threshold as a dynamic threshold benchmark. This solves the problem that the fixed threshold cannot adapt to changes in environmental temperature and humidity, which leads to large fluctuations in background noise and misjudgment. It dynamically and adaptively tracks the background noise of the environment. (3) Based on the current ambient temperature, the measured temperature value is obtained and the current sound speed after compensation is calculated. The boundary of the echo search interval is dynamically adjusted using the current sound speed. This solves the problem that temperature changes change the sound speed in the air, which leads to a large cumulative error in long-distance measurement. It also eliminates the systematic positioning error caused by temperature drift and improves the accuracy of long-range measurement. (4) The echo array is extracted by the start condition, the duration condition and the end condition. The echo array near the preset dead zone distance is screened by the comprehensive background noise value. The final effective echo point is determined based on the ratio of the second largest echo value to the largest echo value and the proportional relationship of the corresponding distance. This solves the problem that the single threshold judgment is easily affected by the false echo interference caused by water surface ripples or obstacles. It accurately removes aftershock interference and multipath reflection false echoes, and improves the echo recognition accuracy in complex offline environments. (5) The maximum deviation of the remaining data after removing extreme values from the filter queue relative to the average height value is compared with the preset dead zone distance to generate a status signal that is fed back to the background noise dynamic calibration step. In the case of abnormal sampling, the comprehensive background noise value is locked and not updated. In the case of valid data, the lock is released and the historical maximum background noise value is updated. This solves the problem that in the prior art, each processing module is independent and belongs to a simple serial pipeline. The lack of a system-level abnormal feedback mechanism leads to continuous abnormal measurement data that cannot be self-recovered when the environment changes suddenly. The data fluctuation state calculated by removing extreme values and the logic of updating the comprehensive background noise value are deeply coupled, realizing the synergistic effect of closed-loop feedback. This improves the system's adaptive recovery ability against violent liquid surface rolling or sudden strong interference and the accuracy of environmental noise tracking. Attached Figure Description
[0021] Figure 1 This is a flowchart of an offline echo detection method for an ultrasonic liquid level measuring and control instrument according to the present invention; The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used together with the embodiments of the invention to explain the invention and do not constitute a limitation thereof. Detailed Implementation
[0022] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0023] Example 1: Please see Figure 1 This embodiment describes an offline echo detection method for an ultrasonic liquid level measuring and control instrument, applied to the instrument. The instrument includes a transducer, a microprocessor, and a temperature sampling circuit. The transducer emits and receives ultrasonic waves; the microprocessor executes data processing logic; and the temperature sampling circuit collects ambient temperature data.
[0024] The specific steps of the method include: Step S1: Execute multi-wave transmission settings: The measurement and control instrument controls the transducer to continuously emit multiple ultrasonic pulses based on the center frequency corresponding to the transducer's range. In this embodiment, the number of continuously emitted ultrasonic pulses is set to 20. The selection of 20 pulses is based on the attenuation characteristics of ultrasound in air and the physical aftershock time of the transducer. Continuously emitting 20 pulses can effectively accumulate echo energy without causing severe aliasing of adjacent pulse waveforms. If the number of pulses is less than 20, the echo signal strength may not exceed the ambient noise during long-range measurements; if the number of pulses is more than 20, it will lead to excessive microprocessor sampling memory usage, and the aftershock waveforms of the transducer will overlap, thus reducing the signal-to-noise ratio.
[0025] The wave emission interval Td is set via the parameter configuration menu of the ultrasonic level measuring and control instrument. In this embodiment, the wave emission interval Td is set to 0.5 seconds. The measurement interval Tds is set, divided into two stages: the first stage is the background noise measurement stage, and the second stage is the multi-wave data measurement stage. In the background noise measurement stage, no ultrasonic pulses are emitted; only raw sampling data is collected. In the multi-wave data measurement stage, the transducer is controlled to continuously emit 20 ultrasonic pulses to acquire raw sampling data, which includes environmental noise characteristics.
[0026] Step S2: Perform dynamic background noise calibration. The microprocessor calculates the historical maximum background noise value BS1 based on the raw sampled data. In this embodiment, the historical maximum background noise value BS1 is the average of the five largest background noise values during the previous measurement. The rationale is that taking a single maximum value is easily affected by occasional single electromagnetic pulse interference, while taking five maximum values and smoothing them can filter out spike interference with extremely short durations and accurately reflect the true high level of environmental background noise.
[0027] The overall background noise value BS2 is calculated based on the historical maximum background noise value BS1. The initial calculation result of the overall background noise value BS2 is equal to the historical maximum background noise value BS1. A preset empirical threshold is added to the overall background noise value BS2. In this embodiment, the preset empirical threshold is set to 250. The basis for selecting 250 as the preset empirical threshold is that, when there is no external signal input, the background noise of the analog-to-digital converter inside the microprocessor usually fluctuates between 100 and 200 due to the thermal noise of the circuit itself and the digital quantization error. Setting the preset empirical threshold to 250 can reserve a safety margin of 50 to 150 for the system. This can prevent the circuit background noise fluctuation from exceeding the threshold and being mistakenly judged as the starting point of a valid echo.
[0028] The overall background noise value BS2 is compared with 250. When the calculated result of the overall background noise value BS2 is less than 250, the overall background noise value BS2 is forcibly set to 250; when the calculated result of the overall background noise value BS2 is greater than or equal to 250, the calculation result remains unchanged.
[0029] The comprehensive background noise value BS2 is used as a dynamic threshold benchmark and transmitted to step S5 for echo identification, and simultaneously transmitted to step S7 for closed-loop feedback determination of abnormal states.
[0030] Step S3: Perform temperature acquisition and sound velocity compensation. The temperature sampling circuit acquires the ambient temperature via a thermistor. In this embodiment, an NTC thermistor is used. The NTC thermistor is a 10k standard resistor connected in series. The 10k standard resistor is connected to the power supply. The NTC resistor is connected to ground. The microprocessor acquires the voltage drop value between the NTC resistor and ground, and records it as the sampled value Nt.
[0031] In actual hardware circuits, to prevent the transducer from damaging the microprocessor in the event of a short circuit or other fault, a 1k protection resistor is connected in series inside the transducer, located between the NTC resistor and ground.
[0032] The microprocessor calculates the actual NTC resistance. When doing so, the voltage drop effect of the 1k protection resistor must be considered. Specifically: ; in, This refers to the voltage at the intermediate node. This is the power supply voltage. It is a 10k standard resistor. For actual NTC resistors, The protection resistor is 1kΩ. The microprocessor calculates the actual NTC resistance based on the sampled value Nt. By accurately taking into account the effect of the 1k protection resistor, the temperature measurement system error caused by hardware parasitic parameters is eliminated.
[0033] The microprocessor internally stores a temperature resistance table for NTC resistors, based on the actual NTC resistors. The measured temperature T is obtained using a lookup table method and interpolation. A temperature judgment rule is set: when the actual NTC resistance... When the resistance is greater than 78.784kΩ, the measured temperature T is determined to be -45℃; when the actual NTC resistance... When the resistance is less than or equal to 0.453kΩ, the measured temperature T is determined to be 100℃; when the actual NTC resistance... When the resistance is between 0.453kΩ and 78.784kΩ, the measured temperature T is accurately obtained through interpolation. The temperature measurement period is set to 1 second.
[0034] The current sound velocity c is calculated after compensation based on the measured temperature T. The speed of sound in air increases with increasing temperature. In this embodiment, the microprocessor uses a high-precision sound velocity formula for calculation, ensuring that the sound velocity error corresponding to a 1℃ temperature error is less than or equal to 0.607 m / s. Compared to the sound velocity at room temperature, the relative measurement error caused by this error is controlled within the range of less than 0.2%. The current sound velocity c is transmitted as a dynamic physical parameter to step S4.
[0035] Step S4: Set the echo search range. The microprocessor obtains the preset dead zone distance corresponding to the transducer's range. Preset dead zone distance This is determined by the physical characteristics of the transducer. In this embodiment, different range transducers correspond to different preset dead zone distances. Preset dead zone distance for a 5m range transducer The preset dead zone distance for an 8m range transducer is 0.3m. The preset dead zone distance for a 0.4m, 20m range transducer is... The preset dead zone distance for a 50m range transducer is 0.8m. The dead zone distance is 1.0m. These dead zone distances are rigorously calculated based on the start-up time and damping characteristics of the transducer's piezoelectric ceramic sheet.
[0036] The sampling interval is calculated based on the transducer's range. It is obtained by calculating using the formula and rounding up, specifically: ; in, The range of the transducer. It is a fixed constant of 5000.
[0037] The specific sampling intervals and absolute errors corresponding to different measurement ranges are as follows: Sampling interval for 5m measurement range The sampling interval is 8 μs with an absolute error of 1.35 mm. The sampling interval corresponding to the 8 m range is... The sampling interval is 13 μs with an absolute error of 2.16 mm. The sampling interval corresponding to a 20 m measurement range is... The sampling interval is 32 μs with an absolute error of 5.40 mm. The sampling interval corresponding to a 40 m measurement range is... The measurement time is 64 μs, and the absolute error is 10.8 mm. The relative error for all measurement ranges is controlled within 0.27‰.
[0038] Based on the preset dead zone distance Current speed of sound c, sampling interval Calculate the initial echo search point Specifically: ; in, Preset dead zone distance The corresponding numerical value. Since ultrasound waves need to travel back and forth, multiply by 2.
[0039] Obtain the maximum measurement distance corresponding to the transducer's range. Based on preset dead zone distance Maximum measurement distance Current speed of sound c, sampling interval Calculate the termination echo search point Specifically: ; The formula ensures the termination echo search point. Not less than the initial echo search point At the same time, it does not exceed the maximum number of points in the microprocessor data storage queue. In this embodiment, the maximum number of points in the microprocessor data storage queue is set to 5000.
[0040] Based on the preset dead zone distance A unified echo point count benchmark is calculated. This benchmark is set as a fixed number of points corresponding to a preset multiple of the preset dead zone distance. In this embodiment, the preset multiple is set to 3, corresponding to a fixed number of 600 points. The basis for setting 600 is that the aftershock attenuation envelope of the transducer after transmission typically ends within 3 times the dead zone distance. Fixing the unified echo point count benchmark at 600 is equivalent to defining a unified physical aftershock boundary for transducers of different ranges. The echo search interval is dynamically adjusted using the current sound velocity c, allowing the interval boundary to expand and contract in real time with changes in ambient temperature.
[0041] Step S5: Perform echo array identification. Within the echo search interval determined in step S4, the microprocessor uses the composite background noise value BS2 obtained in step S2 as the judgment threshold. The echo array is extracted based on three conditions: the starting condition is that the current echo value is less than or equal to the composite background noise value BS2; the continuing condition is that the current echo value is greater than the composite background noise value BS2; and the ending condition is that the current echo value is less than or equal to the composite background noise value BS2.
[0042] Special decision rules are applied to echo arrays located at the boundaries of the echo search interval: First special determination rule: When the initial echo search point When the echo value U0 at a given location is greater than the combined background noise value BS2, the process directly enters the sustained phase, and this echo value U0 is recorded as the first echo value. This prevents valid echoes from being missed when they happen to appear at the search starting point.
[0043] Second special determination rule: When the search process reaches the termination echo search point. If the echo value at the termination echo point is still greater than the combined background noise value BS2, the current echo array is directly determined to have ended. This prevents the microprocessor from accessing memory out of bounds and causing program crashes.
[0044] Record the starting echo point Ns and the maximum echo value Us during the duration of each echo array.
[0045] The echo array near the preset dead zone distance is further filtered using the comprehensive background noise value BS2. The filtering rule is as follows: when the starting echo point Ns of the echo array is less than or equal to the unified echo point count benchmark, the maximum echo value Us of the echo array is further determined. If the maximum echo value Us is less than or equal to the product of the comprehensive background noise value and a preset coefficient, the echo array is discarded. In this embodiment, the preset coefficient is set to 2, meaning the determination condition is that the maximum echo value Us is less than or equal to... If the maximum echo value Us is greater than If the signal is not received, the echo array is retained. The criterion of selecting twice the overall background noise value BS2 is based on the fact that, within the dead zone, the aftershock amplitude of the transducer typically exhibits exponential decay. If the echo amplitude detected within this range is merely a weak fluctuation in background noise (i.e., not reaching twice the background noise level), it can be determined to be aftershock interference rather than a true target reflection.
[0046] Step S6: Perform dual-echo comparison screening: The microprocessor extracts all echo arrays identified in step S5 and identifies the largest echo value Usa and the second largest echo value Usb. The ratio of the second largest echo value Usb to the largest echo value Usa is calculated.
[0047] When the ratio is less than or equal to a preset ratio threshold, the reliability of the echo array corresponding to the maximum echo value Usa is higher. In this embodiment, the preset ratio threshold is set to 0.85. The basis for selecting 0.85 is that, based on the difference in acoustic reflection characteristics of ultrasound on the surface of a liquid and a fixed obstacle, when the difference in amplitude between two echoes reaches 15% or more (i.e., the ratio is 0.85), they can usually be identified as echoes from different reflecting surfaces. At this time, the echo point corresponding to the maximum echo value Usa is selected as the final valid echo point.
[0048] When the ratio is greater than 0.85, calculate the first distance corresponding to the maximum echo value Usa. The second distance corresponding to the second largest echo value Usb .
[0049] Determine the second distance Is it at the first distance? Within a preset distance ratio range. In this embodiment, the preset distance ratio range is set to be greater than 0.45 times and less than or equal to 0.55 times. The basis for selecting the range of 0.45 to 0.55 is that in hydraulic engineering and industrial water tanks, the most common sources of interference are supporting beams, stepped structures, or pipe supports below the water surface. The physical installation positions of these structures are often exactly at half the distance from the main liquid surface. After the ultrasonic waves are reflected from the surfaces of these structures, they are reflected back to the transducer by the liquid surface, and the total propagation path length is exactly equal to the distance from the liquid surface. Setting the range of 0.45 to 0.55 can accurately capture this specific multipath reflection physical phenomenon.
[0050] If the second distance Within this preset distance ratio range, the echo array corresponding to the second largest echo value Usb is determined to be closer to the actual liquid surface target. The echo point corresponding to the second largest echo value Usb is selected as the final valid echo point. If the second distance... If the echo point is not within the preset distance ratio range, the echo point corresponding to the maximum echo value Usa will still be selected as the final valid echo point.
[0051] If no valid echo array is identified in step S5, the instantaneous height value HLS is set to 0. The instantaneous height value HLS for the current period is calculated based on the last valid echo point.
[0052] Step S7: Perform filter calculations and abnormal state closed-loop feedback. The microprocessor sets the filtering parameter NF. In this embodiment, the typical value of the filtering parameter NF is set to 50. The reason for selecting 50 is that, combined with the wave interval of 0.5 seconds to 1.0 seconds, the time window corresponding to 50 filtering points is 25 seconds to 50 seconds. This time window can perfectly cover the typical periodic fluctuations on the water surface caused by wind and waves, ensuring that the filtered output data represents the true average liquid level within one fluctuation cycle.
[0053] NF instantaneous height values (HLS) are continuously acquired to form a filtering queue. An extreme value removal averaging filter is then performed on the filtering queue. The number of small values to be removed is calculated. Number of large values In this embodiment, the preset extremum removal ratio is set to 0.25. . The rationale for choosing a 0.25 ratio is that, in a normally distributed random disturbance model, removing 25% of the extreme values at each end can efficiently eliminate occasional gross errors while retaining enough intermediate valid data for averaging.
[0054] Remove from the filter queue Minimum value and Find the maximum value, obtain the remaining data NFs, and calculate the average. Number of remaining data points. This average value is denoted as the Average Height Value (AHLS).
[0055] Determine if the average height value (AHLS) is 0. If AHLS is 0, maintain the output value from the previous cycle and set the current output value HL(k) equal to the previous cycle's output value HL(k-1). If AHLS is not 0, calculate the maximum deviation of the remaining data relative to the average height value (AHLS). The maximum deviation The distance from the preset dead zone obtained in step S4 Compare them.
[0056] If the maximum deviation Greater than the preset dead zone distance The system determines that the current sampling is in an abnormal state. In this state, a sampling abnormality alarm is triggered, displaying "Sap err". Simultaneously, the output value of the previous cycle is maintained, and the current output value HL(k) is set equal to the previous cycle's output value HL(k-1). The sampling abnormality signal is fed back to step S2 to lock the current comprehensive background noise value BS2. During the locking period, updating the historical maximum background noise value BS1 is prohibited. The core of this closed-loop feedback design is that when the maximum deviation exceeds the dead zone distance, it indicates a drastic change in the environment (such as violent churning of the liquid surface or the appearance of large floating objects). The maximum echo value detected at this time is considered abnormal interference. If updating the historical maximum background noise value BS1 is allowed, these abnormal interference values will be recorded as the new background reference. This will cause the normal liquid surface echo amplitude to be lower than the raised background reference after the environment returns to calm, resulting in the inability to detect the liquid level for a long period. Through feedback locking, synergistic effects between modules are achieved.
[0057] If the maximum deviation Less than or equal to the preset dead zone distance The system determines that the current data is valid. In this valid state, the current output value HL(k) is set equal to the average height value AHLS. The valid data status signal is fed back to step S2 to unlock the system. The historical maximum background noise value BS1 is updated based on the current measurement data, and the overall background noise value BS2 is recalculated. This allows for gradual adaptation to long-term, slow environmental changes, such as an overall increase in background noise due to increased air humidity caused by seasonal changes.
[0058] The microprocessor also executes abnormal alarm logic. Abnormal alarms include sampling abnormal alarms and temperature abnormal alarms.
[0059] The alarm for sampling anomalies is triggered when: the instantaneous height value HLS is 0 for a preset number of consecutive times, or the maximum deviation for a preset number of consecutive times is reached. Greater than the preset dead zone distance In this embodiment, the preset number of times is set to 10. The selection of 10 times is based on the fact that 10 consecutive anomalies correspond to a time of approximately 5 to 10 seconds. This time length is sufficient to eliminate instantaneous electromagnetic interference and confirm that the equipment or environment is indeed in a continuous fault or abnormal state. When any of the above conditions are met, a "Sap err" alarm is triggered. When five consecutive valid instantaneous height values (HLS) appear, the sampling anomaly alarm resets. The selection of five reset times is based on the fact that five valid data points can constitute a basic confirmation window, ensuring that the interference has been completely eliminated.
[0060] The trigger conditions for the abnormal temperature alarm are: 10 consecutive measured temperatures T less than or equal to the preset lower limit, or 10 consecutive measured temperatures T greater than the preset upper limit. In this embodiment, the preset lower limit is set to -45℃, and the preset upper limit is set to 100℃. These two temperature limits correspond to the extreme operating temperatures of the NTC resistor and the internal electronic components of the transducer. When either of the above conditions is met, the "Terr" alarm is triggered. The abnormal temperature alarm resets when 5 consecutive measured temperatures T are within the normal range.
[0061] In the event of an abnormal sampling alarm or an abnormal temperature alarm, the microprocessor locks out all limit-over alarms. Limit-over alarms refer to alarms where the liquid level exceeds a preset safe range. Locking out limit-over alarms prevents malfunctions caused by measurement anomalies, such as incorrectly triggering the start / stop of a water pump. This further enhances operational safety in offline scenarios.
[0062] After the measuring and control instrument is powered on, the microprocessor locks out all alarms within a preset initial measurement cycle. The initial measurement cycle is... The measurement cycle is defined by the power-on interlock mechanism. This mechanism is based on the fact that at the moment of power-on, the circuit is in an unstable state, the capacitors are charging, and the reference voltage is being established. During this time, the acquired temperature and echo data are invalid. Setting this interlock cycle ensures that the system has sufficient time to establish accurate background noise and filtering references, completely avoiding false alarms upon power-on.
[0063] Example 2: This embodiment provides a detailed description of the background noise dynamic calibration in step S2.
[0064] During offline operation, ambient noise can change slowly or abruptly over time. A fixed threshold cannot handle such changes. The microprocessor acquires multiple noise data points during each measurement interval Tds of background noise measurement. The acquired noise data sequence is as follows: Extract the 5 largest values from these. These 5 values are... Calculate the average of these 5 values to obtain the historical maximum background noise value BS1, and assign it to the comprehensive background noise value BS2.
[0065] The microprocessor executes the lower limit protection logic. In an extremely quiet environment, the historical maximum background noise value BS1 is very small, for example, 50. If 50 is used as the judgment threshold, weak environmental fluctuations will be misjudged as echo signals. To prevent misjudgment, 250 is introduced as a preset empirical threshold. It is then determined whether the comprehensive background noise value BS2 is less than 250. If BS1 is 50, the comprehensive background noise value BS2 is forcibly modified to 250. After the comprehensive background noise value BS2 is generated, it enters a waiting state, waiting for the feedback signal from step S7.
[0066] If step S7 determines the data is valid within the current measurement cycle, the historical maximum background noise value BS1 can be updated using the latest acquired data in the next measurement cycle. If step S7 determines the sampling is abnormal, it indicates strong interference in the current environment or violent churning of the liquid surface. Updating the historical maximum background noise value BS1 in this case would cause an abnormal increase in the reference value. After the interference disappears, the system will be unable to recognize normal echo signals. Therefore, upon receiving the feedback signal of the sampling abnormality, the microprocessor locks the historical maximum background noise value BS1 and the combined background noise value BS2, keeping them unchanged.
[0067] Through this feedback mechanism, background noise calibration is no longer a one-way data processing process, but forms a closed-loop control system with strong correlation to filtering calculation, which significantly improves the robustness of offline measurement.
[0068] Example 3: This embodiment provides a detailed description of temperature acquisition and sound velocity compensation in step S3.
[0069] The speed of sound in air is greatly affected by temperature. Without precise compensation, the measurement results will drift significantly.
[0070] The temperature sampling circuit uses a voltage divider method to measure temperature. Power supply voltage. 5V. 10k standard resistor. Connected between the power supply and the NTC resistor. NTC resistor A 10k standard resistor is connected between the 10k standard resistor and ground. The microprocessor's analog-to-digital converter is connected at the midpoint between the 10k standard resistor and the NTC resistor. The voltage value at this node is read and converted into a digital value, namely the sampled value Nt.
[0071] Calculate the actual NTC resistance based on the sampled value Nt. Specifically: ; in, This represents the maximum quantization value of the analog-to-digital converter. The actual NTC resistance, including the influence of the protection resistor, was accurately obtained through calculation. .
[0072] The microprocessor internally stores a temperature resistance lookup table for NTC resistors, covering a temperature range of -45℃ to 100℃. This allows for the determination of the actual NTC resistor value. Scope: When When this occurs, it indicates that the temperature is extremely low, exceeding the normal measurement range. Therefore, the measured temperature T is directly set to -45℃. If this indicates extremely high temperature or a short circuit, the measured temperature T should be set to 100℃. When, look up the match in the lookup table. The two closest resistance points are respectively , The corresponding temperatures are respectively , The measured temperature T is calculated using linear interpolation, specifically as follows: ; This calculation method, which combines table lookup and interpolation, saves microprocessor computing resources while ensuring the accuracy of temperature calculations.
[0073] After obtaining the measured temperature T, sound velocity compensation calculation is performed. The high-precision sound velocity calculation used in this embodiment ensures that the calculation error for every 1°C change in temperature does not exceed 0.607 m / s. Compared to the sound velocity of 340 m / s at room temperature, this error results in a relative measurement error of less than 0.2%. The calculated current sound velocity c is transmitted to step S4 in real time. This real-time transmission mechanism establishes a dynamic correlation between temperature and the set interval.
[0074] Example 4: This embodiment provides a detailed explanation of the echo search interval setting in step S4.
[0075] The setting of the echo search range directly determines the computational workload and anti-interference capability of the microprocessor. If the range is too large, the calculation will be slow and it will be easy to introduce interference from a distance. If the range is too small, the true echo will be lost.
[0076] Taking a 5m range transducer as an example, the specific calculation is explained, with a preset dead zone distance. The current velocity is 0.3m. The current ambient temperature is 25℃, and the calculated current sound velocity c is 346m / s. The sampling interval is... The duration is 8 μs.
[0077] Calculate the initial echo search point : ; This means that the microprocessor will start searching for echoes from the 217th sampling point, and the data corresponding to the first 216 sampling points are transducer aftershock data, which are directly ignored.
[0078] Calculate the termination echo search point Maximum measurement distance It is 8m.
[0079] The theoretical maximum number of points is: ; calculate ,calculate Therefore, the echo search point is terminated. Set to 5000.
[0080] If the temperature changes, for example, if the current temperature drops to 0°C, the current speed of sound c drops to 331 m / s.
[0081] New .
[0082] New theoretical maximum points .
[0083] New .
[0084] Therefore, it can be seen that the change in the current speed of sound c directly affects the initial echo search point. Dynamic translation. Although in this example Limited by the hardware queue length remaining constant at 5000, but under smaller ranges or higher speeds of sound, It also dynamically expands and contracts with the speed of sound. This dynamic translation mechanism ensures that the search range is always precisely aligned with the actual physical distance, eliminating systematic errors caused by temperature drift.
[0085] Example 5: This embodiment provides a detailed explanation of the echo array identification in step S5 and the dual-echo comparison and screening in step S6.
[0086] microprocessors in to The system scans point by point within the specified interval. At a certain location, if the echo value changes from below the overall background noise value BS2 to above BS2, the starting point of the echo array is determined and recorded as the starting echo point Ns. If the starting echo point Ns is exactly equal to the starting echo search point... Furthermore, since the echo value U0 at this point is greater than the comprehensive background noise value BS2, the first special judgment rule is applied, and U0 is directly taken as the first echo value.
[0087] Continuously record the echo value. When the echo value is again less than or equal to the combined background noise value BS2, the echo array is considered to have ended. If the termination echo search point is reached... If the echo value is still greater than the combined background noise value BS2, the second special judgment rule is executed to forcibly terminate the array.
[0088] During the sustained phase, the maximum echo value Us is recorded.
[0089] A secondary screening is performed on the recorded echo arrays. The baseline for the number of echo points is set to 600. If the starting echo point Ns of an echo array is equal to 400 (400 is less than 600), the maximum echo value Us of that array is further checked. The overall background noise value BS2 is 300. If the maximum echo value Us is 500, and 500 is less than 600, the echo array is determined to be within the dead zone aftershock range and is discarded. If the maximum echo value Us is 800, and 800 is greater than 600, the echo array is retained.
[0090] After the above identification and screening, the microprocessor obtains one or more valid echo arrays.
[0091] Proceed to step S6 to perform dual-echo comparison filtering, identifying the largest echo value Usa and the second largest echo value Usb. Usa is 2000, Usb is 1500, and the ratio is... Since 0.75 is less than 0.85, the echo point corresponding to Usa is directly selected as the final valid echo point. Usa is 2000, Usb is 1800, and the ratio is... 0.9 is greater than 0.85. Calculate the first distance corresponding to Usa. The distance is 5.0m; calculate the second distance corresponding to Usb. The value is 2.6m. Determine if 2.6m is within the acceptable range. to The method involves determining whether 2.6m falls within the range of 2.25m to 2.75m. If 2.6m is within this range, the echo array corresponding to the second largest echo value Usb is determined to be the true liquid surface echo, and the echo point corresponding to Usb is selected as the final valid echo point.
[0092] The physical meaning of this judgment logic is that when there are strong waves on the water surface or a support beneath the water, ultrasonic waves may produce multiple reflections. If there is a strong reflector at a distance that is exactly half the distance of the main echo, the echo produced by this reflector is often more representative than the actual echo from the distant liquid surface. Through dual correlation judgment based on similar amplitudes and proportional distances, the system can intelligently identify complex water surface conditions and avoid false locking.
[0093] The instantaneous altitude value (HLS) is calculated based on the final valid echo point. Specifically: ; in, This is the final valid echo point.
[0094] Example 6: This embodiment provides a detailed explanation of the filtering calculation and abnormal state closed-loop feedback in step S7.
[0095] The microprocessor sets the filtering parameter NF to 50 and continuously acquires 50 instantaneous height values HLS to form a filtering queue.
[0096] Calculate the number of extreme values that need to be removed. , The value is also 12. After removing the 12 minimum and 12 maximum values from 50 data points, the number of remaining data points is... Calculate the average of these 26 data points to obtain the average height value (AHLS). Check if the average height value (AHLS) is 0. If AHLS is 0, it means that most of the data is invalid, and set the current output value accordingly. If AHLS is not 0, calculate the difference between these 26 data points and the average height value AHLS, find the maximum value among these 26 differences, and record it as the maximum deviation. .
[0097] Get the preset dead zone distance of the current transducer Currently using a 20m range transducer with a preset dead zone distance. The value is 0.8m. Determine the maximum deviation. Is it greater than 0.8m? The current liquid level is very stable, with minimal fluctuations in the 26 data points, and the maximum deviation is... The value is 0.1m, which is less than 0.8m, so the data is considered valid. The current output value is then set to... A data validity status signal is sent to step S2. After receiving the signal, step S2 updates the historical maximum background noise value BS1 normally in the next measurement cycle.
[0098] The liquid surface is currently experiencing violent churning, or a large object is passing through the measurement area. The fluctuations in the 26 data points are extremely large. Maximum deviation. The value is 1.5m. 1.5m is greater than 0.8m. This is considered an abnormal sampling condition. The microprocessor reports "Sap err". Set the current output value... The output remains unchanged. A sampling anomaly signal is sent to step S2. Upon receiving this signal, step S2 locks the historical maximum background noise value BS1. In subsequent measurement cycles, as long as the sampling anomaly persists, step S2 will not update BS1. This prevents high-intensity spurious echoes generated by tumbling from being recorded as background noise.
[0099] Simultaneously monitor the number of consecutive anomalies. If 10 consecutive cycles are determined to be in a sampling anomaly state, or if the height instantaneous value (HLS) is 0 for 10 consecutive cycles, a "Sap err" alarm is officially triggered and maintained. When the environment returns to stability and 5 consecutive cycles are determined to be in a data valid state, the "Sap err" alarm resets.
[0100] For temperature anomaly alarms, the same continuous judgment logic is executed. A "Terr" alarm is triggered if the measured temperature T exceeds the range of -45℃ to 100℃ for 10 consecutive times. It resets after 5 consecutive normal readings.
[0101] During the presence of either the "Sap err" or "Terr" alarm, the microprocessor locks out over-limit alarms. The system is set to trigger a high-limit alarm when the liquid level exceeds 4.5m. During the "Sap err" alarm period, even if the current output value HL(k) is greater than 4.5m, the high-limit alarm will not be triggered. This prevents relay malfunctions due to measurement anomalies, protecting safety in the industrial environment.
[0102] When the measuring and control instrument is first powered on, the system is in an unstable state. The microprocessor calculates the initial measurement cycle. The initial measurement cycle is... One measurement cycle. During these 50 cycles, all alarms are locked. This ensures the system has sufficient time to establish accurate background noise and filtering references.
[0103] As can be seen from the above embodiments, this invention tightly integrates multi-wave transmission, dynamic noise calibration, temperature and velocity of sound compensation, dynamic range setting, array identification, dual-echo comparison, and adaptive filtering. In particular, the feedback mechanism from filtering deviation to noise calibration breaks away from the isolated, stacked structure of traditional patents. Dynamic parameters are exchanged between the various modules, forming an organic whole with self-regulating capabilities.
[0104] The present invention and its embodiments have been described above. This description is not restrictive, and the accompanying drawings are only one embodiment of the present invention; the actual structure is not limited thereto. In conclusion, if those skilled in the art are inspired by this description and design similar structures and embodiments without departing from the spirit of the invention, such designs should fall within the protection scope of the present invention.
Claims
1. An offline echo detection method for an ultrasonic liquid level measuring and control instrument, characterized in that, The specific steps of the method include: Step S1: The transducer built into the ultrasonic level measuring and control instrument continuously emits multiple ultrasonic pulses to acquire raw sampling data; Step S2: Calculate the historical maximum background noise value based on the original sampling data, and generate a comprehensive background noise value by combining it with a preset empirical threshold; Step S3: Collect ambient temperature data to obtain the measured temperature value, and calculate the current sound velocity after compensation; Step S4: Obtain the preset dead zone distance and maximum measurement distance corresponding to the transducer's range; calculate the sampling interval based on the transducer's range; calculate the echo search interval based on the preset dead zone distance, maximum measurement distance, current sound velocity, and sampling interval; Step S5: Extract the echo array within the echo search interval using the comprehensive background noise value as the judgment threshold, and record the maximum echo value and the second largest echo value of the echo array; Step S6: Extract the maximum echo value and the second largest echo value. Based on the ratio of the two and the corresponding distance relationship, determine the final valid echo point and calculate the instantaneous height value. Step S7: Continuously acquire multiple instantaneous height values to form a filtering queue, perform extreme value removal and average filtering calculation to obtain the average height value; calculate the maximum deviation of the remaining data after removing extreme values from the filtering queue relative to the average height value, compare the maximum deviation with the preset dead zone distance, and feed back the comparison result to step S2 to lock or update the comprehensive background noise value.
2. The offline echo detection method for an ultrasonic liquid level measuring and control instrument according to claim 1, characterized in that: In step S2, the historical maximum background noise value is the average of the maximum preset number of background noise values in the previous measurement process; the historical maximum background noise value is compared with a preset empirical threshold, and the larger of the two values is taken as the comprehensive background noise value.
3. The offline echo detection method for an ultrasonic liquid level measuring and control instrument according to claim 2, characterized in that: In step S4, the starting echo search point is calculated based on the preset dead zone distance, the current sound speed, and the sampling interval; the ending echo search point is calculated based on the preset dead zone distance, the maximum measurement distance, the current sound speed, and the sampling interval; a unified echo point count benchmark is calculated based on the preset dead zone distance; and the interval boundary of the echo search interval is dynamically adjusted using the current sound speed.
4. The offline echo detection method for an ultrasonic liquid level measuring and control instrument according to claim 3, characterized in that: In step S5, if the starting echo point of the echo array is less than or equal to the unified echo point number benchmark, and the maximum echo value of the echo array is less than or equal to the product of the comprehensive background noise value and the preset coefficient, then the echo array is discarded.
5. The offline echo detection method for an ultrasonic liquid level measuring and control instrument according to claim 4, characterized in that: In step S6, when the ratio of the second largest echo value to the largest echo value is greater than a preset ratio threshold, the first distance and the second distance are calculated based on the echo points corresponding to the two; if the second distance is within the preset distance ratio range of the first distance, the echo point corresponding to the second largest echo value is selected as the final valid echo point.
6. The offline echo detection method for an ultrasonic liquid level measuring and control instrument according to claim 4, characterized in that: In step S7, if the maximum deviation is greater than the preset dead zone distance, it is determined to be a sampling abnormal state and is fed back to step S2 to lock the comprehensive background noise value. If the maximum deviation is less than or equal to the preset dead zone distance, the data is determined to be valid, and feedback is sent to step S2 to update the historical maximum background noise value and recalculate the comprehensive background noise value.
7. The offline echo detection method for an ultrasonic level measuring and control instrument according to claim 6, characterized in that: In case of abnormal sampling, trigger an abnormal sampling alarm and lock out the over-limit alarm when the liquid level exceeds the preset safety range.
Citation Information
Patent Citations
Precise temperature compensation ultrasonic liquid level detection method and system
CN111351551A
Anti-interference dynamic distance measuring method and dynamic accumulated water monitoring method
CN112129379A