This action might not be possible to undo. Are you sure you want to continue?

m. Example 1 : Determine the cutoff frequency of the digital filter whose difference equation is, yen) - ~y(n-1) = xin).

Solution : Taking z-transform of given difference equation, 1

Y(z) -2Z-1 Y(z) X(z)

Y(z) _ 1

X(z) - l-..!.Z-l 2

H(z)

'Frequency response can be obtained by putting z = (ejW) i.e.

1

1 ' 1-- e-)W

2

1

1-~ [cos (0- j sin (0]

1

( 1 - ~ cos (0 ) + j sin (0

1

1 - 2 cos (0 . sin (0

( 1 - ~ cos (Or + sin 2 (0 - ] (1 - ~ cos (Or + sin 2 (0

Hence magnitude will be,

1 "2

(3 - 1)

Digital Signal Processing

3-2

FIR Filter Design & Applications

1

( 1 - ~ cos W r + sin 2 W

For W = 0, I H(ejW) I ~ 1

0.5

1.4142

This is the maximum amplitude of the filter response. Now at W = 1.4142 amplitude will be reduced to .J2 = 1. We have to determine the 'cd

We, the above

for which

I H(ejW) 1=1 . This value can be evaluated by testing H(ejW) for few sample values of W i.e.,

W 0.8, I H(ejW) I = 1.031

W 0.85, I H(ejW) I = 0.993

W 0.82, I H(ejW) I = 1.016

W 0.83, I H(ejW) I = 1.0083 Thus the cutoff frequency lies near We = 0.83 radians/sample.

m. Example 2: Let hit) denote the impulse response of a linear time invariant analog filter and hd(n) the unit sample response of a linear shift invariant digital filter.

i) If h , (t) = e-at u(t), determine the analog filter frequency response and sketch its magnitude.

ii) If ha(n)=ha(nT) with ha(t) as given above, determine the digital filter frequency response and sketch its magnitude.

Solution : i) Frequency response of analog filter

Consider, ha(t) = e-atu(t)

From standard fourier transform relations, the fourier transform of this function

becomes,

H(f)

1

a+ j2nf 1

And,

I H(j) I =

Fig. 1 shows the plot of above magnitude.

IH(f)1

Fig. 1 Plot of frequency response of analog filter

Digital Signal Processing

3-3

FIR Filter Design & Applications

ii) Frequency response of digital filter After sampling of ha(t) at t = nT we get, hd(n) = ha(nT) = e-anTu(n) Taking fourier transform,

00 00

Hd(O)) = 'L,hd(n) e-jwn = 'L,e-anTu(n)e-jwn

n=::.-oo

'L,OO T' 'L,oo [ . ]n 1

e-an e-jWn = e-an e-jW = .

l-e-an e-jW

n=O n=O

This equation gives the frequency response of the digital filter.

m. Example 3: Determine the filter coefficients hd(n) for the desired frequency response of a low pass filter given by,

If we define the new filter coefficients by h(n) = hd(n) ,w(n), where

{I for O:$;n:$;4 w(n) =

o elsewhere

Determine hen) and also the frequency response H(ejW) and compare with H d (ejW) I Solution: i) To obtain hd(n)

The given Hd(ejW) is for a lowpass type of filter. Taking inverse fourier transform of Hd(eJW) we get,

1 1t/4

- f ejw(n-2) di» 21t

-1t/4

Digital Signal Processing

3-4

FIR Filter Design & Applications

= J_[eio:.(n-2) ]"/4 2rc j(n-2) 1t -"4

Above equation can be simplified to,

This equation gives filter coefficients for the desired filter.

ii) To obtain h(n)

The given window function is,

{I for O:S;n::::4 w(n) =

o otherwise

This is rectangular window of length M 0:s;n:s;M-1

5. For this window, h(n) =hd(n) for

.. h(O) 0.159091

h(l) 0.224989

h(2) 0.25

h(3) 0.224989

h(4) 0.159091

iii) To obtain H(e jW) Eq. 3.2.14 gives the frequency response for odd value of M. i.e.,

{ M-3 }

-jw M-l M -1 -2- M-1

H(m) = e (2) h(-2-) + 2 ~ h(n)COsm(n--2-)

Putting M = 5 in above equation,

H(m) = e-j2w[h(2)+2tah(n)CoSm(n-2)]

Putting values of h(n),

H(m) e-j2w[h(2)+2 h(O)cosm(-2)+2 h(l)cosm(-l)]

e-j2w [2 x 0.159091 cos 2m+ 2 x 0.224989 cos m+ 0.25]

Digital Signal Processing

3·5

FIR Filter Design & Applications

e-j2w [0.318 cos 2eo + 0.45 cos eo + 0.25]

Here the pseudo magnitude response is given by,

I H(eo) I

0.318 cos 2eo + 0.45 cos eo + 0.25

and

L H(eo)

{ -2eo for -2eo+ 11: for

I H(eo) I > 0 I H(eo) I < 0

Above two equations can be plotted against 'm to give frequency response. Here note that I H(eo) I will not be exactly same as Hd(eo) due to windowing op~ration.

)11. Example 4: Design an FIR filter (lowpass) using rectangular window with passband gain of 0 dB, cut-off frequency of 200 Hz, sampling frequency of 1 kHz. Assume the length of the impulse response as 7.

Solution : Given data :

Fe 200 Hz, Fs = 1000 Hz

fe

Fe 200

F = 1000 = 0.2 cycles/sample

s

211:fc = 211: x 0.2 = 0.4 11:

M 7

The impulse response of the desired filter is as given by eq. 3.4.20. Putting M = 7 and eoe = 0.4 11: in this equation we get,

{Sin[0.411:(n-3)] fi

h ( ) (3) or n *- 3

d n = 11: n-

0.4 for n=3

Since window function is rectangular, h(n) = hd(n). The coefficients are as follows:

h(O) h(l) h(2)

- 0.062341 0.093511 0.302609

h( 4) = 0.302609

h(5) = 0.093511

h(6) = - 0.062341

h(3) 0.4

These are the required filter coefficients.

Digital Signal Processing

3-6

FIR Filter Design & Applications

m. Example 5: Using a rectangular window technique, design a low pass filter with passband gain of unity, cutoff frequency of 1000 Hz and working at a sampling frequency of 5 kHz. The length of impulse response should be 7.

Solution: Here Fe = 1000 Hz, F, = 5000 Hz

Fe 1000

Fs = 5000 = 0.2 cycles/sample

2rtfc = Zrt x 0.2 = O.4rt

M 7

Note that these specifications are exactly similar to those of last example. Hence filter coefficients will be same as calculated in last example i.e.,

h(O) h(1) h(2)

- 0.062341 0.093511 0.302609

h( 4) = 0.302609 h(5) = 0.093511 h(6) = - 0.062341

h(3) 0.4

m. Example 6: Design an ideal bandpass filter with frequency response.

Use rectangular window with N = 11 in your design.

Solution : i) To obtain h d (n)

The given bandpass filter has a passband from (Oct = i to (OQ = ~rt rad/sample.

The desired unit sample response of the ideal bandpass filter is given by eq. 3.4.25 as,

{sin (Oe2 (n-"C) +sin (Oct (n-"C) fi

or n","C

hdn) = rt(n-"C)

(02 -(Oct

e for n = "C

rt

H M-1 11-1 5 P' I . b .

ere "C = -2- = -2- = , uthng va ues in a ove equation,

. [3rt(n-5)] . [rt(n-5)]

sm 4 -sm -4-

rt(n-5) 3rt rt

4-'4 1 -rt--S

for n '" 5

for n=5

Digital Signal Processing

3-7

FIR Filter Design & Applications

ii) To obtain h(n) by windowing

Here since rectangular window is given,

i.e.

hen) hen)

for 0 ~ n ~ M-1

for 0 ~ n ~ 10

Following are the values calculated as per above equation:

h(O) 0 h(6) = 0

h(l) 0 h(7) = - 0.3183

h(2) = 0 h(8) = 0

h(3) - 0.3183 h(9) = 0

h(4) 0 h(10) = 0

h(5) 1

5 m. Example 7: Oesign a lowpass filter with a cutoff frequency We = ~, a transition width L1w= 0.02n and a stopband ripple Os = 0.01. Use Kaiser for your design.

Solution : Given data

n

We 4

L1w 0.02 n

05 0.01

.. A - 20 log10 Os = 40 dB i) To obtain ~ and M

. Here A = 40, hence ~ can be calculated by,

~ 0.5842 (A - 21)°.4 + 0.07886 (A - 21) 0.5842 (40 - 21)°·4 + 0.07886 (40 - 21) 3.395

Value of M is given as,

A-8 M = 2.285L1w

Digital Signal Processing

3-8

FIR Filter Design & Applications

40-8

==

2. 285 x 0 . 02 TC

222.88

Observe that the values of ~ and M are same as in previous example. Value of COe == i == 0.25 TC and it is 0.2 TC in previous example. Hence all the design steps and

calculations will be same as given in previous example.

))'. Example 8: Obtain linear phase realization of

Z-l Z-2

H(z) == 1+-+-+z-3

4 4

Solution From the given system function we can write h(n) as,

1 1

h(O) == 1, hO) == 4' h(2) ==4' h( 3) == 1

Here M == 4 (even). Hence linear phase structure can be obtained using Fig. 3.10.5 in the book. The structure is shown below.

h(O) = 1

x(n) -,...------1

Fig. 2 Linear phase realization of H(z) of Ex. 8

m. Example 9 Obtain the cascade realization of system function,

Htz) == l+~Z-l +2z-2 +2z-3

2

Solution

Here,

H(z)

5

1 + _Z-l + 2z-2 + 2z-3

2

H(z)

5

z3 +_Z2 +12+2

2

Digital Signal Processing

3-9

FIR Filter Design & Applications

(Z+2)(Z2 +0.5z+1) Z2

The cascade realization of above equation is shown in Fig. 3.

y(n)

Fig. 3 Cascade realization of H(z) of Ex. 9

Exampl 10: The frequency response of a linear phase FIR filter is given by,

H( ej (j)) = ej 3 co [2 + 1.8 cos 3w + 1.2 cos 2w + 0.5 cosec] Find the impulse response sequence of the filter.

M-l

Solution: Here -2- = 3 ::::::> M=7. For odd length of M, the frequency response is given

as,

{ M-3 }

M-l -2-

-jw - M-l M-l

e (2) h (-2-)+2 n~o hen) casco (n - -2-)

ej 3 co {h( 3) + 2 n~o h( n) cos co (n - 3)}

= ej 3w {he 3)+ 2 h(O) cos 3 co+ 2 h(l) cos 2 co+ 2 h(2) cos co} Comparing with given H( ej w) we get,

