fir filter design: part ii in this set of notes, we consider how we … · 2005. 3. 4. · eel3135:...

8
EEL3135: Discrete-Time Signals and Systems FIR Filter Design: Part II - 1 - FIR Filter Design: Part II 1. Introduction In this set of notes, we consider how we might go about designing FIR filters with arbitrary frequency responses, through composition of multiple single-peak general filters. 2. General FIR filter A. Introduction Consider the frequency response plotted in Figure 1 below. This filter passes through all normalized frequencies without modification, but amplifies ( ) or attenuates ( ) frequencies in the range ; also, there is a finite-width transition region of width from to . As we will show below, assuming that we know the impulse response of this filter in terms of , , and , we can easily construct filters that have more complex frequency responses. B. Derivation of infinite impulse response Below, we will use the inverse DTFT to determine the time-domain impulse response of the above fil- ter, assuming no delay. For this filter, the inverse DTFT is given by, (1) (2) H g e j θ ( ) θ a 1 > a 1 < θ θ c 1 θ c 2 , [ ] Δ H g e j θ ( ) 1 = H g e j θ ( ) a = h g n [] a θ c 1 θ c 2 Δ H g e j θ ( ) θ c 1 θ π π Figure 1 1 Δ a θ c 2 θ c 2 θ c 1 Δ Δ Δ hn [] h g n [] 1 2 π ------ H g e j θ ( ) e j n θ θ d π π = h g n [] 1 2 π ------ e j n θ θ d π θ c 2 Δ + ( ) 1 2 π ------ a 1 Δ ----------- θ θ c 2 + ( ) a + e j n θ θ d θ c 2 Δ + ( ) θ c 2 + + = 1 2 π ------ ae j n θ θ d θ c 2 θ c 1 1 2 π ------ 1 a Δ ----------- θ θ c 1 + ( ) a + e j n θ θ d θ c 1 θ c 1 Δ ( ) + + 1 2 π ------ e j n θ θ d θ c 1 Δ ( ) θ c 1 Δ ( ) + 1 2 π ------ a 1 Δ ----------- θ θ c 1 ( ) a + e j n θ θ d θ c 1 Δ ( ) θ c 1 1 2 π ------ ae j n θ θ d θ c 1 θ c 2 + + 1 2 π ------ 1 a Δ ----------- θ θ c 2 ( ) a + e j n θ θ d θ c 2 θ c 2 Δ + ( ) 1 2 π ------ e j n θ θ d θ c 2 Δ + ( ) π +

Upload: others

Post on 13-Sep-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: FIR Filter Design: Part II In this set of notes, we consider how we … · 2005. 3. 4. · EEL3135: Discrete-Time Signals and Systems FIR Filter Design: Part II - 1 - FIR Filter Design:

EEL3135: Discrete-Time Signals and Systems FIR Filter Design: Part II

FIR Filter Design: Part II

1. IntroductionIn this set of notes, we consider how we might go about designing FIR filters with arbitrary frequency responses,through composition of multiple single-peak general filters.

2. General FIR filter

A. Introduction

Consider the frequency response plotted in Figure 1 below. This filter passes through all normalizedfrequencies without modification, but amplifies ( ) or attenuates ( ) frequencies in the range

; also, there is a finite-width transition region of width from to .As we will show below, assuming that we know the impulse response of this filter in terms of , ,

and , we can easily construct filters that have more complex frequency responses.

B. Derivation of infinite impulse response

Below, we will use the inverse DTFT to determine the time-domain impulse response of the above fil-ter, assuming no delay. For this filter, the inverse DTFT is given by,

(1)

(2)

Hg ejθ( )θ a 1> a 1<

θ θc1θc2

,[ ]∈ ∆ Hg ejθ( ) 1= Hg ejθ( ) a=hg n[ ] a θc1θc2

Hg ejθ( )

θc1–

θ

π– πFigure 1

1

a

θc2– θc2

θc1

∆ ∆ ∆

h n[ ]

hg n[ ] 12π------ Hg ejθ( )ejnθ θd

π–

π∫=

hg n[ ] 12π------ ejnθ θd

π–

θc2∆+( )–

∫1

2π------ a 1–

∆------------ θ θc2

+( ) a+ ejnθ θdθc2∆+( )–

θ– c2∫ + +=

12π------ aejnθ θdθ– c2

θc1–

∫1

2π------ 1 a–

∆------------ θ θc1

+( ) a+ ejnθ θdθc1–

θc1∆–( )–

∫ + +

12π------ ejnθ θdθc1

∆–( )–

θc1∆–( )

