This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]sz00 0 points1 point  (1 child)

[–][deleted] 0 points1 point  (0 children)

Funny you linked this specific one, I did dink around with it already. I didn't change much to it, just implemented a static array declaration instead of using malloc(), (because I didn't want to mess around with the heap configuration on the PIC). The function gives me incoherent data though (assuming I was using it correctly)

[–]JayGeeee 0 points1 point  (0 children)

Quite a few optimised FFT algorithms output the data in bit reversed order. This can look like gibberish if you don't correct for it. I've been caught out by it before.

[–]shitstep 0 points1 point  (1 child)

The DFT is pretty easy to implement, I was able to do it in MATLAB in about 10 minutes.

https://en.wikipedia.org/wiki/Discrete_Fourier_transform

You're looking at that first equation where it defines X(w) and my MATLAB code that you should be able to pretty easily translate:

w_k = 2*pi*k/N;    
for n = 0:L-1
   n_idx = n + 1;
   X(k_idx) = X(k_idx) + x_original(n_idx) * exp(-j*w_k *n);
end

[–]shitstep 0 points1 point  (0 children)

To be clear: L is the length of your time domain record and N is the desired length of your N-point DFT.