dsp using matlab® - 8
TRANSCRIPT
![Page 1: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/1.jpg)
Lecture 8: Digital Filter Structures and Filter Toolbox
Mr. Iskandar Yahya
Prof. Dr. Salina A. Samad
![Page 2: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/2.jpg)
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
![Page 3: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/3.jpg)
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:
![Page 4: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/4.jpg)
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.
![Page 5: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/5.jpg)
Review………Discrete-time system:
Discrete-time system has discrete-time input and output signals
![Page 6: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/6.jpg)
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
![Page 7: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/7.jpg)
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
![Page 8: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/8.jpg)
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
![Page 9: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/9.jpg)
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
![Page 10: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/10.jpg)
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
![Page 11: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/11.jpg)
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
![Page 12: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/12.jpg)
Basic FIR structuresDirect form, Transposed form, Cascade form,
Linear-phase, Symmetric
Direct form 2nd order
![Page 13: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/13.jpg)
Basic FIR structuresTransposed direct form 2nd order
![Page 14: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/14.jpg)
Basic FIR structuresCascade direct form
![Page 15: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/15.jpg)
Basic FIR structuresDirect form (Tapped delay line)
![Page 16: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/16.jpg)
Basic FIR structuresTransposed direct form
![Page 17: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/17.jpg)
Basic FIR structuresLinear-phase type 1
![Page 18: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/18.jpg)
Basic FIR structuresLinear-phase type 2
![Page 19: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/19.jpg)
Basic FIR structuresSymmetric FIR type I
![Page 20: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/20.jpg)
Basic FIR structuresSymmetric FIR type II
![Page 21: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/21.jpg)
Basic IIR structuresDirect form, Transposed form
Direct form I 2nd order
![Page 22: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/22.jpg)
Basic IIR structuresDirect form I 2nd order
![Page 23: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/23.jpg)
Basic IIR structuresDirect form II 2nd order
![Page 24: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/24.jpg)
Basic IIR structuresCascade direct form II
![Page 25: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/25.jpg)
Basic IIR structuresTransposed direct form II 1st order
![Page 26: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/26.jpg)
Basic IIR structuresTransposed direct form II 2nd order
![Page 27: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/27.jpg)
Simple FIR design example4th order linear-phase filter
![Page 28: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/28.jpg)
Simple FIR design exampleFile, Export …
![Page 29: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/29.jpg)
Simple FIR design exampleEdit, Convert Structure …
![Page 30: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/30.jpg)
Simple FIR example designs
![Page 31: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/31.jpg)
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
![Page 32: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/32.jpg)
Classical digital filter designStart with specification:
![Page 33: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/33.jpg)
Classical digital filter designStart with specification:
![Page 34: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/34.jpg)
Classical digital filter designStep 1: Approximation; Select Chebyshev
Type I
![Page 35: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/35.jpg)
Classical digital filter designExport coefficients: File, Export
![Page 36: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/36.jpg)
Classical digital filter designStep 2: Realization; Direct-form II biquads
![Page 37: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/37.jpg)
Classical digital filter designStep 3: Study of imperfections:
Quantization The spec is violated!
![Page 38: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/38.jpg)
Classical digital filter designRedo step 1: Approximation, Increase
order
![Page 39: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/39.jpg)
Classical digital filter designRedo step 3: Study of imperfections
(Quantization) The spec is OK
![Page 40: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/40.jpg)
Classical digital filter designStep 4: Implementation as a C header file
![Page 41: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/41.jpg)
Digital filters: FIR filter designOverview
FIR filtersDesign techniquesFIR filter design
using Filter Design Toolbox
![Page 42: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/42.jpg)
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)
![Page 43: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/43.jpg)
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
![Page 44: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/44.jpg)
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
![Page 45: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/45.jpg)
Windows
![Page 46: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/46.jpg)
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.
![Page 47: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/47.jpg)
Kaiser
![Page 48: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/48.jpg)
Hann
![Page 49: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/49.jpg)
Hamming
![Page 50: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/50.jpg)
Blackman
![Page 51: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/51.jpg)
Bartlett
![Page 52: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/52.jpg)
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
![Page 53: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/53.jpg)
Equiripple
remez designs a linear-phase FIR filter using the Parks-McClellan algorithm
![Page 54: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/54.jpg)
Constrained Equiripplefirceqrip
![Page 55: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/55.jpg)
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
![Page 56: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/56.jpg)
Least square linear-phase
Least square linear-phase FIR filter design (firls)
![Page 57: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/57.jpg)
Least Pth-norm
![Page 58: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/58.jpg)
Maximally flatSymmetric FIR Butterworth filter (maxflat)
![Page 59: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/59.jpg)
Advanced digital filter design
Overview:Drawback of the classic designAdvanced design paradigmAFDesign toolboxExample design
![Page 60: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/60.jpg)
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
![Page 61: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/61.jpg)
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
![Page 62: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/62.jpg)
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
![Page 63: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/63.jpg)
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
![Page 64: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/64.jpg)
Advanced digital filter designAdvanced design: AFDesign
Gdmax has been reduced to 70
![Page 65: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/65.jpg)
Advanced digital filter designDesign parameters
Design parameters
D = {n, , , fp}
Filter order n
Selectivity factor
Ripple factor
Actual passband edge fp
![Page 66: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/66.jpg)
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.
![Page 67: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/67.jpg)
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.
![Page 68: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/68.jpg)
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.
![Page 69: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/69.jpg)
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.
![Page 70: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/70.jpg)
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.
![Page 71: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/71.jpg)
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.
![Page 72: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/72.jpg)
Advanced digital filter designGroup delay
The maximum delay is obtained for D3a and D3b, while D4a and D4b have lower group-delay variation.
![Page 73: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/73.jpg)
Advanced digital filter designAFDesign: D5 – minimal Q-factor
Gdmax has been reduced to 60
![Page 74: Dsp Using Matlab® - 8](https://reader038.vdocument.in/reader038/viewer/2022102600/546522acb4af9f6c148b462b/html5/thumbnails/74.jpg)
Advanced digital filter designAFDesign: Bandpass