Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I determine phase difference between two signals? 1

Status
Not open for further replies.

oregonianish

Electrical
Mar 23, 2005
6
I have heard of an autocorrelation function that may work. What would the output of autocorrelation be? Specifically, I am working with six digitized audio signals input via an array of microphones in order to find the location of a speaker within a room based upon time delay of arrival. Any help would be greatly appreciated.

Danny
 
Replies continue below

Recommended for you

I think you need to look at cross-correlation rather auto-correlation. The cross-correlation of two signals x and y is a measure of how similar x is to y when y is delayed by some amount delta. If the signal at microphone 1 arrives 1ms earlier than at mic 2, then you will see a peak in the cross-correlation function at a delay time of 1ms.

M

--
Dr Michael F Platten
 
Another approach is to take the transfer function between the two mics, and then use the phase information directly.

I have a suspicion that the cross correlation technique is more accurate.

Cheers

Greg Locock

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
I have tried using the xcorr function in order to determine phase delay between two sine vectors, but the function has not returned the expected peak located at the amount of delay. Here is my code:

>> x=0:0.1:50;
>> y=sin(x);
>> y2=sin(x-1);
>> a=xcorr(y,y2);
>> plot(a)

Am I on the right track?

Danny
 
Yes it has, you are just not plotting it correctly.

try
Code:
[a,delay] = xcorr(y,y2);
plot(delay,a);
You will see a peak at -10 delays. Each delay is the same as your x increment so -10 delays is equavalent to x=-1.

Note that this is only an ESTIMATE of the cross-covariance function. The true cross-covariance between two sine waves of the same frequency but different phases is also a sine wave (the plot you see is clearly not a pure sine wave). It is not possible (except with analytical integrable functions) to obtain the true cross-covariance unless your signals extend to +/- infinity on the x axis. Making the signal longer does not really help. In practice cross-covariance functions are usually determined by measuring an estimate of the cross-spectrum and performing an inverse DFT. The Wiener-Kinchine (I think!) theorem says that the cross-spectrum and cross-covariance form a Fourier transform pair.

M

--
Dr Michael F Platten
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor