Dsp Using Matlab® - 8
-
Upload
api-3721164 -
Category
Documents
-
view
151 -
download
22
Transcript of Dsp Using Matlab® - 8
Lecture 8: Digital Filter Structures and Filter Toolbox
Mr. Iskandar Yahya
Prof. Dr. Salina A. Samad
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
IGNORE
THIS
SLIDE
IIR Filter StructuresSystem function of IIR filter:
an and bn are coefficients and the order is N if aN ≠ 0.
The difference equation representation of IIR filters:
IGNORE
THIS
SLIDE
IIR Filter Structures3 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.
Parallel Form – Similar to cascade form, but use partial fraction to represent the system function.
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 samplesthat can be represented as
))(()( kxy
Review………MATLAB example 1:
N = 80; k = 0:(N-1);
b0 = 1;
b1 = -1;
b2 = 1;
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,y,'b-')
legend('input','output')
MATLAB filter command
corresponds to the symbol
)2()1()()( 210 nxbnxbnxbny )2()1()()( 210 nxbnxbnxbny
))(()( kxny
Review………Impulse response:
Response of a system to the unit impulse sequence is called the unit impulse response or impulse response for short
))(()( knh ))(()( knh
Review………MATLAB example 2:N = 16; k = 0:(N-1);
b0 = 1;b1 = -1;b2 = 2;
B = [b0 b1 b2];
x = (k==0);
y = filter(B,1,x);
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')
)2()1()()( 210 nxbnxbnxbny )2()1()()( 210 nxbnxbnxbny
))(()( knh ))(()( knh
FIR and IIR Filters and SystemWhat 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 SystemMATLAB example 3:N = 80; k = 0:(N-1);
a = 0.97;
B = [0 1];
A = [1 -a];
x = (k==0);
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')
)1()1()( naynxny )1()1()( naynxny
The impulse response does not vanish after
finite number of samples
Basic FIR structuresDirect form, Transposed form, Cascade form,
Linear-phase, Symmetric
Direct form 2nd order
Basic FIR structuresTransposed direct form 2nd order
Basic FIR structuresCascade direct form
Basic FIR structuresDirect form (Tapped delay line)
Basic FIR structuresTransposed direct form
Basic FIR structuresLinear-phase type 1
Basic FIR structuresLinear-phase type 2
Basic FIR structuresSymmetric FIR type I
Basic FIR structuresSymmetric FIR type II
Basic IIR structuresDirect form, Transposed form
Direct form I 2nd order
Basic IIR structuresDirect form I 2nd order
Basic IIR structuresDirect form II 2nd order
Basic IIR structuresCascade direct form II
Basic IIR structuresTransposed direct form II 1st order
Basic IIR structuresTransposed direct form II 2nd order
Simple FIR design example4th order linear-phase filter
Simple FIR design exampleFile, Export …
Simple FIR design exampleEdit, Convert Structure …
Simple FIR example designs
Classical digital filter design
Overview:SpecificationStep 1: Approximation - Select Chebyshev Type
IStep 2: Realization - Cascade of biquadsStep 3: Study of imperfections - QuantizationsRedo design steps
Step 1: Approximation Step 2: Realization Step 3: Study of imperfections
Step 4: Implementation
Classical digital filter designStart with specification:
Classical digital filter designStart with specification:
Classical digital filter designStep 1: Approximation; Select Chebyshev
Type I
Classical digital filter designExport coefficients: File, Export
Classical digital filter designStep 2: Realization; Direct-form II biquads
Classical digital filter designStep 3: Study of imperfections:
Quantization The spec is violated!
Classical digital filter designRedo step 1: Approximation, Increase
order
Classical digital filter designRedo step 3: Study of imperfections
(Quantization) The spec is OK
Classical digital filter designStep 4: Implementation as a C header file
Digital filters: FIR filter designOverview
FIR filtersDesign techniquesFIR filter design
using Filter Design Toolbox
Digital filters: FIR filter designFIR 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 designDesign of FIR filters
Windowing techniquesEquiripple FIR filtersLeast squares and related techniquesLinear programming (LP) and mixed integer
linear programming (MILP)Computationally efficient FIR filters using
periodic subfilters as building blocks
Digital filters: FIR filter designWindowing techniques
One of the earliest design techniquesCoefficients can be obtained in
closed formThere is no need for solving complex
optimization problemsMost frequently used window functions are
Bartlett, Hann, Hamming, Blackman, and Kaiser
Windows
Digital filters: FIR filter designFilter 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 designEquiripple FIR filtersDesign 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 error function
Equiripple
remez designs a linear-phase FIR filter using the Parks-McClellan algorithm
Constrained Equiripplefirceqrip
Digital filters: FIR filter design
Least squares and related techniquesBased 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
Maximally flatSymmetric FIR Butterworth filter (maxflat)
Advanced digital filter design
Overview:Drawback of the classic designAdvanced design paradigmAFDesign toolboxExample design
Advanced digital filter design
Drawback of the classic designThe principal drawback of the classical digital
filter design is in returning only one solutionThat solution can be unacceptable for many
practical implementationsAdvanced approach provides
reduced filter complexity for the desired performance
better performances for the required complexity
Advanced digital filter design
Advanced design paradigmAdvanced 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 1Design a lowpass filter that satisfies the
following specification:Fp = 1600 HzFs = 1696 HzAp = 0.2 dBAs = 40 dBFsamp = 8 kHzGoal: Optimize group delay
Advanced digital filter design
Classic design
Fp = 1600; Fs = 1696;
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)));
Gdmax is over 100
Advanced digital filter designAdvanced design: AFDesign
Gdmax has been reduced to 70
Advanced digital filter designDesign parameters
Design parameters
D = {n, , , fp}
Filter order n
Selectivity factor
Ripple factor
Actual passband edge fp
Advanced digital filter designDesign 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 designDesign 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 designDesign 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 designDesign 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 designDesign 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 designDesign 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 designGroup delay
The maximum delay is obtained for D3a and D3b, while D4a and D4b have lower group-delay variation.
Advanced digital filter designAFDesign: D5 – minimal Q-factor
Gdmax has been reduced to 60
Advanced digital filter designAFDesign: Bandpass