I have a microcontroller that is generating a PWM signal between 0 and 12V of varying frequency. I'm looking to build some sort of circuit that will take this signal and then attenuate the high and low values of that square wave to be anywhere between 0 and Vmax (12V in this case). The trick here is that the low signal may need to be higher than 0V, so it can't just be a voltage divider on the square wave.

I would guess that this would use some sort of potentiometer or maybe even a variable op amp, but I'm a software guy and don't know what I'm doing. :)

Basically I want to be able to generate high and low voltage values of my choice while still retaining the frequency and duty cycle. Ex. 250mV-500mV, 3V-5V, etc.

Any ideas where to start, or what a circuit for this would look like? Please comment if more information is required.


1 Answer 1


Using a precision clamp might be OK: -

enter image description here

U1 clamps the maximum level at the value V3 and U2 keeps the minimum level no lower than V5.

Probably best to do a simulation to see how those particular op-amps handle the maximum PWM frequency you are wanting to use - faster devices can of course be chosen.

  • \$\begingroup\$ Could you explain the difference between the clamped output and the optional buffered output? \$\endgroup\$
    – LaneL
    Dec 29, 2016 at 15:52
  • \$\begingroup\$ The buffer is there to be able to drive a load resistor without affecting the levels - if you look you will see that there is a 1 kohm resistor (R1) present and this means you cannot put too much load on the unbuffered output without upsetting the signal levels. \$\endgroup\$
    – Andy aka
    Dec 29, 2016 at 15:59
  • \$\begingroup\$ Thank you. This is looking good on a simulation except there are pretty large spikes on the edges that will need to get filtered out. I'm running between 250mV and 500mV. Maybe need a capacitor somewhere? \$\endgroup\$
    – LaneL
    Dec 29, 2016 at 16:56
  • \$\begingroup\$ Are they "overshoots"? Maybe try a faster op-amp? \$\endgroup\$
    – Andy aka
    Dec 29, 2016 at 17:00
  • \$\begingroup\$ What op-amp did you use in the sim and what frequency is your PWM (just for my reference)? \$\endgroup\$
    – Andy aka
    Dec 29, 2016 at 17:18

Your Answer

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

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