2 h(O) 2 h(l) 2 h(2)

1.8 ::::::> h(O) = 0.9 1.2 ::::::> h(l) = 0.6 0.5 ::::::> h(2) = 0.25

Digital Signal Processing

3 -10

FIR Filter Design & Applications

h(3) = 2

Since filter has linear phase, h( n) = heM -I-n)

hen) h(4) h(S)

h(6-n) h(6-4)=h(2) = 0.25 h(6-S)=h(I) = 0.6

h(6) h(6-6)=h(0) = 0.9

Thus

hen)

{0.9, 0.6, 0.25, 2, 0.25, 0.6, 0.9}

Example 11 Deduce the equation for the frequency spectrum for the rectangular window

sequence defined by,

{ -(N-I) N-I

w R (n) = 1, for 2 :os; n :os; -2-

o otherwise

What is the width of main lobe of the spectrum ?

Solution: DTFT of window function is given as,

N-l

W(w)

-2-

L wen) e-jwn N-l

n=--2-

N-l -2-

L e-jwn N-l n=--2-

k=Nl

N2 aNl_aN2+1 " a k = _-;- __

L. I-a

Here let us use,

N-l N-l

( e- j co r -2 - ( e- j W)-2 + 1 W(w) =

By rearranging above equation,

W(w) =

.wN.w .wN .w

eJ -2- eJ"2 - e - J -2- e - J "2

. co . (0 • co . (()

eJ"2 e - J"2 - e - J"2 e - J "2

. wN . wN sin (w2N)

eJ -2- - e - J -2-

. co , (t) (w)

eJ"2 - e - J"2 sin '2

Digital Signal Processing

3 - 11

FIR Filter Design & Applications

Frequency spectrum will be,

I W(co) I

ISin(~)1 I sin(~)1

The width of the main lobe of the spectrum is ~: 1 .

Example 12: The frequency response of a filter is given by

H(ejw)=jco; -rc~co~rc

Design the filter, using a rectangular window function. Take N = 7.

Solution: The desired impulse response is given as,

-n

1 n

fico ei w n dco 2rc

-n

{:o~nn

n"*O for n =0

To have linear phase, we will shift h(n) to right. This shift is equal to N; 1 = 7 ~ 1 = 3 samples. i.e.,

{ cos rc( n - 3)

h(n) = n - 3

o

for n"* 3

for n = 3

Values of h(n) can be calculated as follows :

h(O) cos (- 3rc) 1

-3 3

h(l) cos( - 2 rc) 1

-2 = -'2

h(2) cos( -rc)

= 1

-1

and h(3) 0

h(4) cosrc = _ 1

1 Digital Signal Processing

3 -12

FIR Filter Design & Applications

h(5)

cos 2 re 2

h(6)

cos 3 re 3

Thus,

h(n) = {~, - ~,l,O,-l,~,-~}

Here observe that h( n) = - heN -l-n) with N phase filter.

Example 13: By choosing an appropriate window, design a linear phase, odd-length, low-pass

FIR filter that satisfies the following specifications :

7 since it is anti symmetric linear

0.985::; I H(ejw)l::; 1.015, 0::; W::; 0.2 re IH(ejw)l::; 0.001, 0.3re:<:;w::;re

Give the expressions for the impulse response and the corresponding frequency response.

Solution: i) To obtain order of the filter:

The specifications are,

1-0.015 s IH(eiw)l::; 1+0.015, I H( eiw)1 ::; 0.001,

o ::; co ::; 0.2 re

0.3 re::; w::; rt

Comparing above equation with equation 4.2.22,

81 = 0.015, 82 = 0.001, Ws = 0.3 re, wp = 0.2 re

M = Ws -wp = 0.3 re-0.2 re = 0.05

2re 2re

. -10IoglO(81·82)-15

By equation 4.2.23, N = 14 ~ f

- 10 IOglO (0.015 x 0.001) -15 14x 0.05

47.48 "" 48

The nearest odd length is, N = M = 49. ii) To obtain desired unit sample response

ro, + wp Here the cutoff frequency We = 2

0.3 re+ 0.2 re 2

0.25 re

The desired unit sample response is given as,

Digital Signal Processing

3 -13

FIR Filter Design & Applications

for

M-1 n*-- 2

for

M-1

n=--

2

Putting values in above equation,

1 sin 0.25rc (n -24)

hd(n) = rc(n-24)

0.25

for n * 24

for n = 24

iii) Selection of window

The attenuation required is 0.001 i.e. 20 log 0.001 = - 60 dB. This attenuation is offered by blackman window. (Refer table 4.3.1).

{ 2rcn 4rcn

() 00.42 - 0.5 cos M-1 + 0.8 cos M-1

WB n =

for n =0, 1, ... M-1

otherwise

{ n n rt n

= ~.42-0.5 cos 24 + 0.8 casU

for n = 0, 1, .... 48 otherwise

iv) Unit sample response of the filter

h(n) = hd(n)WB(n)

{Sino.25rc(n-24) [ rt n rcn]

h(n) = 0 rc( n - 24) 0.42 - 0.5 cos 24 + 0.8 cos 12

for n = 0, 1, .... 48

otherwise

This is the required expression for impulse response.

Example 14: Let the specifications of a filter be as follows :

0.99:s; IH(eiw)l:s; 1.01, o :s; co :s; 0.2 rc

IH(eiw)l:s; 0.05, 0.25 rc :s; co :s; 0.6 rc

0.99:S; IH(eiw)l:s; 1.01, 0.7 rc s (j) :s; rt i) These specifications approximate an ideal filter. Derive the impulse response of this ideal filter.

ii) Design a linear-phase filter that satisfies the above specifications using the kaiser window. Give the expression for the impulse response of the designed filter.

Digital Signal Processing

3 -14

FIR Filter Design & Applications

Solution : The given specifications are of band reject filter. The cutoff frequencies for rejected band are,

COC[ cop! ; COS1 = 0.2 TC +20.25 TC = 0.225 TC

= 0.6 TC; 0.7 TC = 0.65 TC

To obtain the values of 13 and M

Here 81 = 0.01 and 82 = 0.05

And

minimum of 81 and 82 = 0.01

Ll co minimum of ( COS2 - cop2) and (COS1 - cop! ) Minimum of 0.1 TC and 0.05 1t.

0.05 TC

A -20 log 8= -20 log 0.01 = 40 dB

Value of M is given for kaiser window as,

A-8 M =

2.285 Ll co

40-8 = 89.154 ~90

2.285(0.05 TC)

Since A = 40, which lies in the range of 21 to 50, 13 will be,

13 0.5842(A _21)°.4 + 0.07886(A -21)

0.5842 (40-21)°.4 + 0.07886(40-21) 3.395

i) To obtain impulse response of ideal filter

We know that Hd ( ei (() ) = e : i ro r in the passband band. Hence, 1 1[

2 TC f Hd ( ei w) ei co n dro

-1[

1 [- WC2 . We[ 1[ ]

= 2TC i1[ eJw(n-t) dro+ -L eiw(n-t) dor+ f eiw(n-t) dco

-~l "'C2

Digital Signal Processing

3-15

FIR Filter Design & Applications

!SinwC! (n-t)-sinwC2 (n-t)+ sinre(n-t)

= re(n -t)

re - wC2 + WC!

re

for n = r

M-1

We know that t=-2- . For kaiser window length of the filter is Mr I. Hence 'M'

should be replaced with Ms-I. i.e.,

r = M + 1 -1 = M = 90 = 45

2 2 2

Putting values in equation for h d (n),

1 sin 0.225 re( n -45)-sin 0.65 re( n -45)+ sin re(n -45)

hd(n)= re(n-45)

0.575

for n *- 45

for n= 45

ii) Filter design using kaiser window M 90

a = 2 = 2 = 45 and ~ = 3.395

Putting the values in equation 4.3.12,

Wk (n) =

10 {3395 [l-(~ni)

10 (3.395)

for 0:'0: n s 90

o

otherwise

The impulse response of the filter will be,

Putting the values of hd (n) and Wk (n) obtained earlier, hen) can be obtained.

- Example 15: i) Obtain the cascade realization of the system function :

H(z) = (1+2z-1 -z-2) (1+z-1 _z-2)

ii) Determine the direct form realization of the system function :

H (z) = 1 + 2z-1 - 3z-2 -4z-3 +5z-4

Digital Signal Processing

3 -16

FIR Filter Design & Applications

Solution: i) Cascade realization :

Here

1 + 2 z ? -Z-2 and H2 (z) = 1 + z :' -Z-2

y(n)

Fig. 4 Cascade realization

ii) Direct form realization :

y(n)

Fig. 5 Direct form realization

Example 16: Consider an FIR lattice filter with coefficients K1 = 0.65, K2 = - 0.34, K3 = O.S.

Find its impulse response. Draw the equivalent direct form structure.

Solution: Fig. 6 shows the lattice structure for given K1 ,K2 and K3•

x(n)

}--- y(n)

Here

93(n)

92(n)

Fig. 6 3-stage lattice structure

f1 (n) x(n)+ K1 x(n-l) ... (1)

gl(n) Kl x(n)+x(n-l) ... (2)

f2 (n) f1 (n)+K2 g1 (n-l) ... (3) and

Similarly

Digital Signal Processing

3 -17

FIR Filter Design & Applications

and

... (4)

Putting for f1 (n) and gl (n) from equation 1 and 2 in above equations and simplyfying we get,

and

x(n)+K1(1+K2)x(n-1)+K2 x(n-2) K2 x(n)+K1(1+K2)x(n-1)+x(n-2)

... (5) ... (6)

For third stage we can write,

yen) f2(n)+K3 g2(n-1)

x(n)+{K1 +K1 K2 +K2 K3}x(n-1)

+{K2+K1 K3+K1 K2 K3}x(n-2)+K3 x(n-3)

Putting for K1 = 0.65, K2 = - 0.34 and K3 = 0.8 and after simplification,

yen) x(n)+ 0.157 x(n -1)+ 0.0032 x(n -2)+ 0.8 x(n -3)

