Current Leakage through Analog Pin only when using a Regulator?

I have an Atmega328P connected on a breadboard with an MCP1700 Voltage regulator and a voltage divider. The Atmega is connected directory to the battery voltage (5v). I then feed Aref with a stable 3.3v from the MCP1700 and read that battery voltage using a voltage divider. It's activated by the Atmega through an NPN transistor. I currently use low-side switching because I don't have any FETS available. However, this works fine and consumes 7 microamps of energy in deep sleep.

Imgur

I then tried powering everything from the voltage regulator (except the voltage divider itself, because I still need that to read the actual battery voltage). So AVCC, AREF, VCC are all now powered through the output of the regulator. Something weird happened, suddenly I'm consuming 60 microamps of energy during sleep. I narrowed this down to being current flowing into the analog input pin.

Imgur

I don't understand, why does this happen when connected directly to the regulator?

My interpretation of the schematic is that when Q3 is off, you are connecting what is labeled to be a 5V source, through a 10K resistor, to the ADC input on a processor powered by 3.3V.

That is not a good idea, although the current flow you observed through the input protection diode probably won't damage anything.

You should rethink the voltage sensing circuit.

Ah that does make a little sense. I guess in the first diagram, the sense processor is powered by the same 5v, it's no big deal? And doesn't cause that weird current leak?

The MCU specs clearly state that the absolute maximum voltage than can be applied to any input is Vcc+0.5 V. Q3 is actually counterproductive in this case. To save power, make the voltage divider from 2x100K or even 2x1M, leave out Q3 and add a 100 nF cap from the divider tap to ground.

It is often forgotten that an unpowered processor has Vcc=0 V, which means in that case, the highest voltage you may apply to any input is 0.5V.

1 Like

Why? I would simply connect the output of the voltage divider directly to the analog pin. If you increase the resistor values, the current drawn by the analog pin will be very small, so I'm not sure that switching it on/off with a transistor would be worthwhile. To reduce noise in the analog reading, just add a 0.1uF cap between the analog pin and ground, if needed, but you may find it works well enough without.

I would also use the internal voltage reference rather than the output of the regulator. When the battery voltage falls below around 3.5V, the regulator output will begin to fall below 3.3V. The atmega will continue to operate for quite a long time after that point, giving a useful extra battery life, but you won't be able to measure the voltage accurately. To use the internal reference, you will need to adjust the voltage divider to get the output voltage below ~1V, and add mentioned you can probably increase the total resistance by 10x to reduce the current though the divider.

You'd probably be better off with 1M resistors and a few nF on the analog pin.

Are unused pins all set to INPUT_PULLUP? If not they can also contribute to extra current consumption if picking up noise.

Since input buffers are disabled in Power Down sleep (unless needed by an interrupt) they cannot contribute to extra current consumption.

Ah that's handy - I had to do this before, but IIRC I was using a low clock speed to reduce power consumption, not sleep mode, so the buffers were active.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.