16
EEL3135: Discrete-Time Signals and Systems FIR Filter Design: Part I - 1 - FIR Filter Design: Part I 1. Introduction In this set of notes, we continue our exploration of the frequency response of FIR filters. First, we consider some “intuitive” examples of low-pass and high-pass FIR filters; we had previously considered these examples in our course introduction (see 1/16 lecture notes). Second, we consider the design of FIR filters with more desirable frequency response characteristics. We consider two approaches. In the first approach, we derive low-pass FIR filters from the impulse response of and ideal low-pass filter; that is, a filter with sharp cut-off frequencies between the passband (frequency range for which frequencies are allowed through the system), and the rejection- band (frequency range for which frequencies are zeroed). As we will see, this approach leads to FIR filters with overshoot characteristics near the cutoff frequency. To mitigate this problem, we then consider a second approach, where we allow a finite-length transition between the passband and rejection-band, and observe that the resulting FIR filters more closely approximate an idealized frequency response. 2. Simple low-pass FIR filters 1 A. Introduction Previously (1/16 lecture notes), we had considered low-pass FIR filters of the following form: (1) for which the output is an average of the current input and the previous inputs , . This type of FIR filter is known as a running-average filter , and tends to attenuate high frequencies in an input signal, while leaving lower frequencies relatively untouched (hence, the label “low- pass filter”). For these filters, the frequency response function is given by, . (2) B. Examples Here we consider the frequency response of filters of type (1), for , and . Figure 1 below plots the magnitude and phase part of the frequency response for each of these filters as a function of the frequency variable . Note that the larger the value of , the more narrow the central peak about ; that is, longer running averages will tend to suppress frequency components in the input signal of lower and lower frequency. The zero-frequency component ( ), however, remains unaffected no mat- ter how large the value of , since averaging a constant input sequence will not change that constant value. To verify the frequency response characteristics of these filters, we now conduct the following experiment. We sample a continuous-time, noisy 4Hz cosine wave at Hz and then pass the resulting discrete- time sequence through the three filters above. That is, (3) , , (4) where, for each sample, the noise component of the signal consists of a uniformly distributed random number in the interval . In Figures 2, 3 and 4, for each of the three filters, we plot a -length (1second) part of the input sequence and a 500-length part of the output sequence . Moreover, we plot the magnitude FFT of each 500-length discrete-time sequence as a function of frequency . Note that for 1. You may want to review the 1/16 lecture notes to complement the materials in this section. yn [] 1 L -- xn k [ ] k 0 = L 1 = yn [] xn [] L 1 ( ) xn k [ ] k 12 L 1 , , , { } He j θ ( ) He j θ ( ) 1 L -- e j n θ n 0 = L 1 = L 10 = L 30 = L 100 = θ π π , [ ] L θ 0 = θ 0 = L f s 500 = xn [] xt () 8 π t ( ) cos = xn [] xn f s ( ) noise + = n < < 1 2 1 2 , [ ] 500 xn [] yn [] f

FIR Filter Design: Part I - University of Florida · PDF file- 1 - FIR Filter Design: Part I 1. Introduction ... The zero-frequency component ( ), ... part of the input sequence and

Embed Size (px)

Citation preview

Page 1: FIR Filter Design: Part I - University of Florida · PDF file- 1 - FIR Filter Design: Part I 1. Introduction ... The zero-frequency component ( ), ... part of the input sequence and

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

FIR Filter Design: Part I

1. Introduction

In this set of notes, we continue our exploration of the frequency response of FIR filters. First, we consider some“intuitive” examples of low-pass and high-pass FIR filters; we had previously considered these examples in ourcourse introduction (see 1/16 lecture notes). Second, we consider the design of FIR filters with more desirablefrequency response characteristics. We consider two approaches. In the first approach, we derive low-pass FIRfilters from the impulse response of and ideal low-pass filter; that is, a filter with sharp cut-off frequenciesbetween the passband (frequency range for which frequencies are allowed through the system), and the rejection-band (frequency range for which frequencies are zeroed). As we will see, this approach leads to FIR filters withovershoot characteristics near the cutoff frequency. To mitigate this problem, we then consider a secondapproach, where we allow a finite-length transition between the passband and rejection-band, and observe thatthe resulting FIR filters more closely approximate an idealized frequency response.

