0

Comparing the output of two MAX4466's
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Comparing the output of two MAX4466's

by zheng3 on Sat Aug 27, 2016 10:10 am

right mic: pin 0 left mic pin 1:

r0_l1.png
r0_l1.png (24.05 KiB) Viewed 273 times


right mic: pin 1 left mic pin 0

r1_l0.png
r1_l0.png (27.94 KiB) Viewed 273 times


And just to see if it's pin 0 that's somehow gone bad, I tried with pins 2 and 3 instead.



right mic: pin 2, left mic pin 3

2_3.png
2_3.png (28.2 KiB) Viewed 273 times


and swapping 2 and 3 reverses the results.

zheng3
 
Posts: 20
Joined: Sun Jul 19, 2015 1:42 pm

Re: Comparing the output of two MAX4466's

by adafruit_support_bill on Sat Aug 27, 2016 1:02 pm

Not sure which trace corresponds to which pin, but it seems like the problem follows the microphone when you swap pins. One of the microphones only responds when tapped & the other responds when either is tapped - regardless of the pin connections. Is that accurate?

If you post some close-up photos of both boards, we can check them over for any manufacturing or assembly problems.

adafruit_support_bill
 
Posts: 61065
Joined: Sat Feb 07, 2009 10:11 am

Re: Comparing the output of two MAX4466's

by zheng3 on Sat Aug 27, 2016 3:05 pm

One of the microphones only responds when tapped & the other responds when either is tapped - regardless of the pin connections. Is that accurate?


Yes, that is correct.

a2.jpg
a2.jpg (124.84 KiB) Viewed 260 times

b2.jpg
b2.jpg (752.7 KiB) Viewed 260 times

tap.jpg
tap.jpg (94.79 KiB) Viewed 260 times

zheng3
 
Posts: 20
Joined: Sun Jul 19, 2015 1:42 pm

Re: Comparing the output of two MAX4466's

by adafruit_support_bill on Sat Aug 27, 2016 3:19 pm

No obvious problems there. Let's try replacing the 'B' microphone. Please contact support@adafruit.com with a link to this thread and we can get one out to you.

adafruit_support_bill
 
Posts: 61065
Joined: Sat Feb 07, 2009 10:11 am

Re: Comparing the output of two MAX4466's

by zheng3 on Sat Aug 27, 2016 3:37 pm

Replacing B is a good idea, I'll send this thread over to support.

I've actually got another microphone (let's call it C) already here ready to go. Take a look at these plots.

a_c.png
a_c.png (42.51 KiB) Viewed 255 times


c_b.png
c_b.png (43.19 KiB) Viewed 255 times

zheng3
 
Posts: 20
Joined: Sun Jul 19, 2015 1:42 pm

Re: Comparing the output of two MAX4466's

by adafruit_support_bill on Sat Aug 27, 2016 3:53 pm

OK. I think I see the problem now in the code:

This is how the min and max are initialized:
Code: Select all | TOGGLE FULL SIZE
       unsigned int signalMax = 0.0;
       unsigned int signalMin = 1024.0;

But they are not re-initialized before the second sample. So the second sample will always be at least as high a reading as the first sample.

You need to add this between the first and second samples:
Code: Select all | TOGGLE FULL SIZE
       signalMax = 0.0;
       signalMin = 1024.0;

adafruit_support_bill
 
Posts: 61065
Joined: Sat Feb 07, 2009 10:11 am

Re: Comparing the output of two MAX4466's

by zheng3 on Sat Aug 27, 2016 4:06 pm

In the end, so simple. Thanks so much, Bill. I've learned a great deal in the last couple of days thanks to you.

yaaaaaaaaas.png
yaaaaaaaaas.png (84.01 KiB) Viewed 246 times


Here's the working code should someone else stumble upon this thread with a similar issue.

Code: Select all | TOGGLE FULL SIZE
    /****************************************
    Example Sound Level Sketch for the
    Adafruit Microphone Amplifier
    ****************************************/
     
    const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz)
    unsigned int sample;

    void setup()
    {
       Serial.begin(9600);
       pinMode(A2, INPUT);
       pinMode(A3, INPUT);
    }
     
     
    void loop()
    {

   
       unsigned long startMillis= millis();  // Start of sample window
       double peakToPeak = 0;   // peak-to-peak level

       
       unsigned int signalMax = 0.0;
       unsigned int signalMin = 1024.0;
     
       // collect data for 50 mS
       while (millis() - startMillis < sampleWindow)
       {
          sample = analogRead(2);
          if (sample < 1024)  // toss out spurious readings
          {
             if (sample > signalMax)
             {
                signalMax = sample;  // save just the max levels
             }
             else if (sample < signalMin)
             {
                signalMin = sample;  // save just the min levels
             }
          }
       }

 
       
       peakToPeak = signalMax - signalMin;  // max - min = peak-peak amplitude
       double volts0 = (peakToPeak * 5.0) / 1024.0;  // convert to volts
           
       startMillis= millis();
       signalMax = 0.0;
       signalMin = 1024.0;
       
        while (millis() - startMillis < sampleWindow)
       {
          sample = analogRead(3);
          if (sample < 1024)  // toss out spurious readings
          {
             if (sample > signalMax)
             {
                signalMax = sample;  // save just the max levels
             }
             else if (sample < signalMin)
             {
                signalMin = sample;  // save just the min levels
             }
          }
       }
       peakToPeak = signalMax - signalMin;  // max - min = peak-peak amplitude
       double volts1 = (peakToPeak * 5.0) / 1024.0;  // convert to volts

        Serial.print(volts0);
        Serial.print(",");
        Serial.println(volts1);
       
 
    }

zheng3
 
Posts: 20
Joined: Sun Jul 19, 2015 1:42 pm

Re: Comparing the output of two MAX4466's

by adafruit_support_bill on Sat Aug 27, 2016 4:26 pm

Excellent! Are you able now to distinguish between sounds from the right and left?

adafruit_support_bill
 
Posts: 61065
Joined: Sat Feb 07, 2009 10:11 am

Re: Comparing the output of two MAX4466's

by zheng3 on Sat Aug 27, 2016 4:34 pm

Even better! left, right, and middle.

mics.png
mics.png (17.16 KiB) Viewed 240 times


I'll be using these mics to drive servo rotation on Plutarch, my robot parrot: http://zheng3.com/2016/06/16/plutarch-1-0-finished-still-not-a-robot/

With a little more work, he'll be able to look towards and react to the loudest sound in his environment.

zheng3
 
Posts: 20
Joined: Sun Jul 19, 2015 1:42 pm

Re: Comparing the output of two MAX4466's

by adafruit_support_bill on Sat Aug 27, 2016 8:49 pm

That's pretty awesome. Hope that your robo-parrot performs as expected.

adafruit_support_bill
 
Posts: 61065
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.