DSPRelated.com
Forums

Measuring small phase diffrences between two sampled signals.

Started by Unknown December 4, 2012
robert bristow-johnson <rbj@audioimagination.com> writes:
> [...] > and you need to *normalize* which means another method of estimating > the amplitude of both sinusoids. > > and the cosine function has a slope of zero at zero which makes it a > little bit sloppy, numericially, for small phase differences. little > errors in computing the normalized inner product become big errors in > phase difference if the phase difference is small. and those little > errors can come from little errors in estimating the amplitude.
Prexactly! This is why I don't like such methods. -- Randy Yates Digital Signal Labs http://www.digitalsignallabs.com
On Thursday, December 13, 2012 12:08:28 PM UTC-5, robert bristow-johnson wrote:
> On 12/13/12 9:07 AM, clay wrote: > > > > > > A simple way to make such a 45 degree phase shift FIR filter is detailed in this article: > > > > > > http://www.claysturner.com/dsp/ASG.pdf > > > > > > nice paper. i've seen it before. > > > > setting aside the constant delay offset, we know we can get a -45 > > degree by mixing direct and quadrature. but they gotta be the same > > amplitude or the amplitude differences will result in a phase shift > > deviation from the -45 degrees. > > > > even though the amplitude won't be perfectly flat, we can make a > > (delayed) Hilbert transformer have a perfect -90 degree shift (in > > addition to the linear phase from the given delay). and i can make a > > perfect linear phase plus 0 degree shift, but the amplitude again won't > > be perfectly flat and may not match the amplitude of the Hilbert leg of > > this. > > > > i am curious, Clay, without reading it too much in detail (i know i > > should), does your method try to match the amplitudes of the two > > together to minimize the phase deviation from 45 after combining? > > > > we can make it so that the +45 and -45 have the exact same amplitude at > > each frequency (but it might not be flat). but can we make it so that > > they hit 45 degrees as well as we can hit 90 degrees? or is that simply > > an error tolerance that we design under? > > > > > > > p.s. The normalized inner product as given by Vlad is an excellent starting point for finding the angle between the vectors. > > > > it's a beginning, but it doesn't tell you which signal lags or leads the > > other. not without some other help. > > > > and you need to *normalize* which means another method of estimating the > > amplitude of both sinusoids. > > > > and the cosine function has a slope of zero at zero which makes it a > > little bit sloppy, numericially, for small phase differences. little > > errors in computing the normalized inner product become big errors in > > phase difference if the phase difference is small. and those little > > errors can come from little errors in estimating the amplitude. > > > > > > > > -- > > > > r b-j rbj@ > > > > "Imagination is more important than knowledge."
If you are worried about whether or not input stream "b" leads or lags stream "a", that is a different yet related problem to finding the angular difference between the streams. The simplicity of the inner product method swallows the direction of the phase difference. My approach to the +-45 degree filters matches the amplitudes, but the phase shifts depart from |45| degrees by a small amount which is reduced by lengthening the filter - easy with my method. A linear phase FIR filter has certain symmetry requirements to meet and a 45 degree one can't exactly satisfy them. Clay
Do a sine-wave curve-fit on both signals. You will get A, w, and feta for both signals. Subtract the phases. 
This even works with short time records. You can supply initial estimates based on zero-crossings. 


Bob
>Hello guys,=20 >thanks for the speedy responses guys. The phase measurement is to be
perfor=
>med after the signals are acquired and saved. The noise levels are
moderate=
> although this needs to be quantified. The frequency remains constant
throu=
>gh out. I was thinking of introducing equal phase delay to both signals
and=
> then try and measure the minute delay that i am after. cheerio. zoul >
Since it is offline work then using matlab dsp I will interpolate the two signals as high as to achieve phase resolution, align them using xcorr then find out the difference in phase. x1 = interp(x1,10); x2 = interp(x2,10); y = xcorr(x1,x2); n = find(y == max(y)); thus n indicates phase difference in samples(after some manipulation and all that is left is the sense of this difference). Additionally any noise can be filtered off before xcorr. Kadhiem
On 12/13/12 3:09 PM, Robert Adams wrote:
> Do a sine-wave curve-fit on both signals. You will get A, w, and feta for both signals. Subtract the phases. > This even works with short time records. You can supply initial estimates based on zero-crossings.
that is an idea i never thunk nor heard before. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
On Thu, 13 Dec 2012 17:15:52 -0500, robert bristow-johnson
<rbj@audioimagination.com> wrote:

>On 12/13/12 3:09 PM, Robert Adams wrote: >> Do a sine-wave curve-fit on both signals. You will get A, w, and feta for both signals. Subtract the phases. >> This even works with short time records. You can supply initial estimates based on zero-crossings. > >that is an idea i never thunk nor heard before.
I saw this implemented in LabView SignalExpress as the method to align sinewaves or other signals in the measurement windodw before FFT. I think it was called "Interactive Alignment" or something. For the type of testing I do Synchronous demodulation (Lock-In Amplifier) seems to give the best phase SNR. Mark DeArman