We often take wireless communications for granted, without considering the underlying complexity and technological barriers. It's worth taking a closer look at those aspects.
Pulse width modulation (PWM) is popular because of its efficiency and simplicity, but normally it is relegated to power or digital applications, and not considered useful in a sensitive medium such as audio.
In the last few years, however, a number of well-known audio amplifier manufacturers began making lines of PWM amplifiers for audio, starting with subwoofers and now for what many consider the entire audio spectrum: 20Hz to 22kHz.In this column, we will look at how a digital technique, PWM, can enhance a traditionally analog application. You will also learn how to make a class D amplifier with some inexpensive motion control DSPs.
Class A, B, AB, C
Traditionally, power amplifier techniques have been broken into four classes: A, B, AB, and C. The distinctions among these classes are mostly based on electronics, so my coverage of them will be cursory. But I will do enough to show why PWM is making such a good show.The simplest form of amplifier involves only one active element, such as a transistor. This transistor is biased so that, regardless of the magnitude of the input signal, it is never completely on and never completely off. This not-off/not-on area is known as the linear region. This form of amplifier produces very low distortion output but is terribly inefficient. (A great deal of current and power is wasted keeping it in the linear region.) This is a class A amplifier.
Class B amplifiers typically involve two active elements connected so that they can “push-pull” the power. One drives the output, the other sinks it. To get an idea of what this means, imagine a sine wave referenced to some zero point, and that one of the active elements supplies the upper part of the wave (the part above zero) and the other element supplies the lower part (the part below zero). In other words, the job is shared between the two, neither one having to carry the whole show. So class B amplifiers are a little more efficient. The problem with this setup is the small region where the sine wave is passing through zero, when one transistor is just turning off and the other is just turning on. This is a non-linear condition because the transistors tend to make a small step turning on. This non-linear region results in distortion.
Class AB is-you guessed it-a combination of classes A and B. The topology is very similar to class B but employs a mechanism that supplies a small bias to each transistor so that it is never completely off. Thus, as in class A, you have some wasted power dissipation but the distortion is much lower, and, as in class B, the job is shared between two transistors, so that the overall result is better.
Class C amplifiers are usually used in radio frequency or oscillators, where distortion is really not a problem. We won't examine these here. In addition, some amplifier manufacturers have coined their own classes, but we'll save those for later.
A class D amplifier employs PWM. You will recall that PWM modulates the duty cycle of a fixed-frequency square wave to represent an input value. Because of its power efficiency, it is often chosen for high power applications. The power amplifier that drives that electric car is class D. So is the one that returns current to the line in wind-driven generators. And this industrial brute is going to treat music?
Class D presents a real increase in efficiency (commonly 90%), as far as the amplifier is concerned. Since the transistors are almost always either on or off and only in the linear region when they actually switch from one state to the other, they dissipate much less energy than those in linear amplifiers, where they are in the linear region for a substantial portion of time.
For a class D audio amplifier, the load is placed in the middle of what is called an H-Bridge (see Figure 1). This has the added advantage of allowing the output to be both positive and negative, increasing its power by a factor of four when compared with class A or B amplifiers.
Figure 1: A typical h-bridge output scenario for audio
We tend to be careful when it comes to audio. We spend extraordinary amounts of money for processors, amplifiers, and special speakers to get audio just right, and here I am talking about producing it with the same stuff you use to drive motors or produce and regulate voltages within a PC. Well, the next time you go to the theater, the sound you hear may very well be coming from just such a piece of equipment. It isn't just big amplifiers, either. Because of its power efficiency, PWM is finding its way into the smaller personal equipment, even headphone drivers.
A number of inexpensive DSPs are available, targeted primarily for motion control or power control, that can deliver the kind of carrier frequencies necessary for some segment of what is generally agreed to be the audio band. These DSPs often come with other features such as CAN buses, SPI, or other serial ports that make them suitable for self-powered applications. This makes it possible to process the sound with the same device that drives the speaker.And, if the on-chip features aren't enough, it is also possible to couple a low-cost DSP with one of the many PWM chips that are available in this area. Cirrus Logic and International Rectifier teamed up to make an audio combo for just such a purpose.
To build a class D amplifier
For practical purposes, it is possible, with enough resolution on your PWM and a high enough PWM frequency, to achieve acceptable control and decent audio. The resolution should be around 16 bits (or greater) and the PWM carrier frequency should be no less than 12 times the bandwidth of the audio. Preferably, it would be 25 times the bandwidth.You need the resolution for dynamic range, just as with any other audio application. The standard CD player promises 16 bits.
You need the high frequency for control. Before you are done, you must remove this PWM carrier from the audio; the higher frequency means smaller filters. You might come to think of such an amplifier as a power digital-to-analog converter.
Let's say you want to build a class D subwoofer. The bandwidth for a typical cinema subwoofer is 20Hz to 500kHz. This means that you must over-sample at least at 6kHz, and it would be better to over-sample at 12.5kHz. When I say over-sample, I mean that the PWM carrier frequency needs to be at 6kHz or 12.5kHz (over-sampling can occur on the output as well as the input, in signal processing).
In a simple application, an audio codec would serve as the input to the DSP. The digital output of this converter could be used to drive the PWM peripherals on board, in many cases with little or no treatment.
For best performance, the PWM peripheral should be operating in center-aligned mode. This gives you 16 bits of information on each edge.
There are two main drawbacks to class D amplifiers and both are usually handled in the same way. First, you must remove the PWM carrier from the audio output. This is done with a suitable filter, and the construction of this filter-that is, the corner frequency and the order-depends on the over-sample frequency or PWM frequency. The higher the PWM frequency, the lower the order and the simpler the filter. In Figure 1, you can see the speaker between two LC filters (second order); there's one filter for each half of the bridge. These filters remove the carrier and other harmonics from the output.
Dead-band distortion is the second problem that the filters are designed to remove. The large power transistors that make up this H-Bridge take time to turn on and off; time must be allotted for this or one may still be on when the other turns on. If this happens, we encounter a phenomenon known as “shoot-through” (a short circuit). To avoid this, the controller must ensure that both the top and bottom transistor in either leg are both off for a while before turning the other on. This is called dead-band time. Dead-band time contributes to a distortion similar to that in the class B amplifier. The filters can help eliminate it.
Usually, a Butterworth or Bessel filter is a good fit. Both have a relatively flat passband. The Bessel filter has the added benefit of linear phase.
The H-bridge in Figure 1 features two filters, one on each leg of the speaker. If you are used to designing single-ended filters, it is a simple matter to change them to balanced filters. Simply calculate the filter with half the expected load, and then use the values you get for L and C in both legs.
Next month, I'll go over some of the new, application-specific DSPs that are currently available.
Don Morgan is a senior engineer at Ultra Stereo Labs and a consultant with 25 years experience in signal processing, embedded systems, hardware, and software. He wrote a book about numerical methods, featuring multi-rate signal processing and wavelets, called Numerical Methods for DSP Systems in C. He is also the author of Practical DSP Modeling, Techniques, and Programming in C and Numerical Methods for Embedded Systems. Don's e-mail address is .