Improved Measurement Accuracy Based on Moving Sine-Wave Fitting for Ultrasonic Ranging

In ultrasonic ranging system, the time-of-ﬂight (TOF), which acquired by the determination of two special points of ultrasonic echo, is important for accuracy and speed. The published calculation of TOF processing methods is too enormous to aﬀect the real-time performance. To improve its measurement accuracy and speed, we proposed a new algorithm called “moving sine-wave ﬁtting” to calculate the envelope of ultrasonic echo for each calibration point. Then, the absolute feature point (AFP) corresponding to half of the envelope peak can be deﬁned and used to ﬁnd out the relative feature point (RFP); the linear relationship between the RFPs and the known distances should be obtained referring to calibration points. At last, the distance on the measure can be acquired by using linear interpolation according to the above relationship. The measurement experiments have been performed on a set of distances, which shows a good measurement resolution that the overall measurement accuracy is 0.513mm, and the linear correlation coeﬃcient between the RFPs and the obtained distances is R 2 �


Introduction
As its advantages of nondestructive and rapidity, ultrasonic ranging has been widely used in architecture, metal industry, automobile reverse anticollision systems [1][2][3][4], and so on. Its basis is analyzing the variation of phase or time-of-flight (TOF) between the transmitted and reflected ultrasonic wave from the object in the ultrasonic distance measuring system [5,6]. e former method based on phase analysis requires a whole period of sampling for Fourier transform and is not suitable for real-time measurement. In comparison, the latter one TOF-based is easy and simple to handle [7,8], which can be classified as variable threshold detection and cross-correlation function method [9][10][11]. e working principle of the TOF method is to calculate the duration of propagation of the ultrasonic signal between the transmitter and the receiver. Since the energy of the ultrasonic signal wave is extremely weakened during transmission, the signal-to-noise ratio (SNR) of the echo signal is low. erefore, accurately locating the position of the echo signal is significant for the ultrasonic signal processing of the measurement. A number of scholars have deeply researched in this area and proposed many signal processing methods.
Considering the measurement accuracy of distance largely depends on the quality of the determined TOF, aiming at these problems above, Wu et al. [12] proposed a method easy to implement in hardware; however, it shows a good measurement result only if the signal-to-noise ratio (SNR) is relatively low. Liang et al. [13] and Brassier et al. [14] proposed to extract the stable feature of points located in echo signals based on cross-correlation algorithm, but it needs large computation and also cannot work in real time.
Recently, data envelopment analysis (DEA) has been introduced to calculate TOF by extracting the feature points of echo signals. For example, Angrisani et al. [15] gave a model based on unscented Kalman filtering to estimate TOF by the start and end time of the envelope. Although it can provide a wealth of information, the measurement accuracy and range are unsatisfactory due to the starting point of the echo signal being regarded as the feature position, and the small amplitude of starting point will be disturbed by noise.
In this paper, we propose to improve the measurement accuracy of TOF based on moving sine-wave fitting (MSWF) and linear interpolation algorithm. Figure 1 shows the echo signals of known distance, the half-peak point of the envelope curve is defined as the absolute feature point (AFP), and a peak point near the AFP is expressed as the relative feature point (RFP). e mathematical relationship between the distance l and the sampling sequence of RFP can be established, which converts the distance measurement to the calculation of RFP's sampling sequence value, thus making the measurement result more noise-resistant and accurate. Owing to the limitation of sampling frequency and noise jamming, average values of repeated measurements at the same distance are used to eliminate random error. e RFP's sampling sequence can be calculated using the average one of AFP and the average feature offset (FO) [16]. In the ranging process, the AFP is obtained from the envelope curve which is calculated by the MSWF algorithm. e FO, computed by the linear interpolation with AFP, is applied to the calculation of the RFP's position. After the final compensation of phase method, the accurate distance can be obtained by the mathematic relation between the RFP's sampling sequence and the distance. is method combines both the high accuracy advantage of phase detection and the absolute measurement advantage of TOF [12][13][14][15][16][17].

