Understanding the behavior of the microphone amp

Hello all,

trying to understand the behavior of the microphone amp:
Attached is a pic of my breadboard, a very simple layout:

A Nano drives a 24xLED Ring and uses an analog input to read a mic.

When I switch all LEDs on I see the analogread drop to around 50 and stays there for around 100ms and then moves back to 512. When I turn them off analogread rises to 1023 and stays there for the same amount of time. Attached is also a plot of the data: blue=‘nullAudio’, orange=‘variation’, and gray box=‘color’ ( on/off period )

The draw of the LEDs is about 1.3A. The code:

#define LED_PIN  8
#define MIC_PIN  A3
#define LED_COUNT  24
#define RAW_BUFFER_SIZE 10

#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel ring(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  Serial.begin(115200);
  pinMode(MIC_PIN, INPUT);
  ring.begin();
}

void loop() {

  uint32_t color;
  if ((millis() / 1000) % 2 == 0)
    color = 0x000001;
  else
    color = 0xffffff;

  ring.fill(color);
  ring.show();

  uint32_t  nullAudio = 0;
  int minA = 1024;
  int maxA = 0;
  for (int i = 0; i < RAW_BUFFER_SIZE; i++)
  {
    int aIN = analogRead(MIC_PIN);
    maxA = max(aIN, maxA);
    minA = min(aIN, minA);
    nullAudio += aIN;
  }
  nullAudio /= RAW_BUFFER_SIZE;
  int variation = max(maxA - nullAudio, nullAudio - minA);

  Serial.print(nullAudio ); 
  Serial.print(" ");
  Serial.print(variation);
  Serial.print(" ");
  Serial.println(color );
  delay(10);
}

Any suggestion why the mic is doing this and how to fix it?
Thanks,
Markus

use external power supply for the ring. at least 2A.

I suppose power goes down when LEDs goes on, USB2.0 support up to 500mA.

UPD. Are you sure LED diagram synchronized with Mic gain diagram?
UPD2 on mic module are 2 coils on GND and VCC. On you breadbord is no 1000µF capacitor to see. so i can suppose generated distortion are very high and mic modules coils suppress them to very small voltage.
External PSU will helps.

Helpers are also interested. Why not post a link to the datasheet? Pictures showing a bird nest doesn't tell much.

I cant attached it as a file so here is the raw data:

1023 0 1
1023 0 1
1023 0 1
1023 0 1
1023 0 1
1023 0 1
1023 0 1
1023 0 1
669 55 1
530 54 1
552 73 1
520 49 1
521 73 1
540 56 1
502 79 1
527 62 1
530 57 1
505 85 1
542 56 1
515 66 1
523 59 1
533 69 1
496 73 1
537 52 1
519 56 1
510 61 1
545 72 1
499 66 1
525 71 1
538 60 1
497 58 1
533 71 1
517 58 1
521 75 1
539 64 1
495 58 1
534 73 1
525 59 1
509 62 1
541 58 1
510 73 1
522 60 1
530 56 1
495 92 1
534 57 1
517 59 1
515 67 1
534 69 1
500 50 1
530 62 1
525 59 1
504 54 1
547 47 1
513 49 1
520 56 1
533 73 1
511 63 1
534 57 1
521 72 1
509 54 1
541 76 1
505 67 1
524 59 1
528 41 1
496 62 1
538 60 1
516 65 1
515 52 1
538 66 1
502 72 1
531 75 1
523 61 1
507 52 1
535 69 1
515 55 1
522 49 1
532 58 1
506 58 1
537 64 1
527 74 1
89 359 16777215
48 1 16777215
47 2 16777215
48 4 16777215
47 2 16777215
47 1 16777215
46 1 16777215
46 2 16777215
46 6 16777215
46 1 16777215
46 2 16777215
399 10 16777215
482 28 16777215
499 27 16777215
527 32 16777215
534 27 16777215
500 36 16777215
545 47 16777215
537 33 16777215
533 27 16777215
517 33 16777215
546 22 16777215
539 23 16777215
520 25 16777215
514 30 16777215
546 28 16777215
539 41 16777215
495 31 16777215
558 60 16777215
545 19 16777215
534 26 16777215
509 25 16777215
559 26 16777215
541 20 16777215
523 24 16777215
506 33 16777215
542 22 16777215
540 27 16777215
500 21 16777215
539 47 16777215
539 23 16777215
538 24 16777215
513 27 16777215
542 22 16777215
539 36 16777215
536 20 16777215
508 23 16777215
544 19 16777215
534 24 16777215
497 34 16777215
539 48 16777215
542 24 16777215
530 30 16777215
530 46 16777215
543 23 16777215
535 43 16777215
525 27 16777215
515 21 16777215
546 26 16777215
538 22 16777215
496 30 16777215
534 47 16777215
545 32 16777215
535 25 16777215
510 25 16777215
542 29 16777215
535 26 16777215
528 26 16777215
505 22 16777215
545 28 16777215
541 27 16777215
497 23 16777215
530 51 16777215
539 30 16777215
545 36 16777215
511 29 16777215
541 22 16777215
534 30 16777215
547 45 16777215
968 489 1
1023 0 1
1023 0 1
1023 0 1
1023 0 1
1023 0 1
1023 0 1
1023 0 1
1023 0 1
673 86 1
547 47 1
533 65 1
541 60 1
506 63 1
532 70 1
530 68 1
501 74 1
534 69 1
508 63 1
521 58 1
536 49 1
497 72 1
531 44 1
529 63 1
512 75 1
538 55 1
514 78 1
522 45 1
531 59 1
500 68 1
543 67 1
511 55 1
513 63 1
536 58 1
510 68 1
535 60 1
518 60 1
509 58 1
541 57 1
502 70 1
524 57 1
528 48 1
510 51 1
541 50 1
518 63 1
513 66 1
538 73 1
505 77 1
527 65 1
527 54 1
502 54 1
538 58 1
512 50 1
529 75 1
531 58 1
497 60 1
532 77 1
517 53 1
510 45 1
536 40 1
513 64 1
528 62 1
533 57 1
501 50 1
535 67 1
522 51 1
513 65 1
538 53 1
505 41 1
526 62 1
528 54 1
499 68 1
536 42 1
514 52 1
517 74 1
529 60 1
514 76 1
532 70 1
525 61 1
512 46 1
539 74 1
95 375 16777215
51 3 16777215
50 3 16777215
49 4 16777215
49 3 16777215
48 4 16777215
47 5 16777215
47 2 16777215
47 2 16777215
48 4 16777215
47 5 16777215
402 69 16777215
506 27 16777215
527 26 16777215
487 26 16777215
559 17 16777215
541 26 16777215
532 29 16777215
505 34 16777215
543 29 16777215
544 23 16777215
503 11 16777215
517 43 16777215
550 23 16777215
542 18 16777215
496 28 16777215
557 31 16777215
543 22 16777215
540 27 16777215
514 25 16777215
542 26 16777215
536 27 16777215
534 38 16777215
514 32 16777215
548 28 16777215
537 21 16777215
514 45 16777215
552 31 16777215
536 27 16777215
532 24 16777215
513 33 16777215
546 28 16777215
541 30 16777215
512 16 16777215
517 35 16777215
545 22 16777215
538 35 16777215
500 33 16777215
550 33 16777215
544 26 16777215
538 22 16777215
515 31 16777215
539 32 16777215
547 31 16777215
515 18 16777215
515 36 16777215
542 24 16777215
550 44 16777215
508 34 16777215
549 39 16777215
536 24 16777215
536 12 16777215
518 23 16777215
540 22 16777215
537 25 16777215
510 23 16777215
519 31 16777215
549 24 16777215
534 22 16777215
500 26 16777215
555 46 16777215
539 29 16777215
536 26 16777215
515 29 16777215
546 29 16777215
538 27 16777215
515 28 16777215
512 33 16777215
973 443 1
1023 0 1
1023 0 1
1023 0 1
1023 0 1
1023 0 1
1023 0 1
1023 0 1
1023 0 1
643 52 1
548 46 1
554 86 1
514 56 1
537 77 1
526 81 1
509 53 1
542 91 1
509 55 1
522 59 1
527 61 1
503 60 1
535 66 1
519 72 1
522 68 1
537 49 1
507 61 1
527 46 1
528 67 1
502 60 1
535 69 1
510 56 1
520 43 1
532 60 1
506 79 1
532 73 1
525 61 1
509 51 1
542 51 1
510 59 1
523 69 1
522 63 1
499 63 1
536 69 1
512 68 1
515 85 1
534 81 1
511 56 1
529 64 1
524 58 1
506 53 1
549 64 1
509 64 1
518 71 1
531 62 1
504 63 1
506 53 1
558 100 1
536 47 1

I found a powersupply, Meanwell 5V, 10A and wired it in:

Here is the data dump with external power supply in parallel, very noisy data, similar behavior:


676 115 1
389 75 1
599 143 1
397 141 1
636 115 1
388 176 1
529 124 1
465 324 1
575 108 1
480 303 1
520 131 1
550 252 1
505 92 1
607 294 1
47 426 16777215
1 5 16777215
0 5 16777215
0 6 16777215
280 513 16777215
480 541 16777215
512 511 16777215
534 530 16777215
537 491 16777215
540 483 16777215
519 504 16777215
480 535 16777215
465 555 16777215
504 519 16777215
504 519 16777215
493 530 16777215
557 512 16777215
547 524 16777215
544 540 16777215
537 512 16777215
519 504 16777215
508 515 16777215
455 518 16777215
476 487 16777215
527 496 16777215
524 490 16777215
493 493 16777215
565 492 16777215
536 487 16777215
528 495 16777215
535 488 16777215
505 518 16777215
495 528 16777215
467 527 16777215
512 511 16777215
536 529 16777215
537 526 16777215
493 493 16777215
590 528 16777215
525 514 16777215
499 524 16777215
512 511 16777215
499 524 16777215
514 509 16777215
503 452 16777215
536 479 16777215
549 500 16777215
536 505 16777215
510 506 16777215
527 512 16777215
503 520 16777215
465 558 16777215
500 523 16777215
505 516 16777215
513 510 16777215
490 493 16777215
546 516 16777215
548 539 16777215
524 480 16777215
541 482 16777215
538 491 16777215
520 515 16777215
461 494 16777215
508 515 16777215
488 535 16777215
503 520 16777215
505 474 16777215
537 486 16777215
534 526 16777215
507 506 16777215
549 474 16777215
538 490 16777215
528 517 16777215
470 476 16777215
517 506 16777215
502 521 16777215
500 523 16777215
506 517 16777215
951 640 1
1023 0 1
1023 0 1
1023 0 1
616 112 1
675 348 1
436 98 1
686 85 1
403 72 1
687 113 1
355 82 1
556 115 1
480 328 1
558 100 1
529 255 1
416 71 1
659 259 1
397 76 1
613 122 1
389 304 1
516 95 1
617 300 1
449 84 1
613 103 1
369 137 1
593 107 1
526 264 1
472 125 1
670 384 1
414 78 1
673 121 1
367 302 1
493 91 1
589 258 1
475 84 1
636 345 1
362 57 1
622 103 1
465 326 1
514 111 1
495 265 1
438 75 1
684 113 1
377 78 1
526 102 1
524 246 1
493 97 1
648 330 1
374 95 1
641 108 1
467 330 1
546 105 1
510 259 1
407 69 1
699 117 1
396 65 1
592 123 1
542 254 1
479 87 1
657 343 1
376 95 1
577 114 1
482 319 1
540 94 1
562 259 1
396 65 1
671 113 1
402 203 1
563 120 1
465 239 1
461 84 1
697 110 1
381 84 1
531 100 1
503 261 1
493 95 1
654 344 1
378 102 1
611 105 1
513 275 1
506 87 1
26 230 16777215
0 1 16777215
0 6 16777215
0 1 16777215
259 452 16777215
481 472 16777215
514 466 16777215
540 497 16777215
531 509 16777215
548 515 16777215
534 520 16777215
494 475 16777215
479 520 16777215
503 520 16777215
490 533 16777215
481 539 16777215
537 486 16777215
525 460 16777215
546 507 16777215
544 521 16777215
553 515 16777215
535 522 16777215
482 490 16777215
501 522 16777215
501 522 16777

Now with disconnected +5V between LED and Nano:

data dump, less noisy and a lot less effect but still visible 'swing':


547 75 1
513 15 1
573 21 1
455 53 1
569 6 1
493 27 1
594 12 1
455 16 1
566 7 1
490 14 1
561 60 1
505 56 1
556 19 1
504 38 1
516 73 1
530 54 1
522 69 1
529 45 1
503 10 1
568 21 1
492 49 1
579 11 1
493 7 1
583 15 1
444 43 1
559 10 1
490 15 1
585 80 1
461 33 1
566 23 1
487 10 1
536 69 1
536 50 1
540 27 1
510 61 1
498 15 1
559 46 1
479 70 1
550 70 1
509 8 1
577 19 1
465 41 1
581 11 1
490 12 1
596 10 1
471 42 1
567 10 1
499 7 1
558 51 1
481 49 1
546 43 1
506 64 1
518 50 1
556 37 1
533 40 1
535 53 1
520 17 1
568 33 1
448 45 1
577 13 1
493 6 1
588 14 1
459 20 1
558 8 1
492 16 1
569 64 1
504 49 1
572 12 1
502 11 1
530 71 1
511 53 1
540 43 1
516 55 1
513 19 1
576 20 1
484 41 16777215
530 54 16777215
510 16 16777215
524 51 16777215
507 52 16777215
497 17 16777215
578 84 16777215
513 54 16777215
587 9 16777215
501 26 16777215
579 13 16777215
499 62 16777215
528 47 16777215
518 14 16777215
529 55 16777215
492 46 16777215
489 16 16777215
577 76 16777215
521 45 16777215
590 9 16777215
496 29 16777215
592 7 16777215
475 70 16777215
533 56 16777215
524 22 16777215
564 36 16777215
463 37 16777215
495 36 16777215
562 45 16777215
539 40 16777215
593 10 16777215
491 26 16777215
601 11 16777215
469 56 16777215
532 43 16777215
506 17 16777215
557 23 16777215
465 39 16777215
500 59 16777215
553 66 16777215
542 32 16777215
594 7 16777215
503 25 16777215
593 10 16777215
445 36 16777215
538 42 16777215
500 15 16777215
584 26 16777215
451 26 16777215
525 59 16777215
541 70 16777215
537 38 16777215
586 19 16777215
496 18 16777215
592 13 16777215
461 29 16777215
546 44 16777215
495 21 16777215
585 24 16777215
473 39 16777215
516 63 16777215
514 81 16777215
562 24 16777215
588 29 16777215
499 33 16777215
580 63 16777215
449 14 16777215
543 40 16777215
507 24 16777215
578 13 16777215
457 21 16777215
529 63 16777215
518 49 16777215
557 23 16777215
581 29 16777215
493 35 16777215
579 79 16777215
456 22 16777215
537 49 16777215
492 8 1
601 15 1
493 45 1
570 7 1
493 17 1
584 70 1
487 50 1
500 22 1
495 12 1
541 70 1
555 14 1
558 48 1
509 50 1
507 11 1
549 38 1
465 37 1
567 77 1
499 11 1
584 10 1
470 61 1
549 19 1
504 22 1
592 10 1
501 51 1
583 6 1
475 11 1
550 52 1
495 49 1
506 32 1
499 72 1
522 48 1
562 22 1
548 49 1
518 48 1
496 16 1
589 20 1
457 33 1
579 12 1
504 17 1
591 8 1
447 23 1
513 36 1
494 8 1
584 68 1
541 45 1
571 19 1
493 16 1
531 71 1
550 47 1
469 33 1
516 55 1
521 15 1
581 11 1
485 64 1
541 58 1
507 9 1
589 21 1
468 50 1
580 10 1
508 18 1
587 49 1
466 45 1
515 34 1
481 12 1
557 51 1
560 30 1
559 42 1
491 54 1
513 11 1
562 29 1
462 26 1
553 63 1
507 13 1
585 16 1
450 56 1
544 31 1
507 19 1
592 18 1
511 53 1
576 14 1
495 20 1
575 71 16777215
474 35 16777215
523 50 16777215
511 23 16777215
597 17 16777215
450 39 16777215
549 59 16777215
514 22 16777215
574 18 16777215
564 51 16777215
489 32 16777215
568 73 16777215
478 41 16777215
523 51 16777215
500 14 16777215
585 15 16777215
459 40 16777215
552 66 16777215
524 18 16777215
565 17 16777215
555 50 16777215
491 28 16777215

scrolling is not fun.
i said "external PSU for ring".

OK, so you know how to post code.

Post your "raw data" - you need to go back and edit the ridiculous posts using the "pencil" icon below the post - the same as code.


Thank you.

:+1:

Changed the post now

Thanks for the wiring - I will try this but it's not the typical connection of the max4466 module that I have seen so far.

My last raw data list reflects your wiring - except the mic part


ok. and when you speak into mic?

I changed picture. do you mean such wiring?

I will have to add the resistor and cap to my breadboard and see what effect it has on the analogread - but the readings without them are decoupled the LED power now.
The only issue is that I want to use only one 5V power source. Any idea how that can work?


Edited to

