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):
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:
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?