Battery capacity diy tester

Quite so, of course you need to measure the current, that's the whole point!
Which is where one of these comes in..
ActualModule.jpg


Hall effect current sensor. ACS712, 3 quid odd off ebay
Along with a 16 bit 4 channel ADC..fiver ish Dead accurate. Will measure the voltage of the battery under test and the current sensor output which is a 0 - 5v


1085-03.jpg


And waterproof thermometer..a few quid for a few of them
ds18b20%20dualtronica.jpg


And a Pi!

Getting a little more complex, Python is a new place for me but I had it controlling a FET earlier using PWM pretty quickly. But the what I thought were logic level FETs didn't really open up much with the 3.3v coming out of the Pi so another transistor will probably be needed to use a higher voltage to switch the FET (s) .
But little baby steps..... :cool:

Need a load! Hmm..
 
Last edited:
So as I said, hard to measure the current when using PWM. The only reliable way would be to heat something up with it, not accurate, but repeatable.
Need to wait an see what it looks like battery side after the battery and wiring plus any additional smoothing capacitors have done their stuff on a load switching at several Mhz. Then average 50 odd current readings. Will be easy to confirm accuracy anyway.
 
Good luck smoothing a PWM feed from a battery. In order to smooth a signal, the reactance of the smoothing component has to be many times smaller than the resistance of the source. Internal resistance of a LA battery is probably in the region of 1mΩ.
A quick Google has other people having success with the Hall effect acs712 current sensors so one shall carry on with optimism :) if it comes to it then slowing down the pwm frequency and reading during a high then X the duty cycle would be an option.
 
Another question for the lx boffins who actually know what they are talking about.....

So we have a Pi capable of outputting pwm plus a fet or several controlling current, so why not filter the pwm to more like dc before it gets to the gate of the fet so it acts more like a controllable resistance?

The program shouldn't be bothered about exactly what pwm it's outputting, it will just sneak it up or down so the current is right. And slowly, maybe help keeping the ripple down? Learning as I go here.

FET might get a bit warm though, maybe a few in parallel with a load which would pull enough current at 10.5v so they don't have to work too hard.

Comments?
 
I assume you mean a varying analogue signal driving the FET, rather than DC.
Pretty much the same thing given the small change over 20 hours. :)
I think the problem here may be that the FET will start to dissipate power if it isn't on or off.
Why is that a problem if it's well within the Datasheet values and the FETs don't get too hot?
 
GHA

You need to distinguish between the frequency fed to the PWM generator and the PWM output frequency.

The Pi's ARM micro (like all ARMs) has multiple clock domains. Which one is routed to the PWM hardware and at what speed it runs is dependent on the programming of that clock and the timer's pre-scaler. The frequency seen at the MOSFET gate will be the clock frequency divided by the PWM resolution (number of steps between off and on).

For example, if the clock is 1MHz and the PWM resolution is 256 (using and 8-bit counter) then the frequency at the MOSFET gate will be 1MHz / 256 = 3.906kHz.

When selecting a MOSFET to use on a 3.3V system you need to look for the "Gate Threshold" value in the datasheet. Something around 2.5V max would be OK. Obviously if it is greater than 3V you are going to have a problem.

Switching a MOSFET becomes more difficult as the source to drain current and switching frequency increase. MOSFET gates have capacitance, a few 10s of pF. It doesn't seem much until you increase the switching frequency. It takes time for the gate to charge and to discharge. During that time the source to drain resistance is significant. If the MOSFET is switched slowly then the transition time is brief. But as the frequency is increased the switching transition time increases as a proportion of the total time and the MOSFET gets hotter.

As the current and frequency increase you may find you need to use a push-pull MOSFET driver capable of switching a couple of amps just to drive the gate fast enough.

To keep your hardware design simple. Choose a load current. Select a MOSFET. Choose a switching frequency as low as possible. See how hot the MOSFET gets when it is on and not switching (100%). Then set a 75% PWM duty and check the temperature again. If it gets a lot hotter, reduce the frequency or drive the gate harder.

I'm familiar with the ACS716 and have used it for measuring the currents in PWM switched loads up to 5A and 8kHz. If works well although you do need to take temperature drift and zero offset into account. The ACS712 looks very similar although from the photo of the module you posted, the high current tracks seem rather small.

A customer of mine did some work a few years ago on a lead-acid battery capacity gauge. Currents where 600A plus, PWM switched at 8kHz. The calculation did not need to take account of the switching, average current was OK. In that application (like yours) the battery always begins fully charged.
 
Thanks so much for taking a moment to post all this, having zero formal education in any of this posts like this are a goldmine and can represent hours on google :)
You need to distinguish between the frequency fed to the PWM generator and the PWM output frequency.

The Pi's ARM micro (like all ARMs) has multiple clock domains. Which one is routed to the PWM hardware and at what speed it runs is dependent on the programming of that clock and the timer's pre-scaler. The frequency seen at the MOSFET gate will be the clock frequency divided by the PWM resolution (number of steps between off and on).
For example, if the clock is 1MHz and the PWM resolution is 256 (using and 8-bit counter) then the frequency at the MOSFET gate will be 1MHz / 256 = 3.906kHz.

Looks like the clock the Pi uses for PWM is 19.2MHz though the rpi.gpio python library takes care of all this..
Code:
Using PWM in RPi.GPIO
To create a PWM instance:
p = GPIO.PWM(channel, frequency)
To start PWM:
p.start(dc)   # where dc is the duty cycle (0.0 <= dc <= 100.0)
To change the frequency:
p.ChangeFrequency(freq)   # where freq is the new frequency in Hz
To change the duty cycle:
p.ChangeDutyCycle(dc)  # where 0.0 <= dc <= 100.0
To stop PWM:
p.stop()
Note that PWM will also stop if the instance variable 'p' goes out of scope.



When selecting a MOSFET to use on a 3.3V system you need to look for the "Gate Threshold" value in the datasheet. Something around 2.5V max would be OK. Obviously if it is greater than 3V you are going to have a problem.
FETs are these:
http://pdf1.alldatasheet.com/datasheet-pdf/view/17184/PHILIPS/BUK553-100A.html
Gate threshold max = 2v. I just put 3.3v onto one and it was dropping 0.13v between source and drain with a 1A load on 14.4v so hopefully will be fine

Switching a MOSFET becomes more difficult as the source to drain current and switching frequency increase. MOSFET gates have capacitance, a few 10s of pF. It doesn't seem much until you increase the switching frequency. It takes time for the gate to charge and to discharge. During that time the source to drain resistance is significant. If the MOSFET is switched slowly then the transition time is brief. But as the frequency is increased the switching transition time increases as a proportion of the total time and the MOSFET gets hotter.

As the current and frequency increase you may find you need to use a push-pull MOSFET driver capable of switching a couple of amps just to drive the gate fast enough.
Interesting. I have a little nanoscope so will be able to keep an eye on the waveforms.


A customer of mine did some work a few years ago on a lead-acid battery capacity gauge. Currents where 600A plus, PWM switched at 8kHz. The calculation did not need to take account of the switching, average current was OK. In that application (like yours) the battery always begins fully charged.

Ta , that was the very first question :)

Bad gif which doesn't show it, but this is actually a program loop ramping the duty cycle up and down from zero to 100%



NdpLgR4.gif
 
Use your scope to monitor the load switching (not the gate). The rising and falling edges will be rounded to some extent. That is the result of the gate capacitance and how much current the gate drive can source and sink. If the proportion of the rounded edges is large when compared to the overall PWM period, slow it down. I can't see what your PWM frequency is but that waveform doesn't look too bad.

The gate capacitance will also be increased by the wiring, PCB/stripboard tracks and the MOSFET lead length.

The voltage drop across source/drain is in line with the datasheet values for on resistance.

Your 1A load will give you a high value for battery capacitance compared to real world use (unless you have a very frugal set-up on your boat). Capacity is reduced as you increase the discharge rate.
 
Top