Does anyone have an opinion on the safety or battery longevity implications of using a microcontroller to detect under-voltage conditions in otherwise unprotected LiFe (not LiPo!) battery packs?
Is just running the main pack output voltage through a voltage divider and sampling it on an analog pin of the µc enough or should I use the balance connector to check the voltage of the individual cells? Assume I’m charging the pack with a good balance charger.
The plan would be to switch off the current to the strips with a MOSFET when the pack went under-voltage, and maybe flash a small indicator LED to indicate out-of-battery condition.
I get the feeling using a µc for this (as opposed to custom circuitry or a dedicated charge/discharge controller chip) with LiPo packs would be inviting disaster, but it’ll be fine with LiFe batteries as they’re much safer?
I see nothing wrong in that, but make sure you also cut the µc from the battery. I did that design mistake once, and the battery died.
@Robert_Atkins just some thoughts:
LiFePo4 are quite well tempered. Their lower discarge limit should be 2.8V; then you have around 2% charge left.
Depending on your setup make sure your µC still runs at the lowest voltage.
Use a P-Channel logic level Mosfet like https://github.com/tzapu/WiFiManager
P-Channel is important because a N-Channel will destroy your LEDs.
If your µC puts out a Gnd when not active your Mosfet will be ON (!)
Make sure you get accurate readings http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/
If 3 or 4 consecutive readings show undervoltage then throw off your LED load, do your beeping and blinking and then as Rasmus pointed out, finally throw off your µC (maybe with a second Mosfet, this time a N-Channel).
@Rasmus_Hildonen If the draw of the µC was less than the self-discharge current of the battery, turning off the µC is not really necessary is it? I ask because doing so significantly complicates the circuit.
(To be more precise, turning on the µC—or actually the regulator that powers the µC—with a pushbutton for long enough for it to switch a MOSFET on to turn the regulator supplying the µC on permanently so it can test the battery voltage and then turn the MOSFET off thus pulling the rug out from under itself, so to speak, turns out to be quite tricky. You have to use a P-channel MOSFET for this too @Juergen_Bruegl , as you have to keep the ground pin of the regulator grounded all the time and put the MOSFET switch on the high side of the regulator input. But to get the P-channel MOSFET to switch on, you have to drive its gate to 0V. But that means when the chip is off, you need to hold the gate to the battery voltage, which means somehow inverting the logic of the µC output pin. I saw something mentioning “open collector” outputs on µCs which might be a solution but I can’t get my head around it. There are regulators with a shutdown pin but I’m still stuck on how to drive that to logic-level high from the 12V battery supply from a momentary switch.)
Robert “My that was a large parenthetical, I probably should just draw a schematic” Atkins.
Aha—interesting. I want to do something slightly more sophisticated though, I want to disconnect the battery if/when it goes undervoltage, so for that I’m using the ATTiny.
After that stream-of-consciousness above I actually got something working. Simulate this circuit and then toggle the switch. The light will flash for another second, then the mcu turns off: https://circuits.io/circuits/3580527-switching-an-attiny85-through-an-lm7805-via-a-p-channel-mosfet
The next bit is the voltage sensing, using the ATTiny’s internal voltage reference as described in your links above (super helpful by the way, thanks!)