Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: Internal ADC + FFT?

  1. #1

    Internal ADC + FFT?

    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

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,745
    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.

  3. #3
    Member javiernicola's Avatar
    Join Date
    Apr 2018
    Location
    Madrid
    Posts
    20

    Similar issue here :D

    Quote Originally Posted by PaulStoffregen View Post
    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);
      }
    
    }
    Click image for larger version. 

Name:	Sin título.png 
Views:	99 
Size:	14.2 KB 
ID:	13647
    Last edited by javiernicola; 04-21-2018 at 08:08 PM. Reason: MORE PICTURES!! yaay

  4. #4
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,588
    in setup() try adding AudioMemory(12);

  5. #5
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,584
    Quote Originally Posted by manitou View Post
    in setup() try adding AudioMemory(12);
    AudioMemory is absolutely needed.

    A German proverb says that the best horse cannot fart without eating hay.

  6. #6
    Member javiernicola's Avatar
    Join Date
    Apr 2018
    Location
    Madrid
    Posts
    20

    IT worked

    Quote Originally Posted by manitou View Post
    in setup() try adding AudioMemory(12);
    It worked like a charm!, thanks.
    Click image for larger version. 

Name:	Sin título.png 
Views:	81 
Size:	11.0 KB 
ID:	13649

    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
    Click image for larger version. 

Name:	Sin título.png 
Views:	96 
Size:	29.9 KB 
ID:	13651
    Last edited by javiernicola; 04-22-2018 at 11:54 AM.

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,745
    Quote Originally Posted by javiernicola View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •