Mic output dips with circuit current draw

Just to give a bit of a background: I'm a fairly new to Arduino, I've been playing around with my nano for a few weeks, I have a bit of programming background with Java and I tinker with electronics from time to time.
I've been trying to teach myself electronics theory for a while. I prefer learning by breaking things apart and blowing stuff up, but at some point you have to look at some equations.

Okay, so I've put together a simple circuit, some LED's, some shift registers (one in diagram for the sake of simplicity), a mic and a pot. Here are the component specs:

  • Arduino: Nano
  • Shift register: 74HC595
  • Mic chip: VMA309
  • Pot: 10K

What I'm trying to do is detect sound and send a pulse down the row of LED's, the sensitivity threshold is controlled by the pot while the sound detection is always sampling at the highest possible rate.
This works perfectly, HOWEVER, when any number of LED's are powered on, the analog output signal coming from the mic drops in sync with the voltage drop. I've measured the voltage drop as about 0.3V when all LED's are on, and the current draw is roughly 160mA. This causes the mic output to drop below the sensitivity threshold causing all LED's to light up permanently (until I lower the threshold with the pot and raise it back to where it was again)

I've been pulling my hair out trying to figure out an easy way around this, looked at countless post on here, videos on YouTube, random electronics blogs, etc.

So after a lot of frustration, I just added in an adaptive threshold using a circular buffer. It's not ideal, but it does work and more or less gives me the effect I'm looking for, even though the mic output is very erratic and not as accurate as it could otherwise be.

Another thing I did just as a troubleshooting step is to power the shift register and LED's off a separate 5V supply. This works perfectly, no drop in the mic output whatsoever, but also not ideal, I don't want to use up 2 USB ports. I also don't feel comfortable doing it this way, it just seems wrong.

Can someone please tell where I'm going wrong and how to fix the voltage/output drop?? You'd make my entire week.

Thanks!

P.S. I've modified the code to adapt to the mic output levels when it drops, so this isn't the exact sketch I was running when I had the problem of the whole thing going into always-on mode.

const int SND = 19;
const int POT = 14;
const int SER = 10;
const int LATCH = 11;
const int CLK = 12;

int updateInterval = 0;
boolean sndDetect = false;
unsigned long prevM = 0;
int s = 0;
int lowAvg = 0;
int hiAvg = 0;
int bufferAvg = 2;

void setup() {
  pinMode(SND, INPUT);
  pinMode(POT, INPUT);
  pinMode(SER, OUTPUT);
  pinMode(LATCH, OUTPUT);
  pinMode(CLK, OUTPUT);
  Serial.begin(9600);
}
void loop() {

  unsigned long currM = millis();
  updateInterval = map(analogRead(POT), 0, 1023, 0, 100);
  s = analogRead(SND);
  lowAvg = runningAvg(s);
  hiAvg = lowAvg + bufferAvg * 2 + 1;
  digitalWrite(LATCH, LOW);

  if (s < lowAvg | s > hiAvg)
    sndDetect = true;
  if (currM - prevM > updateInterval)
  {
    prevM = currM;
    if (sndDetect)
    {
      digitalWrite(SER, HIGH);
    }
    else
    {
      digitalWrite(SER, LOW);
    }
    digitalWrite(CLK, HIGH);
    digitalWrite(CLK, LOW);
    sndDetect = false;
  }
  digitalWrite(LATCH, HIGH);
  Serial.print(s);
  Serial.print("\t");
  Serial.print(lowAvg);
  Serial.print("\t");
  Serial.println(hiAvg);
}
int runningAvg (int a)
{
#define block_size 10
  static int block[block_size];
  static byte index = 0;
  static int sum = 0;
  static byte count = 0;

  sum -= block[index];
  block[index] = a;
  sum += block[index];
  index++;
  index = index % block_size;
  if (count < block_size)
    count++;
  return (sum / count) - bufferAvg;
}

The nano is presumably powered from the USB port , which means it has a Vcc of about 4.5v, and is obviously variable with current draw. ( No regulator )

