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

Thread: Teensy 3.6 with Electret Microphone (MAX914) with auto gain

  1. #1

    Teensy 3.6 with Electret Microphone (MAX9814)

    Hi all,

    This is my first post at PJRC forum.

    I am new to teensy and have experience working on just the particle photon. I have a computer science background and new to the world of micro-controllers.

    I am trying to take input from an electret microphone and show it on Serial Monitor. I have connected the microphone as follows:
    teensy 3.6--> MAX9814 electret microphone
    GND--> GND
    3v3--> vdd
    A2--> out
    GND-->Gain

    I am able to get peak values but they look random and garbage. I tried connecting out pin to GND to check if i get 0 as peak but it still shows the same random values. I have also tried removing the entire connection of out to A2 but it still has its random values.

    Please help. I can provide additional information as required. Maybe a pin diagram or image of some sort if needed. I am using sample code for peakMeterMomo.ino for testing microphone.

    Thank you for your time!
    Last edited by kkiokio; 03-12-2017 at 05:47 AM. Reason: Microphone 9814 without adjustable gain

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    10,598
    Perhaps make/post a sketch showing your efforts to read and track the analog value from A2.

  3. #3
    Quote Originally Posted by defragster View Post
    Perhaps make/post a sketch showing your efforts to read and track the analog value from A2.
    Unable to upload a sketch of the setup. The upload button does not appear. It shows browse and then when i browse the image from my computer it doesnt have any other button to upload that image.

    Click image for larger version. 

