Chuck, to me the FFT looks correct and the DFT not so much. The FFT
looks like it starts at 0 Hz, goes to +nyquist, then -nyquist toward
zero, that is pretty typical of FFTs. If you want 0 to be in the center
you just take the right half and move it to the left side. "fftshift"
is a typical name of a function that would do that for you. (So I
concur with the other person)
Why are you bit-reversing? Did you write your own FFT? You are not
doing that for the DFT are you?
When you say you are using correlation for the DFT, do you mean summing
the product of the input sequence with a sinusoid at the bin frequency?
(aka the standard DFT definition)
Why 1024 samples and 512 DFT/FFT? Is it safe to assume that you are only
using the first 512 samples of the 1024 length array?
In your DFT are you ignoring negative frequencies? E.g. Not correlating
for negative frequencies, so only 256 outputs?
DFT or FFT, you can only get 256 positive frequencies from 512 samples.
Hopefully this helps somehow.
On 05/12/2017 03:37 PM, Chuck McManis wrote:
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.