I have a single pulse of a frequency, say X cycles in length, this pulse occurs between times t1 and t2 of a timeline starting from t=0. I need to monitor the location of this pulse, and to do this I do a DFT for the frequency in question. This nicely gives me the phase of the signal which I can easily convert to an accurate time. My problem is that sometimes the signal will shift by more than half a cycle and so give me a negative phase, or positive if it shifts by a whole cycle. So my question is, is there any way to account for the phase shift? (if that's the correct phrase). Thanks, Joseph
phase wrap
Started by ●September 20, 2007
Reply by ●September 20, 20072007-09-20
Since you're using FFT anyway, the following is a brute-force solution. It uses cyclic crosscorrelation between signal and reference: result=ifft(fft(signal) .* conj(fft(ref))) result: a complex vector with the same length. Find the peak => pulse location. Amplitude and phase of the pulse, scaled down with the power in ref, give the amplitude and phase of signal relative to ref. -mn
Reply by ●September 20, 20072007-09-20
On Sep 20, 12:47 pm, JB <josephby...@yahoo.com> wrote:> I have a single pulse of a frequency, say X cycles in length, this > pulse occurs between times t1 and t2 of a timeline starting from t=0. > > I need to monitor the location of this pulse, and to do this I do a > DFT for the frequency in question. This nicely gives me the phase of > the signal which I can easily convert to an accurate time. My problem > is that sometimes the signal will shift by more than half a cycle and > so give me a negative phase, or positive if it shifts by a whole > cycle. > > So my question is, is there any way to account for the phase shift? > (if that's the correct phrase). > > Thanks, > > JosephA different approach: do you know the starting phase of the pulse? If it is the same every time, you could matched-filter the pulse, then do a peak search in the output to find the location. Jason
Reply by ●September 20, 20072007-09-20
On Sep 20, 12:47 pm, JB <josephby...@yahoo.com> wrote:> I have a single pulse of a frequency, say X cycles in length, this > pulse occurs between times t1 and t2 of a timeline starting from t=0. > > I need to monitor the location of this pulse, and to do this I do a > DFT for the frequency in question. This nicely gives me the phase of > the signal which I can easily convert to an accurate time. My problem > is that sometimes the signal will shift by more than half a cycle and > so give me a negative phase, or positive if it shifts by a whole > cycle. > > So my question is, is there any way to account for the phase shift? > (if that's the correct phrase).in the DFT output, you'll get a phase shift of pi (or 180 degrees) when there is a polarity reversal in the data. often the data has a zero crossing and then *would* go negative, but the magnitude of the DFT goes back positive (magnitudes are always non-negative) and that polarity reversal is absorbed in the phase by shifting it suddenly by pi. if you don't like it, whenever there is a jump discontinuity of pi in the phase, add (or subtract, it doesn't matter) the pi back so the discontinuity is removed, but then, to be legit, you have to negate the magnitude for those DFT bins where you added or subtracted pi. r b-j
Reply by ●September 20, 20072007-09-20
Reminds me... I've got a matched filter example here. http://www.elisanet.fi/mnentwig/webroot/optimum_receiver/index.html There's also a reference to a similar thread. -mn
Reply by ●September 20, 20072007-09-20
"JB" <josephbyrns@yahoo.com> wrote in message news:1190306872.354784.16100@d55g2000hsg.googlegroups.com...>I have a single pulse of a frequency, say X cycles in length, this > pulse occurs between times t1 and t2 of a timeline starting from t=0. > > I need to monitor the location of this pulse, and to do this I do a > DFT for the frequency in question. This nicely gives me the phase of > the signal which I can easily convert to an accurate time. My problem > is that sometimes the signal will shift by more than half a cycle and > so give me a negative phase, or positive if it shifts by a whole > cycle. > > So my question is, is there any way to account for the phase shift? > (if that's the correct phrase). > > Thanks, > > Joseph >Using phase of a pulse to determine time of occurrence is a strange way to approach this problem - at least in many applications. The comments about matched filters actually allude to this although indirectly. The ability to determine temporal location is proportional to the time-bandwidth product of the pulse - and a pure tone has a time-bandwidth product of 1.0 more or less. Usually the measurement is all about the temporal location of the pulse. Consider this example: A 2GHz pulse of length 1 microsecond will have 2000 periods in it. A single cycle is of length 5*10^-10 and 10 degrees of phase covers a span of 1/36th of this or 1.389*10^-11. The pulse is 10^-6 so there is a factor of 7.2*10^4 difference between the pulse length and 10 degrees of phase. In many applications it's unlikely to select such a long pulse length if the measurement accuracy needed is higher than that. A matched filter integrates across the length of the pulse - and then you look for the peak which is probably determinable in the 10's of percent of the total length of the pulse. If the pulse is square then it has more bandwidth than if it's shaped. If the receiver bandwidth is adequate to allow the sharp edges of the pulse to be seen, then sometimes one can determine delay by detecting the leading edge of the pulse. That's often much more precise than averaging over the length of the pulse. It depends on signal to noise ratio too. Nonetheless, this is less precise than using a phase measurement IF the phase measurement can be done without ambiguity - which is the problem you've asked about. In continuous FM radar the attempt is to compare the frequency currently being sent vs. the frequency of returns. Since the frequency sweeps at a known rate, the range or temporal difference is thus determined. In some of these, a mixer generates a low-frequency signal whose frequency is proportional to the difference. Maybe phase isn't the way to go. But maybe your application allows it. Note I didn't say anything about DFTs. Fred
Reply by ●September 20, 20072007-09-20
On Sep 20, 9:47 am, JB <josephby...@yahoo.com> wrote:> I have a single pulse of a frequency, say X cycles in length, this > pulse occurs between times t1 and t2 of a timeline starting from t=0. > > I need to monitor the location of this pulse, and to do this I do a > DFT for the frequency in question. This nicely gives me the phase of > the signal which I can easily convert to an accurate time. My problem > is that sometimes the signal will shift by more than half a cycle and > so give me a negative phase, or positive if it shifts by a whole > cycle. > > So my question is, is there any way to account for the phase shift? > (if that's the correct phrase).There is an FFT-based method call time-frequency reassignment, where you do two FFT's, one windowed and one with a ramp modulated window. The ratio between the two FFTs gives some information about the time or position of the centroid of the energy near each frequency bin. This will help if you can get a position within one cycle, in addition to your phase information. If your frequency is not bin centered, you may also need to break the FFT into odd/even referenced components and do phase interpolation between bins. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M http://www.nicholson.com/rhn/dsp.html
Reply by ●September 20, 20072007-09-20
Unfortunately I don't know anything about the pulse before it arrives, and it's location does not vary slowly over time, so I can't just look for a sudden large phase shift. @mnentwig/Fred Marshall, the reason I went with the DFT was the accuracy it gives, looking at the matched filter example provided by mnentwig, it seems the resolution of the accuracy is at best 1/ SampleRate, is this correct? With the DFT, if I shift the phase of the pulse by 0.5 * 1/SampleRate, then I can see this in the resultant phase from the DFT. It would have been nice to just count the number of phase shifts and simply add this value to the time from the phase (i.e. NumPhaseShifts * TimePerCycle + PhaseTime). Thanks, Joseph
Reply by ●September 20, 20072007-09-20
On Sep 20, 9:47 am, JB <josephby...@yahoo.com> wrote:> I have a single pulse of a frequency, say X cycles in length, this > pulse occurs between times t1 and t2 of a timeline starting from t=0. > > I need to monitor the location of this pulse, and to do this I do a > DFT for the frequency in question.X cycles of a frequency in the same as a rectangular window X periods wide on a continuous sinusoid. You could look for the transform of this rectangular window, a Sinc, in the complex frequency domain after a DFT, and perhaps do some sort of least squares or successive approximation fit. The width and "twist" of the found Sinc envelope may give you some information about your rectangular pulse width and location relative to the DFT aperture, in cycles. A more exact phase you can get from the interpolated peak of the Sinc. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M http://www.nicholson.com/rhn/dsp.html
Reply by ●September 20, 20072007-09-20
"JB" <josephbyrns@yahoo.com> wrote in message news:1190320861.298362.273590@w3g2000hsg.googlegroups.com...> Unfortunately I don't know anything about the pulse before it arrives, > and it's location does not vary slowly over time, so I can't just look > for a sudden large phase shift. > > @mnentwig/Fred Marshall, the reason I went with the DFT was the > accuracy it gives,Accuracy? What accuracy are you referring to? The *information* should remain the same (DFT or not) although there may be observations you can make on the data one way or the other that are useful. Here you're trying to do a time domain determination. So, just how does the DFT help do that? Just to be clear: "Phase" in a DFT is relative to time=0 in *the sample taken* and there can be phase wraps at that. Not that I'd suggest it but there are some phase unwrapping methods which will at least give you a continuous phase plot and imply delay. Assuming you can get the phase unwrapped then you add that delay to the delay to the beginning of the sample epoch and that would be an estimate. Assuming this might be done in some reasonable fashion, intuition tells me that this implies way too precise a result to trust in most cases. So, there must be a flaw that I just can't pin down. I suspect it's in the phase unwrapping assumptions. Fred






