filtering pwm for music
i would like to start by saying that this solution might not be the best… if any analog guru read this, please leave a comment.
for 2.75$ you can have a chip that is able to run at 64 mhz (phase-locked loop) and output a pulse width modulation at 250 khz. attiny85 is your friend here. i didn’t found any atmega with this option (pll)… the good news is that it’s fast enough to output a stereo WAV at 16 bits / 48 khz. if you are interested in this project, take a look here: http://elm-chan.org/works/sd8p/report.html
since i want to connect the pwm output in a power amplifier, i need to filter the signal. here’s the waveform of the pulse width modulation @ 440 hz:
now let’s see if we use a simple RC low pass:
looks good to me, but then testing with a triangle instead of an oscillator revealed this:
that’s not beautiful… here’s a close-up:
maybe using more passive filter could help, but since you need to use an op-amp as a buffer (so that your load doesn’t affect the RC filter), why not use a sallen-key topology. this will act as an active low pass filter and a buffer. let’s look at the results:
close-up:
not perfect, but better!
SIMULATIONS
simple RC (250khz = -22db)

sallen-key second-order (250khz = -44db)

sallen-key third-order (250khz = -67db)

third-order is the best and using this method only 1 stage is needed.
when choosing the op-amp, consider this:
100 * highest Q * GBW = Gain Bandwidth Product (read about it here)
slew rate => 2V/µs
i am using a rail-to-rail input / output op-amp.
now simply add an electrolytic capacitor (100 uf) and you can feed an amplifier with the original pwm signal (hopefully).





