26
\$\begingroup\$

I'm hoping to power an ATtiny85V for a nice long time on some small battery, probably a coin cell.

I've looked into the software side, and my code is watchdog timer driven, has unused analog and digital converters turned off, the chip is running at 1MHz etc. Of course being both busy and new at this, I'm not sure exactly how much current it is drawing, but I'm hoping I have basically minimized it.

Every few seconds it wakes up, does its voltage level checks on the ADCs, records it to ram, and goes back to sleep. If it detects a serial line is connected, it spews the data out.

However, now I'm looking at the circuit as a whole and wondering if there are things I should do to make the circuit as a whole more battery friendly?

What are the basic dos and don'ts when it comes to designing a long lasting (simple) circuit where one component (the microcontroller) has a repetitive but variable current draw?

For instance:

  • Is an indicator LED a big deal? Is it using up the battery when it is bright? Should I put a giant resistor on it to make it dim, or does that just make the resistor use the battery?
  • Should I use bypass/decoupling capacitors to even out the current draw from the battery, or will the capacitor just waste the battery's power?
  • The microcontroller only needs 1.8V, but I don't have any 1.8V batteries. Should I use two 1.x batteries and send it too much voltage? Can I prolong the battery life by "not using as many volts"? How do I do that?
  • Does it take extra power to check if a pin is HIGH or LOW? Like compared to a no-op or some arithmetic, is there much additional power usage in checking one of the GP I/O pins for its state?

I vaguely know how to compute (and more vaguely how to measure) current, voltage, power, but I'm not really sure which of those things equates to battery life. Is the important measurement of battery life in Coulombs?

I have this vague idea that batteries are full of stuff like:

  • charge, as in amp-hours
  • energy, as in watt-hours
  • power, as in watts

but I am not really clear on what my circuit "eats" when it runs. I've read a fair amount of EE101 and physics textbooks, but I don't really have any lab experience. In other words, I've read a ton about batteries, but I'm not really sure what most of it means in practice.

Do resistors use up battery life? Do capacitors? Do diodes? I suspect they all do, but which of the numbers are the ones that matter? Impedance? Power dissipation? Current? Voltage?

Is there a way to lower voltage without wasting battery? Is there a way to lower voltage while increasing battery life?

\$\endgroup\$
4
  • 6
    \$\begingroup\$ This is a very very broad question. You almost need to ask multiple questions. I could give a full question for the LED power question. \$\endgroup\$
    – Kortuk
    Oct 7, 2010 at 19:36
  • 1
    \$\begingroup\$ Cool, I'll split it up after office hours. Maybe this one is just broad dos and don'ts. I think such answers would be helpful to people just trying to get more out of a battery, but I guess giving any kind of authoritative or educational answer requires a narrower question. \$\endgroup\$ Oct 7, 2010 at 19:45
  • \$\begingroup\$ Yeah, i realized I was going to have to section my answer by your question and would take me an hour. \$\endgroup\$
    – Kortuk
    Oct 7, 2010 at 19:59
  • \$\begingroup\$ BTW my wife found makezine.com/makeitlast which might eventually be useful, as it is basically a contest to make this kind of thing. I think it starts today, so they don't have any hints posted on how to do it. At any rate, my project is independent, and I doubt I'd have time to enter anyways :) Feel free to wait until the contest is over if you don't like such things. \$\endgroup\$ Oct 8, 2010 at 0:01

5 Answers 5

21
\$\begingroup\$

Just a random list, if you post your schematic it would probably be easier:

1.8V lithium Coin cells are very easy to find, but more likely your serial interface needs 3.3v? Unless your receiving end will deal with 1.8V.

Leakage current does generally go up as your voltage increases, so lower is better usually. Also consider the brown-out point for the system vs the battery characteristics. The 'death' characteristics of the battery will be determines by the battery chemistry you use. For instance if your uC browns out at 1.7V you may actually want to use a higher voltage battery as with some batteries the output voltage will lower slowly as the battery dies. You'd get more life out of a 3.3V battery as when it begins to die its output will slowly drop and you can operate all the way down to 1.8V. If you use a 1.8V battery your going to shut down fairly quickly as the battery dies. This all assumes your serial interface or other components can deal with a wide voltage range (I know the AVR can).

LED's use a lot of power, unless you use a very low power LED and are controlling its current draw it's probably drawing a lot more current than the AVR is. If its just there for debug, don't populate it for production or only have it blink once in a while or something to minimize its on time, and definitely control its current draw.

If you can, pick the polarity / rest state of your serial interface to draw as little power as possible, it's rest state should not be drawing power. If pull ups are required use the largest resistor possible to maintain signal integrity but minimize current usage. If power is a huge concern use a signally scheme that favor's bits that don't draw power. For instance if you have pull ups, using a protocol that results in lots of 1's in the signal will leave the serial interface in a state that isn't drawing as much power most of the time. Such optimizations are only worthwhile if your making heavy use of the serial bus. If its very lightly used just make sure its rest state isn't drawing power.

