Presentation is loading. Please wait.

Presentation is loading. Please wait.

12016-3-131Zhongguo Liu_Biomedical Engineering_Shandong Univ. Biomedical Signal processing Chapter 7 Filter Design Techniques Zhongguo Liu Biomedical.

Similar presentations


Presentation on theme: "12016-3-131Zhongguo Liu_Biomedical Engineering_Shandong Univ. Biomedical Signal processing Chapter 7 Filter Design Techniques Zhongguo Liu Biomedical."— Presentation transcript:

1

2 12016-3-131Zhongguo Liu_Biomedical Engineering_Shandong Univ. Biomedical Signal processing Chapter 7 Filter Design Techniques Zhongguo Liu Biomedical Engineering School of Control Science and Engineering, Shandong University

3 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

4 3 Filter Design Techniques 7.0 Introduction

5 4  Frequency-selective filters pass only certain frequencies  Any discrete-time system that modifies certain frequencies is called a filter.  We concetrate on design of causal Frequency-selective filters

6 5 Stages of Filter Design  The specification of the desired properties of the system.  The approximation of the specifications using 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 6 Frequency-Selective Filters  Ideal lowpass filter

8 7 Frequency-Selective Filters  Ideal highpass filter

9 8 Frequency-Selective Filters  Ideal bandpass filter

10 9 Frequency-Selective Filters  Ideal bandstop filter

11 10  If input is bandlimited and sampling frequency is high enough to avoid aliasing, then overall system behave as a continuous-time system: Linear time-invariant discrete-time system continuous-time specifications are converted to discrete time specifications by:

12 11 Example 7.1 Determining Specifications for a Discrete-Time Filter  Specifications of the continuous-time filter:  1. passband  2. stopband

13 12 Example 7.1 Determining Specifications for a Discrete-Time Filter  Specifications of the continuous-time filter:  1. passband  2. stopband

14 13 Example 7.1 Determining Specifications for a Discrete-Time Filter Specifications of the discrete-time filter in

15 14 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 15 Filter Design Techniques 7.1 Design of Discrete-Time IIR Filters From Continuous-Time Filters

17 16 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.

18 17 Three Reasons 1.The art of continuous-time IIR filter design is highly advanced, and since useful results can be achieved, it is advantageous to use the design procedures already developed for continuous-time filters.

19 18 Three Reasons 2.Many useful continuous-time IIR design method have relatively simple closed form design formulas. Therefore, discrete-time IIR filter design methods based on such standard continuous-time design formulas are rather simple to carry out.

20 19 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 20 Steps of DT filter design by transforming a prototype continuous-time filter  The specifications for the continuous- time filter are obtained by a transformation of 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 21 Constraints of Transformation  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.

23 22 Constraints of Transformation  In order to preserve the property of stability, If the continuous system has poles only in the let half of the s-plane, then the discrete-time filter must have poles only inside the unit circle.

24 23 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 of frequencies

25 24 relation between frequencies S plane Z plane - Relationship of frequencies

26 25 No Aliasing in the Impulse Invariance

27 26 Aliasing in the Impulse Invariance

28 27 periodic sampling T : sample period; fs=1/T:sample rate Ωs=2π/T:sample rate Review

29 28 Time domain : Complex frequency domain : Laplace transform Relation between Laplace Transform and Z-transform Review

30 29 Fourier Transform frequency domain : Laplace transform Fourier Transform is the Laplace transform when s have the value only in imaginary axis, s=jΩ Since So

31 30 For discrete-time signal , 令: z-transform of discrete- time signal Laplace transform the Laplace transform

32 31 so :  Laplace transform Laplace transform continuous time signal z-transform z-transform discrete-time signal let :

33 32 DTFT : Discrete Time Fourier Transform S plane Z plane -

34 33 plane

35 34  If input is bandlimited and f s >2f max, : discrete-time filter design by impulse invariance

36 35 relation between frequencies S plane Z plane - Relationship of frequencies

37 36 periodic sampling T : sample period; fs=1/T:sample rate Ωs=2π/T:sample rate Review

38 37 proof of T : sample period; fs=1/T:sample rate;Ωs=2π/T:sample rate Review s(t) 为冲击串序列,周期为 T ,可展开傅立叶级数

39 38 periodic sampling

40 39 discrete-time filter design by impulse invariance

41 40 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.

42 41 Transformation of specifications from discrete to continuous  In the impulse invariance design procedure, Assuming the aliasing involved in the transformation is neglected, the relation of specifications in transformation is

43 42 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.

44 43 Continuous-time IIR filters  Butterworth filters  Chebyshev Type I filters  Chebyshev Type II filters  Elliptic filters

45 44 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.

46 45 Transformation from continuous to discrete

47 46 Ex. 7.2 design DT filter by Impulse Invariance with a Butterworth Filter  Specifications for the discrete-time filter:  Assume the effect of aliasing is negligible Solution:

48 47 Example 7.2 Impulse Invariance with a Butterworth Filter monotonic function of frequency

49 48 Example 7.2 Impulse Invariance with a Butterworth Filter

50 49 Example 7.2 Impulse Invariance with a Butterworth Filter allows some margin for aliasing passband specifications met exactly stopband specifications exceeded.

51 50 Example 7.2 Impulse Invariance with a Butterworth Filter

52 51 Example 7.2 Impulse Invariance with a Butterworth Filter Plole pairs: Left half of the s-plane

53 52 Example 7.2 Impulse Invariance with a Butterworth Filter Plole pairs:

54 53 Example 7.2 Impulse Invariance with a Butterworth Filter Plole pairs:

55 54 Example 7.2 Impulse Invariance with a Butterworth Filter

56 55 Example 7.2 Impulse Invariance with a Butterworth Filter Frequency response of 6th-order Butterworth filter transformed by impulse invariance. (a)Log magnitude in dB. (b)Magnitude. (c)Group delay

57 56 Program of Ex.7.2 using Impulse Invariance clear all; wp=.2*pi; rp=-20*log10(0.89125); ws=.3*pi; rs=-20*log10(0.17783); 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) [bz,az]=impinvar(bs,as,Fs) %[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');

58 57 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 -100 20]) 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,'XTick',0:0.2*pi:pi) 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,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',0:2:12) set(gca,'YTickLabel',{'0','2','4','6','8','10','12'}) xlabel('Frequency (Hz)'), ylabel('groupdelay '); title('groupdelay ');

59 58 Program of Ex.7.2 using Impulse Invariance

