Phase Difference of Sampled WavesDate: 05/27/2002 at 09:21:31 From: Sean Goddard Subject: Extracting Phase information Hi Dr. Math, OK, I'm no kid, and my maths is way too rusty to be of use to anyone (me included). My problem is that I have two SIN waves which I have sampled into my PC, and I need to find the LAG/LEAD of the second with respect to the first (reference). What I'm trying to do is return the result in the form of a phasor, so I obviously need to be looking in using an I and Q system. I'm trying to give a number in the range of -90 to +90 for the phase shift, with an accuracy of +/- 0.1 degrees. I'm REALLY struggling, and have derived something that sort of works, but not very well. Please help! Date: 05/29/2002 at 14:01:15 From: Doctor Douglas Subject: Re: Extracting Phase information Hi, Sean, It's a little difficult to answer this fully without knowing more about your system. However, if we know that the two sine waves are of the same frequency (they'd better be, otherwise their phase difference will be changing with time), then you can do the following: 1. Find the period T (in say, sampling intervals) of both waves. You can use zero-crossings to do this. 2. Determine a zero-crossing time Z of the first wave. 3. Starting from that time Z, step forward until the next event of the SECOND wave crossing zero with the same polarity (i.e. both crossings are positive-going or both are negative-going). Call this time Y. Note that T, Z, and Y are all measured in number of sampling intervals and that Y >= Z. 4. The number P = [360] * [(Y-Z)/T] (degrees) will be the phase measurement that you require, where 360 is the number of degrees in a full period, and the numbers Y, Z, and T are derived from your measurements. If the number P is greater than 180, then you can subtract 360 from it to get a number in the range -180 to +180. I think you want to consider this range rather than just the range from -90 to +90. To get the accuracy that you require, the numbers Y, Z, and T will need to be of sufficient accuracy. Roughly speaking, you'll want T to be at least 3600 sampling intervals (360/0.1). More is better (longer period sine waves or faster sampling). I don't think that there's any need to make things more complicated with a in-phase and quadrature (if that's what you meant by I-Q) analysis. - Doctor Douglas, The Math Forum http://mathforum.org/dr.math/ |
Search the Dr. Math Library: |
[Privacy Policy] [Terms of Use]
Ask Dr. Math^{TM}
© 1994-2015 The Math Forum
http://mathforum.org/dr.math/