Can someone please help me here.
I've been playing around trying to build a AA battery capacity checker.
Ultimately I'd like to create a discharger/charger that can handle 4 x AA and/or 4 x AAA NiMh batteries and make these for my kids - so that they'll turn away from Alkaline batteries!
I've started by using Adam Welch's thread. I've build the circuit using and Arduino Mega, Robot LCD shield, 1 ohm 5W shunt resistor, 1.2 ohm 15W power resistor to discharge through, a AA battery holder and an N channel Mosfet. The specified Mosfet is IRF3205, but I can't find one, so I've tried an IRF540, IRF 740 (which my local electronics store suggested), but the readout on the serial screen is incorrect / not working. I have some switching transistors, Darlingtons, PNP transistors, but none seems to work - I'm pulling at straw here.
On another forum, it said that I'd have to use a Mosfet with an "L" in it (something about it need to be a "Logic" mosfet. The chap said something about being able to fully open and allow 5V? Link Could this be the problem?
Given my code, I start with:
Battery Voltage = 1.39 Shunt Voltage = 1.50
battVolt current mAh
1.39 -0.10 -0.06
Then it goes to "complete".
I've been playing around trying to build a AA battery capacity checker.
Ultimately I'd like to create a discharger/charger that can handle 4 x AA and/or 4 x AAA NiMh batteries and make these for my kids - so that they'll turn away from Alkaline batteries!
I've started by using Adam Welch's thread. I've build the circuit using and Arduino Mega, Robot LCD shield, 1 ohm 5W shunt resistor, 1.2 ohm 15W power resistor to discharge through, a AA battery holder and an N channel Mosfet. The specified Mosfet is IRF3205, but I can't find one, so I've tried an IRF540, IRF 740 (which my local electronics store suggested), but the readout on the serial screen is incorrect / not working. I have some switching transistors, Darlingtons, PNP transistors, but none seems to work - I'm pulling at straw here.
On another forum, it said that I'd have to use a Mosfet with an "L" in it (something about it need to be a "Logic" mosfet. The chap said something about being able to fully open and allow 5V? Link Could this be the problem?
Given my code, I start with:
Battery Voltage = 1.39 Shunt Voltage = 1.50
battVolt current mAh
1.39 -0.10 -0.06
Then it goes to "complete".
Battery Capacity Checker:
/*
Battery Capacity Checker
Uses ROBOT LCD Keypad shield
Uses 1 Ohm power resister as shunt – Load can be any suitable resister or lamp
YouTube Video: https://www.youtube.com/embed/qtws6VSIoYk
http://AdamWelch.Uk
Required Library – LiquidCrystal.h
*/
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
#define gatePin 3
#define highPin A2
#define lowPin A3
boolean finished = false;
int printStart = 0;
int interval = 5000; //Interval (ms) between measurements
float mAh = 0.0;
float shuntRes = 1.0; // In Ohms – Shunt resistor resistance
float voltRef = 5.01; // Reference voltage (probe your 5V pin)
float current = 0.0;
float battVolt = 0.0;
float shuntVolt = 0.0;
float battLow = 0.8;
unsigned long previousMillis = 0;
unsigned long millisPassed = 0;
void setup() {
Serial.begin(9600);
Serial.println("Battery Capacity Checker v1.1");
Serial.println("battVolt current mAh");
pinMode(gatePin, OUTPUT);
digitalWrite(gatePin, LOW);
lcd.begin(16, 2); // start the library
lcd.clear();
lcd.setCursor(0, 0); // go to 1st space, 1st line
lcd.print("Checking battery:");
lcd.setCursor(0, 1); // go to 1st space, 2nd line
lcd.print("Please wait...");
lcd.blink();
delay(2000);
lcd.clear();
}
void loop() {
battVolt = analogRead(highPin) * voltRef / 1024.0;
// Serial.print("Battery Voltage = ");
// Serial.print(battVolt);
shuntVolt = analogRead(lowPin) * voltRef / 1024.0;
// Serial.print(" Shunt Voltage = ");
// Serial.println(shuntVolt);
if (battVolt >= battLow && finished == false)
{
digitalWrite(gatePin, HIGH);
millisPassed = millis() - previousMillis;
current = (battVolt - shuntVolt) / shuntRes;
mAh = mAh + (current * 1000.0) * (millisPassed / 3600000.0);
previousMillis = millis();
lcd.clear();
lcd.setCursor(0, 0); // go to 1st space, 1st line
lcd.print("Discharge ");
lcd.print(battVolt);
lcd.print("v");
lcd.setCursor(0, 1); // go to 1st space, 2nd line
lcd.print("I=");
lcd.print(current);
lcd.print("a ");
lcd.print(mAh);
lcd.print("mAh");
Serial.print("Battery Voltage = ");
Serial.print(battVolt);
Serial.print(" Shunt Voltage = ");
Serial.println(shuntVolt);
Serial.print(battVolt);
Serial.print("\t");
Serial.print(current);
Serial.print("\t");
Serial.println(mAh);
delay(interval);
}
if (battVolt < battLow)
{
digitalWrite(gatePin, LOW);
finished = true;
lcd.clear();
lcd.print("Discharge");
lcd.setCursor(0, 1);
lcd.print("0mAh. Complete");
delay(interval * 2);
}
}
Attachments
-
2.7 KB Views: 0
Last edited: