PC Controlled Voltage or Current Source
This project was begun as a means to charge and cycle NiCad batteries but has become a versatile tool for experiments requiring either a controlled voltage up to +30V and/or a current of +/- 2.5 Amps.
If all you want to do is charge and recycle NiCad batteries, then, with hindsight, I'd advise you to buy one of the commerical units available. The circuit I will describe will do the job but it is experimental and has many short comings. It is more the beginning of a useful tool than one that has been fully developed. This circuit and the related software have taken me a good 2 years to reach even a marginal degree of reliability despite it's apparently simple actions.
My complete assembly uses the Discovery Series K-2805 Parrallel Port Interface Kit as distributed by DickSmith Electronics as the source of control voltages and, if used as a charger, the Battery Cell measurements. Any other PC interface with at least 4 analogue inputs and 2 analogue outputs, both with 0 to +5V range, could be put to use.
Below is the circuit for one of the two identical voltage/current sources included in my construction.

The components are:
| Label | Component |
| OA1,OA2 | 2 parts of 4 OpAmp I.C. LM324 |
| Q1,Q2 | 2N2055 (TO3 package NPN) or 2N3055 |
| Q3 | BC547 (any small NPN) |
| Q4 | BC557 (any small PNP) |
| D1,D2,D3 | signal diode rated over 30V |
| C1 | 1nF Green |
| F1 | 3A Fast Blow |
| R1 | 0.1R 5W |
| R2,R3 | 470R 1/2W |
| R4,R6 | 10K 1/4W |
| R5,R7 | 100K 1/4W |
| R8 | 47K 1/4W |
| R9 | 270K 1/4W |
| R10 | 47K 1/4W |
| R11 | 1K 1/4W |
| R12 | 100K 1/4W |
| VR1 | 500K |
Vrawpos/neg is supplied in my construction by a seperate power supply module which comprises a centre tapped transformer, a 4amp rectifier and two 10000uF capacitors supplying unregulated 18/36V peak DC.
Typically I use this circuit with Prawpos at +18V and Prawneg and Ground connected to the centre tap. More typically Prawpos would be connected to +18V, Prawneg to -18V and Ground to the centre tap. For higher voltages, Ground can be connected to the -18V supply but great care must be taken this is not connecting a -18V voltage to the PC interface ground which may be earthed through the PC.
"With versitility comes confusion!" - R.Parker 2001AD
The load in my case is a NiCad battery of between 1.2 and 24V, but it could really be anything; active loads like batteries are just more of a challenge to control. Note: to discharge a 1.2V battery will required a negative power source, but for larger voltages, Prawneg may be connected to ground as described above.
Q1 is sources voltage to the load and Q2 sinks voltage from the load. Naturally they get hot and so need good heat sinking and some thermal isolation from other components and sensitive fingers. I was lucky to find a preloved aluminium box with an internal frame on which I mounted the transistors. Air holes either end have further helped to keep the box reasonably cool.
Source or Sink actions can be disabled by opening S2 or S3 respectively. R2 and R3 then clamp the transistor base to prevent transistor operation. Even then, some minor leakage will be apparent through R2 & R3 themselves; a better solution may be to have S2 & S3 in circuit to the load but their rating would need to be increased accordingly.
Transistors Q3 & Q4 buffer the controlling action of opamp OA1 which, throught the magic of feedback, eliminates any dead zone due to the Vbe voltage drops in Q3, Q4 or Q1 (i.e. without feedback, any control voltage would first have to overcome these voltage drops before current could flow to or from the load).
The link between the base of Q3 and the emitter of Q4 is to enable lower discharge voltages to ground when Vrawneg is to ground (enabling discharge to +0.7V with S2 closed, +1.1V with S2 open). This will only work with D1 there to allow the emitter of Q4 to rise above ground. D1 is also there to prevent Base to Emitter breakdown of Q4 (which occurs when the output of OA1 exceeds +6V); it doesn't really prevent it, but it does limit the current from OA1s output through the base to the emitter. The same it true for Q3 if the output of OA1 goes below -6V. This seems to be more complicated than it needs to be.
Trying to understand this apparently simple circuit has caused me a few headaches.
As mentioned already, to reliably discharge a 1.2V cell a split supply is really necessary but it is a bit scary letting a PC connect a -15V to a +1.2V cell.
A voltage between 0 and +5V is fed to OA1 either from a PC interface or, when the interface is unplugged, from the manually operated VR1 (it assumes that the impedance of the Analogue Voltage from the PC interface is much lower than R12). I have used this circuit to charge batteries using only the manual contol but VR1 does not provide a stable control for low currents and frequent adjustment is necessary (not to mention a good alarm clock to remind you to turn it off). Still the manual control is particularly useful for quick diagnostics.
With SW1 in position A, Current Source Mode, negative feedback to OA1 comes from a current measurement taken across R1 via OA2. Since the OA2 is referenced to +2.5V, 0V on the control voltage should result in -2.5Amps (sinking) through R1 (assuming a suitable load is connected). If the control voltage rises to +5.0V, then +2.5Amps (sourcing) through R1 should result. If the load imedance is too high, the output voltage at the load will rise or fall towards the supply rail voltages (more on this in a moment).
With SW1 in position B, Voltage Source Mode, negative feedback to OA1 comes from the output voltage, divided by a factor of 6 by R9 and R10. A control voltage of 0V will result in 0V at the output, +5V will (should) result in +30V (if Vpos is > +30V) at the output. I am thinking R10 could be connected to Vneg to allow negative outputs but it seemed more useful to have the output voltage controlled relative to ground and I haven't tried it out.
For the purposes of Battery charging, SW1 remains in position A.
With the opamp used (LM324) and the the supply conditioning I provide for the opamp (see below), the maximum supply voltage in current source mode is Vrawpos - 4.5V (13.5V for 18V supply). As such, running this system off a car battery will only allow you to charge a 5 cell NiCad. Using an OpAmp which can source and sink closer to supply voltage and possibly connecting the OpAmp supply directly to Vrawpos (quite okay for a 13.5V car battery supply) may allow you to charge 7 cell packs off a car battery but I haven't tried it. I think we'll leave fast charging off car batteries to a more dedicated unit.
I originally thought it would be useful to measure both output voltage and output current and, since both feedback signals should be in the 0 to 5V range, these can be measured with the PC Interface that I use which has 10 analogue inputs. Current measurement turns out to be of no particular use in battery charging as any errors in the control of the source or sink current arise from the +2.5V reference voltage which in turn are reflected in the measurement with a few extra errors thrown in. The current measurement may be of more use where this device is being used as a voltage source or in analysing someone elses charger (I have done this to determine the parameters for an unlabelled NiCad pack that came with a toy car and plug pack charger - see External Logging). Current can also be measured by a sensitive voltmeter across R1 using test poit TP1.
Below is the circuit I used to supply the I.C.s and voltage references:

