I am wanting to build a custom power supply for myself, and am having trouble understanding how to drive the adjust pin with a microcontroller.

The datasheet for it is here: http://www.ti.com/lit/ds/symlink/lm117.pdf

The issue is that I can make a pseudo? DAC with a low pass filter to get 0-5 volts from my PWM output, however Vout is formed by \$1.25+V_{adj} \$ , meaning, I can only get 1.5-6.5 (or 0-5 if negatively offset) with my solution as is.

My questions are: How do I offset -1.25V? A negative regulator (i.e. LM337) seems a little overkill, however I have never seen a solution with my own eyes and it could be very normal. Are there any quick ways you can think of to offset it?

And more importantly, how do I drive the ADJ pin from ~0-12V if my uC can only output 0-5 with PWM? Is there an indirect method of doing this? A simple building block I can place in between to map this range?

I am quite open to alternatives, however fixing this has piqued my interest and there are not many similar adj. regulators available to me (LT3080 with ~0 offset not available on Mouser at the moment)

  • 3
    \$\begingroup\$ You should have a look at this video series about just the same thing you want to do: eevblog.com/2011/11/28/… \$\endgroup\$
    – 0x6d64
    Mar 11, 2012 at 12:54
  • \$\begingroup\$ Actually, @0x6d64, the designer ends up simply living with the offset in that series. He has another project, however, that uses a battery for offset: alternatezone.com/electronics/ucurrent/uCurrent%20Schematic.png \$\endgroup\$
    – tyblu
    Mar 11, 2012 at 16:44
  • \$\begingroup\$ Well, he uses the LT3080 in that project, which OP specifically mentioned wasn't a great choice atm. The LM317s in the first video are both replaced before the end of it. \$\endgroup\$
    – exscape
    Mar 11, 2012 at 17:15
  • 1
    \$\begingroup\$ If you drive the adjust pin with a microcontroller, the regulation is only as good as your microcontroller. (and built-in microcontroller references are usually lousy.) \$\endgroup\$
    – markrages
    Mar 11, 2012 at 17:57
  • 1
    \$\begingroup\$ I watched the eeblog video series on this regualtor. It goes off the rails early, when Dave fails to acknowledge that he's using the pricy LT3080 as an expensive power transistor. Once you have an external reference and control loop, why not just use a PNP darlington or P-channel FET? \$\endgroup\$
    – markrages
    Mar 11, 2012 at 18:04

2 Answers 2


To scale your PWM output voltage (0 - 5 V) up to 0 - 12 V you'll just need a an op-amp in the standard non-inverting configuration with gain of 2.4. You could do this with just about any commodity op-amp. You can also add low-pass filtering to this circuit to (further) reduce the ripple from your PWM setup.

offset gain-of-2.4 op-amp circuit

For this to give 0-12 V output from the '317, Vcc needs to be 14-15 V (to bias the LM4041 properly at 10.8 V out), and you also need a negative rail low to let the op-amp generate -1.2 V when you want the LM317 output at 0 V.

You also want to remember the LM317 can only source current, not sink. So if your load will require some current to be drawn out of it to reach 0 V, you'll need either some kind of pre-loading (a pull-down resistor from the output pin to the negative supply rail)

  • \$\begingroup\$ Grr, with that and a Falstad simulation (reference replaced with 1.2V breakdown Zener) it is just offset, i.e. -15 to -10 volts when applied 0-5 \$\endgroup\$ Mar 12, 2012 at 0:56
  • \$\begingroup\$ You're right. That'll teach me (maybe) to post without testing. Try the new version. \$\endgroup\$
    – The Photon
    Mar 12, 2012 at 4:00
  • \$\begingroup\$ Brilliant, thank you :) First time I've ever used an op-amp for something. Better than a 10V DAC, less parts. Happily on to my current limiting feature. \$\endgroup\$ Mar 12, 2012 at 5:40

My aproach is probably too much in the way of parts for you, but here it goes: Use an opamp ( dual supply ) to generated voltages with an offset. Feed this to the adjust pin. You will use very little negative current, perhaps you can get it from a charge pump running off a square wave produced by the microcontroller, else a 555 timer might be used.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.