Echo Envelope Calculation Using Moving Sine-Wave
Fitting Algorithm. In the ultrasonic ranging, the echo signal reflected from an object is a modulated sine-wave [18], hence the measurement data Y with interval Δ � 2π/n and length N can be fit recursively according to the moving sine-wave fitting algorithm.
For measurement data, Y k � {y k , y k+1 , y k+2 , . . ., y k+n } in data Y, the amplitude of the sample data can be considered as constant within one cycle. erefore, the formulation of the Y k can be expressed as where A k , θ k , c k, and ε i represent the amplitude, the phase angle, the offset, and the random error, respectively. Obviously, equation (1) can be also be rewritten as where parameters a and b satisfied the following constraint condition as e problem to calculate the echo envelope, therefore, is converted to determine a and b, and they can be obtained by using the least square method as e optimal solution in the fitting problem can be obtained at the extreme point in the function of the right part in equation (4). Hence, by taking the partial derivative on a k , b k , and c k , we can obtain where the transmission matrix S and T can be expressed as Once the parameters a k , b k , and c k are calculated, the formulation of the measurement data in one cycle are determined, and by moving the measurement data from y 1 to y N−n+1 , all the expression curves of the measurement data can be represented, as shown in Figure 2.
In order to reduce the amount of calculation in the fitting process, the parameters a k and b k are calculated recursively with the moving sine-wave fitting algorithm, since the transmission matrix S k of the Y k can be described as en, the transmission matrix S k+1 of the Y k+1 can be formulated as follows: According to the proposed method, all the measurement data and amplitude A 2 , A 3 , . . ., A N , of the echo can be obtained reclusively once the Y 1 is calculated. erefore, the proposed method can be well applied to avoid the redundant calculation, and the echo envelop is obtained once all the amplitude is determined.

2
Shock and Vibration

Determination of the Relationship between RFPs and
Distances. Generally, there is the fluctuation of the echo signal in any position, and the range of fluctuation can be as large as one sampling interval. erefore, the position of AFP should be located at the half of the peak with the largest inclined rate point, which gets the closest fluctuation range in the X-axis. From the calculated amplitudes of echo envelope including A 1 , A 2 , . . ., A n , the half of peak A max is determined as AFP, whose sampling sequence is denoted by M.
Because the sampling sequence of AFP is easily disturbed by random noise or the other echo, for a given group of calibrated distances L � {l 1 , l 2 , . . ., l j , l j+1 , . . ., l N } with the same step of ∆l, the sampling sequences M � {M 1 , M 2 , . . ., M j , . . .,M N } corresponding AFPs can be determined. When the RFP 1 of l 1 is selected as the value nearest AFP 1 in echo, the next RFP 2 will move a distance ∆x � ∆l · f/ v (f and v are the sampling frequency and ultrasonic velocity, respectively) and also locate in a specific peak theoretically. en, the sampling sequences M R � {M R1 , M R2 , . . ., M Rj , . . ., M RN } of RFPs are linear related to the distance on the measure, which can be calculated according to the above rule.
If the calculated RFP of the distance on measure does not coincide with a peak located in echo, equation (9) based on linear interpolation is utilized to acquire the feature offset F Ox , which equals to the difference between the sampling sequence of RFP and AFP, as shown in Figure 3.
where M x denotes the sampling sequence for the distance on measure. Further, wrapped phases of echo are analyzed to improve the accuracy of measurement distance, whose description is expressed as where a i and b i are the coefficients of the sine and cosine waves described in equation (2), respectively, as shown in Figure 4. In the last, the sampling sequence M Rx of RFP corresponding to the distance on the measure can be obtained by where θ c is calculated by equation (10), c � M x + F ox , f is the sampling frequency, and F is the transmitted frequency of ultrasound.