∫ +

12π------ a 1–

∆------------ θ θc1

–( ) a+ ejnθ θdθc1∆–( )

θc1∫1

2π------ aejnθ θdθc1

θc2∫ + +

12π------ 1 a–

∆------------ θ θc2

–( ) a+ ejnθ θdθc2

θc2∆+( )

∫1

2π------ ejnθ θdθc2

∆+( )π

∫+

- 1 -

Page 2: FIR Filter Design: Part II In this set of notes, we consider how we … · 2005. 3. 4. · EEL3135: Discrete-Time Signals and Systems FIR Filter Design: Part II - 1 - FIR Filter Design:

EEL3135: Discrete-Time Signals and Systems FIR Filter Design: Part II

The integral in equation (2) is tedious to compute and simplify; therefore, we solve the integration usingMathematica (see “fir_filter_design_part2.nb”) and arrive at the following expression for :

,

. (3)

Note that equation (3) can be further simplified, since,

(4)

for integer . Therefore,

, . (5)

Note that, although is infinite in length, both forwards and backwards in time, the impulse responsedoes decay to zero as . Figure 2 below, for example, plots , , for ,

, and .

C. Approximating of infinite impulse response with a causal FIR filter

Now, we will try to approximate the infinite impulse response in equation (5) with a causal FIR filter usingthe same procedure as we have used before: First, we will retain values for only for a limited range of

,

(6)

since values of approach zero as . Let us denote this finite impulse response as , suchthat,

(7)

Second, we will shift to be causal; let us denote the resulting impulse response as such that,

. (8)

h n[ ]

hg n[ ] 1 a–( )n θc1

∆–( )( )cos n θc2∆+( )( )cos nθc1

( )cos– nθc2( )cos–+

n2π∆-------------------------------------------------------------------------------------------------------------------------------------------------- nπ( )sin

nπ-------------------+=

∞– n ∞< <

nπ( )sinnπ

------------------- δ n[ ]=

n

hg n[ ] 1 a–( )n θc1

∆–( )( )cos n θc2∆+( )( )cos nθc1

( )cos– nθc2( )cos–+

n2π∆-------------------------------------------------------------------------------------------------------------------------------------------------- δ n[ ]+= ∞– n ∞< <

hg n[ ]n ∞→ hg n[ ] 50– n 50≤ ≤ θc1

1=θc2

3 2⁄= ∆ 1 10⁄= a 2=

-40 -20 0 20 40-0.2

-0.1

0

0.1

0.2

Figure 2

hg n[ ]

n

1 1120π---------+

-3 -2 -1 0 1 2 30

0.5

1

1.5

2

Hg ejθ( )

hg n[ ]n

nmax– n nmax≤ ≤

hg n[ ] n ∞→ hg1 n[ ]

hg1 n[ ]hg n[ ]

0

=nmax– n nmax≤ ≤

elsewhere

hg1 n[ ] hg n[ ]

hg n[ ] hg1 n nmax–[ ]=

- 2 -

Page 3: FIR Filter Design: Part II In this set of notes, we consider how we … · 2005. 3. 4. · EEL3135: Discrete-Time Signals and Systems FIR Filter Design: Part II - 1 - FIR Filter Design:

EEL3135: Discrete-Time Signals and Systems FIR Filter Design: Part II

Note that this shift will not change the steady-state frequency response of the resulting system, except tointroduce a delay at the output. Thus, the difference equation corresponding to can be written as:

(9)

where,

, . (10)

3. Composite filter example

A. Introduction

Given that we have computed the impulse response for the filter in Figure 1, we are now in position toconstruct filters with more complex frequency responses. Suppose, for example, we wanted to construct a fil-ter with the idealized frequency response plotted in Figure 3 below for . (Since isan even function, we do not need to explicitly plot it for .)

We could, of course, derive the impulse response of this filter by breaking up the inverse DTFT intopiecewise-continuous integrals (as we did, for example, in equation (2) above) and solving the resultingexpression. Given that we have already compute [equation (5)], this difficult and tedious procedure isnot necessary, however. Instead, we can treat as a composite filter consisting of two different

filters connected in series.

Let,

(11)

and

(12)

where denotes the filter in Figure 1. Then, we can represent in Figure 3 as,

(13)

or, in the time domain as,

hg n[ ]

y n[ ] bkx n k–[ ]k 0=

2nmax

∑=

bk hg n[ ] hg nmax– k+[ ]= = k 0 1 … 2nmax, , ,{ }∈

hg n[ ]

