Mesuring a 12v lead acid battery - Page 1
Forum section: electronics / projects

author: towlerg
author_rank: Contributor
timestamp: June 27, 2018, 01:36:19 pm
content: I've asked this question on several boards but never arrived at a definative result.It seems odd to me that there isn't a whole raft of curcuits to do just this but there isn't and I'm programmer withverylimited anologue skills.Assuming a 10bit ADC, a voltage swing of 10.5v to 40v (does that allow enough for transients?), I'd like a curcuit with input and transient protection which generates an output of 0-5v for an input of 10.5-15v. I know that can be done with a resistor divider but it seems wastefull to throw away so mush of the range measuring meaningless voltages (0-10.5v).It goes without saying, but I will, the curcuit needs to be linear.I'm sure such a curcuit would be usefull in many situations. In my case I have 2 batteries (cranking and leasure) being trickle charged from a single PV controller, manually switched. I'd like this to be automatic driven by a set of rules. The batteries can also be charged from an alternator, also manually switched.

author: iMo
author_rank: Super Contributor
timestamp: June 27, 2018, 09:10:09 pm
content: QuoteThis will subtract 10V from your V1 (the input voltage).An example only, no input protection.In the simulation below the V1 goes from 10.0V to 15.0V step 0.5V.The output goes from 0.0 to 5.0V.

author: tautech
author_rank: Super Contributor
timestamp: June 27, 2018, 09:46:20 pm
content: There's chips that are perfectly suited to your requirements with a little bit of math and quantitative measurement checks.Pretty easy to breadboard it and get it setup just right.ICL7665S is what I use.Datasheet attached.

author: iMo
author_rank: Super Contributor
timestamp: June 27, 2018, 09:57:04 pm
content: And here an example with an input protection. The opamp needs decoupling capacitors at its power rails, of course.Provided as-is.Use at your own risk.

author: Seekonk
author_rank: Super Contributor
timestamp: June 27, 2018, 10:10:24 pm
content: No, it is not a waste. You will just have 10 bits of garbage measuring in that reduced range. You know almost nothing by measuring a batteries voltage. You can get a nice digital output, but it is hokum. I have a microprocessor running my entire camp from refrigeration to hot water to a dishwasher and it is very energy efficient. It needs to be smart, but not that accurate. It will be a good exercise, and then you will get it out of your system.

author: SL4P
author_rank: Super Contributor
timestamp: June 28, 2018, 10:15:07 am
content: Another old trick is to review the battery’s history, then apply a short term ‘extra’ load to observe the discharge rate at the known voltage & load. Merge that into your history for next time.If the discharge rate becomes too aggressive, you can notify the condition / replacement to the user.

author: Seekonk
author_rank: Super Contributor
timestamp: June 28, 2018, 02:39:34 pm
content: The voltage divider is your best protection for the MCU. I would suggest at least 100K between the voltage source and the input pin. The A/D input needs a low impedance source because there is a current surge in the read. A .1uF minimum capacitor from the input pin to common will solve that. If you are willing to waste some current, A TL431 in series with the voltage divider will provide that 10 or so offset volts easily wasting about 2ma. You still need resistor isolation to the input pin. These inputs are pretty well protected and don't need external diodes. If there is something sufficient to damage it, nothing else will survive either. Use a running average to get rid of noise.

author: towlerg
author_rank: Contributor
timestamp: June 29, 2018, 05:02:06 pm
content: Thanks all for great input, will digest and return with more questions.Just to be sure my math is right, if I use a potential dividor over the full range 0-15 but only 10.5-15 is meaningfull. I'm losing about 2/3 of my resolution.15/1024 = 68mV per step, so I guess Seekonk is right 10bits over the whole range probably is good enough.

author: Seekonk
author_rank: Super Contributor
timestamp: June 29, 2018, 08:10:31 pm
content: It is worse than that since the divider should go up to probably 18V. It takes a half hour of the battery being at rest to get a viable reading to determine charge state, and when does that ever happen. I'd try the TL431 thing. Use a 47K/100K divider on the 431 to give you about 7.5V of offset. Feed that into a 3K3 resistor as about a 2ma load to common. Connect your voltage divider for the A/D across that. Don't forget to protect the input, use a 47K to the input pin with .1uF to common.

