Battery capacity diy tester

GHA

Well-Known Member
Joined
26 Jun 2013
Messages
12,552
Location
Hopefully somewhere warm
Visit site
Must be time to resurrect an old project! A while ago I played around with an arduino to record battery discharge data with a fixed load. Like this.....


pbmLywj.jpg


So moving forward, a Raspberry Pi might be better so latest plan is to have a Pi attached to a FET (or many) to control the current and keep it constant, and measure the current, voltage and temperature recording it every second probably into rddtools.

Questions:
The Pi uses PWM, basically turning the transistor on and off many thousands of time a second - will this make any difference than controlling the transistor analog where it doesn't have this very rapid on / off? I'm thinking no, the battery won't know, it's like a big Capacitor. But you never know..

And temperature, 20 hour rate measurements are done at 77degF I think, so how accurate would it be to factor in the temp differences. For example, testing a battery at, say, 60degF, could you calc the different results to get a value for if it was 77degF - would that give any meaningful results ?

Even if it was just a rough calibration in think it would be useful, I suspect most (nearly all? ) cruisers don't have much idea of the state of their battery banks until it's near the end...


Tia
 
I don't know what frequency the Pi would use for PWM, but the battery may not look much like a big capacitor at that frequency.
You will probably do better to smooth the drive to the FET and load the battery with DC.
If you want to cheat, you might get a fairly constant power load by using a DC-DC converter to take the batttery volts down to say 6V and loading that with a fat resistor.
 
I made one a few years ago http://www.picaxeforum.co.uk/archive/index.php/t-9547.html
It uses a picaxe to monitor V and A until the voltage was low driving a hefty load (40W bulb) and integrated amp hours to get a result estimating % of capacity used from starting and ending volts.

Yours sounds much more sophisticated. I'm not sure how good mine is. I only ever applied it to a fairly knackered battery and I now know there's more to batteries such as recovery time after supplying a hefty load. I never thought of allowing for temperature.

The bit of mine that's interesting (maybe) is the Hall effect current sensor. No need for a shunt, just put a cable through the hole

Derek
 
I don't think a lead acid battery can be assumed to be like a capacitor. Peukert's Law that ties residual capacity to discharge rate would suggest the PWM will discharge the battery faster than a steady discharge of the same average current. But I'm sure you could programme your Arduino accordingly :)
 
You can do it with a latched relay in series with the load that will drop out at 11.0V and measure how long it stays on for. You could use a electromechanical counter or 12V clock to time it.
 
I don't know what frequency the Pi would use for PWM, but the battery may not look much like a big capacitor at that frequency.
You will probably do better to smooth the drive to the FET and load the battery with DC.
If you want to cheat, you might get a fairly constant power load by using a DC-DC converter to take the batttery volts down to say 6V and loading that with a fat resistor.
A very quick google suggests that the PWM frequency on a Pi is 200Mhz, does it matter what the battery looks like to the load or does the battery know that the load is being turned on or off at 200 million times a second? At that frequency wouldn't the capacitance of the wires smooth it out a bit as well? Well beyond my electronics knowledge :)

And dc/dc converters - they use PWM switching as well, don't they?
 
I don't think a lead acid battery can be assumed to be like a capacitor. Peukert's Law that ties residual capacity to discharge rate would suggest the PWM will discharge the battery faster than a steady discharge of the same average current. But I'm sure you could programme your Arduino accordingly :)
That's just it, would the battery even know the load was actually HF AC with the capacitance throughout the system.
Anyone know how commercial systems do it?

Anyway, I think the PWM is not a big deal, the "can you calc reliably for temperature " is potentially a bigger deal . Bearing in mind the end result is desire to know how fit your batteries are compared with a few months ago when you last tested them.
When it was hotter :)
 
I have a Smartguage system on my battery banks that allegedly knows all about Peukert's Law. But in terms of indicating remaining capacity I really don't trust it as it always seems too pessimistic. I think it also takes temperature into account but even so I think it's too complicated a problem for practical systems to be more than a rough guide.
 
I have a Smartguage system on my battery banks that allegedly knows all about Peukert's Law. But in terms of indicating remaining capacity I really don't trust it as it always seems too pessimistic. I think it also takes temperature into account but even so I think it's too complicated a problem for practical systems to be more than a rough guide.

The smartgauge does seem to get some very good press.
http://www.pbase.com/mainecruising/smart_gauge

Maybe it's right and your batteries don't have as much capacity left as you'd like to think.... ;)

But as far as testing how much capacity a battery has it doesn't help, it might be good at guessing how full the bucket is, but gives no clues as to how big the bucket is.
 
A very quick google suggests that the PWM frequency on a Pi is 200Mhz, does it matter what the battery looks like to the load or does the battery know that the load is being turned on or off at 200 million times a second? At that frequency wouldn't the capacitance of the wires smooth it out a bit as well? Well beyond my electronics knowledge :)

And dc/dc converters - they use PWM switching as well, don't they?

At that frequency (or even 1/1000th of it) the wiring inductance and battery capacitance will act as a low pass filter and convert the pwm to a dc load. (low pass filtering a pwm signal is a well known method of converting a digital signal to analogue)
 
At that frequency (or even 1/1000th of it) the wiring inductance and battery capacitance will act as a low pass filter and convert the pwm to a dc load. (low pass filtering a pwm signal is a well known method of converting a digital signal to analogue)
Thanks. Though I don't think the FET could keep up with that PWM frequency. Even so, doesn't look like it will be a problem.

And looking at the trojan datasheet, they have a handy temp compensation graph so if that's accurate then getting a good handle on capacity should be possible.


QLzA2HZ.png
 
Thanks. Though I don't think the FET could keep up with that PWM frequency. Even so, doesn't look like it will be a problem.

And looking at the trojan datasheet, they have a handy temp compensation graph so if that's accurate then getting a good handle on capacity should be possible.


QLzA2HZ.png

On reflection, I'm sure the pwm frequency won't be 200Mhz. I no nowt about the Pi, but I'd guess the system clock frequency is 20Mhz or less, and pwm frequencies are usually much less than system clock, so probably under 2Mhz not that this makes any difference - the low pass filtering will still result in effectively a dc load.
 
Some thoughts...

Great project.
Why use a RPi when an Arduino is more than adequate.
PWM makes it hard to measure the current in the feedback loop. I suggest using an 8-bit port with weighted loads on each bit.
A Pi just makes everything easier, you can VPN into it from a phone or tablet plus use the excellent rddtools for data storage and creating graphs.
I'll play around with PWM, averaging the current over many readings hopefully will be good enough, doesn't need to be high speed or anything. Using different loads would add complexity, I haven't even sorted out a load yet but got some resistance wire off ebay which might do the job.
 
Some thoughts...

Great project.
Why use a RPi when an Arduino is more than adequate.
PWM makes it hard to measure the current in the feedback loop. I suggest using an 8-bit port with weighted loads on each bit.

You don't need to explicitly measure the current, you can calculate it from the pwm duty cycle as a percentage of the current at 100% duty cycle.
 
On reflection, I'm sure the pwm frequency won't be 200Mhz. I no nowt about the Pi, but I'd guess the system clock frequency is 20Mhz or less, and pwm frequencies are usually much less than system clock, so probably under 2Mhz not that this makes any difference - the low pass filtering will still result in effectively a dc load.

Looks like it's something like 22Mhz, though I'll most likely be using Python so more like 77Khz or below.
http://codeandlife.com/2012/07/03/benchmarking-raspberry-pi-gpio-speed/
Doubt it will make much difference though, as you say.


The Pi 3 has a quad cortex A53 running at 1.2Ghz, for 4 quid you can get a Pi zero with an ARM11 running at 1Ghz. Amazing little things :cool:
 
Looks like it's something like 22Mhz, though I'll most likely be using Python so more like 77Khz or below.
http://codeandlife.com/2012/07/03/benchmarking-raspberry-pi-gpio-speed/
Doubt it will make much difference though, as you say.


The Pi 3 has a quad cortex A53 running at 1.2Ghz, for 4 quid you can get a Pi zero with an ARM11 running at 1Ghz. Amazing little things :cool:

Yes, amazing amount of computing power in such a small device, and all thanks to the 'arms race', which drove most technology developments spin offs.
 
Peukert's Law that ties residual capacity to discharge rate would suggest the PWM will discharge the battery faster than a steady discharge of the same average current. But I'm sure you could programme your Arduino accordingly :)

I disagree with that.
Peukert's expression (it's not a law, it's purely empirical) is concerned with the useable capacity at different discharge rates. If you take 25Ah out of a 100Ah battery then there is 75Ah left in it, regardless of the rate at which you took out the 25Ah. The same amount of active material has been reacted. If you revert to the nominal rate of the battery (i.e. a 5A discharge if the battery is rated 100Ah at the 20 hr rate etc) you will be able to extract the full remaining capacity.
This is a standard situation in sizing batteries for mixed discharges such as switching stations.
The measured capacity will not be affected from this point of view by the pulsed discharge.

There is theoretically a different potential problem with repeated pulse discharges though and that is the coup de foudre (whiplash) effect whereby at the start of a pulse discharge the voltage drops then recovers. It's as though the battery has inertia. I think it would only matter with a much lower pulse rate though, I'm pretty sure the rate here would fool the battery. It's a minor effect anyway except at very high discharge rates.
 
Top