Digital Signal Processing

By Steven W. Smith, Ph.D.

- 1: The Breadth and Depth of DSP
- 2: Statistics, Probability and Noise
- 3: ADC and DAC
- 4: DSP Software
- 5: Linear Systems
- 6: Convolution
- 7: Properties of Convolution
- 8: The Discrete Fourier Transform
- 9: Applications of the DFT
- 10: Fourier Transform Properties
- 11: Fourier Transform Pairs
- 12: The Fast Fourier Transform
- 13: Continuous Signal Processing
- 14: Introduction to Digital Filters
- 15: Moving Average Filters
- 16: Windowed-Sinc Filters
- 17: Custom Filters
- 18: FFT Convolution
- 19: Recursive Filters
- 20: Chebyshev Filters
- 21: Filter Comparison
- 22: Audio Processing
- 23: Image Formation & Display
- 24: Linear Image Processing
- 25: Special Imaging Techniques
- 26: Neural Networks (and more!)
- 27: Data Compression
- 28: Digital Signal Processors
- 29: Getting Started with DSPs
- 30: Complex Numbers
- 31: The Complex Fourier Transform
- 32: The Laplace Transform
- 33: The z-Transform
- 34: Explaining Benford's Law

Your laser printer will thank you!

Analog Filters for Data Conversion

Figure 3-7 shows a block diagram of a DSP system, *as the sampling theorem
dictates it should be*. Before encountering the analog-to-digital converter,

the input signal is processed with an electronic low-pass filter to remove all frequencies above the Nyquist frequency (one-half the sampling rate). This is done to prevent aliasing during sampling, and is correspondingly called an antialias filter. On the other end, the digitized signal is passed through a digital-to-analog converter and another low-pass filter set to the Nyquist frequency. This output filter is called a reconstruction filter, and may include the previously described frequency boost. Unfortunately, there is a serious problem with this simple model: the limitations of electronic filters can be as bad as the problems they are trying to prevent.

If your main interest is in software, you are probably thinking that you don't
need to read this section. *Wrong*! Even if you have vowed never to touch an
oscilloscope, an understanding of the properties of analog filters is important
for successful DSP. First, the characteristics of every digitized signal you
encounter will depend on what type of antialias filter was used when it was
acquired. If you don't understand the nature of the antialias filter, you cannot
understand the nature of the digital signal. Second, the future of DSP is to
replace *hardware* with *software*. For example, the *multirate* techniques
presented later in this chapter reduce the need for antialias and reconstruction
filters by fancy software tricks. If you don't understand the hardware, you
cannot design software to replace it. Third, much of DSP is related to digital
filter design. A common strategy is to start with an equivalent* analog filter*, and
convert it into software. Later chapters assume you have a basic knowledge of
analog filter techniques.

Three types of analog filters are commonly used: Chebyshev, Butterworth, and
Bessel (also called a Thompson filter). Each of these is designed to optimize a
different performance parameter. The complexity of each filter can be adjusted
by selecting the number of poles, a mathematical term that will be discussed in
later chapters. The more poles in a filter, the more electronics it requires, and
the better it performs. Each of these names describe what the filter *does*, not a
particular arrangement of resistors and capacitors. For example, a six pole
Bessel filter can be implemented by many different types of circuits, all of
which have the same overall characteristics. For DSP purposes, the
characteristics of these filters are more important than how they are constructed.
Nevertheless, we will start with a short segment on the electronic design of
these filters to provide an overall framework.

Figure 3-8 shows a common building block for analog filter design, the
modified Sallen-Key circuit. This is named after the authors of a 1950s paper
describing the technique. The circuit shown is a two pole low-pass filter that
can be configured as any of the three basic types. Table 3-1 provides the
necessary information to select the appropriate resistors and capacitors. For
example, to design a 1 kHz, 2 pole Butterworth filter, Table 3-1 provides the
parameters: k_{1} = 0.1592 and k_{2} = 0.586. Arbitrarily selecting R_{1} = 10K and C
= 0.01uF (common values for op amp circuits), R and R_{f} can be calculated as
15.95K and 5.86K, respectively. Rounding these last two values to the nearest
1% standard resistors, results in R = 15.8K and R_{f} = 5.90K All of the
components should be 1% precision or better.

The particular op amp use isn't critical, as long as the unity gain frequency is more than 30 to 100 times higher than the filter's cutoff frequency. This is an easy requirement as long as the filter's cutoff frequency is below about 100 kHz.

Four, six, and eight pole filters are formed by cascading 2,3, and 4 of these circuits, respectively. For example, Fig. 3-9 shows the schematic of a 6 pole

Bessel filter created by cascading three stages. Each stage has different values
for k_{1} and k_{2} as provided by Table 3-1, resulting in different resistors and
capacitors being used. Need a high-pass filter? Simply swap the R and C
components in the circuits (leaving R_{f} and R_{1} alone).

This type of circuit is very common for small quantity manufacturing and R&D
applications; however, serious production requires the filter to be made as an
*integrated circuit*. The problem is, it is difficult to make resistors directly in
silicon. The answer is the switched capacitor filter. Figure 3-10 illustrates its
operation by comparing it to a simple RC network. If a step function is fed into
an RC low-pass filter, the output rises exponentially until it matches the input.
The voltage on the capacitor doesn't change instantaneously, because the
resistor restricts the flow of electrical charge.