author: towlerg
author_rank: Contributor
timestamp: June 30, 2018, 01:50:43 pm
content: @Seekonk Would it be completly out of line to ask you to draw the curcuit you propose? As I said my analogue skills are minimal to say the least.

author: mtdoc
author_rank: Super Contributor
timestamp: June 30, 2018, 02:40:53 pm
content: Seekonk is right. Even with LA batteries, voltage is not a great indicator of SOC. For your application, you really should be counting Coulombs. Only by tracking charge in and out of your battery will you really know SOC at any given time.You can find cheap inline meters on eBay to do this. For DIY, you can use a current shunt and Arduino or MCU of your choice. Search “arduino coulomb counter”There are also ICs designed for this purpose. For example the LTC4150. Sparkfun sells a small breakout board for it and has some good tutorials on its use. However these ICs, are generally designed for LiPo voltages so you’ll need some analog circuitry to raise the ground, etc. I’m not sure if there is an IC available that is purposely designed to do this for 12V LA batteries.

author: TJ232
author_rank: Frequent Contributor
timestamp: July 01, 2018, 04:12:54 am
content: A while ago I was working on a project where it was needed to remotely monitor a lot of batteries so I ended up with this solution:http://esp8266-projects.org/category/smartmonitor/It's using INA219 and it brings together on a small PCB: Voltage, Current and Power monitoring capabilities, plus a proper hardware RTC with integrated Alarm and Timer functions. The RTC and the RTC alarm MOSFET switch were used to automatically start/shut-down the remote device for power conservation. After about 3 years the devices are still in running smooth in the wild.

author: towlerg
author_rank: Contributor
timestamp: July 01, 2018, 01:12:36 pm
content: I think I've not made myself clear, my aim is to ensure that what ever power is available will be prioritised to the cranking battery. I am vaguely aware of the oddities of lead acid batterys but a simple rule like -Every 10 mins on a timer (or maybe 1 hour? suggestions?)IF CrankingBattery > 12.5VSwitch charge to LeisureBatteryElseSwitch charge to CrankingBatteryEnd IFI appreciate that this is not optimal and battery condition is better ascertained by measuring power but as the PV cells are only going to deliver absolute max 2A and normally a great deal less, this solution seems better than completly charging the cranking battery and having the PV controller dump power that could usefully be applied to the leisure battery.I could add more complex rules if necessary, eg if the cranking battery is below 12V then switching is suspended for 24Hrs.

author: NorthGuy
author_rank: Super Contributor
timestamp: July 01, 2018, 01:21:11 pm
content: Quote from: towlerg on July 01, 2018, 01:12:36 pmWhen you charge a battery, the voltage goes up - will be way higher than 12.5V. When you stop, the voltage goes down until it settles, and the settlement may take long time. If there's any load on the battery, the voltage goes down.Thus, measuring only voltage won't give you much insight into whether the battery is fully charged or not. Therefore, if your device only measures the voltage, it doesn't make any sense to try to get a precise measurement. 0.1V is plenty.

author: Seekonk
author_rank: Super Contributor
timestamp: July 01, 2018, 07:08:48 pm
content: Well, this could be fun. Do you have a charge controller? You don't need one and could use a cheap buck converter and hold the panels at power point with the micro. What do you have for panels? If not yet consider the higher voltage of grid tie panels.

author: towlerg
author_rank: Contributor
timestamp: July 01, 2018, 08:56:48 pm
content: QuoteYes but I won't be measuring the battery with the controller in curcuit. Ball park figure of how long it takes to settle? I could apply a small load to speed things along.QuoteAs I said in my original post I have a single controller. I know that twin controllers are available to do the what I am trying to do (no doubt in a much more sophisicated way).

