We can easily design the FIR filter to meet the required magnitude response in such a way that it achieves a constant group delay.. The phase response of a filter with a constant group del
Trang 1Finite Impulse Response Filters
5.1 INTRODUCTION
From the previous two chapters, we have become familiar with the magnituderesponse of ideal lowpass, highpass, bandpass, and bandstop filters, which wasapproximated by IIR filters In the previous chapter, we also discussed the theoryand a few prominent procedures for designing the IIR filters
The general form of the difference equation for a linear, time-invariant,discrete-time system (LTIDT system) is
1+ a(1)z−1+ a(2)z−2+ a(3)z−3+ · · · + a(N)z −N (5.2)
The transfer function of an FIR filter, in particular, is given by
H (z−1) = b0+ b(1)z−1+ b(2)z−2+ · · · + b(M)z −M (5.3)and the difference equation describing this FIR filter is given by
dis-Introduction to Digital Signal Processing and Filter Design, by B A Shenoi
Copyright © 2006 John Wiley & Sons, Inc.
249
Trang 2output y(n) can be obtained by applying the recursive algorithm on (5.4) We
get the output y(n) due to the unit sample input δ(n) to be exactly the values b(0), b(1), b(2), b(3), , b(M) The output due to the unit sample function δ(n)
is the unit sample response or the unit impulse response denoted by h(n) So
the samples of the unit impulse responseh(n) = b(n), which means that the unit
impulse response h(n) of the discrete-time system described by the difference equation (5.4) is finite in length That is why the system is called the finite impulse response filter or the FIR filter It has also been known by other names such as
the transversal filter, nonrecursive filter, moving-average filter, and tapped delayfilter Since h(n) = b(n) in the case of an FIR filter, we can represent (5.3) in
the following form:
1 We can easily design the FIR filter to meet the required magnitude response
in such a way that it achieves a constant group delay Group delay is defined
as τ = −(dθ/dω), where θ is the phase response of the filter The phase
response of a filter with a constant group delay is therefore a linear function
of frequency It transmits all frequencies with the same amount of delay,which means that there will not be any phase distortion and the input signalwill be delayed by a constant when it is transmitted to the output A filterwith a constant group delay is highly desirable in the transmission of digitalsignals
2 The samples of its unit impulse response are the same as the coefficients
of the transfer function as seen from (5.5) and (5.6) There is no need tocalculateh(n) from H (z−1), such as during every stage of the iterative opti-
mization procedure or for designing the structures (circuits) fromH (z−1).
3 The FIR filters are always stable and are free from limit cycles that arise
as a result of finite wordlength representation of multiplier constants andsignal values
4 The effect of finite wordlength on the specified frequency response or the
time-domain response or the output noise is smaller than that for IIR filters
5 Although the unit impulse response h(n) of an IIR filter is an infinitely
long sequence, it is reasonable to assume in most practical cases that thevalue of the samples becomes almost negligible after a finite number; thus,choosing a sequence of finite length for the discrete-time signal allows us
to use powerful numerical methods for processing signals of finite length
Trang 3of the filter equal to the number of coefficients in (5.6) is N+ 1 If we aregiven H (z−1) = 0.3z−4+ 0.1z−5+ 0.5z−6, its order is 6, although only threeterms are present and the correct number of coefficients equal to the length ofthe filter is 7, becauseh(0) = h(1) = h(2) = h(3) = 0 It becomes necessary to
point out the notation used in this chapter, because in some textbooks, we mayfindH (z−1)=Nn=0−1h(n)z −nrepresenting the transfer function of an FIR filter,
in which case the length of the filter is denoted by N and the degree or order
of the polynomial is (N − 1) (Therefore students have to be careful in using
the formulas found in a chapter on FIR filters, in different books; but with somecaution, they can replaceN that appears in this chapter by (N − 1) so that the
formulas match those found in these books.)
The notation often used in MATLAB, is H (z−1) = h(1) + h(2)z−1+
h(3)z−2+ · · · + h(N + 1)z −N, which is a polynomial of degree N , and has (N + 1) coefficients In more compact form, it is given by
discrete-w= 2πf is the angular frequency in radians per second, f is the frequency in
hertz, and its reciprocal is the period T p in seconds So we have w= 2π/Tp
radians per second Now if we sample this signal with a uniform samplingperiod, we need to differentiate the periodT p from the sampling period denoted
by T s Therefore, the sampled sequence is given by x(nT s ) = A sin(wnTs )=
A sin(2π nT s /T p ) = A sin(2πf/fs ) = A sin(w/fs ) The frequency w (in radians
per second) normalized by f s is almost always denoted by ω and is called the
normalized frequency (measured in radians) The frequency w is the analog
fre-quency variable, and the frefre-quency ω is the normalized digital frequency On
this basis, the sampling frequencyω s = 2π radians Sometimes, w is normalized
by πf s or 2πf s so that the corresponding sampling frequency becomes 2 or 1radian(s) Note that almost always, the sampling period is denoted simply byT
in the literature on digital signal processing when there is no ambiguity and thenormalized frequency is denoted byω = wT The difference between the angular
frequency in radians per second and the normalized frequency usually used inDSP literature has been pointed out in several instances in this book
5.2 LINEAR PHASE FIR FILTERS
Now we consider the special types of FIR filters in which the coefficientsh(n)
of the transfer function H (z−1)=N
n=0h(n)z −n are assumed to be symmetric
or antisymmetric Since the order of the polynomial in each of these two types
Trang 4can be either odd or even, we have four types of filters with different properties,which we describe below.
Type I The coefficients are symmetric [i.e., h(n) = h(N − n)], and the order
Trang 5Let us evaluate its frequency response (DTFT):
H (e −jω ) = e −j3ω {2h(0) cos(3ω) + 2h(1) cos(2ω) + 2h(2) cos(ω) + h(3)}
= e j θ(ω) {HR (ω)}
The expression H R (ω) in this equation is a real-valued function, but it can be
positive or negative at any particular frequency, so when it changes from apositive value to a negative value, the phase angle changes byπ radians (180◦).The phase angleθ (ω) = −3ω is a linear function of ω, and the group delay τ is
equal to three samples Note that on the normalized frequency basis, the groupdelay is three samples but actual group delay is 3T seconds, where T is the
⎫
⎬
⎭= e j θ(ω) {HR (ω)}
(5.11)The total group delay is a constant =N/2 in the general case, for a type I FIR
filter
Type II The coefficients are symmetric [i.e., h(n) = h(N − n)], and the order
N is odd.
Example 5.2
Here we consider an example in which the coefficients are symmetric butN= 7,
as shown in Figure 5.1b For this example, we have
H (z−1) = h(0) + h(1)z−1+ h(2)z−2+ h(3)z−1+ h(4)z−4+ h(5)z−5
+ h(6)z−6+ h(7)z−7
Trang 6and because of symmetry
h(0) = h(7), h(1) = h(6), h(2) = h(5), h(3) = h(4).
Therefore
H (z−1) = h(0)[1 + z−7]+ h(1)[z−1+ z−6]+ h(2)[z−2+ z−5]
+ h(3)[z−3+ z−4]The frequency response is given by
H (e −jω ) = e −j3.5ω {2h(0) cos(3.5ω) + 2h(1) cos(2.5ω)
+ 2h(2) cos(1.5ω) + 2h(3) cos(0.5ω)}
= e j θ(ω) {HR (ω)}The phase angle θ (ω) = −3.5ω, and the group delay is τ = 3.5 samples.
In the general case of type II filter, we obtain
n−12
Trang 7Now if we putz = e j ω, ande j ω − e −jω = 2j sin(ω) = 2e j (π/2)sin(ω), we arrive
at the frequency response for this filter as
H (e −jω ) = e −j3ω {h(0)2j sin(3ω) + h(1)2j sin(2ω) + h(2)2j sin(ω)} (5.15)
= e −j3ω e j (π/2) {2h(0) sin(3ω) + 2h(1) sin(2ω) + 2h(2) sin(ω)} (5.16)
Note that the phase angle for this filter is θ (ω) = −3ω + π/2, which is still a
linear function ofω The group delay is τ = 3 samples for this filter
In the general case, it can be shown that
Trang 8This type IV filter with N = 7 has a linear phase θ(ω) = −3.5ω + π/2 and a
constant group delay τ = 3.5 samples.
The transfer function of the type IV linear phase filter in general is given by
n−12
ω
⎫⎬
⎭(5.21)The frequency responses of the four types of FIR filters are summarized below:
⎫
⎬
⎭for type I
n−12
ω
⎫⎬
⎭for type II
⎫
⎬
⎭for type III
n−12
ω
⎫⎬
⎭for type IV (5.22)
5.2.1 Properties of Linear Phase FIR Filters
The four types of FIR filters discussed above have shown us that FIR filterswith symmetric or antisymmetric coefficients provide linear phase (or equiva-lently constant group delay); these coefficients are samples of the unit impulseresponse It has been shown above that an FIR filter with symmetric or anti-symmetric coefficients has a linear phase and therefore a constant group delay.The reverse statement, that an FIR filter with a constant group delay must havesymmetric or antisymmetric coefficients, has also been proved theoretically [4].These properties are very useful in the design of FIR filters and their applica-tions To see some additional properties of these four types of filters, we haveevaluated the magnitude response of typical FIR filters with linear phase Theyare shown in Figure 5.2
The following observations about these typical magnitude responses will beuseful in making proper choices in the early stage of their design, as will be
Trang 90.5 0
3 2.5 2 1.5 1 0.5 0 Normalized frequency
Magnitude response of type IV FIR filter
2.5
2 1.5 1
0.5 0
2 1.5 1 0.5 0 Normalized frequency
Magnitude response of type II FIR filter
Figure 5.2 Magnitude responses of the four types of linear phase FIR filters.
explained later For example, type I filters have a nonzero magnitude atω= 0 andalso a nonzero value at the normalized frequencyω/π = 1 (which corresponds tothe Nyquist frequency), whereas type II filters have nonzero magnitude atω= 0but a zero value at the Nyquist frequency So it is obvious that these filters arenot suitable for designing bandpass and highpass filters, whereas both of themare suitable for lowpass filters The type III filters have zero magnitude atω= 0and also atω/π = 1, so they are suitable for designing bandpass filters but notlowpass and bandstop filters Type IV filters have zero magnitude atω= 0 and
a nonzero magnitude at ω/π= 1 They are not suitable for designing lowpassand bandstop filters but are candidates for bandpass and highpass filters
In Figure 5.3a, the phase response of a type I filter is plotted showing thelinear relationship When the transfer function has a zero on the unit circle inthez plane, its phase response displays a jump discontinuity of π radians at the
corresponding frequency, and the plot uses a jump discontinuity of 2π whenever
the phase response exceeds±π so that the total phase response remains within
the principal range of ±π If there are no jump discontinuities of π radians,
that is, if there are no zeros on the unit circle, the phase response becomes a
Trang 10−2
−4 6
−14
−12
−10
−8
Figure 5.3 Linear phase responses of type I FIR filter.
continuous function of ω when it is unwrapped The result of unwrapping the
phase (Fig 5.3a) is to remove the jump discontinuities in the phase responsesuch that the phase response lies within ±π (Fig 5.3b) If the order N of the
FIR filter is even, its group delay is an integer multiple of samples equal toN/2
samples If the orderN is odd, then the group delay is equal to (an integer plus
half) a sample We will use all of these properties before we start the design ofFIR filters with linear phase
The linear phase FIR filters have some interesting properties in the z plane
also As seen in the examples, their transfer functions always contain pairs ofterms such as [z n ± z −n] Denoting the transfer function of the FIR filters with
symmetric coefficients by H (z), we write
Trang 11Similarly, the FIR filters with antisymmetric coefficients satisfy the property
A polynomialH (z) satisfying (5.25) is called a mirror image polynomial , and the polynomial that satisfies (5.26) is called an anti–mirror image polynomial
We see that a polynomialH (z) that has symmetric coefficients is a mirror image
polynomial and one with antisymmetric coefficients is an anti–mirror imagepolynomial The reverse statement is also true and can be proved, namely, that
a mirror image polynomial has symmetric coefficients and an anti–mirror imagepolynomial has antisymmetric coefficients
From (5.25) and (5.26), it is easy to note that in a mirror image polynomial
as well as an anti–mirror image polynomial, if z = z1 is a zero of H (z), then
1/z is also a zero of H (z) If the zero z1 is a complex number r1e j φ ; |r| < 1,
then z∗1= r1e −jφ is also a zero Their reciprocals(1/r1)e −jφ and(1/r1)e j φ arealso zeros ofH (z), which lie outside the unit circle |z| = 1 Therefore complex
zeros of mirror image polynomials and anti–mirror image polynomials appearwith quadrantal symmetry as shown in Figure 5.4 If there is a zero on the unitcircle (e.g., atz0= e j φ ), its reciprocal z−1 = e −jφ is already located on the unit
circle, as the complex conjugate ofz0, and therefore zeros on the unit circle donot have quadrantal symmetry Obviously a zero on the real axis atz r = r inside
the unit circle will be paired with one outside the unit circle on the real axis at
Trang 12Example 5.5
We consider the example of a type I FIR filter with H (z−1) = 0.4 + 0.6z−1+
0.8z−2+ 0.2z−3+ 0.8z−4+ 0.6z−5+ 0.4z−6, to illustrate these properties When
it is expressed in the form H (z) = z−6[0.4 + 0.6z + 0.8z2+ 0.2z3+ 0.8z4+
0.6z5+ 0.4z6] and factorized, we get
H (z)= (z − z1) (z − z∗
1)(z − z−1)(z − z−1∗)(z − z2)(z − z∗
2)
where z1= 0.69e j 128.6◦, z∗1= 0.69e −j128.6◦, z−11 = 1.45e −j128.6◦, z1−1∗=
1.45e j 128.6◦, z2= e j 54.12◦, andz−1∗2 = e −j54.12◦ They are plotted in Figure 5.4
along with the six poles ofH (z) at z = 0 The two zeros at z2andz∗2are on theunit circle, and the other four zeros form a quadrantal symmetry in this plot Themagnitude of this type I filter is illustrated in Figure 5.2a, which shows that themagnitude has zero value at the two frequencies corresponding to the two zeros
at z2 and z∗2 that are on the unit circle In Figure 5.3, the phase response alsoshows discontinuities at these two frequencies
Some additional properties of the four types of FIR filters are listed below:
1 Type I FIR filters have either an even number of zeros or no zeros at z= 1and z= −1
2 Type II FIR filters have an even number of zeros or no zeros at z= 1 and
an odd number of zeros atz= −1
3 Type III FIR filters have an odd number of zeros at z = 1 and z = −1.
4 Type IV FIR filters have an odd number of zeros at z= 1 and either aneven or odd number of zeros atz= −1
These properties confirm the properties of the magnitude response of the filters
as illustrated by Figure 5.2 A zero atz = 1 corresponds to ω = 0, and a zero
atz = −1 corresponds to ω = π As an example, we note that the type III FIR
filter has zero magnitude atω = 0 and ω = 1, whereas we stated above that the
transfer function of the type III FIR filter has an odd number of zeros both at
z = 1 and z = −1.
Another important result that will be used in the Fourier series method fordesigning FIR filters is given below This is true of all FIR as well as IIRfilters and not just linear phase FIR filters The Fourier transform (DTFT) of anydiscrete-time sequencex(n) is
X(e j ω )=
n =∞
n=−∞
Trang 13SinceH (e j ω ) is a periodic function with a period of 2π , it has a Fourier series
representation in the form
Comparing (5.28) and (5.29), we see that x(n) = c(n) for −∞ < n < ∞.
When we consider the frequency response of the LTI-DT system H (e j ω )=
n=∞
n=0 h(n)e −jnω, where h(n) = 0 for n < 0, we will find that c(n) = 0 for
n < 0 So we note that the Fourier series coefficients c(n) evaluated from (5.30)
are the same as the coefficients h(n) of the IIR or FIR filter Evaluating the
coefficientsc(n) = h(n) by the integral in the Equation (5.30) is easy when we
choose H (e j ω ) to be a constant in the subinterval within the interval of
inte-gration [−π, π] with zero phase or when H(e j ω ) is piecewise constant over
different disjoint passbands and stopbands, within [−π, π] This result
facili-tates the design of FIR filters that approximate the magnitude response of ideallowpass, highpass, bandpass, and bandstop filters.1 The Fourier series methodbased on the abovementioned properties of FIR filters for designing them isdiscussed next
5.3 FOURIER SERIES METHOD MODIFIED BY WINDOWS
The magnitude responses of four ideal classical types of digital filters are shown inFigure 5.5 Let us consider the magnitude response of the ideal, desired, lowpassdigital filter to beHLP(e j ω ), in which the cutoff frequency is given as ω c It has
a constant magnitude of one and zero phase over the frequency|ω| < ωc From
Trang 15Continuing with the design of the lowpass filter, we choose the finite series
n=M
n =−M cLP(n)e −jnω = HM (e j ω ), which contains (2M + 1) coefficients from −M
to M, as an approximation to the infinite series n=∞
n=−∞cLP(n)e −jnω In otherwords, we approximate the ideal frequency response that exactly matches the given
HLP(e j ω ) containing the infinite number of coefficients by H M (e j ω ), which
con-tains a finite number of coefficients AsM increases, the finite series of H M (e j ω )
approximates the ideal responseHLP(e j ω ) in the least mean-squares sense; that is,
the error defined as
n =M
n =−M
sin(ω c n)
π n
e −jnω − HLP(e j ω )
2
dω
attains a minimum at all frequencies, except at points of discontinuity
We can make the error shown above as small as we like by choosing M
as large as we wish As M increases, the number of ripples in the passband
(and the stopband) increases while the width between the frequencies at whichthe maximum error occurs in the passband (0≤ ω ≤ ωc ) and in the stopband (ω c ≤ ω ≤ π) decreases In other words, as M increases, the maximum deviation
from the ideal value decreases except near the point of discontinuity, where theerror remains the same, however large the value ofM we choose! The maximum
error or the overshoot from the ideal passband value or the stopband value is 11%
of the difference between the ideal passband value that is normalized to 1 andthe stopband value as shown in Figure 5.6 The magnitude response H M (e j ω )
is plotted for two different values ofM in Figure 5.6, where Hid(ω) is the ideal
magnitude response of the lowpass filter as shown in Figure 5.5a
5.3.1 Gibbs Phenomenon
These are some of the features of what is known as the “Gibbs phenomenon,”which was mathematically derived by Gibbs We explain it qualitatively as fol-lows The finite sequence c(n); −M ≤ n ≤ M can be considered as the result
of multiplying the infinite sequence c(n); −∞ ≤ n ≤ ∞ by a finite window
So we have the producth w (n) = c(n) · wR (n), which is of finite length as shown
in Figure 5.7(c) Therefore the frequency response of the product of these two
Trang 16M 0
hw (n)
Figure 5.7 Coefficients of the FIR filter modified by a rectangular window function.
Trang 17functions is obtained from the convolution of(e j ω ) with the frequency response
HLP(e j ω ) of the ideal, desired, frequency response.
H M (e j ω )= 1
2π
π
−π HLP(e j ϕ )(e j (ω −ϕ) ) dϕ (5.40)The mainlobe of(e j ω ), centered at ω= 0, has a width defined by the firstzero crossings on either sides ofω = 0, which occur when [(2M + 1) ω
2] =±π,
that is, whenω = 2π(2M + 1) so that the width of the mainlobe is 4π/(2M + 1).
As M increases, the width of the mainlobe and the sidelobes decreases, giving
rise to more sidelobes or ripples in the same frequency band At the same time,the peak amplitudes of the mainlobe and the sidelobes increase such that thearea under each lobe remains constant These features of(e j ω ) directly reflect
on the behavior of H M (e j ω ) when it is convolved with HLP(e j ϕ ) The effect
of convolution between HLP(e j ω ) and (e j ω ) is illustrated by looking at the
overlapping interval over which the product HLP(e j ϕ )(e j (ω −ϕ) ) is integrated,
for four different values ofω, in Figure 5.8 It is obvious that if the width of the
mainlobe is extremely narrow, the resulting H M (e j ω ) will have a sharp drop at
ω = ωc If the number of sidelobes or their peak values in (e j ω ) increases, so
also will the number of ripples and the maximum error inH M (e j ω ).
Trang 185.3.2 Use of Window Functions
In order to reduce the effects of the Gibbs phenomenon, some researchers haveproposed the use of tapered windows [11,12]; many others have proposed othertypes of window functions Only a few of the more popular window functionsare given below Note that the number of coefficients generated by the windowfunctions given below is 2M + 1 = N + 1:
two frequencies at which the peak error in H M (e j ω ) occurs is denoted as ω M.When the frequency response of the window functions is convolved with thefrequency response of the desired lowpass filter, the transition bandwidth of thefilter is determined by the width of the mainlobe of the window chosen and hence
is different for filters modified by the different window functions The relativesidelobe level Asl is defined as the difference in decibels between the magni-tudes of the mainlobe of the window function chosen and the largest sidelobe
It determines the maximum attenuation A s = −20 log10(δ) in the stopband of
the filter
In Figure 5.9 we have also shown the transition bandwidthω and the center
frequency ω c = (ωp + ωc )/2, where ω p and ω s are respectively the cutoff quencies of the passband and the stopband The value of the ripple δ does not
fre-depend on the length (2M + 1) of the filter or the cutoff frequency ωc of the
2In many textbooks, the Bartlett window is also called a triangular window, but in MATLAB, the
Bartlett window is different from the triangular window.
Trang 19filter The width of the mainlobe ω M, the transition bandwidth ω, and the
relative sidelobe attenuationAslfor the few chosen window functions are listed inTable 5.1 The last column lists the minimum attenuationA s = −20 log10δ s real-ized by the lowpass filters, using the corresponding window functions It should
be pointed out that the numbers in Table 5.1 have been obtained by simulatingthe performance of type I FIR filters withω c = 0.4π and M = 128 [1], and they
would change if other types of filters and other values forω c andM are chosen.
From Table 5.1, we see that asA s increases, with fixed value forM, the transition
bandwidthω also increases Since we like to have a large value for A s and asmall value forω, we have to make a tradeoff between them The choice of the
window function and the value forM are the only two freedoms that we have for
controlling the transition bandwidthω, but the minimum stopband attenuation
A s depends only on the window function we choose, and not the value ofM.
Two window functions that provide control over bothδ s (hence A s ) and the
width of the transition bandwidthω are the Dolph–Chebyshev window [6] and
the Kaiser window functions [7], which have the additional parametersr and β,
respectively The Kaiser window is defined by
Trang 20TABLE 5.1 Some Properties of Commonly Used Windows
k=1
(x/2) k k!
2
(5.42)
We compute the values of the Kaiser window function in three steps as follows:
• The parameter β required to achieve the desired attenuation α s =
−20 log10(δ s ) in the stopband is calculated from the following empirical
formula derived by Kaiser (the ripple in the passband is nearly the same
where ω = ωs − ωp is the transition bandwidth as shown in Figure 5.9
• The third step is to compute I0{x} In practice, adding a finite number of
terms, say, 20 terms of the infinite series, gives a sufficiently accurate valueforI0{x} The parameter x in the numerator represents β"1− (n/M)2in thenumerator of (5.41), so the value of x takes different values as n changes.
5.3.3 FIR Filter Design Procedures
The steps discussed in the design procedure for linear phase FIR filters are marized as follows:
Trang 21sum-1 Depending on the nature of the magnitude response, we choose a value
for M and use (5.31), (5.34), (5.35), or (5.36) to compute the values of
the coefficients CLP(n), CHP(n), CBP(n), or CBS(n) for −M ≤ n ≤ M.
Then we choose a window function (Bartlett, Hamming, Hann, Kaiser,
or other window) and compute its values w(n) for −M ≤ n ≤ M In the
case of Kaiser’s window, we find the value of M = N/2 from (5.44),
whereas he has derived a few other empirical formulas to estimate thevalue ofN , for designing FIR filters using other window functions.3Notethat we have to choose the lowest even integer N greater than the value
calculated from (5.44), since Kaiser’s window is used for the design oftype I filters only
2 Then we multiply the coefficients c(n) and w(n) to get the values of
h w (n) The filter with these finite numbers of coefficients has a frequency
response given by H w (e j ω ) = hw ( −M)e j ωM + hw ( −M + 1)e j ( −M+1)ω+
· · · + hw (1)e j ω + hw (0) + hw (1)e −jω + · · · + hw (M)e −jMω
3 The next step is to multiply H w (e j ω ) by e −jMω, which is equivalent todelaying the coefficients by M samples to get h(n) [i.e., h w (n − M) = h(n)] By delaying the product of c(n) and w(n) by M samples, we have
obtained a causal filter of finite length(N + 1) with coefficients h(n) for
value Its group delay is a constant equal to M samples This completes the
general procedure for designing an FIR filter that approximates the ideal tude response of a lowpass FIR filter; similar procedures are used for designinghighpass, bandpass, and bandstop filters Let us illustrate this procedure by twosimple examples
magni-3 The formulas given by Kaiser may not give a robust estimate of the order for all cases of FIR filters.
A more reliable estimate is given by an empirical formula [10] shown below, and that formula is used in the MATLAB function remezord :
a5(log10δ p ) + a6
, and F (δ p , δ s ) = b1+ b2
log10δ p− log 10δ s
, with a1= 0.005309, a2 =
0.07114, a3= −0.4761, a4= 0.00266, a5= 0.5941, a6= 0.4278, b1= 11.01217, b2= 0.51244.
Whenδ p < δ s, they are interchanged in the expression forD∞(δ p , δ s ) above.
Trang 22; −5 ≤ n ≤ 5
Their products h w (n) = cBP(n)w H (n) are computed next The 11 coefficients
cBP(n), w H (n) and h w (n) for −5 ≤ n ≤ 5 are listed below Next the coefficients
h w (n) are delayed by five samples to get the coefficients of the FIR filter function
[i.e., h(n) = hw (n − 5)], and these are also listed for 0 ≤ n ≤ 10 below The
plot of the four sequences and the magnitude response of the FIR are shown inFigures 5.10 and 5.11, respectively
Design a lowpass FIR filter of length 11, with a cutoff frequency ω c = 0.3π.
Using a Hamming window, find the value of the samples h(3) and h(9) of the
FIR filter given by H (z−1)=10
n=0h(n)z −n.Since the length of the FIR filter is given as 11, its order is N = 10 Thecoefficientsh w (n) have to be known for −5 ≤ n ≤ 5 and delayed by five samples.
Trang 23−0.2
0 2 4 6 8 10
Founer series coefficients of the BP filter Coefficients of the Hamming window
Coefficients of the noncausal BP filter Samples of the FIR BP filter
Trang 24Since onlyh(3) and h(9) are asked for, by looking at Figure 5.10, we notice that
these samples are the same ash w ( −2) and hw (4) because when they are shifted
by five samples, they become h(3) and h(9) So we have to calculate only
cLP( −2), cLP(4) and the values w( −2), w(4) of the Hamming window Then
h w ( −2) = cLP( −2)w(−2) and hw (4) = cLP(4)w(4).
If the frequency response of an FIR filter has multilevel magnitude levels, it
is easy to extend the method as illustrated by Figure 5.12a We design a lowpassfilter with a cutoff frequency ω c1 and a maximum magnitude of 0.8, anotherlowpass filter with a cutoff frequency ω c2, and a maximum magnitude of 0.2
in the passband; we design a highpass filter with a cutoff frequency ω c3 and amaximum value of 0.5 and another bandpass filter with cutoff frequenciesω c3and
ω c4 and a maximum magnitude of 1.0 If all of these filters are designed to havezero phase or the same phase response, then the sum of the four filters describedabove will approximate the magnitude levels over the different passbands Each
of the four filters should be designed to have very low sidelobes so that theydon’t spill over too much into the passbands of the adjacent filter
Even when we design an FIR filter having a constant magnitude over onepassband or one stopband, using the methods described above will produce atransition band between the ideal passband and the stopband Instead of mitigatingthe Gibbs overshoot at points of discontinuity by using tapered windows, wecan make a modification to the ideal piecewise, constant magnitude response toremove the discontinuities We choose a spline function of orderp≥ 0 betweenthe passband and the stopband [5] The spline function of zero order is a straightline joining the edge of the passband and the stopband as shown in Figure 5.12bThe Fourier series coefficients for the lowpass frequency response in this aregiven by
sin(ω c n)
π n
; |n| > 0 (5.45)
where ω = ωs − ωp andω c = [(ωs + ωp )/2].
Trang 25A smoother transition is achieved when we choose a higher-order spline tion (e.g.,p= 2,3,4) In that case, the Fourier series coefficients are given by
psin(ω c n)
is decreased and as p is increased, the magnitude response of the filter exhibits
ripples in the passband as well as the stopband, and it is not much better thanthe response we can obtain from the windowed FIR filters
5.4 DESIGN OF WINDOWED FIR FILTERS USING MATLAB
5.4.1 Estimation of Filter Order
In the discussion of the Fourier series method, it was pointed out that we had achoice only between the windows (Bartlett, Hamming, Hann, etc.) and the order
N = 2M of the filter There is no guideline for choosing the type of window
or the value for N ; in other words, they are chosen arbitrarily on a
trial-and-error basis until the specifications are satisfied But in the case of Kaiser andDolph–Chebyshev windows, we have an empirical formula to estimate the order
N that achieves a desired stopband attenuation α s However, it was pointedout earlier that some authors have derived empirical formulas for estimating theorder N even when windows like those mentioned above are chosen We use
the MATLAB M-file kaiserord(available in the MATLAB Signal ProcessingToolbox) to estimate the orderN of the filter using the Kaiser window We will,
however, use the M-file remezordto estimate the order of the filter using theother windows After the order of the filter has been obtained, the next step inthe design procedure is to find the values of the unit impulse responseh(n) of
the filter that are the same as the coefficients of the FIR filter transfer function.The MATLAB M-filefir1 is used for designing filters with piecewise constantmagnitudes discussed above, andfir2is the M-file used for arbitrary magnitudespecifications In the following examples, note thatN is the order of the FIR filter
that therefore hasN + 1 coefficients but N is the number of coefficients in such
MATLAB functions such ashammingused for computing the window functions!
Example 5.8
If the magnitude response specified in the passband of an FIR filter lies between
1+ δpand 1− δp, then the maximum attenuationα p ( in decibels) in the passband
Trang 26is 20 log 10(1 + δp ) − 20 log 10(1 − δp ) = 20 log[(1 + δp )/(1 − δp )] Solving for
δ pin this case, we get
δ p= 100.05α p− 1
100.05α p+ 1
If the passband magnitude lies between 1 and(1 − δp ), then the maximum
atten-uation in the passband α p = −20 log(1 − δp ), in which case δ p is given by
(1− 10−0.05αp ) If the magnitude in the stopband lies below δ s, the minimumattenuation in the stopband is given byα s = −20 log(δs ), from which we obtain
δ s = 10−0.05αs These relations are used to find the value of δ p and δ s if theattenuations α p and α s in the passband and stopband are specified in decibels
In the MATLAB function [N, fpoints, magpoints,wt] = remezord
edges of the disjoint bands between 0 and the Nyquist frequency but does notinclude the frequency atω= 0 and the Nyquist frequency, as the default value ofthe Nyquist frequency is 1.0 (and therefore the sampling frequency Fs=2) Thevector bandmaglists the magnitudes over each of the passbands and stopbands
If there is transition band between the passband and stopband, it is considered
as a “don’t care” region Since the first edge at 0 and the last one at the Nyquistfrequency are not included in the vector edgepoints, the length of the vector
a bandpass filter with a stopband [0 0.1], a transition band [0.1 0.12], a
pass-band [0.12 0.3], a transition band [0.3 0.32], and a stopband [0.32 1.0].
The input vector edgepoints and the output vector fpoints are the same,
length 3, and the values may be chosen, for example, as [0 1 0] for the pass filter The vector dev lists the values for the maximum deviations δ p and
band-δ s in the passbands and stopbands, calculated from the specifications forα p and
α s as explained above The output vector fpointsis the same asedgepointswhen Fs has the default value of 2; if the edgepoints and the sampling fre-quencyFsare actual frequencies in hertz, then the output vectorfpointsgivestheir values normalized by the actual Nyquist frequency Fs/2 But it must bepointed out that the output vector magpointslists the magnitudes at both ends
of the passbands and stopbands In the above example, the vector magpoints
is [0 0 1 1 0 0] The output of this function is used as the input data tofir1 and (also the functionremez, discussed later) to obtain the unit impulseresponse coefficients of the FIR filter
Let us consider a lowpass filter with a passband over [0 0.3] and a magnitude
1.0 and a stopband over [0.4 1.0] with a magnitude 0.0 In this case, there is
transition band between 0.3 and 0.4 over which the magnitude is not specified,and therefore it is a “don’t care” region The vector edgepointsis [0.3 0.4],
and the vector bandmag is [1.0 0.0] For the previous example of a bandpass
filter, we have already mentioned that edgepoints is [0.1 0.12 0.3 0.32]
and the vector bandmag is [0 1 0] Let us select δ p = δs = 0.01 for both
Trang 27filters, namely, a log magnitude of α p = −20 log(1 − δp ) = 0.087 dB for the
ripple in the passband and a gain of−40 dB in the stopband
The function remezord for estimating the order of the lowpass filter is asfollows:
[N, fpoints, magpoints, wt] = remezord([0.3 0.4], [1.0 0.0], [0.01 0.01], 2)
and it yields a valueN= 39, with the same vectorfpointsasbandmagand thevector wt=[1.0 1.0] If we choose a sampling frequency of 2000 Hz, we use remezord([0.3 0.4], [1.0 0.0], [0.01 0.01], 2000), and the outputwould beN = 39,fpoints=[0.3 0.4], magpoints=[1 1 0 0]and the vec-
[i.e., wt = [(δs/δp) 1]] These output values are used as input in fir1 (or
The function for estimating the order of the bandpass filter is
[N, fpoints, magpoints, wt]=remezord([0.1 0.12 0.3 0.32], [0.0 1.0 0.0], [0.01 0.01 0.01], 2).
which givesN = 195, with the same vectorfpointsas the input vector
The MATLAB functionkaiserordgiven below is used to estimate the order
N of the FIR filter using the Kaiser window The input parameters for this
function are the same as forremezord, but the outputs are the approximate order
N of the Kaiser window required to meet the input specifications, the normalized
frequencies at thebandedges, the parameter beta, and the filtertype:
[N, Wc, Beta, ftype]=kaiserord(edgepoints, bandmag, dev, Fs)For the lowpass filter specified above, we use
[N, Wc, Beta, ftype] =kaiserord([0.3 0.4], [1.0 0.0],
[0.01 0.01], 2)
and we getN=45, Wc=0.35, Beta=3.3953.
For the bandpass filter, with the same input parameters as those used in
and when it isDC-1, it indicates that the first band is a passband.
5.4.2 Design of the FIR Filter
After we have found the order of the filter and any other parameters as the output
of the functions remezord and kaiserord, we use the function fir1, whichtakes various forms as described below: