I want to create an Analog Voltage by filtering a PWM signal. After some googling, I found an active low pass filter topology with -40db/decade called the Sallen-Key topology. I tried implementing a circuit which would take a PWM with 31.25 kHz frequency and filter out anything but the DC component. When simulating with LTSpice this seems to work (if I use a dual supply), however when implementing on a breadboard using the LM358 dual Op-amp, the circuit behaves weird...

This is the circuit (OP27 is in my case the LM358):

It works at high duty cycles, but at low duty cycles really large voltage spikes appear.

This is how it behaves, as seen from my oscilloscope, at over 70% duty cycle (NOTE: RED is PWM input and blue is filter output): At relatively high duty cycle the circuit works as expected, transforming a PWM value into an analog voltage

And this is how it behaves at about 50% duty cycle:

Notice the large, over 1V voltage spikes.

I did an FFT on both signals with following results:

High duty cycle: High duty cycle

Mid-Low duty cycle:

As you can see, no extra harmonics appear, their amplitude just changes with varying duty cycle, however the filter seems to respond really weird.

Does anybody have an idea why this problem appears and how to fix it?

  • \$\begingroup\$ Try adding a 4.7k resistor from the output of the op-amp to the negative rail. This is documented in the datasheet, although they recommend 6.2k. \$\endgroup\$ Commented Apr 30, 2015 at 19:07

1 Answer 1


This looks like crossover distortion in the amplifier- it's really not fast enough to respond to the 30kHz input. You can try a pullup resistor of a few K on the output, but that will prevent the output from going all the way to ground, unless you have a negative supply.

This kind of thing (dependence on op-amp output impedance) is one of the reasons why I don't particularly care for S-K filters. You might do better with a passive filter, at least for the first stage where you've got very fast edges.

  • 2
    \$\begingroup\$ What kind of filter typologies do you care for ? \$\endgroup\$
    – efox29
    Commented May 1, 2015 at 0:25

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.