Arduino Battery Tester

a small project to test 1S Lipo batterys used in micro Helicopters with the help of a Arduino.

1S Lipo Tester

An Arduino shield with mosfets switches big load resistors until the Lipo is drained,
and transmitts the current voltage over the USB Port to the PC.

Sourcecode, Diagramms and more after the break!



Shematics

Arduino Lipo Discharge Shield

Partlist:

1x Arduino
1x Protoboard
3x 3,9R 25W Resistors
3x IRFZ44N
3x 100k Resistor
X Cable connector

Digital Pin 5/6/7 are used to switch the Mosfets directly,
on Analog Input Pin 0 the current battery voltage is measured.

Every 100ms a measurement is done, until the voltage drops below 3.2V

The Data is send to the PC where its logged into a *.csv file and then plotted with Excel:

1S Lipo discharge diagramm

It shows a 300mAh and a 550mAh 1S Lipo, discharged with different settings.
With the known restistance the capacity from the Battery can be calculated!

For interest a conversion to Mini-Dean Plugs was testet:

Lipo Mini-Dean test

It shows the much lower voltage drop on the connector! So Mini-Dean Plugs are worth it!

Code


//Battery Tester by Stephan Martin 
//http://www.designer2k2.at
// 08.06.2012


const int analogInPin = 0;  // Analog input pin that the potentiometer is attached to

int sensorValue = 0;        // value read from the pot
float SensorVoltage = 0;
unsigned long time;
unsigned long Start = 0;
int Mosfets = 0;
boolean RunIt = false;

void setup() {

  //Define Mosfet Pins as Outputs
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(7,OUTPUT);
  
  //and give them a clear off:
  digitalWrite(5,LOW);
  digitalWrite(6,LOW);
  digitalWrite(7,LOW);

  // initialize serial communications at 9600 bps:
  Serial.begin(9600); 
  
  pinMode(13,OUTPUT);
  
  // Ask for the Mosfets
  Serial.println("How many Mosfets to turn on?");
  
}

void loop() {
  


  // check if data has been sent from the computer:
  if (Serial.available()) {
    Mosfets = Serial.parseInt(); 
    Serial.print(Mosfets);
    
  switch(Mosfets){
    case 1:
      //1 Mosfet (Center)
      Serial.println("Activate the center, 1A!");
      digitalWrite(5,LOW);
      digitalWrite(6,HIGH);
      digitalWrite(7,LOW);
      RunIt = true;
      break;
    case 2:
      //2 Mosfet (Center)
      Serial.println("Activate the edges, 2A!");
      digitalWrite(5,HIGH);
      digitalWrite(6,LOW);
      digitalWrite(7,HIGH);
      RunIt = true;
      break;
    case 3:
      //3 Mosfet (Center)
      Serial.println("Activate ALL, 3A!");
      digitalWrite(5,HIGH);
      digitalWrite(6,HIGH);
      digitalWrite(7,HIGH);
      RunIt = true;
      break;
    default:
      Serial.println("");
      Serial.print("NO Idea what: ");
      Serial.print(Mosfets);
      Serial.println(" should be. Try 1/2/3");
      // read the analog in value:
      sensorValue = analogRead(analogInPin); 
      SensorVoltage = sensorValue * (5.0/1023.0);  
      Serial.print("Current Voltage: ");
      Serial.println(SensorVoltage);
      RunIt = false;
      digitalWrite(5,LOW);
      digitalWrite(6,LOW);
      digitalWrite(7,LOW);
  }

    Start = millis();
  }
  
  
  // read the analog in value:
  sensorValue = analogRead(analogInPin); 
  SensorVoltage = sensorValue * (5.0/1023.0);  
  
  //if the Voltage is below 3.2V Turn on the LED, and OFF Them Mosfets!
  if (SensorVoltage < 3.2){
    digitalWrite(13,HIGH);
    digitalWrite(5,LOW);
    digitalWrite(6,LOW);
    digitalWrite(7,LOW);
    if(RunIt==true){
      Serial.println("Shutoff!!!!! UNDERVOLTAGE!!!!");
      RunIt = false;
    }
  }else
  {
    digitalWrite(13,LOW);  
  }
    
  //fetch the time:
  time = millis();
  
  // print the results to the serial monitor (only if needed)
  if(RunIt==true){
  Serial.print(time-Start);                       
  Serial.print(";");      
  Serial.println(SensorVoltage);    
  }


  // wait 100 milliseconds before the next loop
  delay(100);                     
}




Comments powered by CComment