author: Zero999
author_rank: Super Contributor
timestamp: July 02, 2018, 03:15:51 pm
content: Quote from: imo on June 27, 2018, 09:10:09 pmThe disadvantage with that is, it requires a bipolar power supply.How about the TL431 and a current mirror? It's much simpler and only requires a single supply.Of course, this circuit will saturate at 10mV to 20mV, from the negative rail, which is a downside of any single supply circuit.The TL431 is set to 10V. R1 and R2 can be 30k and 10k, which are standard E24 values, if not such a great level of precision is required.

author: towlerg
author_rank: Contributor
timestamp: July 03, 2018, 12:57:37 pm
content: Oh, that looks interesting.QuoteIn practical terms, what does that mean.

author: Zero999
author_rank: Super Contributor
timestamp: July 03, 2018, 03:34:11 pm
content: Quote from: towlerg on July 03, 2018, 12:57:37 pmQ1 & Q2 form a constant current sink, which draws about 1.3mA through the TL431, irrespective of the input voltage. Unfortunately there's a limit to how low the voltage across Q1 can go before it's unable to sink over 1mA, causing the output voltage to become stuck, just above the 0V rail. In other words, the lower output range of this circuit is limited by the saturation voltage of Q1.Looking at the data sheet for the BC547, the saturation voltage is just under 30mV, with a collector current of 1mA, so this will be the expected minimum output voltage from this circuit: I was a bit optimistic in my previous estimate of 10mV to 20mV. Reversing the emitter and collector connections of Q1 and Q2 will probably result in a lower saturation voltage, but R3 might need to be reduced a bit, as the Hfe will be lower in reverse mode, so more current will be taken by the bases.http://www.mouser.com/ds/2/149/BC547-190204.pdf

author: towlerg
author_rank: Contributor
timestamp: July 04, 2018, 12:33:48 pm
content: Code:In practical terms, what does that mean.Isn't it funny how an appearently simple sentence can be interpreted so diffently.I was hoping for something like if the input voltage is below 5v, sparks will fly or I don't know what ...How about, what is the real world consequence of this limitation (which of course is what I should have said in the first place, sorry Hero999).I really wish I understood your original explanation but I'm a bit to old to learn new tricks and if I need an external stimuli to be available I usually use one of the cheap modules intended for the Arduino. Although I think Arduino is a dead end, tinkerers like myself have much to thank it for, the level of interest generated means that you can buy a cheap modules on ebay for much less than the components in them.

author: Zero999
author_rank: Super Contributor
timestamp: July 04, 2018, 01:21:30 pm
content: Quote from: towlerg on July 04, 2018, 12:33:48 pmIn other words, the guaranteed minimum output voltage from this circuit is 30mV, so if the input voltage drops below 10V + 30mV = 10.03V, then the output voltage will sit at 30mV.There are a few tweaks which could improve this slightly, but it's probably already good enough for your application.

author: towlerg
author_rank: Contributor
timestamp: July 06, 2018, 02:21:43 pm
content: Hugh thanks to everyone who posted, I'm going to build Hero999's design. For input protection, a series resistor and a cap to gnd. Does it matter the order of the R and the C? Suitable values?

author: Zero999
author_rank: Super Contributor
timestamp: July 06, 2018, 03:19:40 pm
content: The input takes 1.3mA, from the 12V supply, so no, a series resistor is not a good idea, as it will drop additional voltage.A series resistor could be added between this circuit's output and MCU input, but it would have to be quite small: 10k should do and yes a small capacitor, say 10nF between the MCU's input and 0V would help too.

author: schmitt trigger
author_rank: Super Contributor
timestamp: July 06, 2018, 03:26:49 pm
content: Hero's circuit is a very elegant one which uses commonly available components.Can't get any better than that.The only thing I would suggest is to set the TL431 voltage at 9 volts. The added range will allow you to measure over-discharge batteries.

author: Zero999
author_rank: Super Contributor
timestamp: July 06, 2018, 04:00:08 pm
content: Quote from: schmitt trigger on July 06, 2018, 03:26:49 pmAt the expense of being able to measure voltages above 14V, which is important, when it's charging.https://www.silvertel.com/images/technical-articles/charging_sealed_lead_acid_batteries.pdfhttp://batteryuniversity.com/learn/article/charging_the_lead_acid_batteryThere's not much point in going below 10V: if the voltage is any lower, then the battery is already flat.

author: schmitt trigger
author_rank: Super Contributor
timestamp: July 07, 2018, 03:41:37 pm
content: You are correct.I was confusing the threshold voltage of other battery chemistries.

author: NorthGuy
author_rank: Super Contributor
timestamp: July 07, 2018, 05:01:55 pm
content: Quote from: towlerg on July 01, 2018, 08:56:48 pmIt depends on the battery and the accuracy you need. Couple hours might be enough. You can charge the battery then monitor the settlement process for, say, 24 hours. This will give you an idea of the settlement speed.

author: towlerg
author_rank: Contributor
timestamp: July 09, 2018, 03:48:15 pm
content: @NorthguyOh, thats a good idea, I only need to monitor the cranking battery (A) so a SPDT relay will allow that battery to be either the monitor curcuit or the controller. A SPST relay will either connect battery B to the conroller or disconnect it.So my rule is now -a. Take a peek at Ab. If A above 12.6vswitch to B and monitor A, if A below 12.6v at any time main loopElseswitch to A for 1 hourEndd. Loop foreverThis overcomes any potential problems with monitoring a battery being charged by controller, but leaves the problem of monitoring a battery being charged by alternator. If I could detect when the engine is running and disconnect the monitor, I only need to worry about spikes and nasties on Vdd not on ADC input.Thanks again for that and all the other suggestions.One more question, approx what current will the 10v-15v curcuit draw from Vdd and from battery?I ask because if its only tiny I'll leave it connected and powered but if it's high I'll dissconect from the batteries and remove supply power to it except when taking a measurment.

author: Zero999
author_rank: Super Contributor
timestamp: July 11, 2018, 09:31:43 am
content: Quote from: towlerg on July 09, 2018, 03:48:15 pmAbout 1.3mA.Whether or not that makes any difference, depends on how big the battery is. If the battery is small, say 1.3Ah, it will fully discharge in 1000 hours, with this circuit connected, but if the battery is much larger, 26Ah, it will take 20000 hours.If low power operation is required, the TL431 could be replaced with a different IC, which requires less current and the resistor values all increased, but if that's not good enough, a totally different approach is required.EDIT:Where is the 5V supply coming from? If it's off the battery, via a regulator, that might be the main drain on the battery.If the 5V is off, Q1 will turn off and no current will be taken from the input. To save power, the 5V supply, to the circuit I posted, could be an MCU output pin, which could be set to high, when a measurement is taken and low, when it's not needed.

author: NorthGuy
author_rank: Super Contributor
timestamp: July 11, 2018, 04:16:03 pm
content: Quote from: towlerg on July 09, 2018, 03:48:15 pmBe careful with that. If you overcharge, the water evaporizes from the electrolyte (producing hydrogen, by the way), the plates get exposed and then a little spark cause an explosion. Generac Guardian generators used to overcharge their cranking battery which caused real big explosions - you probably can find videos of damages on Youtube.

author: helius
author_rank: Super Contributor
timestamp: July 11, 2018, 05:31:17 pm
content: If some system was consistently overcharging its batteries, it was using the wrong voltage. Gassing occurs at the equalization voltage, which should not be used to charge it normally.

author: towlerg
author_rank: Contributor
timestamp: July 13, 2018, 01:20:27 pm
content: @Northguy and Helios - I'm using a PV controller. My project is to switch the controllers output between two batteries but with a priority on the cranking battery.@Hero999 - I certainly will power the cuircuit via a uC pin. The battery will be min 50Ah. 5V supply will be regulated from the 12v battery. I guess to optimise I need to be able to detect when the controller is not providing power (at night) and go into sleep mode.I also need to detect when the ignition is on so that I can disconnect the monitoring curcuit but leave the controller attached to the cranking battery.Thanks again to all who posted.