Upload
evhyajah
View
221
Download
0
Embed Size (px)
Citation preview
8/9/2019 Lecture 16 FIR Design
1/28
1
FIR Filter Design
Chapter 12.8
Lecture 16
8/9/2019 Lecture 16 FIR Design
2/28
2
2 Types of Filters
Finite Impulse Response (FIR) Easy to design Always stable!
Phase distortion is LINEAR Large and slow to implement y[n] = b
0x[n] + b
1x[n-1] + .+ b
mx[n-m]
Infinite Impulse Response (IIR) Harder to design Can be unstable More efficient (faster)!
y[n] = -a1y[n-1] + + a
Ny[n-N] + b
0x[n] + .+ b
mx[n-m]
No poles:
always stable
8/9/2019 Lecture 16 FIR Design
3/28
3
Design an FIR LPF
Start with Ideal Filter:
Obtain the time domain impulse response
8/9/2019 Lecture 16 FIR Design
4/28
4
Now, lets observe this filter in the time
domain using MATLAB:
Let 1 = /3
8/9/2019 Lecture 16 FIR Design
5/28
5
MATLAB CODE
close all clear all %note: we must truncate a sinc function! So, let's begin by
observing the
%function from n = -m:m for different values of m n = -10:10; h = sin(pi/3*n)./(pi*n); h(11) = 1/3;
figure, stem(n, h) a = 1; figure, freqz(h, a)
8/9/2019 Lecture 16 FIR Design
6/28
6
Example
Design a LPF-FIR filter if 1= /3, m = 10
0db in pass band Ringing in stop band
fB = 0.3
8/9/2019 Lecture 16 FIR Design
7/28
7
Example 2
Design a LPF-FIR filter if 1= /3, m = 20
0db in pass band
More ringing in the stop band
Steeper cut off
Ringing in pass band (wellsee this better in a bit)
8/9/2019 Lecture 16 FIR Design
8/28
8
Example 3 Design a LPF-FIR filter if 1 = /3, m = 50
8/9/2019 Lecture 16 FIR Design
9/28
9
Design a FIR BPF
How do you think we could adjust the LPF
into a BPF?
8/9/2019 Lecture 16 FIR Design
10/28
10
Example Design a BPF-FIR filter if
0= 0.6,
1= /6,
m = 20, 40, 100
close all clear all
%note: we must truckate a sinc function! So, let'sbegin by observing the
%function from n = -m:m for different values of m n = -20:20; h = (1./(pi.*n)).*(sin(pi/6.*n)).*(cos(0.6*pi.*n)); h(21) = 0.1667; figure, stem(n, h)
a = 1; figure, freqz(h, a)
8/9/2019 Lecture 16 FIR Design
11/28
11
BPF with
0 = 0.6, 1 = /6, m = 20
8/9/2019 Lecture 16 FIR Design
12/28
12
BPF with
0 = 0.6, 1 = /6, m = 40
8/9/2019 Lecture 16 FIR Design
13/28
13
BPF with
0 = 0.6, 1 = /6, m = 100
8/9/2019 Lecture 16 FIR Design
14/28
14
Design an FIR HPF
n = -10:10;
h = (1./
(pi.*n)).*(sin(2*pi/3.*n)).*(cos(pi.*n));
h(11) = 2/3;
figure, stem(h)
a = 1;
figure, freqz(h, a)
8/9/2019 Lecture 16 FIR Design
15/28
15
HPF with
1 = /3, m = 10
8/9/2019 Lecture 16 FIR Design
16/28
16
Improving FIR Filter Look again at LPF results
What would we really like to see? Wheredoes this problem come from?
8/9/2019 Lecture 16 FIR Design
17/28
17
Improving FIR Filter: Ideal vs Real
Ideal LPF
Real LPF
How do we improve?
8/9/2019 Lecture 16 FIR Design
18/28
18
Types of windows
What if a more gradual window is used? Triangle:
Von Hann (aka: the raised cosine window)
Hamming Window (an improved Von Hann Window)
8/9/2019 Lecture 16 FIR Design
19/28
19
ExampleDesign a 51-term FIR LPF with 1=0.3
Using a rectangular window:
h[n] =
h[0] =
8/9/2019 Lecture 16 FIR Design
20/28
20
Rectangular Window
8/9/2019 Lecture 16 FIR Design
21/28
21
Using a Triangular window
h[n] =
h[n] =
ExampleDesign a 51-term FIR LPF with 1=0.3
8/9/2019 Lecture 16 FIR Design
22/28
22
Triangular Window
8/9/2019 Lecture 16 FIR Design
23/28
23
Using a Von Hann window
h[n] =
h[n] =
ExampleDesign a 51-term FIR LPF with 1=0.3
8/9/2019 Lecture 16 FIR Design
24/28
24
Von Hann Window
8/9/2019 Lecture 16 FIR Design
25/28
25
Using a Hamming window
h[n] =
h[n] =
ExampleDesign a 51-term FIR LPF with 1=0.3
8/9/2019 Lecture 16 FIR Design
26/28
26
Hamming Window
8/9/2019 Lecture 16 FIR Design
27/28
27
Closer comparison
8/9/2019 Lecture 16 FIR Design
28/28
28
Log Comparison