I have a customer that needs to measure the phase difference between two signals. Here are some of the parameters: 1. The waveform is very oversampled. 2. Each signal may have a different amplitude 3. Averaging the result is allowable. 4. The signal is relatively noise free. I know that there are FFT methods, but I think this may be more work than necessary. One thought is just looking at the samples at both sides of the zero crossings and interpolating the zero crossings from this data. The measurements could be averaged over multiple zero crossings to improve the accuracy. This seems a little crude. Does anyone have a simple more elegant solution? Calculations are being performed in a SHARC so accuracy, MIPs, floating point or fixed point issues are not of too much concern. -- Al Clark Danville Signal Processing, Inc. -------------------------------------------------------------------- Purveyors of Fine DSP Hardware and other Cool Stuff Available at http://www.danvillesignal.com

# Phase measurement techniques

Started by ●February 16, 2006

Reply by ●February 16, 20062006-02-16

Al Clark wrote:> I have a customer that needs to measure the phase difference between two > signals. > > Here are some of the parameters: > > 1. The waveform is very oversampled. > 2. Each signal may have a different amplitude > 3. Averaging the result is allowable. > 4. The signal is relatively noise free. > > I know that there are FFT methods, but I think this may be more work than > necessary. > > One thought is just looking at the samples at both sides of the zero > crossings and interpolating the zero crossings from this data. The > measurements could be averaged over multiple zero crossings to improve the > accuracy. > > This seems a little crude. Does anyone have a simple more elegant solution? > Calculations are being performed in a SHARC so accuracy, MIPs, floating > point or fixed point issues are not of too much concern. > > > >If the frequency is known exactly you can modulate each signal with quadrature sine waves at the frequency, average, & take the arc tangent. I use this sort of thing quite a lot for various tasks. Come to think of it, this may work even with some frequency variation -- finding the frequency variation vs. phase accuracy is left as an exercise to the reader (or call me off line and we'll arrange a contract). You may be able to do this just by delaying one signal (call it a 'narrow-band Hilbert transform') and using the undelayed + delayed signals for the I and Q, then just do two MAC operations instead of four. If the frequency _isn't_ exactly known you could extend the bandwidth of your 90 degree phase shift enough that you wouldn't have to put the quote marks around 'Hilbert transform' -- the length of the filter you'd want to implement would start out small (1 sample?) and increase as the frequency uncertainty grew and the need for phase accuracy shrank. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Posting from Google? See http://cfaj.freeshell.org/google/

Reply by ●February 16, 20062006-02-16

"Al Clark" <dsp@danvillesignal.com> wrote in message news:Xns976C7CD1C915Caclarkdanvillesignal@66.133.129.71...>I have a customer that needs to measure the phase difference between two > signals. > > Here are some of the parameters: > > 1. The waveform is very oversampled. > 2. Each signal may have a different amplitude > 3. Averaging the result is allowable. > 4. The signal is relatively noise free. > > I know that there are FFT methods, but I think this may be more work than > necessary. > > One thought is just looking at the samples at both sides of the zero > crossings and interpolating the zero crossings from this data. The > measurements could be averaged over multiple zero crossings to improve the > accuracy. > > This seems a little crude. Does anyone have a simple more elegant > solution? > Calculations are being performed in a SHARC so accuracy, MIPs, floating > point or fixed point issues are not of too much concern. >Could you identically LPF and decimate both signals? If you know what the period is then shift the oversampled input delay on one of the streams till you get a maximum on the product of the two filter o/ps integrated over the period. It doesn't sound terribly elegant though does it? Best of luck - Mike

Reply by ●February 16, 20062006-02-16

Al Clark <dsp@danvillesignal.com> writes:> One thought is just looking at the samples at both sides of the zero > crossings and interpolating the zero crossings from this data. The > measurements could be averaged over multiple zero crossings to improve the > accuracy. > > This seems a little crude. Does anyone have a simple more elegant solution? > Calculations are being performed in a SHARC so accuracy, MIPs, floating > point or fixed point issues are not of too much concern.Estimate the time delay: http://cnx.rice.edu/content/m11243/latest/ and convert to a phase by knowing the frequency. :-) Ciao, Peter K. -- "And he sees the vision splendid of the sunlit plains extended And at night the wondrous glory of the everlasting stars."

Reply by ●February 16, 20062006-02-16

Tim Wescott <tim@seemywebsite.com> wrote in news:CvmdnR7U0vSOXmneRVn-tw@web-ster.com:> Al Clark wrote: > >> I have a customer that needs to measure the phase difference between >> two signals. >> >> Here are some of the parameters: >> >> 1. The waveform is very oversampled. >> 2. Each signal may have a different amplitude >> 3. Averaging the result is allowable. >> 4. The signal is relatively noise free. >> >> I know that there are FFT methods, but I think this may be more work >> than necessary. >> >> One thought is just looking at the samples at both sides of the zero >> crossings and interpolating the zero crossings from this data. The >> measurements could be averaged over multiple zero crossings to >> improve the accuracy. >> >> This seems a little crude. Does anyone have a simple more elegant >> solution? Calculations are being performed in a SHARC so accuracy, >> MIPs, floating point or fixed point issues are not of too much >> concern. >> >> >> >> > If the frequency is known exactly you can modulate each signal with > quadrature sine waves at the frequency, average, & take the arc > tangent. > I use this sort of thing quite a lot for various tasks. Come to > think > of it, this may work even with some frequency variation -- finding the > frequency variation vs. phase accuracy is left as an exercise to the > reader (or call me off line and we'll arrange a contract). > > You may be able to do this just by delaying one signal (call it a > 'narrow-band Hilbert transform') and using the undelayed + delayed > signals for the I and Q, then just do two MAC operations instead of > four. If the frequency _isn't_ exactly known you could extend the > bandwidth of your 90 degree phase shift enough that you wouldn't have > to put the quote marks around 'Hilbert transform' -- the length of the > filter you'd want to implement would start out small (1 sample?) and > increase as the frequency uncertainty grew and the need for phase > accuracy shrank. >OK, I think I get the idea, You are basically measuring the phase of each individual signal relative to the reference. If you know these values, you can calculate the difference between the two signals. In this case, I think the sampling rate is an integer multiple of the signal of interest, so the hilbert transform could probably be just an N sample delay. Thank you for your help. -- Al Clark Danville Signal Processing, Inc. -------------------------------------------------------------------- Purveyors of Fine DSP Hardware and other Cool Stuff Available at http://www.danvillesignal.com

Reply by ●February 16, 20062006-02-16

Hi, You can also estimate the delay by looking at the index of the maximum value of the cross-correlation between the signals. This might not be as efficient as solutions mentioned above though...but will give you an accuracy of Ts and requires no assumptions on the frequency and/or the amplitude of the signals (if your data is several periods long).

Reply by ●February 18, 20062006-02-18

Al Clark wrote:> I have a customer that needs to measure the phase difference between two > signals. > > Here are some of the parameters: > > 1. The waveform is very oversampled. > 2. Each signal may have a different amplitude > 3. Averaging the result is allowable. > 4. The signal is relatively noise free. > > I know that there are FFT methods, but I think this may be more work than > necessary. > > One thought is just looking at the samples at both sides of the zero > crossings and interpolating the zero crossings from this data. The > measurements could be averaged over multiple zero crossings to improve the > accuracy. > > This seems a little crude. Does anyone have a simple more elegant solution? > Calculations are being performed in a SHARC so accuracy, MIPs, floating > point or fixed point issues are not of too much concern. > > > >If the signal is a sine wave, the SNR is high, and you know the frequency, you can estimate the amplitude and phase by fitting it to a sine wave. For example, let x[n] be samples of your signal and let "omega" be the known radian frequency. Assume the signal can be modeled by A * sin(omega*n/Fs + phi) where A is the unknown amplitude, Fs is the sample rate, and phi is the unknown phase. Setup a system of equations: x[0] = A*sin(0+phi) x[1] = A*sin(omega*1/Fs+phi) : : Now express the model as A*sin(omega*n/Fs)cos(phi) + Acos(omega*n/Fs)sin(phi) The system can now be expressed as a matrix equation: | x[0] | | sin(omega*0/Fs) cos(omega*0/Fs) | | x[1] | | sin(omega*1/Fs) cos(omega*1/Fs) | | Acos(phi) | | : | = | : : | | Asin(phi) | | : | | : : | where the 2x1 vector on the right is unknown and the matrix and vector on the left are known. Invert the matrix to estimate the unknown vector and phi = arctan(sin(phi)/cos(phi)) Do this for both signals. Mike

Reply by ●February 18, 20062006-02-18

"Al Clark" <dsp@danvillesignal.com> wrote in message news:Xns976C7CD1C915Caclarkdanvillesignal@66.133.129.71...>I have a customer that needs to measure the phase difference between two > signals. > > Here are some of the parameters: > > 1. The waveform is very oversampled. > 2. Each signal may have a different amplitude > 3. Averaging the result is allowable. > 4. The signal is relatively noise free.Hello Al, If the signal is highly sinusoidal (dominated by a single harmonic), then a simple dot product is all you need. If the above case is true, then theta = acos ( (A dot B)/sqrt( (A dot A)*(B dot B) ) The shift in samples is just theta*period/2pi And the angular shift relative to the period is theta/2pi If your signal contains harmonics, then this method will measure them as well but with an incorrect frequency, so the result will be affected. On the other hand, if your signal is harmonic rich, then find an FFT of each signal, form a vector of Hermitian products between the two FFTs, find the argument of each of the inner product terms. Find the slope of this argument function verses frequency and this is the exact relative delay between the two signals. If you know your period, then you have the phase shift. Alteratively after finding the Hermitian inner products, then form I(omega) = real(inner product) and Q(omega) = imag(inner product), and then find (I dQ - Q dI) / (I^2 + Q^2). Finally average together all of these terms to get the delay. You may even use a weighted average for this last step where the weights come from the power density of the waveform. IHTH, Clay S. Turner> > I know that there are FFT methods, but I think this may be more work than > necessary. >This depends on the harmonic content of the waveform and the needed accuracy.