An ultrasonic transit time measurement circuit and method for eliminating the blind area of ​​small pipe diameter measurement

Through the embedded MCU and zero-crossing comparator combined with multi-stage analog switches and automatic gain control circuit, the problem of low crossing time measurement accuracy in small-pipe ultrasonic flowmeters is solved, and an ultrasonic flowmeter with high signal-to-noise ratio and no blind spots is realized Measurement.

CN115388967BActive Publication Date: 2024-11-15CHINA COAL TECH & ENG GRP CHONGQING RES INST CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211040947.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-29
Publication Date
2024-11-15
Estimated Expiration
2042-08-29

AI Technical Summary

Technical Problem

In the measurement of small-pipe ultrasonic flow rate, the measurement accuracy of downstream ultrasonic transit time is affected by the interference of the driving circuit, resulting in a blind spot of measurement, which is difficult to effectively solve in the prior art.

Method used

The high-speed time capture unit of embedded MCU is combined with a zero-crossing comparator, and electrical isolation and signal amplification are performed through multi-stage analog switching cascade and automatic gain control AGC circuit, and threshold calculation is performed by combining ADC sampling and zero-crossing comparator to determine ultrasonic waves. Passing through time.

Benefits of technology

It realizes time measurement resolution at tens of nanoseconds, eliminates the blind spots of small tube diameter measurement, improves the measurement accuracy and signal-to-noise ratio of ultrasonic flowmeters, and is suitable for ultrasonic flowmeters of any tube diameter.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115388967B_ABST
    Figure CN115388967B_ABST
Patent Text Reader

Abstract

The present invention relates to an ultrasonic transit time measurement circuit and method for eliminating a blind spot in small-diameter measurement, and belongs to the field of ultrasonic flow velocity measurement. First, by adopting the principle of multi-stage analog switch cascade and time-sharing conduction, the residual noise of the ultrasonic drive circuit is electrically isolated from the receiving circuit, so that the signal-to-noise ratio of the received signal is enhanced, and the blind spot phenomenon in short-distance measurement caused by the poor isolation effect of a single analog switch can be eliminated; secondly, an automatic gain adjustment circuit composed of a digital potentiometer and a filter amplifier is used to amplify or attenuate the ultrasonic signal to an ideal amplitude; finally, a zero-crossing comparator and an MCU built-in analog-to-digital converter (ADC) are used for sampling to perform threshold comparison and zero-crossing point calculation to determine the ultrasonic transit time of the forward and reverse flow process. The method has the characteristics of simple circuit, high signal-to-noise ratio, and no blind spot in measurement, and is suitable for ultrasonic flowmeters of any diameter.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of ultrasonic flow velocity measurement, and relates to an ultrasonic transit time measurement circuit and method for eliminating a small-diameter measurement blind area. Background Art

[0002] Ultrasonic transit time tof refers to the time taken by the ultrasonic probe from sending an ultrasonic signal to receiving an ultrasonic signal. The ultrasonic flow measurement principle is as follows: Figure 1 shown.

[0003] By measuring the ultrasonic transit time tof in the fluid flow and counter-flow process s and tof n , the velocity and flow rate of the fluid in the pipeline can be calculated as follows:

[0004]

[0005]

[0006] Where: L is the length of the sound channel; v is the fluid velocity; θ is the angle between the sound channel and the pipeline axis; q is the instantaneous flow rate; and D is the inner diameter of the pipeline.

[0007] When a small diameter pipe is used for high flow rate measurement, the downstream ultrasonic transit time will become very small. If the interference of the driving circuit is not suppressed, some pulses will be coupled to the receiving end, affecting the downstream ultrasonic transit time measurement. Figure 2 shown.

