Filtering Problem ] [ n s ] [ n v ] [ n x ] [ ] [ n s n y Filte r SIGNAL NOISE Goal : design a filter to attenuate the disturbances
Feb 13, 2016
Filtering Problem
][ns
][nv
][nx ][][ nsny Filter
SIGNAL
NOISE
Goal: design a filter to attenuate the disturbances
Define Signal and Noise in the Frequency Domain
][ns
][nv
][nx
][][ nsny Filter
SIGNALNOISE
Mostly SIGNAL
n nn
|)(| S|)(| V
)(rad 0
SIGNALNOISE
P
Mostly NOISEMostly NOISE
P
IDEAL Filter
Since the filter has real coefficients, we need only the positive frequencies
)(H
p PASS Band
STOP Band
Non-IDEAL Filter
Since the filter has real coefficients, we need only the positive frequencies
PASS Band
STOP Bandp S
Trans. Band
|)(| H
Design a Low Pass Filter: IDEAL
First we can determine an infinite length expansion using the DTFT:
n
njddd enhnhDTFTH ][][)(
deHHIDTFTnh njddd )(
21)(][
nn
ndenh PPPnjd
P
P
sincsin21][
PP
Hd ( )
1
Design a Low Pass Filter: IDEAL (continued)
nnh PP
d
sinc][This means the following. If
then
n
njdd enhH ][)(
PP
Hd ( ) 1
-60 -40 -20 0 20 40 60-0.1
-0.05
0
0.05
0.1
0.15
0.2
0.25
0.3
][nhd
n
From IDEAL to FIR
0][lim
nhdnNotice that
Then we can approximate with a finite sum…
L
Ln
njdd enhH ][)(
desiredactual
… and choose the filter as ][][ Lnhnh d
Ljd
LjL
Ln
njd
L
n
njd
L
n
nj eHeenheLnhenhH
)(][][][)(
2
0
2
0
Summary of design of Low Pass FIR
Given the Pass Band Frequency
The impulse response of the filter: let
P0
NnLnnh PP ,...,0,)(sinc][
LN 2
Magnitude and Phase:
Ljd
L
n
nj eHenhH
)(][)(2
0
)()(
)()(
LLHH
HH
d
d
Magnitude:Phase:
in the passband
Example of Freq. Response
4/ P 40,20 NL
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1500
-1000
-500
0
Normalized Frequency ( rad/sample)
Pha
se (d
egre
es)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100
-50
0
50
Normalized Frequency ( rad/sample)
Mag
nitu
de (d
B)
dB20
n=0:N; h=(wp/pi)*sinc((wp/pi)*(n-L)); freqz(h)
20
Impulse Response
0 5 10 15 20 25 30 35 40-0.1
-0.05
0
0.05
0.1
0.15
0.2
0.25
0.3][nh
n=0:N;
stem(n,h)
Example with Hamming window
][nh
0 5 10 15 20 25 30 35 40-0.05
0
0.05
0.1
0.15
0.2
0.25
0.3
40,...,0,40
2cos46.054.0)20(41sinc
41][
nnnnh
n=0:N;
h0=(wp/pi)*sinc((wp/pi)*(n-L));
h=h0.*hamming(N);
stem(n,h)
hamming window
Example with Hamming window
40,...,0,40
2cos46.054.0)20(41sinc
41][
nnnnh
hamming window
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1500
-1000
-500
0
Normalized Frequency ( rad/sample)
Pha
se (d
egre
es)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-150
-100
-50
0
50
Normalized Frequency ( rad/sample)
Mag
nitu
de (d
B)
)(Hfreqz(h)~ 50dB
Low Pass Filter Design: Analytical
Transition Region: depends on the window and the filter length NAttenuation: depends on window only
0 0.5 1 1.5 2 2.5 3-120
-100
-80
-60
-40
-20
0
20
attenuation
transition region
Rectangular -13dB
Hamming -43dB
Blackman -58dB
N/4N/8
N/12
nattenuatio
P S
window
Specs: Pass Band 0 - 4 kHz
Stop Band > 5kHz with attenuation of at least 40dB
Sampling Frequency 20kHz
Step 1: translate specifications into digital frequency
Pass Band
Stop Band rad 2/20/52
rad5/220/420
10
40dB
F kHz54 10
225
Step 2: from pass band, determine ideal filter impulse response
52sinc
52sinc)( nnnh PP
d
Example of Low Pass Filter Design
Step 3: from desired attenuation choose the window. In this case we can choose the hamming window;
Step 4: from the transition region choose the length N of the impulse response. Choose an even number N such that:
10
8
N
So choose N=80 which yields the shift L=40.
Example of Low Pass Filter Design (continued)
Finally the impulse response of the filter
h nn
n( )
. . cos , ,
25
0 54 0 46280
0 80sinc2(n - 40)
5 if
0 otherwise
Example of Low Pass Filter Design (continued)
The Frequency Response of the Filter:
H( )
H( )
dB
rad
Example of Low Pass Filter Design (continued)
Design Parameters
Pass Band Frequency rad.
Stop Band Frequency rad.
Pass Band Ripple dB
Stop Band Attenuation dB
p
S
BA /log20 10
CA /log20 10
AB
C
p S
)(H
Best Design tool for FIR Filters: the Equiripple algorithm. It minimizes the maximum error between the frequency responses of the ideal and actual filter.
Computer Aided Design of FIR Filters
PASS STOP
Linear Interpolation
1
0 )(rad
Step 1: define the desired filter with pairs of frequencies and values. For a Low Pass Filter:
f=[0, f1, f2, 1];
A=[1, 1, 0, 0]; πω
πω
STOP
PASS
2 f
1 fwhere
Computer Aided Design of FIR Filters
Step 3: call “firpm” (pm = Parks, McClellan)
h = firpm(N, f, A);
which yields the desired impulse response
][]1[],0[ Nhhhh
Step 2: Choose filter length N from desired attenuation as
/11(dB)n Attenuatio~
PASSSTOP
N
Passband: 3kHz
Stopband: 3.5kHz
Attenuation: 60dB
Sampling Freq: 15 kHz
Example: Low Pass Filter
Then compute:
8211
60157
000,15500,32
52
000,15000,32
52
157
N
STOP
PASS
h = firpm(82,[0,2/5,7/15,1], [1,1,0,0]);
Frequency Response
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4000
-3000
-2000
-1000
0
Normalized Frequency ( rad/sample)
Pha
se (d
egre
es)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100
-50
0
50
Normalized Frequency ( rad/sample)
Mag
nitu
de (d
B)
freqz(h)
50dB, not quite yet!
Increase N.
Increase Filter Length N
h=firpm(95, [0, 2/5, 7/15, 1], [1,1,0,0]);
freqz(h)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4000
-3000
-2000
-1000
0
Normalized Frequency ( rad/sample)
Pha
se (d
egre
es)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100
-50
0
50
Normalized Frequency ( rad/sample)
Mag
nitu
de (d
B)
Impulse Response of Example
stem(h)
0 10 20 30 40 50 60 70 80 90 100-0.1
0
0.1
0.2
0.3
0.4
0.5
0.6
In applications such as Radar, Sonar or Digital Communications we transmit a Pulse or a sequence of pulses.
For example, we transmit a short sinusoidal burst:
Typical Applications
10 0),2sin()( TttFAtx
0 1 2 3 4 5 6 7 8
x 10-3
-2
-1.5
-1
-0.5
0
0.5
1
1.5
2
sec
sec8500
1
0
mTHzF
For example in a communications signal we send “0” and “1”.
For example let:
Typical Applications
)(0)(1tx
tx
0 0.005 0.01 0.015 0.02 0.025 0.03-4
-3
-2
-1
0
1
2
3
4
millisec
1 0 1 0
Transmitted:
Suppose you receive the signal with 0dB SNR:
Received Signal with Noise
0 0.005 0.01 0.015 0.02 0.025 0.03-8
-6
-4
-2
0
2
4
6
8
millisec
Magnitude of the DFT of the Pulse (in dB):
DTFT of Signal
0 1000 2000 3000 4000 5000 6000 7000 8000 9000-50
-40
-30
-20
-10
0
10
20
30
40
50
dB
Hz
Bandwidth of the Signal (take about -20dB from max) is about 1.0kHz
DTFT of Signal
0 1000 2000 3000 4000 5000 6000 7000 8000 9000-50
-40
-30
-20
-10
0
10
20
30
40
50
dB20~
Pass 0 to 1kHz;
Stop 1.5kHz to 10.0kHz
Sampling Freq 20.0kHz
Attenuation 40dB
N=81
Design the Low Pass Filter
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1500
-1000
-500
0
Normalized Frequency ( rad/sample)
Pha
se (d
egre
es)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100
-50
0
50
Normalized Frequency ( rad/sample)M
agni
tude
(dB
)
Filtered Data
Received signal:
… and Filtered:
0 0.005 0.01 0.015 0.02 0.025 0.03-4
-3
-2
-1
0
1
2
3
4
millisec
Compare to the original:
0 5 10 15 20 25 30 35 40-4
-2
0
2
4
millisec
0 5 10 15 20 25 30 35-10
-5
0
5
10
millisec