I've been studying this schematic that I found while searching the web. I understand the point of PWM - it allows us to vary the average voltage fed to the op-amp precisely. The filter R1,R2 and C1 integrate the PWM waveform.

But what is the point of the op-amp? It looks like a non-inverting amplifier to me, with the gain set by R6 and R7 - if I'm not mistaken. But why does the integrated DC voltage need amplification?

Perhaps, I don't understand that part because I don't understand how the Lm317 is working in conjunction with the MCU. I understand that LM317 drops a reference 1.25V between the OUT and ADJ pin (which should be across R5 in reference to the circuit) and the Vout is defined as 1.25(1 + R2/R5) + I(adj.) * R2. (from datasheet)

Since the only variable is I(adj) in the above equation, am I correct in my understanding that the integrated DC voltage is actually changes the current and hence the output voltage?

Any insight would be appreciated.


1 Answer 1


The opamp acts to make the junction of R6 and R7 the same voltage as Vc. And the R6/R7 junction is a fixed proportion of Vl. So

  • Vl = Vc x (R6 + R7) / R7.

Because - the opamp works to set it's input terminals equal when negaive feedback is applied. Non inverting input is set to target voltage by PWM. If R6/R7 feeback point (call this Vf) is too low then opamp output will increase positively to increase Vadj on LM317 which will increase Vl and thus Vf. Opposite applies when Vf is too high.

All the rest is "engineering" (or not :-) )

The opamp is effectively forming a dynamic value of the "datasheet's R2" in series with R4 on the circuit.

R5 drops 1.25V by design of the IC so R4 drops whatever else is required to allow the opamp to balance things as above.

This allows the opamp output to operate at a lower voltage than Vl. This is not especially needed here as the opamp operates from V2 which is at least 3+ Volts above the mzimum level Vl can get to (due to LM317 design) so R4 actually limits the lowest voltage that can be achieved by Vl (due to the division of R5 and R4.)

For best flexibility here R4 = 0 ohms!. Some opamps will not go to full Vdd but here there is ample headroom for almost any opamp as Vs-Vl = LM317 Vdropout_min + 1.25V or about 3.5V. An eg LM324 or LM358 would work OK there.

R3 is something of a mystery - it is not needed to make the circuit work. It adds a positive offset to the PWM voltage which should be unneeded. The circuit designer may have had something special in mind when he added it. Can you provide a link to the original article?

  • 1
    \$\begingroup\$ I think R2 and R3 are there to have a defined output, even if the controller fails to provide the PWM. Could be useful for controlling a fan. \$\endgroup\$ Aug 6, 2011 at 1:52
  • 2
    \$\begingroup\$ R2 & R3 might set a "sane" voltage when the microcontroller pin is floating during boot. Depending on their values in relation to R1, they might also determine a default voltage about which the micro has only limited influence. \$\endgroup\$ Aug 6, 2011 at 1:53
  • \$\begingroup\$ This is the link to the original article: electronicdesign.com/article/digital/… I am trying to understand how you got the relation for Vl. I understand that the voltage across the V- input is VL*(R7/(R6+R7)). \$\endgroup\$
    – Saad
    Aug 6, 2011 at 2:00
  • 1
    \$\begingroup\$ Changed main formula to Vc = ... (was V0 = ...) Both are correct but Vc= is what I really meant. \$\endgroup\$
    – Russell McMahon
    Aug 6, 2011 at 2:17
  • 1
    \$\begingroup\$ Circuit operation description added just under main formula. \$\endgroup\$
    – Russell McMahon
    Aug 6, 2011 at 2:20

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.