[0008] At present, no literature and journals specifically targeting the blind spot of small diameter measurement have been found. For transit time detection, domestic and foreign researchers mainly use the time difference method to design ultrasonic gas flowmeters. The methods adopted mainly include the threshold method and the cross-correlation algorithm. The measurement accuracy of the cross-correlation algorithm is highly dependent on the selected reference waveform, but the acquisition of the reference waveform is difficult, so the more common practice is to use the threshold method combined with zero-crossing detection to calculate the transit time. The measurement accuracy of the transit time directly affects the measurement lower limit and measurement accuracy of the ultrasonic gas flowmeter. The time measurement resolution of the system can be improved by increasing the operating frequency of the processor or acquisition unit. Therefore, some researchers use FPGA combined with high-speed ADC to sample and store waveforms to further complete time detection; some scholars use the dedicated time digital conversion chip TDC-GP22 of the German ACAM company to achieve, and TDC-GP22 has a time measurement resolution of picoseconds. The present invention uses the high-speed time capture unit of the embedded MCU combined with the zero-crossing comparator for time detection. The peripheral circuit is simple and low-cost, and a time measurement resolution of tens of nanoseconds can be obtained. Summary of the invention

[0009] In view of this, an object of the present invention is to provide an ultrasonic transit time measurement circuit and method for eliminating the blind area of ​​small diameter pipe measurement.

[0010] In order to achieve the above object, the present invention provides the following technical solutions:

[0011] An ultrasonic transit time measurement circuit for eliminating a blind area in small-diameter pipe measurement, the circuit comprising a microcontroller unit MCU;

[0012] The MCU is equipped with a timer TIMER and an analog-to-digital conversion circuit ADC;

[0013] The MCU is electrically connected to a driving circuit 1, an ultrasonic transducer 1, a limiting circuit 1, an analog switch 1, an analog switch 3, an automatic gain control AGC circuit and an ADC in sequence;

[0014] The automatic gain control AGC circuit is electrically connected to the zero-crossing comparison circuit and the TIMER in sequence;

[0015] The MCU is also electrically connected to the second driving circuit and the second ultrasonic transducer in sequence;

[0016] The second ultrasonic transducer is electrically connected to the second amplitude limiting circuit, the second analog switch and the third analog switch in sequence;

[0017] The ultrasonic transducer 2 and the ultrasonic transducer 1 transmit and receive ultrasonic signals to each other;

[0018] The analog switch 1 is a single-channel analog switch 1, the analog switch 3 is a multi-channel analog switch, and the analog switch 2 is a single-channel analog switch 2.

[0019] Optionally, the automatic gain control AGC circuit includes a common-direction proportional amplifier circuit, a gain adjustable circuit and a bandpass filter circuit connected in sequence.

[0020] Optionally, the amplification capacity of the in-phase proportional amplifier circuit is 20 dB, the amplification capacity of the gain adjustable circuit is 0-30 dB, and the amplification capacity of the bandpass filter circuit is 20 dB.

[0021] Optionally, the gain adjustable circuit includes a digital potentiometer and an operational amplifier;

[0022] The digital potentiometer and the MCU are connected by SPI protocol communication;

[0023] The adjustment range of the digital potentiometer is 0 to 100 kΩ.

[0024] The ultrasonic transit time measurement method based on the measurement circuit to eliminate the small diameter measurement blind area comprises the following steps:

[0025] Step 1: Use the principle of multi-stage analog switch cascade and time-sharing conduction to electrically isolate the residual noise of the ultrasonic drive circuit from the receiving circuit;

[0026] Step 2: Use an automatic gain adjustment circuit to amplify or attenuate the ultrasonic signal to an ideal amplitude;

[0027] Step 3: Use ADC sampling and zero-crossing comparator to perform threshold calculation and zero-crossing calculation to determine the ultrasonic transit time.

[0028] Optionally, the step 1 is specifically as follows:

[0029] The residual noise of the ultrasonic drive circuit is electrically isolated from the receiving circuit by adopting the principle of multi-stage analog switch cascade and time-sharing conduction.

[0030] The driving signal controls transducer 1 to emit ultrasonic waves, and the limiting circuit composed of parallel diodes limits the output signal of transducer 1 to within ±700mV to prevent excessive voltage from damaging the subsequent circuit.

[0031] The IO port of the microcontroller unit MCU generates a level signal to control the single-channel analog switch 1 to be turned off, and controls the first channel of the multi-channel analog switch to be turned off, so that the signal passing through the limiting circuit 1 is isolated or attenuated twice; correspondingly, the IO port of the MCU generates a level signal to control the single-channel analog switch 2 to be turned on, and controls the second channel of the multi-channel analog switch to be turned on, so that the ultrasonic receiving signal of the transducer 2 after passing through the limiting circuit 2 is turned on and output to the subsequent automatic gain control AGC circuit; the analog switch cascade is turned on or off to avoid noise interference caused by the ultrasonic drive circuit.

[0032] Optionally, the step 2 is specifically as follows:

[0033] The automatic gain control AGC circuit consists of 3 cascades:

[0034] The first stage is a proportional amplifier circuit, which is used to increase the input impedance and reduce the output impedance, and amplify the ultrasonic signal at the same time, with an amplification capacity of 20dB;

[0035] The second stage is a gain-adjustable amplifier circuit based on a digital potentiometer, which amplifies the previous stage signal and performs low-pass filtering to suppress circuit noise. Its amplification capacity is 0 to 30 dB.

[0036] The third stage is a second-order bandpass filter circuit, which further suppresses noise and amplifies the previous stage signal, and its amplification capacity is 20dB;

[0037] Among them, the gain adjustable amplifier circuit is based on a digital potentiometer and an operational amplifier, and the communication between the digital potentiometer and the MCU adopts the SPI protocol; the digital potentiometer selects an adjustment range of 0 to 100 kΩ to obtain an ultrasonic receiving signal that eliminates the measurement blind area.

[0038] Optionally, the step 3 is specifically as follows:

[0039] ADC sampling and zero-crossing comparator are used to perform threshold calculation and zero-crossing point calculation to determine the ultrasonic transit time, which is divided into main path and auxiliary path;

[0040] The main circuit is connected to the built-in ADC of the MCU, and the ultrasonic waveform is collected and stored in the designated RAM space for future use through the DMA function of the MCU.

[0041] The auxiliary circuit is connected to the zero-crossing comparison circuit, and the zero-crossing point information of the ultrasonic signal is converted into a square wave through the comparator. The square wave is connected to the timer input capture port of the MCU to detect the zero-crossing moment.

[0042] Optionally, the use of ADC sampling and zero-crossing comparator to perform threshold calculation and zero-crossing point calculation to determine the ultrasonic transit time is specifically:

[0043] ① Start the DMA controller and ADC to collect ultrasonic waveforms and store them in RAM. At the same time, the zero-crossing comparator generates a zero-crossing comparison pulse and connects it to the timer input capture port of the MCU.

[0044] ②Search for the local peak values ​​P1~Pn and the corresponding time of the rising edge of the waveform, which are recorded as Vp(i) and Tp(i) respectively; where n is the number of peaks in the rising edge stage of the waveform; i is the number of peaks, with a value of 1~n;

[0045] ③ According to the maximum peak amplitude Vp_max, set the dynamic threshold K, K = a*Vp_max, where a is the threshold coefficient;

[0046] ④ Traverse and search the ultrasonic waveform in RAM, and record the characteristic time interval [Tp(3), Tp(4)] where it first intersects with the comparison threshold K, recorded as [T_L, T_H];

[0047] ⑤ Taking the T_L moment of the previous cycle as the reference, generate a high-level signal lasting 50us as the timer input capture enable signal, measure the falling edge time of the zero-crossing detection pulse, and obtain multiple zero-crossing times, recorded as T0[n];

[0048] ⑥ Search for the zero-crossing time in T0[n] that is within the time range [T_L, T_H], record it as T0', and then subtract the fixed delay τ to obtain the accurate transit time Tof, Tof = T0'-τ.

[0049] The beneficial effects of the present invention are as follows: the present invention has the characteristics of simple circuit, high signal-to-noise ratio and no blind area in measurement, and is suitable for ultrasonic flowmeters of any pipe diameter.

[0050] Other advantages, objectives and features of the present invention will be described in the following description to some extent, and to some extent, will be obvious to those skilled in the art based on the following examination and study, or can be taught from the practice of the present invention. The objectives and other advantages of the present invention can be realized and obtained through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention will be described in detail below in conjunction with the accompanying drawings, wherein:

[0052] Figure 1 It is the ultrasonic flow measurement principle;

[0053] Figure 2 For receiving signals with transmission interference;

[0054] Figure 3 To measure the system architecture;

[0055] Figure 4 It is an analog switch cascade control architecture;

[0056] Figure 5 It is an automatic gain control architecture;

[0057] Figure 6 It is a gain adjustment filter amplifier circuit;

[0058] Figure 7 To receive signals without transmitting interference;

