Arduino True Battery Capacity Tester (Li-Ion/NiMH/NiCD/Pb)
by moris_zen in Workshop > Science
335861 Views, 374 Favorites, 0 Comments
Arduino True Battery Capacity Tester (Li-Ion/NiMH/NiCD/Pb)
If anyone saw my last instructable "Simple Li-Ion Battery Power Tester" they can now upgrade to a computerized hi-tech version that is capable of measuring almost any type of rechargeable or none rechargeable batteries (but it will drain one charge from them in the process).
It can even connect to a PC and give you a full "Data-sheet" graph of the discharge and total capacity.
Note that this is my first Arduino project (I am not counting my "blink LED").
It can even connect to a PC and give you a full "Data-sheet" graph of the discharge and total capacity.
Note that this is my first Arduino project (I am not counting my "blink LED").
This Is What You Can Get at the End...(just to Get You Interested)
This is the graph you can get from the text file sent to the PC during drain cycle.
Lets Start at the Begining - Arduino
I really wanted to get this Diecimila copy Arduino board bit it took me ~2 weeks to get it by mail so I just had to start fast with my own bread-board Arduino so I purchased an ATMEGA168 and thought I could get it running without any more components .. to my suprize it didn't work and I just had to get another shipment with a 16Mhz crystal and two 22pf caps .. then I got the next ...
Bread Board Arduino
I basically took junk apart and added the components one by one ...
most of the information can be found in the Arduino web page :
http://arduino.cc/en/Main/ArduinoBoardDiecimila
They realy have everything you need .
It took me about a week to get it up and running (bootloader / building an ISP cable and an RS232 cable ...) - you can read all about this in the site above .
most of the information can be found in the Arduino web page :
http://arduino.cc/en/Main/ArduinoBoardDiecimila
They realy have everything you need .
It took me about a week to get it up and running (bootloader / building an ISP cable and an RS232 cable ...) - you can read all about this in the site above .
FET With 2.2Ohm Load
it was fairly simple to add a FET with "on" resistance of ~8mOHM (no barly any power disipation on it) and a 2.2 10W resistor .
I connected two A/D pins from the Arduino to the resistor poles and subtracted the values to get the exact volatge drop on the resistor .
Now I samples them every second and acumulated the current (I=DeltaV/R).
I also added a buzzer to indicate when charging was over and stoped the discharge .
I connected two A/D pins from the Arduino to the resistor poles and subtracted the values to get the exact volatge drop on the resistor .
Now I samples them every second and acumulated the current (I=DeltaV/R).
I also added a buzzer to indicate when charging was over and stoped the discharge .
The SW
So I also connected and LCD (which I took apart from some other junk) and found the data-sheet on the net + a cool driver from the Arduino web page and started coding .
Auto detecting battery type by the voltage .
Auto detecting battery type by the voltage .
Auto Detect Battery Tyoe
It will detect if it is NiMH/NiCD or Li-ION by the voltage range .
And then start the discharge cycle.
And then start the discharge cycle.
Discharging...
The discharge can take anywhere from 30-120 minuets depending on batery capacity but at the end you get a true indication of battery capacity / quality .
Do you want to use that battery for your air-plain receiver or not ?
This is the diagram of the discharge circuit...
Do you want to use that battery for your air-plain receiver or not ?
This is the diagram of the discharge circuit...
Discharge Circuit
very simple with the 2 A/D connected on the two sides of the resistor /
Vr=Vbat-Vfet.
Vr=Vbat-Vfet.
My SW (free for Anyone to Use)
// include the library code:
#include
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);// initialize the library with the numbers of the interface pins
int sensorPin = 0; // select the input pin for the potentiometer (pin 23)
int sensor2Pin = 2; // select the input pin for the potentiometer (pin 23)
int ledPin = 13; // select the pin for the LED
int SPKPin = 6;
int sensorValue = 0; // variable to store the value coming from the sensor
int sensor2Value = 0; // variable to store the value coming from the sensor
float LiMinThreshold = 2700; // Lithium Minimal Voltage for load removal
float LiMaxThreshold = 4200; // Lithium Max Voltage for load removal
float NmhMinThreshold = 950; // NMH Minimal Voltage for load removal
float NmhMaxThreshold = 1600; // NMH Max Voltage for load removal
float SelectedMinThreshold = 5000;
int i;
int BatVoltage = 5000;
int FetVoltage = 5000;
long TotalCurrent = 0;
boolean done = false;
unsigned long PrevMillis ;
unsigned long MillisPassed ;
void CL2(){
lcd.setCursor(0, 1);// Second line first char
lcd.print(" ");
lcd.setCursor(0, 1);// Second line first char
}
void setup() {
Serial.begin(9600);// start serial port to send data during run to the PC
pinMode(ledPin, OUTPUT);//activation led and enable for FET
pinMode(SPKPin, OUTPUT);//activation led and enable for FET
lcd.begin(24, 2);// set up the LCD's number of rows and columns:
lcd.print("Bat PWR Tester[Active]"); // Print a message to the LCD.
lcd.setCursor(0, 1);// Second line first char
lcd.print("Detecting Bat Type..."); // print voltage value
delay(2000);
lcd.setCursor(0, 1);// Second line first char
lcd.print(" ");
lcd.setCursor(0, 1);// Second line first char
digitalWrite(ledPin, HIGH); // set the LED on
sensorValue = analogRead(sensorPin); // read the value from the sensor:
digitalWrite(ledPin, LOW); // set the LED off
// Detecting battery type
BatVoltage = sensorValue*4.887;
if (BatVoltage > 4500){
lcd.print("Warning high-V! ");
done = true;}
else if (BatVoltage > LiMinThreshold){
lcd.print("Type:Li-Ion Bat ");
SelectedMinThreshold = LiMinThreshold;}
else if (BatVoltage > NmhMinThreshold){
lcd.print("Type:NiMH/Cd Bat ");
SelectedMinThreshold = NmhMinThreshold;}
else{
lcd.print("Unknown Bat V<1 ");
done = true;}
lcd.print("V=");
lcd.print(sensorValue*4.887); // print voltage value
Serial.print("DT[ms]");
Serial.print("\t");
Serial.print("Bat[mV]");
Serial.print("\t");
Serial.print("Fet[mV]");
Serial.println("");
delay(3000);
CL2();
PrevMillis = millis();
}
void loop() {
if (BatVoltage > SelectedMinThreshold && !done) {
digitalWrite(ledPin, HIGH); // set the LED on
sensorValue = analogRead(sensorPin); // read the value from the sensor:
sensor2Value = analogRead(sensor2Pin); // read the value from the FET:
FetVoltage = (sensor2Value*4.887);
BatVoltage = (sensorValue*4.887);
CL2();
lcd.print("V=");
lcd.print(BatVoltage); // print voltage value
lcd.print("mV");
//lcd.print(FetVoltage); // print voltage value
TotalCurrent=TotalCurrent+MillisPassed/1000*(BatVoltage-FetVoltage)/2.2/3.6;
lcd.print(" I=");
lcd.print(TotalCurrent/1000);
lcd.print("mAH ");
delay(1000);
MillisPassed = millis()- PrevMillis;
PrevMillis = millis();
Serial.print(int(MillisPassed));
Serial.print("\t"); // prints a tab
Serial.print(BatVoltage);
Serial.print("\t"); // prints a tab
Serial.print(FetVoltage);
Serial.println(""); // prints a tab
CL2();
}
else
{
done=true;
digitalWrite(ledPin, LOW); // set the LED off - stop loading
lcd.setCursor(0, 0);// First line first char
lcd.print("Bat Power Tester [DONE] "); // Print a message to the LCD.
CL2();//clear line 2
sensorValue = analogRead(sensorPin); // read the value from the sensor:
BatVoltage = (sensorValue*4.887);
lcd.setCursor(0, 1);// Second line first char
lcd.print("V=");
lcd.print(BatVoltage); // print voltage value
lcd.print("mV I=");
lcd.print(TotalCurrent/1000);
lcd.print("mAH ");
for (int i=0; i<100 ; i++){
digitalWrite(SPKPin, HIGH);
delay(1);
digitalWrite(SPKPin, LOW);
delay(1);
}
delay(1000);
}
}
#include
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);// initialize the library with the numbers of the interface pins
int sensorPin = 0; // select the input pin for the potentiometer (pin 23)
int sensor2Pin = 2; // select the input pin for the potentiometer (pin 23)
int ledPin = 13; // select the pin for the LED
int SPKPin = 6;
int sensorValue = 0; // variable to store the value coming from the sensor
int sensor2Value = 0; // variable to store the value coming from the sensor
float LiMinThreshold = 2700; // Lithium Minimal Voltage for load removal
float LiMaxThreshold = 4200; // Lithium Max Voltage for load removal
float NmhMinThreshold = 950; // NMH Minimal Voltage for load removal
float NmhMaxThreshold = 1600; // NMH Max Voltage for load removal
float SelectedMinThreshold = 5000;
int i;
int BatVoltage = 5000;
int FetVoltage = 5000;
long TotalCurrent = 0;
boolean done = false;
unsigned long PrevMillis ;
unsigned long MillisPassed ;
void CL2(){
lcd.setCursor(0, 1);// Second line first char
lcd.print(" ");
lcd.setCursor(0, 1);// Second line first char
}
void setup() {
Serial.begin(9600);// start serial port to send data during run to the PC
pinMode(ledPin, OUTPUT);//activation led and enable for FET
pinMode(SPKPin, OUTPUT);//activation led and enable for FET
lcd.begin(24, 2);// set up the LCD's number of rows and columns:
lcd.print("Bat PWR Tester[Active]"); // Print a message to the LCD.
lcd.setCursor(0, 1);// Second line first char
lcd.print("Detecting Bat Type..."); // print voltage value
delay(2000);
lcd.setCursor(0, 1);// Second line first char
lcd.print(" ");
lcd.setCursor(0, 1);// Second line first char
digitalWrite(ledPin, HIGH); // set the LED on
sensorValue = analogRead(sensorPin); // read the value from the sensor:
digitalWrite(ledPin, LOW); // set the LED off
// Detecting battery type
BatVoltage = sensorValue*4.887;
if (BatVoltage > 4500){
lcd.print("Warning high-V! ");
done = true;}
else if (BatVoltage > LiMinThreshold){
lcd.print("Type:Li-Ion Bat ");
SelectedMinThreshold = LiMinThreshold;}
else if (BatVoltage > NmhMinThreshold){
lcd.print("Type:NiMH/Cd Bat ");
SelectedMinThreshold = NmhMinThreshold;}
else{
lcd.print("Unknown Bat V<1 ");
done = true;}
lcd.print("V=");
lcd.print(sensorValue*4.887); // print voltage value
Serial.print("DT[ms]");
Serial.print("\t");
Serial.print("Bat[mV]");
Serial.print("\t");
Serial.print("Fet[mV]");
Serial.println("");
delay(3000);
CL2();
PrevMillis = millis();
}
void loop() {
if (BatVoltage > SelectedMinThreshold && !done) {
digitalWrite(ledPin, HIGH); // set the LED on
sensorValue = analogRead(sensorPin); // read the value from the sensor:
sensor2Value = analogRead(sensor2Pin); // read the value from the FET:
FetVoltage = (sensor2Value*4.887);
BatVoltage = (sensorValue*4.887);
CL2();
lcd.print("V=");
lcd.print(BatVoltage); // print voltage value
lcd.print("mV");
//lcd.print(FetVoltage); // print voltage value
TotalCurrent=TotalCurrent+MillisPassed/1000*(BatVoltage-FetVoltage)/2.2/3.6;
lcd.print(" I=");
lcd.print(TotalCurrent/1000);
lcd.print("mAH ");
delay(1000);
MillisPassed = millis()- PrevMillis;
PrevMillis = millis();
Serial.print(int(MillisPassed));
Serial.print("\t"); // prints a tab
Serial.print(BatVoltage);
Serial.print("\t"); // prints a tab
Serial.print(FetVoltage);
Serial.println(""); // prints a tab
CL2();
}
else
{
done=true;
digitalWrite(ledPin, LOW); // set the LED off - stop loading
lcd.setCursor(0, 0);// First line first char
lcd.print("Bat Power Tester [DONE] "); // Print a message to the LCD.
CL2();//clear line 2
sensorValue = analogRead(sensorPin); // read the value from the sensor:
BatVoltage = (sensorValue*4.887);
lcd.setCursor(0, 1);// Second line first char
lcd.print("V=");
lcd.print(BatVoltage); // print voltage value
lcd.print("mV I=");
lcd.print(TotalCurrent/1000);
lcd.print("mAH ");
for (int i=0; i<100 ; i++){
digitalWrite(SPKPin, HIGH);
delay(1);
digitalWrite(SPKPin, LOW);
delay(1);
}
delay(1000);
}
}
The Schematics ...
All the schematics for arduino can be found on the Arduino web page (step 2).
you can Also find how to connect standard LCDs on the same site so no need to copy it all here.
you can Also find how to connect standard LCDs on the same site so no need to copy it all here.
Please Support My Work by Voting for Me !
All and all prototype Breadboard and then moving it to a box and soldering it all together took me two weeks (night work 3-4 hours a day)
Thanks you for reading and feel free contacting me with any questions / remarks .
I am now an Arduino expert (naa I am not - 2 weeks XP )
But I have many new project I would like to do .
Thanks you for reading and feel free contacting me with any questions / remarks .
I am now an Arduino expert (naa I am not - 2 weeks XP )
But I have many new project I would like to do .