Hi Everybody, I have been attempting to implement an FFT-based spectrum analyzer using a digitizer card, the reason being: I need (relative) phase information. I have a 100 MS/s digitizer card and I use Matlab to control it. I am using an Agilent I/Q signal generator which, for simplicity, I am loading with 3 cosine tones in the I channel: one at 14.0 MHz, one at 14.5 MHz, and one at 15.0 MHz. I give each of these tones some phase, such as 30 degrees, 70 degrees, and -20 degrees, respectively. I acquire the signal and take the FFT in Matlab. The magnitude of the FFT looks good: I can see the peaks at the appropriate frequencies (and a peak at 60 Hz, lol). The phase is a problem. I cannot get any good phase information out. I have tried sophisticated peak-detection algorithms, even 9th order polynomial interpolation in the vicinity of the peak, and calculate the DFT at a non-integer bin value corresponding to the peak. The magnitudes are great, but the angles seem like garbage. I don't care about absolute phase, but I should be seeing the phase differences between the tones being close to what I set them at, but I'm not seeing this at all. Unwrapping the phase doesn't work. Does anybody have any suggestions for me? I am pulling my hair out here!!
FFT Spectrum Analyzer using Digitizer
Started by ●December 6, 2007
Reply by ●December 6, 20072007-12-06
On Dec 6, 8:21 am, "dsavio" <dsa...@ieee.org> wrote:> Hi Everybody, > > I have been attempting to implement an FFT-based spectrum analyzer using a > digitizer card, the reason being: I need (relative) phase information. I > have a 100 MS/s digitizer card and I use Matlab to control it. > > I am using an Agilent I/Q signal generator which, for simplicity, I am > loading with 3 cosine tones in the I channel: one at 14.0 MHz, one at > 14.5 MHz, and one at 15.0 MHz. I give each of these tones some phase, > such as 30 degrees, 70 degrees, and -20 degrees, respectively. > > I acquire the signal and take the FFT in Matlab. The magnitude of the FFT > looks good: I can see the peaks at the appropriate frequencies (and a peak > at 60 Hz, lol). > > The phase is a problem. I cannot get any good phase information out. I > have tried sophisticated peak-detection algorithms, even 9th order > polynomial interpolation in the vicinity of the peak, and calculate the > DFT at a non-integer bin value corresponding to the peak. The magnitudes > are great, but the angles seem like garbage. I don't care about absolute > phase, but I should be seeing the phase differences between the tones > being close to what I set them at, but I'm not seeing this at all. > Unwrapping the phase doesn't work. > > Does anybody have any suggestions for me? I am pulling my hair out > here!!Could you be getting spectral leakage from the neighbouring tones? If so, the phase will be affected. Have you tried simulating this in Matlab or something similar to see if your idea works. You may want to try an LMS type algorithm or a Phase locked loop - These are just rough ideas though and may not be applicable to your larger problem - as opposed to the one posted here. Cheers, Dave
Reply by ●December 6, 20072007-12-06
On Dec 6, 5:21 am, "dsavio" <dsa...@ieee.org> wrote:> Hi Everybody, > > I have been attempting to implement an FFT-based spectrum analyzer using a > digitizer card, the reason being: I need (relative) phase information. I > have a 100 MS/s digitizer card and I use Matlab to control it. > > I am using an Agilent I/Q signal generator which, for simplicity, I am > loading with 3 cosine tones in the I channel: one at 14.0 MHz, one at > 14.5 MHz, and one at 15.0 MHz. I give each of these tones some phase, > such as 30 degrees, 70 degrees, and -20 degrees, respectively. > > I acquire the signal and take the FFT in Matlab. The magnitude of the FFT > looks good: I can see the peaks at the appropriate frequencies (and a peak > at 60 Hz, lol). > > The phase is a problem. I cannot get any good phase information out. I > have tried sophisticated peak-detection algorithms, even 9th order > polynomial interpolation in the vicinity of the peak, and calculate the > DFT at a non-integer bin value corresponding to the peak. The magnitudes > are great, but the angles seem like garbage. I don't care about absolute > phase, but I should be seeing the phase differences between the tones > being close to what I set them at, but I'm not seeing this at all. > Unwrapping the phase doesn't work. > > Does anybody have any suggestions for me? I am pulling my hair out > here!!The three tones only have the selected phase offsets at some time t = 0. How are you synchronizing your DFT data sets to that reference time? If you aren't doing that the phases -will- look like garbage as the phase differences between tones will change as a function of time. Dale B. Dalrymple http://dbdimages.com http://stores.lulu.com/dbd
Reply by ●December 6, 20072007-12-06
"dsavio" <dsavio@ieee.org> wrote in message news:x_6dnWgfEcTcasranZ2dnUVZ_judnZ2d@giganews.com...> Hi Everybody, > > I have been attempting to implement an FFT-based spectrum analyzer using a > digitizer card, the reason being: I need (relative) phase information. I > have a 100 MS/s digitizer card and I use Matlab to control it. > > I am using an Agilent I/Q signal generator which, for simplicity, I am > loading with 3 cosine tones in the I channel: one at 14.0 MHz, one at > 14.5 MHz, and one at 15.0 MHz. I give each of these tones some phase, > such as 30 degrees, 70 degrees, and -20 degrees, respectively. > > I acquire the signal and take the FFT in Matlab. The magnitude of the FFT > looks good: I can see the peaks at the appropriate frequencies (and a peak > at 60 Hz, lol). > > The phase is a problem. I cannot get any good phase information out. I > have tried sophisticated peak-detection algorithms, even 9th order > polynomial interpolation in the vicinity of the peak, and calculate the > DFT at a non-integer bin value corresponding to the peak. The magnitudes > are great, but the angles seem like garbage. I don't care about absolute > phase, but I should be seeing the phase differences between the tones > being close to what I set them at, but I'm not seeing this at all. > Unwrapping the phase doesn't work. > > Does anybody have any suggestions for me? I am pulling my hair out > here!! >You speak as though the phase makes sense *between* the tones. If so, that's likely a problem as phase is only defined at a single frequency. There are long discussions of "relative phase" between sinusoids at different frequencies here on comp.dsp that you might look up and consider. We *can* talk about phase of each of the tones separately. When you say you give it a phase of "x" degrees then that implies a time reference where phase would be zero, sines would be zero with positive slope and cosines would be at their positive maximum. It raises the question: "how do you set that time reference in the digitizer / sampled data system?" With this, perhaps you can clarify and expand. Fred
Reply by ●December 6, 20072007-12-06
On Dec 6, 5:21 am, "dsavio" <dsa...@ieee.org> wrote:> Hi Everybody, > > I have been attempting to implement an FFT-based spectrum analyzer using a > digitizer card, the reason being: I need (relative) phase information. I > have a 100 MS/s digitizer card and I use Matlab to control it. > > I am using an Agilent I/Q signal generator which, for simplicity, I am > loading with 3 cosine tones in the I channel: one at 14.0 MHz, one at > 14.5 MHz, and one at 15.0 MHz. I give each of these tones some phase, > such as 30 degrees, 70 degrees, and -20 degrees, respectively. > > I acquire the signal and take the FFT in Matlab. The magnitude of the FFT > looks good: I can see the peaks at the appropriate frequencies (and a peak > at 60 Hz, lol). > > The phase is a problem. I cannot get any good phase information out. I > have tried sophisticated peak-detection algorithms, even 9th order > polynomial interpolation in the vicinity of the peak, and calculate the > DFT at a non-integer bin value corresponding to the peak. The magnitudes > are great, but the angles seem like garbage. I don't care about absolute > phase, but I should be seeing the phase differences between the tones > being close to what I set them at, but I'm not seeing this at all. > Unwrapping the phase doesn't work. > > Does anybody have any suggestions for me? I am pulling my hair out > here!!Unless your fft sample windows are offset by integer multiples of all of the periods of your 3 cosine waves, the relative phases will be different in every window. Why? Because frequency is the rate of change of phase. Since your phases are changing at 3 different rates, you will only see them sync up when all 3 exact period multiples align with the offset between your fft window and your phase reference point in time.
Reply by ●December 6, 20072007-12-06
>On Dec 6, 5:21 am, "dsavio" <dsa...@ieee.org> wrote: >> Hi Everybody, >> >> I have been attempting to implement an FFT-based spectrum analyzerusing a>> digitizer card, the reason being: I need (relative) phase information.I>> have a 100 MS/s digitizer card and I use Matlab to control it. >> >> I am using an Agilent I/Q signal generator which, for simplicity, I am >> loading with 3 cosine tones in the I channel: one at 14.0 MHz, one at >> 14.5 MHz, and one at 15.0 MHz. I give each of these tones some phase, >> such as 30 degrees, 70 degrees, and -20 degrees, respectively. >> >> I acquire the signal and take the FFT in Matlab. The magnitude of theFFT>> looks good: I can see the peaks at the appropriate frequencies (and apeak>> at 60 Hz, lol). >> >> The phase is a problem. I cannot get any good phase information out.I>> have tried sophisticated peak-detection algorithms, even 9th order >> polynomial interpolation in the vicinity of the peak, and calculatethe>> DFT at a non-integer bin value corresponding to the peak. Themagnitudes>> are great, but the angles seem like garbage. I don't care aboutabsolute>> phase, but I should be seeing the phase differences between the tones >> being close to what I set them at, but I'm not seeing this at all. >> Unwrapping the phase doesn't work. >> >> Does anybody have any suggestions for me? I am pulling my hair out >> here!! > >Unless your fft sample windows are offset by integer multiples >of all of the periods of your 3 cosine waves, the relative >phases will be different in every window. Why? Because >frequency is the rate of change of phase. Since your phases >are changing at 3 different rates, you will only see them >sync up when all 3 exact period multiples align with the >offset between your fft window and your phase reference >point in time. > >Thanks to everyone for your responses! I actually have been through the thought processes you have all suggested. I understand that the phases of each tone will change at different rates over time, but I propose that this is not the issue. Think about what the FFT tells us: For each tone, use this frequency at this phase to reproduce the original signal. Depending on the time instant that you start acquiring will give a different phase result for each tone, which I don't care about. The phases should, however, track eachother: ie. whatever the phases of the tones are should still differ by the same amount when compared to eachother, since those are the phases that you would need to reproduce the input signal. I DID run some Matlab simulations to test this stuff out with "ideal" signals, and what I discovered was that if you are not EXACT in your frequency peak detection, your phase information quickly becomes garbage. Even if you are off by like 20 Hz, that is enough to make your phase information garbage. But how does one detect the peak to within that accuracy? I have tried acquiring a huge number of samples to improve resolution bandwidth, and taking huge FFTs, but i still can't get good answers. I know that FFT spectrum analyzers are implemented successfully in practice, so there has to be something I'm missing here...!
Reply by ●December 6, 20072007-12-06
dsavio wrote: ...> Thanks to everyone for your responses! I actually have been through the > thought processes you have all suggested. I understand that the phases of > each tone will change at different rates over time, but I propose that this > is not the issue.It is the issue. Let's suppose for a minute that it's possible to compare the phases of two sinusoids of different frequency (it isn't). Suppose further they are 90 degrees apart. That means that when one is at a zero crossing, the other is at a positive or negative peak. (That's what quadrature implies.) If that's always true, then the frequencies must be the same. Any phase can be decomposed into an in-phase and a quadrature component, so what applies to quadrature applies to any other phase difference. ... Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by ●December 6, 20072007-12-06
>>On Dec 6, 5:21 am, "dsavio" <dsa...@ieee.org> wrote: >>> Hi Everybody, >>> >>> I have been attempting to implement an FFT-based spectrum analyzer >using a >>> digitizer card, the reason being: I need (relative) phase information.>I >>> have a 100 MS/s digitizer card and I use Matlab to control it. >>> >>> I am using an Agilent I/Q signal generator which, for simplicity, Iam>>> loading with 3 cosine tones in the I channel: one at 14.0 MHz, oneat>>> 14.5 MHz, and one at 15.0 MHz. I give each of these tones somephase,>>> such as 30 degrees, 70 degrees, and -20 degrees, respectively. >>> >>> I acquire the signal and take the FFT in Matlab. The magnitude ofthe>FFT >>> looks good: I can see the peaks at the appropriate frequencies (and a >peak >>> at 60 Hz, lol). >>> >>> The phase is a problem. I cannot get any good phase information out.>I >>> have tried sophisticated peak-detection algorithms, even 9th order >>> polynomial interpolation in the vicinity of the peak, and calculate >the >>> DFT at a non-integer bin value corresponding to the peak. The >magnitudes >>> are great, but the angles seem like garbage. I don't care about >absolute >>> phase, but I should be seeing the phase differences between the tones >>> being close to what I set them at, but I'm not seeing this at all. >>> Unwrapping the phase doesn't work. >>> >>> Does anybody have any suggestions for me? I am pulling my hair out >>> here!! >> >>Unless your fft sample windows are offset by integer multiples >>of all of the periods of your 3 cosine waves, the relative >>phases will be different in every window. Why? Because >>frequency is the rate of change of phase. Since your phases >>are changing at 3 different rates, you will only see them >>sync up when all 3 exact period multiples align with the >>offset between your fft window and your phase reference >>point in time. >> >> > > >Thanks to everyone for your responses! I actually have been through the >thought processes you have all suggested. I understand that the phasesof>each tone will change at different rates over time, but I propose thatthis>is not the issue. > >Think about what the FFT tells us: For each tone, use this frequency at >this phase to reproduce the original signal. Depending on the time >instant that you start acquiring will give a different phase result for >each tone, which I don't care about. The phases should, however, track >eachother: ie. whatever the phases of the tones are should still differby>the same amount when compared to eachother, since those are the phasesthat>you would need to reproduce the input signal. > >I DID run some Matlab simulations to test this stuff out with "ideal" >signals, and what I discovered was that if you are not EXACT in your >frequency peak detection, your phase information quickly becomes garbage.>Even if you are off by like 20 Hz, that is enough to make your phase >information garbage. But how does one detect the peak to within that >accuracy? I have tried acquiring a huge number of samples to improve >resolution bandwidth, and taking huge FFTs, but i still can't get good >answers. > >I know that FFT spectrum analyzers are implemented successfully in >practice, so there has to be something I'm missing here...! >I appologize for my previous reply: After thinking about it, I agree, unless I am completely time synced, the phases will vary. How does one usually accomplish the time syncing? My comment above about the need to pick a peak with extreme accuracy remains true, though. How is this kind of accuracy achieved with a non-ideal signal?
Reply by ●December 6, 20072007-12-06
On Dec 6, 6:32 pm, "dsavio" <dsa...@ieee.org> wrote:> >>On Dec 6, 5:21 am, "dsavio" <dsa...@ieee.org> wrote: > >>> Hi Everybody, > > >>> I have been attempting to implement an FFT-based spectrum analyzer > >using a > >>> digitizer card, the reason being: I need (relative) phase information. > >I > >>> have a 100 MS/s digitizer card and I use Matlab to control it. > > >>> I am using an Agilent I/Q signal generator which, for simplicity, I > am > >>> loading with 3 cosine tones in the I channel: one at 14.0 MHz, one > at > >>> 14.5 MHz, and one at 15.0 MHz. I give each of these tones some > phase, > >>> such as 30 degrees, 70 degrees, and -20 degrees, respectively. > > >>> I acquire the signal and take the FFT in Matlab. The magnitude of > the > >FFT > >>> looks good: I can see the peaks at the appropriate frequencies (and a > >peak > >>> at 60 Hz, lol). > > >>> The phase is a problem. I cannot get any good phase information out. > >I > >>> have tried sophisticated peak-detection algorithms, even 9th order > >>> polynomial interpolation in the vicinity of the peak, and calculate > >the > >>> DFT at a non-integer bin value corresponding to the peak. The > >magnitudes > >>> are great, but the angles seem like garbage. I don't care about > >absolute > >>> phase, but I should be seeing the phase differences between the tones > >>> being close to what I set them at, but I'm not seeing this at all. > >>> Unwrapping the phase doesn't work. > > >>> Does anybody have any suggestions for me? I am pulling my hair out > >>> here!! > > >>Unless your fft sample windows are offset by integer multiples > >>of all of the periods of your 3 cosine waves, the relative > >>phases will be different in every window. Why? Because > >>frequency is the rate of change of phase. Since your phases > >>are changing at 3 different rates, you will only see them > >>sync up when all 3 exact period multiples align with the > >>offset between your fft window and your phase reference > >>point in time. > > >Thanks to everyone for your responses! I actually have been through the > >thought processes you have all suggested. I understand that the phases > of > >each tone will change at different rates over time, but I propose that > this > >is not the issue. > > >Think about what the FFT tells us: For each tone, use this frequency at > >this phase to reproduce the original signal. Depending on the time > >instant that you start acquiring will give a different phase result for > >each tone, which I don't care about. The phases should, however, track > >eachother: ie. whatever the phases of the tones are should still differ > by > >the same amount when compared to eachother, since those are the phases > that > >you would need to reproduce the input signal. > > >I DID run some Matlab simulations to test this stuff out with "ideal" > >signals, and what I discovered was that if you are not EXACT in your > >frequency peak detection, your phase information quickly becomes garbage. > >Even if you are off by like 20 Hz, that is enough to make your phase > >information garbage. But how does one detect the peak to within that > >accuracy? I have tried acquiring a huge number of samples to improve > >resolution bandwidth, and taking huge FFTs, but i still can't get good > >answers. > > >I know that FFT spectrum analyzers are implemented successfully in > >practice, so there has to be something I'm missing here...! > > I appologize for my previous reply: After thinking about it, I agree, > unless I am completely time synced, the phases will vary. How does one > usually accomplish the time syncing? > > My comment above about the need to pick a peak with extreme accuracy > remains true, though. How is this kind of accuracy achieved with a > non-ideal signal?- Hide quoted text - > > - Show quoted text -Hello, OK I had the same thought, phase relationship only makes sense when the frequencies are the same. The phase between two different frequencies is constaly changing. OK I agree with that... but then...... what is the meaning of the phase result in an FFT? Mark
Reply by ●December 6, 20072007-12-06
On Dec 6, 3:57 pm, Mark <makol...@yahoo.com> wrote:> On Dec 6, 6:32 pm, "dsavio" <dsa...@ieee.org> wrote: > > > > > >>On Dec 6, 5:21 am, "dsavio" <dsa...@ieee.org> wrote: > > >>> Hi Everybody, > > > >>> I have been attempting to implement an FFT-based spectrum analyzer > > >using a > > >>> digitizer card, the reason being: I need (relative) phase information. > > >I > > >>> have a 100 MS/s digitizer card and I use Matlab to control it. > > > >>> I am using an Agilent I/Q signal generator which, for simplicity, I > > am > > >>> loading with 3 cosine tones in the I channel: one at 14.0 MHz, one > > at > > >>> 14.5 MHz, and one at 15.0 MHz. I give each of these tones some > > phase, > > >>> such as 30 degrees, 70 degrees, and -20 degrees, respectively. > > > >>> I acquire the signal and take the FFT in Matlab. The magnitude of > > the > > >FFT > > >>> looks good: I can see the peaks at the appropriate frequencies (and a > > >peak > > >>> at 60 Hz, lol). > > > >>> The phase is a problem. I cannot get any good phase information out. > > >I > > >>> have tried sophisticated peak-detection algorithms, even 9th order > > >>> polynomial interpolation in the vicinity of the peak, and calculate > > >the > > >>> DFT at a non-integer bin value corresponding to the peak. The > > >magnitudes > > >>> are great, but the angles seem like garbage. I don't care about > > >absolute > > >>> phase, but I should be seeing the phase differences between the tones > > >>> being close to what I set them at, but I'm not seeing this at all. > > >>> Unwrapping the phase doesn't work. > > > >>> Does anybody have any suggestions for me? I am pulling my hair out > > >>> here!! > > > >>Unless your fft sample windows are offset by integer multiples > > >>of all of the periods of your 3 cosine waves, the relative > > >>phases will be different in every window. Why? Because > > >>frequency is the rate of change of phase. Since your phases > > >>are changing at 3 different rates, you will only see them > > >>sync up when all 3 exact period multiples align with the > > >>offset between your fft window and your phase reference > > >>point in time. > > > >Thanks to everyone for your responses! I actually have been through the > > >thought processes you have all suggested. I understand that the phases > > of > > >each tone will change at different rates over time, but I propose that > > this > > >is not the issue. > > > >Think about what the FFT tells us: For each tone, use this frequency at > > >this phase to reproduce the original signal. Depending on the time > > >instant that you start acquiring will give a different phase result for > > >each tone, which I don't care about. The phases should, however, track > > >eachother: ie. whatever the phases of the tones are should still differ > > by > > >the same amount when compared to eachother, since those are the phases > > that > > >you would need to reproduce the input signal. > > > >I DID run some Matlab simulations to test this stuff out with "ideal" > > >signals, and what I discovered was that if you are not EXACT in your > > >frequency peak detection, your phase information quickly becomes garbage. > > >Even if you are off by like 20 Hz, that is enough to make your phase > > >information garbage. But how does one detect the peak to within that > > >accuracy? I have tried acquiring a huge number of samples to improve > > >resolution bandwidth, and taking huge FFTs, but i still can't get good > > >answers. > > > >I know that FFT spectrum analyzers are implemented successfully in > > >practice, so there has to be something I'm missing here...! > > > I appologize for my previous reply: After thinking about it, I agree, > > unless I am completely time synced, the phases will vary. How does one > > usually accomplish the time syncing? > > > My comment above about the need to pick a peak with extreme accuracy > > remains true, though. How is this kind of accuracy achieved with a > > non-ideal signal?- Hide quoted text - > > > - Show quoted text - > > Hello, > OK I had the same thought, phase relationship only makes sense when > the frequencies are the same. The phase between two different > frequencies is constaly changing. OK I agree with that... but > then...... what is the meaning of the phase result in an FFT?The the phase result of an FFT reports whether each bin's component sinusoid is even (symmetric), odd, or some mixed ratio of evenness/oddness, with respect to the center of the FFT aperture. The even portion will be represented by the real component, and the odd portion will appear in the imaginary component of each bin. If you try to reference to the beginning of your window, then the even/oddness about the center of your data only applies to input sinusoids which are exactly periodic in the FFT aperture. If you have known or suspected periodicities which are not clipped to exact period length boundaries by an FFT, it might be easier to look at the phases with respect to the center of the FFT aperture (or rotate the input data halfway, using something like FFTShift, so that the center of the data vector aligns with the start of the FFT aperture). Then reference cosines will stay real and reference sines imaginary, no matter what the frequency (useful for phase interpolation). IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M http://www.nicholson.com/rhn/dsp.html






