[dagr] DFT/FFT question

  • From: Chuck McManis <chuck.mcmanis@xxxxxxxxx>
  • To: dagr@xxxxxxxxxxxxx
  • Date: Fri, 12 May 2017 14:37:23 -0700

Hi All,

Being inspired by Mike's videos and my current job is deep into SDRs I have
embarked on internalizing a crap ton of analog stuff I just 'memorized,
regurgitated, and forgot' in college. Specifically the analysis of signals
using transforms. I'm writing this email in part to "explain to someone
else" what I'm trying to do in order to develop insights in where I may be
going wrong, and if you happen to know the answer that is good too :-)

To that end I've been reading papers, and general descriptions, of the
theory and practice of fourier transforms. I subsequently wrote, debugged,
and re-wrote a discrete fourier transform routine that used correlation to
transform my (artificially) generated signal from the time domain to the
frequency domain.

My generated signal is stored in an array of 1024 samples with a nominal
'sampling rate' of 8192 hz. And I fill the array with the output of a cos
function set for 300 hz and an amplitude of 1.0 (so +/- 1.0 values into an
array of floats).

When I run my DFT over 512 bins, and plot the magnitude of the 512 complex
numbers that DFT produces, I get pretty much exactly what I expected, a
large peak centered around bin 300 falling off exponentially to two much
smaller peaks on either side, then two much smaller peaks on either side of
those down to a slightly wavy line along 0. I've plotted the output on a
nice display on a microprocessor and took a picture of it here:
https://goo.gl/photos/rcxFHCeQ18bdR7766

I then take the exact same data and apply my Fast Fourier Transform code to
it. And what I get is in that same picture (the lower half). Two peaks,
very far apart. Still 512 bins, same data. Clearly it is "different" than
the DFT result and I'm struggling to figure out why.

One person suggested "Oh that is the positive and negative versions of the
frequency." And yes when i do my bit reversal sort to take in my signal I
have the imaginary part set to zero (the signal (an array of floats) gets
translated into a an array of complex where the imaginary component is
zero. But even with that "explanation" Neither "half" of that display looks
like the DFT display.
I also tried doing 1024 bins and looking at the magnitude of the first 512
and last 512 bins, they both are very different.

It is really confusing the heck out of me.
--Chuck

Other related posts: