Digital Signal Processing FIR Filter Design: Marc Moonen Dept. E.E./ESAT, K.U.Leuven
Digital Signal Processing FIR Filter Design: Marc Moonen Dept. E.E./ESAT, K.U.Leuven
Digital Signal Processing FIR Filter Design: Marc Moonen Dept. E.E./ESAT, K.U.Leuven
DSP-II
p. 1
FIR filters
Direct form, Lattice, Linear-phase filters
y[k]
Linear :
input u1[k] -> output y1[k]
input u2[k] -> output y2[k]
hence input a.u1[k]+b.u2[k]-> a.y1[k]+b.y2[k]
Time-invariant (shift-invariant)
input u[k] -> output y[k]
hence input u[k-T] -> output y[k-T]
Causal systems:
for all input u[k]=0, k<0 -> output y[k]=0, k<0
Impulse response :
input 1,0,0,0,... -> output h[0],h[1],h[2],h[3],...
input u[0],u[1],u[2],u[3] -> output y[0],y[1],y[2],y[3],...
= `convolution
y[k]
y[0],y[1],...
0
0
y[0] h[0] 0
y[1] h[1] h[0] 0
y
[
3
]
0
h
[
2
]
h
[
1
]
h
[
0
]
y[4] 0
0
h[2] h[1]
0
0
h[2]
y[5] 0
h[0],h[1],h[2],0,0,...
u[0]
u[1]
.
u[2]
u
[
3
]
`Toeplitz matrix
y[0]
y[1]
y[2]
1
2
3
4
5
1 z 1 z 2 z 3 z 4 z 5 .
1
z
z
z
z
z
.
y
[
3
]
y[4]
y[5]
Y ( z)
H ( z).1 z1
Y ( z ) H ( z ).U ( z )
0
h[1] h[0]
0
0
h[2] h[1] h[0]
0
.
0
h[2] h[1] h[0]
0
0
h[2] h[1]
0
0
0
h[2]
h[0]
z2
z3
u[0]
u[1]
u[ 2]
u[3]
Y ( z ) H ( z ).U ( z )
stability
bounded input u[k] -> bounded output y[k]
--iff
h[k ]
k
u[k ] e
jk
, k
H (e )
is `frequency response
is H(z) evaluated on the unit circle
H
(
e
)
Phase response
example :
1
-2
-2
e jk ...,1,1,1,1,1,...
4
0
-5
-4
is odd function
Nyquist frequency
0.5
0
-4
is even
high-pass (HP)
band-pass (BP)
band-stop
multi-band
1
N
B ( z ) b0 b1 z ... bN z
H ( z)
1
N
A( z ) 1 a1 z ... a N z
H ( z ) B ( z ) b0 b1 z ... bN z N
impulse response
h[0] b0 , h[1] b1 ,..., h[ N ] bN , h[ N 1] 0,...
H ( z ) B ( z ) b0 b1 z ... bN z
`direct-form
realization
u[k]
u[k-1]
bo
u[k-2] u[k-3]
b1
b2
u[k-4]
b3
b4
y[k]
u[k-1]
bo
u[k-2] u[k-3]
b1
b2
u[k-4]
b3
b4
y[k]
u[k]
u[k-1]
u[k-2]
bo
b1
b2
y[k]
u[k-3]
b3
b4
b1
x
y[k]
+
b2
x
b3
x
b4
x
bo x
y[k]
y[k]
u[k-1]
u[k-2]
u[k-3]
u[k-4]
b1 x
b2 x
b3 x
b4 x
x b3
x b2
x b4
x b1
x bo
+
+
+
+
+
+
y[k]
bo x
+
x
ko
y[k]
x
+
proof)
u[k-1]
u[k-2]
u[k-3]
u[k-4]
b1 x
b2 x
b3 x
0 x
x b3
x b2
x 0
x b1
x bo
+
+
k0
+
+
+
+
b4 '
, b0 b0 , b1' ..., b2' ..., b3' ...,
b0
+
(=simple
y[k]
bo x
+
x
ko
y[k]
x
+
u[k-2]
u[k-2]
u[k-3]
b1 x
b2 x
b3 x
x b3
x b2
x b1
x bo
+
+
+
+
y[k]
k4
+
+
x
+
x
ko
y[k]
u[k]
x
k2
k1
k3
frequency response is
L
H (e ) h[k ].e
... a[k ]. cos( .k )
L
k 0
- real-valuedk (=zero-phase)
transfer
function
j
j . k
H (e ) h[k ].e
j
k 0
j . k
... e
j L
. a[k ]. cos( .k )
k 0
e
introducing (group) delay
j
z e
j N / 2
Type-2
N=2L+1=odd
anti-symmetric
h[k]=-h[N-k]
. a[k ]. cos( .k )
k 0
LP/HP/BP
jN / 2
Type-2
N=2L=even
symmetric
h[k]=h[N-k]
Type-4
N=2L+1=odd
anti-symmetric
h[k]=-h[N-k]
L 1
L
L
jN / 2
j N / 2
sin( ). a[k ]. cos( .k )
cos( ). a[k ]. cos( .k ) e
sin( ). a[ k ]. cos( .k ) j.e
2 k 0
2 k 0
k 0
zero at
LP/BP
zero at 0,
zero at 0
HP
u[k]
y[k]
b1 b2 b3 b4
x
x
x
x
x
+
. a[ k ]. cos( .k ) e
. A( )
k 0
e.g.: LP
Ad ( ) 1, P
( P passband edge)
Ad ( ) 0, S
( S stopband edge)
optimization criterion is
F (a0 ,..., aL ) W ( ) H (e j ) H d ( ) d W ( ) A( ) Ad ( ) d
a1 ... a L
Q W ( ).c( ).cT ( )d
0
b W ( ). Ad ( ).c( )d
0
(passband edge)
Ad ( ) 0, S
(stopband edge)
optimization criterion is
F (a0 ,..., aL )
A( ) 1 d . A2 ( )d xT .Q.x 2 xT .b
2
( P is passband ripple)
1 P
Passband Ripple
0.8
P S
0.6
0.4
Stopband Ripple
0.2
0
0
0.5
1.5
2.5
1
C
H d ( )
0 C
1
hd [k ]
2
sin(c k )
H d (e ).e d ... . c k
j
j k
hd [ k ]
h[ k ]
0
N /2 k N /2
otherwise
h[k ] hd [k ].w[k ]
1
w[k ]
0
N /2 k N /2
otherwise
h[k ] hd [k ].w[k ]
H ( z ) H d ( z ) *W ( z )
candidate windows : Han, Hamming, Blackman, Kaiser,. (see
textbooks, see DSP-I)
window choice/design = trade-off between side-lobe levels (define
peak pass-/stop-band ripple) and width main-lobe (defines transition
bandwidth)
Design Procedure
Filter specification.
Coefficient calculation.
Structure selection.
Simulation (optional).
Implementation.
pass-band
stop-band
f c : cut-off frequency
f(norm)
f s /2
(a)
|H(f)|
(dB)
pass-band
transition band
|H(f)|
(linear)
stop-band
1 p
1
1 p
pass-band
ripple
-3
stop-band
ripple
s
f sb : stop-band frequency
f c : cut-off frequency
f pb : pass-band frequency
(b)
f s /2
f(norm)
There are several different methods available, the most popular are:
Window method.
Frequency sampling.
Parks-McClellan.
Window Method
First stage of this method is to calculate the coefficients of the ideal filter.
This is calculated as follows:
hd n
1
2
1
2
H e j n d
1 e j n d
2 fc sin n c
n c
2 fc
for n 0
for n 0
Window Method
Second stage of this method is to select a window function based on the passband or attenuation
specifications, then determine the filter length based on the required width of the transition band.
Normalised Transition
Width (f(Hz))
Passband Ripple(dB)
Stopband Attenuation
(dB)
Rectangular
0.9
N
0.7416
21
Hanning
3.1
N
0.0546
44
Hamming
3.3
N
0.0194
53
Blackman
5.5
N
0.0017
74
0.0274
50
0.000275
90
Window Type
Kaiser
2.93
4.54
N
5.71
8.96
N
3.3
3.3
8kHz 132
f 1.2 1.4 kHz
Window Method
h n hd n W n
Where:
for
N 1
N 1
n
for N odd
2
2
N
N
for N even
n
2
2
2n
W n 0.54 0.46 cos
N
2n
0.54 0.46 cos
133
for
66 n 66
Window Method
close all;
clear all;
fc = 8000/44100;
N = 133;
n = -((N-1)/2):((N-1)/2);
n = n+(n==0)*eps;
% cut-off frequency
% number of taps
[h] = sin(n*2*pi*fc)./(n*pi);
[w] = 0.54 + 0.46*cos(2*pi*n/N);
d = h.*w;
[g,f] = freqz(d,1,512,44100);
figure(1)
plot(f,20*log10(abs(g)));
axis([0 2*10^4 -70 10]);
figure(2);
stem(d);
xlabel('Coefficient number');
ylabel ('Value');
title('Truncated Impulse Response');
figure(3)
freqz(d,1,512,44100);
axis([0 2*10^4 -70 10]);
0.4
Window Method
0.3
0.1
20
40
60
80
Coefficient number
100
120
140
Magnitude (dB)
-0.1
0
-20
-40
-60
0
0.2
0.4
0
Phase (degrees)
Value
0.2
0.6
0.8
1
1.2
Frequency (Hz)
1.4
1.6
1.8
2
4
x 10
-2000
-4000
-6000
0.5
1
Frequency (Hz)
1.5
2
4
x 10
Equiripple Design
Starting point is minimax criterion, e.g.
Software
FIR Filter design abundantly available in
commercial software
Matlab:
b=fir1(n,Wn,type,window), windowed linear-phase FIR
design, n is filter order, Wn defines band-edges, type is
`high,`stop,
b=fir2(n,f,m,window), windowed FIR design based on
inverse fourier transform with frequency points f and
corresponding magnitude response m
b=remez(n,f,m), equiripple linear-phase FIR design with
Parks-McClellan (Remez exchange) algorithm