Microcontrollers > Microcontrollers/General

LITHIUM BATTERY TESTING WITH A UNO

(1/3) > >>

OperaHouse:
A short while ago there was a discussion about building lithium battery packs
out of old 18650 cells found in laptop battery packs.  I too have a collection
of these and have used them for LED flashlights.  It is generally easy to find
the bad pair of of batteries in the packs that caused them to be discarded. But,
just how good are the other ones in the pack. This seemed like a nice little
demonstrator project for a UNO. This shows how you can program a UNO to solve a
momentary problem adding a few extra parts and then it can be taken apart and
used for another project.  It reads out in amp minutes and will overload the
counter at a little over 5AH.  It also has an analog voltage output that can be
read by a digital meter once filtered.  The range is 0-5V corresponding to 0 to
255 amp minutes.  The counter will overload before that time (300 A min), still
more than sufficient for testing a pair of 18650 batteries. Never parallel more
than two batteries together without fusing for each pair.There is an easy fix for
this and a chance to improve your skills. You won't learn if I just hand working
programs to you.  This does work sufficiently well as it is to be quite useful.
The voltage and resistance is known. From that the amps could be calculated each
minute and added together.  Rough estimates are more than adequate to evaluate a
battery. There can easily be a 10% difference charging the battery with the same
charger.

When first powered, a HELP screen appears in the compilers TOOLS section on the
serial screen. It is calibrated for 1A standard test when "S" is entered. Currents
are based on 3.7V with a 2.5 ohm resistor (two 5ohm 10W resistors in parallel). You
can change resistances for whatever you have. Currents can be adjusted on the screen
to whatever is desired by choosing set values and incrementing or decrementing from
them.  A timer gives the elapsed time of the test.  It doesn't start till a PWM
load value is entered.  The current is calculated by MAX CURRENT * PWM / 255. 
When battery voltage drops below a set value the test is ended and DONE appears on
the screen.  The last elapsed time, Amp Minute and current are saved. R is entered
on the screen to reset the program. Then select a current Any preference for another
current can be added to the program.  Just select a convenient keyboard character and
edit the program to include that.  Remember, you must type that character in the
upper box and then click SEND.

If there are questions, please ask.  Not going to write elaborate explanations for
a program that isn't used. This is probably the most useful program for the majority
of people here.

/*
   LIPO_BAT_TEST program for testing AH capacity of battery
 
 1.  select various PWM for current draw
 2.  Read battery voltage & stop at minimum
 
 
 CREATED 12/10/2016
 REVISED 12/12/2016
 */


// Declare variables as integers and set initial values

int AI0            = 0;           // Battery raw A/D conversion
int AI1            = 0;           // spare
int kbd            = 'h';         // start with help screen
int blinktime      = 0;           // blink counter
int PWMdrv         = 0;           // PWM drive
int LASTpwm        = 0;           // final PWM drive
int battery        = 0;
int END            = 3600;
int TOTAL          = 0;
int AMPmin         = 0;
int DONE           = 0;
int seconds        = 0;
int minutes        = 0;
int oneamp         = 175;         // PWM for one amp
void setup() {               
// initialize the digital pins
// Pin 13 has LED on Arduino UNO board

pinMode(13,  OUTPUT);               // board LED

Serial.begin (9600);                // Set up serial monitor routine
}

void loop() {                       // This is the start of the program


// This section reads the analog signals.  Range is 0 to 5V DC or 0 to 1023 counts or 4.9mV per count


  AI0  = analogRead (0);             // Anolog In.  Read the battery voltage  PIN #A0  BATTERY
  AI1  = analogRead (1);             // Anolog In.    PIN #A1  36V PANEL
 
  battery = battery - battery/ 6;    // subtract one average reading
  battery = battery + AI0;           // add in a new reading
 
  AMPmin = minutes * (PWMdrv *100/ oneamp) / 100;     // calculate amp minutes
 
  if (battery <= END && PWMdrv > 0 && seconds > 10)   // check battery if A/D stable > 1 minute
  {                                                   // and  drive is on
    TOTAL      = AMPmin;                              // end amp minute
    DONE       = 1;                                   // end of test
    LASTpwm    = PWMdrv;                              // end PWM drive
    PWMdrv     = 0;                                   // turn off load
  } 
 

  // This section sends out serial data contained in the program. It has no actual functional use in the program.  It can be viewed by
  // sing SERIAL MONITOR in TOOLS when the ARDUINO programmer is running.  The program can run without any serial monitor connected. 
  // Some diagnostic sectin like this should be included in all programs.  It will save a lot of time in the development of programs.

  if (Serial.available() > 0) kbd = Serial.read();    // look for and get keyboard character 
  // kbd is the character returned from keyboard


  //             COMMAND FOR PWM TEST
    if (kbd == '0') PWMdrv  = 0;          // OFF
    if (kbd == '1') PWMdrv  = 10;         
    if (kbd == '2') PWMdrv  = 20;         
    if (kbd == '3') PWMdrv  = 30;             
    if (kbd == '4') PWMdrv  = 40;           
    if (kbd == '5') PWMdrv  = 50;             
    if (kbd == '6') PWMdrv  = 60;         
    if (kbd == '7') PWMdrv  = 70;         
    if (kbd == '8') PWMdrv  = 80;         
    if (kbd == '9') PWMdrv  = 90;       
    if (kbd == '-') PWMdrv  = PWMdrv - 1;
    if (kbd == '+') PWMdrv  = PWMdrv + 1;
    if (kbd == 'm' || kbd == 'M') PWMdrv  = PWMdrv + 100;
    if (kbd == 'i' || kbd == 'I') PWMdrv  = PWMdrv + 10;
    if (kbd == 'd' || kbd == 'D') PWMdrv  = PWMdrv - 10;
    if (kbd == 'f' || kbd == 'F') PWMdrv  = 255;
    if (kbd == 's' || kbd == 'S') PWMdrv  = oneamp;  // Standard 1A test @2.5 ohm
    if (kbd == 'r' || kbd == 'R')                    // RESET everything
    {
      PWMdrv   = 0;
      seconds  = 0;
      minutes  = 0;
      TOTAL    = 0;
      DONE     = 0;
    } 
   
    kbd == 'z';                 // reset keyboard to non used character each loop
   
  //                                        HELP SCREEN
 
  if (kbd == 'H' || kbd == 'h')       // if H send out HELP screen
  {
   
    Serial.println("  ");
    Serial.println("  ");
   
    Serial.println(" 0 OFF ");                // load OFF
    Serial.println(" 1-9   10 to 90 ");       // preset PWM
   
    Serial.println(" + increment by one ");
    Serial.println(" - decrement by one ");
    Serial.println(" I increment by ten ");
    Serial.println(" D decrement by ten ");
    Serial.println(" M increment by 100 ");
    Serial.println(" F 255 ON ");             // max load
    Serial.println(" S STANDARD 1A TEST ");
    Serial.println(" R RESET TEST ");
   
    Serial.println("  ");
    Serial.println("  ");
   
    delay (5000);          // keep screen for five seconds
    kbd = 'z';   
  }
 
  if (PWMdrv >255) PWMdrv = 255;   // set upper limit of PWM
  if (PWMdrv < 0) PWMdrv = 0;      // set lower limit of PWM

  //                                  BLINK BOARD LED and COUNT TIME
  // This section blinks the board LED when the micro is working.
  // seuenced using a count routine. 

  blinktime = blinktime + 1;       // increment blink counter
  if (blinktime  == 100)           // 100 ish is about 1 second
  {                                     
    blinktime = 0;                 // Reset blink counter
   
    if (DONE == 0 && PWMdrv > 0) seconds = seconds +1;   // increment seconds if running
  }
 
  if (blinktime  == 0 && seconds >= 60)   // 60 is 1 minute
  {                                       
    minutes = minutes +1;                 // add a minute
    seconds = 0;                          // reset seconds
  }
             
//        SEND OUT LOAD DRIVE
  analogWrite(10, PWMdrv);                 // analogWrite values from 0 to 255
                             
  delay (10);                              // delay creates second interval
   

  //          BLINK LED
 
  if (blinktime == 0) digitalWrite (13,LOW);     
  if (blinktime == 5) digitalWrite (13,HIGH);   // on blink
  if (blinktime == 8) digitalWrite (13,LOW);
 
 
  if (PWMdrv >= 1 && blinktime == 40) digitalWrite (13, HIGH);   // indicate LOAD ON   
  if (blinktime == 60) digitalWrite (13, LOW);                    // indicator LED OFF

  if (PWMdrv >= 100 && blinktime == 80) digitalWrite (13, HIGH);    // indicator LED ON   
  if (blinktime == 90) digitalWrite (13, LOW);                      // indicator LED OFF
 
  //              SCREEN PRINT ROUTINE
  if ( blinktime == 0)
  {
    Serial.print (AI0);
    Serial.print (" ");
    Serial.print (battery);
    Serial.print ("mV  ");
   
    Serial.print (END);
    Serial.print (" END  ");
   
    Serial.print (PWMdrv);
    Serial.print (" PWM   ");
     
    Serial.print (minutes);
    Serial.print (":");
    Serial.print (seconds);
    Serial.print (" elapsed  ");
   
    if (DONE == 0) Serial.print (AMPmin);     // overloads at 327Amp Min
    else Serial.print (TOTAL);
    Serial.print (" AMP min  ");
   
    if (DONE == 0) Serial.print ((float)PWMdrv / oneamp);
    else Serial.print ((float)LASTpwm / oneamp);
    Serial.print ("A  ");
   
    if (DONE == 1) Serial.print(" DONE");   // indicate test finished
   
    Serial.println(" ");       // start new line
   
   
   
  // SEND AMP MINUTE CAPACITY TO PIN 5 TO READ ON AN ANALOG METER
  // filter with a 4 to 5K resistor and 2.2uF cap or higher
  // Voltage is divided by two because 255 = 5.1V.  The division
  // will make 128 = 2.55V  Normal micro supply voltage will be between
  // 5.05V and 5.2V   A CAL for 100 is included
                                              // output is X2 volts
    if (DONE == 0) analogWrite (5, AMPmin);   // overloads at 255 Amp Min
    else analogWrite (5, TOTAL);              // or about 4AH
    analogWrite (6, 100);                        // CAL PIN FOR 100 AMP MIN
  }
     
}     // END of the program loop



