http://www.edn.com/design/analog/4363990/Control-an-LM317T-with-a-PWM-signal
The LM317T from NationalSemiconductor is a popular adjustable-voltageregulator that
provides output voltagesof 1.25 to 37V with maximum 1.5Acurrent. You can adjust the output
voltagewith a potentiometer. The circuit inFigure 1 replaces the potentiometerwith an analog
voltage that you cancontrol from a PWM (pulse-width-modulation)signal. You control
thissignal with a microcontroller or anyother digital circuit. You can use thesame
microcontroller to dynamicallymonitor the output and adjust theLM317T.
Using an RC lowpass filter and anop amp, you can convert the PWMsignal to a dc level that
can adjust the LM317T’s voltage output. Varying thepulse width of the input signal lets
yougenerate an analog voltage of 0 to 5V atthe output of the lowpass filter. The opamp
multiplies the voltage to achievethe desired voltage range.
For scenarios in which you mustmultiply the input voltage by two, theLM317T’s adjustment
pin receives 0 to10V. Its output-voltage range is 1.25 to11.25V.
The equation VOUT=VADJ+1.25V governs the LM3175T’s output voltage.
You can change the op amp’s gainby choosing proper values for R4 and R2.
You must be able to remove offset voltages from the op amp.
Use an opamp, such as a National Semiconductor LM741, with null adjustment.
The selection of values for the capacitor and resistor for the RC lowpass filter
depends onthe PWM signal’s frequency. This circuituses values for a 1-kHz PWM signal.
You can improve the circuit by replacingthe RC lowpass filter with an activefilter and then
feeding a feedback signalfrom the circuit’s output into the microcontrollerfor dynamic
adjustments.