Experiments and Result Analysis
e sketch of the ultrasonic ranging system applied here is shown in Figure 5. A signal N sig . with the frequency of 1 Hz is generated to control MCU A and B simultaneously, and then a square wave containing eight pulses with the frequency of 40 kHz is excited from the transducer Tx. By sampling the echo signal with the frequency of 1 MHz, the distance between two transducers can be successfully calculated.
In order to determine the distance effectively, a calibration process is conducted to define the formulation between the distance and the sample sequence. Measurement is performed at every 5 mm and distance group l � {l 1 , l 2 , l 3 , . . ., l 25 } is recorded correspondingly. Hence, according to the proposed model which shows the relationship between M ex and l x , the distance measurement can be easily obtained by linear interpolation.

Shock and Vibration
During the experiment, the sound velocity is assumed as 346 m/s under a temperature of 25.7°C, and ∆x is about 15. In order to reduce the interference of noise, the AFP and RFP sequences are averaged with ten measurements, as shown in Table 1.
e relationship between the feature offset (FO) and the AFP's sample sequence is shown in Figure 6. It can be seen from Figure 6 that the FO obtained in each measurement does not exceed two ultrasonic cycles, namely, the RFP will not be too far from the AFP. Meanwhile, an obvious relationship between the FO and the AFP's sampling sequence value can be perceived with the similar correspondence at each measurement, so the average measurement data in Figure 6 can be used as the sample of the linear interpolation. Furthermore, a good reproducibility can be verified from the consistent figures.
Substituting the sampling sequence value of the randomly measured 48 AFP (M) into equation (11) to calculate the RFP's compensation value M R , the RFP-distance relationship and the AFP-distance relationship can be established, which is presented in Figure 7.
As shown in Figure 7, the linear correlation coefficient (LCC) between M R and the distance is 0.806, and the LCC between the M and the distance is 0.682. Besides, though the sampling sequences of both the AFP and the RFP overlap at some specific distance, the higher LCC can be reached at the RFP sampling sequence. e result proves that the RFP's sampling sequence value is much closer to the actual distance and verifies the proposed method effectively.      By fitting the curve in Figure 7, the equation between the standard distance and the RFP's sampling sequence value can be expressed as erefore, the distance l n can be easily calculated once the RFP sampling sequences are determined. Compared with the standard distance measured by the grating ruler l s , the distance error can be represented as Δl � l n − l s , and the error distribution of 48 random RFP sampling sequences is shown in Figure 8 in percentage form. e results measured using RFP are significantly better than those using AFP. In addition, the error fluctuation of the measurement system is random, and the standard deviation of the results of the 48 groups measured using RFP is δ � 0.171 mm. According to the 3δ evaluation principle, the measurement accuracy of this method is ±3δ � 0.513 mm. By contrast, the standard  Shock and Vibration deviation of the distance error obtained by fitting the AFP's sampling sequence value (M) with standard distance is 0.387 mm and the measurement accuracy is 1.161 mm. erefore, the measurement accuracy is improved by 55.8% within our proposed method, and a great potential advantage is discovered in the application of high-precision ultrasonic measurement.

Conclusions
In this work, we proposed MSWF to extract the envelope curves rapidly from echo signals without iteration. en, the AFP was described as half-peak point in the ultrasonic ranging TOF based, which can be determined in the measurements, and the F Ox is interpolated from AFP and the feature offsets on the known distances obtained ahead during the calibration test. en, the RFP can be located quickly, and we readjusted the position of RFP applying phase analysis further. When the measurement distance is within 50 mm∼170 mm, the measurement accuracy is 0.513 mm, and the LCC is 0.806. Experiments show that the localization method of RFP has the capability of noise suppression and the ranging method has higher accuracy and application potential [19][20][21].

Data Availability
e data used to support the findings of this study have been deposited in the UltrasonicData repository (https://github. com/XBCMZ-kaka/UltrasonicData).

Conflicts of Interest
e authors declare that they have no conflicts of interest.  Shock and Vibration