Bruce S:
OperaHouse;
 I was just thinking about a home-based way of finding the "health" on the batteries I have. Most of the time I make use of the department's $6k professional charger/tester.
This will certainly help me when I don't that available.
I'm going to need more of these UNOs

Thanks

george65:

Opera,

Thank you for this sketch, it is yet another of the many you have put up that I am interested in and would love to build.
With almost a heady 24Hours since my geek criet kit arrived and having now got that damn LED to blink and played with the timing AND, made the servo turn with a pot, I'd like to give you some well meaning feedback.

Now it may be because I'm about as ignorant as they come right now. but I find most of your posts like this way over my head.  Specifically after looking at things online and on the arduino site, I can see all the code here which I wouldn't have a hope in hell of doing myself but there is nothing about what components or how to hook it up.

I don't mean to sound like these people I get on my YT channel that look at the simplest of things and then ask for " Plans" ( which ships me to tears when all the "plans" they need is to look at the damn thing) but for twits like me, not having the parts list and the wiring diagram pretty much kills any chance of building the thing and making yuse of the time and effort you have put into writing and working out these things.

Now I think the likelihood is that I'm too ignorant right now and someone more advanced should know how to hook it all up and what they need and I get that.  From MY POV though, If I knew what I needed parts wise and what went where, I have half a chance.  Perhaps it's just that these things need more experience and if so I get that but looking over some of what you have put up, I'm sure even a pelican Newbie like me could have a chance of getting these things working with the back end filled in.

Now this may bore you to tears, you may not have time or desire for it or other factors I am ignorant to. You seem to go out of your way so much to share with others though and give people so much help, I thought I'd give you the dummies POV though in case there is something else in it for you.

In any case, thanks for putting up all you do. I'm sure in time I'll get a better understanding of it and be able to figure things out to let me build so many of the things you have shown.

