DSPRelated.com
Forums

FFT phase

Started by john john December 31, 2006
Ron N. ha scritto:

> john john wrote: > > Every frequency has a proper > > phase. I need to reference this phase with something? > > Yes. For instance, a weekly cosine wave starting with phase 0 > at Sunday midnight will not be the same as a cosine wave starting > with phase 0 at Monday noon. A phase of 0 tells you little without > a reference point. You will also need a direction if you have a > time machine which can go in either direction (past or future).
Very romantic fft explanation.
PRECISELY how are you generating the triangle and square waves?

Dirk

john john wrote:
> Ron N. ha scritto: > > > > > The phase of what with reference to what? > > Midnight 1/1/2007 GMT? Or some other point in time? > > > > > > IMHO. YMMV. > > -- > > rhn A.T nicholson d.0.t C-o-M > > We have a waveform from a certain number of data, tell 1024. From this > waveform you can have a lot of different frequencies. Right? Ok. No > think at magnitude. Is not important now. Every frequency has a proper > phase. I need to reference this phase with something? Can you show me > how? In my calculation I find negative frequecies. Possible? In this > days I've searched this informations in the web but I've seen that is > impossible to find a code (c, vb, fortran etc) that explain it. I can't > believe at this. > > Look here at my results: > > Triangular waveform > > N Magnitude Phase > 0) 0.000000 0.000000 > 1) 103.753218 -90.045649 > 2) 0.000000 0.000000 > 3) 11.528425 90.045649 > 4) 0.000000 0.000000 > 5) 4.150441 -90.045649 > 6) 0.000000 0.000000 > 7) 2.117732 90.045649 > 8) 0.000000 0.000000 > 9) 1.281225 -90.045649 > 10) 0.000000 0.000000 > 11) 0.857788 90.045649 > 12) 0.000000 0.000000 > 13) 0.614248 -90.045649 > 14) 0.000000 0.000000 > 15) 0.461450 90.045649 > 16) 0.000000 0.000000 > 17) 0.359332 -90.045649 > 18) 0.000000 0.000000 > .................... > 1023)............. > > Square wave > > N Magnitude Phase > 0) 0.000000 0.000000 > 1) 318.310386 -89.869779 > 2) 0.000000 0.000000 > 3) 106.104793 -89.518038 > 4) 0.000000 0.000000 > 5) 63.664474 -89.166297 > 6) 0.000000 0.000000 > 7) 45.476336 -88.814556 > 8) 0.000000 0.000000 > 9) 35.372260 -88.462816 > 10) 0.000000 0.000000 > 11) 28.942756 -88.111075 > 12) 0.000000 0.000000 > 13) 24.491869 -87.759334 > 14) 0.000000 0.000000 > 15) 21.228151 -87.407593 > 16) 0.000000 0.000000 > 17) 18.732602 -87.055852 > 18) 0.000000 0.000000 > 19) 16.762643 -86.704112 > 20) 0.000000 0.000000 > 21) 15.168105 -86.352371 > 22) 0.000000 0.000000 > 23) 13.851052 -86.000630 > 24) 0.000000 0.000000 > 25) 12.744888 -85.648889 > 26) 0.000000 0.000000 > 27) 11.802748 -85.297148 > 28) 0.000000 0.000000 > 29) 10.990697 -84.945407 > 30) 0.000000 0.000000 > ........................ > 1023).... > > what about.
john john wrote:
> Ron N. ha scritto: > >> The phase of what with reference to what? >> Midnight 1/1/2007 GMT? Or some other point in time? >> >> >> IMHO. YMMV. >> -- >> rhn A.T nicholson d.0.t C-o-M > > We have a waveform from a certain number of data, tell 1024. From this > waveform you can have a lot of different frequencies. Right? Ok.
... Not necessarily OK. In order to use the usual tools of DSP, your signal needs to have an upper-frequency limit. Have you imposed one? Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Jerry Avins ha scritto:
> > Not necessarily OK. In order to use the usual tools of DSP, your signal > needs to have an upper-frequency limit. Have you imposed one? > > Jerry > -- > Engineering is the art of making what you want from things you can get. > =AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=
=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF No upper frequency limit imposed. Are you telling about fundamental frequency? dbell ha scritto:
> PRECISELY how are you generating the triangle and square waves? > > Dirk
Those are two different waveform and two different arrays of data. // Triangular wave x =3D 0; for(int i=3D0;i<256;i++) { glb.trw[i] =3D x++; } for(;i<768;i++) { glb.trw[i] =3D x--; } for(;i<1024;i++) { glb.trw[i] =3D x++; } // Square wave x =3D 500; for(int i=3D0;i<512;i++) { glb.sqw[i] =3D x; } x =3D -500; for(;i<1024;i++) { glb.sqw[i] =3D x; }
john john wrote:
> Jerry Avins ha scritto: >> Not necessarily OK. In order to use the usual tools of DSP, your signal >> needs to have an upper-frequency limit. Have you imposed one?
> No upper frequency limit imposed. Are you telling about fundamental > frequency?
No. The spectra of square and triangular waves are infinite series. Computers can't deal with infinities. If you truncate the series, the waveforms you get might surprise you. What are you trying to see? Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
CkplcnJ5IEF2aW5zIGhhIHNjcml0dG86Cgo+Cj4gTm8uIFRoZSBzcGVjdHJhIG9mIHNxdWFyZSBh
bmQgdHJpYW5ndWxhciB3YXZlcyBhcmUgaW5maW5pdGUgc2VyaWVzLgo+IENvbXB1dGVycyBjYW4n
dCBkZWFsIHdpdGggaW5maW5pdGllcy4gSWYgeW91IHRydW5jYXRlIHRoZSBzZXJpZXMsIHRoZQo+
IHdhdmVmb3JtcyB5b3UgZ2V0IG1pZ2h0IHN1cnByaXNlIHlvdS4KPgo+IFdoYXQgYXJlIHlvdSB0
cnlpbmcgdG8gc2VlPwo+Cj4gSmVycnkKPiAtLQo+IEVuZ2luZWVyaW5nIGlzIHRoZSBhcnQgb2Yg
bWFraW5nIHdoYXQgeW91IHdhbnQgZnJvbSB0aGluZ3MgeW91IGNhbiBnZXQuCj4gr6+vr6+vr6+v
r6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+v
r6+vr68KCkkga25vdyBhYm91dCBpbmZpbml0ZSBzZXJpZXMgYW5kIEkgZG9uJ3QgY3V0IHRoZSBz
ZXJpZXMuIEknbSBqdXN0CnRyeWluZyB0byBzZWUgdGhlIGZyZXF1ZW5jeSBzcGVjdHJ1bSBvZiBh
IHdhdmVmb3JtIGJ1dCBldmVyeSBmcmVxdWVuY3kKd2l0aCBpdHMgY29ycmVjdCBwaGFzZS4gSSB3
b24ndCB0aGUgaW5maW5pdGUgYnV0IGp1c3QgdGhlIGZpcnN0cyB0ZW4KZnJlcXVlbmN5Lgo=