2. Simple low-pass FIR filters1

A. Introduction

Previously (1/16 lecture notes), we had considered low-pass FIR filters of the following form:

(1)

for which the output is an average of the current input and the previous inputs ,. This type of FIR filter is known as a running-average filter, and tends to attenuate high

frequencies in an input signal, while leaving lower frequencies relatively untouched (hence, the label “low-pass filter”).

For these filters, the frequency response function is given by,

. (2)

B. Examples

Here we consider the frequency response of filters of type (1), for , and . Figure 1below plots the magnitude and phase part of the frequency response for each of these filters as a function ofthe frequency variable . Note that the larger the value of , the more narrow the central peakabout ; that is, longer running averages will tend to suppress frequency components in the input signalof lower and lower frequency. The zero-frequency component ( ), however, remains unaffected no mat-ter how large the value of , since averaging a constant input sequence will not change that constant value.

To verify the frequency response characteristics of these filters, we now conduct the following experiment.We sample a continuous-time, noisy 4Hz cosine wave at Hz and then pass the resulting discrete-time sequence through the three filters above. That is,

(3)

, , (4)

where, for each sample, the noise component of the signal consists of a uniformly distributed random numberin the interval . In Figures 2, 3 and 4, for each of the three filters, we plot a -length(1second) part of the input sequence and a 500-length part of the output sequence . Moreover, weplot the magnitude FFT of each 500-length discrete-time sequence as a function of frequency . Note that for

1. You may want to review the 1/16 lecture notes to complement the materials in this section.

y n[ ] 1

L---x n k–[ ]

k 0=

L 1–

∑=

y n[ ] x n[ ] L 1–( ) x n k–[ ]k 1 2 … L 1–, , ,{ }∈

H ejθ( )

H ejθ( ) 1

L---e jnθ–

n 0=

L 1–

∑=

L 10= L 30= L 100=

θ π– π,[ ]∈ Lθ 0=

θ 0=L

fs 500=x n[ ]

x t( ) 8πt( )cos=

x n[ ] x n fs⁄( ) noise+= ∞– n ∞< <

1 2⁄– 1 2⁄,[ ] 500

x n[ ] y n[ ]f

- 1 -

Page 2: FIR Filter Design: Part I - University of Florida · PDF file- 1 - FIR Filter Design: Part I 1. Introduction ... The zero-frequency component ( ), ... part of the input sequence and

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

this sampling process, the relationship between the frequency variable in Figure 1 and the real frequency (in Hertz) is given by,

(5)

so that the frequency variable range,

(6)

corresponds to the frequency range,

. (7)

A few observations: first, note that the uniform noise added to the 4Hz cosine waveform at the input shows upas non-zero frequencies throughout the frequency range ; second, note that each filter tends tosmooth out the noisy cosine waveform by suppressing most of the noise-induced frequency components —the longer the filter, the more the noise-induced frequencies are suppressed, and, consequently, the smootherthe resulting output waveform .

In the following section, we reconsider some high-pass filters that we derived “intuitively” in an earlier lec-ture (1/16).

-3 -2 -1 0 1 2 30

0.2

0.4

0.6

0.8

1

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

-3 -2 -1 0 1 2 30

0.2

0.4

0.6

0.8

1

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

-3 -2 -1 0 1 2 30

0.2

0.4

0.6

0.8

1

-3 -2 -1 0 1 2 3

-2

-1

0

1

2

Figure 1

θ

H ejθ( ) H ejθ( )∠

θ

L 10=

θ

H ejθ( ) H ejθ( )∠

θ

L 30=

θ

H ejθ( ) H ejθ( )∠

θ

L 100=

θ f

θ 2πffs

--------=

θ π– π,[ ]∈

f fs– 2⁄ fs 2⁄,[ ]∈ 250Hz– 250Hz,[ ]=

fs– 2⁄ fs 2⁄,[ ]

y n[ ]

