## the result of FFT question

36 posts / 0 new
Author
Message

According to FFT , if the input is real, FFT results are symmetrical (sampling point for the N, then N/2 FFT results are effective results)
My question is:
What do we have?
N frequency components or N/2 frequency components?

Sorry for my english

Not being my regular field, I'd have to dig through all the references. IIRC, "it depends" on how you do the FFT.

My reference of choice, mentioned first in
https://www.avrfreaks.net/index.p...

Quote:
Quote:

The Scientist and Engineer's Guide to Digital Signal Processing

This does get rave reviews at Amazon, but also consider this "review" if you are going to purchase a hard copy:
Quote:
A great book, but his newer edition is cheaper!, January 3, 2003 ...
Evarything that the other reviewers say is true. However, his newer book is an update with added material, improve typesetiing, and a CD with programs.
Buy the new book, which has a slightly different title, "DSP for Engineers and Scientists..."

I believe that this refers to "Digital Signal Processing: A Practical Guide for Engineers and Scientists"
ISBN: 075067444X

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

1. Wrong forum, not AVR related.

2. Real-FFT-input then FFT-Output: N/2 complex values
(real + imaginary part or phase+amplitude)

what about "the DFT transforms N discrete-time samples to the same number of discrete frequency samples"(http://cnx.org/content/m12019/la...)?
Are the DFT results different form FFT results?

The real samples are in the real array, you zero the imaginary array... lets say 1024 samp in real array... after fft, take magnitude of 512 real and imag components, the remaining lines are the mirror image of the first 512 lines.

Imagecraft compiler user

the result of FFT and DFT are identical, FFT just takes some shortcuts and reuses values that will always be the same(and there is not one single method for FFT, you have several)

It is true that you will get N results for N data, but only N/2 are meaningful.

so can we say that if the input sample is real,the frequency components are always mirrored(is that true in reality)?

.....

JChristoff
Illinois

Last Edited: Sat. Dec 18, 2010 - 01:00 PM

if the sample nuumber is N,the sample rate is M,
it can Calculate N frequency components,and its Resolution is M/N, then 0 to N/2 frequency components is mirrored to N/2 to N frequency components.
Is that true?
thanks all you gays

True.

(but because of the mirroring i´d say there are N/2 frequency components)

To calculate the amplitude of each frequency you have to square both, the real and the imaginary part, add them and take the squareroot.

Klaus
********************************
Look at: www.megausb.de (German)
********************************

"but because of the mirroring i´d say there are N/2 frequency components"
If that is true,its Resolution should be 2*M/N.
Is it true?
it confuses me

With a FFT you can calculate frequencies up to the half sample frequency.

with a sample frequency of 10.000 Hz and a 1024 FFT you
get 512 frequencies from 0 Hz (DC), up to 511*f-sample/1024= 4990Hz with equal stepsize/bandwidth of f-sample/1024 = 9.766Hz.

Klaus
********************************
Look at: www.megausb.de (German)
********************************

thank you
it makes senses to me now.
but I still don't know why,is there any article concerning this?

Google or try the recommended book.

Also nyquist says that you only can recognize frequencies up to f-sample/2.

Klaus
********************************
Look at: www.megausb.de (German)
********************************

Quote:
from 0 Hz (DC), up to 511*f-sample/1024= 4990Hz
I recall that the FFT produces "amplitude only" for 0.000 Hz (DC) and 5000 Hz (Nyquist) since neither has any phase information. By convention the amplitude at Nyquist is stored as the phase of the DC component. Or did it originate there by definition? Sorry, don't recall.

EDIT: rather the Nyquist amplitude is stored as the imaginary component of the DC pair.

C: i = "told you so";

Here i´m not sure - maybe i misunderstood something:
I don´t think the FFT gives any result for nyquist frequency.
In my eyes the DC component has no phase information.

Klaus
********************************
Look at: www.megausb.de (German)
********************************

It's been a few years, but this is what I remember:

Nyquist theorem provides for information at half the sample rate, not half the sample rate less the line width.

Say you sample a pure 5000 Hz signal at 10000 Hz. Depending on the phase of sampling versus the signal, the amplitude of the samples will represent a triangle wave at the correct frequency but with amplitude from 0% to 100%. (However, phase cannot be detected with two points.)

Relying on such information is probably foolish. This is also true for results in the neighborhood of Nyquist. Depending on the application 10 samples per cycle may be a limit, or 3 samples, but you are allowed to use down to and including 2.

C: i = "told you so";

DFT:
As JGRUNT said, do some hand calculations to
understand what happens. For example N=4
(DFT Matrix obtainable from Wikipedia)

Then transoform input sequence (1,-1,1,-1)
(What frequency ?)

Or Transform (i,i,i,i)
(What frequency, what phase ?)

Nyquist:
The Nyquist Sampling Theorem says under which
circumstances you can reconstruct a continous
time-signal from samples. It has not directly
something to do with DFT.

Read books or articles from the web ! Take

Quote:

Read books or articles from the web ! Take

Gee, I wish >>I<< would have thought to take the time to post a link to a definitive, free, quality reference.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

Quote:
Relying on such information is probably foolish. This is also true for results in the neighborhood of Nyquist. Depending on the application 10 samples per cycle may be a limit, or 3 samples, but you are allowed to use down to and including 2.

with an FFT you have a number of samples. let´s say 1024. The FFT not only sees 2 or 3 points. It takes all points into account.
if you now have a signal at 511/1024*f_sample you plot the points than you see the amplitude varying from 0 to 100%.
But the POINTS are not what nyquist or the mathematics says. You have to form it into a line. usually one does this with a lowpassfilter.
Often there is a simple lowpassfilter used. (especially with scopes) but the mathematics says that for reconstruting the true signal you need an sin(x)/x filter. This filter takes care of the varying amplitude and indeed forms back a constant amplitude sinewave.
But an exach sin(x)/x filter is impossible to build. neither possible in digital nor in analog. So one (the high end analog freaks) try to get as close as possible to the filter. usually with both analog and digital techniques.
On one side i like the idea to reconstruct the (audio) signal as good as possible. On the other side i can not hear those high frequencies, and one can not hear the difference/(resolution) of the 9Hz at those high frequencies.
(because the FFT works with equal distances and the human ear works with multiplying frequencies - one ocatve is i multiply by 2 in frequency)

And with digital scopes it is something different than with audio. Here some scope use the effects of undersampling and the shifted frequencies. One (ab-)uses the nyquistin a special way to visualise frequencies often far above nyquist- and even sampling-frequency.
Here one can neither work with anti-aliasing filters nor with sin(x)/x reconstruction filters.

Klaus
********************************
Look at: www.megausb.de (German)
********************************

Quote:
Nyquist:
The Nyquist Sampling Theorem says under which
circumstances you can reconstruct a continous
time-signal from samples. It has not directly
something to do with DFT.

True. They play together - but don´t harm each other.

Klaus
********************************
Look at: www.megausb.de (German)
********************************

Quote:
FFT not only sees 2 or 3 points. It takes all points into account.
Sorry to not be clear on this. I didn't mean 2 or 3 points in a frame, but 2 or three points defining the content of the higher frequencies of the spectrum.

Again, sampling a 5000 Hz sinusoidal signal at 10000 Hz provides an estimate of content (amplitude only) as long as the sampling does not fall exactly at the zero crossings; in such case the samples will be all zero.

On the other hand, a 5001 Hz signal will be lost (aliased) entirely as the sampled waveform will appear to be something like a 1 Hz sinusoid.

But as you state, in most cases you'd better be filtering well below Nyquist or the analysis will be faulty.

EDIT: Wrong, a 5001 Hz signal will be aliased into 4999 Hz signal.

C: i = "told you so";

Are you sure the FFT result includes f_sample/2?

I´m just imagine an 8 sample FFT with a samplerate of 16000Hz
gives 4 results and the mirrors of them:
0Hz (=DC)
2000Hz
4000Hz
6000Hz
6000Hz mirrored
4000Hz mirrored
2000Hz mirrored
0Hz (DC) mirrored

Am i wrong here?
For sure you can run a DFT for 8000Hz, but - as you said - the result of it is useless.

************
Yes, it must be 4999Hz

Klaus
********************************
Look at: www.megausb.de (German)
********************************

Consider the first element of the resulting complex array, i.e. the DC value. Obviously there is no phase so you would expect the real component to give the DC amplitude, and the imaginary component to always be zero.

I checked my FFT routine and the imaginary component evaluated to a non-zero value in proportion to the amplitude at the Nyquist frequency. (If sampled at zero phase the samples were all zero and of course the imaginary component of the DC element was also zero.)

C: i = "told you so";

Quote:
Consider the first element of the resulting complex array, i.e. the DC value. Obviously there is no phase so you would expect the real component to give the DC amplitude, and the imaginary component to always be zero.

I see, makes sense now.

Klaus
********************************
Look at: www.megausb.de (German)
********************************

For me its not obvious, that DC has no phase.
Imagine: imaginary DC (Input i,i,i,i,i,i,,,,,).

Well, in terms of Fourier analysis I think DC has no phase. Perhaps it can be more complicated when you consider that the elements of the complex result represent lines of the spectrum and therefore a range of frequencies.

So say your SR=1000 Hz, frame size is 1024, then each line of the spectrum "covers" 0.976563 Hz. The DC element then is presumably a statistical average of all frequencies from 0 up to but not including df (0.976563).

So any signal content at 0.5 Hz say DOES have phase, however, the FFT will be unable to discern (quantify) it. You could use a larger frame size so that df = 0.488281 Hz and the second complex value will provide phase information for 0.5 Hz.

This could be verified easily with matlab but sorry, I don't have time.

C: i = "told you so";

?

JChristoff
Illinois

Last Edited: Fri. Jan 21, 2011 - 04:07 AM

Quote:
what's the phase of -5VDC or 5*cos(2*pi*0*n/N + pi)
What no answer yet? Let's make it multiple choice:
a) 0 b) PI
c) 42

