In this video I'm going to explain what a Class D amplifier is
and show you how to build one that's powerful enough for a home stereo system.
30 watts is a surprising amount of power and it'll cost you about 20 bucks.
So what is a Class D amplifier? It's an amplifier that works in a certain way.
A Class D amplifier takes an input wave, like a sine wave,
and converts it into a high frequency pulse width modulated square wave.
Then you filter the square wave and you end up with an amplified sine wave on
the output.
Let's start with example waveforms and block diagrams and we'll talk about
specific circuitry later.
I'm using my function generator to generate a 2Hz sine wave with
200 millivolts peak to peak.
2Hz is unusually slow but it lets us see what's going on.
Next, let's use some circuitry to convert that low frequency sine wave into a
high frequency square wave.
And lets show that in green. Notice how the frequency of the square wave
is a constant 300 kHz its but our 2Hz input signal is changing the pulse width of the wave.
As you know from my previous videos
a pulse width modulated square wave is an excellent way to quickly change the
amount of power going to a load.
In this case we're going to quickly change the amount of power going to a speaker.
The amount of power supplied to the speaker ends up being proportional
to the duty cycle of the high-frequency square wave. But we're not ready to
connect a speaker yet.
We've got a signal that's 0 to 12 volts DC
with tons of unwanted high-frequency noise and our speakers won't like that.
Let's add an LC low-pass filter to get rid of a lot of the high-frequency crap.
And let's pause the input signal so we can see what happens.
The high-frequency square wave is in green and the low-pass filtered output
is in yellow. The square wave is 0 to 12 volts DC with a duty cycle about 50%.
After filtering we end up with an average DC voltage of
around six volts. Notice how this isn't perfect DC.
It's a little bumpy. That's because our low pass filter isn't perfect.
Now let's crank up the input frequency to 2 Hz again so you can see how
the output changes.
Now let's zoom out on the time scale
and you can see that we've got a 2Hz sine wave now and its 2 volts peak to
peak...
Ten times more than the input. We have successfully amplified the voltage of
the input signal,
and the amplifier can also deliver a lot more current than the function generator
can.
Overall we get more power. But we're not ready to connect a speaker just yet
We still have the 6 volt DC offset. So let's add a high pass filter so only AC
can pass through to our speaker.
And instead of this boring 2 hertz test signal let's connect something more fun.
... Music playing ...
Alright, you want to make your own amplifier? Let's build this thing!
Let's start with the TPA3122.
A 12 volt power supply and a 1000uF capacitor to help filter it.
I'll put a link to the parts in the video description section.
First, let's add some more capacitors. Remember how I said a Class D amplifier
converts your input sine wave into a high frequency square wave?
A class D amplifier switches high currents at high frequencies.
Your bench power supply or your battery is not going to do a very good job
delivering stable power at these high frequencies,
So we use these capacitors to help fix that. They're also used to help stabilize
the reference voltages used inside the chip.
Next, we're going to need some bootstrap capacitors.
These are needed to help drive the transistors inside the amplifier chip.
Some class D amplifiers require these capacitors, some don't.
We can configure the gain of the amplifier with the two gain pins here.
If we connect both gain pins to the positive power supply rail,
we get a gain of 63. It's like turning our amp up to 11! Wait... wrong movie.
Connect the shutdown pin to your positive rail
and connect mute to ground, otherwise the amplifier will just stay silent.
Next, we add our LC low-pass filter
to turn the 300 kHz square wave back into something that looks more like a
normal audio signal.
You don't have to use the exact same 33uH inductor I used
but try to get one with at least 3 amp rating. Now for the capacitors,
I'm using 50V ceramic caps with X7R dielectrics.
Remember, we're trying to get rid of the high frequency content of the square wave
so there's going to be a decent amount of high-frequency current flowing
through these capacitors.
So electrolytic capacitors are not going to be good enough. Now because speakers don't
like to be fed DC
we add some 1000uF electrolytic capacitors
in series with the amplifier's output so that we only get
AC going through the speaker. So we're low-pass filtering
then we're high pass filtering. Finally let's add some 1uF capacitors to
high pass filter the input audio signal.
These also help ensure that your mp3 player doesn't get damaged in case you screw
something up.
So now we have a highly efficient class D stereo amplifier.
This thing is more than powerful enough with a 12 volt supply
but if you want to crank the supply voltage up to 28 volts
you can get two channels of 15 watts, and that's more than enough for
anyone's living room. And if you don't like doing stuff on a breadboard,
check out the link in the video description where you can buy a kit
with a PCB so you can solder a very similar version of this amplifier.
and it should give you less distortion than mine. Okay
so after all of that we turned a sine wave into a bigger sine wave.
What's the point? You can use an op-amp to do that. What's all the square wave stuff
anyhow?
Well, let's take a look at the power consumption.
Look at what's inside an LM1875 op amp.
There's a lot going on here but the part that will draw the most amount of power
is the output stage. This transistor arrangement helps form what is called a
class AB amplifier. This is the part of the amplifier
that allows it to deliver high amounts of current to a speaker.
Class AB amplifiers typically use NPN and PNP transistors on the output
and they operate in the forward active region. And to simplify what that means,
it's kind of like they have a resistance of several ohms.
This generates a lot of heat, but allows the amplifier to output a continuous low
distortion waveform.
So what does the output stage of our Class D amplifier look like?
Well it's two MOSFETs. When the top one is on and the bottom one is off
the square with goes high. When the bottom one is on and the top one is off
the square wave goes low. The resistance of each MOSFET here
is 0.2 ohms. And only one MOSFET is on at any given time.
Less resistance, less heat. And yes this is a huge simplification.
Accurately calculating amplifier efficiency is beyond the scope of this tutorial
but the important thing that I want you to know is that Class D amplifiers
are very efficient.
So if class D amplifiers are cheap and very efficient,
why aren't they used everywhere? Well at the end of the day
we're listening to a filtered square wave. Even after the low-pass filter,
it's never going to be a perfect reproduction of the input audio signal.
You're always going to have a small amount of distortion. Chances are you'll
never even notice it on most speakers and headphones
and that's why most modern consumer electronics use class D amps.
But if you have expensive speakers or you're a professional musician,
chances are you want to avoid class D and stick to less efficient,
higher quality class A or class AB designs.
But for the rest of us bums class D will do just fine
and you can use the circuit as part of a home stereo system a home made boom box
animatronics and more. Speaking of bums...
don't give money to this guy, he doesn't even know where to get a good deal!
If you like my videos you can support me by checking out the links in the video
description section.
There are many ways to help. Check this out... if you visit my Amazon link and
bookmark it
every time you use that bookmark I'll get a percentage of the money you spent
on Amazon.
The price to you is exactly the same. You get to buy whatever you would've bought on
Amazon anyway,
and Amazon just gives me a commission. And that can make the difference between me
being able to make videos
or spending my time on another job. If you can't afford to buy or donate,
that's cool too. I love reading all the encouraging comments that you guys leave.
They keep me motivated and I read every single one of them. Thanks guys!