切换到宽版
  • 4399阅读
  • 8回复

[AVR]Arduino 锂电、镍镉、镍锰电池容量测试仪 [复制链接]

上一主题 下一主题
离线abigbell
 

发帖
11330
M币
1683
专家
457
粉丝
532
只看楼主 倒序阅读 我要置顶 楼主  发表于: 2015-01-05
        Arduino Diecimila 1602单色屏 制做简单的锂电、镍镉、镍锰电池容量测试仪,转自网友moris-zen。



           这个东西,能够根据待测电池的电压自动判断放电类型。使用的一块arduino diecimila板子,这里作者
就直接使用了一块atm168配合几个外围元件代替。放电假负载用的是一个2.2 欧姆的 10W的水泥电阻。所以
可以测量大功率电池,例如 18650 锂电池。







         数据采集就是使用单片机两个AD数模单元分别采集电压、电流,然后计算得出最后的容量。
放电电路简单,就是下图,2.2欧姆 10W水泥电阻做负载,穿上个开关管,由单片机控制开关。
测试时,直接将两个单片机的两个A/D脚接到水泥电阻两端即可。电压直接读取,电流 I = Delta V / R。
具体参看代码。



(开关管的G端接单片机的19脚)


       这个模块可以通过串口向计算机发送数据,可以例如Excel将所得到的数据统计”成图”


代码如下:
// include the library code:
#include<liquidcrystal.h>

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);
    }
}


有网友利用类似的设计,做出来的4通道电池容量测试仪,屏幕用是手机彩屏。
可惜没有公布代码








本文内容包含图片或附件,获取更多资讯,请 登录 后查看;或者 注册 成为会员获得更多权限
本帖最近打赏记录:共9条打赏 ,M币+27
离线科学家

发帖
789
M币
1618
专家
4
粉丝
43
只看该作者 1楼 发表于: 2015-01-05
离线z674163666

发帖
3632
M币
180
专家
10
粉丝
83
只看该作者 2楼 发表于: 2015-01-05
请登录后查看
离线统领三界
发帖
107
M币
-341
专家
0
粉丝
3
只看该作者 3楼 发表于: 2015-01-05
请登录后查看
离线yzq1736
发帖
78
M币
4
专家
1
粉丝
2
只看该作者 4楼 发表于: 2015-11-30
请登录后查看
离线mrplplplpl

发帖
491
M币
3558
专家
0
粉丝
4
只看该作者 5楼 发表于: 2015-11-30
请登录后查看
离线qwa1234

发帖
86
M币
440
专家
0
粉丝
1
只看该作者 6楼 发表于: 2015-12-21
请登录后查看
离线holdsky28

发帖
72
M币
2662
专家
0
粉丝
1
只看该作者 7楼 发表于: 2015-12-22
离线szcolcol
发帖
2
M币
-500
专家
0
粉丝
0
只看该作者 8楼 发表于: 2016-03-25
请登录后查看
快速回复
限80 字节
温馨提示:所有技术区严禁灌水,“沙发”“顶”字样;禁止广告贴;以免被删除
 
上一个 下一个