How to prevent battery over-discharge while running unnattended circuit? - Page 1
Forum section: electronics / projects

author: Ducttape
author_rank: Regular Contributor
timestamp: September 14, 2020, 02:55:43 pm
content: I want to power a little 3.3V Arduino ProMini circuit with a 10440 lithium cell (good physical size). How can I, circuit-wise, prevent the battery from over-discharging? It will probably consume roughly 50mA while running. It will be used intermittently and have a manual on-off switch but, worst case scenario, I could forget to turn it off and forget about it for a few days.

author: Fixpoint
author_rank: Regular Contributor
timestamp: September 14, 2020, 03:59:07 pm
content: If you are using 3.3 V, you can't make use of the full potential of the battery without taking extra measures. The battery would actually be usable down to 2.5 V, but you cut off at 3.3 V.Anyway:This quick & dirty way comes to my mind: as you are already using a 328 microcontroller, you can use one of its ADCs to monitor the battery. You need to scale the maximum lithium voltage of 4.2 V into the 3.3 V range of your ADC, for example using a trimpot, and then you put the MCU into a deep sleep mode as soon as it sees an ADC reading of 803. That corresponds to a cutoff voltage of 3.3 V (803 = 3.3 V / 4.2 V * 1023) because you said that your circuit requires 3.3 V, so it must not go lower. . I am assuming that you are using the full 10 bit resolution of the ADC. After this point, the MCU will only consume ~10 µA. If you leave the MCU running this way, the battery will be fine for quite some time. Of course, the rest of the circuit must be shut off by the MCU and it might draw some additional µA.So, this method is probably pretty blunt, but I think it should minimize the number of extra parts in your circuit.

author: Ducttape
author_rank: Regular Contributor
timestamp: September 14, 2020, 05:37:01 pm
content: Thanks for the reply. I am concerned tho with the additional drain of trim-potting the battery to ground. Although I suppose if the voltage divider was, say, a 10k and a 30k a few mA of extra current might be OK.And as far as adding extra parts to my circuit, I'm concerned with size only, not cost as it's a one-off.Incidentally, this is a circuit board I'll glue onto to an exercise grip to count down the reps that are set and then beep. I expect it to be ugly but just not too big.My first go-around was with 5v ProMini, powered by 7.6V LiPo, so I could measure the middle 'balance' connection, therefor keeping the ADC pin voltage below VCC. And assume that the voltage of the other cell is probably close to the one I'm measuring. This battery is just so physically big tho. Thought I'd try to figure out how to do it with a 10440 somehow.

author: Peabody
author_rank: Super Contributor
timestamp: September 14, 2020, 06:16:38 pm
content: There is a thread somewhere about measuring the battery voltage when the battery is directly driving Vcc (no regulator). Normally ADC would just give you 1023 all the time, but the idea was to somehow do an ADC measurement of the alternate 1.1V reference voltage, which would vary depending on Vcc voltage. Pretty clever, I think, but I don't remember how it was actually done.The other thing is that a normal battery protection circuit would automatically shut it down on low voltage. I believe 10440s do come in a protected version. See the datasheet for the DW01 for how the protection works. It would shut off at 2.4V.

author: Fixpoint
author_rank: Regular Contributor
timestamp: September 14, 2020, 06:28:21 pm
content: Quote from: Ducttape on September 14, 2020, 05:37:01 pmWell, it would just be in the µA range. Imagine you use a 200k trimpot. Then it would waste only 21 µA worst case.But when I think of better solutions, I would try to let the circuit run directly from the battery without any regulation, if that's possible for you. So the MCU would run from 4.2 V down to 2.5 V, that's a perfect range for the 328. Maybe you could experiment with a 2.5 V zener for providing the MCU with a low signal when the voltage drops below 2.5 V. Just a simple offhand idea

author: ledtester
author_rank: Super Contributor
timestamp: September 14, 2020, 06:33:55 pm
content: QuoteFirst thing to do is to add battery protection circuitry which protects against over-discharge.Next you should add brown-out detection to your code so the micro can stop any peripherals from using power when the battery runs low.Then you need to monitor the state of the battery. To do this without consuming power all the time, just connect the ground of your voltage divider to a GPIO pin. Most of the time set the GPIO pin to be an input and when you want to measure the battery set it to a digital output with value 0. Also use an internal voltage reference.Code:BATT+ --- /\/\/ ---- /\/\/ --- GPIO|ADCThe ADC pin is always high impedance. If the GPIO is also high impedance (i.e. an input pin) no current will flow from the battery. When the GPIO is set to a digital output with a value of 0 it is effectively grounded.

author: ledtester
author_rank: Super Contributor
timestamp: September 14, 2020, 06:47:12 pm
content: Quote from: Fixpoint on September 14, 2020, 06:28:21 pmThis is also a good idea because regulators have a quiescent current draw.

author: Ian.M
author_rank: Super Contributor
timestamp: September 14, 2020, 08:01:44 pm
content: There's no need for all that faffing about with dividers and what have you. The Arduino Pro Mini has an on-board 3.3V regulator. As the battery voltage drops past 3.3V its output is certain to drop as the regulator 'browns out'. It may start dropping as high as 3.5V input from the battery. When the battery is down to 3.0V (which is where to cut off in most cases) the ATmega's Vcc will be below 3.0V. It has an internal 1.1V (nominal) reference which can be measured relative to the Vcc supply by the ADC with no extra hardware required. Measure the reference with a fully charged battery and store the ADC result in EEPROM. Periodically measure the reference while running and if the ADC result is more than 10% greater than the value from the EEPROM, its time to shut off, as the battery must be down to about 3V.It then becomes a matter of how to shut off the Arduino. If you remove the power LED, and can shut off external peripherals effectively you may be able to simply put it in sleep mode to reduce the current consumption sufficiently.Otherwise you'll need an external PMOS power control transistor the Arduino can shut off and some way to manually turn it on in the first place. Seehttps://www.eevblog.com/forum/beginners/push-button-power-circuit-for-arduino-trying-to-modify-it-for-12v-input/where I posted a single I/O pin button sensing and power control circuit. N.B. you'll need low Vgs threshold MOSFETs, typically with a min. gate threshold voltage less than half your minimum Vcc.

author: Fixpoint
author_rank: Regular Contributor
timestamp: September 14, 2020, 08:20:07 pm
content: Quote from: Ian.M on September 14, 2020, 08:01:44 pmBut why should you use the regulator? Does the project really need it? Probably not. So, it could be a good idea to circumvent the regulator.

author: Ian.M
author_rank: Super Contributor
timestamp: September 14, 2020, 08:30:04 pm
content: Even if you bypass the regulator the same idea will work if you calibrate the 3.0V Vcc endpoint running from your bench supply, storing the reference voltage ADC value@3.0V Vcc in the EEPROM for later comparison.However, Ducttape hasn't told us if any other parts of the circuit need a regulated supply . . . .

author: Ducttape
author_rank: Regular Contributor
timestamp: September 14, 2020, 11:52:37 pm
content: Quote from: Ian.M on September 14, 2020, 08:30:04 pmSorry, indisposed for a few hours. Here's a screen capture from Diptrace. In case I haven't mentioned, pretty much a beginner. And appreciative of all the replies, which I am cogitating on.

author: David Hess
author_rank: Super Contributor
timestamp: September 14, 2020, 11:58:15 pm
content: I would use a CMOS set/reset flip-flop to control the on/off state. Then a reference and comparator can monitor the battery voltage and if it drops below a threshold, change the state of the flip-flop to remove power from the circuit, including the reference and comparator. Then the only power draw when off is from the CMOS set/reset flip-flop which can be microamps or less.

author: viperidae
author_rank: Frequent Contributor
timestamp: September 15, 2020, 09:42:23 am
content: Dave has done a video or few on soft-on/off switches. It can be as simple as a mosfet that bypasses a momentary push button. As long as you push the power button long enough for your code to start executing, it can turn on the mosfet to keep itself on. Then it decides to turn off, power draw drops to zero.From there you can monitor the battery voltage as ledtester suggested, using a GPIO to disconnect the voltage divider.What ever you choose to do, you should also add in a dedicated lithium ion cell protection IC or use protected cells. Over discharging a battery isn't going to do much more then destroy the life of the cell, but charging one that has been damaged from over discharge can pose a fire risk.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: September 15, 2020, 09:18:29 pm
content: What sort of current consumption in "off" mode is acceptable for you?is 20uA OK or not?Lots of microcontrollers can go into deep sleep modes in which current consumption can be well below 1uA, and they can still wake up occasionally to do something useful.When using a MOSfet as a switch, you're likely to have a uA or so of leakage, which increases exponentially (From memory, it doubles every 10 degrees Celcius)One of the few ways to completely disconnect your uC from a battery is with a good old fashioned bi-stable relay. Just give it a short pulse and it disconnects, with 0.0 current consumption (you may be able to measure some residual leakage over the PCB itself if it's dirty.Bipolar transistors tend to have lower leakage then MOSfets. I very much like the circuit as used in the ubiquitous AVR based transistor tester. With occasional use it can last multiple years from a single 9V battery with no hard turn off.

author: Ducttape
author_rank: Regular Contributor
timestamp: September 16, 2020, 02:17:00 pm
content: Quote from: Doctorandus_P on September 15, 2020, 09:18:29 pmThe primary concern I have is the case where I simply forget to turn it off. I'll never need it to operate unattended. In retrospect my post could have been titled a lot clearer, although I did clarify in the body of my text. If there's a good method of having it simply turn itself off after some period of inactivity that would be preferable, although if it could 'sleep' for, say, months that would probably suffice. I'm imagining forgetting to turn it off and then losing interest in it for a long time. And all of this is predicated on my, maybe inaccurate, assumption that completely draining a lithium battery presents a safety issue. I'm not so concerned with just ruining the battery.

author: voltsandjolts
author_rank: Unknown
timestamp: September 16, 2020, 03:40:05 pm
content: Like Peabody said in reply #3, the answer is use a protected cell, which has the feature you need built-in. It will protect the cell from over-discharge.Maybe the cell you have is protected.

author: ledtester
author_rank: Super Contributor
timestamp: September 16, 2020, 03:52:25 pm
content: QuoteCheck this info out:https://learn.sparkfun.com/tutorials/reducing-arduino-power-consumption/allFor a Pro Mini it will require modifying your board and adding sleep code to your program. At 10uA consumption a 1500 mAH battery will last a good while.But also be aware that not all Pro Mini's are alike:https://www.eevblog.com/forum/microcontrollers/arduino-pro-mini-two-copies-have-different-sleep-currents/100/

author: Ducttape
author_rank: Regular Contributor
timestamp: September 16, 2020, 04:08:42 pm
content: Quote from: voltsandjolts on September 16, 2020, 03:40:05 pmYou're probably right. If only someone made a battery holder like thishttps://www.mouser.com/datasheet/2/215/1075-741579.pdfthat would fit an elongated protected 10440, I'd be a happy camper. Haven't bought any 10440s yet. Might buy both protected and unprotected so I'm covered whichever direction I go.Although this is just for my personal use, and I could use a jst connector along with some tape to hold the battery in place, I'm just trying to do a downtown job.

author: SiliconWizard
author_rank: Super Contributor
timestamp: September 16, 2020, 04:45:04 pm
content: Several approaches to this as already mentioned. If the circuit is around an MCU, and said MCU has a low-power mode with "negligible" power draw, AND the rest of the circuit either draws "negligible" current, or you can switch it off from the MCU, then the solution could be entirely software-based; you'd only need to monitor the battery voltage, relatively straightforward if said MCU has an integrated ADC.I would favor an hardware-based solution, as the above solution may either not be usable (if the above requirements are not met), or the software could have bugs.What you'd basically need if shutting down the whole circuit at any moment is acceptable: a voltage supervisor and a power switch. Voltage supervisors are easy to find these days, with a whole range of thresholds, and some draw less than 1 uA. The power switch can be as simple as a MOSFET. Ideally you'd choose a voltage supervisor with some hysteresis (like two thresholds), or combine two, so that there be no "pumping effect" when the battery goes low (battery goes under threshold / circuit gets shut down / battery voltage then rises up a bit under minimal load / circuit gets powered on again / and so on...)