FFT IFFT

Mehmet Ozan Ünal edited this page Jan 25, 2017 · 9 revisions
Clone this wiki locally

Theory

detailed info

Arduino example

FFT and IFFT functions require 2 arguments. data data lenght Do not forget to add #include "simpleDSP_fft.h"

  FFT(data,DATA_LEN);
  IFFT(data,DATA_LEN);
  calcTime = millis()-startTime;
  Serial.print("Total calculation time: ");
  Serial.println(calcTime);

Performance of implementation

Arduino Nano

  • fft 16 points: 2 ms
  • fft 32 points: 6 ms
  • fft 64 points: 16 ms

Arduino Due

  • fft 64 points: 2 ms
  • fft 128 points: 6 ms
  • fft 256 points: 10 ms

Octave Code

This code create sample data and plot the signal and its fft. The octave code only needed for testing of function.

N=255;
f1=800;
f2=3200;
fo=10000;
for i=1:1:N
x(i)=1000*cos(2*pi*f1*i/fo)+1000*cos(2*pi*f2*i/fo);
printf("%d\n",x(i));
end
plot(x);
X=abs(fft(x));
figure;
kor=(1:N)*fo/N;
plot(kor,X);

Output from octave

you can use octave from here