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

Thread: fft doesn't run fft.available() always returns 0

  1. #1
    Junior Member
    Join Date
    Mar 2016
    Posts
    2

    fft doesn't run fft.available() always returns 0

    Hi guys,
    I m trying a simple project with Teensy 3.1. I want to read and adc input and perform an fft on it. For troubleshooting I cutout all the irrelevant code and I am left with this.

    The problem is that myFFT.available() call always returns a 0.

    I have an adafruit electret microphone I am powering from the teensy 3.3Vout. I can disconnect it - no difference. I know the code runs since the LED blinks and I do get some output on the serial monitor.

    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>

    // GUItool: begin automatically generated code
    AudioInputAnalog adc1;
    AudioAnalyzeFFT1024 myFFT;
    AudioConnection patchCord1(adc1, 0, myFFT, 0);
    // GUItool: end automatically generated code
    float level[16];

    void setup() {
    // put your setup code here, to run once:

    Serial.begin(115200);
    AudioMemory(12);
    pinMode(10, OUTPUT);

    // Configure the window algorithm to use
    myFFT.windowFunction(AudioWindowHanning1024);
    }

    void loop() {
    // put your main code here, to run repeatedly:
    Serial.println("start: ");
    digitalWriteFast(10, !digitalReadFast(10));
    Serial.println(myFFT.available());
    delay(100);
    level[1] = myFFT.read(1);
    Serial.println(level[1]);
    Serial.print(" cpu:");
    Serial.println(AudioProcessorUsageMax());
    // delay(1000);
    }

    Any thoughts on why I keep getting myFFT.available() always = 0?

    Thanks

  2. #2
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,386
    The question is if the signal of the electret microphone is strong enough... You could check that with your oscilloscope or by connecting the DAC output directly to the ADC input as a kind of "monitor" function. Or you take your function generator and feed a 400Hz 1Vpp sine wave into the ADC.

  3. #3
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,161
    Quote Originally Posted by dimivb01 View Post
    I have an adafruit electret microphone I am powering from the teensy 3.3Vout. I can disconnect it - no difference. I know the code runs since the LED blinks and I do get some output on the serial monitor.
    Are you sure the put the actual code here ?
    Teensy3.1 LED is on pin 13 and not Pin10.

    please give a functioning code that demonstrates the problem
    Last edited by WMXZ; 03-08-2016 at 07:55 AM.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,942
    Make sure you have the CPU speed set to 96 MHz.

  5. #5
    Junior Member
    Join Date
    Mar 2016
    Posts
    2
    Thanks Paul. It seems the clock speed was the problem. I set it to 96MHz and now I can read values. YAY!

Posting Permissions

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