The components are:
| Label | Component |
| D1 | Rectifier Diode rated over 30V and 100mA |
| ZD1 | Zener Diode 30V 1W |
| ZD2 | Zener Diode 5.1V 400mW |
| Q5 | BC557 PNP |
| RD1 | LM336-2.5V Voltage Reference |
| D5 | Small Rectifier Diode (~30mA duty) |
| LED1 | Whatever |
| R13 | 330R 1W |
| R14 | 2.2K 1/4W |
| R15 | 110R 1/4W |
| R16 | 1K 1/4W |
| C2 | 10uF 50VW |
The LM324 is happy with voltages up to 30V, so this supply is clamped at 30V with ZD1 and C2 removes a good deal of ripple from the unregulated supply. The value of R13 was found by trial and error to match the I.C. supply current. D4 is there to prevent the inevidable mistake.
The voltage reference circuit draws more current than I would have liked so I have used a current source from the unregulated supply to feed 5V Zener ZD2 which in turn feeds the 2.5V reference circuit. Originally I used a simple resistor to feed ZD2 but with the supply varying from 10 to 36V, the current to ZD2 also varied greatly and all sorts of problems followed. Q5 controls the current to approx. 20mA by using the voltage drop through LED1 as a reference voltage. The diode is there to drop the "5V" level to about 4.7V. This is connected in my unit to the 5V supply in the PC interface (through a 1K resistor) so that both operate at the exact same level. This was a good idea when the 2.5V reference was created by a simple divider, but now that I use a 2.5V reference diode, this link and diode D5 are nolonger necessary and I have only shown it as this is what is in my construction.
While I have shown only one 2.5V ref. circuit (R16 & RD1), I have in my construction 2 circuits, one for each voltage current source circuit. This was necessary before I fitted Q5 to provide a constant current to ZD2. I suspect two 2.5V reference circuits are nolonger necessary but I haven't tried it yet.
One of the problems in using this Current Source for battery charging is that, until the software has taken control, this unit will initially attempt to sink 2.5Amps from the battery (control voltage at 0V). As such, either the battery must be left disconnected or S3 left open until the software has got itself together. If the computer crashes for some reason the results would be unpleasant.
The simplest solution I have come up with so far is to disable the +2.5V reference circuit with the following alternative supply circuit.

While D0 to D3 are open collector outputs from the PC Interface which must be enabled by the software before they sink any current. As such, while D0 and D1 are not enabled following boot up, the 2.5V reference will float between 0V (as will occur with zero control volts) and about 0.8V. On my unit at boot up, this results in about 100mA discharge of the connected battery. Not exactly passive, but not disasterous either.
As it happens, this modification provides additional versatility. By connecting D2 and D3 to the 2.5V reference voltages, these can be clamped to rise no greater than 0.9V. When this is so, 5V control voltage will now correspond to 5Amps source. Given the right power supply (mine could not handle this load for long) and the right load, this could be useful. There would be no affect in the voltage source mode.
This is the end of description of the circuit regarding voltage and current source control. The software (charger) I've written for an IBM PC compatible (based on Intel Microprocessor 8086 series and above) computer and the Discovery Series PC Interface, has a manual test mode and a battery charger mode. Future modes intended for the voltage/current source will be added as they occur to me (or you). I will be considering release of the source code on a GNU licence with the hope that useful modification would be released back to me. In the mean while, if you would like the source code, my current email address is "rpact" with an ISP called "dingoblue.net.au" (I'm trying to avoid automatic spam so put an @ inbetween and mail me).
The following pages might also be of interest for people intending to use this circuit for EXPERIMENTAL battery charging. I repeat that for reliable battery charging, a commercial unit would probably give better satisfaction.