60 59 Program of Ex.7.2 直接用数字滤波器设计指令 clear all; Fs=1 wp=.2*pi; rp=-20*log10(0.89125); ws=.3*pi; rs=-20*log10(0.17783); [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 ([0 0.15 -20 0]) figure zplane(bz,az) [z,p,k]=tf2zp(bz,az) zplane(z,p,k)

61 60 Basic for Impulse Invariance  To chose an impulse response for the discrete-time filter that is similar in some sense to the impulse response of the continuous-time filter.  If the continuous-time filter is bandlimited, then the discrete-time filter frequency response will closely approximate the continuous-time frequency response.  The relationship between continuous-time and discrete-time frequency is linear; consequently, except for aliasing, the shape of the frequency response is preserved.

62 61 7.1.2 Bilinear Transformation  Bilinear transformation can avoid the problem of aliasing.  Bilinear transformation maps onto  Bilinear transformation:

63 62 7.1.2 Bilinear Transformation

64 63 7.1.2 Bilinear Transformation

65 64 7.1.2 Bilinear Transformation To derive a relationship between the variables w and Ω

66 65 relation between frequency response of H c (s), H(z)

67 66 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

68 67 Comments on the Bilinear Transformation  The design of discrete-time filters using 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.

69 68 Bilinear Transformation of distortion in the frequency axis also manifests the warping of the phase response of the filter frequency axis

70 69 Comparisons of Impulse Invariance and Bilinear Transformation  The use of bilinear transformation is restricted to the design of approximations to filters with piecewise-constant frequency magnitude characteristics, such as highpass, lowpass and bandpass filters.  Impulse invariance can also design lowpass filters. However, it cannot be used to design highpass filters because they are not bandlimited.

71 70 Comparisons of Impulse Invariance and Bilinear Transformation  Bilinear transformation cannot design filter whose magnitude response isn’t piecewise constant, such as differentiator. However, Impulse invariance can design an bandlimited differentiator.

72 71  Butterworth Filter,  Chebyshev Approximation,  Elliptic Approximation 7.1.3 Example of Bilinear Transformation

73 72 Example 7.3 Bilinear Transformation of a Butterworth Filter Solution:

74 73 Example 7.3 Bilinear Transformation of a Butterworth Filter Butterworth Filter passband specifications exceeded. no aliasing, stopband specifications met exactly

75 74 Locations of Poles Plole pairs:

76 75 Example 7.3 Bilinear Transformation of a Butterworth Filter Plole pairs:

77 76 Ex. 7.3 frequency response of discrete-time filter

78 77 Program of Ex.7.3 by Bilinear Transformation clear all; wp=.2*pi; rp=-20*log10(0.89125); ws=.3*pi; rs=-20*log10(0.17783); 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) [bz,az]=bilinear(bs,as,Fs) % [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');

79 78 [Hz,Wz] = freqz(bz,az,512); subplot(311) plot(Wz,20*log10(abs(Hz)),'r');grid on axis ([0 pi -100 20]) 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,'XTick',0:0.2*pi:pi) 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,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',0:2:12) set(gca,'YTickLabel',{'0','2','4','6','8','10','12'}) xlabel('Frequency (Hz)'), ylabel('groupdelay '); title('groupdelay '); Program of Ex.7.3 by Bilinear Transformation

80 79 Program of Ex.7.3 by Bilinear Transformation

81 80 Program of Ex.7.3 直接用数字滤波器设计指令 clear all; Fs=1 wp=.2*pi; rp=-20*log10(0.89125); ws=.3*pi; rs=-20*log10(0.17783); [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 ([0 0.15 -20 0]) figure zplane(bz,az) [z,p,k]=tf2zp(bz,az) zplane(z,p,k)

82 81  Butterworth Filter,  Chebyshev Approximation,  Elliptic Approximation 7.1.3 Example of Bilinear Transformation

83 82 Example 7.4 Butterworth Approximation (Hw)

84 83 Example 7.4 frequency response Magnitude in passband only

85 84 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) [bz,az]=bilinear(bs,as,Fs) % [bs,as] = butter(n,wn,'s'); % [bz,az]=bilinear(bs,as,Fs) [Hz,Wz] = freqz(bz,az,512); Hz=Hz*(1+e);

86 85 [Hz,Wz] = freqz(bz,az,512); Hz=Hz*(1+e); subplot(311) plot(Wz,20*log10(abs(Hz)),'r'); axis ([0 pi -100 20]) 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.99 1.01]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) 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,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',0:5:25) set(gca,'YTickLabel',{'0','5','10','15','20','25'}) xlabel('Frequency (Hz)'), ylabel('groupdelay '); title('groupdelay '); Program of Ex.7.4 by Bilinear Transformation

87 86 Program of Ex.7.4 by Bilinear Transformation Frequency response

88 87 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,0.6*pi/pi,rp,rs) [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)

89 88 Chebyshev filters C Chebyshev filter (type I) 1 Chebyshev polynomial Chebyshev filter (type II) 1

90 89 Example 7.5 Chebyshev Type I, II Approximation Type I Type II

