Download presentation
Presentation is loading. Please wait.
Published byCandace Gray Modified over 6 years ago
1
Biomedical Signal processing Chapter 7 Filter Design Techniques
2018年11月29日6时3分 Biomedical Signal processing Chapter 7 Filter Design Techniques Zhongguo Liu Biomedical Engineering School of Control Science and Engineering, Shandong University 山东省精品课程《生物医学信号处理(双语)》 2018/11/29 1 Zhongguo Liu_Biomedical Engineering_Shandong Univ.
2
Chapter 7 Filter Design Techniques
7.0 Introduction 7.1 Design of Discrete-Time IIR Filters From Continuous-Time Filters 7.2 Design of FIR Filters by Windowing 7.3 Examples of FIR Filters Design by the Kaiser Window Method 7.4 Optimum Approximations of FIR Filters 7.5 Examples of FIR Equiripple Approximation 7.6 Comments on IIR and FIR Discrete-Time Filters
3
Filter Design Techniques
7.0 Introduction
4
2018年11月29日6时3分 7.0 Introduction Frequency-selective filters pass only certain frequencies Any discrete-time system that modifies certain frequencies is called a filter. We concentrate on design of causal Frequency-selective filters
5
Linear time-invariant discrete-time system
If input is bandlimited and sampling frequency is high enough to avoid aliasing, then overall system behaves as an LTI continuous-time system effective continuous-time specifications are converted to discrete time specifications by:
6
Stages of Filter Design
Determine the specification of the desired properties of the system. The approximation of the specifications using(designing) a causal discrete-time system. The realization of the system. Our focus is on second step Specifications are typically given in the frequency domain.
7
Frequency-Selective Filters
Ideal lowpass filter (discrete-time system)
8
Frequency-Selective Filters
Ideal highpass filter(discrete-time system)
9
Frequency-Selective Filters
Ideal bandpass filter(discrete-time system)
10
Frequency-Selective Filters
Ideal bandstop filter(discrete-time system)
11
tolerance scheme 容限图 Figure depicts the typical representation of the tolerance limits associated with approximating an ideal lowpass filter. tolerance scheme 容限图 discrete-time continuous -time
12
Example 7.1 Determining Specifications for a Discrete-Time Filter H(ejw) .
Known: Specifications of the continuous-time filter: 1. passband 2. stopband For bandlimited input, aliasing avoided when sampling frequency is high enough
13
Example 7.1 Determining Specifications for a Discrete-Time Filter
Specifications of the continuous-time filter: 1. passband 2. stopband tolerance scheme 容限图
14
Example 7.1 Determining Specifications for a Discrete-Time Filter
Solution: Specifications of the discrete-time filter in Same tolerance limits:
15
Filter Design Constraints
Designing IIR filters is to find the approximation by a rational function of z. The poles of the system function must lie inside the unit circle(stability, causality). Designing FIR filters is to find the polynomial approximation. FIR filters are often required to be linear-phase.
16
Filter Design Techniques
7.1 Design of Discrete-Time IIR Filters From Continuous-Time Filters
17
7.1 Design of Discrete-Time IIR Filters From Continuous-Time Filters
The traditional approach to the design of discrete-time IIR filters involves the transformation of a continuous-time filter into a discrete filter meeting prescribed specification: Impulse Invariance, Bilinear transformation
18
Three Reasons The art of continuous-time IIR filter design is highly advanced, and useful results can be achieved, it is advantageous to use the design procedures already developed for continuous-time filters.
19
Three Reasons Many useful continuous-time IIR design method have relatively simple closed form design formulas. Therefore, discrete-time IIR filter design methods based on standard continuous-time design formulas are rather simple to carry out.
20
Three Reasons The standard approximation methods that work well for continuous-time IIR filters do not lead to simple closed-form design formulas when these methods are applied directly to the discrete-time IIR case, because the frequency response of a discrete-time filter is periodic, and that of a continuous-time filter is not.
21
Steps of DT filter design by transforming a prototype continuous-time filter
① Obtain the specifications for continuous-time filter by transforming the specifications for the desired discrete-time filter. ② Find the system function of the continuous-time filter. ③ Transform the continuous-time filter to derive the system function of the discrete-time filter.
22
H(s)极点分布与原函数的对应关系(稳定性)
几种典型情况 p211
23
Constraints of Transformation
In transformations, to preserve the essential properties of the frequency response, the imaginary axis of the s-plane is mapped onto the unit circle of the z-plane.
24
Constraints of Transformation
In order to preserve the property of stability, If the continuous system has poles only in the left half of the s-plane, then the discrete- time filter must have poles only inside the unit circle.
25
7.1.1 Filter Design by Impulse Invariance
The impulse response of discrete-time system is defined by sampling the impulse response of a continuous-time system. Relationship between two systems: i.e. the continuous-time filter is bandlimited, and Ωs >2Ωmax in one period
26
relation between frequencies
Relationship between two systems: S plane Z plane - No Aliasing one period
27
No Aliasing in the Impulse Invariance
28
Aliasing in the Impulse Invariance
29
Steps of DT filter design by transforming a prototype continuous-time filter
① Obtain the specifications for continuous-time filter by transforming the specifications for the desired discrete-time filter. ② Find the system function of the continuous- time filter. ③ Transform the continuous-time filter to derive the system function of the discrete-time filter.
30
① Transformation of specifications from discrete to continuous
In impulse invariance design procedure, assuming the aliasing in transformation is neglected, relation of specifications in transformation is
31
Steps of DT filter design by transforming a prototype continuous-time filter
① Obtain the specifications for continuous-time filter by transforming the specifications for the desired discrete-time filter. ② Find the system function of the continuous-time filter. ③ Transform the continuous-time filter to derive the system function of the discrete-time filter.
32
② Find Continuous-time IIR filters
Butterworth filters Chebyshev Type I filters Chebyshev Type II filters Elliptic filters
33
Steps of DT filter design by transforming a prototype continuous-time filter
① Obtain the specifications for continuous-time filter by transforming the specifications for the desired discrete-time filter. ② Find the system function of the continuous-time filter. ③ Transform the continuous-time filter to derive the system function of the discrete-time filter.
34
③ Transformation from continuous to discrete
Laplace Transform impulse invariance z-Transform
35
Ex. 7.2 design DT filter by Impulse Invariance with a Butterworth Filter
Specifications for the discrete-time filter: Solution: ① Assume the effect of aliasing is negligible
36
Dependence of Butterworth magnitude characteristics on the order N.
② Butterworth Filter monotonic function of frequency magnitude-squared function Dependence of Butterworth magnitude characteristics on the order N.
37
Example 7.2 Impulse Invariance with a Butterworth Filter
monotonic function of frequency
38
Example 7.2 Impulse Invariance with a Butterworth Filter
round N up to passband specifications met exactly stopband specifications exceeded. allows some margin for aliasing
39
Example 7.2 Impulse Invariance with a Butterworth Filter
Plole pairs: Left half of the s-plane
40
Example 7.2 Impulse Invariance with a Butterworth Filter
Plole pairs: Left half of the s-plane
41
Example 7.2 Impulse Invariance with a Butterworth Filter
Plole pairs:
42
Example 7.2 ③ Ak, Sk same as Td=1 same as Td=1
43
Example 7.2 Impulse Invariance with a Butterworth Filter
Frequency response of 6th-order Butterworth filter Log magnitude in dB Magnitude Group delay
44
Program of Ex.7.2 using Impulse Invariance
clear all; wp=.2*pi; rp=-20*log10( ); ws=.3*pi; rs=-20*log10( ); Fs=1; wap=wp*Fs; was=ws*Fs; [n,wn]=buttord(wap,was,rp,rs,'s') % Note: 's'! [z,p,k]=buttap(n); [bp,ap]=zp2tf(z,p,k) [bs,as]=lp2lp(bp,ap,wn) %[bs,as] = butter(n,wn,'s'); [bz,az]=impinvar(bs,as,Fs) [Hz,Wz] = freqz(bz,az,512); subplot(311);plot(Wz,20*log10(abs(Hz)),'r'); Butterworth analog lowpass filter prototype
45
Program of Ex.7.2 using Impulse Invariance
[Hz,Wz] = freqz(bz,az,512); subplot(311) plot(Wz,20*log10(abs(Hz)),'r');grid on axis ([0 pi ]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',-100:20:20) set(gca,'YTickLabel',{'-100','-80','-60','-40','-20','0','20'}) xlabel('Frequency (Hz)'), ylabel('Magnitude (dB)'); title('Log Magnitude Response '); subplot(312) plot(Wz,(abs(Hz)),'r'); axis ([0 pi 0 1.2]) set(gca,'YTick',0:0.2:1.2) set(gca,'YTickLabel',{'0','0.2','0.4','0.6','0.8','1.0','1.2'}) xlabel('Frequency (Hz)'), ylabel('Magnitude '); title('Magnitude Response '); subplot(313) plot(Wz,(grpdelay(bz,az,Wz)),'r'); axis ([0 pi 0 12]) set(gca,'YTick',0:2:12) set(gca,'YTickLabel',{'0','2','4','6','8','10','12'}) xlabel('Frequency (Hz)'), ylabel('groupdelay '); title('groupdelay ');
46
Program of Ex.7.2 using Impulse Invariance
[Hz,Wz] = freqz(bz,az,512); set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',0:0.2:1.2) set(gca,'YTickLabel',{'0','0.2','0.4','0.6','0.8','1.0','1.2'}) xlabel('Frequency (Hz)'), ylabel('Magnitude '); title('Magnitude Response '); subplot(313) plot(Wz,(grpdelay(bz,az,Wz)),'r'); axis ([0 pi 0 12]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'YTick',0:2:12) set(gca,'YTickLabel',{'0','2','4','6','8','10','12'}) xlabel('Frequency (Hz)'), ylabel('groupdelay '); title('groupdelay ');
47
Program of Ex.7.2 using Impulse Invariance
Log magnitude in dB Magnitude Group delay
48
summary for Impulse Invariance
The basis for Impulse Invariance is to choose an impulse response for the DT-filter that is similar in some sense to the impulse response of the CT-filter. If the CT filter is bandlimited, then the DT filter frequency response will closely approximate the CT filter frequency response.
49
summary for Impulse Invariance
The relationship between CT and DT frequency is linear; consequently, except for aliasing, the shape of the frequency response is preserved.
50
summary for Impulse Invariance
The relationship between CT and DT frequency is linear; consequently, except for aliasing, the shape of the frequency response is preserved.
51
7.1.2 Bilinear Transformation
Bilinear transformation can avoid the problem of aliasing. Bilinear transformation maps onto Bilinear transformation:
52
7.1.2 Bilinear Transformation
53
7.1.2 Bilinear Transformation
54
7.1.2 Bilinear Transformation
Derivation (textbook): relationship between w and Ω
55
relation between frequency response for CT, DT filter
2018年11月29日6时3分 relation between frequency response for CT, DT filter Same tolerance limit for Passband, stopband
56
Comments on the Bilinear Transformation
It avoids the problem of aliasing encountered with the use of impulse invariance. It is nonlinear compression of frequency axis. S plane Z plane - S plane Z plane
57
Comments on the Bilinear Transformation
bilinear transformation is useful only when this compression can be tolerated or compensated for, as the case of filters that approximate ideal piecewise-constant magnitude- response characteristics.
58
Bilinear Transformation of
distortion in the frequency axis also manifests warping of the phase response of the filter
59
Comparisons of Impulse Invariance and Bilinear Transformation
The use of bilinear transformation is restricted to the design of approximations to filters with piecewise-constant magnitude-response characteristics, such as highpass, lowpass and bandpass filters. Impulse invariance can be used to design lowpass filters. However, it cannot be used to map highpass CT designs to highpass DT designs because they are not bandlimited.
60
Comparisons of Impulse Invariance and Bilinear Transformation
Bilinear transformation cannot design filter whose magnitude-response isn’t piecewise constant, like differentiator. However, Impulse invariance can design an bandlimited differentiator.
61
7.1.3 Examples of Bilinear Transformation
Example 7.3 is to illustrate the steps in the design of a Butterworth filter using the bilinear transformation. Example 7.4, 7.5 , 7.6 illustrate design of: Butterworth Filter; Chebyshev (I, II) Approximation; Elliptic Approximation
62
Bilinear Transformation of a Butterworth Filter
Ex.7.3 Design DT filter, given specification: Solution: (1) CT fiter spec, (prewarp)
63
Ex.7.3 Bilinear Transformation: Butterworth Filter
passband specifications exceeded. stopband specifications met exactly (2) Butterworth Filter
64
Example 7.2 Impulse Invariance with a Butterworth Filter
Plole pairs: Left half of the s-plane
65
Example 7.3 Bilinear Transformation of a Butterworth Filter
Plole pairs: (3) same as
66
Ex. 7.3 frequency response of DT filter
Log magnitude in dB Magnitude Group delay
67
Program of Ex.7.3 by Bilinear Transformation
clear all; wp=.2*pi; rp=-20*log10( ); ws=.3*pi; rs=-20*log10( ); Fs=1; wap=2*Fs*tan(wp/2);was=2*Fs*tan(ws/2); [n,wn]=buttord(wap,was,rp,rs,'s') % Note: 's'! [z,p,k]=buttap(n); [bp,ap]=zp2tf(z,p,k) [bs,as]=lp2lp(bp,ap,wn) %[bs,as] = butter(n,wn,'s'); [bz,az]=bilinear(bs,as,Fs) [Hz,Wz] = freqz(bz,az,512); subplot(311);plot(Wz,20*log10(abs(Hz)),'r'); Butterworth analog lowpass filter prototype [n,Wn]=buttord(.2*pi/pi,0.3*pi/pi,rp,rs) % no 's‘! [bs,as] = butter(n,wn);
68
Program of Ex.7.3 by Bilinear Transformation
[Hz,Wz] = freqz(bz,az,512); subplot(311) plot(Wz,20*log10(abs(Hz)),'r');grid on axis ([0 pi ]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',-100:20:20) set(gca,'YTickLabel',{'-100','-80','-60','-40','-20','0','20'}) xlabel('Frequency (Hz)'), ylabel('Magnitude (dB)'); title('Log Magnitude Response '); subplot(312) plot(Wz,(abs(Hz)),'r'); axis ([0 pi 0 1.2]) set(gca,'YTick',0:0.2:1.2) set(gca,'YTickLabel',{'0','0.2','0.4','0.6','0.8','1.0','1.2'}) xlabel('Frequency (Hz)'), ylabel('Magnitude '); title('Magnitude Response '); subplot(313) plot(Wz,(grpdelay(bz,az,Wz)),'r'); axis ([0 pi 0 12]) set(gca,'YTick',0:2:12) set(gca,'YTickLabel',{'0','2','4','6','8','10','12'}) xlabel('Frequency (Hz)'), ylabel('groupdelay '); title('groupdelay ');
69
Program of Ex.7.3 by Bilinear Transformation
Log magnitude in dB Magnitude Group delay
70
Program of Ex.7.3直接用数字滤波器设计指令
clear all; Fs=1 wp=.2*pi; rp=-20*log10( ); ws=.3*pi; rs=-20*log10( ); [n,Wn]=buttord(.2*pi/pi,0.3*pi/pi,rp,rs) % no 's'! [bz,az]=butter(n,Wn); freqz(bz,az,512, Fs) axis ([ ]) figure zplane(bz,az) [z,p,k]=tf2zp(bz,az) zplane(z,p,k)
71
7.1.3 Examples of Bilinear Transformation
Butterworth Filter, Chebyshev Approximation, I, II Elliptic Approximation Example7.4, 7.5, 7.6 Design DT filter, given specification:
72
Example 7.4 Butterworth Approximation
CT filter specification
73
Example 7.4 frequency response
Log magnitude in dB Magnitude in passband only Group delay
74
Example 7.4 frequency response
1.007 Magnitude in passband only passband edge frequency 0.99 passband stopband 0.983
75
Program of Ex.7.4 by Bilinear Transformation
clear all; Fs=1; e=0.007 wp=.4*pi; rp=-20*log10(0.99*(1/(1+e))); ws=.6*pi ; rs=-20*log10(0.001*(1/(1+e))); wap=2*Fs*tan(wp/2);was=2*Fs*tan(ws/2); [n,wn]=buttord(wap,was,rp,rs,'s') % Note: 's'! [z,p,k]=buttap(n); [bp,ap]=zp2tf(z,p,k) [bs,as]=lp2lp(bp,ap,wn) % [bs,as] = butter(n,wn,'s'); [bz,az]=bilinear(bs,as,Fs) bz=bz *(1+e); [Hz,Wz] = freqz(bz,az,512); % Hz=Hz*(1+e);
76
Program of Ex.7.4 by Bilinear Transformation
[Hz,Wz] = freqz(bz,az,512); % Hz=Hz*(1+e); subplot(311) plot(Wz,20*log10(abs(Hz)),'r'); axis ([0 pi ]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',-100:20:20) set(gca,'YTickLabel',{'-100','-80','-60','-40','-20','0','20'}) xlabel('Frequency (Hz)'), ylabel('Magnitude (dB)'); title('Log Magnitude Response '); subplot(312) plot(Wz,(abs(Hz)),'r'); axis ([0 pi ]) set(gca,'YTick',0.99:0.005:1.01) set(gca,'YTickLabel',{'0.99','0.995','1.0','1.005','1.01'}) xlabel('Frequency (Hz)'), ylabel('Magnitude '); title('Magnitude Response '); subplot(313) plot(Wz,(grpdelay(bz,az,Wz)),'r'); axis ([0 pi 0 25]) set(gca,'YTick',0:5:25) set(gca,'YTickLabel',{'0','5','10','15','20','25'}) xlabel('Frequency (Hz)'), ylabel('groupdelay '); title('groupdelay ');
77
Program of Ex.7.4 by Bilinear Transformation
Log magnitude in dB Frequency response Magnitude Group delay
78
Program of Ex.7.4直接用数字滤波器设计指令
clear all; Fs=1; e=0.007 wp=.4*pi; rp=-20*log10(0.99*(1/(1+e))); ws=.6*pi ; rs=-20*log10(0.001*(1/(1+e))); [n,Wn]=buttord(.4*pi/pi, .6*pi/pi,rp,rs) % no's'! [z,p,k]=butter(n,Wn); [sos,g] = zp2sos(z,p,k); Hd = dfilt.df2tsos(sos,g); h = fvtool(Hd) figure zplane(z,p,k) [bz,az]=zp2tf (z,p,k)
79
Chebyshev filter (type I)
Chebyshev filters Chebyshev filter (type I) 双曲余弦 Chebyshev polynomial N=0, V0(x)=1; N=1, V1(x)=cos(cos-1x)= x; N=2, V2(x)=cos(2cos-1x) =2x2-1; N=3, V3(x)=4x3-3x VN+1(x)=2xVN(x) - VN-l(x)
80
Chebyshev filter (type I)
Chebyshev filters Chebyshev filter (type I) 双曲余弦 Chebyshev polynomial
81
Chebyshev filter (type I)
Chebyshev filters Chebyshev filter (type I) Chebyshev polynomial x
82
Ws is stopband cut-off frequency
Three parameters of Chebyshev filter: Wc :given passband cut-off frequency e :is specified by the allowable passband ripple 由通带衰减(passband attenuation)决定 N:filter order, 等于通带内最大最小值的总数 Ws is stopband cut-off frequency 阻带衰减越大所需阶数越高
83
Chebyshev低通滤波器幅度平方函数的极点分布
以上Ωc,ε和N确定后,可以求出滤波器的极点,并确定Ha(p),p=s/Ωc。 有用的结果:设Ha(s)的极点为si=σi+jΩi,可证明: 上式是一个椭圆方程,因为ch(x)大于sh(x),长半轴为Ωcchξ(在虚轴上),短半轴为Ωcshξ(在实轴上)。
84
令bΩc和aΩc分别表示长半轴和短半轴,可推导出:
设N=3,平方幅度函数的极点分布如图所示(极点用X表示)。为稳定,用左半平面的极点构成Ha(p),即
85
c是待定系数。根据幅度平方函数式可导出:c=ε·2N-1,代入上式,得到归一化的传输函数为
去归一化后的传输函数为 三阶切比雪夫滤波器的极点分布图
87
Chebyshev filters Chebyshev filter (type II) Chebyshev filter (type I)
1 Chebyshev filter (type I)
88
Example 7.5 Chebyshev Type I , II Approximation
89
Example 7.5 frequency response of Chebyshev
Type I Type II Magnitude in passband only
90
Program of Ex.7.5 by Bilinear Transformation
% Chebyshev I Matlab program: clear all; Fs=1; e=0.007(书图中最大幅值大约值1+e) wp=.4*pi; rp=-20*log10(0.99*(1/(1+e))); ws=.6*pi ; rs=-20*log10(0.001*(1/(1+e))); wap=2*Fs*tan(wp/2);was=2*Fs*tan(ws/2); [n,wn]=cheb1ord(wap,was,rp,rs,'s') % 's'! [z,p,k]=cheb1ap(n,rp); [bp,ap]=zp2tf(z,p,k) [bs,as]=lp2lp(bp,ap,wn) % [bs,as] = cheby1(n,rp,wn,'s'); [bz,az]=bilinear(bs,as,Fs) bz=bz *(1+e);
91
Program of Ex.7.5 by Bilinear Transformation
% Chebyshev II Matlab program clear all; Fs=1; e=0.007 wp=.4*pi; rp=-20*log10(0.99*(1/(1+e))); ws=.6*pi ; rs=-20*log10(0.001*(1/(1+e))); wap=2*Fs*tan(wp/2);was=2*Fs*tan(ws/2); [n,wn]=cheb2ord(wap,was,rp,rs,'s') [z,p,k]=cheb2ap(n,rs); [bp,ap]=zp2tf(z,p,k) [bs,as]=lp2lp(bp,ap,wn) %[bs,as] = cheby2(n,rs,wn,'s'); [bz,az]=bilinear(bs,as,Fs) bz=bz *(1+e); be careful !
92
Program of Ex.7.5 by Bilinear Transformation
[Hz,Wz] = freqz(bz,az,512); %Hz=Hz*(1+e); subplot(311) plot(Wz,20*log10(abs(Hz)),'r'); axis ([0 pi ]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',-100:20:20) set(gca,'YTickLabel',{'-100','-80','-60','-40','-20','0','20'}) xlabel('Frequency (Hz)'), ylabel('Magnitude (dB)'); title('Log Magnitude Response '); subplot(312) plot(Wz,(abs(Hz)),'r'); axis ([0 pi ]) set(gca,'YTick',0.99:0.005:1.01) set(gca,'YTickLabel',{'0.99','0.995','1.0','1.005','1.01'}) xlabel('Frequency (Hz)'), ylabel('Magnitude '); title('Magnitude Response '); subplot(313) plot(Wz,(grpdelay(bz,az,Wz)),'r'); axis ([0 pi 0 25]) set(gca,'YTick',0:5:25) set(gca,'YTickLabel',{'0','5','10','15','20','25'}) xlabel('Frequency (Hz)'), ylabel('groupdelay '); title('groupdelay ');
93
Program of Ex.7.5 by Bilinear Transformation
Frequency response Chebyshev I型
94
Program of Ex.7.5 by Bilinear Transformation
Log magnitude in dB Frequency response Chebyshev II型 Magnitude in passband Group delay
95
Program of Ex.7.5直接用数字滤波器设计指令
% Chebyshev I型M程序如下 clear all; Fs=1; e=0.007 wp=.4*pi; rp=-20*log10(0.99*(1/(1+e))); ws=.6*pi ; rs=-20*log10(0.001*(1/(1+e))); [n,wn]=cheb1ord (.4*pi/pi,0.6*pi/pi,rp,rs) [z,p,k]= cheby1(n,rp,wn); k=k*(1+e); [sos,g] = zp2sos(z,p,k); Hd = dfilt.df2tsos(sos,g); h = fvtool(Hd) figure zplane(z,p,k) [bz,az]=zp2tf (z,p,k)
96
Program of Ex.7.5直接用数字滤波器设计指令
% Chebyshev II型M程序如下 clear all; Fs=1; e=0.007 wp=.4*pi; rp=-20*log10(0.99*(1/(1+e))); ws=.6*pi ; rs=-20*log10(0.001*(1/(1+e))); [n,wn]=cheb2ord (.4*pi/pi,0.6*pi/pi,rp,rs) [z,p,k]= cheby2(n,rs,wn); k=k*(1+e); [sos,g] = zp2sos(z,p,k); Hd = dfilt.df2tsos(sos,g); h = fvtool(Hd) figure zplane(z,p,k) [bz,az]=zp2tf (z,p,k) zplane(bz,az)
97
elliptic filters 1 Elliptic filter Jacobian elliptic function
98
Example 7.6 Elliptic Approximation
99
Example 7.6 frequency response of Elliptic
Log magnitude in dB Magnitude in passband Group delay
100
Program of Ex.7.6 by Bilinear Transformation
% Elliptic filter M程序如下 clear all; Fs=1; e=0.005 wp=.4*pi; rp=-20*log10(0.99*(1/(1+e))); ws=.6*pi ; rs=-20*log10(0.001*(1/(1+e))); wap=2*Fs*tan(wp/2);was=2*Fs*tan(ws/2); [n,wn]=ellipord(wap,was,rp,rs,'s') [z,p,k]=ellipap(n,rp,rs); [bp,ap]=zp2tf(z,p,k) [bs,as]=lp2lp(bp,ap,wn) %[bs,as] =ellip(n,rp,rs,wn,'s'); [bz,az]=bilinear(bs,as,Fs); bz=bz *(1+e);
101
Program of Ex.7.5 by Bilinear Transformation
[Hz,Wz] = freqz(bz,az,512); %Hz=Hz*(1+e); subplot(311) plot(Wz,20*log10(abs(Hz)),'r'); axis ([0 pi ]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',-100:20:20) set(gca,'YTickLabel',{'-100','-80','-60','-40','-20','0','20'}) xlabel('Frequency (Hz)'), ylabel('Magnitude (dB)'); title('Log Magnitude Response '); subplot(312) plot(Wz,(abs(Hz)),'r'); axis ([0 pi ]) set(gca,'YTick',0.99:0.005:1.01) set(gca,'YTickLabel',{'0.99','0.995','1.0','1.005','1.01'}) xlabel('Frequency (Hz)'), ylabel('Magnitude '); title('Magnitude Response '); subplot(313) plot(Wz,(grpdelay(bz,az,Wz)),'r'); axis ([0 pi 0 25]) set(gca,'YTick',0:5:25) set(gca,'YTickLabel',{'0','5','10','15','20','25'}) xlabel('Frequency (Hz)'), ylabel('groupdelay '); title('groupdelay ');
102
Program of Ex.7.5 by Bilinear Transformation
Log magnitude in dB Frequency response Elliptic filter Magnitude in passband Group delay
103
Program of Ex.7.4直接用数字滤波器设计指令
% Elliptic filter M程序如下 clear all; Fs=1; e=0.007 wp=.4*pi; rp=-20*log10(0.99*(1/(1+e))); ws=.6*pi ; rs=-20*log10(0.001*(1/(1+e))); [n,wn]=ellipord (.4*pi/pi,0.6*pi/pi,rp,rs) [z,p,k]= ellip(n,rp,rs,wn); k=k*(1+e); [sos,g] = zp2sos(z,p,k); Hd = dfilt.df2tsos(sos,g); h = fvtool(Hd) figure zplane(z,p,k) [bz,az]=zp2tf (z,p,k) zplane(bz,az)
104
Butterworth Filter : N=14. ( max flat)
*Comparison of Butterworth, Chebyshev, elliptic filters: Example -Given specification -Order Butterworth Filter : N=14. ( max flat) Chebyshev Filter : N= ( Cheby 1, Cheby 2) Elliptic Filter : N= ( equiripple) B C E
105
-Pole-zero plot (analog)
B C1 C2 E -Pole-zero plot (digital) B C1 C2 E (14) (8)
106
-Group delay -Magnitude C1 B B E C1 E C2 C2
107
7.2 Design of FIR Filters by Windowing
FIR filters are designed based on directly approximating the desired frequency response of the discrete-time system. Most techniques for approximating the magnitude response of an FIR system assume a linear phase constraint.
108
Window Method An ideal desired frequency response
Many idealized systems have discontinuous piecewise-constant frequency response, and their impulse responses are noncausal and infinitely long.
109
Window Method The most straightforward approach for obtaining a causal FIR approximation is to truncate the ideal impulse response.
110
Windowing in Frequency Domain
Windowed frequency response The windowed version is smeared version of desired response Gibbs phenomenon
111
Window Method If
112
Choice of Window is as short as possible in duration. This minimizes computation in the implementation of the filter. approximates an impulse.
113
Window Method If is chosen so that is concentrated in a narrow band of frequencies around then would look like , except where changes very abruptly.
114
Rectangular Window for the rectangular window has a generalized linear phase. As M increases, the width of the “main lobe” decreases.
115
will oscillate at the discontinuity.
Rectangular Window will oscillate at the discontinuity. The oscillations occur more rapidly, but do not decrease in magnitude as M increases. Gibbs phenomenon
116
Rectangular Window In theory of Fourier series, this nonuniform convergence, the Gibbs phenomenon can be moderated through the use of less abrupt truncation of the Fourier series.
117
Rectangular Window By tapering the window smoothly to zero at each end, the height of the side lobes can be diminished. The expense is a wider main lobe and thus a wider transition at the discontinuity. 主瓣
118
7.2.1 Properties of Commonly Used Windows
Rectangular Bartlett (triangular) M-1 non zero values
119
7.2.1 Properties of Commonly Used Windows
Hanning Hamming
120
7.2.1 Properties of Commonly Used Windows
Blackman
121
7.2.1 Properties of Commonly Used Windows
122
主瓣 Hamming Blackman Rectangular Bartlett (triangular) Hanning
Frequency Spectrum of Windows (a)-(e) attenuation of sidelobe increases, width of mainlobe increases.
123
7.2.1 Properties of Commonly Used Windows
Table 7.1 边瓣幅值 主瓣 宽度 biggest,high oscillations at discontinuity smallest,the sharpest transition
124
7.2.2 Incorporation of Generalized Linear Phase
In designing FIR filters, it is desirable to obtain causal systems with a generalized linear phase response. The above five windows are all symmetric about the point ,i.e.,
125
7.2.2 Incorporation of Generalized Linear Phase
Their Fourier transforms are of the form
126
7.2.2 Incorporation of Generalized Linear Phase
2018年11月29日6时3分 7.2.2 Incorporation of Generalized Linear Phase Hilbert filter hd[n]
127
Frequency Domain Representation
Linear Phase
128
Ex. 7.7 design Linear-Phase Lowpass Filter
The desired frequency response is verification Solution:
129
magnitude frequency response
Example:design a FIR filter M
130
例7.7 matlab program for FIR Filter disign,specification:
Solution: clc;clear all; close all wp=0.15*pi; ws=0.25*pi; wdelta=ws-wp; N=ceil(8*pi/wdelta); Wn=( )*pi/2; b=fir1(N,Wn/pi,hanning(N+1)); figure % freqz(b,1,512) [H,w]=freqz(b,1,512) ; plot(w,abs(H)) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) axis([0,pi,0.97,1.03]); Hanning窗
131
7.2 Design of FIR Filters by Windowing Method
Review To design an lowpass FIR Filters
132
7.2.1 Properties of Commonly Used Windows
smallest,the sharpest transition biggest,high oscillations at discontinuity
133
7.2.3 The Kaiser ['kaizə] Window Filter Design Method
Caesar[ˈsi:zə] 凯撒 Trade side-lobe amplitude for main-lobe width
134
continuous envelopes of Kaiser windows
(b) M=20 As increases, attenuation of sidelobe increases, width of mainlobe increases. =6 (c) As M increases, attenuation of sidelobe is preserved, width of mainlobe decreases. (a) Window shape, M=20 (b) Frequency spectrum, M=20, (c) beta=6 Figure 7.24
135
2018年11月29日6时3分 Comparison If the window is tapered more, the side lobe of the Fourier transform become smaller, but the main lobe become wider. Increasing M wile holding constant causes the main lobe to decrease in width, M=20 but does not affect the amplitude of the side lobe. =6 M=20
136
Transition width is a little less than mainlobe width
Table 7.1 Comparison Of Commonly Used Windows- with Kaiser windows Transition width is a little less than mainlobe width
137
Filter Design by Kaiser Window
(1) the specifications must be established : (2) (3) Peak approximation error Transition width To predict the values of M and β
138
Filter Design by Kaiser Window
(3) (4) magnitude response validation, (5) linear phase, group delay
139
Example 7.8 Kaiser Window Design of a Lowpass Filter
analysis: to get need need
140
Ex. 7.8 Kaiser Window Design of a Lowpass Filter
Solution:
141
Example 7.8 Kaiser Window Design of a Lowpass Filter
142
Ex. 7.8 Kaiser Window Design of a Lowpass Filter
magnitude response validation, peak approximation error is δ= instead of the desired value of h[n]=[ ] In this case it is necessary to increase M to 38 in order to meet the specifications. phase response
143
Ex. 7.8 Kaiser Window Design of a Lowpass Filter
clear all; clc; wp=0.4*pi; ws=0.6*pi; Wn=(wp+ws)/2; b=fir1(37,Wn/pi, kaiser(38,5.653)); fcuts = [wp/pi ws/pi]; mags = [1 0]; devs = [ ]; [n,Wn,beta,ftype] = kaiserord(fcuts,mags,devs); b= fir1(n,Wn,ftype,kaiser(n+1,beta)); [H,w]=freqz(b,1,2048) ; A(1:ceil(0.4*2048))=1-abs(H(1:ceil(0.4*2048))); A(floor(0.6*2048)-1:2048)=-abs(H(floor(0.6*2048)-1:2048)); A(round(0.4*2048)+1:floor(0.6*2048)-1)=nan; subplot(311) stem(b) subplot(312) plot(w,20*log10(abs(H))) axis([0,pi,-100,20]); subplot(313) plot(w,A) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) axis([0,pi,-0.001,0.001]);
144
7.3 Examples of FIR Filters Design by the Kaiser Window Method
The ideal highpass filter with generalized linear phase
145
Example 7.9 Kaiser Window Design of a Highpass Filter
Specifications: By Kaiser window method
146
Ex. 7.8 Kaiser Window Design of a Lowpass Filter
clear all; clc; wp=0.5*pi; ws=0.35*pi; fcuts = [ws/pi wp/pi]; mags = [0 1]; devs = [ ]; [n,Wn,beta,ftype] = kaiserord(fcuts,mags,devs); b=fir1(n,Wn,ftype,kaiser(n+1,beta)); [H,w]=freqz(b,1,2048) ; A(1:ceil(ws/pi*2048))=-abs(H(1:ceil(ws/pi*2048))); A(floor(wp/pi*2048)-1:2048)=1-abs(H(floor(wp/pi*2048)-1:2048)); A(round(ws/pi*2048)+1:floor(wp/pi*2048)-1)=nan; subplot(311) stem(b) subplot(312) plot(w,20*log10(abs(H))) axis([0,pi,-100,20]); subplot(313) plot(w,A) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) axis([0,pi,-0.025,0.025]); n =24, beta =2.5974
147
7.3.2 Discrete-Time Differentiator
M=10,even Type III M=5,odd Type IV
148
Example 7.10 Kaiser Window Design of a Differentiator
Suppose Ideal Impulse response Kaiser window type III FIR differentiator. Impulse response
149
Example 7.10 Kaiser Window Design of a Differentiator
Suppose Magnitude response Approximation error for A0(ejW ).
150
Example 7.10 Kaiser Window Design of a Differentiator
Suppose Ideal Impulse response Kaiser window type IV FIR differentiator. Impulse response
151
Example 7.10 Kaiser Window Design of a Differentiator
Suppose Magnitude response Approximation error for A0(ejW ).
152
Group Delay Phase: Group Delay: Noninteger delay
153
7.4 Optimum Approximations of FIR Filters
Goal: Design a ‘best’ filter for a given M In designing a causal type I linear phase FIR filter, it is convenient first to consider the design of a zero phase filter. Then insert a delay sufficient to make it causal.
154
7.4 Optimum Approximations of FIR Filters
zero phase filter
155
7.4 Optimum Approximations of FIR Filters
Designing a filter to meet these specifications is to find the (L+1) impulse response values Packs-McClellan algorithm is the dominant method for optimum design of FIR filters. In Packs-McClellan algorithm, is fixed, and is variable.
156
7.4 Optimum Approximations of FIR Filters
157
7.4 Optimum Approximations of FIR Filters
158
7.4 Optimum Approximations of FIR Filters
159
Minimax criterion Within the frequency interval of the passband and stopband, we seek a frequency response that minimizes the maximum weighted approximation error of
160
Other criterions
161
Alternation Theorem Let denote the closed subset consisting of the disjoint union of closed subsets of the real axis x. is an r th-order polynomial. denotes a given desired function of x that is continuous on is a positive function, continuous on The weighted error is The maximum error is defined as
162
Alternation Theorem A necessary and sufficient condition that be the unique rth-order polynomial that minimizes is that exhibit at least (r+2) alternations; i.e., there must exist at least (r+2) values in such that and such that for
163
Example 7.11 Alternation Theorem and Polynomials
suppose Each of these polynomials is of fifth order.
164
Example 7.11 Alternation Theorem and Polynomials
The closed subsets of the real axis x referred to in the theorem are the regions P3(x) is the unique optimal 5th-order polynomial approximation for this region.
165
7.4.1 Optimal Type I Lowpass Filters
For Type I lowpass filter The desired lowpass frequency response Weighting function
166
7.4.1 Optimal Type I Lowpass Filters
The weighted approximation error is The closed subset is or
167
7.4.1 Optimal Type I Lowpass Filters
The alternation theorem states that a set of coefficients will correspond to the filter representing the unique best approximation to the ideal lowpass filter with the ratio fixed at K and with passband and stopband edge and if and only if exhibits at least (L+2) alternations on ;
168
7.4.1 Optimal Type I Lowpass Filters
i.e., if and only if alternately equals plus and minus its maximum value at least (L+2) times. Such approximations are called equiripple approximations.
169
7.4.1 Optimal Type I Lowpass Filters
The alternation theorem states that the optimum filter must have a minimum of (L+2) alternations, but does not exclude the possibility of more than (L+2) alternations. In fact, for a lowpass filter, the maximum possible number of alternations is (L+3).
170
7.4.1 Optimal Type I Lowpass Filters
Because all of the filters satisfy the alternation theorem for L=7 and for the same value of , it follows that and/or must be different for each ,since the alternation theorem states that the optimum filter under the conditions of the theorem is unique.
171
Property for type I lowpass filters from the alternation theorem
The maximum possible number of alternations of the error is (L+3) Alternations will always occur at and All points with zero slope inside the passband and all points with zero slope inside stopband will correspond to alternations; i.e., the filter will be equiripple, except possibly at and
172
7.4.2 Optimal Type II Lowpass Filters
For Type II causal FIR filter: The filter length (M+1) is even, ie, M is odd Impulse response is symmetric The frequency response is
173
7.4.2 Optimal Type II Lowpass Filters
174
7.4.2 Optimal Type II Lowpass Filters
For Type II lowpass filter,
175
7.4.3 The Park-McClellan Algorithm
From the alternation theorem, the optimum filter will satisfy the set of equation
176
7.4.3 The Park-McClellan Algorithm
Guessing a set of alternation frequencies and
177
7.4.3 The Park-McClellan Algorithm
178
7.4.3 The Park-McClellan Algorithm
For equiripple lowpass approximation Filter length: (M+1)
179
7.5 Examples of FIR Equiripple Approximation 7.5.1 Lowpass Filter
180
Comments M=26, Type I filter The minimum number of alternations is (L+2)=(M/2+2)=15 7 alternations in passband and 8 alternations in stopband The maximum error in passband and stopband are and , which exceed the specifications.
181
M=27, Type II filter, zero at z=-1
7.5.1 Lowpass Filter M=27, Type II filter, zero at z=-1 The maximum error in passband and stopband are and , which exceed the specifications. The minimum number of alternations is (L+2)=(M-1)/2+2=15 7 alternations in passband and 8 alternations in stopband
182
Comparison Kaiser window method require M=38 to meet or exceed the specifications. Park-McClellan method require M=27 Window method produce approximately equal maximum error in passband and stopband. Park-McClellan method can weight the error differently.
183
7.6 Comments on IIR and FIR Discrete-Time Filters
What type of system is best, IIR or FIR? IIR: closed-form design formulas straightforward noniterative computer programs for IIR filter design. 一次设计,指标要求满足 FIR: can have a (generalized) linear phase iteration may be necessary to meet a prescribed specification. 一次设计,未必满足指标要求
184
7.6 Comments on IIR and FIR Discrete-Time Filters
Why give so many different design methods? Which method yields the best result? Closed-Form Formulas Generalized Linear Phase Order IIR Yes No Low FIR High
185
Zhongguo Liu_Biomedical Engineering_Shandong Univ.
Chapter 5 HW 7.2, 7.4, 7.15, Zhongguo Liu_Biomedical Engineering_Shandong Univ. 199 2018/11/29 返 回 上一页 下一页
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.