Disclosure of Invention
Aiming at the defects of the prior art, the invention provides an ultrasonic echo signal characteristic peak identification method based on an adaptive threshold.
The invention mainly comprises the following steps:
the method comprises the following steps: and filtering and amplifying the echo signal received by the transducer, and then obtaining a peak voltage signal of the echo signal by using a peak detection circuit. And selecting m pieces of echo data with the maximum peak value closest to the set target amplitude as a reference for processing the echo signal data. Setting an initial threshold Th according to the m echo signals0。
Step two: and identifying the steps of the echo peak signals. The maximum value of the echo peak signal is selected, and then the voltage of each peak step is determined. And setting a resolution D, namely considering that two sampling points are on the same peak step when the difference between the amplitudes of two adjacent sampling points is less than the resolution D, and considering that the next peak step appears when the difference between the amplitudes of two adjacent sampling points is greater than the resolution. Obtaining a step array A ═ A from the peak step identification result1,A2…Ak]. Where k represents the corresponding peak step total, where A1Is the first peak step, AkThe peak step maximum. By dividing each element in array A by AkObtaining a ratio array R ═ R1,R2…1]。
On one hand, the threshold selection selects two peak steps with the largest amplitude difference from all the peak steps and takes the midpoint of the voltage values of the peak steps as a threshold, so that the fault tolerance of the threshold selection is improved; on the other hand, the threshold value is close to the reference zero crossing point of the echo as much as possible, and the influence of overall amplitude fluctuation is reduced.
Step three: storing N echo signals according to the first-in first-out principle to obtain N step arrays Ai=[A1i,A2i,…,Aki],i∈[1,N]K is the total number of peak steps of the echo signal; obtaining N proportional arrays R simultaneouslyi=[R1i,R2i,…,1],i∈[1,N]Wherein R is1i、R2i、R3iAre respectively the ithThe ratio of the first peak step to the maximum peak value, the ratio of the second peak step to the maximum peak value and the ratio of the third peak step to the maximum peak value of the echo. Thereby obtaining the voltage average value of the peak stepj∈[1,k]:
Simultaneously obtaining the proportional average value of each peak step
Comparing the step arrays of the currently acquired echoes according to the sequence to obtain a first element A larger than a threshold valuep,p∈[1,k]。
When p is 1 and judged to obtain
If the first peak step is lost, get
As the first peak step.
When p is 2, the first peak step is considered to be successfully identified.
Taking the median of the first peak step and the second peak step of the collected echo as a threshold, and obtaining the self-adaptive threshold as follows:
and continuously updating and storing the echo signal array by a first-in first-out principle, so that the threshold can be adaptively adjusted according to the actual echo signal to obtain the optimal value of the real-time threshold.
Furthermore, the method also comprises the steps of carrying out wave hopping identification on the echo data after the first peak step identification and compensation, and setting R1(N+1)、R2(N+1)、R3(N+1)Respectively representing the ratio of the first, second and third peak steps of the currently measured echo signal to the maximum peak step.
When in use
And when the current threshold value is between the first peak value step and the second peak value step, no wave jump exists.
When in use
And then, if the current threshold value is between the first peak step and the reference step, the zero crossing point is moved forward by one period, and the zero crossing point is delayed backward by one period to be used as the real echo reaching time.
When in use
And when the current threshold value is between the second peak value step and the third peak value step, the zero crossing point is delayed by one period as a whole, and the previous period of the zero crossing point is taken as the real echo arrival time.
Compared with the prior art, the invention adopts an ultrasonic echo signal characteristic peak identification method of self-adaptive threshold value, and sets the threshold value according to the identified characteristic wave peak value. The self-adaptive threshold value can be adjusted according to the change of the amplitude of the echo signal, and can be adjusted in real time when the characteristic peak of the current echo signal changes, so that the self-adaptive threshold value has stronger adaptability compared with a fixed threshold value method.
Detailed Description
The present invention is described in further detail below with reference to the attached drawing figures.
The circuit principle of the ultrasonic flowmeter used in the present embodiment is shown in fig. 1, and is mainly composed of 8 parts: the device comprises a singlechip, a switch switching circuit, a transducer (A, B), an echo signal preprocessing circuit, a zero-crossing detection circuit, a peak detection circuit and a signal acquisition module. The echo signal processing circuit plays a role in filtering and amplifying the ultrasonic echo signal.
Fig. 2 is a flow chart of a method for identifying a characteristic peak of an ultrasonic echo signal based on an adaptive threshold, and the method comprises the following steps:
the method comprises the following steps: the echo signal received by the transducer is filtered and amplified, and then a peak voltage signal of the echo signal is obtained by using a peak detection circuit, as shown in fig. 3, the original echo signal and the peak step in this embodiment are obtained. And selecting m pieces of echo data with the maximum peak value closest to the set target amplitude as a reference for processing the echo signal data. In this embodiment, the number m of echo signal data stored is 100, and the initial threshold Th is set through experimental observation0=1.65V。
Step two: and step identification of the echo peak signal, namely selecting the maximum value of the echo peak signal, and determining the voltage of each peak step according to the voltage value of the peak step. The resolution D is set, as can be seen from the peak voltage amplitude diagram in fig. 4, the fluctuation range of the peak voltage amplitude in this embodiment is 0.02V, and therefore the resolution D is set to 0.03V, that is, when the difference between the amplitudes of two adjacent sampling points is smaller than the resolution D, two sampling points are considered to be on the same peak step, otherwise, when the difference between the amplitudes of two adjacent sampling points is larger than the resolution, the next peak step is considered to occur.
Obtaining a step array A ═ A from the peak step identification result1,A2…Ak]. Where k represents the corresponding peak step total number, whichIn A1Is the first peak step, AkThe peak step maximum. By dividing each element in array A by AkObtaining a ratio array R ═ R1,R2…1]。
On one hand, the threshold selection selects two peak steps with the largest amplitude difference from all the peak steps and takes the midpoint of the voltage values of the peak steps as a threshold, so that the fault tolerance of the threshold selection is improved; on the other hand, the threshold value is close to the reference zero crossing point of the echo as much as possible, and the influence of overall amplitude fluctuation is reduced.
Step three: storing N echo signals according to the first-in first-out principle, in this embodiment, taking N to 10, and obtaining 10 step arrays Ai=[A1i,A2i,…,Aki],i∈[1,10]K is the total number of peak steps of the echo signal; obtain 10 proportional arrays R simultaneouslyi=[R1i,R2i,…,1],i∈[1,10]Wherein R is1i、R2i、R3iThe ratio of the first peak step to the maximum peak value, the ratio of the second peak step to the maximum peak value and the ratio of the third peak step to the maximum peak value of the ith echo are respectively. Thereby obtaining the average voltage value of each peak stepj∈[1,k]:
Simultaneously obtaining the proportional average value of each peak step
Comparing the step arrays of the currently acquired echoes according to the sequence to obtain a first element A larger than a threshold valuep,p∈[1,k]。
When p is 1 and judged to obtain
If the first peak step is lost, get
As the first peak step.
When p is 2, the first peak step is considered to be successfully identified.
Taking the median of the first peak step and the second peak step of the collected echo as a threshold, and obtaining the self-adaptive threshold as follows:
and continuously updating and storing the echo signal array by a first-in first-out principle, so that the threshold can be adaptively adjusted according to the actual echo signal to obtain the optimal value of the real-time threshold.
Step four: performing wave hopping identification on the echo data subjected to first peak step identification and compensation, and setting R1(N+1)、R2(N+1)、R3(N+1)Respectively representing the ratio of the first, second and third peak steps of the currently measured echo signal to the maximum peak step.
When in use
And when the current threshold value is between the first peak value step and the second peak value step, no wave jump exists.
When in use
And then, if the current threshold value is between the first peak step and the reference step, the zero crossing point is moved forward by one period, and the zero crossing point is delayed backward by one period to be used as the real echo reaching time.
When in use
Then the current threshold value is between the second peak value step and the third peak value step, and the zero crossing point can be integrally delayedAnd in the latter period, taking the previous period from the zero-crossing point as the real echo arrival time.
The time measuring module in the embodiment adopts DTC-GP22, and can simultaneously measure 3 continuous echo periods in the process of calculating the arrival time of the ultrasonic echo signal; three zero-crossing points t can be obtained according to the hopping data processing schematic diagram of FIG. 51、t2、t3When there is no beat, i.e., when the threshold value is 2, t is2For echo arrival time, t0=(t1+t2+t3) (iii)/3 as echo arrival time to improve the stability of the measurement;
when the threshold 1 condition occurs, t is set3As the true echo arrival time;
when the threshold 3 condition occurs, then t will be1As the true echo arrival time.