Building an automatic battery tester. How to measure voltage and/or current? - Page 1
Forum section: electronics / general

author: misquamacus
author_rank: Newbie
timestamp: March 13, 2018, 08:50:25 pm
content: Hi friends,I'm looking to test some lithium batteries quickly, and automate the process with an arduino.The batteries I need to testhave six 18650s wired to an internal balancing board, but there are no external balancing leads, so the only way to find if a cell has gone bad is by testing discharge rate. The manufacturer says they should be able to discharge 18 amps continuously without issue, and 22 in a burst.So far I have rigged up a bunch of LED strips using a sketch similar tothe one attached below from adafruit. That draws the max safe output current from my batteries (22.2v, 18a, 400W), and I've determined that if they can supply that for 6 min then they are good. The test works; however, I'd like to have the Arduino automate that process.Is there a way I could get the arduino to measure the current or voltage going into the LEDs even though it bypasses the board? I'd like to write a sketch wherein if the voltage/current drops below a specified threshold the arduino stops the test and signals me (flashes the LEDs), or if the energy stays above that threshold for six minutes the arduino stops the test and gives some other signal.thanks!

author: Ian.M
author_rank: Super Contributor
timestamp: March 14, 2018, 12:00:02 am
content: I hope you aren't really trying to put 18A through the ground track of a solderless breadboard!As far as hardware goes, a potential divider for measuring the voltage into an Arduino ADC input, 22K upper resistor, 4K7 lower resistor and a 0.1uF decoupling cap across the lower resistor should do nicely. It will need calibration but that's fairly easy - simply knock together a test sketch and read the ADC with a known voltage applied and divide the voltage by the ADC reading to get the calibration constant. Edit that into your code - its easiest to put it as a #define in a separate header - calibration.h then #include that in your sketch.For the current, I'd use an Allegro ACS series isolated hall current sensor. Look for a supplier that stocks 30A ACS715 breakout boards. There are other current sensor options but they are all far more complex than an ACS715 which when powered at 5V will produce 0-4V for 0-30A through it, suitable direct connection to an Arduino ADC input. It will also require calibration - do so at the highest steady current within its range you can reliably generate and measure.Personally I'd have the Arduino log the current and voltage at 1 second intervals over its UART to a PC terminal for later plotting, and use a beeper for the user alert rather than flashing the load LEDs as continuing discharge once the battery drops to 18V is *NOT* a good idea.

author: misquamacus
author_rank: Newbie
timestamp: March 20, 2018, 09:28:04 pm
content: Thanks for the very helpful reply, Ian! I got some of those breakout boards, and am well on my way now.cheers

author: metrologist
author_rank: Super Contributor
timestamp: March 20, 2018, 10:42:53 pm
content: This is similar to what I was doing, but targeting solar panel monitoring. I am building a second project for portable stuff just like this.Here is my thread with some code. It will log the data to SD card as well, and is using an inexpensive 0.96 OLED, and simple resistor divider to drop ~24V:https://www.eevblog.com/forum/beginners/arduino-code-voltsampspower-monitor/

author: misquamacus
author_rank: Newbie
timestamp: March 22, 2018, 03:19:02 pm
content: Wow, that's just what I needed at this point in the project. Thanks very much, metrologist!

author: metrologist
author_rank: Super Contributor
timestamp: March 22, 2018, 10:14:31 pm
content: You can see the ACS712 in the photo above, but for my GP tester, I think I will build it into an old crusty DMM so I can use the rotary switches, banana plugs, and the meter's current shunt.I've started modifying my previous code to have a much faster sampling rate. Right now I have the loop time down to ~350µs; that includes sampling and summing two ADCs, then running a boundary test on each computed value. From there, the loop runs again if the boundary condition passes and otherwise bails to a fail-safe routine. I was thinking this test case could have a number of case scenarios that would call a variety of actions, such as controlling current flow through a fet...