Help me understand this battery charger circuit

I hope to use my arduino to control charging some NiMh batteries using a circuit much like Peter Hayles did using a PIC on his website: http://www.angelfire.com/electronic/hayles/charge1.html. Below is a diagram of his circuit (fig 3):

Now my question for all the EE types out there. He uses a transistor to turn the LM317 on or off to fast charge his batteries.... How does he change the current for trickle charging at 4% of the speed of the fast charging? I think you could use a current divider and another transistor, but that may not be the best way.

A little background about myself... I did a few years of EE before changing majors to Mathematics 10 years ago.

I just discovered the arduino and it seems to represent the most interesting and fun part of EE!!

Thanks!!

The magic word is "PWM": the PIC sends out a square wave, and varies the duty cycle from (presumably) about 100% for "fast charge" to about 4% for "trickle charge".

Ran

And the Ardunio can do PWM, using the "analogWrite()" function.

Cool. Using PWM to create a variable resistor...

I'll have to build it and try it.

Thanks!!

OK, I need some help with basic circuitry and math. The LM317 outputs 1.25 Volts between the Output and the Adj pins. So, with a 1 ohm resistor, it would output 1.25 amps (I=1.25 Volts/1 Ohm). So what role does the 1k resistor hold?

Also, when the transistor is biased on, what exactly happens mathematically?

I am trying build a circuit that requires the same values as the original author (ie charge NiMh batteries at a maximum of 1250 mA, and then use a PWM output to throttle it down to about 4% of the max which is about 50 mA) but would really like to understand the math and circuitry behind it.

Thanks!!

The 1K resistor is to provide a feedback voltage to the regulator from the top of the diode. However, when the transistor turns on this feedback is shorted to earth and stops any voltage being produced. In that case if you didn't have the 1K then the transistor would fry.

when the transistor is biased on, what exactly happens mathematically?

then Adj is connected to zero volts. See the LM317 data sheet for what that does to the regulator.

Any idea what the wire going from pin 4 to the 3k3 resistor is used for?

It appears that pin 4 is the master clear for the PIC16C711-04/P.

I want to duplicate this circuit using an Arduino and an external DC source. Do I need the wire going from pin 4 to the 3k3 resistor? I was hoping to leave it out and use a multimeter to measure the current across the load (battery charger) with various PWM values until I got what I was looking for (50 mA or 1250 mA).

Thanks for helping out a newbie.

Any idea what the wire going from pin 4 to the 3k3 resistor is used for?

Do you mean pin 4 to the 1K? If so it is not the pin 4 it is connecting to it is just the +5V, it just so happens that pin 4 is directly connected to 5V as well.