Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Digital Signal Processing. The Scientist and Engineers Guide. Steven W. Smith

.pdf
Скачиваний:
166
Добавлен:
02.05.2014
Размер:
7 Мб
Скачать
☆

Chapter 13Continuous Signal Processing

257

Time Domain

a. Pulse

k

A

 

d = k/T

T

 

t = 0

 

b. Square

 

A

 

t = 0

 

c. Triangle

 

A

 

t = 0

 

d. Sawtooth

A

 

t = 0

 

e. Rectified

 

A

 

t = 0

 

f. Cosine wave

A

 

t = 0

 

Frequency Domain

A

a0

' A d

 

2 A

an ' n B sin (n Bd )

0

 

 

 

 

 

 

bn ' 0

 

 

 

 

 

 

 

0

f

2f

3f

4f

5f

6f

( d ' 0.27 in this example)

A

 

 

 

 

 

 

 

 

a0

' 0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

a

n

'

2 A

sin

n B

 

 

 

 

 

 

 

 

 

 

 

 

n B

 

2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0

 

 

 

 

 

 

 

 

 

bn

' 0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(all even harmonics are zero)

 

 

 

 

 

 

 

 

 

0

f

2f

3f

4f

5f

6f

A

 

 

 

 

 

 

 

 

a0

' 0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

an

'

 

4 A

 

 

 

 

 

 

 

 

 

 

 

 

 

(n B)2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0

 

 

 

 

 

 

 

 

 

bn

' 0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(all even harmonics are zero)

 

 

 

 

 

 

 

 

 

0

f

2f

3f

4f

5f

6f

A

 

 

 

 

 

 

 

 

a0

' 0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

an

' 0

 

 

 

 

 

 

 

 

 

 

 

bn

'

A

 

 

 

 

 

 

n B

0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0

f

2f

3f

4f

5f

6f

 

 

A

a0

'

2 A /B

 

 

an

'

 

& 4 A

 

 

B(4n 2& 1)

 

 

 

 

0

 

 

 

 

 

bn

' 0

 

 

 

 

 

 

 

0

f

2f

3f

4f

5f

6f

 

A

a1 ' A

(all other coefficients are zero)

0

0

f

2f 3f 4f 5f 6f

FIGURE 13-10

Examples of the Fourier series. Six common time domain waveforms are shown, along with the equations to calculate their "a" and "b" coefficients.

258

The Scientist and Engineer's Guide to Digital Signal Processing

 

 

 

 

-T/2 -k/2 k/2

T/2

 

 

 

A

 

 

 

 

 

 

 

Amplitude

 

 

 

 

 

 

 

0

 

 

 

 

 

 

 

-3T

-2T

-T

0

T

2T

3T

Time

FIGURE 13-11

Example of calculating a Fourier series. This is a pulse train with a duty cycle of d = k/T. The Fourier series coefficients are calculated by correlating the waveform with cosine and sine waves over any full period. In this example, the period from -T/2 to T/2 is used.

Figure 13-11 shows an example of calculating a Fourier series using these equations. The time domain signal being analyzed is a pulse train, a square wave with unequal high and low durations. Over a single period from & T /2 to T /2 , the waveform is given by:

x (t )

'

A

for -k/2 # t # k/2

x (t )

'

0

otherwise

The duty cycle of the waveform (the fraction of time that the pulse is "high") is thus given by d ' k /T . The Fourier series coefficients can be found by evaluating Eq. 13-5. First, we will find the DC component, a0 :

T/2

a0

'

1

m

x (t ) d t

(start with Eq. 13-5)

 

T

 

 

 

 

& T/2

 

 

 

1

k/2

 

 

 

a0

'

m

A d t

(plug in the signal)

 

 

 

T

 

 

 

 

 

 

 

 

 

 

& k/2

 

 

 

 

a0

'

 

A k

(evaluate the integral)

 

 

 

 

 

 

 

T

 

 

 

 

 

 

 

a0

'

A d

(substitute: d = k/T)

 

 

This result should make intuitive sense; the DC component is simply the average value of the signal. A similar analysis provides the "a" coefficients:

Chapter 13Continuous Signal Processing

259

 

 

2

T /2

 

 

 

2Bt n

 

an

'

 

m

x (t ) cos

d t

T

 

T

 

 

 

 

& T /2

 

 

 

 

 

 

 

2

k /2

 

 

2Bt n

 

 

an

'

 

m

A cos

d t

 

T

 

 

T

 

 

 

 

 

 

 

 

 

 

 

 

& k /2

 

 

 

 

 

 

 

2 A

 

T

 

 

2Bt n

 

k /2

an

'

 

sin

 

/

T

 

2Bn

T

 

 

 

 

 

 

 

& k /2

 

 

 

 

 

 

 

 

 

 

 

a

n

'

2 A sin(Bn d )

 

 

 

 

 

 

n B

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(start with Eq. 13-4)

(plug in the signal)

(evaluate the integral)

(reduce)

The "b" coefficients are calculated in this same way; however, they all turn out to be zero. In other words, this waveform can be constructed using only cosine waves, with no sine waves being needed.

The "a" and "b" coefficients will change if the time domain waveform is shifted left or right. For instance, the "b" coefficients in this example will be zero only if one of the pulses is centered on t ' 0 . Think about it this way. If the waveform is even (i.e., symmetrical around t ' 0 ), it will be composed solely of even sinusoids, that is, cosine waves. This makes all of the "b" coefficients equal to zero. If the waveform if odd (i.e., symmetrical but opposite in sign around t ' 0 ), it will be composed of odd sinusoids, i.e., sine waves. This results in the "a" coefficients being zero. If the coefficients are converted to polar notation (say, Mn and 2n coefficients), a shift in the time domain leaves the magnitude unchanged, but adds a linear component to the phase.

To complete this example, imagine a pulse train existing in an electronic circuit, with a frequency of 1 kHz, an amplitude of one volt, and a duty cycle of 0.2. The table in Fig. 13-12 provides the amplitude of each harmonic contained in this waveform. Figure 13-12 also shows the synthesis of the waveform using only the first fourteen of these harmonics. Even with this number of harmonics, the reconstruction is not very good. In mathematical jargon, the Fourier series converges very slowly. This is just another way of saying that sharp edges in the time domain waveform results in very high frequencies in the spectrum. Lastly, be sure and notice the overshoot at the sharp edges, i.e., the Gibbs effect discussed in Chapter 11.

An important application of the Fourier series is electronic frequency multiplication. Suppose you want to construct a very stable sine wave oscillator at 150 MHz. This might be needed, for example, in a radio

260

The Scientist and Engineer's Guide to Digital Signal Processing

transmitter operating at this frequency. High stability calls for the circuit to be crystal controlled. That is, the frequency of the oscillator is determined by a resonating quartz crystal that is a part of the circuit. The problem is, quartz crystals only work to about 10 MHz. The solution is to build a crystal controlled oscillator operating somewhere between 1 and 10 MHz, and then multiply the frequency to whatever you need. This is accomplished by distorting the sine wave, such as by clipping the peaks with a diode, or running the waveform through a squaring circuit. The harmonics in the distorted waveform are then isolated with band-pass filters. This allows the frequency to be doubled, tripled, or multiplied by even higher integers numbers. The most common technique is to use sequential stages of doublers and triplers to generate the required frequency multiplication, rather than just a single stage. The Fourier series is important to this type of design because it describes the amplitude of the multiplied signal, depending on the type of distortion and harmonic selected.

 

1.5

 

 

 

 

(volts)

1.0

 

 

 

 

 

 

 

 

 

Amplitude

0.5

 

 

 

 

0.0

 

 

 

 

 

 

 

 

 

 

-0.5

 

 

 

 

 

0

1

2

3

4

Time (milliseconds)

FIGURE 13-12

Example of Fourier series synthesis. The waveform being constructed is a pulse train at 1 kHz, an amplitude of one volt, and a duty cycle of 0.2 (as illustrated in Fig. 13-11). This table shows the amplitude of the harmonics, while the graph shows the reconstructed waveform using only the first fourteen harmonics.

frequency

 

amplitude

 

 

(volts)

 

 

 

DC

 

0.20000

1 kHz

 

0.37420

2 kHz

 

0.30273

3 kHz

 

0.20182

4 kHz

 

0.09355

5 kHz

 

0.00000

6 kHz

 

-0.06237

7 kHz

 

-0.08649

8 kHz

 

-0.07568

9 kHz

 

-0.04158

10 kHz

 

0.00000

11 kHz

 

0.03402

12 kHz

 

0.05046

!

 

 

123 kHz

 

0.00492

124 kHz

 

0.00302

125 kHz

 

0.00000

126 kHz

 

-0.00297

!

 

 

803 kHz

 

0.00075

804 kHz

 

0.00046

805 kHz

 

0.00000

806 kHz

 

-0.00046

 

CHAPTER

Introduction to Digital Filters

14

Digital filters are used for two general purposes: (1) separation of signals that have been combined, and (2) restoration of signals that have been distorted in some way. Analog (electronic) filters can be used for these same tasks; however, digital filters can achieve far superior results. The most popular digital filters are described and compared in the next seven chapters. This introductory chapter describes the parameters you want to look for when learning about each of these filters.

Filter Basics

Digital filters are a very important part of DSP. In fact, their extraordinary performance is one of the key reasons that DSP has become so popular. As mentioned in the introduction, filters have two uses: signal separation and signal restoration. Signal separation is needed when a signal has been contaminated with interference, noise, or other signals. For example, imagine a device for measuring the electrical activity of a baby's heart (EKG) while still in the womb. The raw signal will likely be corrupted by the breathing and heartbeat of the mother. A filter might be used to separate these signals so that they can be individually analyzed.

Signal restoration is used when a signal has been distorted in some way. For example, an audio recording made with poor equipment may be filtered to better represent the sound as it actually occurred. Another example is the deblurring of an image acquired with an improperly focused lens, or a shaky camera.

These problems can be attacked with either analog or digital filters. Which is better? Analog filters are cheap, fast, and have a large dynamic range in both amplitude and frequency. Digital filters, in comparison, are vastly superior in the level of performance that can be achieved. For example, a low-pass digital filter presented in Chapter 16 has a gain of 1 +/- 0.0002 from DC to 1000 hertz, and a gain of less than 0.0002 for frequencies above

261

262

The Scientist and Engineer's Guide to Digital Signal Processing

1001 hertz. The entire transition occurs within only 1 hertz. Don't expect this from an op amp circuit! Digital filters can achieve thousands of times better performance than analog filters. This makes a dramatic difference in how filtering problems are approached. With analog filters, the emphasis is on handling limitations of the electronics, such as the accuracy and stability of the resistors and capacitors. In comparison, digital filters are so good that the performance of the filter is frequently ignored. The emphasis shifts to the limitations of the signals, and the theoretical issues regarding their processing.

It is common in DSP to say that a filter's input and output signals are in the time domain. This is because signals are usually created by sampling at regular intervals of time. But this is not the only way sampling can take place. The second most common way of sampling is at equal intervals in space. For example, imagine taking simultaneous readings from an array of strain sensors mounted at one centimeter increments along the length of an aircraft wing. Many other domains are possible; however, time and space are by far the most common. When you see the term time domain in DSP, remember that it may actually refer to samples taken over time, or it may be a general reference to any domain that the samples are taken in.

As shown in Fig. 14-1, every linear filter has an impulse response, a step response and a frequency response. Each of these responses contains complete information about the filter, but in a different form. If one of the three is specified, the other two are fixed and can be directly calculated. All three of these representations are important, because they describe how the filter will react under different circumstances.

The most straightforward way to implement a digital filter is by convolving the input signal with the digital filter's impulse response. All possible linear filters can be made in this manner. (This should be obvious. If it isn't, you probably don't have the background to understand this section on filter design. Try reviewing the previous section on DSP fundamentals). When the impulse response is used in this way, filter designers give it a special name: the filter kernel.

There is also another way to make digital filters, called recursion. When a filter is implemented by convolution, each sample in the output is calculated by weighting the samples in the input, and adding them together. Recursive filters are an extension of this, using previously calculated values from the output, besides points from the input. Instead of using a filter kernel, recursive filters are defined by a set of recursion coefficients. This method will be discussed in detail in Chapter 19. For now, the important point is that all linear filters have an impulse response, even if you don't use it to implement the filter. To find the impulse response of a recursive filter, simply feed in an impulse, and see what comes out. The impulse responses of recursive filters are composed of sinusoids that exponentially decay in amplitude. In principle, this makes their impulse responses infinitely long. However, the amplitude eventually drops below the round-off noise of the system, and the remaining samples can be ignored. Because

Chapter 14Introduction to Digital Filters

263

 

0.3

 

 

 

 

 

 

1.5

 

 

 

 

 

 

 

a. Impulse response

 

 

 

 

 

c. Frequency response

 

 

Amplitude

0.2

 

 

 

 

 

Amplitude

1.0

 

 

 

 

 

0.1

 

 

 

 

FFT

0.5

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0.0

 

 

 

 

 

 

0.0

 

 

 

 

 

 

-0.1

 

 

 

 

 

 

-0.5

 

 

 

 

 

 

0

32

64

96

1287

 

 

0

0.1

0.2

0.3

0.4

0.5

 

 

 

Sample number

 

 

 

 

 

 

Frequency

 

 

 

 

 

Integrate

 

 

 

 

 

 

20 Log(

)

 

 

1.5

 

 

 

 

 

 

40

 

 

 

 

 

 

 

b. Step response

 

 

 

 

 

d. Frequency response (in dB)

 

 

1.0

 

 

 

 

 

 

20

 

 

 

 

 

Amplitude

 

 

 

 

 

Amplitude(dB)

 

 

 

 

 

 

 

 

 

 

 

 

0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0.5

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

-20

 

 

 

 

 

 

0.0

 

 

 

 

 

 

-40

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

-0.5

 

 

 

 

 

 

-60

 

 

 

 

 

 

0

32

64

96

1287

 

 

0

0.1

0.2

0.3

0.4

0.5

 

 

 

Sample number

 

 

 

 

 

 

Frequency

 

 

FIGURE 14-1

Filter parameters. Every linear filter has an impulse response, a step response, and a frequency response. The step response, (b), can be found by discrete integration of the impulse response, (a). The frequency response can be found from the impulse response by using the Fast Fourier Transform (FFT), and can be displayed either on a linear scale, (c), or in decibels, (d).

of this characteristic, recursive filters are also called Infinite Impulse Response or IIR filters. In comparison, filters carried out by convolution are called Finite Impulse Response or FIR filters.

As you know, the impulse response is the output of a system when the input is an impulse. In this same manner, the step response is the output when the input is a step (also called an edge, and an edge response). Since the step is the integral of the impulse, the step response is the integral of the impulse response. This provides two ways to find the step response: (1) feed a step waveform into the filter and see what comes out, or (2) integrate the impulse response. (To be mathematically correct: integration is used with continuous signals, while discrete integration, i.e., a running sum, is used with discrete signals). The frequency response can be found by taking the DFT (using the FFT algorithm) of the impulse response. This will be reviewed later in this

264

The Scientist and Engineer's Guide to Digital Signal Processing

chapter. The frequency response can be plotted on a linear vertical axis, such as in (c), or on a logarithmic scale (decibels), as shown in (d). The linear scale is best at showing the passband ripple and roll-off, while the decibel scale is needed to show the stopband attenuation.

Don't remember decibels? Here is a quick review. A bel (in honor of Alexander Graham Bell) means that the power is changed by a factor of ten. For example, an electronic circuit that has 3 bels of amplification produces an output signal with 10 × 10 × 10 ' 1000 times the power of the input. A decibel (dB) is one-tenth of a bel. Therefore, the decibel values of: -20dB, -10dB, 0dB, 10dB & 20dB, mean the power ratios: 0.01, 0.1, 1, 10, & 100, respectively. In other words, every ten decibels mean that the power has changed by a factor of ten.

Here's the catch: you usually want to work with a signal's amplitude, not its power. For example, imagine an amplifier with 20dB of gain. By definition, this means that the power in the signal has increased by a factor of 100. Since amplitude is proportional to the square-root of power, the amplitude of the output is 10 times the amplitude of the input. While 20dB means a factor of 100 in power, it only means a factor of 10 in amplitude. Every twenty decibels mean that the amplitude has changed by a factor of ten. In equation form:

EQUATION 14-1

Definition of decibels. Decibels are a way of expressing a ratio between two signals. Ratios of power (P1 & P2) use a different equation from ratios of amplitude (A1 & A2).

dB ' 10 log10

P2

P

 

 

1

dB ' 20 log10

A2

 

 

A

1

 

 

The above equations use the base 10 logarithm; however, many computer languages only provide a function for the base e logarithm (the natural log, written loge x or ln x ). The natural log can be use by modifying the above equations: dB ' 4.342945 loge (P2 / P1) and dB ' 8.685890 loge (A2 / A1).

Since decibels are a way of expressing the ratio between two signals, they are ideal for describing the gain of a system, i.e., the ratio between the output and the input signal. However, engineers also use decibels to specify the amplitude (or power) of a single signal, by referencing it to some standard. For example, the term: dBV means that the signal is being referenced to a 1 volt rms signal. Likewise, dBm indicates a reference signal producing 1 mW into a 600 ohms load (about 0.78 volts rms).

If you understand nothing else about decibels, remember two things: First, -3dB means that the amplitude is reduced to 0.707 (and the power is

Chapter 14Introduction to Digital Filters

265

therefore reduced to 0.5). Second, memorize the following conversions between decibels and amplitude ratios:

60dB = 1000 40dB = 100 20dB = 10

0dB = 1 -20dB = 0.1 -40dB = 0.01 -60dB = 0.001

How Information is Represented in Signals

The most important part of any DSP task is understanding how information is contained in the signals you are working with. There are many ways that information can be contained in a signal. This is especially true if the signal is manmade. For instance, consider all of the modulation schemes that have been devised: AM, FM, single-sideband, pulse-code modulation, pulse-width modulation, etc. The list goes on and on. Fortunately, there are only two ways that are common for information to be represented in naturally occurring signals. We will call these: information represented in the time domain, and information represented in the frequency domain.

Information represented in the time domain describes when something occurs and what the amplitude of the occurrence is. For example, imagine an experiment to study the light output from the sun. The light output is measured and recorded once each second. Each sample in the signal indicates what is happening at that instant, and the level of the event. If a solar flare occurs, the signal directly provides information on the time it occurred, the duration, the development over time, etc. Each sample contains information that is interpretable without reference to any other sample. Even if you have only one sample from this signal, you still know something about what you are measuring. This is the simplest way for information to be contained in a signal.

In contrast, information represented in the frequency domain is more indirect. Many things in our universe show periodic motion. For example, a wine glass struck with a fingernail will vibrate, producing a ringing sound; the pendulum of a grandfather clock swings back and forth; stars and planets rotate on their axis and revolve around each other, and so forth. By measuring the frequency, phase, and amplitude of this periodic motion, information can often be obtained about the system producing the motion. Suppose we sample the sound produced by the ringing wine glass. The fundamental frequency and harmonics of the periodic vibration relate to the mass and elasticity of the material. A single sample, in itself, contains no information about the periodic motion, and therefore no information about the wine glass. The information is contained in the relationship between many points in the signal.

266

The Scientist and Engineer's Guide to Digital Signal Processing

This brings us to the importance of the step and frequency responses. The step response describes how information represented in the time domain is being modified by the system. In contrast, the frequency response shows how information represented in the frequency domain is being changed. This distinction is absolutely critical in filter design because it is not possible to optimize a filter for both applications. Good performance in the time domain results in poor performance in the frequency domain, and vice versa. If you are designing a filter to remove noise from an EKG signal (information represented in the time domain), the step response is the important parameter, and the frequency response is of little concern. If your task is to design a digital filter for a hearing aid (with the information in the frequency domain), the frequency response is all important, while the step response doesn't matter. Now let's look at what makes a filter optimal for time domain or frequency domain applications.

Time Domain Parameters

It may not be obvious why the step response is of such concern in time domain filters. You may be wondering why the impulse response isn't the important parameter. The answer lies in the way that the human mind understands and processes information. Remember that the step, impulse and frequency responses all contain identical information, just in different arrangements. The step response is useful in time domain analysis because it matches the way humans view the information contained in the signals.

For example, suppose you are given a signal of some unknown origin and asked to analyze it. The first thing you will do is divide the signal into regions of similar characteristics. You can't stop from doing this; your mind will do it automatically. Some of the regions may be smooth; others may have large amplitude peaks; others may be noisy. This segmentation is accomplished by identifying the points that separate the regions. This is where the step function comes in. The step function is the purest way of representing a division between two dissimilar regions. It can mark when an event starts, or when an event ends. It tells you that whatever is on the left is somehow different from whatever is on the right. This is how the human mind views time domain information: a group of step functions dividing the information into regions of similar characteristics. The step response, in turn, is important because it describes how the dividing lines are being modified by the filter.

The step response parameters that are important in filter design are shown in Fig. 14-2. To distinguish events in a signal, the duration of the step response must be shorter than the spacing of the events. This dictates that the step response should be as fast (the DSP jargon) as possible. This is shown in Figs. (a) & (b). The most common way to specify the risetime (more jargon) is to quote the number of samples between the 10% and 90% amplitude levels. Why isn't a very fast risetime always possible? There are many reasons, noise reduction, inherent limitations of the data acquisition system, avoiding aliasing, etc.

Соседние файлы в предмете Электроника