So

1/ use higher value resistors in series with the LEDS to reduce power consumption - the brightness drop may be acceptable.

2/ The microphone/preamp can works from 3.3v.

So power it from the 3.3v output on the nano, which has a separate 3v3 LDO regulator.

Allan

allanhurst:
1/ use higher value resistors in series with the LEDS to reduce power consumption - the brightness drop may be acceptable.

Any amount of voltage drop makes the mic output drop to an unusable level, even 1 LED @ 20mA. I plan to hook up quite a few LED's, total current would be in the region of about 1.5A. External power obviously, not USB. So I need some way to mitigate the voltage drop or some way to get a clean 3.3V or 5V to the mic without adding a 2nd power source.

2/ The microphone/preamp can works from 3.3v.

So power it from the 3.3v output on the nano, which has a separate 3v3 LDO regulator.

I'm sure I tried this already and saw the exact same results, but i'll give it another go.
Could I add my own regulator? I know very little about them, haven't used one in a project yet.

Thanks for the suggestions.

With significant powers you will need a suitable external psu - eg a 2A 12v wallwart.

Then you have sufficient excess voltage for regulators to work properly.

While USB based I fear you''l have no joy.

Note also that there is a maximum total power rating for the AT328. You can draw 20mA from one pin, but not from 16 at once. And obviously if you have much higher current displays you will need suitable external drivers.

Allan

Can I just ask, how is this microphone intended to be used if it's default behavior is so erratic and voltage dependent?

allanhurst:
Note also that there is a maximum total power rating for the AT328. You can draw 20mA from one pin, but not from 16 at once. And obviously if you have much higher current displays you will need suitable external drivers.

I'm not entirely sure on this, please correct me if I'm wrong, but the LED's are not drawing current from the D pins on the Arduino, correct? So my current limit at the moment (powering everything through USB) should be the 200mA limit on the Arduino's 5V output?

Try this:

Set Aref to external in setup()

analogReference(EXTERNAL); // use an external reference voltage

And connect the Vref pin to the 3.3volt pin.

Warning: do both of the above if you don't want to fry the Aref of the Nano

Power the sound module from the 3.3volt pin (~30mA is available from that pin).

There is 4.6volt/~450mA available from the 5volt pin on USB power, to power LEDs.
More will fry the <=500mA USB backflow diode.
Leo..

I've read up on reference voltage a bit, and what you've suggested sounds promising, but I still don't entirely understand what this will do for my situation. I don't want to implement something that I don't fully understand, I'll rather read up on it some more.

I'm still new to this and I really don't feel like waiting for a new board if I let the smoke out.
So if I understand correctly, I'm connecting the sound module AND Aref to the Arduino's 3.3V pin? When you wrote Vref, were you just referring to the Aref pin, or something else?

Vref is written on the Nano board, meaning "reference voltage".
That pin shouldn't be used as an output (can, but with very light load), but the pin can be uses as an input if you have/want to connect a more stable reference voltage to the A/D.

Not needed/wanted if you use a ratiometric sensor like a pot or current/pressure sensor,
but it is an improvement if you use a 'voltage output' sensor, like the module you have.

By using the 3.3volt supply as reference, the A/D is less depending on the potentially 'dirtier' default Aref (the 5volt supply).

You MUST add that EXTERNAL line to setup if you connect an EXTERNAL reference voltage to the Aref pin.
Because if you don't, the Nano will internally connect that pin to 5volt the moment you call analogRead, and that would short 3.3volt to 5volt internally.
Leo..

Seems to be working as you suggested, thanks for the explanation.

Another issue came up and I'm not sure if it's related at all, maybe I just bumped a wire or something. The LED's flicker at different brightness's depending on ow many are on, and my blues which require bigger resistors all turn off when all the LED's are supposed to be on. I'm sure I can troubleshoot this on my own.

As I said, thanks, original problem solved, thank you all for your input and patience :slight_smile:

