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

Thread: Teensy3.0/3.1 Audio Library Perform FFT on analoginput pin without Audio Shield

  1. #1
    Junior Member
    Join Date
    Dec 2014
    Posts
    5

    Teensy3.0/3.1 Audio Library Perform FFT on analoginput pin without Audio Shield

    Hi,

    I have a question regarding perform FFT on an analogpin pin on Teensy3.0 without using the Audio Shield.

    In the Audio System Design Tool, when using the acd1 block, in the info section, there is a recommended circuitry to use. May I know the purpose of this circuitry. Can't I just connect a microphone breakout board (http://www.adafruit.com/product/1063) directly to the teensy (Gnd, 3.3V and A2). Is it because the default signal range used by the audio library is 0 to 1.2V? So the circuit is used to bias the microphone signal output to fluctuate between 0 to 1.2? In that case is it possible to change this signal range to 0 to 3.3V instead so that I can do away with those additional resistors and capacitors in the microphone circuit.

    Another question... I just want to perform a 1024 point FFT on a signal picked up by an external eletrect microphone. What advantage is there to use the audio shield as compared to just connecting the microphone directly to the analoginput pin on the teensy? I am looking at a sampling rate of 44100 Hz. If I were to use the audio shield, should I connect the microphone to the mic input or to the line in input? The microphone breakout board from Adafruit already has the biasing circuit.


    Cheers,
    Kian

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,395
    Quote Originally Posted by kian79 View Post
    Is it because the default signal range used by the audio library is 0 to 1.2V?
    Yes, exactly.

    If your signal already has a 0.6V DC offset, and if it's approx the right level, you could connect it directly.

    In that case is it possible to change this signal range to 0 to 3.3V instead so that I can do away with those additional resistors and capacitors in the microphone circuit.
    It may be possible with quite a bit of hacking in the code, to change the ADC reference.

    But there's no "easy" way to change this, without editing the library code.


    What advantage is there to use the audio shield as compared to just connecting the microphone directly to the analoginput pin on the teensy?
    The mic input on the audio shield has a bias current circuit those microphones require, and an amplifier to increase its signal.


    If I were to use the audio shield, should I connect the microphone to the mic input or to the line in input? The microphone breakout board from Adafruit already has the biasing circuit.
    You could probably connect Adafruit's amplified signal to the line-in input. The default input range is also about 1.2V, but with the audio shield, that range is easily changed.

    http://www.pjrc.com/teensy/gui/?info...ontrolSGTL5000

    On the right panel, scroll down to "Signal Levels". You'd use lineInLevel() to adjust the audio shield's line-in to approx match whatever output Adafruit's product sends.

  3. #3
    Junior Member
    Join Date
    Dec 2014
    Posts
    5
    Thanks Paul for the reply.

    Just to further followup on this, is it possible to achieve similar performance of having 44.1kHz sampling rate and 1024 point FFT without using the audio shield and just connecting the mic to an analog input pin?

    There is an example of performing FFT on a Teensy3.0 on Adafruit tutorial:
    https://learn.adafruit.com/fft-fun-w...forms/hardware

    They did not use the library, but instead just used the CMSIS library directly. In trheir codes, they only achieve 9kHz sampling rate with a 256 point FFT. In the codes, there was a comment:
    // Size of the FFT. Realistically can only be at most 256
    // without running out of memory for buffers and other state.

    So how did the audio library achieve a much higher sampling rate and higher number of FFT points? Does the audio library use the same CMSIS library?

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,395
    Quote Originally Posted by kian79 View Post
    So how did the audio library achieve a much higher sampling rate and higher number of FFT points?
    Teensy 3.1 has 64K of RAM.

    That old article was written when only Teensy 3.0 existed, with only 16K of RAM.

  5. #5
    Member
    Join Date
    Nov 2014
    Location
    Italy
    Posts
    34
    hello,
    I'm also working on the same solution discussed by kian79 on a Teensy 3.1, and I tried to set a different size of FFT in the adafruit sketch. Strangely if I set the FFT_SIZE on 512, I cannot read the serial. If I set it on 1024, the sketch works even if not as fluid as the original, but printing the results on serial stopping for a few tenths of a second between some prints and others.
    It is not a problem, but I wonder if it is not using bad the memory and this can not cause some unexpected error (that I didn't found after a few tests).
    Do you have any idea or suggestion about it? I have to change some parameters to properly use the memory?
    Thanks
    Last edited by GeppettoLab; 12-17-2014 at 03:01 PM.

Posting Permissions

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