Generally speaking you can assume all instructions (reading GPIO, etc) require the same amount of power. Its not really true but the power difference is minimal.

Power usage is much more dependent on the number/type of peripherals you have powered on, and the amount of time the micro spends active vs sleeping. So the ADC uses more power, EEPROM writes use a fair amount of power. Specifically something like the EEPROM writes are usually done in fairly large 'chunks' so you should accumulate as much information as you can before doing the write to the EEPROM (if your even using it of course). For the ADC that micro supports doing the ADC read during 2 of its sleep states, as ADC conversion takes a relatively long time this is a good time to sleep.

You should probably just read the sections on power management, sleep states and minimizing power using in the microcontroller's data sheet: linky page 35 on. Keep the AVR in the deepest sleep state possible as long as possible. The only exception to this is that you have to consider the start up and shutdown time. Its not worth it to sleep for 10 cycles if waking back up takes 25, etc.

Do resistors use up battery life? Do capacitors? Do diodes?

They all do to some extent. Resistors dissipate the most in most applications:

P = V*I

P = V^2 / R or P = I^2 * R (where V is the voltage drop across the resistor)

Diode's have a (relatively) fixed voltage drop, so power dissipation is almost exclusively tied to current passing through the diode. For instance a diode with a 0.7V forward voltage drop, P = 0.7 * I if current is moving forward through the diode. This is a simplification of course and you should check out the operating mode based on the diode's I-V characteristics.

Capacitors theoretically shouldn't dissipate any power, but in reality they have a finite series resistance and non-zero leakage current which means they do dissipate some power, generally not something you should worry about with such low voltages though. That being said choosing capacitors with minimal leakage current and ESR is a power win.

As far as using them to smooth out battery draw, this doesn't really help for power usage, its more for filtering. Also battery chemistry comes into play here, some chemistries will be happier with a constant draw, some deal better with spiky current draws.

\$\endgroup\$
9
  • 1
    \$\begingroup\$ the important part of P=V^2/R is that as R goes up with a fixed voltage, power usage decreases. \$\endgroup\$
    – Kortuk
    Oct 7, 2010 at 23:46
  • \$\begingroup\$ Cool, so to use more of the battery, I'll probably need higher voltage (possibly using the regulator suggested by Andrew). I'll do some experiments to see how low of voltage the serial line will take. I'll also make sure to set the unused pins to output. Serial is only used occasionally, so I'll just check the rest state. I've definitely tried to shutdown all the peripherals I can. \$\endgroup\$ Oct 7, 2010 at 23:54
  • \$\begingroup\$ For capacitors: so probably I don't need any capacitor to help the battery out. Check the battery chemistry, but assuming it can handle the pattern of current drain I have, then no need to try to adjust it, right? \$\endgroup\$ Oct 7, 2010 at 23:55
  • \$\begingroup\$ Thanks for the P thing. I think I now understand. P = I*V where V is the voltage drop, so I can measure the battery drain in P or I (or P-hours or I-hours) as long as the voltage can't be changed. I'm still not sure if I can change V "for free". \$\endgroup\$ Oct 7, 2010 at 23:58
  • 1
    \$\begingroup\$ The buck-boost regulator andrew mentioned is really the best solution. I didn't mention it because the layout of such circuits is usually critical. They are difficult to breadboard without funky performance or radiating tons of EMI. Read the datasheet carefully, recommendations for layout and identification of critical paths is usually included. There will also be tighter constraints on some of the parts used. Low ESR capacitors and such. \$\endgroup\$
    – Mark
    Oct 8, 2010 at 2:18
12
\$\begingroup\$

Mark gave a most excellent answer and hit on many of the points I was going to make. There are a few that I'd like to contribute as well.

Use an oscilloscope with a low-ohm resistor in series with the return to battery common to make current measurements. Current draw with a microcontroller is not straightforward and as a general rule, meters are FAR too slow to give you a good idea of what's going on. What "low-ohm" means depends on the expected current draw. a 1 ohm resistor will develop 100mV for every 100mA drawn, and that is probably too much for you. I'd try a 10 ohm 1% or 0.5% resistor; you'll see 100mV for every 10mA of current draw. 18 ohms would give you 100mV for every 5.5mA. If you're REALLY going for low power you might be able to get away with 1k; I=V/R: you'll see 100mV for every 100uA of current drawn. Careful though; if you draw enough current you'll end up dropping too much across the shunt and your measurements will be off, not to mention the circuit probably won't work. :-)

With the 'scope connected, try a few different operating frequencies for the microcontroller. You may be surprised to learn that you consume less power with a higher clock speed because you spend much less time "awake."