Seems you have power supply problems.
Blue LEDs have a higher working voltage than reds, so they drop out first on a bad supply.
Try a cellphone charger, connected to the USB socket.

PixelCortex:
...and my blues which require bigger resistors...

Blue LEDs have a higher working voltage than red/green LEDs.
More voltage across the LED, and less across the current limiting resistor.
So the CL resistor for blue LEDs must be lower in value for the same LED current.
Leo..

Hi,
Can you please post a picture of your project, so we can see your component layout.

This works perfectly, HOWEVER, when any number of LED's are powered on, the analog output signal coming from the mic drops in sync with the voltage drop. I've measured the voltage drop as about 0.3V when all LED's are on, and the current draw is roughly 160mA. This causes the mic output to drop below the sensitivity threshold causing all LED's to light up permanently (until I lower the threshold with the pot and raise it back to where it was again)

In sync with what voltage drop?
Have you measured the 5V at the 595 Vcc pin while this is happening?
Can you show of your Fritzy picture where you are measuring the volt drops and where you are reference the neg probe of the DMM?

Are you sure that the voltage lines along the edge of the protoboard are continuous from one end to the other, some have a break in the middle.
Protoboards1.jpg

Tom... :slight_smile:

Blue LEDs have a higher working voltage than red/green LEDs.
More voltage across the LED, and less across the current limiting resistor.
So the CL resistor for blue LEDs must be lower in value for the same LED current.

Yes but a blue LED with the same current through it as a red one will look brighter. So you have to increase the resistor to make it look the same brightness.
I have the same problem with white ones. Blue LEDs are likely to be more modern and therefore more efficient at converting current into light.

OP sounds like you have a bit of a crap power supply and if you have more than one shift register you need decoupling capacitors on each chip. A 0.1uF ceramic capacitor from supply to ground is normally needed on all external chips. And also put a big capacitor across the supply 47uF or bigger.

TomGeorge:
Hi,
Can you please post a picture of your project, so we can see your component layout.

Will do once I get home, 6 hours or so.

TomGeorge:
In sync with what voltage drop?
Have you measured the 5V at the 595 Vcc pin while this is happening?
Can you show of your Fritzy picture where you are measuring the volt drops and where you are reference the neg probe of the DMM?

Across the Arduinos pins, see picture below. I haven't measured across the 595.
The mic shares the same power supply, and it seems to have been affecting the mics output readings.

The workaround that Leo suggested above using Aref 3V3 has solved this issue though.

TomGeorge:
Are you sure that the voltage lines along the edge of the protoboard are continuous from one end to the other, some have a break in the middle.

yes, mine are not continuous, but I've joined them as you can see in the diagram

Grumpy_Mike:
OP sounds like you have a bit of a crap power supply and if you have more than one shift register you need decoupling capacitors on each chip. A 0.1uF ceramic capacitor from supply to ground is normally needed on all external chips. And also put a big capacitor across the supply 47uF or bigger.

Haha, everything I know about decoupling capacitors started from reading your countless posts about them, I've been lurking for a while.
I ordered a bunch, but I have yet to use them since this whole project including 2 shift registers works perfectly fine when using 2 separate power supplies Will report back later.

everything I know about decoupling capacitors started from reading your countless posts about them

And yet you still started a project without them. :wink:

The LED's flicker at different brightness's depending on ow many are on,

Sounds like a dead ringer for decoupling to me.

I have something embarassing to admit...

TomGeorge:
Are you sure that the voltage lines along the edge of the protoboard are continuous from one end to the other, some have a break in the middle.

PixelCortex:
yes, mine are not continuous, but I've joined them as you can see in the diagram

I wired my boards to accept power from another separate USB cable........... and I forgot to rewire it for PC USB power only.

Good news is that everything is working 100% now. Just need to add some caps for protection.

Thank you all for your sharing your expertise :slight_smile:

Maybe I'll post again once I've added a few more tuning inputs and made this project a little more permanent.