Sei sulla pagina 1di 24

TECHNOLOGICAL INSTITUTE OF THE PHILIPPINES

938 AURORA BOULEVARD, CUBAO, QUEZON CITY

Advanced Digital Signal Processing

Chapter 7: Finite Impulse Response Filter Design

Rating:

Aloysius Jan P. Quiros


EC42FB1

Engr. Francis Malit


Instructor

February 22, 2016

TECHNOLOGICAL INSTITUTE OF THE PHILIPPINES

938 AURORA BOULEVARD, CUBAO, QUEZON CITY

Advanced Digital Signal Processing

Chapter 7: Finite Impulse Response Filter Design

Rating:

Lacuna, Karen D.
EC42FB1

Engr. Francis Malit


Instructor

7.1. Design a 3-tap FIR lowpass filter with a cutoff frequency of 1,500 Hz and a
sampling rate of 8,000 Hz using
a. rectangular window function

b. Hamming window function.


Determine the transfer function and difference equation of the designed FIR system,
and compute and plot the magnitude frequency response for

=0,

3
, ,
radians .
4 2 4

Solution:

c =2 f c T s =2 ( 1500 )

1
( 8000
)= 38

2 M +1=3
M =1

Lowpass filter

h ( n )=
sin ( c n )
for n 0
n

n=0
1 n 1

8
3
h ( 0 )=
=

sin
h ( 1 )=h (1 )=

a. rectangular window function

w rec ( n )=1,M n M

3
(1 )
8
=0.29 40799888
(1)

w rec ( 0 )=wrec ( 1 )=wrec (1 ) =1

Windowed impulse response

3
3
hw ( 0 )=h ( 0 ) wrec ( 0 )= ( 1 )= =0.375
8
8
hw ( 1 )=h w (1 )=h ( 1 ) wrec ( 1 )=0.29 40799888 (1 ) =0.29 40799888
b0 =b2=0.29 40799888
b1=0.375

Transfer function

H ( z )=0.29 40799888+0.375 z1 +0.29 40799888 z2

Difference equation

H ( z )=

Y ( z)
1
2
=0.29 40799888+0.375 z + 0.29 40799888 z
X ( z)
1

Y ( z ) =0.29 40799888 X ( z )+ 0.375 z X (z)+0.29 40799888 z X ( z)


y ( n )=0.29 40799888 x ( n ) +0.375 x( n1)+0.29 40799888 x(n2)

Magnitude frequency response

H ( e j ) =0.29 40799888+0.375 e j +0.29 40799888e2 j

H ( e j ) =e j ( 0.29 40799888 e j +0.375+ 0.29 40799888 e j )


H ( e j ) =e j [ 0.375+0.5881599776 cos ( ) ]

|H ( e j )|=|[ 0.375+ 0.5881599776cos ( ) ]|


H ( e j) =

radians

f=

fs
Hz
2

