DC blocking capacitor

We’ve had a few questions about the in-line capacitor on our audio player board. This is the capacitor between the PIC pwm output pin and the gate pin on the transistor amplifier. At first glance, it seems a bit counter-intuitive: we’re “blocking” the output from the PIC to the speaker. What’s it there for?

Well, here’s the thing – the circuit will actually work without the capacitor in place.
Go ahead, try it. You can connect the output from the PIC directly to the gate on the transistor, and you’ll still hear sound. It might not be quite as loud, but it’ll still be an amplified signal. So what does the “blocking capacitor” do?

Consider what’s happening – we’re using PWM to drive a speaker.
It’s not the most efficient use of the speaker, since we’re not generating negative voltages, so we’re only every driving the speaker “forwards” using a positive voltage. But let’s ignore that for a moment!

Our PWM is creating an “average” voltage over a particular time period, to move the speaker by a certain amount. Now most digitally recreated sound waves go from minus the maximum amplitude (let’s call it -5V for simplicity) and plus maximum amplitude (e.g. +5V). When there’s no sound/signal, there’s no voltage 0V.

But because we don’t have negative values in our PWM , we’re having to use a value 0-255 to represent the full range from -5 (in this example) to +5.

So -5 (the lowest possible value in the wav file) becomes PWM value zero (the lowest possible value in our PWM output). And +5 (the maximum value in the wav file) becomes PWM value 255 (the highest possible value in our PWM output).

So where the audio file is normally zero (half-way between max and min) our output PWM value is actually 128 (half-way between 0-255). When there is no audio signal, our PWM output is 128, or half-duty cycle, or (on average) 2.5V output.

Now driving 2.5v continuously through the coil in our speaker is going to cause it to heat up and over time, eventually burn out the speaker. So what we do is put a capacitor between the output pin and the gate (which in turn controls the amount of current going into the speaker).

So now, while our audio is silent, there’s nothing actually coming out of the other side of the capacitor.

  • When the wav signal falls, the capacitor discharges  and creates a high output.
  • When the wav signal rises, the capacitor starts charging up and the “output” side falls low.
  • The output from the capacitor lags the input by a single sample width.

This means that while the signal is fluctuating – ie. we’re using an AC signal – the capacitor allows the signal to “pass-through” albeit one sample width behind the input. When the AC signal becomes DC (a period of sustained silence, for example) the output from the capacitor drops to zero and no voltage is passed into the speaker. The “blocking capacitor” acts like a filter – stopping DC current but allowing AC signals through.

This is a very crude method of driving the speaker, but one that works.
The downside is that where a very quiet audio signal is being played, with large gaps of silence, or very quiet background noise, the speaker is hardly active at all, and you can hear all the other “noise” in the line (the PWM carrier signal, for example).

We can hear this at the start of the song being played in the earlier video.
For the first ten seconds or so, the background sound of rain just sounds like a digital noise and you can hear the hum of the PWM signal. This is because parts of the audio signal are being treated as “rippling DC current” rather than a true AC signal. However, once the audio signal amplitude increases, a large AC signal is generated and the blocking capacitor allows all of the signal to pass into the speaker and the audio clarity improves.

This entry was posted in audio, News. Bookmark the permalink.

Comments are closed.