- 2 -

Page 3: FIR Filter Design: Part I - University of Florida · PDF file- 1 - FIR Filter Design: Part I 1. Introduction ... The zero-frequency component ( ), ... part of the input sequence and

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

3. Simple high-pass FIR filters1

A. Introduction

Previously (1/16 lecture notes), we had considered the following high-pass FIR filters:

1. You may want to review the 1/16 lecture notes to complement the materials in this section.

-200 -100 0 100 200

5

10

15

20

25

30

35

40

-200 -100 0 100 200

5

10

15

20

25

30

35

40

0 100 200 300 400 500-1.5

-1

-0.5

0

0.5

1

1.5

0 100 200 300 400 500

-1

-0.5

0

0.5

1

Figure 2

n

x n[ ]

n

L 10=

f

FFT x n[ ]( )

f

y n[ ]

FFT y n[ ]( )

-200 -100 0 100 200

5

10

15

20

25

30

35

40

-200 -100 0 100 200

5

10

15

20

25

30

35

40

0 100 200 300 400 500-1.5

-1

-0.5

0

0.5

1

1.5

0 100 200 300 400 500

-0.75

-0.5

-0.25

0

0.25

0.5

0.75

Figure 3

n

x n[ ]

n

L 30=

f

FFT x n[ ]( )

f

y n[ ]

FFT y n[ ]( )

- 3 -

Page 4: FIR Filter Design: Part I - University of Florida · PDF file- 1 - FIR Filter Design: Part I 1. Introduction ... The zero-frequency component ( ), ... part of the input sequence and

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

(second-order) (8)

(third-order) (9)

(fourth-order) (10)

which we derived by taking consecutive discrete-time derivatives of the first-order high-pass filter:

. (11)

These filters will tend to attenuate low frequencies (zeroing any DC or zero-frequency component), whilepassing through higher frequencies relatively untouched (hence, the label “high-pass filter”).

For these filters, the frequency response functions are straightforward to compute:

(12)

(13)

. (14)

Figure 5 below plots the magnitude and phase part of the frequency response for each of these filters as afunction of the frequency variable . Note that as the length of the filter is increased, more andmore low frequencies are virtually zeroed out entirely, while the highest frequencies remain untouched.

B. Experiments

To verify the frequency response characteristics of the high-pass filters in equations (12) through (14), wenow conduct the same experiment as for the low-pass filters in the previous section. We sample a continuous-time, noisy 4Hz cosine wave at Hz and then pass the resulting discrete-time sequence throughthe three high-pass filters above. That is,

-200 -100 0 100 200

5

10

15

20

25

30

35

40

-200 -100 0 100 200

5

10

15

20

25

30

35

40

0 100 200 300 400 500-1.5

-1

-0.5

0

0.5

1

1.5

0 100 200 300 400 500 600

-0.2

-0.1

0

0.1

0.2

0.3

Figure 4

n

x n[ ]

n

L 100=

f

FFT x n[ ]( )

f

y n[ ]

FFT y n[ ]( )

y1

n[ ] 1 4⁄ x n[ ] 1 2⁄ x n 1–[ ]– 1 4⁄ x n 2–[ ]+=

y2

n[ ] 1 8⁄ x n[ ] 3 8⁄ x n 1–[ ]– 3 8⁄ x n 2–[ ] 1 8⁄ x n 3–[ ]–+=

y3

n[ ] 1 16⁄ x n[ ] 1 4⁄ x n 1–[ ]– 3 8⁄ x n 2–[ ] 1 4⁄ x n 3–[ ]– 1 16⁄ x n 4–[ ]+ +=

y n[ ] 1 2⁄ x n[ ] 1 2⁄ x n 1–[ ]–=

H1

ejθ( ) 1

4---

1

2---e jθ––

1

4---e j2θ–+=

H2

ejθ( ) 1

8---

3

8---e jθ––

3

8---e j2θ– 1

8---e j3θ––+=

H3

ejθ( ) 1

16------

1

4---e jθ––

3

8---e j2θ– 1

4---e j3θ––

1

16------e j4θ–+ +=

θ π– π,[ ]∈