91 90 Example 7.5 frequency response of Chebyshev Type I Type II Magnitude in passband only

92 91 Program of Ex.7.5 by Bilinear Transformation % 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))); 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) [bz,az]=bilinear(bs,as,Fs) % [bs,as] = cheby1(n,rp,wn,'s'); % [bz,az]=bilinear(bs,as,Fs)

93 92 Program of Ex.7.5 by Bilinear Transformation % 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))); 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) [bz,az]=bilinear(bs,as,Fs) %[bs,as] = cheby2(n,rs,wn,'s'); %[bz,az]=bilinear(bs,as,Fs)

94 93 [Hz,Wz] = freqz(bz,az,512); Hz=Hz*(1+e); subplot(311) plot(Wz,20*log10(abs(Hz)),'r'); axis ([0 pi -100 20]) 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.99 1.01]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) 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,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',0:5:25) set(gca,'YTickLabel',{'0','5','10','15','20','25'}) xlabel('Frequency (Hz)'), ylabel('groupdelay '); title('groupdelay '); Program of Ex.7.5 by Bilinear Transformation

95 94 Program of Ex.7.5 by Bilinear Transformation Chebyshev I 型 Frequency response

96 95 Program of Ex.7.5 by Bilinear Transformation Chebyshev II 型 Frequency response

97 96 Program of Ex.7.4 直接用数字滤波器设计指令 % 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); [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)

98 97 Program of Ex.7.4 直接用数字滤波器设计指令 % 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); [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)

99 98 E elliptic filters Elliptic filter 1 Jacobian elliptic function

100 99 Example 7.6 Elliptic Approximation

101 100 Example 7.6 frequency response of Elliptic

102 101 Program of Ex.7.5 by Bilinear Transformation % 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))); 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) [bz,az]=bilinear(bs,as,Fs) %[bs,as] =ellip(n,rp,rs,wn,'s'); %[bz,az]=bilinear(bs,as,Fs)

103 102 [Hz,Wz] = freqz(bz,az,512); Hz=Hz*(1+e); subplot(311) plot(Wz,20*log10(abs(Hz)),'r'); axis ([0 pi -100 20]) 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.99 1.01]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) 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,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',0:5:25) set(gca,'YTickLabel',{'0','5','10','15','20','25'}) xlabel('Frequency (Hz)'), ylabel('groupdelay '); title('groupdelay '); Program of Ex.7.5 by Bilinear Transformation

104 103 Program of Ex.7.5 by Bilinear Transformation Elliptic filter Frequency response

105 104 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); [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)

106 105 *Comparison of Butterworth, Chebyshev, elliptic filters: Example -Given specification -Order Butterworth Filter : N=14. ( max flat) Chebyshev Filter : N=8. ( Cheby 1, Cheby 2) Elliptic Filter : N=6 ( equiripple) B C E

107 106 -Pole-zero plot (analog) -Pole-zero plot (digital) BC1C2E BC1C2E (14)(8)

108 107 -Magnitude -Group delay B C1 C2 E B C1 C2 E

109 108 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.

110 109 Window Method  An ideal desired frequency response  Many idealized systems are defined by piecewise-constant frequency response with discontinuities at the boundaries. As a result, these systems have impulse responses that are noncausal and infinitely long.

111 110 Window Method  The most straightforward approach to obtaining a causal FIR approximation is to truncate the ideal impulse response.

112 111 Windowing in Frequency Domain  Windowed frequency response  The windowed version is smeared version of desired response

113 112 Window Method  If

114 113 Choice of Window  is as short as possible in duration. This minimizes computation in the implementation of the filter.  approximates an impulse.

115 114 Window Method  then would look like, except where changes very abruptly.  If is chosen so that is concentrated in a narrow band of frequencies around

116 115 Rectangular Window  for the rectangular window has a generalized linear phase.  As M increases, the width of the “main lobe” decreases.  While the width of each lobe decreases with M, the peak amplitudes of the main lobe and the side lobes grow such that the area under each lobe is a constant.