Steve Underwood wrote:

> I guess you haven't worked in defense,
i haven't and they would never have me.
> ... or you'ld know lots of really evil ways to use DFTs.
i guess every good thing can be corrupted. r b-j
john john wrote:

> dbell ha scritto: > > > PRECISELY how are you generating the triangle and square waves? > > > > Dirk > > Those are two different waveform and two different arrays of data. > > > // Triangular wave > > x = 0; > for(int i=0;i<256;i++) > { > glb.trw[i] = x++; > } > > for(;i<768;i++) > { > glb.trw[i] = x--; > } > > for(;i<1024;i++) > { > glb.trw[i] = x++; > } > > > // Square wave > > x = 500; > > for(int i=0;i<512;i++) > { > glb.sqw[i] = x; > } > > x = -500; > > for(;i<1024;i++) > { > glb.sqw[i] = x; > }
presuming the size of your FFT is N=1024, these are both periodically synced waveforms (the FFT length is precisely the same as the waveform period) and they are odd symmetry about 0 (meaning sin terms, no cos terms). the implication of the first fact is that, in fact, there are no windowing issues. you are literally using the DFT to map one periodic function in "time" with period N=1024, to another periodic function in "frequency" with the same period. the bin at 0 represents your DC component, the bins at 1 and N-1 have the magnitude and phase of your fundamental, the bins at 2 and N-2 have the magnitude and phase of your 2nd harmonic, etc (all magnitudes perhaps scaled up by a factor of N). there is no effect of windowing here. the implication of the second fact (the odd symmetry) is that the real parts of all of the bins are 0 (no energy in the cosine terms) meaning that the phase angles will be at +/- pi/2 or +/- 90 degrees. i just realized that the square wave isn't *perfectly* odd symmetry (so there will be a tiny amount in the real parts and the phase angles won't be exactly +/- pi/2 unless you must set glb.sqw[0] and glb.sqw[N/2] to zero, and then the square wave is perfectly odd symmetry and this applies).
> Jerry Avins ha scritto: > > > > Not necessarily OK. In order to use the usual tools of DSP, your signal > > needs to have an upper-frequency limit. Have you imposed one? > > > > No upper frequency limit imposed. Are you telling about fundamental > frequency?
this won't be an issue for your synchronized case, but if you generate triangle and square waves that same way that are not synchronized to the length of the FFT (and presumably window), those waveforms can be thought of as uniformly sampled from an ideal analog triangle and square waves which have harmonics that go up to infinity. all implied harmonics that are over the Nyquist frequency will fold back upon the base band and screw up the spectrum. this is why properly generated digital triangle, sawtooth, and square waves have some visible evidence of Gibbs phenomena (little ripples in the waveform) because they are generated in such a way as to deliberately bandlimit the ideal analog waveform. r b-j