You are on page 1of 28

11.1 ECE 410 University of Illinois DIGITAL SIGNAL PROCESSING Chapter 11 D.

Munson

DIGITAL FILTER DESIGN FIR Design Methods 1) Windowing a) Truncation b) General windowing 2) Frequency Sampling ~ will cover later in connection with the DFT 3) Computer-Aided Optimization a) Parks - McClellan () ~ widely used b) Linear Programming 1a) Truncation Illustrate by example. Suppose we want a LPF with frequency response:
D()

We might choose the filter coefficients {hn} to be


1 dn = 2

D( )

e j n

1 d = 2

1 e j n d =

sinc c n

(Then frequency response Hd() = DTFT [{d n}] = D() exactly.) Look at the dn:

11.2
dn

This sequence is infinite in length and noncausal. So, lets choose (assume N odd, for now):
d N1 n hn = 2 0 0 n N 1 else

hn

n N-1 2 N-1

If N is large, then hn consists of all the larger values of dn and Hd() D() e
j N 1
2

But this approximation is poor in the following sense. The frequency response will look like:
H d ( )

Gibbs Phenomenon

The ripples are due to the Gibbs phenomenon. Get tall ripples at sharp transitions. As N increases, ripples become narrower and more numerous, but the heights of the ripples nearest the discontinuity remain large. We will soon develop our own explanation for why this occurs. For now, it is worth noting that the DTFT

11.3

is actually a Fourier series expansion of D(). We had not thought of the DTFT in this way before, because there was no advantage in doing so. Here, though, we note that Hd() is obtained by truncating this Fourier series (i.e., choosing hn = d N1 for 0 n N 1.)
n
2

n =

d n e jn

Gibbs and other mathematicians studied truncation of Fourier series and showed that ripples will occur around locations where the periodic function is discontinuous. These ripples can be made narrower and to bunch up around the points of discontinuity by taking N larger. However, a larger N does not reduce the heights of the ripples! How can we reduce the ripple heights?
1b) General Windowing
1 Given D() and the corresponding infinite-length {dn}, choose the coefficients {h n}N to be n =0 (again, assume N odd for now):

hn = wn d

n N1
2

0nN1

where wn = 0, n [0, N 1], is a window sequence that gently tapers to zero. For truncation we used 1 0 n N 1 wn = 0 else which does not taper gently to zero. Smoother windows can lead to much lower ripple. An example of a good window is the Hamming window: 2 n wn = .54 .46 cos , 0 n N 1. N 1 This is plotted below

11.4
wn

N1

1 How does the window choice affect the frequency response of the designed filter {h n}N ? n =0

Let gn = d Then:
hn = wn gn
n N1
2

desired u.p.r. after shifting window coeffs. of designed FIR filter

In the frequency domain this corresponds to: Hd() =

wn g n
n

ejn

1 wn 2 Gd ( ) ejn d ejn n 1 2 1 2

Gd ( ) wn e jn ( ) d
n

Gd ( ) Wd() d

(*)

Notice that this has the form of a convolution. Since the integrand is periodic and we integrate over only a single period, this is called a periodic convolution.

11.5 Since our goal is to have Hd() Gd(), we see from (*) that we would like Wd() = 2 () But, Wd() = 2 () wn =
1 2

2 ( ) e jn d = 1

for all n

wn is not a window sequence! wn nonzero only on n [0, N 1] results in (at best) either: i) or ii) Wd() is wider around the origin but the sidelobes are lower. So, we have a tradeoff. From (*) we see that the ripple in Hd() is caused by integrating the product of Gd and Wd as the ripples in Wd are shifted across the discontinuity of Gd. Likewise, the width of the transition band for Hd will depend on the width of the mainlobe (center lobe) of Wd. We conclude: High sidelobes of Wd Large ripple in Hd. Wide center lobe of Wd Wide transition band in Hd. Our goal is to achieve moderately low sidelobes and a moderately narrow transition width in Wd simultaneously. What does Wd() look like for some common windows? Truncation N 2 Wd () = 1 e jn = 1 n =0 sin 2
N1

Wd() is a narrow pulse around = 0, but has high sidelobes.

sin

11.6 Plot on log scale:

0 13dB -20 -40 -60 -80 -100

0 2 N

0.2

0.4

0.6

0.8