fs 500= x n[ ]

- 4 -

Page 5: FIR Filter Design: Part I - University of Florida · PDF file- 1 - FIR Filter Design: Part I 1. Introduction ... The zero-frequency component ( ), ... part of the input sequence and

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

(15)

, , (16)

where, for each sample, the noise component of the signal consists of a uniformly distributed random numberin the interval . In Figures 6, 7 and 8, for each of the three high-pass filters, we plot a -length (1second) part of the input sequence and a 500-length part of the output sequence . More-over, we plot the magnitude FFT of each 500-length discrete-time sequence as a function of frequency .Note that for this sampling process, the relationship between the frequency variable in Figure 5 and thereal frequency (in Hertz) is again given by,

(17)

so that the frequency variable range,

(18)

corresponds to the frequency range,

. (19)

-3 -2 -1 0 1 2 30

0.2

0.4

0.6

0.8

1

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

-3 -2 -1 0 1 2 30

0.2

0.4

0.6

0.8

1

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

-3 -2 -1 0 1 2 30

0.2

0.4

0.6

0.8

1

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Figure 5

θ

H1

ejθ( ) H1

ejθ( )∠

θ

θ

H2

ejθ( ) H2

ejθ( )∠

θ

θ

H3

ejθ( ) H3

ejθ( )∠

θ

x t( ) 8πt( )cos=

x n[ ] x n fs⁄( ) noise+= ∞– n ∞< <

1 2⁄– 1 2⁄,[ ] 500

x n[ ] y n[ ]f

θf

θ 2πffs

--------=

θ π– π,[ ]∈

f fs– 2⁄ fs 2⁄,[ ]∈ 250Hz– 250Hz,[ ]=

- 5 -

Page 6: FIR Filter Design: Part I - University of Florida · PDF file- 1 - FIR Filter Design: Part I 1. Introduction ... The zero-frequency component ( ), ... part of the input sequence and

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

Note that each filter removes the low-frequency cosine wave from the signal and preserves only high-fre-quency components (to varying degrees). Also note that these experimental results closely match the magni-tude frequency response functions in Figure 5.

The Mathematica notebook “fir_filter_design_part1a.nb” was used to generate the examples in the previoustwo sections. Additional speech and image processing examples for the low-pass and high-pass filters dis-cussed so far can be found in the notes corresponding to the 1/16 lecture. In the next two sections, we illus-trate how one might go about designing low-pass FIR filters, where you, as the designer, have much morecontrol over the filter’s resulting frequency response.

-200 -100 0 100 200

5

10

15

20

25

30

35

40

-200 -100 0 100 200

5

10

15

20

25

30

35

40

0 100 200 300 400 500-1.5

-1

-0.5

0

0.5

1

1.5

0 100 200 300 400 500

-0.4

-0.2

0

0.2

0.4

Figure 6

n

x n[ ]

n

f

FFT x n[ ]( )

f

y1

n[ ]

FFT y1

n[ ]( )

-200 -100 0 100 200

5

10

15

20

25

30

35

40

-200 -100 0 100 200

5

10

15

20

25

30

35

40

0 100 200 300 400 500-1.5

-1

-0.5

0

0.5

1

1.5

0 100 200 300 400 500-0.4

-0.2

0

0.2

0.4

Figure 7

n

x n[ ]

n

f

FFT x n[ ]( )

f

y2

n[ ]

FFT y2

n[ ]( )

- 6 -

Page 7: FIR Filter Design: Part I - University of Florida · PDF file- 1 - FIR Filter Design: Part I 1. Introduction ... The zero-frequency component ( ), ... part of the input sequence and

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

4. Design of a low-pass FIR filter: approach #1

A. Introduction

In the previous two sections, we saw examples of two types of simple FIR filters: (1) low-pass and (2) high-pass. Although these filters were relatively simple to derive, we had little control over the precise shape of thefrequency response function corresponding to each filter. Here, we consider the design of a low-pass filter,beginning with an ideal low-pass filter with zero-width transitions between the passband and rejection-band.

B. Ideal low-pass filter

