GPLv3 cheap battery discharger (is this the right forum category?)

20 posts / 0 new
Last post
Djhg2000
Offline
Last seen: 7 years 3 months ago
Joined: 09/21/2014 - 07:32
Posts: 10
GPLv3 cheap battery discharger (is this the right forum category?)

Hi! This in my first post on this forum and I hope I got this thread in the right category (chargers was the closest to matching dischargers but maybe this belongs with the battery threads?).

 

I've written an open source battery tester made from cheap hardware based on a cheap Arduino clone. It should work with a regular Arduino Leonardo, but I haven't tested that yet. I built it for testing a set of 18650 batteries I ordered from China, mostly because of all the examples of fraud that I found on various sites. This forum seemed to contain the most useful info so I thought I'd contribute back to this community.

 

The charger I ordered hasn't arrived yet, so this has yet to be tested on actual 18650 cells. I did however test it with some smaller battery packs (one 110mAh and one 1000mAh) and it seems to get the capacity pretty close to accurate (119mAh and 1170mAh respectively which I think isn't unreasonable for barely used high quality cells). The main problem is that I don't have any reference tester so I've had to think it all through and hunt bugs based on logic, math and physics alone. I'd be very grateful if somebody could test the same battery with both this and an off the shelf LiPo tester and report back with the accuracy.


Enough with the background story, this is the current list of features:

  • Automatic battery disconnection upon test completion (with MOSFET)
  • Plot of voltage over time upon test completion with error highlighting
  • Error detection and compensation
  • Realtime statistics reporting
  • Cross platform PC software (written in Octave)
  • Easily portable Arduino code (tested with Arduino IDE 1.5.x)
  • Documented communication protocol based on serial
  • GPLv3 because a true community project can't be closed source
  • In desperate need of a better name

 

Entire source tree can be found here:

https://github.com/Djhg2000/AStar_32u4_battery_discharger

Getting started guide:

https://github.com/Djhg2000/AStar_32u4_battery_discharger/wiki/Getting-s...

Protocol documentation

https://github.com/Djhg2000/AStar_32u4_battery_discharger/wiki/Communica...

 

I hope you guys enjoy my software and please don't hesitate to ask questions or report bugs!

 

List of features last updated 2014-09-21.

Edited by: Djhg2000 on 09/21/2014 - 11:56
Major
Major's picture
Offline
Last seen: 6 years 7 months ago
Joined: 11/10/2011 - 13:59
Posts: 232
Location: Peak district, UK

Hello and welcome. Thanks for posting.
I know what a arduino is but have never heard of octave, it is the UI and does the logging? will it work on Windows xp, 7 or 8, each of which I have access to. The cut off voltage to disconnect the battery is preset into the arduino?
Is there a circuit diagram for a relative beginner like me?

kronological
kronological's picture
Offline
Last seen: 4 years 1 month ago
Joined: 12/12/2012 - 09:23
Posts: 3042
Location: Texas

Looks interesting.

I know I don’t want to spend the $ on an Opus charger because I already have enough chargers. This could fill the gap, depending on complexity and cost, of course.

No one, after lighting a lamp, puts it away in a cellar nor under a basket, but on the lampstand, so that those who enter may see the light.

My Reviews: Ma

Major
Major's picture
Offline
Last seen: 6 years 7 months ago
Joined: 11/10/2011 - 13:59
Posts: 232
Location: Peak district, UK

Cost sounds very low if it’s using a arduino clone and a fet it’s the software bit that I need help walking through!

Djhg2000
Offline
Last seen: 7 years 3 months ago
Joined: 09/21/2014 - 07:32
Posts: 10

Major wrote:
Hello and welcome. Thanks for posting.
I know what a arduino is but have never heard of octave, it is the UI and does the logging? will it work on Windows xp, 7 or 8, each of which I have access to. The cut off voltage to disconnect the battery is preset into the arduino?
Is there a circuit diagram for a relative beginner like me?

Octave is a free and open source reimplementation of MATLAB. It’s available for a variety of platforms including but not limited to Windows XP/Vista/7/8, Mac OS X and Linux. The Windows version is a port and may lag behind a version or two since Octave is primarily developed for *nix type operating systems. Instructions for installing on Windows 8 can be found here http://youneedtoprogram.wordpress.com/2013/10/12/installing-octave-3-6-4... , but since MATLAB is so widespread in college education there are many guides on the web for installing Octave (saving the cost of a MATLAB license).

Octave does have a GUI but it’s in heavy development and will probably be pretty unstable until they hit version 4. As long as you’re OK with this and is prepared to disconnect the battery manually in case something goes wrong, you can launch Octave using the “—force-gui” argument and load the .m file.

The intelligent stuff is done at the PC end so the cutoff voltage is configurable at the top of the .m file (default is 3V). Implementing a failsafe on the Arduino is totally possible, but I haven’t gotten around to doing that yet.

Djhg2000
Offline
Last seen: 7 years 3 months ago
Joined: 09/21/2014 - 07:32
Posts: 10

kronological wrote:
Looks interesting.

I know I don’t want to spend the $ on an Opus charger because I already have enough chargers. This could fill the gap, depending on complexity and cost, of course.


I went with the SparkFun MOSFET breakout board since it was my first time using a MOSFET. That turned out to connecting it a bit confusing though as it isn’t all that obvious which pin does what on the board. Basically any fairly decent N-channel MOSFET should be good enough (the breakout board uses a RFP30N06LE and a 10k resistor as a pull down between the gate and the ground of the MOSFET). As for the resistors you can use whatever you have lying around since that has to be configured in the software anyway. Something around the 30-100 Ohm range of total resistance is recommended though, please note that the lower resistance you use the hotter the resistors get, but the discharge will also be faster.

For accurate results, try to discharge at around 1C. This can be calculated using the following formula based on Ohms law, notice the parenthesis:
1 / voltage*((1/resistor1) + (1/resistor2) + … + (1/resistorN)) = discharge current

An example of the calculated resistance is provided in the .m file where 3 resistors are used; two 99.7 Ohm and one 99.4 Ohm. The beauty of making this in Octave is that you can write math straight into the code 8)

All in all I’d expect the cost of parts to be one Arduino-like board and a couple of dollars worth of parts. You can find the entire hookup guide in the Fritzing file (just noticed I had forgotten about that pull down resistor, I will fix that and push the changes soon).

Edit:
Actually, after evaluating the code it should handle operation without a MOSFET as well. It will measure the capacity but it will throw warnings at you (as it should) and the battery must be disconnected manually when it tells you to. I wouldn’t recommend doing this for safety reasons but if you can’t get a MOSFET I guess you don’t really have a choice.

djozz
djozz's picture
Offline
Last seen: 2 hours 11 min ago
Joined: 09/07/2012 - 17:04
Posts: 18162
Location: Amsterdam

Welcome to BLF! That sounds like a cool piece of equipment that you developed!

I think the best person to check your discharger is member HKJ, because he knows everything about batteries, has tested an enormous amount of them, has the best equipment and is computer-man as well. If he does not chime in this thread, you can write him a personal mail.

Djhg2000
Offline
Last seen: 7 years 3 months ago
Joined: 09/21/2014 - 07:32
Posts: 10

djozz wrote:

Welcome to BLF! That sounds like a cool piece of equipment that you developed!

I think the best person to check your discharger is member HKJ, because he knows everything about batteries, has tested an enormous amount of them, has the best equipment and is computer-man as well. If he does not chime in this thread, you can write him a personal mail.


Thanks! I’ll contact him if he doesn’t show up within a few days, I don’t want to bother him in case he’s busy with other stuff.

I have also updated the Octave code to deal with the lack of a MOSFET. I now prints a warning telling you that it won’t be able to protect the battery from damage without it.

