University of West Bohemia in Pilsen Department of Computer Science and Engineering Univerzitni 8 30614 Pilsen Czech Republic Short Time Delay Measurement Ing. Karel Dudáček Technical Report No. DCSE/TR-2015-03 July, 2015 Distribution: public Technical Report No. DCSE/TR-2015-03 July 2015 Short Time Delay Measurement Ing. Karel Dudáček Abstract This paper describes the state of the art of the short time delay measurement and proposes new method for the delay measurement. A brief introduction to the delay measurement and the problem specification are in the first two chapters. Chapter 3 presents the state of the art of the delay measurement. In the next chapter, the evaluation and comparison of selected delay measurement methods are presented. Also the problems of using these methods are described in this chapter. Chapter 5 describes the new method for decreasing the number of the samples necessary for the time delay measurement. Chapter 6 brings a description of the further work and the goals of the Ph.D. thesis. This work has been supported by the UWB grant SGS–2013–029 Advanced Computer and Information Systems and by the European Regional Development Fund (ERDF) — project NTIS (New Technologies for Information Society), European Centre of Excellence, CZ.1.05/1.1.00/0.2.0090.. Copies of this report are available on http://www.kiv.zcu.cz/publications/ or by surface mail on request sent to the following address: University of West Bohemia in Pilsen Department of Computer Science and Engineering Univerzitni 8 30614 Pilsen Czech Republic c Copyright 2015 University of West Bohemia in Pilsen, Czech Republic Contents 1 Introduction 5 2 Problem specification 2.1 Signal features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2 Properties of the measurement . . . . . . . . . . . . . . . . . . . . . . . . . . 6 6 6 3 State of the art of delay measurement methods 3.1 Basic time delay measurement methods . . . . . . . . . . . . . . . . . . 3.1.1 Cross-correlation method . . . . . . . . . . . . . . . . . . . . . . 3.1.2 Pulse counting method . . . . . . . . . . . . . . . . . . . . . . . . 3.1.3 Phase shift method . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1.4 Delay line method . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 Various measurement methods described in the literature . . . . . . . . 3.2.1 Using a harmonic reference clock for the pulse counting method . 3.2.2 Edge transformation using a SAW filter . . . . . . . . . . . . . . 3.2.3 Dividing delay line into coarse and fine blocks . . . . . . . . . . . 3.2.4 Multichannel cross-correlation . . . . . . . . . . . . . . . . . . . 3.2.5 Interpolation methods for the cross-correlation method . . . . . 3.2.6 Design of an optimal filter for the cross-correlation method . . . 3.2.7 Time delay estimation based on SINC filtering . . . . . . . . . . 3.2.8 Signal filtering using an auto-adjusting Wiener filter . . . . . . . 3.2.9 Cross-wavelet transformation . . . . . . . . . . . . . . . . . . . . 3.2.10 Third order cumulant method . . . . . . . . . . . . . . . . . . . . 3.2.11 Bispectrum method . . . . . . . . . . . . . . . . . . . . . . . . . 3.3 Summary of the methods. . . . . . . . . . . . . . . . . . . . . . . . . . . 3.4 Methods based on cross-correlation . . . . . . . . . . . . . . . . . . . . . 3.4.1 Continuous time cross-correlation method . . . . . . . . . . . . . 3.4.2 Discrete time cross-correlation method . . . . . . . . . . . . . . . 3.4.3 Cross-correlation of the harmonic functions . . . . . . . . . . . . 3.4.4 Computation complexity of the cross-correlation method . . . . . 3.4.5 Maxima detection . . . . . . . . . . . . . . . . . . . . . . . . . . 3.5 Summary of Chapter 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Experimental evaluation of methods 4.1 Description and evaluation of the methods . . . . . . 4.1.1 Interpolation followed by correlation . . . . . 4.1.2 Approximation of the correlation function . . 4.1.3 Signal approximation using the least squares evaluation . . . . . . . . . . . . . . . . . . . . 4.1.4 Phase shift methods . . . . . . . . . . . . . . 4.2 Methods comparison . . . . . . . . . . . . . . . . . . 4.3 Summary of the evaluation . . . . . . . . . . . . . . 3 . . . . . . . . . . . . . . . method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . and statistical . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 8 8 9 9 9 10 10 10 10 11 11 11 11 12 12 12 12 13 14 14 15 15 17 17 18 19 19 20 20 22 24 25 31 4 CONTENTS 5 Nonuniform sampling for sampling frequency reduction 5.1 Difficulties when using the Fourier transform for signals time 5.2 Non-uniform sampling . . . . . . . . . . . . . . . . . . . . . 5.2.1 Latent sampling frequency . . . . . . . . . . . . . . . 5.2.2 Sampling points . . . . . . . . . . . . . . . . . . . . 5.3 Non-uniform Fourier Transform . . . . . . . . . . . . . . . . 5.4 Experimental evaluation of the NDFT method . . . . . . . shift . . . . . . . . . . . . . . . measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 32 32 33 33 34 35 6 Goals of the Ph.D. thesis and further work 6.1 Goals of the Ph.D. thesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.2 Objectives to be met . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.3 Further work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 39 39 40 7 Conclusion 41 Chapter 1 Introduction In many applications, precise measurement of short delays between analogue signals is required. A number of methods were developed for this purpose, supposing measurement of signals with sharp edges. However if the signal has no sharp edge, it is common to use some of the analogue methods which are based on various principles. Usage of analogue measurement methods requires highly precise production and calibration of each manufactured piece. More recently, there has been a great tendency towards digital signal processing making product development faster and production cheaper. This work compares existing measurement methods and suggests a new method. 5 Chapter 2 Problem specification In many applications, e.g. radar and sonar sensors, laser range-finders etc., it is necessary to measure the delay between two pulses. These devices use signals with a high propagation speed for measurement in shorter and shorter ranges, thus the delay between transmitted impulse and received echo is decreasing. This results in more stringent requirements for precision of time delay measurement between analogue signals. This chapter describes typical features of processed signals and requirements for precision of the measurement methods. 2.1 Signal features Suppose we have acquired two signals (signal pair). Suppose this signal pair has the following features: • Signals appear in bursts of finite waveform length, • both waveforms in the pair have a similar envelope shape, but are time-shifted by ∆t, • bursts are non-periodic (each burst is unique), • signals in the burst are harmonically oscillating at unknown frequency fp , • the analytical description of the signal envelope is not known. The above-described signal may be obtained from some sort of sensors, for example from ultrasonic detectors. An example of such a waveform can be seen in Figure 2.1. 2.2 Properties of the measurement Suppose the above-described signal pair is acquired in some appliance regardless of whether it is radar, a laser range-finder or something else. The basic principle of many devices is a measurement of the time shift ∆t between the two waveforms in the signal pair with high precision. The measured time shift is usually very short (∆t ≈ 10−6 ÷ 10−11 s). In many applications, very fine measurement resolution (in the order of 10ps) is required. Simple correlation methods commonly used for such measurements have a resolution equal to the sampling period. To achieve the required resolution of 10ps, the sampling frequencies would be unattainably high (100Gs · s−1 ). Thus more advanced methods must be used. Summary of the properties of the measurement: • Ability to measure very short time delays (∆t ≈ 10−6 ÷ 10−11 s). • Measurement resolution in the order of 10 ps. • High accuracy of measurement (error in the order of 0.1%). 6 7 CHAPTER 2. PROBLEM SPECIFICATION 2.5 μs Figure 2.1: Waveform example. An example of a signal pair recorded on an ultrasonic flowmeter prototype. The time shift is hard to notice because ∆t ≈ 0.01 · fp−1 . Chapter 3 State of the art of delay measurement methods The problem of the short time delay measurement is very old. Thus many measurement methods were developed in the past. The first methods were fully analogue. Then came methods using analogue preprocessing for digital measurement. In recent years, there is a great tendency to use fully digital signal processing. This chapter describes the state of the art of the delay measurement methods focusing on the digital methods. 3.1 Basic time delay measurement methods A few basic measurement methods exist for time delay measurement. These methods are easy to use but they are unsuitable for many applications. Basic delay measurement methods are: • the cross-correlation method, • the pulse counting method, • the phase shift method, • the delay line method. In this section, there is a brief description of these basic methods. 3.1.1 Cross-correlation method A common method for signal delay computation is finding the maximum of their cross-correlation function (3.1). This maximum corresponds to the time shift with the best similarity between signals. X Rxy (k) = x(m) · y(k + m) m (3.1) Lxy (k) = k Each point of cross-correlation function Rxy (k) is a dot product of discrete signals x(m) and y(m) mutually shifted by k samples. Time shift k is known as a lag; dependence of lag k on time (sample number) is linear increasing function Lxy (k). The distance between samples is sampling period Ts = fs−1 , where fs is sampling frequency. The distance between points in the cross-correlation function is also Ts . This means 8 CHAPTER 3. STATE OF THE ART OF DELAY MEASUREMENT METHODS 9 that maximal resolution of this method is equal to the sampling period Ts . Many applications need resolution that corresponds to very high sampling frequencies (10Gs/s). In these applications, this method is not usable without modifications providing finer resolution. 3.1.2 Pulse counting method The second basic time shift measurement method is the pulse counting method. A reference clock generator produces pulses with period Tr . These pulses are routed to the counter. When the first event (e.g. signal transition on signal x) occurs, the counter starts counting reference pulses; when the second event occurs (e.g. transition on signal y), the counter stops counting. The delay between events is ∆t = n · Tr , where n is the counter value. Maximal measurement error is Emax = 2 · Tr , mean error is E = Tr . 3.1.3 Phase shift method Let us consider a pair of discrete (attenuated) harmonic signals x(t) and y(t). Both signals have frequency fp . If phase shift ∆ϕ is known, it is possible to compute time shift ∆t of waveforms using (3.2). ∆ϕ ∆ϕ = (3.2) ∆t = ωp 2 · π · fp The phase shift and frequency fp can be easily computed using the discrete Fourier transform. The phase shift computed using D E the Fourier transform is in range < −π, +π >; the time shift 1 1 is then in range − 2·fp , + 2·fp . When using this method, frequency fp of the signal must be found. It is possible to use a priori knowledge of the frequency or determine the frequency from the signal spectra. When the ratio of sampling frequency fs and signal frequency fp is not an integer (3.3), no point in the discrete spectra corresponds to the frequency of the signal, but more points are influenced by this frequency. fs = k · fp ; k ∈ N (3.3) 3.1.4 Delay line method Usage of a delay line is another basic delay measurement method. This method is suitable only for signals with edges or similar synchronization points. One signal is connected to the input of the delay line, the other signal is used as a clock signal for memory elements (e.g. flip-flops). When an event occurs on the first signal, it propagates along the delay line. Propagation is delayed in each element by its propagation delay. When an event occurs on the second signal, it triggers memory elements capturing a state of the delay elements, i.e. the position of the first event can be found. The time difference between events can be computed from events positions and the propagation delay of delay elements. The basic delay line concept can be seen in the Figure 3.1. 10 CHAPTER 3. STATE OF THE ART OF DELAY MEASUREMENT METHODS 1. Event x propagates along the delay line. event delay x 0 tPD event delay tPD D C y 1 Q tPD event delay tPD D C Q 2 tPD event delay tPD D C 3 event delay tPD tPD Q D C Q 4 tPD D C Q 2. Event y triggers memory elements capturing state of the delay line. 3. Captured state of the delay line is routed to the outputs. outputs Figure 3.1: Basic delay line concept. An event on signal x propagates along the delay line; an event on signal y triggers memory elements (D flip–flops) and captures a state of the delay line. 3.2 Various measurement methods described in the literature In the literature, many methods for measurement of the time shift of signals are described. In this section, there is a brief description of these methods. 3.2.1 Using a harmonic reference clock for the pulse counting method Paper [1], describes a method for increasing the precision of the pulse counting method using a harmonic reference clock signal instead of a rectangular clock signal. For a coarse measurement of the time interval between two events, counting reference clock pulses (periods of sinus) is used. The distance between the start event and the first pulse (and between the last pulse and the stop event) is estimated using measurement of a phase of the reference clock at the moment of the event. This means that delay measurement precision is in fractions of the reference clock period. 3.2.2 Edge transformation using a SAW filter Paper [2] describes a method for time measurement using a transversal surface acoustic wave (SAW) filter. When signals are sampled, it is problematic to measure the precise position of sharp narrow peaks or transitions because of the sampling theorem (a sharp edge has an infinite spectrum; thus sampling frequency must also be infinite — practically, it means very high). The authors of this paper used a SAW filter for transformation of the sharp edge into finite deterministic oscillations. A SAW filter’s oscillations have a narrow spectral line at a known fixed frequency; thus waveforms can be easily sampled and reconstructed from the samples. Due to the known behaviour of the SAW filter, the time of arrival of the excitation pulses can be computed. 3.2.3 Dividing delay line into coarse and fine blocks The authors of paper [3] presented an improved delay line method for measurement of onchip signal delays. According to the paper, it is a problem to produce a long on-chip delay line with high precision. The method presented in the paper divides the delay line into CHAPTER 3. STATE OF THE ART OF DELAY MEASUREMENT METHODS 11 a coarse block and a fine block. When the signal pair arrives, it is routed to the coarse block. In the coarse block, a coarse delay (tC ) between signals as c multiples of coarse block elements’ delay TC is measured. The delay between signals is also reduced by tC in the coarse block. From the coarse block the signals are routed into the fine block. In the fine block, a fine delay (tF ) between signals as f multiples of fine block elements’ delay TF is measured. The measured delay between signals is computed as a sum of fine and coarse delay ∆t = tC + tF = c · TC + f · TF . The values c and f are integers not greater than the number of delay elements in the appropriate block. 3.2.4 Multichannel cross-correlation Paper [4] introduces an improvement of the cross-correlation method . The time resolution of the basic cross-correlation method is equal to the sampling period Ts . The authors of this paper increased the resolution of the method to Ts /N where N is a small integer. One of the signals (x) in the pair is directly sampled, the other signal (y) is routed to an analogue delay line with N − 1 stages. The delay of each stage is Ts /N . The original signal and outputs of all stages are sampled giving N delayed waveforms yn where n is the number of delay stages in the path (n = 0, 1, . . . , N − 1). Time shifts ∆tn are computed using the c correlation method. Linear approximation function ∆t(n) is fitted using the least squares c method and final time shift ∆t is computed as ∆t(0). 3.2.5 Interpolation methods for the cross-correlation method Paper [5] describes four interpolation methods for resolution improvement of the cross-correlation method . In the article, following interpolation methods are described: • Parabolic fitting with bias compensation. • Parabolic-fit interpolation combined with linear filter interpolation. • Parabolic interpolation to the complex correlation function envelope. • Matched filtering for interpolation. 3.2.6 Design of an optimal filter for the cross-correlation method The authors of paper [6] derived an optimal filter for use in cross-correlators. They derived a mathematical model of cross-correlator for measurement of the time shift between two signals in a noisy environment. According to the model, two optimization criteria were found: • The ratio between the cross-correlation function peak and background noise must be maximized at a position (lag) corresponding to the time shift of the signals. • The mean-square difference between the original signal (signal before addition of noise) and the filtered signal must be minimized. Using these two criteria, the paper’s authors derived an optimal filter for filtering the crosscorrelation function in order to minimize the influence of the noise on the peak detector. 3.2.7 Time delay estimation based on SINC filtering Papers [7] and [8], describe a method for time delay estimation using a sinc function coefficients estimation. P The papers describe the relation between two delayed signals xk and yk as a function yk = xk−n · sinc(n + m + a). The authors have shown that the delay between signals is equal to the peak position (in time axis) of the sinc function. According to paper [7], this peak position can be estimated using an LMS adaptive algorithm. CHAPTER 3. STATE OF THE ART OF DELAY MEASUREMENT METHODS 3.2.8 12 Signal filtering using an auto-adjusting Wiener filter The authors of paper [9] used a Wiener filter for reconstruction of a noisy signal from an ultrasonic receiver. For adjusting the Wiener filter, it is necessary to the know system’s impulse response and the power spectra of the signal and noise. The authors of the paper used the part of the received signal with high amplitude for measurement of the signal parameters and the part of the signal with low amplitude for measurement of noise parameters. The impulse response of the system is obtained from the transmitter—receiver acoustic crosstalk. 3.2.9 Cross-wavelet transformation The method described in paper [10] uses wavelet and cross-wavelet transforms for time shift computation. Received signals x(s, τ ) and y(s, τ ) are transformed from the time domain into the wavelet domain using wavelet transform ψ giving their wavelet domain images Xψ (s, τ ) and Yψ (s, τ ). In the wavelet domain the image of their cross-wavelet function Cψ = Xψ · Yψ∗ is computed. The cross-wavelet function is transformed back to the time domain (i.e. we get c(s, τ )) and its maximum cmax (smax , τmax ) is found. The time shift between signals corresponds to τmax and the ratio between amplitudes of signals corresponds to smax . 3.2.10 Third order cumulant method Paper [11], describes two time delay computation methods: the Third order cumulant method and the Bispectrum method 1 . The third cumulant of the normal distribution is zero. The third order cumulant method computes third order cumulant Cxxx (m1 , m2 ) of signal x(t) and cross-cumulant Cxxx (m1 , m2 ) of signals x(t) and y(t) = x(t − τ ) (i.e. τ is the time shift between signals). These cumulants do not contain white Gaussian noise. Then the cumulants are sliced at m2 = 0 and the cross-correlation of the slices is computed R(m1 ) = xcorr{Cxxx (m1 , 0), Cxyx (m1 , 0)}. The maximum of the cross-correlation function is at the position m1 = τ , i.e. max{R(m1 )} = R(τ ). 3.2.11 Bispectrum method The Bispectrum method is the second method described in paper [11]. The bispectrum is the Fourier transform of the third order cumulant (it suppresses white noise). According to this paper, the bispectra Bxxx (ω1 , ω2 ) = FFT {Cxxx (m1 , m2 )} and RR Bxyx (ω1 , ω2 ) = FFT {Cxyx (m1 , m2 )} are computed. From these bispectra function T (t) = (Bxyx /Bxxx ) dω1 dω2 is computed, having its peak at position t = τ (signals’ time shift). 1 The bispectrum method is described in subsection 3.2.11. CHAPTER 3. STATE OF THE ART OF DELAY MEASUREMENT METHODS 3.3 13 Summary of the methods. The previous two sections briefly describe various time delay estimation methods whether well–known or described in literature. These methods can be divided into two groups: 1. Methods for measuring time delay between sharp edges in the signals. 2. Methods for measuring time delay between signals without sharp edges. Methods described in subsections 3.1.2, 3.1.4, 3.2.1, 3.2.3 belong to the first group. These methods are intended for measurement of delay between digital signals. For measurement of delay between analogue signals they are suitable only in a limited number of cases. These methods are useless for processing signals described in Chapter 2. The method described in subsection 3.2.2 belongs to this group, but only partially, because it converts a problem of measuring delay between sharp edges to the problem belonging to the other group. Methods described in subsections 3.1.1, 3.1.3, 3.2.4, 3.2.5, 3.2.6, 3.2.7, 3.2.8, 3.2.9, 3.2.10 and 3.2.11 belong to the second group. Method 3.2.2 partially belongs to this group too. These methods are intended for measurement of delay between analogue signals. Many of these methods are based on the basic cross-correlation method , improving some of its features. The basic cross-correlation method has two main disadvantages. The first disadvantage of this method is coarse time resolution and the second disadvantage is the problem with precise peak identification when the cross-correlation function is flat and signals are noisy. • Time resolution of the basic cross-correlation method is equal to the sampling period of processed signals. Methods described in subsections 3.2.4, 3.2.5 and 3.2.2 improve the time resolution of the cross-correlation method in various ways. Method 3.2.4 uses an analogue delay line and multiple AD converters, the methods described in 3.2.5 use various interpolation methods and method 3.2.2 uses computation in a continuous time domain. • When the amplitude of the processed signals changes slowly, their cross-correlation function has a flat peak. Then the maximum detection is difficult and can be easily influenced by noise. Methods described in subsections 3.2.6, 3.2.8, 3.2.9 and 3.2.10 enhance the cross-correlation function in order to get sharper maxima. Method 3.2.9 uses a wavelet transform instead of the Fourier transform to compute crosscorrelation. The main idea behind this method is a description of the signal using functions more similar to the signal (in paper [10] short oscillating impulses are processed) than sinusoids are. Methods not based on the cross-correlation method are phase shift method 3.1.3, sinc filtering method 3.2.7 and bispectrum method 3.2.11. CHAPTER 3. STATE OF THE ART OF DELAY MEASUREMENT METHODS 3.4 14 Methods based on cross-correlation The basics of the cross-correlation method are described in subsection 3.1.1, but for a better understanding of the main advantages and drawbacks of this method and its improved versions, it is necessary to provide a wider introduction to cross-correlation methods. 3.4.1 Continuous time cross-correlation method Let us consider a pair of time-shifted continuous time signals (3.4). Their cross-correlation function is in (3.5). The time shift between these signals can be computed by maximizing the cross-correlation function. Substituting (3.4) into (3.5) we get (3.6). x(t) (3.4) y(t) = x(t − ∆t) Rxy (τ ) = Z +∞ x(t) · y(t + τ ) dt (3.5) −∞ Lxy (τ ) = τ Z +∞ Rxy (τ ) = x(t) · x(t + τ − ∆t) (3.6) dt −∞ The maximum of the cross-correlation function Rxy is at the position defined by equation (3.7). Thus the time shift between signals can be found as an argument of the cross-correlation function at its maximum (3.8). max{Rxy } = n Z +∞ x2 (t)dt = −∞ o ∆t = arg max {Rxy (τ )} = arg τ max τ Z +∞ −∞ Z x(t) · x(t + τ − ∆t) | {z } (3.7) dt =0 +∞ −∞ x(t) · x(t + τ − ∆t) | {z } =0 dt (3.8) If the signals x and y are zero outside the interval hA, Bi, the cross-correlation function can be normalized (3.9). 1 Rxy (τ ) = (B − A) Z 2B−A x(t) · x(t + τ − ∆t) (3.9) dt 2A−B If the signals are noisy, equation (3.9) can be rewritten as (3.10), where r(t) and s(t) are noises with zero mean value (E(s) = 0 and E(r) = 0). d R xy (τ ) = 1 (B − A) d R xy (τ ) = Z 2B−A (x(t) + s(t)) · (x(t + τ − ∆t) + r(t + τ )) dt (3.10) 2A−B If the signal length increases (B − A) → ∞, the cross-correlation function of the noisy signals d approaches the cross-correlation function of the original signals R xy (τ ) → Rxy (τ ). 1 (B−A) R 2B−A x(t) · x(t + τ − ∆t) 2A−B R 2B−A 1 + (B−A) x(t) · r(t + τ ) 2A−B R 2B−A 1 x(t + τ − ∆t) + (B−A) 2A−B R 2B−A 1 + (B−A) 2A−B s(t) · r(t + τ ) dt + dt −→ (B−A)→∞ dt + · s(t) (B−A)→∞ −→ dt + (B−A)→∞ −→ (B−A)→∞ −→ Rxy (τ ) 0 0 0 (3.11) 15 CHAPTER 3. STATE OF THE ART OF DELAY MEASUREMENT METHODS 3.4.2 Discrete time cross-correlation method If the signal is sampled with sampling period Ts , the equations in (3.4) change to (3.12). x(t) = x(n · Ts ) y(t) = x(t − ∆t) = x(n · Ts − ∆t) N −1 n = −⌊N/2⌋, . . . − 2, −1, 0, 1, 2, . . . , 2 (3.12) The cross-correlation function of sampled signals is in (3.13). Substituting (3.12) to (3.13), we get (3.14). The n is the sample number; N is the number of samples of each signal. If the signal is infinite, N → ∞. X Rxy (k · Ts ) = x(n · Ts ) · y((n + k) · Ts ) n (3.13) Lxy (k · Ts ) = k · Ts k = −(N − 1), . . . , −2, −1, 0, 1, 2, . . . , (N − 1) Rxy (k · Ts ) = X (3.14) x(n · Ts ) · x(n · Ts + k · Ts − ∆t) n The time shift between sampled signals can be computed using (3.15) (modification of (3.8) for sampled signal). The position of the maximum of the cross-correlation function of sampled signals corresponds to the position of the maximum of the cross-correlation function of original (i.e. continuous) signals only if the time shift between signals is equal to the integer multiple of the sampling period (3.16). X c = arg max {Rxy (k · Ts )} = arg max ∆t x(n · Ts ) · x(n · Ts + k · Ts − ∆t ) | {z } k·Ts k·T s n =0 if∆t=m·Ts m∈Z 6=0 otherwise c ∆t = ∆t ∈ h∆t − Ts , ∆t + Ts i if ∆t = m · Ts ; otherwise m∈Z (3.15) (3.16) It is possible to normalize the cross–correlation function of sampled signals (3.17). Rxy (k · Ts ) = 3.4.3 1 X x(n · Ts ) · x(n · Ts + k · Ts − ∆t) N n (3.17) Cross-correlation of the harmonic functions If the signals x(n) and y(n) are harmonic functions with angular frequency ω (3.18), then their cross-correlation function is a harmonic function with the same frequency (3.19). x(n) = A · sin(ωn) y(n) = B · sin(ωn + ω ∆t ) = B · sin(ω(n + ∆n)) Ts |{z} s =∆n (3.18) CHAPTER 3. STATE OF THE ART OF DELAY MEASUREMENT METHODS Rxy (k) = X x(n) · y(n + k) = n = AB X X 16 A · sin(ωn) · B · sin(ω(n + k + ∆n)) = n sin(ωn) · sin(ω(n + k + ∆n)) = n AB X cos(ω∆n − ωk) − cos(2ωn + ωk − ω∆n) = = {z } | 2 n |{z} s =C const. in n = CN cos(ωk − ω∆n) − C X cos(ωk − ω(2n + ∆n)) = n = CN cos(ωk − ω∆n 0 + ∆n))− | {z }) − C cos(ωk − ω(2n {z } | ψ ϕ0 − C cos(ωk − ω(2n1 + ∆n)) − · · · | {z } ϕ1 · · · − C cos(ωk − ω(2nN −1 + ∆n)) = | {z } ϕN −1 C j(ωk+ϕ0 ) =− e + e−j(ωk+ϕ0 ) + ej(ωk+ϕ1 ) + e−j(ωk+ϕ1 ) + · · · 2 · · · + ej(ωk+ϕN −1 ) + ej(ωk+ϕN −1 ) − N ej(ωk+ψ) − N ej(ωk+ψ) = =− (3.19) C jωk jϕ0 e e + ejϕ1 + · · · + ejϕN −1 − N ejψ − 2 | {z } s =D − C −jωk −jϕ0 e e + e−jϕ1 + · · · + e−jϕN −1 − N e−jψ = 2 | {z } s =E C C Dejωk − Ee−jωk = − ((D + E) cos(ωk) + j(D − E) sin(ωk)) = 2 2 ! X = C N cos(ω∆n) − cos(2ωn + ω∆n) cos(ωk)+ =− C | | n {z s =F (constant in k) N sin(ω∆n) − X sin(2ωn + ω∆n) sin(ωk) = n s ! } {z =G (constant in k) } AB (F cos(ωk) + G sin(ωk)) A, B, F, G ∈ R 2 If the signals have finite lengths, the cross-correlation function is a harmonic function modulated by the cross-correlation function of their envelopes (it is trapezoid for rectangular envelopes because of the summation of different numbers of signal points at different positions on k axis). c When the time shift computation is done according to equation (3.15), the value ∆t Ts Ts occurs at any point in the interval h∆t − 2 , ∆t + 2 i with same probability (always valid because (3.20) holds for all cross-correlation functions). = f (xmax + ∆x) = f (xmax − ∆x) n o xmax = arg max {f (x)} x ∆x ≤ ε ε ∈ R+ (3.20) 17 CHAPTER 3. STATE OF THE ART OF DELAY MEASUREMENT METHODS Thus the more precise estimation of value ∆t should be done using knowledge of the shape of cross-correlation function and using more points of the cross-correlation function than only c Some methods for such estimations were described in the literature and briefly described ∆t. in subsections 3.2.4, 3.2.5 and 3.2.2. 3.4.4 Computation complexity of the cross-correlation method Computation of the cross-correlation function according to the definition in 3.13 requires N · K = N (2N − 1) = 2N 2 − N of the multiplications and the same number of summations. The localization of the maximum requires K = 2N − 1 comparisons. Thus the computation complexity of the cross-correlation method is O(N 2 ). The cross-correlation function can be also computed using a fast algorithm (3.21). Computation complexities of FFT and IFFT are O(N · log N ), thus the computation complexity of the cross-correlation method is decreased to O(N · log N ). Rxy (t) = IFFT {Rxy (f )} R (f ) = X(f ) · Y∗ (f ) xy (3.21) X(f ) = FFT {X(t)} Y(f ) = FFT {Y (t)} Y ∗ is the complex conjugate of Y 3.4.5 Maxima detection The problem of localization of maxima of the discrete cross-correlation function seems to be easy, but when sampling frequency decreases to the Nyquist limit, it became to be tricky. Let us consider hypothetical cross-correlation function described by (3.22). This function is used just for demonstration; any real cross-correlation function of finite length signals is more complicated. x(t) = t · sin(ωt) (3.22) If this function is continuous, the value of any local maximum (3.23) of this function is greater than the values of all previous local maxima (3.24). xmax = max{x(t)} = x(tmax ) D D = (−∞, τ i (3.23) τ ∈R i.e. tmax = arg{xmax } xmax > max{x(t)} (3.24) Dε Dε = (−∞, tmax ) If this function is sampled, i.e. (3.25), the relation (3.24) isn’t valid for some points, even if the Nyquist’s condition is met. x(n) = nTs · sin(ωnTs ) n∈Z (3.25) The violation is unavoidably caused by sample timing if the sampling frequency is not an integer multiple of the signal frequency. See Figure 3.2. If the sampling frequency 1/Ts decreases, the relation (3.24) is violated more and more often. Thus the sampling frequency should be much higher than Nyquist’s limit or the localization of the maxima of the crosscorrelation function cannot be done using a basic search for the highest value of the crosscorrelation function . CHAPTER 3. STATE OF THE ART OF DELAY MEASUREMENT METHODS t·sin (ωt ) Global and local maximum in the discrete time domain. Local maximum in the continuous time domain. Notice the different positions of the global maxima in the discrete time domain and in the continuous time domain. 18 Global and local maximum in the continuous time domain. Local maximum in the discrete time domain. time Signal in the discrete time domain. Signal in the continuous time domain. Figure 3.2: False peak detection Local and global maxima of the signal x(t) = t · sin(ωt). Notice the different positions of global maxima for the continuous time domain and the discrete time domain. 3.5 Summary of Chapter 3 In the literature, many methods for short time delay measurement are described. When the methods requiring sharp edges in the signal are eliminated, the rest of the methods have the following common features: 1. Requires high sampling frequency (in the sense of multiples of signal bandwidth). Thus high speed AD converters are required, e.g. for sampling of a 1 MHz signal, 20 MS/s AD converter is necessary. 2. When the signals are sampled, a large amount of data is produced and must be stored or transmitted for processing; thus high speed communication is required. 3. For real-time computations fast computation units (e.g. digital signal processors) are required. Chapter 4 Experimental evaluation of methods For better evaluation of the features of various methods described, several methods were implemented and their features were evaluated and compared under various conditions. As input signals for the method comparison, a pair of the signals imitating typical signals from the real appliance were used.1 In this section following methods are compared: 1. interpolation followed by correlation, 2. approximation of the cross-correlation function, 3. time shift computation from the phase shift, 4. signal approximation using the least squares method and statistical evaluation. 4.1 Description and evaluation of the methods In this section, details of the evaluated time delay measurement methods are described and different versions of these methods are compared for various sampling frequencies and noise levels. A numeric method evaluation was carried out using the above-described signals. The main features of the simulated signal are in accordance with the signal features described in the Chapter 2.1, fp = 1 MHz. White Gaussian noise at various signal to noise ratios was added to the simulated signal in order to evaluate the method’s noise sensitivity. Time shift computations for various time shifts were carried out for many times (5 to 1000 times, depending on computation complexity) and errors were statistically evaluated. The computations were carried out in double precision IEEE 754 floats. Two different error behaviours were observed regarding dependence between time shift and error magnitude: • The error depends only on the method’s parameters. In the following chapters the error is considered as absolute (4.1). • The error depends on the method’s parameters and the time shift. In the following chapters the error is considered as relative (4.2). 1 The amplitude of the signal is exponentially increases and then exponentially decreases. 19 CHAPTER 4. EXPERIMENTAL EVALUATION OF METHODS c − ∆t Eabs = ∆t ∆t c − ∆t Erel = t ∆ 20 (4.1) (4.2) The results for various combinations of parameters are compared in the following statements and in the next chapter (Chapter 4.2) the methods are compared to one another. 4.1.1 Interpolation followed by correlation This method is based on the common correlation method. Analogue signals are sampled (sampling period is less than the required resolution of the result) and interpolated to the required sampling rate. The common correlation method is applied to these interpolated (i.e. up-sampled) signals . The interpolation ratio can be computed from equation (4.3) where fs is the sampling frequency of the original signal, finterp is the sampling frequency of the interpolated signal and res is the required resolution. fs 1 = = res · fs n finterp (4.3) The interpolation can be carried out in different ways: • Lagrange’s (Newton’s) polynomial interpolation, • Hermitian polynomial interpolation, • interpolation using zero–value samples insertion and filtration, • spline interpolation. Because the interpolation ratio can be very high, the usability of this method is limited due to very high computation complexity. Interpolation methods comparison Comparison of the following interpolation methods was carried out: interpolation using zerovalued samples insertion and filtration [12], linear interpolation and spline interpolation using natural cubic spline [13] and pchip spline [14]. Lagrangian and Hermitian interpolation are not suitable for interpolating oscillating signals due to their properties. The interpolation method using zero-valued samples insertion and filtration was found to get much better results than the other methods, see Figure 4.1. Effect of filtration The effect of signal filtration was analysed. As signal disturbed by white Gaussian noise at various levels was filtered using a bandpass filter with cut-off frequencies 0.5·fp and 2·fp . The signals were filtered before or after interpolation. Experiments confirmed that filtration after interpolation has no effect on results, see Figure 4.2. When filtration is carried out before interpolation, error magnitude increases rapidly. 4.1.2 Approximation of the correlation function This method is another modification of the correlation method increasing its resolution. As signal pair is sampled and then cross-correlation of signals is computed. The correlation function is approximated using the least square method near its maximum. The maximum 21 CHAPTER 4. EXPERIMENTAL EVALUATION OF METHODS 0. 0001 E abs [s] 8e- 05 6e- 05 4e- 05 2e- 05 0 - 11 10 - 10 10 -9 10 -8 10 Δt [s] -7 10 Figure 4.1: Interpolation methods comparison. Absolute computation error for various interpolation methods, snr = 20 dB, fs = 50 Msample/s. Interpolation using zero-valued samples insertion and filtration; interpolation using natural cubic and pchip splines. 5e- 09 Eabs [s] 4e- 09 3e- 09 2e- 09 1e- 09 0 - 11 10 - 10 10 -9 10 -8 10 Δt [s] -7 10 Figure 4.2: Effect of filtration after interpolation. Absolute computation error for method of interpolation followed by correlation. Filtration after interpolation, fp = 1 MHz, passband 0.5·fp to 2·fp , snr = 20 dB, fs = 5 Msample/s. Without filtration in blue, with filtration in red. o . . . mean error, + . . . maximal error CHAPTER 4. EXPERIMENTAL EVALUATION OF METHODS 22 of the approximation function is analytically computed and corresponds to the time shift between signals in the pair. The signal (maximal frequency fmax ) is sampled at sampling frequency fs (fs > 2 · fmax ) and the correlation function Rxy is computed according to the equation (3.1). Its maximum Rmax = max(Rxy ) and corresponding lag Lmax are found. The lag corresponds to the time shift with resolution Ts . In the vicinity of Lmax the correlation function is approximated by bxy and its maximum R bmax = max(R bxy ) is found. Having corresponding lag L b max function R c time shift ∆t can be computed with a resolution much higher than Ts , see equation (4.4). For approximation of the correlation function it is advantageous to use a polynomial approximation using the least squares method (at least in the case of cross-correlation of signals specified in Chapter 2.1). In the neighbourhood of correlation maxima, n points in both directions are picked up. Coordinates of these points are [Lmax−n , Rmax−n ], . . . , [Lmax , Rmax ], . . . , [Lmax+n , Rmax+n ]. These points are polynomially fitted by polynomial Pm (L) of degree m (in the least-squares sense). Local maxima of this polynomial can be b max , R bmax ] nearest (in the sense of min |Lmax − computed analytically. Local maximum [L b max |) to the cross-correlation function maximum [Lmax , Rmax ] determines the time shift L c see equation (4.4). ∆t, c = L̂max · Ts = L̂max (4.4) ∆t fs Appropriate degree of the approximation polynomial The appropriate number of points n for polynomial fitting depends on the degree of the polynomial (m). If the quadratic curve is fitted, it is a good choice to fit it between inflexion points of the correlation function. For the harmonic function, the inflexion points are situated at zero crossings. In this case, n is given by equation (4.5). For a higher polynomial degree, more points can be used. fs n= (4.5) 4 · fp Increasing the polynomial degree also brings increasing ripple and approximation error in the intervals between nodes (samples). An extreme case arises when m + 1 points (n = m/2) are fitted with a polynomial of degree m. In this case the least square method changes into Lagrange interpolation with all its consequences. Experimental comparison of approximation polynomials Comparison of results has been done for approximation of the cross-correlation function by polynomials of degree two and four. A polynomial of degree two gives better results for some combinations of sampling frequency and noise level and a polynomial of degree four is better for the other combinations (see Figure 4.3 and 4.4). The results of the experiment are summarised in Table 4.1. Effect of filtration The effect of signal filtering has been evaluated using low-pass filter with cut-off frequency 2 · fp (for definition of fp , see Chapter 2.1). It was found that filtration has no effect on computation error. 4.1.3 Signal approximation using the least squares method and statistical evaluation Sampled signals are divided into small elements (e.g. half–waves) and each element is approximated using the least square method. Time shifts are analytically computed for corre- 23 CHAPTER 4. EXPERIMENTAL EVALUATION OF METHODS 1. 2e- 06 Eabs [s] 1e- 06 8e- 07 6e- 07 4e- 07 2e- 07 0 - 11 10 - 10 10 -9 10 -8 10 Δt [s] -7 10 Figure 4.3: Computation error — approximation of correlation function. Absolute computation error for method of approximation of correlation function, snr = 10 dB, fs = 5 Msample/s. Polynomial of degree two in green, of degree four in red. o . . . mean error, + . . . maximal error 2. 5e- 09 Eabs [s] 2e- 09 1. 5e- 09 1e- 09 5e- 10 0 - 11 10 - 10 10 -9 10 -8 10 Δt [s] -7 10 Figure 4.4: Computation error — approximation of correlation function. Absolute computation error for method of approximation of correlation function, snr = 20 dB, fs = 50 Msample/s. Polynomial of degree two in green, of degree four in red. o . . . mean error, + . . . maximal error CHAPTER 4. EXPERIMENTAL EVALUATION OF METHODS 24 Table 4.1: Appropriate degree of approximation polynomial. Appropriate degree of approximation polynomial for method of approximation of correlation function for various sampling frequencies and noise levels. fp = 1 MHz Without noise snr = 20 dB snr = 10 dB snr = 0 dB 50 Ms/s 4 4 2 2 10 Ms/s 4 4 2 x 5 Ms/s 2 2 2 x 2 or 4 . . . appropriate degree of polynomial is 2 or 4; x . . . differences between degrees 2 and 4 are insignificant. sponding pairs of elements. This set of elementary time shifts is statistically evaluated. Let us consider a pair of time shifted signals, x1 and x2 . Both of them are divided in some way to n elements x11 , x12 , . . . , x1n and x21 , x22 , . . . , x2n . Each element is approximated (in the sense of least squares) by an appropriate function (a polynomial is a good choice); we get n functions for each signal x b11 , x b12 , . . . , x b1n and x b21 , x b22 , . . . , x b2n . For each pair c 1 · · · ∆t c n is computed. The algorithm for of corresponding functions, their time shift ∆t computation of time shifts depends on the approximation function used; for a quadratic approximation it may be the distance between peaks, for linear approximation it may be the c i } is statistically distance between zero-crossings, etc. The set of elementary time shifts {∆t c Basic methods of statistical evaluation are evaluated in order to get final time shift ∆t. c i }. computations of the arithmetic mean or median of the set {∆t Experimental comparison of approximation polynomials This method was evaluated in versions using polynomials of degree two or four as an approxid mation function xc ik . For a quadratic function the time shift ∆tk was computed as a distance of vertexes in t–axis. Local extrema were found for polynomials of degree four. Time shifts (in t–axis) were computed for extrema laying at particular intervals. These time shifts were dk . used as ∆t The comparison of both versions of the method can be found in Table 4.2. In the table, it can be seen that the polynomial of degree of two is better then the one of degree of four, with the exception of noiseless signals sampled at low frequency. Dependence of computation error on sampling frequency can be seen in the Figure 4.5. Statistical evaluation of elementary time shifts n o d1 , ∆t d2 , . . . , ∆t dn , the arithmetic mean For statistical evaluation of the set of time shifts ∆t and median were used. Computation error is many times (102 − 1010 ) higher when using the arithmetic mean than when using the median. 4.1.4 Phase shift methods In this subsection, there two variants of the method for time shift computation from the phase shift are compared; the basic phase shift method (see 3.1.3) and the phase shift method with phase interpolation (described below). CHAPTER 4. EXPERIMENTAL EVALUATION OF METHODS 25 Table 4.2: Appropriate degree of approximation polynomial. Appropriate degree of approximation polynomial for method using approximation and statistical evaluation for various sampling frequencies and noise levels. fp = 1 MHz Without noise snr = 20 dB snr = 10 dB snr = 0 dB 50 Ms/s 2 2 2 2 10 Ms/s 4 2 2 2 5 Ms/s 4 2 2 2 2 or 4 . . . polynomial of degree two or four gives a smaller computation error. Phase shift method with phase interpolation This method is based on the basic phase shift method (see 3.1.3). The phase spectrum of the signal is computed using the Fourier transform and n points of the phase spectrum is chosen in the neighbourhood of the frequency fp . Then an approximation polynomial ϕ(f b ) d is fitted through these points. The phase shift between signals ∆ϕ is computed according to equation (4.6). The time shift is computed according to (3.2). d=ϕ ∆ϕ c1 (fp ) − ϕ c2 (fp ) (4.6) Comparison of methods with and without phase interpolation A comparison of the phase shift method with and without phase interpolation was carried out. Methods were compared for signals with signal to noise ratios 20, 10 and 0 dB sampled at frequencies 50, 10 and 5 M sample/s. The method without phase interpolation was better in all evaluated cases. See Figures 4.6 and 4.7. Influence of the windowing function The influence of the windowing function used for sample weighting during Fourier transform computation was evaluated. It was found that differences between results when using rectangular or different windows are negligible and thus can be ignored, see Figure 4.8. 4.2 Methods comparison Various modifications of methods were compared in the previous section (section 4.1) and for each method the best variant was found. In this section, the above mentioned methods are compared with one another for various combinations of noise level and sampling frequency. The results are summarized in Table 4.3. Because the computation complexity of interpolation followed by the correlation method is much higher than the computation complexity of the other methods, also the next best method has been indicated in the cases when this method was the best. In Table 4.3 it can be seen that the choice of method for a particular application depends on the signal to noise ratio and is independent of the sampling frequency. The error magnitude depends on the sampling frequency. (Excluding cases of very low sampling frequency — near the Nyquist frequency.) Error magnitudes for various combinations of noise level and sampling frequency can be found in Table 4.4. Methods used for computations are summarized in Table 4.3. 2 All computation were carried out in double precision IEEE 754 floating point arithmetic. 2 Methods comparison was accepted for publication at Applied Electronics Conference 2015. 26 CHAPTER 4. EXPERIMENTAL EVALUATION OF METHODS 2e- 07 Eabs [s] 1. 8e- 07 1. 6e- 07 1. 4e- 07 1. 2e- 07 1e- 07 8e- 08 6e- 08 4e- 08 2e- 08 0 - 11 10 - 10 10 -9 10 -8 10 Δt [s] -7 10 Figure 4.5: Signal approximation using the least squares method — dependence of error on sampling frequency. Absolute computation error for signal approximation and statistical evaluation method. Degree of approximation polynomial is two, snr = 0 dB. Sampling frequency fs = 50 Msample/s in blue, fs = 10 Msample/s in green and fs = 5 Msample/s in red. o . . . mean error, + . . . maximal error. 0. 004 Erel 0. 0035 0. 003 0. 0025 0. 002 0. 0015 0. 001 0. 0005 0 10- 11 10- 10 10- 9 10- 8 Δt [s] 10- 7 Figure 4.6: Time shift computation from the phase shift I. Relative computation error for time shift computation from the phase shift with and without phase interpolation. Without noise, fs = 10 Msample/s. Without phase interpolation in red, with phase interpolation in black. o . . . mean error, + . . . maximal error 27 CHAPTER 4. EXPERIMENTAL EVALUATION OF METHODS 4e- 07 Eabs [s] 3. 5e- 07 3e- 07 2. 5e- 07 2e- 07 1. 5e- 07 1e- 07 5e- 08 0 - 11 10 - 10 10 -9 10 -8 10 Δt [s] -7 10 Figure 4.7: Time shift computation from the phase shift II. Absolute computation error for time shift computation from the phase shift with and without phase interpolation. snr = 10 dB, fs = 10 Msample/s. Without phase interpolation in red, with phase interpolation in black. o . . . mean error, + . . . maximal error 1e- 08 Eabs [s] 8e- 09 6e- 09 4e- 09 2e- 09 0 - 11 10 - 10 10 -9 10 -8 10 Δt [s] -7 10 Figure 4.8: Time shift computation from the phase shift - influence of the window. Absolute computation error for time shift computation from the phase shift. snr = 20 dB, fs = 5 Msample/s. Windowing function: rectangular in blue, triangular in red, hamming in green, hann in black and kaiser in magenta. o . . . mean error, + . . . maximal error. 28 CHAPTER 4. EXPERIMENTAL EVALUATION OF METHODS 0. 004 Erel 0. 0035 0. 003 0. 0025 0. 002 0. 0015 0. 001 0. 0005 - 11 10 - 10 10 -9 10 -8 10 Δt [s] -7 10 Figure 4.9: Computation error for signal time shift computation using the Fourier transform — without noise. Relative computation error for signal time shift computation using the Fourier transform. fp = 1 MHz, without noise. Sampling frequency fs = 50 Msample/s in blue, fs = 10 Msample/s in green, fs = 5 Msample/s in red. 1e- 08 Eabs [s] 8e- 09 6e- 09 4e- 09 2e- 09 0 - 11 10 - 10 10 -9 10 -8 10 Δt [s] -7 10 Figure 4.10: Computation error for method of approximation of correlation function I. Absolute computation error for method of approximation of correlation function. fp = 1 MHz, snr = 20 dB. Approximation polynomial of degree 2: Sampling frequency fs = 50 Msample/s in blue, fs = 10 Msample/s in green, fs = 5 Msample/s in red. Approximation polynomial of degree 4: Sampling frequency fs = 50 Msample/s in black, fs = 10 Msample/s in magenta. o . . . mean error, + . . . maximal error. 29 CHAPTER 4. EXPERIMENTAL EVALUATION OF METHODS 7e- 09 Eabs [s] 6e- 09 5e- 09 4e- 09 3e- 09 2e- 09 1e- 09 0 10- 11 10- 10 10- 9 10- 8 Δt [s] 10- 7 Figure 4.11: Computation error for method of approximation of correlation function II. Absolute computation error for method of approximation of correlation function. fp = 1 MHz, snr = 10 dB. Approximation polynomial of degree 2. Sampling frequency fs = 50 Msample/s in blue, fs = 10 Msample/s in green, fs = 5 Msample/s in red. 1. 4e- 09 Eabs [s] 1. 2e- 09 1e- 09 8e- 10 6e- 10 4e- 10 2e- 10 0 -9 10 -8 10 -7 10 Δ t [s] -6 10 Figure 4.12: Comparison of absolute computation errors for fs = 100 Msample/s. fs = 100 · fp , SNR = 20 dB, fp = 1 MHz, Approximation of the correlation function using quadratic polynomial in blue, using polynomial of order of four in red. Phase shift method in green. Computation run repeatedly: ”x”. . . mean error, ”o”. . . median of error, ”+”. . . maximal error. 30 CHAPTER 4. EXPERIMENTAL EVALUATION OF METHODS Table 4.3: Methods comparison. This table summarizes the best methods for various combinations of noise level and sampling frequency. fp = 1 MHz. Without noise snr = 20 dB snr = 10 dB snr = 0 dB ∗ 50 Ms/s FP IK (KC4)∗ KC2 PS 10 Ms/s FP KC4 KC2 PS 5 Ms/s FP KC2 KC2 PS IK . . . Interpolation followed by correlation. FP . . . Time shift computation using Fourier transform. PS . . . Signal approximation using least squares and statistical evaluation. KC2 or KC4 . . . Approximation of correlation function using polynomial of degree two or four. This method has much higher computation complexity than the other methods. The next best method is KC4. Table 4.4: Magnitude of computation error. This table summarizes magnitudes of computation errors for methods from the Table 4.3. Computations were carried out in double precision floating point arithmetic. fp = 1 MHz. Without noise snr = 20 dB snr = 10 dB snr = 0 dB 1 50 Ms/s 0.1 % 170 ps / 220 ps 0.5 ns 4 ns 1 2 10 Ms/s 0.38 % 450 ps / 400 ps 1.5 ns 20 ns 1 5 Ms/s 0.35 % 700 ps 2 ns 37 ns Figure number 4.9 4.10 4.11 4.5 Error magnitudes for methods KC4 / KC2. Error magnitude for interpolation followed by correlation (IK) is 200 ps. (Interpolation using zero–valued samples insertion and filtration. Interpolation rate 1:100.) Computation time for this method is much higher than for other methods. 2 CHAPTER 4. EXPERIMENTAL EVALUATION OF METHODS 4.3 31 Summary of the evaluation The above-compared methods can be used for delay measurement, but the common disadvantage of all methods mentioned is the requirement that the sampling frequency must be much higher than the Nyquist limit. Thus the sampling frequency of the AD converter must be high even for relatively low-frequency signals and a large amount of data is produced and must be processed. This requires high speed communication between the AD converter and the processing unit, a large memory for data storage and a high speed computation unit for data processing. This makes development of such a device difficult and the resulting device expensive. For wider usage of digital delay measurement it is necessary to reduce the design complexity of delay measurement devices. Thus the development of methods for decreasing the sample amount is required. Chapter 5 Nonuniform sampling for sampling frequency reduction A high frequency of processed signals requires high sampling frequency. When long signals are sampled, a large amount of data is produced increasing processing system complexity. In the author’s article [15], a method for decreasing sampling frequency using nonuniform sampling proposed. This method is described in the following sections. 5.1 Difficulties when using the Fourier transform for signals time shift measurement Suppose we have the pair of signals described in Chapter 2.1. For time shift computation, signals have to be sampled at least at Nyquist’s sampling rate fs = 2 · fp . Therefore, if fp is very high, the signal has to be sampled at a very high sampling frequency. If the sampled segment of the waveform is long at the same time, we get a huge amount of sample data to process. It can require a large amount of memory, high speed communication for real-time data transfers etc. To reduce the amount of data, we can consider reducing the sampling frequency or sampling only a part of the waveform. Both approaches have disadvantages: Reducing sampling frequency can cause problems with aliasing. If, on the other hand, only a short part of the waveform is sampled, short-time noise could influence the results1 . This problem can be solved by using non-uniform sampling. To use non-uniform sampling, we use the time measurement resolution dt instead of sampling period f1s , and thus the average sampling rate can be lower then 2 · fp . This means that the signal can be sampled along the whole waveform length, while providing a lower amount of data without the danger of aliasing. Using a non-uniform Fourier transform, the signals time shift can be computed. 5.2 Non-uniform sampling Let us consider a band limited signal (bandwidth B). A well-known Nyquist theorem says that sampling frequency has to be at least 2 · B to avoid aliasing. Using an infinite sampling frequency, we can get an infinite bandwidth. In a real system, infinite frequency is unreachable, but we can approximate it. If we sampled a signal of infinite length composed of harmonic waveforms at random sample intervals, we would reach an infinite bandwidth [16]. But this is also impossible for two reasons; firstly no available signal is of infinite length, 1 It also influences the result in the case of whole waveform sampling, but in this case the influence is reduced by the amount of other samples. 32 CHAPTER 5. NONUNIFORM SAMPLING FOR SAMPL. FREQ. REDUCTION 33 and, secondly we cannot measure time at infinite precision. However, it can be done using an approximation, if we comply with several conditions. If the signal is of finite length and we take enough samples, it will be statistically similar to an infinite length signal. Precision of finite time measurement resolution becomes evident in limited bandwidth and therefore latent sampling frequency. 5.2.1 Latent sampling frequency If the signal is sampled at random points in time, it is important to specify not only the sample number m, but also the time tm , when each one of the samples is taken. Time intervals between sampling time points can be specified as multiples of a time quantum dt. As a result, time measurement has limited resolution dt. (Note that time quantum does not represent the time measurement accuracy but the time measurement resolution.) Sampling times tm can be written as multiplies of this time quantum (5.1). tm = n · dt n. . . random integer m. . . sample number (5.1) Having this equation, the non-uniform sampling can be regarded as uniform sampling at frequency dt−1 with some samples missing. If the sampling frequency is known, the Nyquist theorem can be applied to figure out the allowed signal bandwidth (5.2). 1 2 · dt B. . . allowed bandwidth B= 5.2.2 (5.2) Sampling points For sampling points distribution, it is convenient to use (5.3). This distribution assures a flat probability mass function when time goes to infinity. tn+1 = tn + rn · dt fs ); dt rn . . . random variable rn ∼ P o( (5.3) fs . . . average sampling frequency Suppose we have an AD converter with maximal sampling frequency fmax . For sampling (uniform or non-uniform), we must ensure fs ≤ fmax . Because sampling times are random, we can’t ensure it for each sample, but we can set the probability of violation to acceptable level p. From cumulative distribution function (5.4) of the Poisson distribution [17, pp. 32–38], we can find rmin 2 . At probability level 1 − p, the value rmin is the minimum of the set {rn }; n = 0, 1, . . . N − 1. Therefore, the sampling period is greater than rmin · dt and the maximal frequency can be enumerated. r X λk p > e−λ = F (r) N k! k=0 N . . . number of samples λ= 2 Values fs dt of F (r) are tabulated for various values of λ, see [17, pp. 104]. (5.4) 34 CHAPTER 5. NONUNIFORM SAMPLING FOR SAMPL. FREQ. REDUCTION The AD converter sampling frequency has to comply with (5.5). 1 fm > (5.5) rmin · dt For values of λ greater than 9 approximation (5.6) can be used [17, pp. 104]. P o(λ) ≈ N (µ = λ, σ 2 = λ) 5.3 (5.6) Non-uniform Fourier Transform Let us consider a signal x(t). The Fourier transform X(k) of x(t) definition is in (5.7)3 . [18] N is the total number of samples, tn is the sampling time, and ∆ω is the circular frequency step. N −1 X x(tn ) · e−j·k·∆ω·tn (5.7) X(k) = n=0 Assigning frequency step (5.8) and sampling time tn = n, we get the standard DFT definition (5.9). 2·π ∆ω = (5.8) N X(k) = N −1 X n x(n) · e−j2πk N (5.9) n=0 Assigning frequency step (5.10), we get non-uniform DFT definition (5.11). 2·π T T . . . signal (window) length ∆ω = X(k) = N −1 X tn x(tn ) · e−j2πk T (5.10) (5.11) n=0 This definition expects continuous time, but we can measure time only in discrete time quanta (clock ticks) lasting dt. Then we can use the number of clock ticks instead of the time (5.12). t m= (5.12) dt Substituting (5.12) into (5.11), we get (5.13). Informally said, we sample the signal in N points of M possible. X(k) = N −1 X x(mn ) · e−j2πk mn M n=0 T M= ; dt (5.13) tn mn = dt M . . . signal (window) length in clock ticks dt mn . . . sampling time in clock ticks dt Frequency resolution and maximal nonaliased frequency of standard (DFT) and nonuniform (NDFT) Fourier transform versions can be found in Table 5.1. 3 In this and all following equations we have omitted normalization considering the number of samples CHAPTER 5. NONUNIFORM SAMPLING FOR SAMPL. FREQ. REDUCTION 35 Table 5.1: Fourier transform modifications comparison. Frequency resolution Maximal nonaliased frequency a DFT NDFT Padded DFTa 1 T fs 2 1 T 1 2·dt 1 l·T fs 2 Zero padded to l times original length. The non-uniform Fourier transform can be computed from its definition with computational complexity O(N 2 ), using the FFT algorithm with computational complexity O(M · log(M )) 4 , or faster using an approximation algorithm, for example [19–21]. 5.4 Experimental evaluation of the NDFT method Numerical experiments were carried out to prove the method’s desired features. Pairs of time shifted waveforms were generated and noise of a defined level was added. Then the waveforms’ time shift was computed and relative and absolute errors were evaluated. This procedure was repeated for many combinations of sampling frequency and signal to noise ratio. For each combination of parameters, the computation was repeated many times and results were statistically evaluated. When SNR is high (in the context of this article, SN R ≈ 20 dB) and sampling frequency is high (f s ≈ 50 · fp ), the NDFT method is inferior to the correlation or polynomial fit methods. But as noise gets stronger (SN R → 0 dB) and sampling frequency decreases, Fourier transform methods start to perform better than the others. See Figures 5.1 and 5.1 for details. When sampling frequency approaches the Nyquist limit (f s = 2 · fp ) and then decreases, NDFT is preferable to classical (uniform) DFT, see Figures 5.3 and 5.4. 4 Each clock tick, we have not used for sampling, as zero-valued sample for computation using FFT is used. CHAPTER 5. NONUNIFORM SAMPLING FOR SAMPL. FREQ. REDUCTION 36 2e- 06 Eabs [s] 1. 5e- 06 1e- 06 5e- 07 0 10- 9 10- 8 10- 7 Δt [s] 10- 6 Figure 5.1: Methods comparison I. fs = 2 · fp , dt = (100 · fp )−1 , fp = 1 MHz, without noise Approximation of the cross-correlation function in blue, time shift computation from the phase shift (classical) in red, non-uniform Fourier transform method in green. Computation run repeatedly: ”x”. . . mean error, ”o”. . . median of error, ”+”. . . maximal error. 8e- 06 Eabs [s] 7e- 06 6e- 06 5e- 06 4e- 06 3e- 06 2e- 06 1e- 06 0 -9 10 -8 10 -7 10 Δt [s] -6 10 Figure 5.2: Methods comparison II. fs = 2 · fp , dt = (100 · fp )−1 , fp = 1 MHz, SNR = 0 dB Approximation of the cross-correlation function in blue, time shift computation from the phase shift (uniform) in red, non-uniform Fourier transform method in green. Computation run repeatedly: ”x”. . . mean error, ”o”. . . median of error, ”+”. . . maximal error. CHAPTER 5. NONUNIFORM SAMPLING FOR SAMPL. FREQ. REDUCTION 37 6e- 07 Eabs [s] 5e- 07 4e- 07 3e- 07 2e- 07 1e- 07 0 -9 10 -8 10 -7 10 Δt [s] -6 10 Figure 5.3: NDFT method’s absolute error I. . fs = 1 · fp , dt = (500 · fp )−1 , SNR = 0 dB, fp = 1 MHz, N = 125 , M = 50 000 Signal approximation using least squares (see 4.1.3) in blue, non-uniform Fourier transform method in green. Classical (uniform) phase shift method failed. Computation run repeatedly: ”x”. . . mean error, ”o”. . . median of error, ”+”. . . maximal error. 2. 5e- 07 Eabs [s] 2e- 07 1. 5e- 07 1e- 07 5e- 08 0 -9 10 -8 10 -7 10 Δt [s] Figure 5.4: NDFT method’s absolute error II. -6 10 . fs = 0.5 · fp , dt = (100 · fp )−1 , fp = 1 MHz, N = 62, M = 10 000 Diagram only for non-uniform Fourier shift method, other methods failed due to lack of samples. Without noise in green, SNR = 20 dB in red, SNR = 10 dB in blue, SNR = 0 dB in cyan. Computation run repeatedly: ”x”. . . arithmetic mean of the error, ”o”. . . median of the error, ”+”. . . maximal error. CHAPTER 5. NONUNIFORM SAMPLING FOR SAMPL. FREQ. REDUCTION 38 7e- 07 Eabs [s] 6e- 07 5e- 07 4e- 07 3e- 07 2e- 07 1e- 07 0 -9 10 -8 10 -7 10 Δt [s] Figure 5.5: NDFT method’s absolute error III. -6 10 . fs = 0.2 · fp , dt = (100 · fp )−1 , fp = 1 MHz, N = 25, M = 10 000 Diagram only for non-uniform Fourier shift method, other methods failed due to lack of samples. Without noise in green, SNR = 20 dB in red, SNR = 10 dB in blue, SNR = 0 dB in cyan. Computation run repeatedly: ”x”. . . arithmetic mean of the error, ”o”. . . median of the error, ”+”. . . maximal error. Chapter 6 Goals of the Ph.D. thesis and further work 6.1 Goals of the Ph.D. thesis The goals of the Ph.D. thesis are the following: 1. To study and compare the methods for time delay measurement. — Done. 2. To develop new procedures for decreasing the sampling frequency and amount of sampled data necessary for time delay measurement. — In progress. 3. To verify properties of the proposed methods. — To be done. The hypothesis emerging from the current research is: Using non-uniform sampling and the non-uniform Fourier transform, it is possible to decrease the number of samples and the sampling frequency needed for measurement of the time shift between analogue signals compared to methods using periodic sampling. 6.2 Objectives to be met In Chapter 6.3 the main problems to be solved are described. In this section, those problems are summarised into several objectives planned for further studies in order to accomplish the goals of the Ph.D. thesis: 1. Modify the sampling scheme in order to ensure the minimal sampling period with 100 % probability. 2. Reduce noise and secondary aliasing in the spectrum. 3. Examine the relation between the number of samples and accuracy. 4. Adapt the method for the use of general purpose AD converters. 5. Implement and test the method in a near-to-real appliance. 39 CHAPTER 6. GOALS OF THE PH.D. THESIS AND FURTHER WORK 6.3 40 Further work The basic principle of the time delay measurement method using nonuniform sampling was introduced. But to make the method usable, more work must be done. First of all, the properties of the non-uniform sampling must be better studied. In section 5.2, the minimal sampling frequency of the AD converter ensuring at certain probability level that no sampling instant would be missed is derived. It would be useful to modify the sampling scheme (e.g. modifying the probability density function or using precomputed pseudo-random number sequences in (5.3)) to ensure this at the 100% probability level. It is necessary to improve an algorithm for detection of the frequency of the signal. When the signal to noise ratio is low, peaks in the spectra are hardly distinguishable. And fuzzy or secondary aliasing in the results of the Fourier transform can also appear(see [22, chapter 9]). For wider use of the method, it is necessary to specify conditions for method usability. When the signal gets shorter, the number of samples taken decreases. Thus the probabilistic properties of the sampling process get worse and results distortion appears. When the average sampling frequency decreases, a similar effect appears. The construction of a dedicated AD converter for non-uniform sampling is improbable; thus general purpose AD converters would be used in real appliances. According to [22, pp. 58], the bandwidth of analogue inputs of common AD converters is typically 4 to 8 times higher than half of the maximal (periodic) sampling frequency of the AD converter. This means that using non-uniform sampling, a much wider bandwidth can be achieved compared to periodic sampling using the same AD converter. Thus, the features of common AD converters should be carefully studied and the time delay computation method should be adapted for non-uniform sampling carried out using common AD converters originally intended for periodic sampling. Many microcontrollers are equipped with AD converters working at a sampling frequency of several hundreds of kilosamples. Using the appropriate method, it may be (or may not be) possible to measure the delay between signals at frequencies of several megahertz using these cheap devices. For practical verification of the intended properties of the method, some time delay measurement device should be implemented using this method and tested in a real or nearto-real appliance. Chapter 7 Conclusion In the first two chapters, there is a brief introduction to short time delay measurement and the problem specification. The third chapter describes the state of the art of delay measurement. The selected methods are experimentally evaluated and compared in Chapter 4. All methods require a high sampling frequency (in the sense of multiples of the signal bandwidth). Because of this, high speed AD converters must be used, which produce a large amount of the data to be stored and processed, thus increasing the complexity of the device. In the fifth chapter a new method for decreasing the number of samples necessary for time delay measurement using nonuniform sampling and nonuniform Fourier transform is described. An experimental evaluation of the method was carried out. It was found that results obtained using this method are better than results obtained using the other methods. These results are promising, but for the full usability of the method, more work must be done. Chapter 6 describes the further work. Also the goals of the Ph.D. thesis are described in that chapter. 41 Acknowledgement This work has been supported by UWB grant SGS–2013–029 Advanced Computer and Information Systems and by the European Regional Development Fund (ERDF) — project NTIS (New Technologies for the Information Society), European Centre of Excellence, CZ.1.05/ 1.1.00/ 0.2.0090. 42 Bibliography [1] Xiangwei Zhu, Guangfu Sun, Shaowei Yong, and Zhaowen Zhuang. A high-precision time interval measurement method using a phase-estimation algorithm. Instrumentation and Measurement, IEEE Transactions on, 57(11):2670–2676, Nov 2008. ISSN 0018-9456. doi: 10.1109/TIM.2008.925025. [2] P. Pánek. Time-interval measurement based on SAW filter excitation. Instrumentation and Measurement, IEEE Transactions on, 57(11):2582–2588, Nov 2008. ISSN 0018-9456. doi: 10.1109/TIM.2008.925014. [3] Ming-Chien Tsai and Ching-Hwa Cheng. A full-synthesizable high-precision built-in delay time measurement circuit. In Design Automation Conference, 2009. ASP-DAC 2009. Asia and South Pacific, pages 123–124, Jan 2009. doi: 10.1109/ASPDAC.2009.4796463. [4] Xu Wei, Chen Qian, and Gu Guo-hua. Research on laser ranging system based on time delay estimation. In Photonics and Optoelectronics (SOPO), 2011 Symposium on, pages 1–3, May 2011. doi: 10.1109/SOPO.2011.5780683. [5] Xiaoming Lai and H. Torp. Interpolation methods for time-delay estimation using crosscorrelation method for blood velocity measurement. Ultrasonics, Ferroelectrics, and Frequency Control, IEEE Transactions on, 46(2):277–290, March 1999. ISSN 0885-3010. doi: 10.1109/58.753016. [6] Joseph C. Hassab and R. Boucher. Optimum estimation of time delay by a generalized correlator. Acoustics, Speech and Signal Processing, IEEE Transactions on, 27(4):373– 380, Aug 1979. ISSN 0096-3518. doi: 10.1109/TASSP.1979.1163269. [7] Wen Ma and Jianguo Huang. Accurate time delay estimation based on SINC filtering. In Signal Processing, 2002 6th International Conference on, volume 2, pages 1621–1624 vol.2, Aug 2002. doi: 10.1109/ICOSP.2002.1180109. [8] Y.T. Chan, J. Riley, and J. Plant. A parameter estimation approach to time-delay estimation and signal detection. Acoustics, Speech and Signal Processing, IEEE Transactions on, 28(1):8–16, Feb 1980. ISSN 0096-3518. doi: 10.1109/TASSP.1980.1163361. [9] Fan Di, Cao Maoyong, and Sun Nongliang. Time delay estimation based on wiener filter in ultrasonic detection of sediments in drilling hole. In Computer Science and Engineering, 2009. WCSE ’09. Second International Workshop on, volume 2, pages 582–585, Oct 2009. doi: 10.1109/WCSE.2009.880. [10] C. Guetbi, D. Kouame, A. Ouahabi, and J.P. Chemla. Methods based on wavelets for time delay estimation of ultrasound signals. In Electronics, Circuits and Systems, 1998 IEEE International Conference on, volume 3, pages 113–116 vol.3, 1998. doi: 10.1109/ICECS.1998.813947. 43 44 BIBLIOGRAPHY [11] Shiyuan Zhou, Yao Xu, Hongbo Wang, and Chunguang Xu. Time delay estimation via third-order cumulant. In Nondestructive Evaluation/Testing: New Technology Application (FENDT), 2013 Far East Forum on, pages 77–81, June 2013. doi: 10.1109/FENDT.2013.6635533. [12] Jiří Jan. Číslicová filtrace, analýza a restaurace signálů. Vysoké učení technické v Brně, VUTIUM, Brno, Czech Republic, 2002. ISBN 80-214-1558-4. [13] Dana Černá. Interpolace. [online], April 2010. kmd.fp.tul.cz/lide/cerna/MA3_FS/interpolace.pdf. [cit. 2013-06-20] Available: [14] David Kahaner, Cleve Moler, and Stephen Nash. Numerical Methods and Software. Prentice Hall, Phoenix, New Jersey, 1988. ISBN 0-13-627258-4. [15] Karel Dudáček jr., Karel Dudáček, and Vlastimil Vavřička. Short delay measurement using non-uniform fourier transform. In 14th Biennial Baltic Electronics Conference, Proceedings of the, pages 165–168, Tallinn, Estonia, October 2014. Tallinn University of Technology. ISBN 978-9949-23-672-5. [16] Jian-Jiun Ding. Non-uniform Sampling. [online]. http://djj.ee.ntu.edu.tw/Nonuniform_Sampling.docx [2014, Apr. 3]. Available: [17] Zdeněk Kobeda and Jiří Reif. Úvod do pravděpodobnosti a spolehlivosti. University of West Bohemia, Pilsen, Czech Rep., 2nd edition, 2004. ISBN 80-7043-333-7. [18] Jae-Jeong Hwang, Sang-Gyu Cho, Joon Moon, and Jae-Wan Lee. Nonuniform DFT based on nonequispaced sampling. WSEAS Transactions on Information Science and Applications, 2(9):1403–1408, 2005. [19] Alok Dutt. Fast Fourier Transform for Nonequispaced Data. PhD thesis, Yale University, Connecticut, 1993. [20] Alok Dutt and V. Rokhlin. Fast Fourier Transform for Nonequispaced Data II. Technical report, Yale University, Connecticut, 1993. Research Report 980. [21] Daniel Potts. NFFT. [Online], January 2014. chemnitz.de/∼potts/nfft/ [2014, Apr. 3]. Available: http://www-user.tu- [22] Ivars Bilinskis. Digital Alias-free Signal Processing. John Wiley & Sons, Ltd, Chichester, England, 2007. ISBN 978-0-470-02738-7.