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:

pwm_signal

now let’s see if we use a simple RC low pass:

pwm_filtered_rc_osc

looks good to me, but then testing with a triangle instead of an oscillator revealed this:

pwm_filtered_rc_tri

that’s not beautiful… here’s a close-up:

pwm_filtered_closeup_rc

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:

pwm_filtered_sk_tri

close-up:

pwm_filtered_closeup_sk

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).

29

11 2009

0 Comments Add Yours ↓

  1. psc #
    1

    I still can’t help you out, but i am very curious. The keywords i found are:
    Reconstruction filter
    Output buffer

    From this application note:
    A seventh degree Bessel filter, with a −3 dB cutoffof, 2f, f fc = fs/4, is a good choice for filtering arbitrary waveforms. This filter will exhibit an output risetime of 0.35/fc.

  2. Gorkem #
    2

    Thank you very much for your answer.
    I am using a DAC. It generates 50Hz to 8kHz. It has high freq noise components but it works. I wonder what kind of filter I can use above 2khz. Because after 2khz a big capacitive effect occurs on signal. For example a sawtooth or a triangle wave turns to a sine. Also I am planning to use an analog multiplexer to send the (nearly perfect) square wave to output without filtering.
    And one more question, why band pass filter?

  3. psc #
    3

    Hello Gorkem,
    My knowledge in analog filter is very limited…

    Your signal generator is using a DAC or PWM?
    Are you sure that your MC is fast enough?
    Maybe you will need to use a band-pass filter?

  4. Gorkem #
    4

    Hello, I would like to ask you something. I am designing a signal generator. It works between 50Hz-8kHz freq range. I used a sallen key lowpass (fc=8kHz) but I have some problems. Below 600Hz it has no effect on signal. Also above 1kHz a huge disturbance occurs. I will be grateful if I can take some answers or suggestions.

    Thank you,
    Gorkem



Your Comment