In this configuration only resistors are needed which brings the parts list down to a level that most Arduino owners will already have sitting on their desk. Simply bridge the drain and source of where the MOSFET would be (MOSFET pins 1 and 3 in the Fritzing schematic). Don’t get me wrong, a MOSFET is still the way to go if you care about your batteries but at least it’s a case that the program can handle.

Edit:
I updated the first post with a revised list of features.

eas
eas's picture
Offline
Last seen: 2 years 2 days ago
Joined: 07/14/2014 - 18:53
Posts: 1363
Location: PNW

Sweet!

I’ve been planning a suite of inexpensive, open source, battery testing hardware/software, and working on the first piece. I look forward to checking this out.

Djhg2000
Offline
Last seen: 7 years 3 months ago
Joined: 09/21/2014 - 07:32
Posts: 10

eas wrote:
Sweet!

I’ve been planning a suite of inexpensive, open source, battery testing hardware/software, and working on the first piece. I look forward to checking this out.


Awesome, let me know if you want to collaborate and use a common protocol for the hardware! As I’m sure you’ve noticed, the protocol I designed intentionally leaves a lot of room for expansion.
Djhg2000
Offline
Last seen: 7 years 3 months ago
Joined: 09/21/2014 - 07:32
Posts: 10

Allright, for the last few days I’ve had the charger and tested my 18650 batteries. The battery discharger claimed its first victims; the 20 batteries me and my friend bought are all fake Flat Stare . They were marked with UltraFire 3000 mAh and tested to about 1000-1100 mAh (only tested two so far but more will follow). Meanwhile my Nitecore 2600 mAh tested to 2740 mAh which is about what I expected from a genuine quality battery.

djozz
djozz's picture
Offline
Last seen: 2 hours 11 min ago
Joined: 09/07/2012 - 17:04
Posts: 18162
Location: Amsterdam

Nice, it works fine then. Which charger are you going to use as a reference? Oh, and for me (and perhaps others) Arduino is something that I have only heard of and never seen, do you have a picture of the set-up, just to get an idea?

Ledsmoke
Ledsmoke's picture
Offline
Last seen: 1 year 7 months ago
Joined: 08/08/2011 - 16:05
Posts: 1995
Location: Denmark

AWESOME!!!

Thank you for joining us and WELCOME to the BLF!

And Another thank you for making this publicly available to the forum. TY very much Smile

~ Ledsmoke ~

Dutch humor:

[quote=djozz]

 I do not think that the BLF-community ben

Djhg2000
Offline
Last seen: 7 years 3 months ago
Joined: 09/21/2014 - 07:32
Posts: 10

djozz wrote:

Nice, it works fine then. Which charger are you going to use as a reference? Oh, and for me (and perhaps others) Arduino is something that I have only heard of and never seen, do you have a picture of the set-up, just to get an idea?


I actually used a TOMO portable battery pack (takes 4x unprotected 18650 batteries) as a charger. It’s quite slow but it does the job.

Here’s a pic of the discharger in its current form, please note however that there is a lot of redundant wiring in my test setup so it does look a bit intimidating:

Here’s a screenshot from Fritzing of the actual simplified schematics, this is what you’d typically end up with:

Finally here’s a screenshot from when it had finished testing the Nitecore 2600 mAh battery:

Unfortunately I didn’t catch the graph in that screenshot, I’ll make sure to include that next time.

djozz
djozz's picture
Offline
Last seen: 2 hours 11 min ago
Joined: 09/07/2012 - 17:04
Posts: 18162
Location: Amsterdam

Thanks for the pictures, that gives an impression Smile . Not that I understand it all....

Djhg2000
Offline
Last seen: 7 years 3 months ago
Joined: 09/21/2014 - 07:32
Posts: 10

Well, I’ve thought about writing a GUI for it later and possibly porting it to Python so that getting started is easier. That will have to wait though as I’ve only done some basic GUI stuff in Octave and the way Octave does GUI stuff differs a lot from how Python does it.

