Professional Documents
Culture Documents
FIR and IIR Filter Design & FIR and IIR Filter Design & Implementation Structures P
FIR and IIR Filter Design & FIR and IIR Filter Design & Implementation Structures P
Implementation
p Structures
Wonyong Sung
2 x 1.5 hrs
School of Electrical Engineering
Seoul National University
Algorithm considerations for system design
Performance in terms of signal processing
FIR is better in terms of phase linearity when
Wonyong Sung
Multimedia Systems Lab SNU
Digital and Analog Filters
Wonyong Sung
Multimedia Systems Lab SNU
Types of Digital Filters
Usages:
Low pass: anti-aliasing,
smoothing, noise
reduction
|H(ejω)| Low pass
High
g p pass: DC removal,,
baseline wander reduction
ω
π Band pass: noise
reduction
High pass Design:
|H(ejω)|
Choose FIR or IIR filter
coefficients to
ω approximate desired
π
frequency response.
Band pass Usually the designed filter
|H(ejω)| coefficients are not
unique! Leaving large
ω design space to be
π
explored. Passband,
stopband ripples. Wonyong Sung
Multimedia Systems Lab SNU
Filter design and implementation
Wonyong Sung
Multimedia Systems Lab SNU
Digital filter specifications
Wonyong Sung
Multimedia Systems Lab SNU
Digital
g filter specifications
p
Wonyong Sung
Multimedia Systems Lab SNU
Digital filter specifications
Wonyong Sung
Multimedia Systems Lab SNU
Digital filter specifications
Minimum
Mi i stopband
t b d attenuation
tt ti
α s = − 20 log10 (δ s ) dB
Wonyong Sung
Multimedia Systems Lab SNU
FIR, IIR digital filters
quantization error
Wonyong Sung
Multimedia Systems Lab SNU
FIR filters
Direct form structure, which has
a form of convolution, is usually
used. Cascade or parallel forms
are a little bit complex in terms of
structure. The quantization
effects of direct form FIR filters
are still
till tolerable,
t l bl in i mostt cases.
Symmetric coefficients FIR
Linear p phase: critical for image
g
processing
Halve the # of multiplications
Filter design
Windowing
Wonyong Sung
Multimedia Systems Lab SNU
Linear phase filter - symmetric FIR
h(n) = h(-n)
Evaluate the frequency
response (assuming that N is
odd) and h(n) is real-valued h(n)
(N=7)
N -1
n2 2
H(z) = ∑h(n) z -n = ∑h(n) z -n
n = n1 N -1
n =-
2
n
The frequency
q y response
p is real: pphase shift is 0 or 180 degrees
g
Wonyong Sung
Multimedia Systems Lab SNU
Linear-phase type 1
Wonyong Sung
Multimedia Systems Lab SNU
Needed number of coefficients
2 1 Fs
Ne = log[ ]
3 10 Dpass Dstop Fstop - Fpass
9Independent
p of BW ((Fpass))!
9Weak (logarithmic) dependence on the
Pass band ripple level and the Stop band
attenuation
i
9Linear dependence on the transition band!
• Our
O example:l Ne
N = 29 ((compared d tto 31)
• Problem: Very narrow filters -> Decimating
Wonyong Sung
Multimedia Systems Lab SNU
Example
Wonyong Sung
Multimedia Systems Lab SNU
FIR filter design
Signal Processing
Toolkit of MATLAB
Define the frequency
response template.
Case of LPF:
9 Pass band End Fpass
9 Pass band Ripple
Dpass
9 Stop band Start Fstop
t
9 Stop band
Attenuation Dstop
Wonyong Sung
Multimedia Systems Lab SNU
Design of Equiripple
Linear--Phase FIR Filters
Linear
The linear-phase FIR filter obtained by
minimizing the peak absolute value of
ε = max E (ω )
ω ∈ R equiripple FIR filter
is usually called the
After is minimized, the weighted error
function E(ω) exhibits an equiripple
ε in the frequency range R
behavior
19
Design of Equiripple
Linear--Phase FIR Filters
Linear
The general form of frequency response of
a causal linear-phase FIR filter of length
2M+1: jω − jMω jβ (
H (e ) = e e H (ω)
(
where the amplitude response H (ω) is a
real function of ω
Weighted error function is given by
(
E (ω) = W (ω)[ H (ω) − D (ω)]
where D (ω) is the desired amplitude
response
spo s and d W (ω) iss a positive
pos weighting
g g
function
20
Design of Equiripple
Linear
Linear--Phase FIR Filters
21
Design of Equiripple
Linear-
Linear-Phase FIR Filters
Thus, weighting function can be chosen
either as
⎧ 1, in the ppassband
W (ω) = ⎨
⎩δ p / δ s , in the stopband
or
⎧δ s / δ p , in the passband
W (ω) = ⎨
⎩ 1, in the stopband
22
Example 1: Equiripple LP FIR (1)
LPF example:
9 Pass band End Fpass =
0.1
9 Pass band Ripple
Dpass=0.05 (5%)
9 Stop band Start Fstop=
0.13
9 Stop band Attenuation
Dstop = 0.1
0 1 (1/10)
Minimum of 31 coefficients
needed to achieved
required specifications
Even-symmetric impulse
response
Wonyong Sung
Multimedia Systems Lab SNU
Example 1: Equiripple LP FIR (3)
Pole-Zero plot in the
z-plane
FIR -> pole
l att zero
(causal)
Location of zeros:
9 On the unit circle in
the Stop band
9 Far from unit circle
in Pass band ->
ripples
Wonyong Sung
Multimedia Systems Lab SNU
FDAtool FIR design example
Wonyong Sung
Multimedia Systems Lab SNU
Edit, Convert Structure …
Wonyong Sung
Multimedia Systems Lab SNU
MATLAB example 1
N = 80; k = 0:(N-1);
MATLAB filter
b0 = 1; command
b1 = -1; corresponds to
b2 = 1; the symbol Φ
B = [b0 b1 b2];
f = 1/8;
x = sin(2*pi*f*k+pi/6);
y = filter(B,1,x);
subplot(2,1,1)
systemFIR(0,0,4,5,10,'b')
subplot(2,1,2)
plot(k,x,'go', k,y,'bo',...
k x 'g-'
k,x, g- , k,y,
k y 'b-')
b- )
legend('input','output')
Wonyong Sung
Multimedia Systems Lab SNU
IIR or recursive filter
The
Th poles l should
h ld bbe inside
i id off theh uniti circle
i l
in the z-domain for stability
Finite word-length
word length effects can affect
Direct forms are more susceptible.
Usually,
U ll theth order
d needed
d d isi smaller
ll when
h
compared to FIR filters
Direct forms are not good fixed-point
fixed point
implementations
2nd order cascade,
cascade …
Wonyong Sung
Multimedia Systems Lab SNU
MATLAB example 3
N = 80; k = 0:(N-1);
a = 0.97;
B = [0 1]; The impulse response
A = [1 -a]; does not vanish after
x = (k==0);
(k 0) finite number of
samples
y = filter(B,A,x);
p ( , , )
subplot(3,1,1)
draw1stIIR(0,0,4,5,10,'b')
subplot(3,1,2)
( , , )
stem(k,x,'r')
ylabel('input')
subplot(3,1,3)
( ,y, )
stem(k,y,'b')
ylabel('output')
Wonyong Sung
Multimedia Systems Lab SNU
Basic 2nd Order IIR Structures
P
Parallel
ll l realization
li ti
P1
μi P 2
ν k + ρ k z −1
⎛ P1 ⎞ H ( z) = ∑ +∑
A( z ) = ⎜ ∏ (1 − α i z −1 ) ⎟ i =1 1 − α i z k =1 1 − 2rk cos β k z
−1 −1
+ rk2 z −2
⎝ i =1 ⎠
⎛ P2 ⎞
⋅ ⎜ ∏ (1 − 2rk cos β k z −1 + rk2 z −2 ) ⎟
⎝ k =1 ⎠
⎛ P1 ⎞ ⎛ P2 ⎞
= ⎜ ∏ Ai ( z ) ⎟ ⋅ ⎜ ∏ Ak ( z ) ⎟
⎝ i =1
P = P1 + P2
⎠ ⎝ k =1 ⎠ +
Wonyong Sung
Multimedia Systems Lab SNU
2nd-order Sections
Generally implement high-order IIR filters as a sum or
cascade of 2nd-order filters to reduce the sensitivity of
the overall response to the precision of each coefficient
High-order polynomial is factored to find poles and
zeros, and each 2nd-order filter (biquad) implements
two zeros and two poles (real or complex conjugate)
Poles and zeros are grouped in pairs—usually try to
group in such a way that minimizes peak gain of each
section
If cascaded, 2nd-order sections are usually ordered from
lowest gain to highest gain to minimize overflow
likelihood
Scaling may be needed for overall response or for each
section individually (computation vs. quality)
b0 + b1 z −1 + b2 z −2
H ( z) =
1 + a1 z −1 + a 2 z −2
Wonyong Sung
Multimedia Systems Lab SNU
Pole-zero pairing
Wonyong Sung
Multimedia Systems Lab SNU
Implementation Issues
Coefficient quantization
Due to limited coefficients word
word-length.
length.
This affects the frequency response.
Quantization of coefficients
Q z-1
−a(1) b(1)
w(n-1)
z-1
−a(2) b(2)
w(n-2)
Wonyong Sung
Multimedia Systems Lab SNU
Engineering an IIR filter
Wonyong Sung
Multimedia Systems Lab SNU
Cascade direct form II
Wonyong Sung
Multimedia Systems Lab SNU
Comparison of the complexity of different IIR
filters
Wonyong Sung
From: Miodrag Bolic Multimedia Systems Lab SNU
Further reading
Integrator
H(z) = 1/1-z
1/1 z-1
Integrator has a pole at z=1,
so it is a kind of lowpass filter
with no multiplier.
multiplier Should be
careful for overflow due to
DC accumulation. x[n] y[n]
Moving average (MA) filter
H(z) = (1-z-N)/(1-z-1)
MA filter has many zeroes
Feed-forward type:
Higher number of x[n] z-1 z-1 z-1
arithmetic operations
y[n]
Better
ette stability
stab ty
Feed-back type: z-N
x[n]
Lower number of
y[n]
[ ]
arithmetic operations
z-1
Should be careful
against overflows
Specifications/performance goals
Filter structures
Direct, parallel, cascade …
Numerical properties (floating point/fixed point, etc.)
Wonyong Sung
Multimedia Systems Lab SNU
Interpolation, Decimation, Narrow band,
Multi-band filters
These filters are widely used for
communication especially
communication,
modulation/demodulation
The filter lengths can be very long because
of narrowband filtering
Assume decimation by 1:10
The passband needs to be less than 1/10 pi.
The p
practical transition bandwidth would be
around 1/50 ~ 1/100 pi. Long FIR filter
What if the decimation ratio is 1:100
Wonyong Sung
Multimedia Systems Lab SNU
Interpolation filter
Wonyong Sung
Multimedia Systems Lab SNU
Here's an example of a 12-tap FIR filter that implements
i
interpolation
l i b by a ffactor off ffour. Th
The coefficients
ffi i are h0
h0-h11,
h11 and
d
three data samples, x0-x2 (with the newest, x2, on the left) have
made their way into the filter's delay line:
x2 0 0 0 x1 0 0 0 x0 0 0 0 x2·h0+x1·h4+x0·h8
0 x2 0 0 0 x1 0 0 0 x0 0 0 x2·h1+x1·h5+x0·h9
0 0 x2 0 0 0 x1 0 0 0 x0 0 x2·h2+x1·h6+x0·h10
0 0 0 x2 0 0 0 x1 0 0 0 x0 x2·h3+x1·h7+x0·h11
Wonyong Sung
Multimedia Systems Lab SNU
Decimation (Sample rate reduction)
Conduct lowpass filtering (pi/N).
Among N output samples, select only one. So, we
do not need to compute N N-11 output samples.
(This is not possible for recursive filters because of
feedback!)
Wonyong Sung
Multimedia Systems Lab SNU
FIR filter implementation for decimation,
interpolation
p
For interpolation: (N-1) among N input
values at the tap are zero! No need to
conduct multiplications
For decimation: We only need to compute 1
output sample at every N output.
It is interpreted as polyphase filter with
the tap length of about M/N.
Wonyong Sung
Multimedia Systems Lab SNU
FIR filtering for narrowband signal
Wonyong Sung
Multimedia Systems Lab SNU
Narrow bandpass filtering
This makes
Thi k a narrow band
b d filter,
filt but
b t there
th exist
i t
unwanted harmonic bands
2nd stage eliminates harmonic bands
Wonyong Sung
Multimedia Systems Lab SNU
ifir - Interpolated FIR filter from filter
specification
Wonyong Sung
Multimedia Systems Lab SNU
Example with SSB generation
Wonyong Sung
Multimedia Systems Lab SNU
Quantization error, stability, overflow
An IIR filter is BIBO
stable if all the poles of Overflow
its transfer function H(z) Dynamic
y range
g of
lie within the unit circle intermediate results
in z-plane. must be bounded.
A stable IIR digital filter Otherwise, overflow
Wonyong Sung
Multimedia Systems Lab SNU