Download presentation
Presentation is loading. Please wait.
1
Chapter 7 FIR Digital Filter Design
2
Introduce In this chapter, we consider the FIR digital filter design problem. Unlike the IIR digital filter design problem, it is always possible to design FIR digital filters with exact linear-phase. In the case of FIR digital filter design, the stability is not a design issue as the transfer function is a polynomial in z-1.
3
Introduce First, we describe a popular approach to the design of FIR digital filters with linear-phase. We then consider the computer-aided design of linear-phase FIR digital filters. To this end, we restrict our discussion to the use of MATLAB in determining the transfer functions.
4
Advantages FIR digital filter is always guaranteed stable.
It is always possible to design FIR digital filters with exact linear-phase.
5
Disadvantages The order of the FIR transfer function is usually much higher than that of an IIR transfer function meeting the same frequency response specification.
6
7.1 Linear-phase FIR transfer function
In the previous section, we pointed out why it is important to have a transfer function with a linear-phase property. In this section, we develop the forms of a linear-phase FIR transfer function H(z) with real impulse response h(n).
7
7.1 Linear-phase FIR transfer function
If H(z) is required to have a linear-phase, its frequency response must be of the form Where Hg(ω) is called the amplitude response. NOTE: Hg(ω) is different from |H(ejω)|. Θ(ω) is a linear-phase function.
8
7.1 Linear-phase FIR transfer function
Type 1 linear-phase: Type 2 linear-phase: A unify representation:
9
7.1 Linear-phase FIR transfer function
It can be proven that the transfer function have a linear-phase, if its impulse response h(n) is either symmetric or is antisymmetric
10
7.1 Linear-phase FIR transfer function
11
7.1 Linear-phase FIR transfer function
12
7.1 Linear-phase FIR transfer function
13
7.1 Linear-phase FIR transfer function
14
7.1 Linear-phase FIR transfer function
15
7.1 Linear-phase FIR transfer function
16
7.1 Linear-phase FIR transfer function
Type 1 FIR Transfer Function The impulse response of a Type1 FIR transfer function is of odd length, that is, the degree N is even and satisfies the symmetry condition. Its amplitude response Hg(ω) is given by
17
7.1 Linear-phase FIR transfer function
Type 2 FIR Transfer Function The impulse response of a Type2 FIR filter is of even length, that is, the degree N is odd and satisfies the symmetry condition. Its amplitude response Hg(ω) is given by
18
7.1 Linear-phase FIR transfer function
Type 3 FIR Transfer Function The impulse response of a Type3 FIR filter is of even length, that is, the degree N is odd and satisfies the antisymmetry condition. Its amplitude response Hg(ω) is given by
19
7.1 Linear-phase FIR transfer function
Type 4 FIR Transfer Function The impulse response of a Type1 FIR filter is of even length, that is, the degree N is odd and satisfies the antisymmetry condition. Its amplitude response Hg(ω) is given by
22
7.1 Linear-phase FIR transfer function
23
7.1 Linear-phase FIR transfer function
24
7.1 Linear-phase FIR transfer function
25
7.1 Linear-phase FIR transfer function
26
7.1 Linear-phase FIR transfer function
27
7.1 Linear-phase FIR transfer function
28
7.1 Linear-phase FIR transfer function
29
7.1 Linear-phase FIR transfer function
30
7.2 FIR Filter Design based on Windows Function Method
We now turn our attention to the design of real coefficient FIR filters. These filters are described by a transfer function that is a polynomial in z-1and therefore require different approaches for their design.
31
7.2 FIR Filter Design based on Windows Function Method
A direct and straightforward method is based on truncating the Fourier series representation of the prescribed frequency response is discussed in this section.
32
7.2.1 Windows function method
Let Hd(ejω) denote the desired frequency response function. Since Hd(ejω) is a periodic function of ω with a period 2π, it can be expressed as a Fourier series,
33
7.2.1 Windows function method
Where the Fourier coefficients are precisely the corresponding impulse response samples and are given by
34
7.2.1 Windows function method
Thus, given a frequency response specification Hd(ejω), we can compute hd[n] using the above equation and, hence, determine the transfer function Hd(z). However, for most practical applications, the desired frequency response is piecewise constant with sharp transitions between bands, in which case, the corresponding impulse response sequence {hd[n]} is of infinite length and noncausal.
35
7.2.1 Windows function method
Our objective is to find a finite-duration impulse response sequence {ht[n]} of length 2M+1 whose DTFT Ht(ejω) approximates the desired DTFT Hd(ejω) in some sense.
36
7.2.1 Windows function method
One commonly used approximation criterion is to minimize the integral-squared error where
37
7.2.1 Windows function method
Using Parseval’s relation, we can further obtained It is evident that the integral-squared error is minimum when for In other words, the best finite-length approximation to ideal infinite-length impulse response in the mean-square error sense is simply obtained by truncation.
38
7.2.1 Windows function method
A causal FIR filter with an impulse response h[n] can be derived from ht[n] by delaying the latter sequence by M samples, that is, by forming The causal filter h[n] has the same magnitude response as that of the noncausal filter ht[n] and its phase response has a linear phase shift of ωM ridians with respect to that of the noncausal filter.
39
7.2.2 impulse Response of Ideal Filters
Ideal frequency selective filters are characterized by passband and stopband with sharp transitions from passband to stopband. Four such commonly used filters are the lowpass, highpass, bandpass, and bandstop filters whose ideal frequency response have been discussed.
40
7.2.2 impulse Response of Ideal Filters
The frequency response of the ideal lowpass filter is The corresponding impulse response coefficients is It is doubly infinite, not absolutely summable, and therefore unrealizable.
41
7.2.2 impulse Response of Ideal Filters
By setting all impulse response coefficients outside the range –M<=n<=M equal to zero, we arrive at a finite-length noncausal approximation of length 2M+1, which when shifted to the right yields the coefficients of a causal FIR lowpass filter:
42
7.2.2 impulse Response of Ideal Filters
The frequency responses of the ideal highpass, bandpass and bandstop filter is
43
7.2.2 impulse Response of Ideal Filters
The impulse responses of the ideal highpass, bandpass and bandstop filter is
44
7.2.2 impulse Response of Ideal Filters
They are also characterized by doubly infinite impulse response that are not absolutely summable, making them unrealizable. They can be made realizable by truncating the impulse response sequence to finite lengths and shifting the truncated coefficients to the right appropriately.
45
7.2.3 Gibbs Phenomenon The causal FIR filters obtained by simply truncating the impulse response coefficients of the ideal filters given in the previous section exhibit an oscillatory behavior in their respective magnitude responses, which is more commonly referred to as the Gibbs phenomenon.
46
7.2.3 Gibbs Phenomenon The reason behind the Gibbs phenomenon can be explained by considering the truncation operation as multiplication by a finite-length window sequence w[n] and by examining the windowing process in the frequency domain.
47
7.2.3 Gibbs Phenomenon The FIR filter obtained by truncation can be alternatively expressed as From the modulation theorem, the Fourier transform is given by
48
7.2.3 Gibbs Phenomenon 其中 Wg(ω)称为矩形窗的幅度函数,a=(N-1)/2。则 所以
加窗后的滤波器的幅度特性等于理想低通滤波器的幅度特性与矩形窗幅度特性的卷积。 所以
49
图 矩形窗对理想低通 幅度特性的影响
50
7.2.3 Gibbs Phenomenon 加窗后的影响: (1)在理想特性不连续点ωc附近形成过渡带。
(2)通带内产生了波纹,最大值在ωc-2π/N处。阻带产生了余振,最大的负峰在 ωc+2π/N。 (3)通带与阻带中的波纹与窗函数的幅度谱有关,其旁瓣幅度直接影响滤波器的波纹幅度。
51
7.2.1 Windows function method
如何减小Gibbs效应的影响 增加矩形窗的长度,是否可以减少Gibbs效应的影响? 因为 加大N只能使过渡带变窄,但不能有效减小Gibbs效应的影响。 结论:要减少带内波动以及增大阻带衰减,只能从窗函数的形状上找解决问题的方法。
52
7.2.4 Fixed Windows Function
The commonly used window of length N=2M+1 listed below: Rectangular: Barlett: Hann: Hamming: Blackman:
53
7.2.4 Fixed Windows Function
The frequency response are listed below: Rectangular: Barlett: Hanning: Hamming: Blackman:
54
7.2.4 Fixed Windows Function
55
7.2.4 Fixed Windows Function
56
7.2.4 Fixed Windows Function
The essential properties of the above widow functions, except the Bartlett window
57
表7.2.1 凯塞窗参数对滤波器的性能影响
58
7.2.4 Fixed Windows Function
表 六种窗函数的基本参数
59
7.2.4 Fixed Windows Function
In the case of the window function of Rectangular, Hann and Hamming, the value of the ripple δ does not depend on the filter length, or the cutoff frequency ωc, and is essentially constant.
60
7.2.4 Fixed Windows Function
In addition, the transition bandwidth is approximately given by Where c is a constant for most practical purposes and is determined from the above table after the specific windows has been selected.
61
7.2.5 Design Step Step 1: select windows function and N
Step 2: modeling the desired frequency response 根据设计需要,一般选择相应的线性相位理想滤波器。 Step 3: calculate Step 4: obtain the impulse response of the desired FIR filter
62
Example 用窗函数法设计线性相位高通FIR DF。 通带截止频率: 阻带截止频率: 通带最大衰减: 阻带最小衰减:
63
Example Step 1: 选择窗函数。 已知阻带最小衰减为40dB,可知Hann和Hamming窗均满足要求,我们选Hamming窗。
Hamming窗的过度带宽度ΔB=8π/N,所以有 可得 对高通滤波器,N必须取奇数,所以,N=33。
64
Example Step 2: 其中
65
Example Step 3: 求hd(n)。 ,所以
66
Example Step 4: 加窗
67
7.2.6 FIR Filter Design using MATLAB
hn=fir1(M,wc) %ep721.m: 例7.2.1 wp=pi/2; ws=pi/4; Bt=wp-ws; N0=ceil(6.2*pi/Bt); N=N0+mod(N0+1,2); wc=(wp+ws)/2/pi; hn=fir1(N-1,wc,’high’,hanning(N));
68
7.3 FIR filter design using frequency sampling
Basic idea Let the desired frequency function be Hd(ejω). We can obtain Hd(k) by sampling it in ω∈[0,2π] with interval T Taking N-point IDFT, we can obtain
69
7.3 FIR filter design using frequency sampling
Taking Z-transform, the transfer function H(z) is given This can be implemented with the direct form. Or It can be implemented with the frequency sampling structure.
70
7.3 FIR filter design using frequency sampling
Constrain condition of Hd(k) By the linear-phase condition: H(n) is a real sequence
71
7.3 FIR filter design using frequency sampling
We can obtain that the frequency response should satisfy
72
7.3 FIR filter design using frequency sampling
The sampling points in [0,2π] are at We can obtain Constrain condition
73
7.3 FIR filter design using frequency sampling
Assume the desired filter Hd(ejω) is a ideal lowpass filter with ωc, then N-point Hg(k) and θ(k) can be computed: When N=odd
74
7.3 FIR filter design using frequency sampling
When N=even
75
7.3 FIR filter design using frequency sampling
Error and improvement If the frequency response of desired FIR filter is Hd(ejω) and its impulse response is hd(n), then, If Hd(ejω) is not a smooth continuous function, the corresponding impulse response hd(n) is infinite length. It leads to aliasing h(n).
76
7.3 FIR filter design using frequency sampling
The increasing N leads to decreasing transition band width, high computational complexity, but αp and αs can not be obviously improved. The improved αs can be obtained by interpolating at the discontinuous points. m 1 2 3 as 44~54dB 65~75dB 85~95dB
77
图 理想低通滤波器增加过渡点
78
7.3 FIR filter design using frequency sampling
Design step 根据阻带衰减确定过渡带采样点的个数m; 确定过渡带宽度,估算频域采样点数N; 构造希望逼近的频率响应函数; 进行频率采样; 取IDFT,得到h(n); 检验结果,如未达到指标要求,修改过渡带采样值。
79
7.3 FIR filter design using frequency sampling
Examples See P220
80
7.4 Computer-Aided Design of Equiripple Linear-Phase FIR Filters
In this section, we consider the application of computer-aided optimization technique for the design of FIR filters.
81
7.4 Computer-Aided Design of Equiripple Linear-Phase FIR Filters
The basic idea behind the computer-based technique is to minimize iteratively an error measure that is function of the difference between the desired frequency response D(ejω) and the frequency response H(ejω) of the filter being designed.
82
7.4 Computer-Aided Design of Equiripple Linear-Phase FIR Filters
The design objective is to iteratively adjust the filter parameters so that ε defined by the followed equation is a minimum. Minimax criterion Least-squares criterion
83
7.4 Computer-Aided Design of Equiripple Linear-Phase FIR Filters
The linear-phase FIR filter obtained by minimizing the peak absolute value of the weighted error ε given by the above equation is usually called the equiripple FIR filter. Since here, after ε has been minimized, the weighted error function ε(ω) exhibits an equiripple behavior in the frequency range of interest.
84
The Parks-McClellan Algorithm
A weighted-Chebyshev approximation method has been advanced by Parks and McClellan for designing equiripple liear-phase FIR filters.
85
The Parks-McClellan Algorithm
The general form of the frequency response H(ejω) of a causal linear-phase FIR filter of length N+1 is given by Where the amplitude response is a real function ω.
86
The Parks-McClellan Algorithm
The weighted error function in this case involves the amplitude response and is given by The desired amplitude response A positive weighting function The Parks-McClellan algorithm is based on iteratively adjusting the coefficients of the amplitude response until the peak absolute value of ε(ω) is minimized.
87
The Parks-McClellan Algorithm
If the minimum value of the peak absolute value of ε(ω) in a ωa<= ω<= ωb is ε0, then the absolute error satisfies
88
The Parks-McClellan Algorithm
In typical filter design applications, the desired amplitude response is given by The amplitude response is required to satisfy the above desired response with a ripple of ±δp in the passband and a ripple δs in the stop.
89
The Parks-McClellan Algorithm
As a result, it is evident from the weighted error function that the weighting function can be chosen either as or as
90
The Parks-McClellan Algorithm
By a clever manipulation, the expression for the amplitude response for each of the four types of linear-phase FIR filters can be expressed in the same form. The same algorithm can be adapted to design any one of the four types of filters. To develop this general form for the amplitude response expression, we consider each of the four types of filters separately.
91
The Parks-McClellan Algorithm
For the Type 1 linear-phase FIR filter, the amplitude response can be rewritten using the notation N=2M in the form where
92
The Parks-McClellan Algorithm
For Type 2 linear-phase FIR filter, the amplitude response can be rewritten in the form where
93
The Parks-McClellan Algorithm
For Type 2 linear-phase FIR filter, the amplitude response can be rewritten in the form where
94
The Parks-McClellan Algorithm
For the Type 3 linear-phase FIR filter, the amplitude response can be rewritten in the form where
95
The Parks-McClellan Algorithm
For the Type 4 linear-phase FIR filter, the amplitude response can be rewritten in the form where
96
The Parks-McClellan Algorithm
The amplitude response for all four types of linear-phase FIR filters can be expressed in the form Where the first factor Q(ω) is given by
97
The Parks-McClellan Algorithm
98
The Parks-McClellan Algorithm
We arrive at a modified form of the weighted approximation function given by Using the notation
99
The Parks-McClellan Algorithm
The optimization problem now becomes the determination of the coefficients Then, the corresponding coefficients of the original amplitude response are computed from which the filter coefficients are obtained.
100
Alteration Theorem The amplitude function A(ω) is the best unique approximation of the desired amplitude response obtained by minimizing the peak absolute valueεof ε(ω) if and only if there exist at least L+2 extremal angular frequencies.
101
The Parks-McClellan Algorithm
The Remez exchange algrithm, a highly efficient iterative procedure, is used to determine the locations of the extremal frequencies and consists of the following steps at each iteration stage:
102
The Parks-McClellan Algorithm
Step 1: A set of initial value for the extremal frequencies are either chosen or are available from the completion of the previous iteration.
103
The Parks-McClellan Algorithm
Step 2: The value ε is then computed by solving the following equation
104
The Parks-McClellan Algorithm
Step 3: The values of the amplitude response A(ω) at ω= ωi are then computed using
105
The Parks-McClellan Algorithm
Step 4: The polynomial A(ω) is determine by interpolating the above values at the L+2 extremal frequencies using the Lagrange interpolation formula:
106
The Parks-McClellan Algorithm
Step 5: The new weighted error function ε(ω) is computed at a dense set S(S>=L) of frequencies. In practice, S=16L is adequate. Determine the L+2 new extremal frequencies from the values of ε(ω) evaluated at the dense set of frequencies.
107
The Parks-McClellan Algorithm
Step 6: If the peak values ε are equal in magnitude, the algorithm has converged. Otherwise, go bask to Step 2.
108
10.5 FIR Digital Filter Design Using MATLAB
The signal Processing ToolBox of MATLAB includes a variety of M-files for the design of FIR digital filters.
109
10.5.1 FIR Digital Filter Order Estimation Using MATLAB
As in the case of FIR digital filter design, the FIR digital filter design process also consists of two steps. In the first step, the filter order is estimated from the given specification In the second step, the coefficients of the transfer function are determined using the estimated order and filter specifications..
110
10.5.1 FIR Digital Filter Order Estimation Using MATLAB
Example FIR Filter Order Estimation Using Kaiser’s Formula N=kaiord( , , 1800, 2000, 12000)
111
10.5.1 FIR Digital Filter Order Estimation Using MATLAB
Example FIR Filter Order Estimation Using Bellanger’s Formula. N=kaiord( , , 1800, 2000, 12000)
112
10.5.1 FIR Digital Filter Order Estimation Using MATLAB
Example FIR Filter Order Estimation Using Hermann’s Formula fedge = input('Type in the bandedges = '); mval = input('Desired magnitude values in each band = '); dev = input('Allowable deviation in each band = '); FT = input('Type in the sampling frequency = '); [N, fpts, mag, wt] = remezord(fedge, mval, dev, FT); fprintf('Filter order is %d \n',N);
113
10.5.2 Equiripple Linear-Phase FIR Filter Design Using MATLAB
For designing an equiripple linear-phase FIR filter employing the Parks-McClellan algorithm, we can use the MATLAB M-files remez.
114
10.5.2 Equiripple Linear-Phase FIR Filter Design Using MATLAB
Example Design of an Equiripple Linear-Phase FIR Lowpass Filter Using Remez Algorithm.
115
10.5.2 Equiripple Linear-Phase FIR Filter Design Using MATLAB
% Program 10_2 % Design of Equiripple Linear-Phase FIR Filters % format long fedge = input('Band edges in Hz = '); mval = input('Desired magnitude values in each band = '); dev = input('Desired ripple in each band ='); FT = input('Sampling frequency in Hz = '); [N,fpts,mag,wt] = remezord(fedge,mval,dev,FT); b = remez(N,fpts,mag,wt); disp('FIR Filter Coefficients'); disp(b) [h,w] = freqz(b,1,256); plot(w/pi,20*log10(abs(h)));grid; xlabel('\omega/\pi'); ylabel('Gain, dB');
117
10.5.2 Equiripple Linear-Phase FIR Filter Design Using MATLAB
Example Design of an Equiripple Linear-Phase FIR bandpass Filter Using Remez Algorithm. N=input(‘Filter order= ‘); Fpts=input(‘Normalized band edges = ‘); Mag=input(‘ Desired weights for each band = ‘); [N,fpts,mag,wt] = remezord(fedge,mval,dev,FT); b = remez(N,fpts,mag,wt); disp('FIR Filter Coefficients'); disp(b) [h,w] = freqz(b,1,256); plot(w/pi,20*log10(abs(h)));grid; xlabel('\omega/\pi'); ylabel('Gain, dB');
118
10.5.4 Windows-Based FIR Filter Design Using MATLAB
The windows-based FIR filter design process involves three steps: First, the type of window to be used is determined to meet the desired stopband attenuation. second, the order of the FIR filter to be designed is estimated. Finally, the desired impulse response of the ideal filter is computed, which is then multiplied by the window coefficients generated in the first step to yield the coefficients of FIR filter.
119
Window Generation W=blackman(L) W=hamming(L) W=hann(L) W=chebwin(L,Rs)
W=kaiser(L,beta)
120
Window Generation Example 10.24 Kaiser window generation using MATLAB
fpts = input('Type in the bandedges = '); mag = input('Type in the desired magnitude values = '); dev = input('Type in the ripples in each band = '); [N,Wn,beta,ftype] = kaiserord(fpts,mag,dev) w = kaiser(N+1,beta); w = w/sum(w); [h,omega] = freqz(w,1,256); plot(omega/pi,20*log10(abs(h)));grid; xlabel('\omega/\pi'); ylabel('Gain, dB');
121
Filter Design The functions available in MATLAB for the design of FIR filters using the windowed Fourier series approach are fir1 and fir2. The function fir1 is used to design conventional lowpass, highpass, bandpass, bandstop, and multiband FIR filters. The function fir2 is employed to design FIR filters with arbitrarily shaped magnitude response.
122
Filter Design Example 10.25 Lowpass FIR Design Using the Kaiser Window
The desired specifications for the filter are fpts = input('Type in the bandedges = '); mag = input('Type in the desired magnitude values = '); dev = input('Type in the ripples in each band = '); [N,Wn,beta,ftype] = kaiserord(fpts,mag,dev) kw = kaiser(N+1,beta); b = fir1(N,Wn, kw); [h,omega] = freqz(b,1,512); plot(omega/pi,20*log10(abs(h)));grid; xlabel('\omega/\pi'); ylabel('Gain, dB');
123
Filter Design Example Highpass FIR Filter Design Using the Kaiser Window A highpass FIR filter is to be designed meeting the following specifications:
124
Filter Design fpts = input('Type in the bandedges = ');
mag = input('Type in the desired magnitude values = '); dev = input('Type in the ripples in each band = '); [N,Wn,beta,ftype] = kaiserord(fpts,mag,dev) kw = kaiser(N+1,beta); b = fir1(N,Wn,’highpass’ , kw); [h,omega] = freqz(b,1,512); plot(omega/pi,20*log10(abs(h)));grid; xlabel('\omega/\pi'); ylabel('Gain, dB');
125
Filter Design Example Design of Multiband FIR Filter Using Hamming Window Consider the design of an FIR filter of order 100 with three different constant magnitude levels: 0.3 in the frequency range 0 to 0.28, 1.0 in the frequency range 0.3 to 5.0, and 0.7 in the frequency range 0.52 to 2.0.
126
10.5.4 Windows-Based FIR Filter Design Using MATLAB
% Program 10_6 % Design of Multiband FIR Filter Using Hamming Window % fpts = [ ]; mval = [ ]; b = fir2(100,fpts,mval); [h,omega] = freqz(b,1,512); plot(omega/pi,abs(h));grid; xlabel('\omega/\pi'); ylabel('Magnitude');
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.