Constant Current battery capacity tester.

GHA

Well-known member
Joined
26 Jun 2013
Messages
12,400
Location
Hopefully somewhere warm
Visit site
Moving along from this one >
http://www.ybw.com/forums/showthread.php?501730-DIY-ammeter-dead-cool

Bit more work & now can control current draw pretty accurately and do the setup on a webpage using MQTT.
Overview, an ESP8266 measures current through an INA219 sensor and sets the current draw using a FET transistor. Soon will write all the data to a database (through signalk doing all the hard work) then plotting graphs is easy.

Vaguely similar to these videos but using a current sensor >
https://www.youtube.com/watch?v=jGEuJ45dnjs&t

Schematic sketch >


mApiZiL.png


vjRYG87.png

Code & stuff here if anyone wants a play>
https://github.com/boatybits/ConstantCurrent




Current control is so far a buk553 logic level mosfet driven from a pwm pin with a low pass filter to smooth out the voltage from pulses so the measurements aren't all or nothing. Something up with the config of the ina219, should be less noisy than that.


-------------------------------
So questions >
What to use as a load? Just a little 1ohm resister at the moment playing around with a 18650 battery but it's getting a bit smelly in here :) There is some resistance wire which could maybe be wrapped round some dowel & painted then in a bucket of water, but there might be some obvious method???

And any point using the FET to drive a much bigger power transister? Got a few lying around and was thinking of just paralleling some onto a big heatsink but winging it here really. They're rated 75W but suspect they'll need a hefty heatsink.
---------------------------------


Eventually the idea is to be able to do a "half' capacity test on the main batteries without having to turn anything off, constant current down to 12v or whatever then overly a plot of the data over the last time to see if the batts look OK or might be on the verge of collapse.....
 
Last edited:

JohnGC

Active member
Joined
21 Oct 2011
Messages
907
Location
Plymouth
Visit site
Driving MOSFET gates. Do not add the RC filter, this will just make it get hotter than it should. Although if you're running the PWM at a low frequency this may not be noticeable.

There are devices with much better Rds(on) than the BUK553 (which will dissipate 10W @ 10A and need heatsinking).

For the current measurement. You need to ensure the ground current in the load does not flow through the INA219's signal ground. You also need to filter the INA219's output to remove the PWM effect on the measurement; but since the INA219 includes the ADC I'm not sure you can do that - check the datasheet. You can try to synchronise the ADC measurement with the PWM on period. You can also average or (low pass filter) the results in software although this is not as good a solution.

For the load. Look on ebay for aluminium clad wire wound resistors and a suitable heatsink.

Alternatively, ditch the MOSFET and use an adjustable linear voltage regulator with and enable pin. Configure it as a constant current load, heatsink it and drive the enable pin with your PWM signal.

Have fun.
 

lw395

Well-known member
Joined
16 May 2007
Messages
41,951
Visit site
It looks like the current and voltage are varying a lot. Possibly a whole lot more than is revealed by the under-sampled measurement.
What does it look like on a scope?

Why not use a simple transistor current sink to set a steady analogue current?
A common power transisitor can dissipate tens of watts continuously. A resistor or two in series can share the power. Or you could use lightbulbs for the bulk of the power and just use the transistor to take more current as the volts drop off.
With a small fan, it's not hard to get rid of a few hundred watts.
 

rszemeti

Active member
Joined
17 Jul 2018
Messages
738
Location
Bewdley, Worcs
Visit site
You'll need to run quite high speed PWM and then make sure you have a suitable inductor in series with the load resistor to try and make sure the current drawn from the battery is free (as possible) from the PWM variations .. or your V/I readings are going to be all over the shop ...
 

lw395

Well-known member
Joined
16 May 2007
Messages
41,951
Visit site
You'll need to run quite high speed PWM and then make sure you have a suitable inductor in series with the load resistor to try and make sure the current drawn from the battery is free (as possible) from the PWM variations .. or your V/I readings are going to be all over the shop ...

Fast switching a transistor with an inductive load. What could possibly go wrong?
Actually I have just such a circuit, it's sold as a de-sulphator, the idea being that the voltage spikes break down suplhate in the battery, restoring its performance. It can put 50V spikes into a 12V battery.
 

lw395

Well-known member
Joined
16 May 2007
Messages
41,951
Visit site
.....

Alternatively, ditch the MOSFET and use an adjustable linear voltage regulator with and enable pin. Configure it as a constant current load, heatsink it and drive the enable pin with your PWM signal.

Have fun.
I don't know what reg IC you have in mind, but I don't know of one where this will work.
The enable pin is usually not very quick to respond and digital so, putting PWM into it will probably either enable it or disable it digitally.

A regulator IC configured as a current source, with the PWM used to control a voltage on the reference pin would be a valid approach.
 

lw395

Well-known member
Joined
16 May 2007
Messages
41,951
Visit site
TBH, if you want to measure the capacity of a battery, all you really need to do is keep the current 'roughly' constant, log current and voltage vs time, and most importantly, turn the current off when the volts drop below whatever safe level you choose.
Before microcontrollers got easy and cheap, we'd use a comparator circuit to turn the load off at the end voltage and a clock powered by the volts on the load. So the clock would stop when the volts got down to 11 or whatever.

A refinement is to automatically turn on a charger at the end of the load cycle.
 

GHA

Well-known member
Joined
26 Jun 2013
Messages
12,400
Location
Hopefully somewhere warm
Visit site
Driving MOSFET gates. Do not add the RC filter, this will just make it get hotter than it should. Although if you're running the PWM at a low frequency this may not be noticeable.

There are devices with much better Rds(on) than the BUK553 (which will dissipate 10W @ 10A and need heatsinking).

For the current measurement. You need to ensure the ground current in the load does not flow through the INA219's signal ground. You also need to filter the INA219's output to remove the PWM effect on the measurement; but since the INA219 includes the ADC I'm not sure you can do that - check the datasheet. You can try to synchronise the ADC measurement with the PWM on period. You can also average or (low pass filter) the results in software although this is not as good a solution.
Thanks for the reply... but,

Can't get it to work without the filter, it looks like the current is either flowing or not, seems random when the INA reads, sometimes full current, sometimes not. Averaging doesn't work, too random.

Voltage at the battery (18650) without the filter, just PWM driving the mosfet.>

FJFIoKp.png


With the filter, about 100mV of noise >

aRdaxpV.png


Good news is it works though :cool: Only took a few minutes to add a library so it sends data as signalk to a rasp Pi to record in a database & plot.
21:53:30 the FET gate was swapped from the filter to PWM. Then swapped back again.
Still the current draw ins't bang on stable but I suspect that's cos the smallest capacitor I could find was 10uf , google came up with some examples substantially less. Takes a moment for the PWM signal to change the voltage on the gate so maybe it's hunting around a bit with the lag. But it works! The FETs might get a bit warmer not on PWM, time to up the current now & find out. :cool:
Switched of bang on 2.8v as well.


A9i2r2H.png





For the load. Look on ebay for aluminium clad wire wound resistors and a suitable heatsink.

Alternatively, ditch the MOSFET and use an adjustable linear voltage regulator with and enable pin. Configure it as a constant current load, heatsink it and drive the enable pin with your PWM signal.

Have fun.[/QUOTE]
 

rszemeti

Active member
Joined
17 Jul 2018
Messages
738
Location
Bewdley, Worcs
Visit site
Fast switching a transistor with an inductive load. What could possibly go wrong?

Not a lot, I don't know what you do for a living, but I design and build "mid sized" switch mode power supplies (1kw to 15kw) and switch inductive loads (the transformer primary), all day, every day with FETs and IGBT's ... got a couple of hundred thousand units out in the field ...
 

rszemeti

Active member
Joined
17 Jul 2018
Messages
738
Location
Bewdley, Worcs
Visit site
If it was me, I would arrange the FET to switch PWM at around 50 to 100kHz into a resistive load ... and put a simple 3 or 5 pole L/C low pass filter based on a powdered-iron toroid and a smallish film cap to ensure that the battery saw minimal ripple current, which should make for minimal noise on the current sensor. Drive the fet with a simple low side gate driver such as the TC4427 and you'll be good to go.
 
Last edited:

lw395

Well-known member
Joined
16 May 2007
Messages
41,951
Visit site
Not a lot, I don't know what you do for a living, but I design and build "mid sized" switch mode power supplies (1kw to 15kw) and switch inductive loads (the transformer primary), all day, every day with FETs and IGBT's ... got a couple of hundred thousand units out in the field ...

Then you'll know that the effect of the inductor is anything but smoothing the current in the transistor.
Not that steady DC current would be at all desirable in the primary of a switcher of course.
 

GHA

Well-known member
Joined
26 Jun 2013
Messages
12,400
Location
Hopefully somewhere warm
Visit site
If it was me, I would arrange the FET to switch PWM at around 50 to 100kHz into a resistive load ... and put a simple 3 or 5 pole L/C low pass filter based on a powdered-iron toroid and a smallish film cap to ensure that the battery saw minimal ripple current, which should make for minimal noise on the current sensor. Drive the fet with a simple low side gate driver such as the TC4427 and you'll be good to go.

I really can't see the point. This works. Lucked out in finding a big heat sink with a couple of 2Ohm 25W power resistors & a thermistor already mounted. (Never walk past a boatyard wheely bin without having a peek :) )
So without any heat compound or a fan the FET seems to top out at about 45DegC drawing 2A @ 12v. A handful of them should easily cope with what's required for 5A or so which would be needed to get up to 11.5A on top of house loads and everything else turned on.
Current is still a bit unstable which should be sortable but even as is it's only a few mA and looks plenty accurate enough for the job. It works, why try harder :)

To be added is sending incremental Ah to signalk for logging, which should be pretty easy. And a thermometer on a battery has been on the list for a while.



qChkfg8.png
 
Last edited:

lw395

Well-known member
Joined
16 May 2007
Messages
41,951
Visit site
I really can't see the point. ....

Why do you think there is so much 'noise' in your measurements?
Do your processed measurements agree with a multimeter?

