## Introduction: 16 Channel 18650 Lithium Capacity Tester

Hello, my name is Cedric and today im introducing you to my Arduino-based capacity tester.

I had a lot of 18650 cells lying around from old laptop batteries. I wanted to test each cell to find out its capacity. So I tried to find a way to test many cells simultaneously. My first instructable was born.

This lithium tester can test 1-16 cells at the same time. It uses resistance wire with circa 20ohm / meter as load, mosfets as switches and an arduino mega as a calculator ;). It is able to display the data on a 1602 or a 2004 LCD Display or via the serial monitor on your computer. The displayed data are "volt" "time" and "capacity". It would be possible to display the current as well, but i don´t need it. I used the internal pull up resistors to have defined levels. Because of this you will see "5000mV" in the Display if no battery is connected. You can use external pull-down resistors (20-50kohm) if you want to get "0mV" displayed if no battery is connected. In this case you have to rewrite the code.

I build mine as a 10 channel tester because I only had 10 mosfets lying around (I destroyed two of them while building-as you can see there are only 8 Mosfets on my PCB). I hope you enjoy my first instructable. If you got any questions, just write a comment. I hope it is easy to understand. Have fun !

## Step 1: How to Measure Capacity - Some Basics

The main thing to calculate the capacity is the ohm's law. The formula is U = R * I. If you want to measure the capacity, first you have to calculate the current "I". Then divide the mAh through 3600 (1hour has 3600 seconds) and you have mah per second. Now calculate this value with the past time in seconds and you have the capacity in the past time :).

The calculating code:

totalcurrent[c] = totalcurrent[c] + (((valbat[c] - fetoffset[c]) * 5000 / offset) / load[c] / 3600 * ((premillis[c] - millispassed[c]) / 1000.0));

The simplified formula: Capacity in mAh= (Cell voltage - Mosfet Voltage drop) / load / 3600 * past time in seconds.

## Step 2: Tools and Parts

Tools you will need:

• soldering iron
• solder
• hand saw or circular saw
• screwdriver/allen wrench(hexagon)
• side cutter
• stripping plier
• Ferrule crimping plier

Parts you will need:

Electronics:

• 1x arduino mega
• 1x 1602 or 2004 LCD or LCDshield
• 1x I2C Display adapter and 4-pole female header for the I2C (not necessary, but makes the wiring much easier)
• 16x IRL540 (5V mosfets with RDS(on) 0.077ohm) ( one for each channel)
• universal pcb with strip grid
• a fan (a old Computer fan will work - its for cooling the hot wire)
• zip ties
• 2m resistor wire with 0.3 mm and 20ohm per meter (circa 11cm for each channel)
• 0.5mm² ferrule
• 16x resistors 1/8watt (200-600) as gate resistor
• at least 40-50male headers to connect the inputs and outputs to the arduino
• some 25 AWG (circa 0.25mm²) single wire for the inputs and outputs or an old IDE cable from a computer
• some 13 AWG (circa 2.5mm²) single wire for connecting the cell with the load

Battery holder for a 10 channel holder (not needed if you already have any kind of battery holders)

• 6x 5x40 wood screws
• 10x cylinder screw M8x80mm (only 20mm of thread) ( i used countersunk srews, but i think cylinder srews are better for pulling )
• 10x self-locking nut M8
• 8mm drill bit
• 10x 1x10x40 springs
• Wood plates: 1x 220x180x20mm 2x 220x30x20mm
• some 1.5mm² (15 AWG) rigid wire for "+"-pole

Batter holder for a 16 channel holder (not needed if you already have any kind of battery holders)

• 6x 5x40 wood screws
• 10x cylinder screw M8x80mm (only 20mm of thread)
• 10x self-locking nut M8
• 8mm drill bit
• 10x 1x10x40 springs
• Wood plates: 1x 450x180x20mm 2x 450x30x20mm
• some 1.5mm² (15 AWG) rigid wire for the "+"-pole

## Step 3: How to Build the Battery Holder (skip This Step If You Already Have Battery Holders)

I forgot to make pictures during the building process of the project, so i have to explain it with the pictures of the finished project.

First cut down the wood to the following dimensions:

10 channel holder : 1x 220x180x20mm 2x 220x30x20mm

16 channel holder : 1x 450x180x20mm 2x 450x30x20mm

Then assemble the smaller strips to the ground plate as shown in the pictures. Drill 8mm holes at a distance of 25mm from center to center at a height of 10mm in one of the small strips as shown in the pictures (here are the M8x80 screws inserted). Drill two 2mm holes per cell close together on the opposite side in the other small strip. Now cut 70mm 1.5mm² rigid wire pieces. Put them through the small holes and solder the 2 ends together. This will be your "+"-pole. Now insert de M8x80 srews in the holes and slide the springs onto the screws. Screw self-locking nuts onto the threads and solder the thread ends a bit. You can also sand the thread ends half-round instead. I have also built a plexiglas plate under the battery holder to attach the electronics.

Now you have a flexible Battery holder which is also compatible with other battery types. Great !

## Step 4: How to Build the Electronic Board

I took a 39x8 holes stripgrid PCB and assembled the components as shown. It is important that you connect the "-" of all Cells to "gnd" of your Arduino, otherwise your Arduino will measure not the correct value ! Solder the 0.25mm² cables to the gates of the mosfets and the measure points for measuring the voltage. Solder the other ends to the male headers.

## Step 5: Combine the Parts

Now solder 2.5mm² wire to each "+" and "-" pole of the battery holder and connect it to the electronic board like shown in the pictures. Connect the male headers and the additional ground connection to the Arduino board. Connect the Display to the Arduino.

## Step 6: The Code

Update: I included the "for loop" in the Battery section to shorten the code, as suggested by "Tachyon". Thank you for the hint.

Some explanations:

float batnumber = 16; change the value from 1-16 -- Only the desired cells are displayed on the display

int intervaldisp = 1000; display changing time

int interval = 1000; time between the next calulation process of each battery. Don´t set to low if yo want to hav a smooth running program ;)

int intervalserial = 1500; time between each serial.print command

int disp = 0; here you can choose your Display type : 0 = 16x2 Display 1 = 20x4 Display

int fetoffset[17] = {16,... these values are the voltage drops at the mosfets in mV. Measure the value while discharging between "Drain" and "Source" - should be 16mv at a current of 2A. You can also calculate tat value. The resistance of the IRL540 is 0.077ohm when 5v are present at the gate. So use U = R*I and calculate it ;). For example 1.5A --> U = 0.077*1.5 -> U = 0.1155V. For example 3A --> U = 0.077*3 -> U = 0.231V.

int bat[17] = {A0,... these are the Analog input pins. Normally no changes have to be made here

float load[17] = {1.6,... these are the resistance values of your load. you can set individual values for each cell if you want. My values were 1.6ohm

float offset = 5013; this value is important! Measure the 5V pin and set the value in mV. In my case 5,013V. I will explain this in the next step.

float cutoffmin = 3000; the value in mV at which the measurement is stopped

float cutoffmax = 4300; the maximum voltage of the cell. If the voltage is higher, the code wont recognize a cell.

There are 2 sort of .ino files. One is for an I2C Display and the other one is for a default connected LCD.

If you use the I2C Display you will need the correct library. I found a good explanation and Library here: https://arduino-info.wikispaces.com/LCD-Blue-I2C. Download and install the newest library. There is also the code you need to find out the I2C adress called "I2C Address scanner for Arduino". In my case the address was "0x27".

## Step 7: Arduino Power Supply

Some facts:

• The ADC of the Arduino Mega has 10bit which are 1023 steps (0 is counted as a step --> 1024)
• The default reference voltage is 5V
• The Arduino "reads" 1023 when 5V is connected to an analog input pin
• the internal reference depends on the exact value of the Arduino 5V pin

Example:

You use an usb-port of your computer to power the Arduino. The USB Volt-value is maybe only 4,8V. You connect the 5V pin of the Arduino to A0 and let the Arduino read A0 and then do "serial.print" to the serial monitor. The serial monitor will display 1023. It´s because the 4.8V at the 5V pin are the default reference of the Arduino . The Arduino now interprets the value 4.8V as 1023. If you connect a cell with 3,7V to A0 and to the same now, the serial monitor will display only 3.552V (3,7/5)*4,8. And since the capacitance measurement is based only on an assumed value of the load (1.6ohm) and the measured voltage, it is important to integrate the reference value with the calculation.

To solve this problem, it is advisable to use the Vin pin instead. Connect a external power supply to the Vin pin with 7-10V. Now the onboard available 7805 voltage regulator produces a relatively constant voltage which won´tbe exact 5V. Therefore, there is the offset value in the code to make sure calculating is correct. So measure the value o the 5V pin and write this value into "float offset = 5013;".

Now its time to start your Arduino and test some cells ;)

## Step 8: Future Goals

• I want to make a 8 cell capacity tester, which uses two analog inputs per cell. This will result in a higher accuracy. It will measure the battery voltage and the voltage drop at the load resistor (the load resistor is used as a shunt). (Vbat Vshunt) / R * Time.
• rewrite the code to fit in an Arduino nano.
• rewrite the code to be able to set the current per channel by a pwm output.
• visualize the data in The Computer screen with the tool called " processing"
• adding a buzzer

Participated in the
Arduino Contest 2016

Participated in the
First Time Authors Contest 2016