You are on page 1of 74

Lecture 8: Digital Filter Structures and Filter

Toolbox

Prof. Dr. Salina A.


Samad
Mr. Iskandar Yahya
Basic Elements
We need 3 elements for designing digital
filters:
 Adder – 2 input and 1 output. Addition of two signals:
 x1(n), x2(n) x1(n) + x2(n)

 Multiplier – Also called gain.


 x(n) ax(n)

 Delay – Also called shifter or memory. Delays the signal


by one or more samples:
 x(n) x(n -1)

 Using these elements, we can describe various structures


of IIR and FIR filters
IIR Filter Structures
 System function of IIR filter:

 an and bn are coefficients and the order is N if aN ≠ 0.

 The difference equation representation of IIR filters:

O R E
I G N E
S L I D
THI S
IIR Filter Structures
 3 structures to implement an IIR filter:
 Direct Form – According to (2) and have 2 parts, namely
moving average part and recursive part (the numerator and
denominator). There are 2 versions; direct forms 1 and direct
forms 2.

 Cascade Form – System function as in (1) is factored into


biquads and is represented as a product of these biquads. Each
biquad is direct form and entire system is implemented as a
cascade of biquad sections.

O R E
G N
 Parallel Form – Similar to cascade form, but use partial
I E
fraction to represent the system function.
S L I D
THIS
Review………
Discrete-time system:

Discrete-time system has discrete-time


input and output signals
Review………
Linear time-invariant (LTI) system:

 Discrete-time system is LTI if its input-output relationship can


be described by the linear constant coefficients difference
equation

 The output sample y(ν) might depend on all input samples


that can be represented as

y (ν ) = Φ ( x(k ))
Review………
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 (n) = b0 x(n) + b1 x(n − 1) + b2 x(n − 2)
y = filter(B,1,x); y (n) = Φ ( x(k ))
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,y,'b-')
legend('input','output')
Review………
Impulse response:

 Response of a system to the unit impulse sequence is called the


unit impulse response or impulse response for short

h(n) = Φ (δ (k ))
Review………
MATLAB example 2:
N = 16; k = 0:(N-1);
b0 = 1; y (n) = b0 x(n) + b1 x(n − 1) + b2 x(n − 2)
b1 = -1;
b2 = 2;
B = [b0 b1 b2];
x = (k==0);
y = filter(B,1,x); h(n) = Φ (δ (k ))
subplot(3,1,1)
systemFIR(0,0,4,5,10,'b')
subplot(3,1,2)
stem(k,x,'r')
ylabel('input')
subplot(3,1,3)
stem(k,y,'b')
ylabel('output')
FIR and IIR Filters and System
What are FIR and IIR systems?
A discrete system is said to be an FIR system if
its impulse response has zero-valued samples
for n > M > 0
Integer number M is called the
length of the impulse response
IIR system is a discrete system with an infinite
impulse response
FIR = Finite Impulse Response
IIR = Infinite Impulse Response
FIR and IIR Filters and System
MATLAB example 3:
N = 80; k = 0:(N-1); y (n) = x(n − 1) + ay (n − 1)
a = 0.97;
B = [0 1]; The impulse response
A = [1 -a];
does not vanish after
finite number of
x = (k==0); samples
y = filter(B,A,x);
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)
stem(k,y,'b')
ylabel('output')
Basic FIR structures
Direct form, Transposed form, Cascade form,
Linear-phase, Symmetric

Direct form 2nd order


Basic FIR structures
Transposed direct form 2nd order
Basic FIR structures
Cascade direct form
Basic FIR structures
Direct form (Tapped delay line)
Basic FIR structures
Transposed direct form
Basic FIR structures
Linear-phase type 1
Basic FIR structures
Linear-phase type 2
Basic FIR structures
Symmetric FIR type I
Basic FIR structures
Symmetric FIR type II
Basic IIR structures
Direct form, Transposed form

Direct form I 2nd


order
Basic IIR structures
Direct form I 2nd order
Basic IIR structures
Direct form II 2nd order
Basic IIR structures
Cascade direct form II
Basic IIR structures
Transposed direct form II 1st order
Basic IIR structures
Transposed direct form II 2nd order
Simple FIR design example
4th order linear-phase filter
Simple FIR design example
File, Export …
Simple FIR design example
Edit, Convert Structure …
Simple FIR
example designs
Classical digital filter design
Overview:
Specification
Step 1: Approximation - Select Chebyshev Type
I
Step 2: Realization - Cascade of biquads
Step 3: Study of imperfections - Quantizations
Redo design steps
 Step 1: Approximation
 Step 2: Realization
 Step 3: Study of imperfections