Do you think the noisy nature of the current drawn might influence the capacity exhibited?
The effects of fairly high frequency ripple voltages and currents on lead acid batteries have been debated 'some' over the years. Both in the context of de-sulphators and pulsing chargers doing magick repairs to old batteries and theories that current spikes can do damage.
Given that the capacity of a battery is a function of its discharge rate, would you expect discharging a battery with a varying current to influence the indicated capacity?

The point of drawing a steady, clean DC current from a battery under test is that it's a meaningful, repeatable measurement.
 

GHA

Well-known member
Joined
26 Jun 2013
Messages
12,400
Location
Hopefully somewhere warm
Visit site
Why do you think there is so much 'noise' in your measurements?
Do your processed measurements agree with a multimeter?
Multi meter too slow, and you need plots to see what's going on. Probably makes little to no difference in the real world but it looks like it's reacting too slow, the esp runs @ 16Mhz, so should be able to trak much tighter than this , mA & pulse width output. Not that a big deal but annoying enugh to keep coming back to.
bGw9oUB.png



Do you think the noisy nature of the current drawn might influence the capacity exhibited?
Doubt it. It's only a few mA.



The effects of fairly high frequency ripple voltages and currents on lead acid batteries have been debated 'some' over the years. Both in the context of de-sulphators and pulsing chargers doing magick repairs to old batteries and theories that current spikes can do damage.

Pulsing sounds more like snake oil....

http://www.cruisersforum.com/forums...-flooded-cell-batteries-12707.html#post132464
[QUOTEYes, I know about the pulsing vs. equalization thing. Our testing was to try to determine whether the little pulsing devices sold by a number of manufacturers really did anything. We worked up a testing regime which involved a series of full charges and discharges to 10.5VDC under load (all done WITHOUT the pulsers), followed by a series of cycles of pulsing for a few days, then load testing, then recharging, then pulsing for a few more days, etc. Tons of data, a few surprises, learned a lot.

You'll be interested to know that after almost six months of testing using the above methodology, we decided to equalize the T-105s ONE TIME to see what would happen. Presto...the results were much more positive than had been the pulsing/charging/discharging over the previous six months. See, e.g., this graph: Gallery :: Miscellaneous 2007 :: First20minEqual][/QUOTE]



The point of drawing a steady, clean DC current from a battery under test is that it's a meaningful, repeatable measurement.
That's the whole point of the exercise...
Suspect temperature will completely swamp any tiny differences which may or may not come from a few mA ripple on the current draw.
 

rszemeti

Active member
Joined
17 Jul 2018
Messages
738
Location
Bewdley, Worcs
Visit site
The reason he has so much noise on his voltage measurements is because sometimes he is sampling during a PWM 'on' point, sometimes during a PWM 'off' point ... he needs to either sync his measurements to the PWM so he is always sampling at the same point in the PWM cycle .. or speed up the PWM and filter the current draw from the battery so the battery "sees" a constant DC (or at least low ripple) current to get nice smooth measurement. A (poor) alternative would be to low pass filter the feed to the voltage and current sense sensors with something like 10k/100uF.
 

rszemeti

Active member
Joined
17 Jul 2018
Messages
738
Location
Bewdley, Worcs
Visit site
Then you'll know that the effect of the inductor is anything but smoothing the current in the transistor.
Not that steady DC current would be at all desirable in the primary of a switcher of course.

Sigh ... you don't really get it do you?

Best I leave you to your project, good luck with your +- 100mv measurements ...
 

lw395

Well-known member
Joined
16 May 2007
Messages
41,951
Visit site
The reason he has so much noise on his voltage measurements is because sometimes he is sampling during a PWM 'on' point, sometimes during a PWM 'off' point ... he needs to either sync his measurements to the PWM so he is always sampling at the same point in the PWM cycle .. or speed up the PWM and filter the current draw from the battery so the battery "sees" a constant DC (or at least low ripple) current to get nice smooth measurement. A (poor) alternative would be to low pass filter the feed to the voltage and current sense sensors with something like 10k/100uF.

But which point in the PWM cycle would be the 'right' voltage?
I'd suggest looking at the waveforms with a scope of adequate bandwidth.
 

GHA

Well-known member
Joined
26 Jun 2013
Messages
12,400
Location
Hopefully somewhere warm
Visit site
Upping the PWM freq to 5Khz & tweaking the RC has got the ripple down to about +/- 5mA @ 670mA, under 1%.
Plenty good enough. So going rather well so far. :cool:


KUer3rw.png
 
Last edited:

GHA

Well-known member
Joined
26 Jun 2013
Messages
12,400
Location
Hopefully somewhere warm
Visit site
First test and it works! :eek:

Only 1A on an 18650 but seems to do just fine. The used 18650 from eBay had a sticker saying 1.37Ah but came out looking more like 1.62Ah. I think, 1A for 102 minutes. Or is 2.8V to low to go? Though 3v would have made little difference.

Big heat sink & try on the main batteries next...

Openplotter/signalk behaving impeccably as ever on the Raspberry Pi, receiving SigK data updates 5 times a second and saving to a database. Playing a cool jazz web streaming station at the same time without breaking into a sweat :cool:


n6ym4WI.png
 
Last edited:
Top