Some (most) of us are PR**LX renegades
During this Dark Age, I built a battery discharger using a 12V lamp as resistive load. This was the good old time when an Analog Input had to be emulated through an RC circuit...
The purpose of such a device is to evaluate the actual capability of a AA (R6) battery, in term of mAh
This smart version is based on an electronic load, with fixed/adjustable discharge current.
The NPN transistor acts as a variable resistor
Current is sensed through a shunt resistor; the corresponding voltage is fed back to the inverting input of an OpAmp configured as a comparator. The non inverting input is set at a reference voltage value through an adjustable voltage divider.
In an effort to have both input at the same level, the OpAmp will output the adequate signal which is fed to the NPN transistor base
To avoid full depletion of the battery, a relay disconnects the battery below 500mV. This sub miniature relay is directly driven by the Arduino
I used TIP41C and LM324, but any GP OpAmp and NPN transistor will fit the bill; just make sure that the max allowable collector current is over 2 Amps.
Volts and Amps are acquired through AI0 and AI1, mAh are computed by integrating Amp over time
Caution: This device is designed to convert electric power to HEAT :o
The power dissipation can be calculated, or simulated in LTSpice
according to datasheet, the TIP41C transistor can dissipate up to 65W. Don't take the info for granted; this value assumes that collector temperature remains at 25°C which is unrealistic.
For more than a couple of Watts, install a suitable radiator on the component.
To avoid destroying the component it is advisable to limit max power within the code
LTSpice simulation X axis = potentiometer wiper relative position (0-100%)
Arduino code is straightforward. The main point is to create a fixed time loop for accurate mAh integration.
What I learnt on batteries:
Not all batteries are created equal; I get results from 662 to 2764 mAh (all AA size)
Ageing does reduce battery capacity; some batteries where discarded after test
Internal resistance is a real issue, 1500 mAmp will definitely bring voltage down, below 1 Volt.
What I learnt as a bonus:
NPN Bipolar Junction Transistor in the active region, versus saturation region Bipolar junction transistor - Wikipedia
Operational amplifier (comparator configuration) Comparator - Wikipedia
Circuit simulation using LTSPICE (a magic world)
and... learning to post on a message board
Some questions for you: your objective is to measure battery capacity (Ah). And you also want to measure linearity of this capacity. Is this right ?
Internal resistance is a real issue, 1500 mAmp will definitely bring voltage down, below 1 Volt.
Surely. This is due to how batteries work internally, chemically speaking.
Add some decoupling capacitor (should I ???)
No need. What for ?
Take into account Base/Emitter current in calculation
It's too small compared to C-E current. But yes, perform a slight adjust.
Use a MCP3208 12 bits A/D Converter for further accuracy
Time is more important here than instantaneous current. IMHO. So make sure your timebase is accurate. But you're measuring voltage between ground and D2? if so, you're actually (if you compensate for the resistor temperature) measuring current. If you place R2 between ground and battery (-), then you can more accurately see discharge current.
reconnect to PC for graphical trends of voltage versus time
Thanks for the kind words; As your mention, the objective is to measure capacity (mAh) and the influence of current load (mA) on battery behaviour.
If you place R2 between ground and battery (-), then you can more accurately see discharge current.
I do compute mA based on mV between D2 and ground
If I place R2 between ground and battery (-), the battery voltage measured at D3 will be biased, won't it??
:o :o good job... may be overkill for this application.
I just need to pass one integer every other second
I am developping the project using StampPlot lite
Will report progress this week-end
If I place R2 between ground and battery (-), the battery voltage measured at D3 will be biased, won't it??
Yes, but since you also know V(R2) you can compensate. Which might be easier than doing compensation based on transistor values (they vary quite a bit depending on junction temperature.
#if defined CHART
delay(200); //------- Stamplot ---------------
Serial.print("!TITL Battery tester"); Serial.print(13, BYTE); // Set window title
Serial.print(MESSAGE); Serial.print(13, BYTE); // Set Status message
Serial.println("!PNTS 6000"); Serial.print(13, BYTE); // Set number of data points to collect
Serial.println("!SPAN 500, 1500"); Serial.print(13, BYTE); // Set maxi & mini range
Serial.println("!AMUL 1"); Serial.print(13, BYTE); // Set the value to multiply da
Serial.println("!CLRM"); Serial.print(13, BYTE); // Clear the message list
Serial.println("!CLMM"); Serial.print(13, BYTE); // Clear the MIN/MAX values
Serial.println("!RSET"); Serial.print(13, BYTE); // Reset the plot and all data
Serial.println("!TMAX 3600"); Serial.print(13, BYTE); // seconds maxi on x axis
#endif
in display():
#if defined CHART //StampPlot data for trending
Serial.print((int)mVolt); Serial.print(13, BYTE);
#endif
Amazing work. Let me congratulate you for the achievement!
What exactly are you plotting there ? battery voltage vs. time ?
I wonder if you can overlay also current (or voltage across sense resistor). I am curious if integration of this one will lead to "700mAh" they advertise.
Any chance you can provide me the data (data points+timebase) for both ?
Whats this ? and why the necessity to cloak it ?
Are you using this in the picture . What is its relevence?
Private joke
Some of us started learning microcontrollers with the Basic Stamp from Parallax: BASIC Stamp - Parallax
Easy language, tons of documentation,
allthough technically limited, Basic Stamp is, in my opinion, the best option for absolute beginers (Julien... : )
your battery discharger is exactly the type of projects I bought my Arduino for, but I'm afraid I'm not fit enough yet to get it done by the plan and the photos, so I would very much appreciate if you could answer me some questions:
-what is the green (quite big) part on your photos? I assume it is R2? You talk about a shunt resistor in your text. Is this the part and what are the specifications that I have to search for when I would like to order it?
-I would like to build your AdaFruit Shield version. In the photo I saw that you use a different IC there. Is it LM358N? Is it used the same way as the LM324?
-Do you have some more photos of the AdaFruid Shield version? Is it Version 2 already?
-how is the jumper for different voltages wired?
Thanks in advance. I'm looking forward to measure the capacity of my rechargeable battery collection (mainly AA and AAA-types)
You are right, the green big thingy is R2; this is a 0.47R 8W shunt resistor (SETA RB60)
Only one OpAmp is required for this project.
LM324 is a Quad OpAmp, LM358 is a dual OpAmp, both are inexpensive and OK for the job.
I finally switched to LM358 (8 pins) to save room on the PCB
My advices:
First build your prototype on a breadboard Half Sized Premium Breadboard - 400 Tie Points : ID 64 : $4.95 : Adafruit Industries, Unique & fun DIY electronics and kits
Install only basic parts, ignore relay, buzzer and voltage divider
You don't need the heatsink if you only want to test AA or AAA batteries
Make sure everything is OK before any soldering
Develop a simple software that displays Volts and Amps on your computer.
It will be easy to add features once you have the basic design right
Oh... I finally built vesion 1 circuit, please ignore V2
Good luck,this is a very educational project
Thanks a lot for your clarifications, I think I should be able to rebuild it now. I will of course first try to breadboard before I build the final shield version. A (hopefully) last question about the resistor:
What's the reason for using a 8W resistor? I thought that the transistor acts as the load and the resistor should therefore stay "cool" and does not need to have 8W. Or is it because of the precision of that types of resistors? What other kind of resistor could I use here? (it is not so easy to get, so I'm looking for alternatives)
Heat is actually shared among the two components (transistor, shunt).
You can use a 5W resistor, not less.
Heat will change resistor value and decrease accuracy
Another option is to choose a 0.1 R shunt, 1W should be OK
Don't forget to modify the code
Hi, I saw your smart arduino battery discharger today from randomly surfing and is very interested. I have a few question hopefully you can help me out with it .
The question I have is about the NPN variable resistor.
From what I understand the op-amp used as a comparator is used to limit the current draw from the battery? That if I set the Vref to 2V and initially Vp is greater than Vn in the opamp so comparator output goes to high 5V and the NPN is turned on and current flows through the shunt resistor. And if current is too high then the feedback voltage Vn is now greater than Vp and comparator output goes Low and the BJT is turned off.
I am just wondering if my observation is correct if not please shed some light on me
Hi aznweirdo
That's what it is
according to Wikipedia:
When the non-inverting input (V+) is at a higher voltage than the inverting input (V-), the high gain of the op-amp causes it to output the most positive voltage it can. When the non-inverting input (V+) drops below the inverting input (V-), the op-amp outputs the most negative voltage it can. The OpAmp will output 0 or Vs (maxi) according to Vn-Vp sign.