Your circuit will allow you to vary the output voltage, but only over a narrow range. I see that your input voltage is 24 - which implies to me that you need an output voltage that is probably above 10V.
The LM317 series of regulators is designed such that the output voltage on pin 2 is 1.2V greater than the voltage at the "adj" pin 1. For that reason, your circuit will have a voltage output of a little over 1.2V (at "0" PWM) or to a maximum of 6.2V at PWM = 255.
If you want full-range, you should add an op-amp with a gain of about 5 at the R-C junction, and the output of that op-amp would go to the LM317 adjust pin. I would also pull up the PIC output pin to Vcc through a 1K (or so) resistor to help insure that the pin swings close to 5V when it is HIGH.
Adding an op-amp to the circuit would also let your raise the impedance of the R1/R2 circuit. That would allow for a smaller capacitor and lower your PIC loading.
Bookmarks