The switched capacitor filter operates by replacing the basic resistor-capacitor
network with two capacitors and an electronic switch. The newly added
capacitor is much smaller in value than the already existing capacitor, say, 1%
of its value. The switch alternately connects the small capacitor between the
input and the output at a very high frequency, typically 100 times faster than the
cutoff frequency of the filter. When the switch is connected to the input, the
small capacitor rapidly charges to whatever voltage is presently on the input.
When the switch is connected to the output, the charge on the small capacitor
is transferred to the large capacitor. In a resistor, the rate of charge transfer is
determined by its resistance. In a switched capacitor circuit, the rate of charge
transfer is determined by the value of the small capacitor *and* by the switching
frequency. This results in a very useful feature of switched capacitor

filters: *the cutoff frequency of the filter is directly proportional to the clock
frequency used to drive the switches*. This makes the switched capacitor filter
ideal for data acquisition systems that operate with more than one sampling rate.
These are easy-to-use devices; pay ten bucks and have the performance of an
eight pole filter inside a single 8 pin IC.

Now for the important part: the characteristics of the three classic filter types. The first performance parameter we want to explore is cutoff frequency sharpness. A low-pass filter is designed to block all frequencies above the cutoff frequency (the stopband), while passing all frequencies below (the passband). Figure 3-11 shows the frequency response of these three filters on a logarithmic (dB) scale. These graphs are shown for filters with a one hertz cutoff frequency, but they can be directly scaled to whatever cutoff frequency you need to use. How do these filters rate? The Chebyshev is clearly the best, the Butterworth is worse, and the Bessel is absolutely ghastly! As you probably surmised, this is what the Chebyshev is designed to do, roll-off (drop in amplitude) as rapidly as possible.

Unfortunately, even an 8 pole Chebyshev isn't as good as you would like for an antialias filter. For example, imagine a 12 bit system sampling at 10,000 samples per second. The sampling theorem dictates that any frequency above 5 kHz will be aliased, something you want to avoid. With a little guess work, you decide that all frequencies above 5 kHz must be reduced in amplitude by a factor of 100, insuring that any aliased frequencies will have an amplitude of less than one percent. Looking at Fig. 3-11c, you find that an 8 pole Chebyshev filter, with a cutoff frequency of 1 hertz, doesn't reach an attenuation (signal reduction) of 100 until about 1.35 hertz. Scaling this to the example, the filter's cutoff frequency must be set to 3.7 kHz so that everything above 5 kHz will have the required attenuation. This results in the frequency band between 3.7 kHz and 5 kHz being wasted on the inadequate roll-off of the analog filter.

A subtle point: the attenuation factor of 100 in this example is probably
sufficient even though there 4096 steps in 12 bit. From Fig. 3-4, 5100 hertz will
alias to 4900 hertz, 6000 hertz will alias to 4000 hertz, etc. You don't care what
the amplitudes of the signals between 5000 and 6300 hertz are, because they
alias into the unusable region between 3700 hertz and 5000 hertz. In order for
a frequency to alias into the filter's passband (0 to 3.7 kHz), it must be greater
than 6300 hertz, or 1.7 times the filter's cutoff frequency of 3700 hertz. As
shown in Fig. 3-11c, the attenuation provided by an 8 pole Chebyshev filter at
1.7 times the cutoff frequency is about 1300, much more adequate than the 100
we started the analysis with. The moral to this story: *In most systems, the
frequency band between about 0.4 and 0.5 of the sampling frequency is an
unusable wasteland of filter roll-off and aliased signals*. This is a direct result
of the limitations of analog filters.

The frequency response of the perfect low-pass filter is* flat* across the entire
passband. All of the filters look great in this respect in Fig. 3-11, but only
because the vertical axis is displayed on a *logarithmic* scale. Another story is
told when the graphs are converted to a *linear* vertical scale, as is shown

in Fig. 3-12. Passband ripple can now be seen in the Chebyshev filter (wavy
variations in the amplitude of the passed frequencies). In fact, the Chebyshev
filter obtains its excellent roll-off by *allowing* this passband ripple. When more
passband ripple is allowed in a filter, a faster roll-off can be achieved. All the
Chebyshev filters designed by using Table 3-1 have a passband ripple of about
6% (0.5 dB), a good compromise, and a common choice. A similar design, the
elliptic filter, allows ripple in both the passband *and* the stopband. Although
harder to design, elliptic filters can achieve an even better tradeoff between roll-off and passband ripple.

In comparison, the Butterworth filter is optimized to provide the sharpest roll-off possible *without* allowing ripple in the passband. It is commonly called the
*maximally flat filter*, and is identical to a Chebyshev designed for zero passband
ripple. The Bessel filter has no ripple in the passband, but the roll-off far worse
than the Butterworth.

The last parameter to evaluate is the step response, how the filter responds
when the input rapidly changes from one value to another. Figure 3-13 shows
the step response of each of the three filters. The horizontal axis is shown for
filters with a 1 hertz cutoff frequency, but can be scaled (inversely) for higher
cutoff frequencies. For example, a 1000 hertz cutoff frequency would show a
step response in *milliseconds*, rather than *seconds*. The Butterworth and
Chebyshev filters overshoot and show ringing (oscillations that slowly
decreasing in amplitude). In comparison, the Bessel filter has neither of these
nasty problems.

Figure 3-14 further illustrates this very favorable characteristic of the Bessel filter. Figure (a) shows a pulse waveform, which can be viewed as a rising step followed by a falling step. Figures (b) and (c) show how this waveform

would appear after Bessel and Chebyshev filters, respectively. If this were a
video signal, for instance, the distortion introduced by the Chebyshev filter
would be devastating! The overshoot would change the brightness of the *edges*
of objects compared to their *centers*. Worse yet, the left side of objects would
look bright, while the right side of objects would look dark. Many applications
cannot tolerate poor performance in the step response. This is where the Bessel
filter shines; no overshoot and symmetrical edges.