[0059] Figure 8 It is a zero-crossing detection architecture;

[0060] Fig. 9 It is the ultrasonic sampling waveform. DETAILED DESCRIPTION

[0061] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the illustrations provided in the following embodiments only illustrate the basic concept of the present invention in a schematic manner, and the following embodiments and features in the embodiments can be combined with each other without conflict.

[0062] Among them, the drawings are only used for illustrative explanations, and they only represent schematic diagrams rather than actual pictures, and should not be understood as limitations on the present invention. In order to better illustrate the embodiments of the present invention, some parts of the drawings may be omitted, enlarged or reduced, and do not represent the size of actual products. For those skilled in the art, it is understandable that some well-known structures and their descriptions in the drawings may be omitted.

[0063] The same or similar numbers in the drawings of the embodiments of the present invention correspond to the same or similar parts; in the description of the present invention, it should be understood that if the terms "upper", "lower", "left", "right", "front", "rear", etc. indicate the orientation or position relationship, they are based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operate in a specific orientation. Therefore, the terms describing the position relationship in the drawings are only used for illustrative purposes and cannot be understood as limiting the present invention. For ordinary technicians in this field, the specific meanings of the above terms can be understood according to specific circumstances.

[0064] An ultrasonic transit time measurement method for eliminating a blind spot in small-diameter pipe measurement includes the following three steps:

[0065] Step 1: Use the principle of multi-stage analog switch cascade and time-sharing conduction to electrically isolate the residual noise of the ultrasonic drive circuit from the receiving circuit;

[0066] Step 2: Use an automatic gain adjustment circuit to amplify or attenuate the ultrasonic signal to an ideal amplitude;

[0067] Step 3: Use ADC sampling and zero-crossing comparator to perform threshold calculation and zero-crossing calculation to determine the ultrasonic transit time.

[0068] The entire measurement system architecture is as follows Figure 3 shown.

[0069] Step 1:

[0070] The residual noise of the ultrasonic drive circuit is electrically isolated from the receiving circuit by adopting the principle of multi-stage analog switch cascade and time-sharing conduction. Taking transducer 1 emitting ultrasonic waves and transducer 2 receiving ultrasonic waves as an example, the drive signal controls transducer 1 to emit ultrasonic waves, and the limiting circuit composed of parallel diodes limits the output signal of one end of the transducer to within ±700mV to prevent excessive voltage from damaging the subsequent circuit; the IO port of the MCU generates a level signal to control the single-channel analog switch 1 to turn off, and controls the first channel of the multi-channel analog switch to turn off, so that the signal passing through the limiting circuit 1 can be isolated or attenuated twice; correspondingly, the IO port of the MCU generates a level signal to control the single-channel analog switch 2 to turn on, and controls the second channel of the multi-channel analog switch to turn on, so that the ultrasonic receiving signal at both ends of the transducer after passing through the limiting circuit can be smoothly conducted and output to the subsequent automatic gain control (AGC) circuit. This process is turned on or off by the analog switch cascade, which can effectively avoid the noise interference caused by the ultrasonic drive circuit. The analog switch cascade control architecture is as follows Figure 4 shown.

[0071] Step 2:

[0072] The ultrasonic signal at the receiving end of the transducer is usually only a few millivolts to tens of millivolts and is accompanied by amplitude jitter, so it needs to be amplified and automatically adjusted for gain. The automatic gain control AGC circuit consists of three cascades. The first stage is a unidirectional proportional amplifier circuit, which is used to increase the input impedance and reduce the output impedance, and amplify the ultrasonic signal at the same time, with an amplification capacity of 20dB; the second stage is a gain-adjustable amplifier circuit based on a digital potentiometer, which amplifies the previous stage signal while performing low-pass filtering to suppress circuit noise, and its amplification capacity is 0 to 30dB; the third stage is a second-order bandpass filter circuit, which further suppresses noise and amplifies the previous stage signal, and its amplification capacity is 20dB. The entire automatic gain control AGC circuit is as follows Figure 5 shown.

[0073] Among them, the gain adjustable amplifier circuit is based on a digital potentiometer and an operational amplifier, and the communication between the digital potentiometer and the MCU adopts the SPI protocol. Considering the greater amplitude adjustment capability, the digital potentiometer should select an adjustment range of 0 to 100 kΩ. The circuit has a low-pass filtering function, which can filter out the high-frequency noise signal of the circuit. The gain adjustable filter amplifier circuit is as follows Figure 6 shown.