Y(z) H(z) hen)

X(z)+ 0.157 z " X(z)+0.0032 z-2 X(z)+ 0.8 z-3 X(z) 1 + 0.157 z-l + 0.0032 z-2 + 0.8 z-3

1 +0.157b(n -1)+ 0.0032 b(n -2)+ 0.8b(n - 3)

y(n)

Fig. 7 Direct form structure

))). Example 17: Design an ideal high pass filter with a frequency response:

for

1t -<lwl<1t

4 - -

O<lwl<~

- - 4

for

Find the value of hen) for N = 11 using (i) Hamming window

(ii) Hanning window

[Nov.lDec.-2004, 16 Marks]

Solution: Here the magnitude of HdejW) is given. The complete function can be represented as,

Digital Signal Processing

3 -18

FIR Filter Design & Applications

[or - 11: < co < _2: & 2: < co < 11:

- - 4 4--

elsewhere

To obtain hd(n) for M = 11

Taking inverse Fourier transform of H d ( e jro ),

-It

-It

It

2_ f e jro( n-T) di» 211:

-It

1 {-4lt It

211: L ejm(n-T) des+ I ejro(n-T) ds»

4

... (1)

2_ {[e.iro(n-T) ]-~ + [e.iro(n-T)]lt }

211: J(n-1;) J(n-1;) It

-It 4

... (2)

And for n = 1;, equation (1) above becomes,

{ It }

1 -4 It

211: L ds» + , ds»

3 4

for n =1;

... (3)

M-1 11-1

For linear phase filter 1; =-2- =-2- =5. Therefore from eq. (2) and (3) hd(n) can be

collectively written as,

Digital Signal Processing

3 -19

FIR Filter Design & Applications

{ ;(L5) {sin n(n-5) -sin ::[(n-5)}

"4 for n =5

To obtain coefficients of a filter

Following table shows values of hd(n), wen) for hamming and hanning window. Then hen) is given as,

hen) = hd (n) ·w(n)

**n hd(n) Hamming Hanning window Filter Filter
**

window wHamm(n) coefficients coefficients

w Hamm(n) (Hamming) h(n) (Hanning) h(n) =

= hd(n)WHann(n) hd(n)w hann (n)

1 0.54- 0.46 \ 2nn)

It(n- 5) - 1-eos-

2ltn 2 M-1

\''"'In-5) ) eosM -1 l.e, for M = 11,

-Sini(n - 5) l.e. for M = 11, ~( 1- eosin)

0.54 - 0.46

for n ~ 5 n

eosSn

0 hd (0) = 0.045 0.08 0 0.0036 0

1 hd(1) = 0 0.167 0.095 0 0

2 hd(2) = -0.75 0.397 0.345 - 0.2977 - 0.2587

3 hd(3) = -0.159 0.682 0.654 - 0.1084 - 0.1039

4 hd(4) = -0.225 0.912 0.904 - 0.2052 - 0.2034

5 3 1 1 0.75 0.75

hd (5) = "4 = 0.75

6 hd(6) = -0.225 0.912 0.904 - 0.2052 - 0.2034

7 hd(7) = -0.159 0.682 0.654 - 0.1084 - 0.1039

8 hd (8) = - 0.075 0.397 0.345 - 0.2977 - 0.2587

9 hd(9) = 0 0.167 0.095 0 0

10 hd (10) = 0.045 0.08 0 0.0036 0 DOD

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue reading from where you left off, or restart the preview.

scribd