So you now realise that as the Adafruit module (for which sadly they do not provide a schematic :roll_eyes: ) is not powered by a bipolar supply and presumably has no output capacitor, the additional components are unnecessary. :thinking:

I have seen schematic and i realized prebias is unnecessary

Good trick. I may not have tried too hard but Adafruit was not giving it away easily for that module. Did you have to go to Github (which I understand has been debased :worried:)? Perhaps post it here.

post #2. isn't it?

There's always going to be some noise because your room isn't perfectly quiet and there is always some electrical noise and you have a high-gain preamp that amplifies any noise along with the signal.

"Real" professional microphone preamps have balanced-differential inputs to minimize hum from the mic & cable and the preamp circuit often has it's own-separate voltage regulator or power supply or some filtering to minimize power supply noise. And of course they use a low-noise op-amp, and put it in a metal/shielded case.

And, raw audio data "looks like" noise because you are randomly(1) sampling a constantly-varying waveform. Even the "data' from a pure sine wave will look random.

But you should be able to see the difference between loud and quiet sounds.

With louder sounds some readings will deviate more from zero (or more from the bias) but there are still lots of values between the positive & negative peaks. With quiet sounds all of the readings will be near zero (or near the bias if you haven't subtracted-out the bias).

(1) It's not really "random" but the sample points are not correlated with the waveform so you might sample a positive or negative peak (or near a peak) or you might sample a zero-crossing (or a near zero-crossing)

1 Like

P.S.
There is a filter you can try:
Half-Filter

Try it on just the microphone board, or maybe on the microphone board & Arduino, or you can try two of these, one for the Arduino and one for the microphone board.

The LEDs should connect directly to the power supply, bypassing the filter(s).

There is a voltage drop across the diode so with a 5V supply you won't get the full 5V out. A Schottky is preferable because it has a 0.2 or 0.3V drop whereas a regular silicon diode has a about a 0.5 - 0.7V drop. But if you have a regular diode you can try it, and if helps you can optionally "upgrade" later. And in general, the bigger the capacitor the better.

I call this a "half-filter" (I don't know if it has a name). "Negative" noise-spiles on the power supply (where the voltage drops-down) are filtered-out. The capacitor holds-up the voltage on the output side of the filter, and the diode prevents the capacitor from discharging into the power supply or LEDs. The capacitor only has to power the preamp or Arduino temporarily until the power comes-back to normal.

It doesn't help much more than a capacitor alone with positive spikes, but it does help a little because the positive-spike has a negative-going edge, and that is discharged slowly and "smoothed out".

The half-filter can work great if you're powering the Arduino and powering through Vin with more than 5V while using the built-in voltage regulator. The voltage regulator is a very-good noise filter by itself and the capacitor in the half-filter protects against negative glitches or shirt voltage dropouts.

The application is just with USB power so I don't think the diode will work but I'll give it a try.
To give the project it's use-case: The mic is there to pickup the sound and I'll do something audio reactive. The current design works good if it's loud but the more quiet it gets the more the noise and 'feedback' from the LEDs making it hard to control.
I am wondering if I can calculate the current draw from the LEDs into the supply voltage and offset the result of the ADC accordingly. in FastLED there is this calculation :

//// POWER MANAGEMENT

// These power usage values are approximate, and your exact readings
// will be slightly (10%?) different from these.
//
// They were arrived at by actually measuing the power draw of a number
// of different LED strips, and a bunch of closed-loop-feedback testing
// to make sure that if we USE these values, we stay at or under
// the target power consumption.
// Actual power consumption is much, much more complicated and has
// to include things like voltage drop, etc., etc.
// However, this is good enough for most cases, and almost certainly better
// than no power management at all.
//
// You're welcome to adjust these values as needed; there may eventually be an API
// for changing these on the fly, but it saves codespace and RAM to have them
// be compile-time constants.

static const uint8_t gRed_mW   = 16 * 5; // 16mA @ 5v = 80mW
static const uint8_t gGreen_mW = 11 * 5; // 11mA @ 5v = 55mW
static const uint8_t gBlue_mW  = 15 * 5; // 15mA @ 5v = 75mW
static const uint8_t gDark_mW  =  1 * 5; //  1mA @ 5v =  5mW

Since I know the pixel values I can predict the current and possibly the voltage drop. The unknown part is the characteristic of the mic module and why it's taking the time (about 100ms) to adapt to the new voltage. Unfortunately I have no scopes to measure if the voltage actually stays lower if the LEDs are 'on' or if the mic module has some slow reacting filter.