Figure 9 illustrates the frequency response of an ideal low-pass filter with normalized cutoff frequency at. Note that a filter with these characteristics will not change the magnitude of any frequencies in the

input signal for the range , but will zero out all frequencies outside that range. Moreover, thelinear-phase property of such a filter will shift input frequencies in the range by an amountproportional to each frequency and, therefore, will not introduce any phase distortion into the output of thesystem. The slope of the line ( ) in the phase plot will determine the extent of the shift; a slope of zero willcorrespond to no phase shift (i.e. no delay).

Below, we will use the inverse DTFT to determine the time-domain impulse response of an ideal filterwith (i.e. no delay). Recall that the inverse DTFT is given by,

-200 -100 0 100 200

5

10

15

20

25

30

35

40

-200 -100 0 100 200

5

10

15

20

25

30

35

40

0 100 200 300 400 500-1.5

-1

-0.5

0

0.5

1

1.5

0 100 200 300 400 500

-0.3

-0.2

-0.1

0

0.1

0.2

0.3

Figure 8

n

x n[ ]

n

f

FFT x n[ ]( )

f

y3

n[ ]

FFT y3

n[ ]( )

θ θc=θ θc– θc,[ ]∈

θ θc– θc,[ ]∈

a–

H ejθ( )

θcθc–

θπ– π

H ejθ( )∠

θcθc–

θπ– π

Figure 9

1

slope a–=

h n[ ]a 0=

- 7 -

Page 8: FIR Filter Design: Part I - University of Florida · PDF file- 1 - FIR Filter Design: Part I 1. Introduction ... The zero-frequency component ( ), ... part of the input sequence and

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

. (20)

For the ideal filter in Figure 9 (with no delay), equation (20) reduces to,

(21)

(22)

, . (23)

Note that the impulse response for an ideal filter with no delay is infinite in length, both forwards and back-wards in time. For example, in Figure 10, we plot , , for .

C. Approximating an ideal filter with an FIR filter

Now, we will try to approximate the ideal filter with a causal FIR filter using the following procedure: Firstwe will retain values for only for a limited range of ,

(24)

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

(25)

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

. (26)

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:

(27)

where,

h n[ ] 1

2π------ H ejθ( )ejnθ θd

π–

π∫=

h n[ ] 1

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

θc–

θc

∫=

h n[ ] 1

2π------ejnθ

jn----------

θ θc–=

θ θc=1

2π------ ejnθc

jn------------ e jnθc–

jn--------------–

1

nπ------ ejnθc e jnθc––

j2--------------------------------

nθc( )sin

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

hideal n[ ]nθc( )sin

nπ---------------------= ∞– n ∞< <

h n[ ] 50– n 50≤ ≤ θc 1=

-40 -20 0 20 40

-0.05

0

0.05

0.1

0.15

0.2

0.25

0.3

Figure 10

hideal n[ ]

n

hideal n[ ] n

nmax– n nmax≤ ≤

h n[ ] n ∞→ h1

n[ ]

h1

n[ ]hideal n[ ]

0

=nmax– n nmax≤ ≤

elsewhere

h1

n[ ] h2

n[ ]

h2

n[ ] h1

n nmax–[ ]=

h2

n[ ]

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

2nmax

∑=

- 8 -

Page 9: FIR Filter Design: Part I - University of Florida · PDF file- 1 - FIR Filter Design: Part I 1. Introduction ... The zero-frequency component ( ), ... part of the input sequence and

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

(28)

In Figure 11, we plot the impulse response and the corresponding magnitude frequency response for various values of (10, 20 and 50) and a numeric cutoff frequency of . For each

frequency response plot, the blue line indicates the ideal magnitude frequency response.

Note that as we increase the length of the FIR filter (i.e. ) the transition region at the cutoff frequencybecomes more well-defined; however, also note the overshoot phenomenon (Gibbs phenomenon) at the cutofffrequency, which is similar to what we observed earlier in the course for the finite-sum Fourier series approx-imation of periodic waveforms with discontinuities (such as a square wave). While increasing the FIR filterlength will make the transition region in the frequency response function increasingly narrow, the overshootat the cutoff frequency will remain. Therefore, this approach for designing low-pass FIR filters will yield fil-ters that approximate the ideal filter characteristic arbitrarily well, except near , where the overshootproblem will remain. This problem motivates our second approach to filter design in the following section,where we explicitly allow some narrow, nonzero transition region between the passband and rejection band ofthe filter.