Triangular (Bartlett):
wn

n N-1

Wd () =

sin

N+1 2 4 1 sin 2

Plot on log scale:

11.7
0 -20 25 dB

log10 Wd ( )
20

-40 -60 -80

-100 0 4 N+1 0.2 0.4 0.6 0.8

From this plot, we see that the triangular window has a mainlobe that is twice as wide as that of the rectangular window, but the highest sidelobe is reduced by 12 db. Hamming: 2 n wn = .54 .46 cos 0nN1 N 1 Plot of Wd () on a log scale:
0 -20
20 log W ( ) 10 d

41dB

-40 -60 -80

-100 0 4 N 0.2 0.4 0.6 0.8

From this plot, we see that the Hamming window has essentially the same mainlobe width as the triangular window, and sidelobes that are reduced an additional 16 dB to 41 dB. Thus, the

11.8 Hamming window is preferred over the triangular window. Comparing the Hamming window to the truncation window, we see that the highest sidelobe is reduced by 28 dB (more than a factor of 10) at the expense of increasing the mainlobe width by a factor of 2. Best window: Kaiser N 1 wn = Io 1 n 2 N 1 2 2
1/ 2

0nN1

Io is the zeroth-order modified Bessel function of the first kind: Io(x) =


1

excos d =

cosh (x cos) d

The choice of affects the tradeoff between the mainlobe width and sidelobe heights. is user specified. The Kaiser window can achieve slightly narrower mainlobe with the same sidelobe height as Hamming window.

11.9
Typical Frequency Responses Using Window Design

If the desired magnitude response is


G d ( )

then the frequency response of a truncation design may look like:

H ( ) = G d ( ) W ( ) d d truncation

c transition band

and the frequency response of a Hamming design will look like:


H ( ) = G d ( ) W ( ) d d Hamming
H H

So, Hamming widens the transition band by a factor of two, but greatly reduces ripple.

11.10 Note: The actual filter design procedure is hn = wn gn 0 n N 1.

The above Fourier-domain concepts are to help us visualize the resulting Hd(). Now, so far we have considered only the case with N odd, where we defined gn = d
n N1 2

where D() is the desired Hd(). How do we find gn if N is even? Answer: Select gn as shown in the following procedure, which works for both N odd and N even.

General Window Design Procedure

To design a generalized linear phase { h n }n = 0 with Hd ( ) D() do this:


N1

1) Let Gd() = D() e

N1 2

2) Find gn = DTFT1 [Gd ( )] 3) Let hn = wn gn . Notes: 1) For N odd this procedure gives gn = d
n N1 as before. For N even, steps 1) and 2

2) give {gn} as an interpolated set of values lying between d N and d N2 . n 2 n 2

2) We wish to know whether Hd(), designed via the window method, will have generalized linear phase. The answer is ordinarily yes, since {hn} will be symmetric or antisymmetric if {wn} is symmetric and {gn} is either symmetric or antisymmetric.

FIR Window Design Examples Example Design generalized linear-phase, low-pass FIR filters having coefficients { h n }29 n = 0 and cutoff

c = 4 using the window design procedure with both truncation and Hamming windows.

11.11

Solution
j N1 2

Gd() = D() e

j 29 e 2 = 0

< 4

gn =

1 2
4

4 j 29 e 2

e j n d

1 e 2 j n 29 2 4

j ( n

29 ) 2 4

sin =

29 n 2 4 29 n 2

1 29 sinc n 4 4 2
0 n 29 else

1 Now, for truncation hn = wn gn with wn = 0 So: 1 29 sinc n 4 4 2

hn =

0 n 29

11.12

For the Hamming window design we have 2 n 1 29 h n = .54 .46 cos sinc n 29 4 4 2

0 n 29

Example

Design generalized linear phase high-pass FIR filters having coefficients { h n }n = 0 and cutoff 2 using the window design procedure with both truncation and Hamming windows. c = 3

60

Solution

e j30 Gd() = 0

2 3

<

2 3

1 gn = 2

G d ( ) e j n d

periodic with period = 2


1 = 2
2 0

Gd ( ) e jn d

(*)

1 e j30 e jn d 2 2
3 4 3 2 3

4 3

( )

e j(n 30) 2 j(n 30)

()

11.13

j 4 (n 30) j 2 (n 30) 1 e 3 e 3 2 j(n 30) j (n 30) j (n 30) e 3 e 3

1 e j (n 30 ) = 2 j(n 30) =

1 (1)n 2 j sin (n 30) 2 j(n 30) 3 1 sinc (n 30) 3 3

= (1)n

So, using a truncation window gives: 1 h n = (1)n sinc (n 30) 3 3 0 n 60

and applying a Hamming window gives: 2 n 1 h n = .54 .46cos (1)n sinc (n 30) 60 3 3 0 n 60

Notes: 1) Since Gd() is nonzero on two subintervals of < for the high-pass case, it can save algebra if we use periodicity to rewrite the inverse DTFT as in (*) across the interval 0 2. This trick is straightforward if N is odd. For N even, however, there are two extra things to think about. First, in view of the table on p. 35.8, we should use an oddsymmetric design with Type 2 generalized linear phase. Second, for N even, the slope of the N1 phase, , is noninteger and the phase will take a jump of at = . Thus, Gd() seemingly will have two different forms on the interval 0 2. See the next example for details. 2) Since the denominator of () is zero at n = 30, we cannot presume that () follows from () at n = 30. Thus, we must be careful to check that our expressions for {hn} hold at n = 30. Our final expression for gn, which follows from (), gives: g30 = (1)30 1 1 1= 3 3
2

Evaluating () at n = 30 gives

11.14 g30 = 1 1 4 2 1= 2 3 3 3

which agrees with (). Thus, our expressions for hn are valid for 0 n 60. Now, lets change N in the previous example from N = 61 to N = 62 and see how the algebra associated with the design changes for N even.
Example

Design a generalized linear phase high-pass FIR filter having coefficients { h n }n = 0 and cutoff 2 c = using the window design procedure with a Hamming window. 3

61

Solution

A filter with real-valued unit-pulse response satisfies Gd ( ) = Gd ( ). Thus, for an

antisymmetric design with Type 2 generalized linear phase, we have


61 j e 2 2 0 61 j e 2 2

Gd() =

2 < 3 2 < 3 < 2 3

j 61 j e 2 0 61 j j e 2

2 < 3 2 < 3 < 2 3

(*)

11.15 As in the last example we can write


4 3

gn =

1 Gd ( ) e jn d 2 2
3

(**)

Equation (*) specifies Gd() on || < . To find Gd() for < <
Gd()

4 consider 3

2 3
j 61

2 3 Gd() = j e in here

j 61 2

4 3

Gd() = j e 2 in here

Gd() = Gd(2) = j e =je


j 61 (2) 2

j 61 2

So, Gd() in (**) maintains the same form across the full range of integration in (**) and we have
j 1 2 e j n d je 2 2 3 61 n j 2 e 4 3 4 3 61

gn =

61 2 2 n 2 3
61 2 61 j 4 n j n e 3 2 e 3 2 61 2 n 2

11.16
1 61 2 n 2
61 61 61 j n j n j n 2 2 e e 3 2 e 3

61 (1) n 2sin n 61 2 3 2 n 2 1 1 61 sinc n 3 3 2

= (1)n

Applying the Hamming window gives hn = .54 .46 cos 2 n (1)n 1 sinc n 61 3 3 61 2 0 n 61

Example

h n }n = 0 so that Hd ( ) approximates Window design of bandpass filter. Find {


N1

D() 1 o c o + c o o c o + c

For lowpass filter had dn =

dn (cos o n) c sinc [ c n] . Lets see:


+c c

c sinc c n. By modulation property, here for BP case we expect

1 dn = 2

1 1e jn d +

+c c

1e jn d

e jn o + c e j n o + c + 2 jn o c 2 jn o c

11.17

e jn( o + c ) e jn( o c ) + e jn( o + c ) e jn( o c ) 2 jn

1 e jn o (e jnc e jn c )+ e jno (e jnc e jn c ) 2 jn

1 jn sin c n o sin c n + e jn o sin c n] = e 2 cos o n [ n n

= 2 (cos o n) c sinc c n
N 1

what we expected.

Now, to design { h n }n = 0 with linear phase, need to incorporate shift to give: N 1 c N 1 g n = 2cos o n sinc n c 2 2

0 n N1

Windowed coefficients are then


h n = wn g n 0 n N1

~ coefficients for FIR filter where wn is a Hamming or

other window.

In MATLAB, the command to design FIR filters using the window method is called fir1.

11.18
Parks-McClellan

Parks and McClellan developed a computer program for solving the following problem: Define the error
E( ) = W( )[D( ) R( )]
desired response from

arbitrary weighting

H d ( ) = R( )e

N 1 j 2

0 or

Let p, s be the passband and stopband cutoff frequencies so that D() might look like:
D() 1.0

p s

Ordinarily D() is unspecified on p < < s because we are not concerned with the precise shape of Hd() or R() in this transition band. The Parks-McClellan algorithm finds { h n }n = 0 that minimizes max E( ) 0 p s This error measure is called the minimax or Chebyshev error norm. In the standard P-M algorithm, W() can be selected to have one value, Wp, on the passband and another, Ws, on the stopband. Frequently, Ws is chosen larger than Wp so that the designed filter will have a smaller stopband error than passband error. The program user specifies:
N1

11.19

N, p, s, Wp, and Ws The designed filter has equiripple behavior:


H d ( )

1.0

1 p

How are the ripple heights related to Wp and Ws? Answer: They satisfy p Wp = s Ws. Thus,

p s

Ws . Wp

What filter order is required to meet given specifications? Answer: It has been found empirically that N 10log10 p s 13

( ) 2.324( s p )

Note: The filter order is not too sensitive to p, and s. But, N is inversely proportional to the transition bandwidth! Halving the transition bandwidth doubles the required filter length! All students will get experience with the Parks-McClellan algorithm in a Matlab assignment.
Linear Programming

11.20

Linear programming is a fairly general optimization algorithm that can solve the ParksMcClellan problem and many others. LP is slower, but its generality can be exploited to incorporate time-domain or additional frequency-domain constraints. For example, it is possible to eliminate ripple in the passband by constraining the derivative of R() to be 0 in the passband. The result is a monotone decreasing response in the passband, with ripple remaining in the stopband:
H() 1.0

Incorporating the monotone passband constraint increases the required filter order slightly. In MATLAB, the command to design FIR filters using the P-M method is called remez.

Frequency Sampling FIR Filter Design

Given Gd() ~ desired frequency response with linear phase Idea: Choose Hd() to agree with Gd() at = 2 m, 0 m N 1. N

2 m N1 N1 Take { h n }n = 0 to be DFT1 Gd , i.e., N m = 0


2 1 N1 2 j N nm hn = m e 0 n N 1 G N m= 0 d N

(FS)

11.21 Using { h n }n = 0 as our FIR filter coefficients will give a frequency response Hd() satisfying
N1

Hd() = Gd() at = actual Why? H d ( )


m =2 N

2 m N

0mN1

desired

= DFT [{h n } ]

2 m = DFT DFT 1 G d N
by (FS)

2 = Gd m N
But in general Hd() Gd() for This approach can be too simplistic. Example

2 m. N

Let Gd() be an ideal LPF with linear phase and delay


G d ( )

N 1 . 2

2 N

11.22 Using (FS), will produce an Hd() that agrees with Gd() at the points shown above. The resulting Hd() might look like:
Hd ()

agrees with Gd() at uniformly spaced points, but can have large ripple.

There is a modified frequency sampling design procedure that works better. In the modified procedure, one or more frequency samples in the filters transition band are left unconstrained as free variables. The values of these free variables are then selected via linear programming to minimize some measure of ripple. This results in a wider transition band, but lower ripple, as suggested in the figures below.
G d ( )

variable transition sample that can be selected to minimize ripple.

11.23
H d ( )

wider transition band, lower ripple.

Note: If you take Gd() to have zero phase, the designed Hd will still pass through the correct 2 m . Hoping for zero phase samples of Gd, but the response will be terrible off the grid = N (no delay) in a causal filter is a pipe dream!
Example

Use the frequency sampling method to design a linear-phase HPF { h n }n = 0 , with cutoff c = .6.
60

Solution N = 61 phase = N 1 = 30 2
0 < .6 .6 1.4 1.4 < 2

0 Gd() = e j30 0

0 j30 2 m 2m 61 Gd 61 = e 0

0 m 18 19 m 42 43 m 60

2 m Now, {hn} is the inverse DFT of Gd as given by 61


nm 1 60 2 m j 2 61 Gd e 61 m= 0 61

hn =

11.24 1 42 j30 2 m j2 nm = e 61 e 61 61 m=19 = 1 42 j 2 (n 30)m e 61 61 m=19 effect of linear phase is to circularly shift the {hn} since replacing n30 with <n 30>61 does not change this equation 1 23 j 2 (n 30 )(k +19) e N 61 k = 0

k = m 19
1 j 2 (n 30 )19 1 e 61 e 61 = j 2 (n 30) 61 1 e 61
j 2 (n 30 )24

1 j 2 (n 30)31 e 61 j2 (n 30 )12 j 2 (n 30)12 e 61 e 61 61 = (n 30) j2 j (n 30) j (n 30) 61 e e 61 e 61

2 2 jsin (n 30)12 1 j (n 30) 61 e = 61 2jsin (n 30) 61 1 (1)n = 61 sin 24 (n 30) 61 sin (n 30) 61

0 n 60

sampled periodic sinc Here, the factor (1)n makes this a high-pass filter rather than a low-pass filter. Since this term multiplies a periodic sinc, which is similar to a sinc, we expect that the resulting frequency

11.25 response will not be too different from that obtained using the window design procedure with a truncation window.

Lets next consider the design of a low-pass filter { h n }n = 0 where N is even. This example will
N1

be more complicated than the previous one in two respects. First, since N is even, the formula for Gd() will take two different forms on 0 < 2. Second, since this is a low-pass filter, there will be two separate bands where Gd() is nonzero on 0 < 2.
Example

Frequency sampling design of { h n }n = 0 , linear-phase LPF with c =


21

. 2

Solution N = 22 phase =
e j 21 2 Gd() = 0

N 1 21 = 2 2
2

< 2

But, for a frequency sampling design, we need samples of Gd() on [0, 2). For N even, with
N 1 2

noninteger, we must be careful! Consider the phase of Gd(). Here for clarity, we

will not wrap the phase inside the interval (, ) and will instead show its linear extension.

11.26
Gd() 21 4

2 21 4

3 2

5 2

21 Gd() = e j 2 in here

21 Gd() = e j 2 ( 2 )

=e

j j 21

= e j 2 in here Note: Minus sign doesnt occur if N is odd. So: e j 21 2 0 21 e j 2 0 2

21

Gd() =

3 << 2 2 3 2 2

2 m Gd = 22

2 m j 21 e 2 ( 22 ) 0 j 21 2 m ( ) e 2 22

0m5 6 m 16 17 m 21

11.27 Thus, hn =
2 m mn 2 1 5 j 21 1 21 j 21 2 m j2 ( ) 2 22 22 e e + e 2 ( 22 ) e j 22 mn 22 m= 0 22 m=17 n 21 m n 21 m 1 5 j2 1 21 j 2 e 22 ( 2 ) e 22 ( 2 ) 22 m= 0 22 m=17

Making the change of variable = m 22, the second sum can be rewritten as

Thus,

j 2 n 21 ( + 22 )
22 2

= 5

j 2 n 21
22 2

= 5

e j21 = 1

hn =

n 21 m 1 5 j2 e 22 ( 2 ) 22 m= 5 n 21 (k 5) 1 10 j 2 ( 2) 22 e 22 k = 0

k=m+5 =
n 2 ) 11 n 21 (5) 1 e j 22 ( 1 j2 ( ) 22 2 e j2 n 21 22 1 e 22 ( 2 )
2 21

1 22

j10 n 21 2 e 22

) 2 ( ) j n 21 1 e 22 ( 2 )2

2 21 11 e j 22 n 2 2

11 21 n 22 2 21 j2 sin n 22 2 j2 sin

21 n 1 2 2 22 sin n 21 22 2
sin

0 n 21

Thus, hn is a sampled, periodic sinc, which is similar to the sinc-type design that would have resulted from a window design using a truncation window.

11.28 In general, the formula for the coefficients of either an FIR LPF or HPF, designed using the frequency sampling technique, are given by N 1 sin n N 1 2 N sin n N 1 N 2

LPF: hn =

N 1 sin n 1 N 2 HPF: hn = (1)n N sin n N 1 N 2 2 m where is the number of samples Gd , 0 m N 1, that are nonzero (number of N samples in the passband).

You might also like