Friday 12 February 2016

Arduino Signal Experiment #2 FFT Analysis using Arduino

From the previous blog, we were able to see signals in the  time domain. Now, we will try to analyze things in frequency domain. I will be using this FFT Library  http://wiki.openmusiclabs.com/wiki/ArduinoFFT  . To start with, I created three different sine waves on Audacity (I will be sticking to sine waves to avoid the unwanted harmonics of a square wave):


The three different sine waves are: 200Hz, 625Hz and 850Hz. I also opened the built-in Frequency Analyzer of Audacity for us to have an idea of what those 3 frequencies are.

This is the code that I wrote for Arduino  http://codepad.org/UnFPb87k

On the code, notice that I used 450usec on the delay. This value is ideal for the 3 target frequencies that I will generate from Audacity and this is the explanation: The FFT bin size is 256. The output array will be FFT bin size divided by 2 (256/2 = 128). In this case, my array dimension is from 0 to 127.
@ array 0,  index * (1/T) / binsize = 0 * (1/450usec) / 256 = 0 Hz
@ array 1,  1 * (1/450usec) / 256 = 8.680555555555555 Hz
@ array 2,  2 * (1/450usec) / 256 = 17.36111111111111 Hz
@ array 127,  127 * (1/450usec) / 256 = 1102.4305555555554 Hz

Which means, I will be measuring only up to 1102 Hz.

Now, after I played the tones and measured it using the Arduino program, I tried to plot the values using OpenOffice Calc:


We can clearly see that the FFT works as shown by the rise on the magnitude on 200Hz, 625Hz and 850Hz. :)

No comments:

Post a Comment