bk hideal nmax– k+[ ]nmax– k+( )θc( )sin

nmax– k+( )π-------------------------------------------------= =

h2

n[ ]H

2ejθ( ) nmax θc 1=

0 20 40 60 80 100-0.05

0

0.05

0.1

0.15

0.2

0.25

0.3

-3 -2 -1 0 1 2 30

0.5

1

1.5

2

0 10 20 30 40-0.05

0

0.05

0.1

0.15

0.2

0.25

0.3

-3 -2 -1 0 1 2 30

0.5

1

1.5

2

0 5 10 15 20-0.05

0

0.05

0.1

0.15

0.2

0.25

0.3

-3 -2 -1 0 1 2 30

0.5

1

1.5

2

Figure 11

θ

H2

ejθ( )h2

n[ ]

n

nmax 10=

θ

H2

ejθ( )h2

n[ ]

n

nmax 20=

θ

H2

ejθ( )h2

n[ ]

n

nmax 50=

nmax

θ θc±=

- 9 -

Page 10: FIR Filter Design: Part I - University of Florida · PDF file- 1 - FIR Filter Design: Part I 1. Introduction ... The zero-frequency component ( ), ... part of the input sequence and

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

5. Design of a low-pass FIR filter: approach #2

A. Introduction

In this section, we will follow exactly the same approach to designing a low-pass FIR filter as in the previoussection, except that we will start off with a slightly different magnitude frequency response, as illustrated inFigure 12 below. Note that unlike before, we now allow a finite-width transition region of width from oneto zero in the magnitude frequency response.

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

(29)

Note that,

, (30)

, (31)

are the equations of the two lines in the transition regions. We solve the integration in equation (29) usingMathematica (see “fir_filter_design_part1b.nb”) and arrive at the following solution for :

, . (32)

Using L’Hopital’s rule, we can show that this result is, in fact, identical to the one previously derived for theideal filter [equation (23)], as :

(33)

(34)

. (35)

H ejθ( )

θcθc– θπ– π

Figure 12

1

θc ∆+θc ∆+( )–

h n[ ]

h n[ ] 1

2π------ 1

∆--- θ θc+( ) 1+⋅

ejnθ θdθc ∆+( )–

θc–

∫1

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

θc–

θc

∫+=

1

2π------ 1

∆--- θc θ–( ) 1+⋅

ejnθ θdθc

θc ∆+( )∫

H ejθ( ) 1

∆--- θ θc+( ) 1+⋅= θ θc ∆+( )– θc–,[ ]∈

H ejθ( ) 1

∆--- θc θ–( ) 1+⋅= θ θc θc ∆+( ),[ ]∈

h n[ ]

h n[ ]nθc( )cos n θc ∆+( )( )cos–

n2π∆------------------------------------------------------------------= ∞– n ∞< <

∆ 0→

h n[ ]∆ 0→lim

nθc( )cos n θc ∆+( )( )cos–

n2π∆------------------------------------------------------------------

∆ 0→lim=

h n[ ]∆ 0→lim

∆dd nθc( )cos n θc ∆+( )( )cos–{ }

∆dd n2π∆{ }

--------------------------------------------------------------------------------∆ 0→lim=

h n[ ]∆ 0→lim

n n θc ∆+( )( )sin

n2π---------------------------------------

∆ 0→lim

nθc( )sin

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

- 10 -

Page 11: FIR Filter Design: Part I - University of Florida · PDF file- 1 - FIR Filter Design: Part I 1. Introduction ... The zero-frequency component ( ), ... part of the input sequence and

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

As for the case of the ideal filter, the impulse response in equation (32) is infinite in length, both for-wards and backwards in time. For example, in Figure 13, we plot , , for and