Name:	Untitled.png 
Views:	2401 
Size:	565.8 KB 
ID:	9921

    code used:

    Code:
    /* Mono Peak Meter
    
       Scrolling peak audio level meter in the Arduino Serial Monitor
    
       Audio input needs to connect to pin 16 (A2).  The signal range is 0 to 1.2V.
       See the documentation in the Audio System Design Tool for the recommended
       circuit to connect an analog signal.
    
       This example code is in the public domain
    */
    
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    // GUItool: begin automatically generated code
    AudioInputAnalog         adc1;           //xy=164,95
    AudioAnalyzePeak         peak1;          //xy=317,123
    AudioConnection          patchCord1(adc1, peak1);
    // GUItool: end automatically generated code
    
    
    void setup() {
      AudioMemory(4);
      Serial.begin(9600);
    }
    
    // for best effect make your terminal/monitor a minimum of 31 chars wide and as high as you can.
    
    elapsedMillis fps;
    
    void loop() {
      if (fps > 24) {
        if (peak1.available()) {
          fps = 0;
          int monoPeak = peak1.read() * 30.0;
          Serial.print("|");
          for (int cnt=0; cnt<monoPeak; cnt++) {
            Serial.print(">");
          }
          Serial.println();
        }
      }
    }
    Last edited by kkiokio; 03-08-2017 at 03:04 PM. Reason: aded code used

  4. #4
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    10,598
    It may be browser hiding the function - but it is there to browse and upload files. Perhaps try the 'Go Advanced' for posting. Also on that page is a "#" hash mark to wrap posted code in tags to make it more readably formatted:

  5. #5
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,209
    Press the button on the teensy.

  6. #6
    Senior Member
    Join Date
    Jun 2013
    Location
    Torrance CA
    Posts
    397
    Back up to make sure your hardware is working. Do something really simple like this:

    Code:
    void setup(void) {
    Serial.begin(9600);
    }
    
    void loop(void) {
    Serial.println(analogRead(A2));
    delay(10);
    }
    In a quiet room the number should stay about the same. Loud noises should make it move more. If that's not what you see, check your connections.

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,322
    This product's 1.25V offset is problem.

    The Teensy Audio lib's ADC input uses a 0 to 1.2V range, expecting a 0.6V offset.

    It's probably going to need a hardware mod to change the offset to 0.6V, similar to this one:

    https://forum.pjrc.com/threads/40468...l=1#post126317

  8. #8
    Quote Originally Posted by potatotron View Post
    Back up to make sure your hardware is working. Do something really simple like this:

    Code:
    void setup(void) {
    Serial.begin(9600);
    }
    
    void loop(void) {
    Serial.println(analogRead(A2));
    delay(10);
    }
    In a quiet room the number should stay about the same. Loud noises should make it move more. If that's not what you see, check your connections.

    The output I get is in the range of 300-500 in my lab, when everyone is quiet. I also saw it drop down in the range of 25-45. I dont know which one are legit. also what do they even mean?

  9. #9
    Quote Originally Posted by PaulStoffregen View Post
    This product's 1.25V offset is problem.

    The Teensy Audio lib's ADC input uses a 0 to 1.2V range, expecting a 0.6V offset.

    It's probably going to need a hardware mod to change the offset to 0.6V, similar to this one:

    https://forum.pjrc.com/threads/40468...l=1#post126317
    The link shows the use of MAX4466 component.
    The one I am using is a MAX9814 microphone.Would that make a difference?

    Also I am not a hardware electronic guy, is there another way around it?

    The microphone now wors but it gives me wither values in the range of 200-500 or 25-45 when presseddown.

  10. #10
    Senior Member
    Join Date
    Jun 2013
    Location
    Torrance CA
    Posts
    397
    Quote Originally Posted by kkiokio View Post
    The output I get is in the range of 300-500 in my lab, when everyone is quiet. I also saw it drop down in the range of 25-45. I dont know which one are legit. also what do they even mean?
    A few things.

    First, in a quiet environment your Teensy should read around 390: the DC bias of the module is 1.25 Volts and your Teensy is running at 3.3 Volts; 1.25 / 3.3 * 1024 = 388. It will never be exact because of line power noise, random fluctuations, etc. but it should be close to that.

    When the microphone picks up noise the readings will fluctuate higher and lower, if you read & mapped them out fast enough you'd see a sine wavey output like this: http://www.tropicalcoder.com/Sine.gif

    So, if you're seeing big fluctuations in a quiet environment then check all your connections, power supply etc. because the noise is coming from something.

    Second, per Paul's earlier message ultimately you're going to need to make a change to your microphone module to use it with the Teensy audio library. The library is expecting a 0.6 Volt bias, meaning in perfectly quiet environment it would read 0.6 Volts, and when it hears sounds the output would swing between 0 Volts and 1.2 Volts. Converting this to numbers you'd see on analogRead(), quiet would read as 186 (0.6 / 3.3 * 1024), and noises would swing between 0 and 372 (1.2 / 3.3 * 1024).

  11. #11
    A few things.

    First, in a quiet environment your Teensy should read around 390: the DC bias of the module is 1.25 Volts and your Teensy is running at 3.3 Volts; 1.25 / 3.3 * 1024 = 388. It will never be exact because of line power noise, random fluctuations, etc. but it should be close to that.

    When the microphone picks up noise the readings will fluctuate higher and lower, if you read & mapped them out fast enough you'd see a sine wavey output like this: http://www.tropicalcoder.com/Sine.gif
    Yes I am getting the readings as predicted above. I was also able to set up a threshold kin of limit so i can eliminate noise. I triggered a print statement when
    Code:
    previous_analogRead()-50<current_analogRead()<previous_analogRead()+50
    It worked and it responded to specific sound events around me.

    So, if you're seeing big fluctuations in a quiet environment then check all your connections, power supply etc. because the noise is coming from something.
    is it necessary to get rid of fluctuations or can i just work around them? I am trying to do sound localization. Do you think fluctations would make a lot of difference?


    Second, per Paul's earlier message ultimately you're going to need to make a change to your microphone module to use it with the Teensy audio library. The library is expecting a 0.6 Volt bias, meaning in perfectly quiet environment it would read 0.6 Volts, and when it hears sounds the output would swing between 0 Volts and 1.2 Volts. Converting this to numbers you'd see on analogRead(), quiet would read as 186 (0.6 / 3.3 * 1024), and noises would swing between 0 and 372 (1.2 / 3.3 * 1024).
    I am stuck between the though of using a library or just writing my own code, what do u suggest. I am above average with coding languages and I am fairly certain I might be able to write a descent working code without much of library support.


    I had some questions I wanted to ask,
    1. Is it possible to take simultaneous input from 4 microphone son teensy 3.6?
    2. Would I need an external power supply for the microphones? or Is teensy capable of supplying power to all 4 microphones?
    3. Would i need to sync the inputs all 4 microphones or would it happen automatically?
    4. Can i collect data from microphones in a continuous stream like a background process or would i have to iterate through the microphone inputs and then process it and loop the above process to mimic a continuous stream of data?


    I really appreciate the input and explanation especially about the voltages and the reason why i would nee to mod my microphone. Is there a simple enough tutorial i can follow, how do i find it. i am not aware of the keywords i might need to look it up-.

    Thank you potatotron, , defragster, PaulStoffregen and Frank B. I appreciate all your inputs and your time.


    Rural hack has a similar project made by kripthor called MicLoc. I want to recreate this project and make it my own and build up on it using teensy 3.6.
    http://ruralhacker.blogspot.com/p/micloc.html
    Last edited by kkiokio; 03-10-2017 at 03:27 PM. Reason: added micloc info

  12. #12
    Member
    Join Date
    Jan 2017
    Location
    Pella, Iowa, USA
    Posts
    85
    Quote Originally Posted by kkiokio View Post
    I really appreciate the input and explanation especially about the voltages and the reason why i would nee to mod my microphone. Is there a simple enough tutorial i can follow, how do i find it. i am not aware of the keywords i might need to look it up-.
    kkiokio - I'm working on a microphone module that is intended to run as quiet as possible and also output the signal with a 0.6VDC bias suitable for the Teensy. I have an Alpha prototype that I can send you for testing, if you have time. You can check it out some of the details on the Teensy Microphone forum topic. If interested, just send me a private message and I'll send you one for testing.

  13. #13
    Quote Originally Posted by Neutronned View Post
    kkiokio - I'm working on a microphone module that is intended to run as quiet as possible and also output the signal with a 0.6VDC bias suitable for the Teensy. I have an Alpha prototype that I can send you for testing, if you have time. You can check it out some of the details on the Teensy Microphone forum topic. If interested, just send me a private message and I'll send you one for testing.
    I would love that. Thank you!

    I have sent you a message, please check your inbox.

Posting Permissions

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