I'm designing a pwm generator comparing a saw-tooth signal with a DC signal. The saw tooth is applied on the non inverting input of the U3A, and it is compared with the DC signal that comes from the voltage divider. The problem is that I can't find a formula that relates the square wave that I'm getting at output, the saw tooth signal and the DC signal. Can someone help me figure out a formula so I can size the voltage divider? enter image description here


1 Answer 1


The range of voltages that are capable of being produced by R13 is largely what the signal amplitude range of the sawtooth should be. This gives you 0% to 100% PWM at the output of your comparator. I can't think of a way to express this more succintly by using a formula.

Choose R8, R13 and R7 to produce a range that equals the sawtooth peak and trough voltages - it's as simple as that. Or you can even exceed those voltages if you want to a guaranteed 0% and 100%. If you want to go from 1% to 99% choose those resistor values to produce a range just inside the limits of the sawtooth amplitude.

You can even use circuitry that peak detects the sawtooth limits and use these to set the end-point voltages on the potentiometer R13. Then, if your sawtooth grows a little, your PWM duty cycle remains constant.

Not really suited for a formulaic answer. However, a picture never hurts: -

enter image description here

  • \$\begingroup\$ Thank you! Maybe that's why I didn't found a formula in any book I've searched. I need to adjust the duty cycle between 25% and 65%, and I placed a DC source on the inverting input and I've figured out after a couple of tries that my reference voltage for 25% duty cycle is -2.5V and +2.5V for 65%. That means I need to replace the ground with a -14V on the voltage divider. \$\endgroup\$
    – Lowrdson
    Commented May 12, 2018 at 10:03
  • \$\begingroup\$ Yes, if your triangle wave is symmetrical around 0 volts you need the mid-point of R13 to also produce 0 volts. \$\endgroup\$
    – Andy aka
    Commented May 12, 2018 at 10:14
  • \$\begingroup\$ It's a saw tooth, not a triangle, this are the requirements. Thank you! \$\endgroup\$
    – Lowrdson
    Commented May 12, 2018 at 10:17
  • \$\begingroup\$ Oops, I'll fix my answer but the "theory" is the same! \$\endgroup\$
    – Andy aka
    Commented May 12, 2018 at 10:19
  • \$\begingroup\$ Is it unprofessional that I'm finding my needed reference voltages by multiple tries with a voltage source on the inverting input? I need to write a documentation on this project and I'm kind of blocked when I reach the duty cycle part. \$\endgroup\$
    – Lowrdson
    Commented May 12, 2018 at 10:29

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.