×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How can I determine phase difference between two signals?

How can I determine phase difference between two signals?

How can I determine phase difference between two signals?

(OP)
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

RE: How can I determine phase difference between two signals?

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

RE: How can I determine phase difference between two signals?

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.

RE: How can I determine phase difference between two signals?

(OP)
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

RE: How can I determine phase difference between two signals?

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources