Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Pages: [1]   Go Down
Author Topic: fft music labs basic question  (Read 721 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,
I'm new with the arduino and im trying to do an FFT using the music labs library. (until now nothing makes sense). My final objective is to be able to store a 1500:1 size vector, and then perform an fft in that vector, and then do an inverse fft. First question, does this library allows me to do an inverse fft?
Ive been playing with the basic example provided (fft_adc) but i dont really understand what it is doing. specially what is the output supposed to be and how im i supposed to see it? I put a 4 khz sine in adc0, and checked out the serial monitor but all I saw is random characters, Im not sure whats that smiley-sad also I noticed the serial monitors baud rate is set to 9600, do i need to change that to 115200 to match the code?
I would really appreciate ANY help! thank you so much!

* fft_adc.pde (1.53 KB - downloaded 19 times.)
Logged

Oregon, USA
Offline Offline
Faraday Member
**
Karma: 74
Posts: 2590
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

First of all, you don't have enough RAM on a typical Arduino to perform an FFT on a vector of length 1500, and second, the Open Music Labs code accomodates vectors of length 256 maximum.

It is good to experiment as you are doing, but you do need to know the difference between Serial.write(), which outputs binary to the console, and Serial.print(), which outputs ascii formatted numbers. If you want to look at the output of the transform, you will need to rewrite that section of the code to loop through the 256 elements of the array and print them out using Serial.print()

Of course, the baud rates need to match between the Arduino and the monitor.
Logged

"It seems to run on some form of electricity"

Offline Offline
Edison Member
*
Karma: 51
Posts: 1734
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Replace this:
Code:
    Serial.write(255); // send a start byte
    Serial.write(fft_log_out, 128); // send out the data
with this:
Code:
    Serial.println("Start");
    for(int i = 0;i < 128;i++) {
    Serial.println(fft_log_out[i]);
    }
    delay(10000);
This will print the results on the serial monitor and the delay will give you a bit of time to look at the output before the loop starts again.
That library does not appear to have a function to do an inverse FFT.

You need to set the serial monitor to 115200 baud.

Pete
Logged

Offline Offline
Faraday Member
**
Karma: 62
Posts: 3085
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The vector of samples for the FFT has to be a power of 2  (  64, or 128,  or 256,  or 512 samples, etc ).   On the arduino you are limited to 256.

The range of frequencies you can analyze is limited by the sample rate you can perform,  the Nyquist theorum,  and the number of samples.
Logged

Pages: [1]   Go Up
Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Jump to: