Constant Current battery capacity tester.

Seems to be running more than stable enough as I work through some really cheap used 18650 batteries off ebay, what a complete bargain they were!
At some point soon the code will get tidied up & updated to github with the node-red flow as well in the very unlikely event that someone else might actually have a play. ;)
At the moment it writes to a database through a raspberry pi using signalk, but should be not too involved to get it to write straight to a database running on a laptop.

All great fun :cool:



8vGueCy.gif
 
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.

Well I can't find it now either. Mind you, it was 20 years ago I did this and I no longer have access to the schematic. I seem to remember it was OK at a few kHz. But as you say there are other options.
 
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]


If you can't drive the MOSFET without a gate capacitor, then I suspect you have a high value gate resistor. This is not the way to drive a MOSFET gate for PWM.

For the ADC;
- is the sample rate/clock even?
- how many samples have you averaged?
- an alternative to averaging is to implement a software low-pass filter. A first order low-pass filter is trivial with floating point maths and not much more complex with integers. Its main advantage over averaging is that it only requires one stored value between samples.
 
If you can't drive the MOSFET without a gate capacitor, then I suspect you have a high value gate resistor. This is not the way to drive a MOSFET gate for PWM.

For the ADC;
- is the sample rate/clock even?
- how many samples have you averaged?
- an alternative to averaging is to implement a software low-pass filter. A first order low-pass filter is trivial with floating point maths and not much more complex with integers. Its main advantage over averaging is that it only requires one stored value between samples.

This is not the way to drive a MOSFET gate for PWM.
I can see why it's so important to drive the FET with PWM? Feeding the MOSFET gate with filtered PWM, so close to DC, works, it's stable even if they not designed to be used like that. The energy has to go somewhere so why not dissipate some across the FET. It's miles inside the datasheet temperature & power limits. Bottom line is it works, for a few quid, does what's wanted of it though not tested on the main battery bank yet. Though power BJTs look like the way to go, I don't have any :)

Raw PWM into the FET gate and averaging samples didn't work, hugely unstable, the current sensor sees only near full or near zero , you might be able to dig deep into interrupts and somehow time the PWM with the INA sample times but it's just at the end of an I2C comms line maybe it's just not possible. Anyway, seems an awful lot of running around when the thing actually works already.

I suspect longer term driving a power BJT or several with filtered PWM would be the way to go, in the meantime we'll see if these MOSFETs carry on working :cool:


EDIT - What seems to be a good description of why driving with DC isn't great here ( not that I doubted you :) ) >
https://electronics.stackexchange.c...sfet-in-its-resistive-region-with-a-heat-sink
& more of why
https://www.youtube.com/watch?v=WUPrj03UbTM

Still works though :)
 
Last edited:
Top