Hc ejθ( ) θ 0 π,[ ]∈ H ejθ( )θ π– 0, )[=

hc n[ ]

hg n[ ]Hc ejθ( )

Hg ejθ( )

πθ2θ1

∆1 ∆1

Hc ejθ( )

θ

Figure 3

1

a2

a1

0 θ4θ3

∆2 ∆2

H1 ejθ( ) Hg ejθ( )a a1→ θc1 θ1→ θc2 θ2→ ∆ ∆1→, , ,

=

H2 ejθ( ) Hg ejθ( )a a2→ θc1 θ3→ θc2 θ4→ ∆ ∆2→, , ,

=

Hg ejθ( ) Hc ejθ( )

Hc ejθ( ) H1 ejθ( )H2 ejθ( )=

- 3 -

Page 4: FIR Filter Design: Part II In this set of notes, we consider how we … · 2005. 3. 4. · EEL3135: Discrete-Time Signals and Systems FIR Filter Design: Part II - 1 - FIR Filter Design:

EEL3135: Discrete-Time Signals and Systems FIR Filter Design: Part II

(14)

where and denote the causal FIR approximations of the infinite impulse response of filters and , respectively. Below, we give one example of such a composite filter.

B. Example

Let us assume that we want to filter a piece of music, sampled at kHz, with the composite filtershown in Figure 3 and the following numeric values:

. Hz, Hz, (15)

, kHz, kHz, (16)

and Hz for both segments. Note that the value of corresponds to +12dB (decibels), while thevalue of corresponds to -12dB.1 First, we need to convert the frequency values above to normalized fre-quency values using the conversion formula:

(17)

Applying equation (17), we get the following values in terms of normalized frequency for kHz:

, , , and . (18)

The composite filter transfer function for the numeric values in (18) is plotted in Figure 4 below, interms of normal amplitude, and decibel amplitude.

The FIR impulse-function approximations and , corresponding to the filters defined by (11) and(12), respectively, are plotted in Figure 5 below for . Note that was chosen such that the

coefficients near and are very close to zero in value. Now, we compute , thecomposite-filter FIR impulse-function approximation, by convolving and [see equation (14)above]; is plotted in Figure 6.

Observe from Figure 6, that is approximately twice as long as and (2001 vs. 1001) asshould be expected from the convolution operator. Also note that many of the coefficients are veryclose to zero in value; hence, we can derive a shorter FIR filter by retaining only values in the range

, and shifting the resulting impulse response to start at . From Figure 6,we suggest that a value of seems appropriate since values for and appear negligibly small. Let us denote the shortened FIR filter as :

, , . (19)

1. For an amplitude , the corresponding dB value is given by .

hc n[ ] h1 n[ ] * h2 n[ ]≈

h1 n[ ] h2 n[ ]H1 ejθ( ) H2 ejθ( )

fs 32=

a1 10 12 20⁄( ) 3.981≈= f1 375= f2 1500=

a2 10 12 20⁄–( ) 0.2512≈= f3 6= f4 15=

∆f 100= a1a2

A 20log10A

θ 2πffs

--------=

fs 32=

θ1 3π 128⁄= θ2 3π 32⁄= θ3 3π 8⁄= θ4 15π 16⁄= ∆1 ∆2 2π∆f fs⁄ π 160⁄= = =

Hc ejθ( )

-3 -2 -1 0 1 2 30

1

2

3

4

-3 -2 -1 0 1 2 3

-10

-5

0

5

10Hc ejθ( ) 20log10Hc ejθ( )

θ θFigure 4

h1 n[ ] h2 n[ ]nmax 500= nmax

h n[ ] n 0= n 2nmax= hc n[ ]h1 n[ ] h2 n[ ]

hc n[ ]

hc n[ ] h1 n[ ]' h2 n[ ]hc n[ ]

hc n[ ]n 1001 n2– 1001 n2+,[ ]∈ n 0=

n2 300= hc n[ ] n 700< n 1300>hc n[ ]

hc n[ ] hc n 1001 n2–+[ ]= n 0 1 … 2n2, , ,{ }∈ n2 300=

- 4 -

Page 5: FIR Filter Design: Part II In this set of notes, we consider how we … · 2005. 3. 4. · EEL3135: Discrete-Time Signals and Systems FIR Filter Design: Part II - 1 - FIR Filter Design:

EEL3135: Discrete-Time Signals and Systems FIR Filter Design: Part II

This impulse response ( ) is plotted in Figure 7 below. Therefore, the difference equation correspondingto this impulse function is given by,

(20)

where,

, , . (21)

In Figure 8, we plot the magnitude frequency response of system (20) given by,

0 200 400 600 800 1000-0.2

-0.1

0

0.1

0.2

0.3

0 200 400 600 800 1000-0.2

-0.1

0

0.1

0.2

0.3

Figure 5

h1 n[ ]

n

n

h2 n[ ]

0 500 1000 1500 2000

-0.04

-0.02

0

0.02

0.04

Figure 6

hc n[ ]

n

hc n[ ]

y n[ ] bkx n k–[ ]k 0=

2n2

∑=

bk hc k[ ]= k 0 1 … 2n2, , ,{ }∈ n2 300=

Hc ejθ( )

- 5 -

Page 6: FIR Filter Design: Part II In this set of notes, we consider how we … · 2005. 3. 4. · EEL3135: Discrete-Time Signals and Systems FIR Filter Design: Part II - 1 - FIR Filter Design:

EEL3135: Discrete-Time Signals and Systems FIR Filter Design: Part II

(22)

both as a function of normalized frequency and real frequency . Note how closely we are able to approx-imate our desired frequency response (see Figure 4) with this FIR filter of length 601; also note that we neverhad to compute using the inverse DTFT, but rather computed it through time-domain convolution of

and .

To see this filter in action, we convolve with a sampled music file 1, and compare the frequencycontent of the original music file and the filtered music file where,

. (23)

In Figure 9 below, we plot the spectrograms2 of and , where we analyze frequency content inone-second long segments with a 50% overlap. We also plot one column of both spectrograms (the magnitudeFFT for one of the one-second segments of and ) in Figure 10 below. Note, how the frequencycontent in the range has been amplified, while the frequency content in the range

has been significantly attenuated, as we should expect from the frequency response of.

1. See the web page for this music file — a 23.06 second segment of Kenny Roger’s “The Gambler,” sampled at kHz.

2. Recall from previous notes that the spectrogram gives us the magnitude frequency content of a signal for short segments of a long discrete-time sequence.

0 100 200 300 400 500 600

-0.04

-0.02

0

0.02

0.04

Figure 7

hc n[ ]

n

Hc ejθ( ) hc n[ ]e jnθ–

n 0=

600

∑=

θ f

hc n[ ]h1 n[ ] h2 n[ ]

-3 -2 -1 0 1 2 30

1

2

3

4

-15 -10 -5 0 5 10 150

1

2

3

4

Figure 8f kHz( )

Hc ejθ( ) θ 2πf fs⁄→Hc ejθ( )

θ

hc n[ ] xm n[ ]

fs 32=

xm n[ ] ym n[ ]

ym n[ ] xm n[ ] * hc n[ ]=

xm n[ ] ym n[ ]

xm n[ ] ym n[ ]f 375Hz 1500Hz,[ ]∈

f 6kHz 15kHz,[ ]∈hc n[ ]

- 6 -

Page 7: FIR Filter Design: Part II In this set of notes, we consider how we … · 2005. 3. 4. · EEL3135: Discrete-Time Signals and Systems FIR Filter Design: Part II - 1 - FIR Filter Design:

EEL3135: Discrete-Time Signals and Systems FIR Filter Design: Part II

0 5 10 15 20

0

2500

5000

7500

10000

12500

15000

0 5 10 15 20

0

2500

5000

7500

10000

12500

15000

Figure 9

t sec( )

fH

z(

)

Spectrogram ym n[ ]( )

t sec( )

fH

z(

)

Spectrogram xm n[ ]( )

- 7 -

Page 8: FIR Filter Design: Part II In this set of notes, we consider how we … · 2005. 3. 4. · EEL3135: Discrete-Time Signals and Systems FIR Filter Design: Part II - 1 - FIR Filter Design:

EEL3135: Discrete-Time Signals and Systems FIR Filter Design: Part II

4. ConclusionThe Mathematica notebook “fir_filter_design_part2.nb” was used to generate the detailed filtering example inthis set of notes; that notebook also contains a second composite filter example for the same piece of music,where all the design values (i.e. , , , , and ) are the same, except the values for and arereversed; that is,

and . (24)

The filtered and unfiltered music segments referred to in these notes is available in mp3 and wav formats on thecourse web site.

0 5 10 150

2·106

4·106

6·106

8·106

1·107

0 5 10 150

2·106

4·106

6·106

8·106

1·107

Figure 10

f kHz( )

FFT ym n[ ]( )

FFT xm n[ ]( )

f kHz( )

θ1 θ2 ∆1 θ3 θ4 ∆2 a1 a2

a1 10 12 20⁄–( )= a2 10 12 20⁄( )=

- 8 -