As you may have inferred from the above paragraph, the output of the class D amplifier will be a square wave. Square waves can be used to drive many things. This instructable will focus on using the output to drive an audio driver (ideally a sub-woofer); however it can be used for DC-DC conversions as well as to drive various types of motors.
Most class D amps are built from dedicated IC's. These are generally more expensive, but are good quality. As stated earlier, this instructable will layout a class D amplifier built from standard IC's. Depending on the quality of your build can result in a good sounding amplifier for common listeners considering it's simplicity and ease of construction.
This instructable will be broken into 4 parts. 1) Saw-tooh Generator 4) Modulator 3) Amplifier/ Low-Pass and 4) Additional Recommendations.
Step 1: Saw-Tooth Generator
When designing this portion of the circuit, I recommend a duty cycle of 75%-90% and a frequency well above 20kHz. The components listed in the attached schematic will yield a duty cycle of about 80% and a frequency ~30kHz.
There are other ways to generate saw-tooth waveforms with more accuracy, however this is quick and dirty. Also, I believe it is more common for the wave for to be a triangle wave, but this works equally as well.
Step 2: Square Wave Modulator
The circuit is pretty simple, take an LM311 comparator and feed it the saw-tooth wave at one input, and the AC signal with the DC offset. The DC offset is set by the potentiometer in the modulator circuit attached. You can play around with this but 6V is about where you should be (assuming your rail supply is 12V). The 1uF AC coupling cap is absolutely necessary. The value isn't critical, although I would recommend above .1uF. It should also be non-polarized.
If your audio source is an MP3 player, cell phone, or the like; the second circuit, voltage input with gain, should be used. The both will work, but the voltage out of these devices are usually small. This circuit gives volume control with the potentiometer and insures that the device always sees at least 10k as to not load the device. The circuit shown has a gain of 11, but I recommend playing around with this value based on your liking. RB1=RB2 so that the DC biasing is centered. You can use a potentiometer for this in order to balance the voltages if you'd like. Use relatively large resistances for these. If you do decide to use this circuit, the AC coupling capacitor as well as the 10k pot should be eliminated so that the output of the op-amp feeds directly into the comparator. The reasoning is that the output of the op-amp should already be offset by a the DC value at the non-inverting input of the op-amp. I forgot to write op-amp IC i used in the picture. I recommend an LF356 however an LM741 would work equally as well. There are other ways of going about this but this is simple and effective.
Step 3: Amplifier and LC Low-Pass Filter
Once you've determined the MOSFETs and driver configuration, the last step is the low-pass filter. This filter takes out the carrier signal that the wanted AC signal lies on. In my case, it's the 30kHz signal generated by the saw-tooth generator. The cut-off frequency of an LC low-pass filter follows the equation f=(2*pi*L*C)^-1. You can set this at 20kHz for full audio range or cut it off much lower for use as a sub-woofer amp. It's absolutely up to you. The capacitor before the LC filter Cblk is critical. You could destroy your speaker without this capacitor. It should be electrolytic and it should also be rather large.
With that being said, grab a crappy speaker and test away. Good luck!
Step 4: Final Recomendations
Implement star grounding so that the current draw from the FETs doesn't freak out the op-amp and other ICs.(I didn't in the circuit attached, oh well)
Separate the FETs from the ICs.
Use a scrap speaker for testing so that you don't destroy good speakers in case you've made a mistake.
Build each component separately, test, and then move on once it works.
I know I'm overlooking a few things but use your imagination and google and things will come together.
Thanks for taking your time to read my instructable. I hope you enjoyed the read. Also I hope you enjoy your freshly built class D amp.