.However, when comparing Figures 10 and 13, we notice that the impulse response for non-zerotransition regions (i.e. , Figure 13), decays to zero values much quicker than for (Figure 10) as

. This is due to the fact that the values vary as for the ideal filter in the previous section,while they vary as for the filter with nonzero-width transition regions in this section. Therefore, theeffects of approximating the infinite impulse response in Figure 13 by retaining only values of for

should be less severe.

B. Approximation with an FIR filter

Here we will approximate the infinite impulse response in Figure 13, corresponding to the frequencyresponse in Figure 12 (with no delay), with a causal FIR filter, following the same procedure as for the idealfilter in the previous section. First we will retain values for [see equation (32)] only for a limited rangeof ,

(36)

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

(37)

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

. (38)

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:

(39)

where,

(40)

In Figure 14, we plot the impulse response and the corresponding magnitude frequency response for various values of (10, 20 and 50) and numeric values, and . For each

h n[ ]h n[ ] 50– n 50≤ ≤ θc 1=

∆ 1 10⁄=∆ 0≠ ∆ 0=

n ∞→ h n[ ] 1 n⁄1 n2⁄

h n[ ]nmax– n nmax≤ ≤

-40 -20 0 20 40

0

0.1

0.2

0.3

Figure 13

h n[ ]

n

h n[ ]n

nmax– n nmax≤ ≤

h n[ ] n ∞→ h1

n[ ]

h1

n[ ]h n[ ]0

=nmax– n nmax≤ ≤

elsewhere

h1

n[ ] h2

n[ ]

h2

n[ ] h1

n nmax–[ ]=

h2

n[ ]

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

2nmax

∑=

bk h nmax– k+[ ]nmax– k+( )θc( )cos nmax– k+( ) θc ∆+( )( )cos–

nmax– k+( )2π∆-------------------------------------------------------------------------------------------------------------------------= =

h2

n[ ]H

2ejθ( ) nmax θc 1= ∆ 1 10⁄=

- 11 -

Page 12: FIR Filter Design: Part I - University of Florida · PDF file- 1 - FIR Filter Design: Part I 1. Introduction ... The zero-frequency component ( ), ... part of the input sequence and

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

frequency response plot, the blue line indicates the infinite impulse magnitude frequency response.Note thatunlike the previous examples in Figure 11, we no longer have the same overshoot problem. In fact, for

, we see that the FIR filter is a very good approximation of the IIR filter. Again, this is due to thefact that we no longer require the transition from one to zero in the frequency response to occur instanta-neously, but rather that we allow for that transition region to be of some small, non-zero width (i.e. ).

C. Filtering examples

In this section, we illustrate the output for an FIR filter of type (40) on some sample input signals .For these examples, we assume a sampling rate of Hz, a desired cutoff frequency Hz, anda transition width of Hz. We also, limit our FIR filter to a length , where .Using the conversion rule between and ,

(41)

we can compute our normalized cutoff frequency and transition-region width :

(42)

. (43)

nmax 50=

0 20 40 60 80 100

0

0.1

0.2

0.3

-3 -2 -1 0 1 2 30

0.5

1

1.5

2

0 10 20 30 40

0

0.1

0.2

0.3

-3 -2 -1 0 1 2 30

0.5

1

1.5

2

0 5 10 15 20

0

0.1

0.2

0.3

-3 -2 -1 0 1 2 30

0.5

1

1.5

2

Figure 14

θ

H2

ejθ( )h2

n[ ]

n

nmax 10=

θ

H2

ejθ( )h2

n[ ]

n

nmax 20=

θ

H2

ejθ( )h2

n[ ]

n

nmax 50=

y n[ ] x n[ ]fs 500= fc 100=

∆f 10= 2nmax 1+( ) nmax 50=θ f

θ 2πffs

--------=

θc ∆

θc 2π fc fs⁄( ) 2π 100 500⁄( ) 2π 5⁄= = =

∆ 2π ∆f fs⁄( ) 2π 10 500⁄( ) π 25⁄= = =

- 12 -

Page 13: FIR Filter Design: Part I - University of Florida · PDF file- 1 - FIR Filter Design: Part I 1. Introduction ... The zero-frequency component ( ), ... part of the input sequence and

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