117 116 Rectangular Window  will oscillate at the discontinuity.  The oscillations occur more rapidly, but do not decrease in magnitude as M increases.  The Gibbs phenomenon can be moderated through the use of a less abrupt truncation of the Fourier series.

118 117 Rectangular Window  The Gibbs phenomenon can be moderated through the use of a less abrupt truncation of the Fourier series.

119 118 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. 主瓣

120 119 7.2 Design of FIR Filters by Windowing Method  To design an ilowpass FIR Filters Review

121 120 7.2.1 Properties of Commonly Used Windows  Rectangular  Bartlett (triangular) M-1 non zero values

122 121 7.2.1 Properties of Commonly Used Windows  Hanning  Hamming

123 122 7.2.1 Properties of Commonly Used Windows  Blackman

124 123 7.2.1 Properties of Commonly Used Windows

125 124 Frequency Spectrum of Windows (a)-(e) attenuation of sidelobe increases, width of mainlobe increases. Rectangular Bartlett (triangular) Hanning Hamming Blackman 主瓣

126 125 7.2.1 Properties of Commonly Used Windows biggest , high oscillations at discontinuity smallest , the sharpest transition Table 7.1 主瓣 宽度 边瓣幅值

127 126 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.,

128 127 7.2.2 Incorporation of Generalized Linear Phase  Their Fourier transforms are of the form

129 128 7.2.2 Incorporation of Generalized Linear Phase

130 129 Frequency Domain Representation

131 130 Ex. 7.7 design Linear-Phase Lowpass Filter  The desired frequency response is Solution:

132 131 magnitude frequency response

133 132 7.2.1 Properties of Commonly Used Windows smallest , the sharpest transition biggest , high oscillations at discontinuity

134 133 7.2.3 The Kaiser Window Filter Design Method Trade side-lobe amplitude for main-lobe width

135 134 Figure 7.24 As  increases, attenuation of sidelobe increases, width of mainlobe increases. As M increases, attenuation of sidelobe is preserved, width of mainlobe decreases. M=20 (a) Window shape, M=20, (b) Frequency spectrum, M=20, (c) beta=6  =6 (a) (b) (c)

136 135  Increasing M wile holding  constant causes the main lobe to decrease in width, but does not affect the amplitude of the side lobe. Comparison  If the window is tapered more, the side lobe of the Fourier transform become smaller, but the main lobe become wider. M=20  =6 M=20

137 136 Table 7.1 Transition width is a little less than mainlobe width

138 137 Filter Design by Kaiser Window

139 138 Filter Design by Kaiser Window M=20

140 139 Example 7.8 Kaiser Window Design of a Lowpass Filter Solution: scheme, To get need

141 140 Ex. 7.8 Kaiser Window Design of a Lowpass Filter

142 141 Example 7.8 Kaiser Window Design of a Lowpass Filter

143 142 Ex. 7.8 Kaiser Window Design of a Lowpass Filter

144 143 Ex. 7.8 Kaiser Window Design of a Lowpass Filter clear all; clc; close all wp=0.4*pi; ws=0.6*pi; wdelta=ws-wp; Wn=(wp+ws)/2; b=fir1(37,Wn/pi, kaiser(38,5.653)); [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]);

145 144 7.3 Examples of FIR Filters Design by the Kaiser Window Method  The ideal highpass filter with generalized linear phase

146 145 Example 7.9 Kaiser Window Design of a Highpass Filter  Specifications:  By Kaiser window method

147 146 Example 7.9 Kaiser Window Design of a Highpass Filter  Specifications:  By Kaiser window method

148 147 7.3.2 Discrete-Time Differentiator

149 148 Example 7.10 Kaiser Window Design of a Differentiator  Since kaiser’s formulas were developed for frequency responses with simple magnitude discontinuities, it is not straightforward to apply them to differentiators.  Suppose

150 149 Group Delay  Phase:  Group Delay:

151 150 Group Delay  Phase:  Group Delay:  Noninteger delay

152 151 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.

153 152 7.4 Optimum Approximations of FIR Filters

154 153 7.4 Optimum Approximations of FIR Filters  Designing a filter to meet these specifications is to find the (L+1) impulse response values  In Packs-McClellan algorithm, is fixed, and is variable.  Packs-McClellan algorithm is the dominant method for optimum design of FIR filters.

155 154 7.4 Optimum Approximations of FIR Filters

156 155 7.4 Optimum Approximations of FIR Filters

157 156 7.4 Optimum Approximations of FIR Filters

158 157 Minimax criterion  Within the frequency interval of the passband and stopband, we seek a frequency response that minimizes the maximum weighted approximation error of

159 158 Other criterions

160 159  Let denote the closet subset consisting of the disjoint union of closed subsets of the real axis x. Alternation Theorem  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

161 160 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

162 161 Example 7.11 Alternation Theorem and Polynomials  Each of these polynomials is of fifth order.  The closed subsets of the real axis x referred to in the theorem are the regions

163 162 7.4.1 Optimal Type I Lowpass Filters  For Type I lowpass filter  The desired lowpass frequency response  Weighting function

164 163 7.4.1 Optimal Type I Lowpass Filters  The weighted approximation error is  The closed subset is or

165 164 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, 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.

166 165 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).

167 166 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.

168 167 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 slop inside the passband and all points with zero slop inside stopband will correspond to alternations; i.e., the filter will be equiripple, except possibly at and

169 168 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

170 169 7.4.2 Optimal Type II Lowpass Filters

171 170 7.4.2 Optimal Type II Lowpass Filters  For Type II lowpass filter,

172 171 7.4.3 The Park-McClellan Algorithm  From the alternation theorem, the optimum filter will satisfy the set of equation

173 172 7.4.3 The Park-McClellan Algorithm  Guessing a set of alternation frequencies and

174 173 7.4.3 The Park-McClellan Algorithm

175 174 7.4.3 The Park-McClellan Algorithm  For equiripple lowpass approximation  Filter length: (M+1)

176 175 7.5 Examples of FIR Equiripple Approximation 7.5.1 Lowpass Filter

177 176 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 0.0116 and 0.0016, which exceed the specifications.

178 177 7.5.1 Lowpass Filter  M=27,, Type II filter, zero at z=-1  The maximum error in passband and stopband are 0.0092 and 0.00092, 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

179 178 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.

180 179 7.6 Comments on IIR and FIR Discrete-Time Filters  What type of system is best, IIR or FIR?  Why give so many different design methods?  Which method yields the best result?

181 180 7.6 Comments on IIR and FIR Discrete-Time Filters Closed- Form Formulas Generalized Linear Phase Order IIRYesNoLow FIRNoYesHigh

182 181 7.2.1 Properties of Commonly Used Windows  Their Fourier transforms are concentrated around  They have a simple functional form that allows them to be computed easily.  The Fourier transform of the Bartlett window can be expressed as a product of Fourier transforms of rectangular windows.  The Fourier transforms of the other windows can be expressed as sums of frequency-shifted Fourier transforms of rectangular windows.(Problem7.34)

183 182 Homework  Simulate the frequency response (magnitude and phase) for Rectangular, Bartlett, Hanning, Hamming, and Blackman window with M=21 and M=51

184 183 2016-3-13 183 Zhongguo Liu_Biomedical Engineering_Shandong Univ. Chapter 5 HW  7.2, 7.4, 7.15, 上一页下一页 返 回


Download ppt "12016-3-131Zhongguo Liu_Biomedical Engineering_Shandong Univ. Biomedical Signal processing Chapter 7 Filter Design Techniques Zhongguo Liu Biomedical."

Similar presentations


Ads by Google