[0074] After steps 1 and 2, the ultrasonic receiving signal with the blind area eliminated can be obtained, such as Figure 7 shown.

[0075] Step 3:

[0076] ADC sampling and zero-crossing comparator are used to perform threshold calculation and zero-crossing calculation to determine the ultrasonic transit time. The whole process is completed in two main and auxiliary paths. The main path is directly connected to the high-precision ADC built into the MCU, and the DMA function of the MCU is used for continuous acquisition to collect the ultrasonic waveform and store it in the specified RAM space for standby use; the auxiliary path is connected to the zero-crossing comparison circuit, and the zero-crossing information of the ultrasonic signal is converted into a square wave through the comparator, and the square wave is connected to the timer input capture port of the MCU for zero-crossing detection. Figure 8 This is the schematic diagram of the zero-crossing detection architecture.

[0077] Fig. 9 This is a schematic diagram of the transit time measurement based on the threshold method and zero-crossing detection. The workflow of the entire process is described in detail as follows:

[0078] ① Start the DMA controller and ADC to collect ultrasonic waveforms and store them in RAM. At the same time, the zero-crossing comparator generates a zero-crossing comparison pulse and connects it to the timer input capture port of the MCU.

[0079] ②Search for the local peak values ​​P1~Pn and the corresponding time of the rising edge of the waveform, which are recorded as Vp(i) and Tp(i) respectively;

[0080] ③ According to the maximum peak amplitude Vp_max, set the dynamic threshold K, K = a*Vp_max, where a is the threshold coefficient;

[0081] ④ Traverse and search the ultrasonic waveform in RAM, and record the characteristic time interval [Tp(3), Tp(4)] where it first intersects with the comparison threshold K, recorded as [T_L, T_H];

[0082] ⑤ Taking the T_L moment of the previous cycle as the reference, generate a high-level signal lasting 50us as the timer input capture enable signal, measure the falling edge time of the zero-crossing detection pulse, and obtain multiple zero-crossing times, recorded as T0[n];

[0083] ⑥ Search for the zero-crossing time in T0[n] within the time range [T_L, T_H], record it as T0', and then subtract the fixed delay τ to obtain the accurate transit time Tof, Tof = T0'-τ.

[0084] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the purpose and scope of the technical solution, which should be included in the scope of the claims of the present invention.

Claims