C: i = "told you so";

2*pi*0*n = 0, 0/(N + pi) = 0, 5*cos(0) = 5
OR, if you meant...
2*pi*0*n = 0, (0/N) + pi) = pi, 5*cos(pi) = -5
a, b or c you say?

I have coded for about 2 dozen architectures, and they all have their place.
Don't get too religious about them (but AVR is excellent!)

Or:

d) Undefined

C: i = "told you so";

Now I think I see your point, jgrunt.

The phase of the DC component can indeed vary from zero to pi based on the polarity of the real term of the complex result.

So, the phase of a +V is 0 and the phase of -V is 180 degrees...?

C: i = "told you so";

One can measure the phase with the help of time difference and the wavelength/period time.
DC has infite period time and inifinite wavelength.
Also with DC you can not measure time difference.

Short: DC has no phase (-shift).

Klaus
********************************
Look at: www.megausb.de (German)
********************************

Assume you have a multiplying mixer followed by a
low-pass. (Usual RF-front-end) You feed
the mixer with the local-oscillator signal (LO)
and the RF-signal happens to have the same frquency as
the LO. What frequency has the mixer output signal ?

Has it a phase ?

Or better: If you know the
amplitude of the input-signal and of the LO and the
mixer-gain. What can you knowledge is contained
in the mixer-output-signal.

But if you compare the FFT results for a postive signal versus a negative (constant) their phases will differ by 180 degrees.

For a complex FFT result C(i) = re(i) + j Im(i) the phase angle is given by:

`phase = atan2( Im(i), Re(i) );`

While the imaginary term Im(i) is zero at DC, re(i) may be negative or positive; therefore the phase may be 0 or 180 degrees.

C: i = "told you so";