Class D Amplifier Tutorial!

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!

100 thoughts on “Class D Amplifier Tutorial!”

  1. I still don't understand what is so good about digital implifiers. And why convential "linear"amplifiers have big coils and digital amps don't. Is it because digital amps are incredibily efficient driving the movement of the speakerdriver?
    All I can imagine so far is a microprocessor driving a"tone generator" which is also the power generator directly driving the speaker drivers movement.(As you can see I am a total electronic noob)

  2. cool thanks for the input. Sounds like another application for this would be one where the distortion would be fesirable, like, say a distortion pedal for a guitar…hmm…

  3. Wait, so an audio signal is dc, lets say from 0 volts to 1 volt, or ac lets say from -1 volt to 1 volt? I am confused

  4. love your videos so great and informational and in laymen terms question I would like to build an amp that does not cut off at over 20khz I'm not using it for music so no worries there just want to amplify the freq gen I got that goes up into the MHz .. and not sure where to start since all audio amps cut off at 20khz and not sure what part of amp does that or how to fix/change etc…

  5. Great video. I need to bump the current output of a function generator and this video cleared up everything that was muddy in my text books. Thanks!

  6. great videos my friend! And I'm about to start doing some Home Studio Musician Youtube live videos and I'd love to copy your "bookmark this link and use it as your Amazon home page" function – I live in Canada and use, so not sure if it's available here, but if it is can you please tell me how to find out about it? Do I need a sellers account at Amazon? Again, many thanks, great teacher 🙂 James

  7. There are many very good class D amplifiers, theses days you will see fewer and fewer "old iron" types in any sound reinforcement situation (ex. concert), mostly becuase they are not nearly as power dense and much less efficient. Being a musician does not mean you have any special knowledge of what constitutes good sound quality. The same can be said of the so called "audiophiles" who spend thousands on tube amps (and other junk) that distorts the crap out of what they are listing to.

    There is nothing "budget", or "crappy" about a class D amp, they are becoming so popular becuase in many situations they are superior in any meaningful way.

    I make this point becuase too often I see an otherwise very informative video that happens to feature something related to audio and the presenter makes the mistake of assuming that the above mentioned groups actually know what they are talking about, if you really care to know what is best look at what actual audio engineers ( a surprising amount of whom are EEs) are using to produce the sound at large concert or in a high quality recording studio.

  8. I would like to find a schematic to build a 2.1 amplifier that could deliver some real power like 2 X 50W R.M.S and 100W for a subwoofer that could work on a 24 volts battery with an insanely low distortion…kinda like 0.001%…. I know it would be easy to get one tiny board from China….but they are so cheap and you didn't even turned the volume that the distortion already peaks at 10% and I just don't want to build a boombox that sounds like trash…..So I sure hope you can help me!
    Thanks in advance!!!

  9. Interested in learning about wireless power? Subscribers can get up to 80% off my course Wireless Power to the People – Wireless Charging 101 on udemy using the coupon code "YOUTUBE"

  10. can you tell me what program you used to draw the schematic?
    i use eagle and cant seem to find the integrated circuit's library.

  11. Please do another video of filterless class D amplifier. I did a filterless amplifier out of just microcontroller and motor H-bridge with no inductor at all (well the speaker itself is inductor).

  12. I've been watching you for a long time. I actually bought my OWON scope based on your reviews years ago.
    I'm using your amazon link now and just bought this for my son to use with ProTools

    Keep up the great work 🙂

  13. Loved your video! The part about musicians avoiding Class D is inaccurate though. Most high quality bass amps have at least a Class D power section, Dark Glass stuff and others alike. Small head, 900W of power, can only be achieved by Class D at that size and sounds amazing!

  14. Love your stuff, man. I'm an Electrical Engineering student and this is giving me a lot of encouragement to survive my classes. Keep it up!

  15. If I were playing with this, I'd experiment with using pin 6 to augment the lowpass Butterworth filters to arrive at a tunable 3rd and 5th harmonic Gyrator. The Bypass controls the first op amp of both the left and right pre-amplifiers, so why not use it to do more than power supply and startup noise reduction? Also, I'd make the MUTE, part of an active clipping controller. Remember, wherever logic is used, these are just transistors that can be operated analog, just make sure nothing overheats.

  16. Theoretically, class D amp can have 90% of power efficiency. How can I measure the power efficiency of the circuit?

  17. I dunno… I look at class D stuff and all I can think is spurious radio frequency emissions and RFI all over the place.

  18. That explainend me everything really thanks.And May be ,can you also help me out for an idea to make any HAT Board using CAN-Bus and any kind of sensors….

  19. I read a paper on a scientific magazine about this for 2 days along but this video speeds up my understanding like a rocket !! many thanks !

  20. … i know its a test but, 30w isnt a lot at all… nor a surprising amount of power… im at 4200w and still needing more for loudness.

  21. i don't get all the techy stuff. can you give me some references to check out for a better unerstanding? thank you.

  22. Hey, Nice Video. If I'm trying to make a 1 watt Mono amplifier (with the TPA2001D1pwr) Would I use all the same Inductors and capacitors? what do you think?

  23. Damn!
    Been watching you videos and I am kind of getting inspired to build a Sound box by myself for my regular uses 🙂

  24. Yours are some of my favorite electronics videos on the YouTubes. Informative with a side of humor. Thanks for all you do brother.

  25. This would have been the perfect thing back when "boomboxes" were popular. They would have used a lot less battery power, and could have driven lower impedance speakers, making them even more powerful. Once built, what was the 0 signal idle current @ 12 volts? Many of those large portable stereos used 8 D-Cells. They would last longer, particularly at lower playback levels, with a switch mode output stage. I noticed on the efficiency graphs, the levels with the widest margin of efficiency between the analog and switch mode output stages. at very low levels, the switch mode appears to have a very low idle current. It does not need a bias current, to prevent 0 crossing distortion. from 1 watt on up, advantage switch mode.

  26. …now to bridge the gap from PCM/DSD to Class-D PWM+DSP crossover/filter/delay
    (sooo… rip my CDs at 300kHz/24bit??)… toslink 48k/20… Bluetooth??? just screw the amps to the back of my 2/3-way speakers, plug in Old notebook PS… oua la!!

  27. Very nice one!! I wanted to do one like yours but amazon doesn’t ship to UK and also I want to build an max of 200W!!

  28. Well you said you read every comment so here we go. When creating tutorials like these it is hard to decide when to go a bit deep but not too deep. More important when to declare something is complicated and you should see at as black box for not. Which you did very well. I shared your page in my Facebook to gather more audience. I have a suggestion: Please provide a road map of the videos you like to make in your website and try to raise money for each like a kick starter. So there will be 30 videos in entry level which cover all basic thing and you have made some of them. But you need money to make the others. This goes on for other levels. So people see what they are missing 🙂

  29. IT WAS GREAT ! I CANt buy any thing from amazon i live in iran… and i cant donate…. but it was helpful for me. and
    thank you

  30. Wrong about high-end speakers. There are versions of audiophile (fool) grade class-d amps out there! You'll need a full bridge output stage with GAN FETS operating at 750kHz PWM with robust closed-loop control and high-quality 5th order LPF with low distortion inductors. Such class-d amp will const around 500$ per monoblock unit, which also included a high-quality SMPS.

    I'm using 2 ICEPOWER monoblocks to drive my Focal Aria 926 speakers. And the sound is much better than the class AB amp in my Denon X4400H AVR…

  31. Thanks! I'm taking an electronics course at university but it's totally useless when trying to actually make something. I'm trying to make a bass amp right now and actually understand the course material at the same time, so your video was really helpful!

  32. And if the two-wire of any output speaker gets connects, amplifier shuts down. because the output is AC, not DC? (I am not pro, just learning)

  33. Great video to introduce how the class D amplifier works! How to choose the speaker impedance? Can I use the 4 ohm impedance electronic guitar speaker?

Leave a Reply

Your email address will not be published. Required fields are marked *