1. Ultrasonic transit time measurement method based on measurement circuit to eliminate the blind area of ​​small diameter measurement, Features: The measuring circuit comprises a microcontroller unit MCU; The MCU is equipped with a timer TIMER and an analog-to-digital conversion circuit ADC; The MCU is electrically connected to a driving circuit 1, an ultrasonic transducer 1, a limiting circuit 1, an analog switch 1, an analog switch 3, an automatic gain control AGC circuit and an ADC in sequence; The automatic gain control AGC circuit is electrically connected to the zero-crossing comparison circuit and the TIMER in sequence; The MCU is also electrically connected to the second driving circuit and the second ultrasonic transducer in sequence; The second ultrasonic transducer is electrically connected to the second limiting circuit, the second analog switch and the third analog switch in sequence; The ultrasonic transducer 2 and the ultrasonic transducer 1 transmit and receive ultrasonic signals to each other; The analog switch 1 is a single-channel analog switch 1, the analog switch 3 is a multi-channel analog switch, and the analog switch 2 is a single-channel analog switch 2; The automatic gain control AGC circuit comprises a proportional amplifier circuit, a gain adjustable circuit and a bandpass filter circuit connected in sequence; The amplification capacity of the in-phase proportional amplifier circuit is 20 dB, the amplification capacity of the gain adjustable circuit is 0-30 dB, and the amplification capacity of the bandpass filter circuit is 20 dB; The gain adjustable circuit includes a digital potentiometer and an operational amplifier; The digital potentiometer and the MCU are connected by SPI protocol communication; The adjustment range of the digital potentiometer is 0 to 100 kΩ; The measuring method comprises the following steps: Step 1: Use the principle of multi-stage analog switch cascade and time-sharing conduction to electrically isolate the residual noise of the ultrasonic drive circuit from the receiving circuit; Step 2: Use an automatic gain adjustment circuit to amplify or attenuate the ultrasonic signal to an ideal amplitude; Step 3: Use ADC sampling and zero-crossing comparator to perform threshold calculation and zero-crossing point calculation to determine the ultrasonic transit time; The step 1 is specifically as follows: The residual noise of the ultrasonic drive circuit is electrically isolated from the receiving circuit by adopting the principle of multi-stage analog switch cascade and time-sharing conduction. The driving signal controls transducer 1 to emit ultrasonic waves, and the limiting circuit composed of parallel diodes limits the output signal of transducer 1 to within ±700mV to prevent excessive voltage from damaging the subsequent circuit. The IO port of the microcontroller unit MCU generates a level signal to control the single-channel analog switch 1 to turn off, and controls the first channel of the multi-channel analog switch to turn off, so that the signal passing through the limiting circuit 1 can be isolated or attenuated twice; correspondingly, the IO port of the MCU generates a level signal to control the single-channel analog switch 2 to turn on, and controls the second channel of the multi-channel analog switch to turn on, so that the ultrasonic receiving signal of the transducer 2 after passing through the limiting circuit 2 is turned on and output to the post-stage automatic gain control AGC circuit; the analog switch cascade is turned on or off to avoid noise interference caused by the ultrasonic drive circuit; The step 2 is specifically as follows: The automatic gain control AGC circuit consists of 3 cascades: The first stage is a proportional amplifier circuit, which is used to increase the input impedance and reduce the output impedance, and amplify the ultrasonic signal at the same time, with an amplification capacity of 20dB; The second stage is a gain-adjustable amplifier circuit based on a digital potentiometer, which amplifies the previous stage signal and performs low-pass filtering to suppress circuit noise. Its amplification capacity is 0 to 30 dB. The third stage is a second-order bandpass filter circuit, which further suppresses noise and amplifies the previous stage signal, and its amplification capacity is 20dB; Among them, the gain adjustable amplifier circuit is based on a digital potentiometer and an operational amplifier, and the communication between the digital potentiometer and the MCU adopts the SPI protocol; the digital potentiometer selects an adjustment range of 0 to 100 kΩ to obtain an ultrasonic receiving signal that eliminates the measurement blind area; The step 3 is specifically as follows: ADC sampling and zero-crossing comparator are used to perform threshold calculation and zero-crossing point calculation to determine the ultrasonic transit time, which is divided into main path and auxiliary path; The main circuit is connected to the built-in ADC of the MCU, and the ultrasonic waveform is collected and stored in the designated RAM space for future use through the DMA function of the MCU. The auxiliary circuit is connected to the zero-crossing comparison circuit, and the zero-crossing point information of the ultrasonic signal is converted into a square wave through the comparator, and the square wave is connected to the timer input capture port of the MCU to detect the zero-crossing moment; The use of ADC sampling and zero-crossing comparator to perform threshold calculation and zero-crossing calculation to determine the ultrasonic transit time is specifically: ① Start the DMA controller and ADC to collect ultrasonic waveforms and store them in RAM. At the same time, the zero-crossing comparator generates a zero-crossing comparison pulse and connects it to the timer input capture port of the MCU. ②Search for the local peak values ​​P1~Pn and the corresponding time of the rising edge of the waveform, which are recorded as Vp(i) and Tp(i) respectively; where n is the number of peaks in the rising edge stage of the waveform; i is the number of peaks, with a value of 1~n; ③ According to the maximum peak amplitude Vp_max, set the dynamic threshold K, K = a*Vp_max, where a is the threshold coefficient; ④ Traverse and search the ultrasonic waveform in RAM, and record the characteristic time interval [Tp(3), Tp(4)] where it first intersects with the comparison threshold K, recorded as [T_L, T_H]; ⑤ Taking the T_L moment of the previous cycle as the reference, generate a high-level signal lasting 50us as the timer input capture enable signal, measure the falling edge time of the zero-crossing detection pulse, and obtain multiple zero-crossing times, recorded as T0[n]; ⑥ Search for the zero-crossing time in T0[n] that is within the time range [T_L, T_H], record it as T0', and then subtract the fixed delay τ to obtain the accurate transit time Tof, Tof = T0'-τ.