Using equations (32), (37) and (38), we can now compute the impulse response for the values of and in (42) and (43) above. In Figure 15 below, we plot that impulse response and the corresponding mag-nitude frequency response as a function of frequency . Note how well the FIR frequency response approxi-mates our desired cutoff frequency and transition width.

We now apply the following four test inputs to this system:

(i.e. sampled 50Hz cosine wave) (44)

(45)

(46)

(47)

For each test input, we compute the output as the convolution between and :

, , (48)

and compute the magnitude FFT of 500-length segments of the steady-state input and corresponding output(see Mathematica notebook “fir_filter_design_part1b.nb” for time-domain plots with transient responses aswell).These FFTs are plotted in Figures 16 through 19 below.

Note that for the first three test signals, the filter leaves the magnitude of the input frequencies less than100Hz unchanged, while zeroing out frequencies above 110Hz. For the fourth signal, we see that the 105Hzfrequency component is approximately halved, since it lies exactly halfway inside the transition region from100Hz to 110Hz. Thus, this low-pass FIR filter appears to perform exactly as designed.

h2

n[ ] θc∆

f

0 20 40 60 80 100

0

0.1

0.2

0.3

0.4

Figure 15

h2

n[ ]

n

-200 -100 0 100 2000

0.2

0.4

0.6

0.8

1

H2

ejθ( ) θ 2πf fs⁄=

f

x1

n[ ] 2π 50n⋅fs

-------------------- cos 0.2πn( )cos= =

x2

n[ ] 2π 50n⋅fs

-------------------- cos 3

2π 75n⋅fs

-------------------- cos+ 0.2πn( )cos 3 0.3πn( )cos+= =

x3

n[ ] 2π 50n⋅fs

-------------------- cos 3

2π 150n⋅fs

----------------------- cos+ 0.2πn( )cos 3 0.6πn( )cos+= =

x4

n[ ] 2π 50n⋅fs

-------------------- cos 3

2π 105n⋅fs

----------------------- cos+ 0.2πn( )cos 3 0.42πn( )cos+= =

xi n[ ] h2

n[ ]

yi n[ ] xi n[ ] * h2

n[ ]= i 1 2 3 4, , ,{ }∈

- 13 -

Page 14: FIR Filter Design: Part I - University of Florida · PDF file- 1 - FIR Filter Design: Part I 1. Introduction ... The zero-frequency component ( ), ... part of the input sequence and

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

-200 -100 0 100 2000

50

100

150

200

250

-200 -100 0 100 2000

50

100

150

200

250

Figure 16

FFT y1

n[ ]( )

f

FFT x1

n[ ]( )

f

-200 -100 0 100 2000

100

200

300

400

500

600

700

-200 -100 0 100 2000

100

200

300

400

500

600

700

Figure 17

FFT y2

n[ ]( )

f

FFT x2

n[ ]( )

f

- 14 -

Page 15: FIR Filter Design: Part I - University of Florida · PDF file- 1 - FIR Filter Design: Part I 1. Introduction ... The zero-frequency component ( ), ... part of the input sequence and

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

-200 -100 0 100 2000

100

200

300

400

500

600

700

-200 -100 0 100 2000

100

200

300

400

500

600

700

Figure 18

FFT y3

n[ ]( )

f

FFT x3

n[ ]( )

f

-200 -100 0 100 2000

100

200

300

400

500

600

700

-200 -100 0 100 2000

100

200

300

400

500

600

700

Figure 19

FFT y4

n[ ]( )

f

FFT x4

n[ ]( )

f

- 15 -

Page 16: FIR Filter Design: Part I - University of Florida · PDF file- 1 - FIR Filter Design: Part I 1. Introduction ... The zero-frequency component ( ), ... part of the input sequence and

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

6. ConclusionThe Mathematica notebooks “fir_filter_design_part1a.nb” and “fir_filter_design_part1b.nb” were used to gener-ate all the examples in this set of notes. In a companion set of notes, we conclude our discussion on FIR-filterdesign.

- 16 -