In Polish magazine 'Elektronika dla Wszystkich' ('Electronics for Everyone') there's a 'Constructors School' section with new design task given every month. In March 2014 the task was to design a device to measure capacity of lithium betteries. I decided give my skills a try and built the circuit described below.
My approach was to discharge the battery using large transistor (with a heatsink) connected in series with resistor to measure current. The current is integrated to obtain drawn load. Base of the transistor is controlled to achieve current value set by the user. Maximum discharge current is 2A, but it can be increased by adding bigger heatsink or active cooling.
The electronics consists of ATmega8 microcontroller, R-2R ladder DAC using 74HC595 shift register, LCD display, a few buttons and some analog electronics that controler the battery discharging. The DAC output is connected to non-inverting input of op-amp and inverting input is wired to shunt resistor (1R). Op-amp's output controls the current flow through transistor and shunt resistor. The microcontroller measures battery's voltage and lowers the set current (via DAC output) when voltage reaches lower threshold. The circuit was assembled on a breadboard.
Code was written in C and compiled using WinAVR toolset. I had to develop the firmware quickly (as the deadline was near), so it isn't elegant, but it works. After powering up the device asks the user about measurement parameters (discharge current, cut-off voltage) and starts the test. Actual current drawn from the battery is measured at set interval and it's integrated to obtain load, which is displayed on the LCD. When voltage reaches certain threshold the set current is lowered and when current set point reaches 0 the measurement is finished.
What I've learned
This project was interesting for me as it combines two worlds of electronics: digital and analog. I learnt a bit about R-2R DACs and designing simple transistor circuits.