10
\$\begingroup\$

I am running a battery powered device, and would like my microcontroller (PIC) to report on the supply voltage.

This is so I can determine how many batteries is used in the supply, and also the state of charge of the battery pack.

Supply voltage ranges from 4xD (either 1.2V nominal NiMH or 1.5V Alkalines making about 6V) to 12xAA (1.2V NiMH for 14.4V or 1.5V Alkaline for 18V).

My PIC is running off a regulated 5V supply.

I plan to use one of the ADC ports to measure the voltage, and therefore believe I should map the 18V f.s.d. to the range 0-5V, so roughly I'd need to divide the input voltage by 3.

I've heard of using a resistor voltage divider, but know that it can be wasteful in terms of energy consumed.

Wondering if there is a better way to achieve this voltage division without too much energy loss/wastage?

Thanks.

\$\endgroup\$

2 Answers 2

9
\$\begingroup\$

you want a voltage divider. if you care about power dissipation, there are a couple of things you can do:

  • use a fairly high impedance voltage divider, with a capacitor on the output terminal, and buffer it with a low-power op-amp. Make sure you use an RC filter between op-amp and ADC, values of this RC filter are typically around 50-200 ohms, 1000pf. This serves to keep voltage stable when the ADC is switching between channels and charge is transferred between the ADC's internal capacitor and the outside pin. An op-amp alone cannot do this. If you don't buffer the high-impedance voltage divider, you will get errors due to ADC leakage current and charge transfer.

  • switch the voltage divider, e.g. connect/disconnect it to the supply voltage, so you can do this only occasionally when you want. A PFET would work, just be careful with how you drive it.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ This sounds great, I would just like to add that you need to load (pull current from) a battery to get a realistic measurement of the remaining battery life. You are much better off with a higher current divider with an off switch. \$\endgroup\$
    – Kortuk
    Commented Dec 2, 2009 at 14:39
  • \$\begingroup\$ I just posted a similar response, and voted to delete it. Apparently I had an old version of the page cached. I voted this up, it's the way to go. \$\endgroup\$
    – Lou
    Commented Dec 2, 2009 at 19:29
  • \$\begingroup\$ +1 for switching the voltage divider. A very useful trick. \$\endgroup\$ Commented Dec 2, 2009 at 20:15
  • \$\begingroup\$ @Kortuk: you have a very good point, but I'd decouple the voltage divider from the battery load. It's really easy to drive an N-channel FET directly from a microcontroller (well... there should be a small resistor between micro output + FET gate, I usually use 10-100 ohms) and have a resistor from FET drain to power supply. Much easier than trying to combine these two functions and finagle a switchable voltage divider. Besides, there are lots of times when you want to measure a battery voltage at no-load or near no load. Actually if I had to pick one or the other, I'd measure it at no-load. \$\endgroup\$
    – Jason S
    Commented Dec 3, 2009 at 4:49
7
\$\begingroup\$

Jason S has provided a good suggestion for how you can reduce the power if required. But before making life more complicated for youself, it's possible to determine how much power you can really afford.

For any low power design, you should consider the overall power budget. For a battery powered device this will usually be determined by the desired life of the batteries. If the combined power of the rest of the circuit is significantly more than the resistor divider, then either you don't need to worry about it or you've got other power hungry parts of the circuit to worry about.

\$\endgroup\$
5
  • 5
    \$\begingroup\$ +1 for pointing out the importance of perspective. I would add, if it's 1% of your power budget, it's not worth worrying about (unless you have a bunch of voltage dividers!) -- if it's 5-10% of your power budget, it may be worth worrying about; if it's 20% or more it is. (just my 2c) \$\endgroup\$
    – Jason S
    Commented Dec 3, 2009 at 4:44
  • 1
    \$\begingroup\$ Sounds like a good rule of thumb to me. The other important point, is that we can measure and calculate these things. And doing so it more helpful than guessing :) \$\endgroup\$ Commented Dec 3, 2009 at 20:39
  • \$\begingroup\$ Good point Jason. A bit more about the application: it is a lighting system that will be sitting unused for long periods of time, and then when powered on, draws about 3A from the supply with a constant current circuit. So in operation, the power draw for voltage monitoring is an insignificant part of total power draw. However in the standby mode, I'd like for the battery capacity to not be unnecessarily drained as much as possible, or rather I'd like any unavoidable parasitic drain to be minimised in standby mode. \$\endgroup\$
    – Kheng
    Commented Dec 3, 2009 at 21:32
  • 1
    \$\begingroup\$ @Kheng: Is it possible to have everything except the microcontroller on a separate power supply? They switch the peripherals on all at once with one relay or fet under the control of the uC. It should then be easy to control the standby current of of the uC and you don't have to worry about minimising the power in individule circuits. \$\endgroup\$ Commented Dec 3, 2009 at 21:57
  • 1
    \$\begingroup\$ @Kheng: "I'd like for the battery capacity to not be unnecessarily drained as much as possible" is too pointy-haired for an engineer. What is the average current drawn? To calculate that you will need to know the average duty cycle and the idle current. Then apply the rules of thumb given by Jason to see whether it makes sense to do anyhting more complicated than a resistor divider. Engineering is NOT doing the 'best possible', it is 'meeting the requirements for the lowest cost'. \$\endgroup\$ Commented Aug 31, 2011 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.