In other news, I’ve ordered a fancy charger for RC battery packs which can also measure the capacity. Mostly because I’m getting back into doing RC on the weekends, but when that arrives I can compare the result from this to a professionally designed product.

Djhg2000
Offline
Last seen: 7 years 3 months ago
Joined: 09/21/2014 - 07:32
Posts: 10

The fancy charger I bought, a SkyRC IMAX B6AC (verified to be genuine), showed one of the cells to discharge 1088 mAh and charge 1094 mAh. I believe the 6 mAh difference is due to the internal resistance of the battery (it gets ever so slightly warmer). This is very close to what I’ve gotten out of the other batteries with my discharger, only a few mAh off though I’ll have to wait until I’m done testing this cell again in my discharger (to eliminate a different charge level as an error source).

After discovering that the IMAX B6 series has a serial output I hooked up my handy little Bus Pirate to it and started receiving data from it. I found a nice piece of software called LogView which knew how to interface with it and provided me with nice graphs of the discharging process, much like what I wanted to achieve. LogView V2 works well in WINE and should work out of the box with Windows. However, interfacing with LogView is something I’ll have to investigate further before making a decision on whether do repurpose my code for it or not. Just wanted to let you guys know about it (we’re looking for the best way to diagnose batteries after all).

Edit:
My own battery discharger tested it to 1058 mAh, which is still precise enough for reliably detecting fake batteries.

ChibiM
ChibiM's picture
Offline
Last seen: 1 hour 46 min ago
Joined: 05/09/2011 - 10:25
Posts: 6835
Location: Holland

I heard the old Squirrel from here thinks THIS is a pretty accurate analyzer.

so you could get that one to use as a reference. It can also do graphs if I`m correct.

eas
eas's picture
Offline
Last seen: 2 years 2 days ago
Joined: 07/14/2014 - 18:53
Posts: 1363
Location: PNW
Djhg2000 wrote:
The fancy charger I bought, a SkyRC IMAX B6AC (verified to be genuine), showed one of the cells to discharge 1088 mAh and charge 1094 mAh. I believe the 6 mAh difference is due to the internal resistance of the battery (it gets ever so slightly warmer). This is very close to what I’ve gotten out of the other batteries with my discharger, only a few mAh off though I’ll have to wait until I’m done testing this cell again in my discharger (to eliminate a different charge level as an error source).

I suspect that 0.5% difference is well within the margin of error for the charger. I’m sure that it isn’t enough to account for cell heating detectable by touch. Besides, LiIons are “coulomb efficient” meaning every electron that goes in should come out, but power is lost to voltage drops.

Djhg2000
Offline
Last seen: 7 years 3 months ago
Joined: 09/21/2014 - 07:32
Posts: 10
eas wrote:
Djhg2000 wrote:
The fancy charger I bought, a SkyRC IMAX B6AC (verified to be genuine), showed one of the cells to discharge 1088 mAh and charge 1094 mAh. I believe the 6 mAh difference is due to the internal resistance of the battery (it gets ever so slightly warmer). This is very close to what I’ve gotten out of the other batteries with my discharger, only a few mAh off though I’ll have to wait until I’m done testing this cell again in my discharger (to eliminate a different charge level as an error source).

I suspect that 0.5% difference is well within the margin of error for the charger. I’m sure that it isn’t enough to account for cell heating detectable by touch. Besides, LiIons are “coulomb efficient” meaning every electron that goes in should come out, but power is lost to voltage drops.

You’re absolutely right, it probably wouldn’t be detectable by touch since the heat it would dissipate is about 0.02 watts (4 volts times 5 milliamps assuming exactly one hour charge time). Putting that in perspective an OMAP5 SoC (commonly used in smartphones) has a standby power consumption of about 2.5 watts.

I charged up the battery from before and it received 1082 mAh of charge according to the B6AC. There’s definitely an error somewhere, now I’ll just have to find it.