Saturday, 31 August 2019

batteries - Making a battery last a long time in a microcontroller circuit



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?



Answer



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.


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...