Step 4: Implementation
Classical digital filter design
Start with specification:
Classical digital filter design
Start with specification:
Classical digital filter design
Step 1: Approximation; Select Chebyshev
Type I
Classical digital filter design
Export coefficients: File, Export
Classical digital filter design
Step 2: Realization; Direct-form II biquads
Classical digital filter design
Step 3: Study of imperfections:
Quantization The spec is
violated!
Classical digital filter design
Redo step 1: Approximation, Increase
order
Classical digital filter design
Redo step 3: Study of imperfections
(Quantization) The spec is
OK
Classical digital filter design
Step 4: Implementation as a C header file
Digital filters: FIR filter design
Overview
FIR filters
Design techniques
FIR filter design
using Filter Design Toolbox
Digital filters: FIR filter design
FIR filter
FIR filter is characterized by a unit sample
response that has a finite duration
An advantage of FIR filters compared to IIR
counterparts is that FIR filters can be designed
with exactly linear phase
Linear phase is important for applications where
phase distortion due to nonlinear phase can
degrade performance (e.g., data transmission)
Digital filters: FIR filter design
Design of FIR filters
Windowing techniques
Equiripple FIR filters
Least squares and related techniques
Linear programming (LP) and mixed integer
linear programming (MILP)
Computationally efficient FIR filters using
periodic subfilters as building blocks
Digital filters: FIR filter design
Windowing techniques
One of the earliest design techniques
Coefficients can be obtained in
closed form
There is no need for solving complex
optimization problems
Most frequently used window functions are
Bartlett, Hann, Hamming, Blackman, and Kaiser
Windows
Digital filters: FIR filter design
Filter Design Toolbox windows

The main role of


the window is to
damp out the effects
of the Gibbs phenomenon
that results from
truncation of an infinite series.
Kaiser
Hann
Hamming
Blackman
Bartlett
Digital filters: FIR filter design
Equiripple FIR filters
Design of FIR filters can be accomplished through
iterative methods

An iterative method is known as the weighted-


Chebyshev method; an error function is
formulated in terms of linear combination of
cosine functions and is then minimized by using a
very efficient multivariable optimization algorithm
known as the Remez exchange algorithm

When convergence is achieved, the error function


becomes equiripple
Amplitude of the error in different frequency
bands is controlled by applying weighting to the
Equiripple

remez designs a linear-phase FIR filter


using the Parks-McClellan algorithm
Constrained
Equiripple
firceqrip
Digital filters: FIR filter design
Least squares and related techniques
Based on approach of minimizing, in some
specified manner, the mean squared error
between the transfer function of the filter and the
frequency characteristics of a desired filter
response
Four approaches exist: unweighted list squares,
frequency sampling, weighted list squares, and
eigen filter methods
Least
square
linear-
phase

Least square linear-phase FIR filter design


(firls)
Least
Pth-norm
Symmetric FIR Butterworth filter (maxflat) Maximally flat
Advanced digital filter design

Overview:
Drawback of the classic design
Advanced design paradigm
AFDesign toolbox
Example design
Advanced digital filter design

Drawback of the classic design


The principal drawback of the classical digital
filter design is in returning only one solution
That solution can be unacceptable for many
practical implementations
Advanced approach provides
 reduced filter complexity
for the desired performance
 better performances
for the required complexity
Advanced digital filter design

Advanced design paradigm


Advanced digital filter design introduces
straightforward procedures to map the filter
specification into a design space, that is, a set
of ranges for parameters that we use in the
filter design
We search this design space for the optimum
solution according to given criteria, such as
optimized group delay
Advanced digital filter design

Design example 1
Design a lowpass filter that satisfies the
following specification:
Fp = 1600 Hz
Fs = 1696 Hz
Ap = 0.2 dB
As = 40 dB
Fsamp = 8 kHz
Goal: Optimize group delay
Advanced digital filter design
Classic design
Fp = 1600; Fs = 1696; Gdmax is over 100
Ap = 0.2; As = 40;
Fsamp = 8000; Fnyquist = Fsamp/2;
Wp = Fp/Fnyquist;
Ws = Fs/Fnyquist;
[N, Wn] = ellipord(Wp, Ws, Ap, As)
[num,den] = ellip(N, Ap, As, Wn)
[H,f]=freqz(num, den, 512, Fsamp);
[Gd,fGd]=grpdelay(num,den,512,Fsamp);
plot(fGd,Gd);
figure; plot(f,-20*log10(abs(H)));
Advanced digital filter design
Advanced design: AFDesign

Gdmax has been


reduced to 70
Advanced digital filter design
Design parameters
Design parameters Filter order n
Selectivity factor ξ
D = {n, ξ, ε, fp}
Ripple factor ε
Actual passband edge fp
Advanced digital filter design
Design alternative D1

D1 design has higher attenuation in the stopband than is required by


the specification. We choose D1 design when we prefer to achieve
as large an attenuation as possible in the stopband.
Advanced digital filter design
Design alternative D2

D2 design has lower attenuation in the passband than is required by


the specification. We choose this design when we prefer to achieve
as low an attenuation as possible in the passband.
Advanced digital filter design
Design alternative D3a

D3a design has the sharpest magnitude response.


Disadvantages of D3a can be very high Q-factors and large variation
of the group-delay in the passband. This is MATLAB default design.
Advanced digital filter design
Design alternative D3b

D3b design has the sharpest magnitude response.


Disadvantages of D3b can be very high Q-factors. The variation of the group delay
can be high, but its maximal value can be moved into the transition region, so the
group-delay variation can be acceptable in the passband.
Advanced digital filter design
Design alternative D4a

D4a has a smoother magnitude response, and that is the main reason for
lower Q-factors and smaller variation of the group delay in the passband.
Advanced digital filter design
Design alternative D4b

D4b has a smoother magnitude response. D4b usually yields


very low Q-factors and small variation of the group delay in the
passband. D4b has a very low ripple factor.
Advanced digital filter design
Group delay

The maximum delay is obtained for D3a and D3b, while


D4a and D4b have lower group-delay variation.
Advanced digital filter design
AFDesign: D5 – minimal Q-factor

Gdmax has been


reduced to 60
Advanced digital filter design
AFDesign: Bandpass

You might also like