OperaHouse:
These actually take a long time to create and edit right. In the many years I've been here I only know of one person that ever tried to build one thing posted.  This initial program is a demonstrator of the basic process  I am just starting to do testing with the program and a picture and schematic hasn't been posted yet.  Already I am seeing initial assumptions are not correct.  I like junkbox projects. At camp I go out to the garage and whatever I have available, I use.   FETs, resistors, pots are all subject to change.  That makes for some really interesting designs sometimes.  I want to demystify electronics.
Pictures will often have pieces of circuit boards cut up with an angle grinder with a thin cutoff wheel.  These are then hot melt glued to a piece of wood. The world is a cornucopia of  little useful sub assemblies free for the taking.  I get some really nasty comments on some boards.  I've put many boards into production.  I used to write the UL files for products and send them to the inspectors.  They would change a couple words just to keep some self respect.  I just got things through quicker and frankly many of them were morons. I suspect many of them were student work study.  And people feel safe when they see UL.  I digress.  The point is I've been around and know how to do it right. Right takes a lot of effort.  Getting things close is empirically just as good often.  I really have little interest in turnkey systems unless I am getting paid.  This is bar talk and I will keep working with someone as long as they are trying to learn something.  Ideas should be free.  There is no one solution and I want people to be able to adapt these ideas to their situation.  I like my camp and knowing that I created a very efficient system for next to nothing. That solved a need.  If the beer was cold and the milk didn't stink that quick hack was just fine with me. Frankly, I don't care much about electronics anymore. I really need to be managed to get anything productive out of me these days.

Every five years I look back and think, I knew nothing then.  So I know how daunting this can be starting out.  Just break down everything into small parts.  So if you have questions, ask.  I can be motivated enough to put down a few sentences. 

OperaHouse:
                        FIRST TESTING

This is the first time I've been intimate with a lithium battery in a Cole Porter
sense. Testing was with a pair of 18650 batteries welded in parallel. I have had
these several years and not used them.  A number of months ago I had charged them
when I got those little TP4056 charger boards. They are neat little boards and I
suggest you get 10 of them for $3.50 if you have a number of Li batteries around.
These boards can be left connected to the battery when not being powered, so build
them into your device.  You should also put a resistor in series with the + power
supply lead. Spec sheet recommends .5 ohm. I've used them with 2-5 ohms to lower
maximum charge current when charging unknown batteries.  This puts the heat in the
resistor and not in the chip. I use an old cell phone charger for the 5V.  Most of
these telephone wall warts can supply .6 to 1.2A. For thise under 1A, having the
1 ohm resistor is a must. Anything between 4V and the supply voltage is just turned
into heat. Better heating a resistor than the chip.

With the battery as found, the voltage measured 4.08 at the beginning of the test.
3.700V was the programmed in stop voltage and the test ended after 9 Amp Minute.
Stop was changed to 3.600V and the test ran another 23AM. Voltage recovered and a
short timelater the test was resumed at the same stop. That added another 5AM. The
next day I continued the test and added another 6AM for a total of 43AM.  43 amp
minutes for a free battery isn't bad.  That can run a flashlight a long time before
recharging.

I wanted to sufficiently discharge it before a charging operation. This was only a
quick test as I changed some numbers in the program. My charge rate was .75A and
mostly limited by the wall wart rated at 700mA. The charger board remained cool to
the touch. The charge limit is 4.2 volts. The TP4056 terminates the charge when the
total charge current drops to 100mA. The TP4056 is set up for a single cell, two
cells works fine

This time I ran the test down to 3.5V. Some manufacturers test down to 2.5V, but
below 3.4 there can be damage to battery chemistry and 90% of the power is used
up at that point.  You can't run many devices through that range and it wouldn't
be useful to me. 33 amp minute is just over .5AH, not much for two parallel cells.
One standard test is at 610mA. With two cells in parallel that is only 500mA each.
I still have a jar of cells somewhere that need to be tested. Not a great cell. 
Still good enough for a LED light. Just shows why these batteries need to be tested
before commiting them to a project. It will be an education.

As I said before this is a demonstrator project for how data logging can be performed
fairly easily. I'm sure you can find one trady made on ebay for less than $10. I just
bought this one for $4. Will report after testing it. 

http://www.ebay.com/itm/302159402311?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

There is no documentation.  Looks like you can read the amps, amp hours, and voltage. 
Not sure if you can adjust the load except externally with a resistor or whether it
will stop on its own.

This is a picture of the test set up with the TP4056 charger.  Only one FET is active.
The pot is to fine tune the voltage read and the large black capacitor is the filter for
the amp minute analog output.  And old VOM with a meter movement will often have a scale
on the meter face that will match up with amp hours or minutes.  I certainly hope everyone
feels they can make a better project than this. Missing resistor value is 62K.









Navigation

[0] Message Index

[#] Next page

Go to full version