Eliminate pull-ups/downs as much as possible. You shouldn't have any on any output, since you can drive them to an idle state in most cases. Inputs should be tied to what makes sense, using as high a value as possible, as Mark said.

Make sure that your microcontroller has as much shut off as possible. Turn unused pins into outputs and drive them to a state (high or low, doesn't matter). Don't leave LEDs on. If you can power down other components or stop their clocks, do it. SPI Flash memories, for example, often have a 'power down' command that will take the already low power draw and drive it even lower.

Others have touched on the voltage aspect, and I'd like to comment on it as well. You will likely end up with MUCH better battery use if you use a high-efficiency buck/boost regulator between the battery and your circuit. The regulator will be in buck mode (voltage reduction) when the battery level is higher than the 1.8V you need, and switch to boost mode (voltage increasing) when the battery level drops below 1.8V. This will allow you to run the circuit until the battery is well and truly dead, which is well worth the few percent efficiency loss you'll get when using them. Make sure to select the regulator based on its efficiency over the entire range you want to use, and size the regulator appropriately; a regulator that can deliver 1A at 98% efficiency is probably at 60% efficiency delivering 50mA. Read the datasheets carefully.

\$\endgroup\$
4
  • \$\begingroup\$ Cool. I've not used a scope before, but I suspect our local lab will be happy to show me this (right now I'm actually using the multi-meter in series to measure current; not very good). – Also, would you recommend the regulator even if I am only using 1-10mA, assuming I can find an appropriate part? Is 90% efficiency good enough (I remember finding a cheap one in that range), or is it using more current than it saves me? \$\endgroup\$ Oct 7, 2010 at 23:40
  • 1
    \$\begingroup\$ very good point on playing with the frequency, reminds me of how the wifi radio in my cell phone uses more power than the cellular modem does but wifi is so much faster it can sleep more and ends up being better overall on power because of it. \$\endgroup\$
    – Mark
    Oct 8, 2010 at 2:31
  • 2
    \$\begingroup\$ Another trick for estimating time-average microcontroller current usage in scenarios where current draw will be "bursty" is to charge up a really big capacitor and have it feed a low-quiescent-current regulator to simulate battery voltage. A 100,000uF capacitor will drop 0.01 volts per milliamp-second. If it drops by 0.3 volts in five minutes (300 seconds) your average current draw is 100uA. \$\endgroup\$
    – supercat
    Apr 4, 2011 at 4:27
  • \$\begingroup\$ The point of the efficiency of regulators is very important. So you have to estimate your range of current consumption to select an appropriate regulator within that range \$\endgroup\$ Nov 2, 2018 at 20:10
4
\$\begingroup\$

With your circuit, I'd recommend using a multimeter on the microamps range to measure current consumption. Then, given the battery characteristics you can calculate the longevity. It's not necessarily amp-hours / current, as the battery will have different discharge characteristics for different loads. But, it can be useful as an approximation.

At 1 MHz I think you will be sucking a bit of power - at least 100µA, if PIC micros are anything to compare with. But this is going to be overwhelmed by the 5mA to 20mA going through your LED, so you should get rid of that first.

\$\endgroup\$
1
  • \$\begingroup\$ Cool, LED erased. Having a hard time getting an accurate measurement. Looks like 0.9mA right now, so maybe my software isn't powering down as much as I thought it was. With Arduino (and heartbeat LED) involved it is more like 8-9mA, so at least the tiny is helping. \$\endgroup\$ Oct 7, 2010 at 23:50
1
\$\begingroup\$

These days there are readily available development kits and breakout boards that are extremely handy for making precise current measurments, in some cases down to the nA range. If you haven’t already definitely check out the µCurrent Gold. This is good for static measurements but less so for logging measurements over time.

One way you can still use the µCurrent is to hook up a difference amp to the output. Then you can feed that to an oscilliscope or a logic analyzer with analog inputs. I wrote up a full nuts and bolts tutorial on it I feel like it may help for folks on a budget who don’t quite have the right tools.

It’s amazing what you can learn not only from what the voltage is doing inside your circuit but also how it reacts to every little spike in current. It’s saved my butt a couple times when choosing battery technologies and validation testing. 😎

\$\endgroup\$
0
\$\begingroup\$

All answers already have important points. I will add one from my experience.

When I was developing devices with consumption of less than 10uA, even less than 1uA in deep sleep mode, cleaning of the board made a difference. Once I had 7 out of 10 boards with the expected current consumption. All were the same and all worked OK. After cleaning them in an ultrasonic cleaner, all the boards went to the expected result.

And finally, estimate your expected/targeted consumption checking the datasheets of all your elements. If you handle them ok, you will reach your estimation. This includes all unused pins in microcontroller. Even if you turn off your ADC, make sure the pin configuration while off is the best depending on your external connection.

\$\endgroup\$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.