Hi,
Some (most) of us are P*R**L*X 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.
Here it is:

Smart battery discharger/tester diagram
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

Breaboard implementation
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
http://en.wikipedia.org/wiki/Bipolar_junction_transistor#Regions_of_operationOperational amplifier (comparator configuration) http://en.wikipedia.org/wiki/Comparator
Circuit simulation using LTSPICE (a magic world)
and... learning to post on a message board
Additional readings
TIP41C datasheet: http://www.datasheetcatalog.com/datasheets_pdf/T/I/P/4/TIP41C.shtml
LM324 datasheet:
http://www.datasheetcatalog.com/datasheets_pdf/L/M/3/2/LM324.shtmlLTSpice Homepage: http://www.linear.com/designtools/software/
LTSpice Tutorial: http://claymore.engineer.gvsu.edu/~steriana/Videos/
Next steps
- Add some decoupling capacitor (should I ???)
- Take into account Base/Emitter current in calculation
- Use a MCP3208 12 bits A/D Converter for further accuracy
- install an LCD display and piezo buzzer for stand alone operation
- reconnect to PC for graphical trends of voltage versus time
Thanks for reading
Yves