Class D Amp With An H-Bridge

Class D amps are simple – just take an input, and use that to modulate a square wave with PWM. Send this PWM signal to a MOSFET or something, and you have the simplest class D amp in existence. They’re so simple, you can buy a class D amp chip for $3, but [George] thought that would be too easy. Instead, he built his own with an ATTiny and an H-bridge motor driver. No surprise, it works, but what’s interesting is what effect the code on the ATtiny can have on the quality of the audio coming out of the speaker.

The microcontroller chosen for this project was the ATtiny 461, a part we don’t see much, but still exactly what you’d expect from an ATtiny. The heavy lifting part of this build is an L298 chip found on eBay for a few dollars. This dual H-bridge is usually used for driving motors, but [George] found a home for it in the power section of an amplifier.

The ATtiny is clocked at 16 MHz, making the ADC clock run at 1 MHz. A 10-bit precision conversion takes place, and this value sets the PWM duty cycle. Timer1 in the chip is set up to run at 32 MHz, and by counting this timer up to 1023 gives this amp its PWM cycle speed of 31.25 kHz. That’s right in the neighborhood of what a class D amp should run at, and the code is only about 30 lines. It can’t get simpler than that.

[George] put up a video of this amp in operation, and despite not following the standard design of a Class D amp, it sounds pretty good. You can see that video below.

Continue reading “Class D Amp With An H-Bridge”

[Afrotech]’s Guide To Class D Amplifiers

classd

Hang around in any of the many guitar or audiophile forums or discussion boards for long enough, and eventually you’ll come across the arguments over amplifier topologies. One of the more interesting and useful of these classes of amplifier is class d – they’re extremely efficient and when well designed can sound pretty good. [Afrotech] is here to show you how they work, and how to build a 15 Watt amp using a $3 class d amplifier chip.

The very definition of an amplifier is taking a low power signal and transforming it into a high power signal. A great way to modulate a high power signal very quickly is by modulating a square wave with pulse width modulation. A class d amplifier takes a low power input signal, uses it to modulate the duty cycle of a high power square wave, and with a little filtering, amplifies the low power input.

To demo this, [Afrotech] used TI’s TPA3122 class d amplifier chip. It’s a pretty cheap chip for being a 15 Watt stereo amplifier, and the circuit is simple enough to build on a breadboard. With a few caps, resistors, and a pair of inductors, [Afrotech] built this one-chip amplifier that’s capable of powering some pretty big speakers. It’s also very efficient – no heat sink required.

Although class d amps are extremely efficient. there are a few people out there that say because the amplifier is basically a filtered square wave, you’ll be able to hear a difference in the audio over class a or class ab amplifiers. This led to the development of class t amplifiers, basically a class d amp with a higher switching speed (Megahertz for class t, a few hundred kilohertz for class d). Still, if you need a cheap amplifier for a DIY boombox or any other high power application, you could do a lot worse than a simple class d amp.

Continue reading “[Afrotech]’s Guide To Class D Amplifiers”