{+

if 0.375+0.5881599776 cos ( )> 0


if 0.375+0.5881599776 cos ( )< 0

0.375+0.5881599776 cos ( )

|H ( e j )|

0.9631599776

0.963159977
6

1000

0.7908919086

0.790891908
6

2000

.375

.375

3
4

3000

-0.04089190858

0.040891908
58

4000

-0.2131599776

0.213159977
6

|H ( e j )|dB dB
0.32603144
09
2.03765735
2
8.51937464
5
27.7672523
8
13.4258866
8

Plot
[hz, w] = freqz( [0.2941 0.375 0.2941], [1], 512);
phi= 180*unwrap(angle(hz))/pi;
plot(w,20*log10(abs(hz))),grid;
xlabel(Frequency (radians));
ylabel(Magnitude Response (dB))

H ( e j)
0

45

90
45
0

b. hamming window function

w ham ( n )=0.54+0.46 cos

( nM ) , M n M
w ham ( 0 )=0.54+0.46 cos

[ ]

( 0 )( )
=1
1

w ham ( 1 )=wham (1)=0.54 +0.46 cos

[ ]

( 1) ( )
=0.08
1

Windowed impulse response

3
3
hw ( 0 )=h ( 0 ) wham ( 0 )= ( 1 ) = =0.375
8
8
hw ( 1 )=h w (1 )=h ( 1 ) wham ( 1 )=0.29 40799888 ( 0.08 )=0.0235263991
b0 =b2=0.0235263991
b1=0.375

Transfer function

H ( z )=0.0235263991+ 0.375 z1 +0.0235263991 z2

Difference equation

H ( z )=

Y (z)
1
2
=0.0235263991+0.375 z +0.0235263991 z
X ( z)

Y ( z ) =0.0235263991 X ( z)+0.375 z1 X (z )+0.0235263991 z2 X ( z)


y ( n )=0.0235263991 x ( n ) +0.375 x (n1)+0.0235263991 x (n2)

Magnitude frequency response

H ( e j ) =0.0235263991+ 0.375 e j +0.0235263991 e2 j


H ( e j ) =e j ( 0.0235263991 e j +0.375+0.0235263991 e j )
H ( e j ) =e j [ 0.375+0.0470527982 cos ( ) ]

|H ( e j )|=|[ 0.375+ 0.0470527982cos ( ) ]|


H ( e j) =
radians

f=

fs
Hz
2

if 0.375+0.0470527982 cos ( ) >0


if 0.375+0.0470527982 cos ( ) <0

0.375+0.0470527982 cos ( )

0.4220527982

1000

0.4082713527

2000

0.375

|H ( e j )|
0.422052798
2
0.408271352
7
0.375

|H ( e j )|dB dB
7.49266432
7.78102184
6
8.51937464
5

H ( e j)
degree
0

45

90

3
4

3000

0.3417286473

0.341728647
3

4000

0.3279472018

0.327947201
8

9.32637225
1
9.68392140
7

135
180

Plot
[hz, w] = freqz( [0.0235 0.375 0.0235], [1], 512);
phi= 180*unwrap(angle(hz))/pi;
plot(w,20*log10(abs(hz))),grid;
xlabel(Frequency (radians));
ylabel(Magnitude Response (dB))

7.3. Design a 5-tap FIR bandpass filter with a lower cutoff frequency of 1,600 Hz, an
upper cutoff frequency of 1,800 Hz, and a sampling rate of 8,000 Hz using
a. rectangular window function
b. Hamming window function.
Determine the transfer function and difference equation of the designed FIR system,
and compute and plot the magnitude frequency response for

=0,

3
, ,
radians .
4 2 4

Solution:

l=2 f l T s=2 ( 1600 )

1
( 8000
)= 52

h=2 f h T s=2 ( 1800 )

1
( 8000
)= 209

2 M +1=5
M =2

Bandpass filter

H L

h ( n )=
sin ( H n ) sin ( L n )

for n 0
n
n

n=0
M n M

9
2

20
5
1
h ( 0 )=
=

20

sin
h ( 1 )=h (1 )=

sin
h ( 2 )=h (2 )=

] [

9
2
( 1 ) sin ( 1 )
20
5

=0.01166027182
(1)
(1)

] [

9
2
(2 ) sin ( 2 )
20
5

=0.04436734622
(2)
( 2)

a. rectangular window function

w rec ( n )=1,M n M
w rec ( 0 )=wrec ( 1 )=wrec (1 ) =w rec (2 )=w rec (2)=1

Windowed impulse response

hw ( 0 )=h ( 0 ) wrec ( 0 )=

1
1
( 1 )= =0.05
20
20

hw ( 1 )=h w (1 )=h ( 1 ) wrec ( 1 )=0.01166027182 (1 ) =0.01166027182


hw ( 2 )=h w (2 )=h ( 2 ) w rec (2 )=0.04436734622 ( 1 )=0.04436734622
b0 =b4 =0.04436734622
b1=b3=0.01166027182
b2=0.05

Transfer function

H ( z )=0.04436734622+0.01166027182 z1+ 0.05 z 2 +0.01166027182 z30.04436734622 z 4

Difference equation

H ( z )=

Y (z)
=0.04436734622+ 0.01166027182 z 1 +0.05 z2+0.01166027182 z30.04436734622 z4
X ( z)
1

Y ( z ) =0.04436734622 X (z )+ 0.01166027182 z X (z )+ 0.05 z X ( z)+ 0.01166027182 z X (z)0.04436734622 z X ( z)

y ( n )=0.04436734622 x (n)+0.01166027182 x (n1)+0.05 x (n2)+0.01166027182 x (n3)0.04436734622 x ( n

Magnitude frequency response

H ( e j ) =0.04436734622+0.01166027182 e j + 0.05 e2 j + 0.01166027182 e3 j 0.04436734622 e4 j


H ( e j ) =e j (0.04436734622e j + 0.01166027182+0.05 e j +0.01166027182 e2 j 0.04436734622e3 j )

H ( e j ) =e j {0.04436734622 [ cos +i sin ] +0.01166027182+0.05 [ cos ( ) +isin ( ) ] +0.01166027182[co

H ( e j ) =e j {0.04436734622 [ cos +i sin ] +0.01166027182+0.05 [ cos ( ) isin ( ) ] +0.01166027182 [cos ( 2

|H ( e j )|=|{0.04 [ cos +isin ] +0.01+0.05 [ cos ( )isin ( ) ]+0.01[ cos ( 2 )isin ( 2 ) ]0.04 [ cos ( 3 )i sin
H ( e j) =

{+

if {0.04 [ cos +i sin ] +0.01+0.05 [ cos ( )i sin ( ) ] +0.01[cos ( 2 )i sin ( 2 ) ]0.04 [ cos ( 3 )isin ( 3 ) ] }> 0
if {0.04 [ cos +i sin ] +0.01+0.05 [ cos ( )i sin ( ) ] +0.01[cos ( 2 )i sin ( 2 ) ]0.04 [ cos ( 3 )isin ( 3 ) ] }< 0

radians

f=

fs
Hz
2

)iHsin
( e j(2) ) ]0.04 [ cos ( 3
{0.04 [ cos +i sin ] + 0.01+0.05|[Hcos( e(j )|i sin ( |)H] +0.01[cos
( e j )|dB dB( 2

-0.01

0.01

-40

180

1000

0.05-0.05i=0.07 -

0.07

-23.10

135

2000

-0.13i=0.13 -1.57

0.13

-17.72

90

3
4

3000

-0.03-0.03i= 0.04 -

0.04

-27.96

45

4000

2.36
0.05

0.05

-26.02

180

0.79

Plot

H ( z )=0.04436734622+0.01166027182 z1+ 0.05 z 2 +0.01166027182 z30.04436734622 z 4

[hz, w] = freqz( [-0.0444 0.0117 0.05 0.0117 -0.0444], [1], 512);


phi= 180*unwrap(angle(hz))/pi;
plot(w,20*log10(abs(hz))),grid;
xlabel(Frequency (radians));
ylabel(Magnitude Response (dB))

b. Hamming window function.

w ham ( n )=0.54+0.46 cos

( nM ) , M n M
w ham ( 0 )=0.54+0.46 cos

[ ]

( 0 )( )
=1
1

w ham ( 1 )=wham (1)=0.54 +0.46 cos

[ ]

(1) ( )
=0.54
2

w ham ( 2 )=wham (2)=0.54+0.46 cos

[ ]

(2) ( )
=0.08
2

Windowed impulse response

hw ( 0 )=h ( 0 ) wham ( 0 )=( 0.05 )( 1 )=0.05


hw ( 1 )=h w (1 )=h ( 1 ) wham ( 1 )=( 0.01166027182 ) ( 0.54 ) =6.30 x 103
hw ( 2 )=h w (2 )=h ( 2 ) w ham ( 2 )=(0.04436734622 )( 0.08 )=3.55 x 103

b0 =b4 =3.55 x 103


b1=b3=6.30 x 103
b2=0.05

Transfer function

H ( z )=3.55 x 103 +6.30 x 103 z1+ 0.05 z2 +6.30 x 103 z33.55 x 103 z4

Difference equation

H ( z )=

Y ( z)
=3.55 x 103 +6.30 x 103 z1 +0.05 z2+ 6.30 x 103 z 33.55 x 103 z4
X ( z)

Y ( z ) =3.55 x 103 X ( z)+6.30 x 103 z1 X ( z )+ 0.05 z2 X ( z )+ 6.30 x 103 z 3 X ( z )3.55 x 103 z4 X (z)
y ( n )=3.55 x 103 x( n)+6.30 x 103 x (n1)+0.05 x (n2)+ 6.30 x 103 x (n3)3.55 x 103 x (n4)

Magnitude frequency response

H ( e j ) =3.55 x 103+ 6.30 x 103 e j + 0.05 e2 j +6.30 x 103 e j 3 3.55 x 103 e4 j


H ( e j ) =e j (3.55 x 103 e j + 6.30 x 103 +0.05 e j +6.30 x 103 e2 j 3.55 x 103 e3 j )

H ( e j ) =e j {3.55 x 103 [ cos +i sin ] +6.30 x 103 +0.05 [ cos ( ) +i sin () ]+6.30 x 103 [cos (2 ) +i sin (
H ( e j ) =e j {3.55 x 103 [ cos +i sin ] +6.30 x 103 +0.05 [ cos ( )isin ( ) ] +6.30 x 103 [cos ( 2 ) isin ( 2 )

|H ( e j )|=|{3.55 x 103 [ cos +i sin ] + 6.30 x 103 +0.05 [ cos ( )i sin ( ) ] +6.30 x 103 [ cos ( 2 )i sin ( 2 )]

H ( e j) =

{+

if {3.55 x 103 [ cos +isin ] +6.30 x 103+ 0.05 [ cos ( )i sin ( ) ] + 6.30 x 103 [cos ( 2 )isin ( 2 ) ]3.55 x 103 [ cos ( 3 )

if {3.55 x 103 [ cos +isin ] +6.30 x 103+ 0.05 [ cos ( )i sin ( ) ] + 6.30 x 103 [cos ( 2 )isin ( 2 ) ]3.55 x 103 [ cos ( 3 )

radians

f=

fs
Hz
2

j
))isin
( e j [)cos
)|dB dBx 103 [cos
H((2e
{3.55 x 103 [ cos +isin ] +6.30 x 103|+H0.05
| ( )i sin
|H( (e j)]+6.30

0.0555

0.0555

-25.11

180

1000

0.04-0.04i=0.06 -0.79

0.06

-24.44

135

2000

-0.0571i=0.0571 -1.57

0.0571

-24.87

90

3
4

3000

-0.02905533906-0.029i=

0.04

-27.96

45

4000

0.0303

-30.37

0.04 -2.36
-0.0303

Plot

H ( z )=3.55 x 103 +6.30 x 103 z1+ 0.05 z2 +6.30 x 103 z33.55 x 103 z4

[hz, w] = freqz( [-3.55x10^-3 6.30x10^-3 0.05 6.30x10^-3 -3.55x10^-3], [1], 512);


phi= 180*unwrap(angle(hz))/pi;
plot(w,20*log10(abs(hz))),grid;
xlabel(Frequency (radians));
ylabel(Magnitude Response (dB))

7.5. Given an FIR lowpass filter design with the following specifications:
Passband (fpass)= 0800 Hz
Stopband (fstop)= 1,2004,000 Hz
Passband ripple = 0.1 dB
Stopband attenuation =40 dB
Sampling rate (fs) = 8,000 Hz,
determine the following:

a. window method

b. length of the FIR filter


c. cutoff frequency for the design equation.

Solution:
a. window method
Passband ripple = 0.1 dB
Hence, it is hanning window method

b. length of the FIR filter

f=

N=

|f stop f pass|
fs

1200800
=0.05
8000

3.1 3.1
=
=62
f 0.05

c. cutoff frequency for the design equation.

f c=

f pass + f stop 800+1200


=
=1000 Hz
2
2

7.7. Given an FIR bandpass filter design with the following specifications:
Lower cutoff frequency (fl) = 1,500 Hz
Lower transition width =600 Hz
Upper cutoff frequency(fh) =2,300 Hz
Upper transition width = 600 Hz
Passband ripple =0.1 dB
Stopband attenuation = 50 dB
Sampling rate(fs) = 8,000 Hz,

determine the following:


a. window method
b. length of the FIR filter
c. cutoff frequencies for the design equation.
Solution:
a. window method
Passband ripple = 0.1 dB
Hence, it is hamming window method

b. length of the FIR filter

f 1=

1500600
=0.1125
8000

f 2=

n=

2300600
=0.2125
8000

5
=44.4 which is approximately equal 45
0.1125

c. cutoff frequencies for the design equation


Lower cutoff frequency (fl) = 1,500 Hz
Upper cutoff frequency(fh) =2,300 Hz

7.9. Given an FIR system

H ( z )=0.25 0.5 z1 +0.25 z2 ,


realize H(z) using each of the following specified methods:

a. transversal form, and write the difference equation for implementation


b. linear phase form, and write the difference equation for implementation.

Solution:
a. transversal form, and write the difference equation for implementation

H ( z )=

Y (z)
=.25 0.5 z1+ 0.25 z 2
X ( z)

Y ( z ) =0.25 X (z) 0.5 z 1 X (z)+0.25 z2 X ( z)


y ( n )=0.25 x ( n )0.5 x ( n1 ) +0.25 x (n2)

b. linear phase form, and


equation for

H ( z )=

Y (z)
1
2
=.25 0.5 z + 0.25 z
X ( z)

Y ( z ) =0.25 X (z) 0.5 z 1 X (z)+0.25 z2 X ( z)


y ( n )=0.25 x ( n )0.5 x ( n1 ) +0.25 x (n2)

y ( n )=0.25 [ x ( n )+ x(n2)] 0.5 x ( n1 )

write the difference


implementation.

7.11. Determine the transfer function for a 5-tap FIR lowpass filter with a lower
cutoff frequency of 2,000 Hz and a sampling rate of 8,000 Hz using the frequency
sampling method.

Solution:

N=2 M +1=5
M =2

k =

2
k , k =0,1,2
5

for 0=0 radians , H 0=1


2
for 1= radians, H 1=1
5
4
for 2= radians , H 2=0
5
Specifications

H0

H1

H2

0.5

c =2 f c T s =2 ( 2000 )

1
( 8000
)= 2

Frequency Sampling

]}

2
2 k ( n3 )
1
h ( n )= 1+2 H k cos
, n=0,1,2
5
7
k=1

FIR filter coefficients

[ ]}

[ ]}

[ ]}

h ( 0 )=

1
4
1+2 cos
=0.1236
5
5

h ( 1 )=

1
2
1+ 2cos
=0.3236
5
5

h ( 2 )=

1
0
1+ 2cos
=0.6
5
5

b0 =b4 =0.1236
b1=b3=0.3236
b2=0.6
1

H ( z )=0.1236+ 0..3236 z + 0.6 z +0.3236 z 0.1236 z

7.13. Given the following specifications:

a 7-tap FIR bandpass filter


a lower cutoff frequency of 1,500 Hz and an upper cutoff frequency of 3,000
Hz
a sampling rate of 8,000 Hz

the frequency sampling design method,

determine the transfer function.

N=2 M +1=7
M =4

k =

2
k , k =0,1,2
5

for 0=0 radians , H 0=0


2
for 1= radians , H 1=0
7
4
for 2= radians , H 2=1
7
6
for 3= radians , H 3 =0
7
Specifications

H1

H3

H0
0

H2

0.35

0.75

l=2 f l T s=2 ( 1500 )

1
( 8000
)= 38

h=2 f h T s=2 ( 3000 )

1
( 8000
)= 34

Frequecny Sampling

]}

3
2 k ( n3 )
1
h ( n )= 0+ 2 H k cos
, n=0,1,2
7
7
k=1

FIR filter coefficients

{ [ ]}

h ( 0 )=

1
6
2 cos
=0.2574
7
7

h ( 1 )=

1
4
2 cos
=0.0636
7
7

h ( 2 )=

1
2
2 cos
=0.1781
7
7

h ( 2 )=

1
0
2 cos
=0.2857
7
7

{ [ ]}
{ [ ]}
{ [ ]}

b0 =b6 =0.1781
b1=b5=0.2574
b2=b4 =0.0636
b3 =0.2857
H ( z )=0.17810.2574 z10.0636 z2+ 0.2857 z3 0.0636 z40.2574 z 5 +0.1781 z6

7.15. In a speech recording system with a sampling rate of 10,000 Hz, the speech is
corrupted by broadband random noise. To remove the random noise while
preserving speech information, the following specifications are given:
Speech frequency range = 03,000 kHz
Stopband range = 4,0005,000 Hz
Passband ripple = 0.1 dB
Stopband attenuation = 45 dB
FIR filter with Hamming window.
Determine the FIR filter length (number of taps) and the cutoff frequency; use
MATLAB to design the filter; and plot the frequency response.

f=

|f stop f pass|
fs

40003000
=0.1
10000

FIR filter length

N=

3.3 3.3
=
=33
f 0.1

cutoff frequency

f c=

f pass + f stop 3000+ 4000


=
=3500 Hz
2
2

7.17. A digital crossover can be designed as shown in Figure 7.43.

Given the following audio specifications:


Sampling rate = 44,100 Hz
Crossover frequency = 2,000 Hz

Transition band range = 1,600 Hz


Passband ripple = 0.1 dB
Stopband attenuation = 50 dB
Filter type = FIR, determine the following for each filter:
a. window function
b. filter length
c. cutoff frequency.
Use MATLAB to design and plot frequency responses for both filters.
Solution:
a. window function
Lowpass filter: Hamming Window method
Highpass filter: Hamming Window method

b. filter length

f=

1600
=0.0363
44100

N lowpass=N highpass=

3.3
=90.91 which is approximately equal 91
0.0363

c. cutoff frequency

c =crossover frequency
c (low )=c (high )=2000 Hz

Potrebbero piacerti anche