Internal ADC + FFT?

Status
Not open for further replies.

StefanPetrick

Well-known member
Hello,

I´d like to do some FFT tests. I don´t have an Audio Adaptor Board.

So, how to start? I found the Audio System Design Tool for Teensy Audio Library. I guess there I have to connect the ADC input to the fft256 analyze module.

Copy the code into the Arduino IDE and try to adapt the FFT example.

Hardware: The audio input into the circuit as described in the Audio System Design Tool information - 4 restistors, 2 capacitors, input to A2.

Is there any obvious mistake in this plan? Or an important step I missed so far?

Thanks for any hint!

Stefan
 
Yeah, that's pretty much it. The audio library is designed to let you connect any of its components together pretty much any way you like.

Unless you have Teensy 3.0, you might as well use the 1024 point FFT. It gives 4X better resolution. Teensy 3.1 & 3.2 are plenty fast enough to do 1024 points.

The examples mostly use the audio shield, but they still may be helpful to show how the rest is done. Look at File > Examples > Audio > Analysis > FFT.
 
Similar issue here :D

Yeah, that's pretty much it. The audio library is designed to let you connect any of its components together pretty much any way you like.

Unless you have Teensy 3.0, you might as well use the 1024 point FFT. It gives 4X better resolution. Teensy 3.1 & 3.2 are plenty fast enough to do 1024 points.

The examples mostly use the audio shield, but they still may be helpful to show how the rest is done. Look at File > Examples > Audio > Analysis > FFT.
Howdy Paul, thanks in advance for surf this forum answering everything.

I tried to use the audio design tool and connected ebverything but FFT.available returns 0 :(
This is my .ino , on the serial monitor i get no fft available all the time....
I just want a FFT of my ADC input (its not going to be audio, just analog signal up to 250hz);
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>



AudioInputAnalog         myadc;           
AudioAnalyzeFFT1024      myfft;      
AudioConnection          patchCord1(myadc, myfft);


void setup(){
  Serial.begin(38400);
  Serial.println("FFT example : ");
  myfft.windowFunction(AudioWindowHanning1024);
}

void loop() {
  float n;
  int i;

  if (myfft.available()) {
    // each time new FFT data is available
    // print it all to the Arduino Serial Monitor
    Serial.print("FFT: ");
    for (i=0; i<40; i++) {
      n = myfft.read(i);
      if (n >= 0.01) {
        Serial.print(n);
        Serial.print(" ");
      } else {
        Serial.print("  -  "); // don't print "0.00"
      }
    }
    Serial.println();
  }else{
  Serial.println("no fft available");
  delay(100);
  }

}

Sin título.png
 
Last edited:
IT worked

in setup() try adding AudioMemory(12);
It worked like a charm!, thanks.
Sin título.png

I didnt undestand how Audio system patches all together but i do now, i found this wich was helpful for me.


Is it a good idea to change the sampling Frecuency (inside the library AudioStream.h) so i get a narrower BW (down to 500hz for example) with the same 512 values so there is an increase on resoltion?
Now resolution would be 1hz
Sin título.png
 
Last edited:
Is it a good idea to change the sampling Frecuency (inside the library AudioStream.h) so i get a narrower BW (down to 500hz for example) with the same 512 values so there is an increase on resoltion?

Changing the sampling frequency isn't easy. Not impossible either, but requires quite a bit of fiddling...

However, consider the loss of temporal resolution that comes with the increase in spectral resolution. A 1024 point FFT using 500 Hz sample rate will span 2 seconds of input data. If you're analysis is something like astronomy radio telescope signals, this finer resolution is probably worth the loss of timing. But for music, 2 seconds will usually span at least a few different notes and percussive events (beats of the music). Probably not useful for anything other than perhaps instrument tuning (which is much better done with the YIN algorithm than FFT).

This trade-off between temporal versus spectral resolution is a fundamental aspect of the Fourier Transform math. No amount of crafty software or wishful thinking can get around it. You could try other ways than FFT, but for Fourier Transform any increase in resolution for the spectrum comes at a cost of doing the analysis over a longer period of time.
 
Status
Not open for further replies.
Back
Top