PWM To Control a LM317 Adjust Pin

Hey Guys,

Ive seen a few discussions on the internet relating to how people have used the arduinos PWM signal to change the adjust pin on a LM317 Voltage regulator using a MOSFET.

I know this is usually done through the ratio of a resistor and a potentiometer in a feedback loop, but since a PWM signal can only be changed to emulate a DC Signal for voltage I'm getting quite lost on how driving it into a MOSFET could act as resistance to change this ratio.

I want to regulate my 12v (via Wallwart) into the lm317 to anywhere between 2-10v using the PWM from my arduino so i can digitally set the voltage.

This is one discussion that i have come across.

http://www.protonbasic.co.uk/showthread.php/62966-Just-pondering-LM317-control-using-PWM-as-opposed-to-a-Potentiometer

Any Help is more than appreciated. :smiley:

Any feedback of a voltage regulator can be (mis)used this way.

The normal way is to use (programmable) resistors to ground.
A mosfet could be used instead of resistors. The gate of the mosfet could be a filtered PWM signal from the Arduino.
You need a mosfet, capable to operate with low voltages. And you have to find out yourself which PWM signal results in which voltage. I couldn't find a schematic, did you find any?

But it is also possible to draw current from or inject current to the feedback.
So you could use digital outputs with resistors to the feedback. And use HIGH (+5V) to inject current or LOW (0V) to draw current from the feedback.

The answer is a theoretical yes and a practical maybe.

One way to adjust the output is to raise the potential on the adj pin. So that part is definitely yes.

The practical difficulty is how you raise it. Your arduino can output an analog signal, by pwming through a low-pass filter. However, the pin has limited current capabilities and the low-pass filiter has high output resistance to minimize ripple. The regulator has a minimum output current requirement and the highest value resistor across its reference voltage is 470ohm (typically 120ohm).

That means the low-pass filter has to have an output resistance substantially smaller than that - and that requires either low resistance (which means high ripple) or large capacitance (tough to get and poor dynamic regulation).

One way to overcome that is to use a buffer.

Reopened at the request of @rasman

The general answer is that this is a very inappropriate way to control a regulator. :roll_eyes:

You need a proper DAC and an op-amp circuit to configure the DAC output voltage to what is required to feed the regulator.

What's really important is the required response time for a change on the adjust pin. If this is for a programmable voltage regulator application where you're not expecting the high speed performance of a DAC, then I think this is relatively easy to accomplish.

Here's an interesting solution that doesn't use a MOSFET or op-amp. Just some careful resistor selection and 2-stages of filtering. Also, you could use 10-bit PWM instead of 9-bit as shown.

  • What is the minimum response time requirement?
  • What is the "adjust" resolution requirement? (i.e. 0.01V from 2V-10V is 800 steps)

A LM317 is simply a 1.2 V regulator designed to have minimum current it the control leg.

Controlling the LM317 with a voltage is perfectly fine. I can think of no reason to suggest this is a bad thing to do. In fact I believe the app for this part shows one configuration with a Zener in the control leg, which is basically a voltage source.

Be sure you have enough filtering on your PWM output to make it into a DC voltage, otherwise the LM317 will be unstable and likely unusable (if no filtering).

If you have some filtering but still have ripple on your filter, then the LM317 will try to control the output with that amount of ripple. It may or may not be successful.

In any case it's unlikely to harm the LM317.

Nice to see the additional input from long time posters but not sure of the value to a post where the OP's are no longer members.

ballscrewbob:
Nice to see the additional input from long time posters but not sure of the value to a post where the OP's are no longer members

:slight_smile: I didn't even look at the date of the OP. I saw there was a "NEW" post and blindly carried it on....

See reply #3.

herbschwarz:
See reply #3.

And where are they ?

When you build your project be sure to properly heat sink it. The LM317 sort of acts like a resistor in that the voltage drop across it is burnt up as heat. This will show up real quick at the lower voltage settings.

JohnRob:
Controlling the LM317 with a voltage is perfectly fine. I can think of no reason to suggest this is a bad thing to do. In fact I believe the app for this part shows one configuration with a Zener in the control leg, which is basically a voltage source.

Be sure you have enough filtering on your PWM output to make it into a DC voltage, otherwise the LM317 will be unstable and likely unusable (if no filtering).

And that is what I was getting at. PWM is a very poor voltage for the purpose. It is unlikely to be particularly stable or linear. :roll_eyes:

I tend to use these modules for this type of app.

Programming the cutoff points is quite simple on the Arduino side.

PWM is a very poor voltage for the purpose. It is unlikely to be particularly stable or linear.

Its a timer based PWM filter ... very stable (CPU clock) and very linear (1023 duty control steps). Only considerations are load (also linear) and peak-peak ripple (determined by PWM frequency, set voltage, R and C).

For just a 1-stage filter, 10-bit PWM frequency at 7.8kHz, R=3.6K, C=100µF, 0-50% duty step response:

  • Settling time to 90% = 0.83 sec
  • Final Vout = 2.5V
  • Pk-Pk ripple = 0.000445V

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.