Electronic – the meaning of the fourier transform results

dspfftfilterfourierfrequency

I've been experimenting with Fourier transforms, and I'd like to understand some of the results I'm seeing.

I've written a simulator which generates a data stream of length 1/120 seconds, sampled at 33.92 nS intervals. The data represents a half-sine wave generated by an inverter. I concatenated this stream with its own negative inverse, to create a single perfectly symmetrical 60 Hz sine wave 491,352 samples long.

enter image description here

I then ran an FFT of the results using numpy. Most of the results made sense to me: the FFT was the same length as the original signal. Discrete Fourier results are symmetrical about the fundamental, so I have half that many "bins" (about 246,000) to represent harmonics. The lowest frequency content in the original signal is 60 Hz. Per Nyqist, the original signal can not represent frequencies higher than 1/(2*33.92 nS) = 14.74 MHz, which is also the roughly 246,000 harmonic of 60 Hz. So each bin represents one harmonic of the 60 Hz fundamental, with no skipped bins. If I tried transforming five full sine waves instead of just one, four out of every five bins was zero, which makes sense; those bins represent fractional harmonics, which are meaningless.

Going back to my single-wave FFT, every even-index (index from zero) entry of my FFT results is zero. Every odd entry is non-zero, with index 1 being by far the largest. This makes sense if 1 is the fundamental, because the even harmonics won't show up in a symmetrical sine wave. But why is the first entry in the FFT results not the fundamental?

After this, I applied an LC filter, by iterating through the FFT results and multiplying each bin by the filter gain at that frequency. I then did an inverse FFT, giving me the filtered time-domain signal. The result has both real and imaginary components. The real component and the imaginary component, when taken separately, each look like what I expected the time domain signal to look like: a better looking sine wave than I started with, shifted by 90 degrees relative to each other.

enter image description here

But the magnitude is pretty much constant, rather than looking at all line a sine wave. This is not at all what I was expecting. What is the significance of this result?

Best Answer

But why is the first entry in the FFT results not the fundamental?

Typically the 0'th entry stores the DC term. In some schemes, the [N/2]'th entry might be the DC term and the [N/2+1]'th entry would be the fundamental.

I applied an LC filter, by iterating through the FFT results and multiplying each bin by the filter gain at that frequency. I then did an inverse FFT, ... The result has both real and imaginary components.

Did you consider the phase effect of the filter? You should be multiplying by a complex value accounting for both the magnitude and phase response of the LC filter.

Even then, due to finite precision issues, you will often still get non-zero imaginary components in the inverse-transformed time-domain signal. But usually these are very small, for example on the order of \$10^{-15}\times\$ the real components. These are usually dealt with by simply ignoring them (taking the real part of the result only). Some tools even offer a built-in function (Mathematica's Chop, for example) to eliminate these artifacts.