View
239
Download
0
Category
Tags:
Preview:
DESCRIPTION
Design FIR filter using window Method
Citation preview
Find Content Search or
FIR FILTER DESIGN: THE WINDOW DESIGN METHOD Page by: Nguyen Huu Phuong
� Metadata +
FIR FILTER DESIGN: THE WINDOW DESIGN METHOD Page by: Nguyen Huu Phuong
▸
▸▸
▸ Summary
The design of a FIR filter starts with its specifications in either discrete-time domain or DTFT
frequency domain, or both. In the time domain, the design objective is the impulse response. In the
frequency domain, the requirement is on various parameters of the magnitude response, shown in
Fig.5.8 for a lowpass filter. Important parameters are band edge frequencies and , passband
Choose a Subject
ωp ωs
CNX Author | Legacy Site (//legacy.cnx.org/content/m28304/1.1?legacy=true) | Donate (/donate)
Page 1 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
, transition band , stopband , cutoff frequency ,
passband ripple (or deviation) and stopband ripple . The two ripples are usually assumed
equal . Notice that for ideal (desired) filter, the passband frequency magnitude is normalized to 1 and
the stopband to 0 , and the frequency response of the designed filter oscillates between the high
amplitude of 1 or the low amplitude of 0.
Figure illustrates the specifications of bandpass filter. Here there are two sets of edge frequencies,
lower and upper. The rising bandwith and the falling bandwidth are usually assumed equal.
Even the initial requirement is imposed on magnitude response but we must design the filter having
linear phase or generalized linear phase.
Overall filter design
From the filter specifications, the first step is to choose between FIR and IIR filters based on their
advantages and disadvantages. This chapter only concerns FIR filters. The next step is to select the
proper linear phase FIR filters (section 5.2.3). A rather complete procedure for the design of FIR filters
are as follows.
• Specifications of the filter
• Choosing an appropriate linear phase filter type (section 5.2.3)
• Choosing the mothod of design such as window, optimal, frequency sampling…
• Calculation the filter coefficients (impulse response)
• Finding suitable structure
• Analysis of the finite wordlength effects (chapter 7)
• Implementation of the filter in hardware and/or software (chapter 7).Fig.5.9: Bandpass filter
specifications
Figure 1. Typical normalized magnitude response specfications of a lowpass filter
[0, ]ωp ∆ω = −ωs ωp =( + )/2ωc ωp ωc
δp δs
∆ωl ∆ωu
Figure 2. Bandpass filter specifications
Page 2 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
Fixed windowsThe impulse response of ideal filters is infinite duration (IIR). We cannot evaluate the corresponding
frequency response and, especially, implement the filter by hardware and/or software. Thus we must
truncate the impulse response at both ends with respect to the central. Even we truncate the impulse
response when it is small enough, but such a sudden cutoff will cause some undesired effects. The
window method will reduce them.
In the time domain, windowing means that the we multiply the desired (usually ideal) infinite
duration impulse response by a finite duration window (or window function) to
get a soft truncation. The resulted impulse response of the designed filter is the product
Here we assume that all desired impulse responses and windows are causal, from to
, i.e. window length is samples (time indices). Many authors start the design with
and bi-sided (noncausal), i.e. defined in the interval then shift to the right
indices to make them causal.
Multiplying in time domain corresponds to convolution in frequency domain. Thus the frequency
response of the designed filter (corresponding to the windowed impulse response ) is
where is the Fourier transform (DTFT) of the window .
In the window design method , we first evaluate the desired filter impulse response from the
given desired frequency response , and then apply an appropriate window . Thus the method
should be called the Fourier – window method.
Retangular window
Actually, the sudden truncation mentioned earlier is the simplest window called rectangular window,
defined as (Figure)
(n)hd w(n)h(n)
h(n) = (n)w(n), 0 ≤ n ≤Mhd
n = 0n =M M + 1(n)hd w(n) M/2
h(n)
H(ω)= (ω)∗W(ω)= (ω')W(ω− ω')dω'Hd
1
2π∫
π
−π
Hd
W(ω) w(n)
(n)hd(ω)Hd
Figure 3. Rectangular window of order M or length M + 1
Page 3 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
The Fourier transform of this window is
This is the same as Equation (3.54) when replacing by . Also, instead of the above
expression we can use the sum of cosines (Equations (3.46), (3.53)). has includes a phase
factor showing the time shift of a two-sided symmetric window to a causal window. The magnitude
and phase responses are, respectively,
where is 0 or as discussed in previous section. Thus the window is linear phase. Fig.3.27
illustrates the variation of the amplitude of (remember to replace by ). It is
maximum and equals to at . The zero-crossing points are multiples of
w(n)= , 0 ≤ n ≤M1
, otherwise0
W(ω) = w(n) = =∑n=−∞
∞
e−jωn ∑n=0
M
e−jωn1 − e−jω(M+1)
1 − e−jω
, ω ≠ 0= e−j ωM
2sin ω(M+1)/2
sin ω/2
M + 1 , ω = 0
M 2NW(ω)
Figure 4. Normalized frequency response of rectangular window for M = 30 and 50
|W(ω)| = , ω ≠ 0∣ ∣ sin ω(M+1)/2
sin ω/2∣ ∣
ω = 0M + 1 ,
Φ(ω) = − ω+ βM
2
β π∣W(ω)∣ 2N M
M + 1 ω = 0
Page 4 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
. The response consists of a main lobe and many sidelobes. As gets larger the
main-lobe gets smaller, and there are more sidelobes, also narrower but the amplitude of the first
sidelobe remains the same (Fig.5.11). As , tends to be an unit sample .
The oscillatory when convolved with the ideal lowpass response will result in a
response having a non-zero transition width and ripples is both the passband and stopband.
Fig.5.12 shows the designed lowpass filter when using rectangular window having to
abruptly truncate the impulse response of an ideal lowpass filter with cutoff frequency .
Fig.5.13 shows the magnitude in linear scale for two case of filter order, M = 10 and M = 18.
In order that approaches the rectangular window must be of infinite duration, i.e. we
must take into account the whole impulse response without truncation. In frequency domain this
means is an unit sample as said. We can reason in the reverse direction: Since
then must be a unit sample and the windows must be of
infinite duration. When we simulate on a computer using Maltlab sofware, or else, with in
the hundreds we will still see the non-zero transition width and ripples due to the Gibbs phenomenon
(section 3.1.4). An infinitely long windows is not practical, so the idea is to look for finite duration
windows which perform better than the rectangular.
2π/(M + 1) MM →∞ W(ω) δ(ω)
Figure 5. Magnitude response of designed lowpass filter when using rectangular window with M = 44
∣W(ω)∣ (ω)Hd
H(ω)M = 44
= π/2ωc
H(ω) (ω)Hd
W(ω) δ(ω)H(ω)= (ω)∗δ(ω)= (ω)Hd Hd δ(ω)
H(ω) M
Page 5 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
Actually in examples 5.2.1 and 5.2.2 the truncation of the impulse responses of the ideal filters meant
the rectangular window had been applied.
Other windows
The Gibbs phenomenon can be reduced considerably by the use of a softer (less abrupt) truncation,
i.e. by tapering the rectangular smootly to zero at both ends. Unfortunately, the reduction in amplitude
of sidelobes of is accompanied by a widening of its mainlobe. For comparision, the window
responses are usually plotted in scale.
Figure 6. Magnitude response of designed filter for M = 10 and M = 18
H(ω)W(ω) dB
Page 6 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
Several smooth window functions have been proposed and used. It might come to our mind that the
first applicant would be the triangular window, also called Bartlett window , depicted in Fig.5.14.
From the figure we can write the window function ( table 5.1). Table 5.1 lists common fixed windows
and Fig.5.15 plots their functions. Fig.5.16 plots the dB magnitude for and Fig.5.17 for M = 50.The first
sidelobe is at -25dB compared to the -13dB of the corresponding (same length) rectangular window.
However the mainlobe width is about twice as large.
The sidelobe of the triangular window is still high because the tapering is still rather coarse. For
smoother tapering, cosinusoid is incorporated into the window function. This observation has led to
the three well known windows: Hanning (or von Hann), Hamming, and Blackman, all defined in the
interval , otherwise zero (table 5.1). We can check that the functions are normalized
(peak value of 1 at ) and zero at both ends except the rectangular and the Hamming
(0.08 instead of 0). Besides, there are many other less-used fixed windows.
Notice that all windows mentioned, from rectangular to Blackman, are simple functions easily
evaluated, and their frequency responses concentrate around (the mainlobe) as expected.
Also notice that all the windows mentioned are symmetric about the mid-point , this
when combined with the symmetry or antisymmetry of the filter’s impulse response will make the
corresponding designed filter linear phase or generalized linear phase.
Figure 7. Triangular window (Bartlett window)
Figure 8. Common window plotted as function of continuous time n (whereas actual windows are function
of discrete index n)
0 ≤ n ≤Mn =M/2
ω = 0n =M/2
Page 7 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
Figure 9. dB magnitude frequency response of fixed windows for M = 20 (a) Bartlett, (b) Hanning, (c)
Hamming, (d) Blackman
Page 8 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
Table 5.2 lists various features of common windows for comparison. The passband ripple and the
stopband ripple and the stopband ripple , are taken equal (the smaller of the two):
Fig.5.16, Fig.5.17 and Table 5.2 show that no window is the best in all aspects but there is a tradeoff
of features, and the choice of an appropriate window depending on our requirement. For smallest
mainlobe width it’s the rectangular window, for best sidelobe attenuation it’s the Blackman. In
between, the Hamming is a good choice. The Bartlett is the transition from the rectangular to the other
windows. See section 5.3.3 for design examples.
Figure 10. dB magnitude frequency response of various windows for M = 50 (a) Bartlett, (b) Hanning, (c)
Hamming, (d) Blackman
δs δs
A = −20 [min( , )]log10 δp δs
Page 9 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
The Kaiser windowThe windows discussed so far are fixed windows, only the length is adjustable. The
Kaiser window has an additional ripple parameter , enabling the designer to tradeoff the transition
and ripple. It is defined in the interval , otherwise zero:
where is the modified zeroth-order Bessel function, computed by a power series
expansion:
Following is the values of for small :
The upper limit of the summation does not need to be too large, say about 20 at the most.
(M + 1)β
0 ≤ n ≤M
w(n) = , 0 ≤ n ≤M
{ }I0 1 − ( )n−M/2
M/2
− − − − − − − − − − − √β 2
(β)I0
(x)I0
(x)= 1 + = 1 + + ⋅ ⋅ + ⋅ ⋅ + ⋅I0 ∑k=1
∞ [ ]x(2)k
k!
2
x2
4
1
22x2
4
x2
4
1
z2x2
4
x4
16
(x)I0 x
X (n) X (n)I0 I0
0.0 1.000 1.2 1.3938
0.1 1.002 2.0 2.2796
0.2 1.010 3.0 4.3306
0.4 1.040 4.0 11.302
0.6 1.092 5.0 27.240
0.8 1.166 6.0 67.235
1.0 1.266 7.0 168.59
Page 10 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
For both the numerator and denominator are 1 and the Kaiser window becomes the
rectangular window, and for it is near to the Hamming window. The parameter is so
chosen that the magnitude response of the filter lies in the allowed region (see Fig.5.1). Fig.5.18
shows the Kaiser for various values of and . Notice that the Kaiser is also symmetric. It has
minimum stopband attenuation from 50dB (for ) to 90dB (for ), so we can
choose a Kaiser window to have maximum stopband atternuation equal to the Blackman window (74,
Table 5.2) or higher.
Figure 11. (a) Kaiser window for and 6 and M = 20, (b) Magnitude response corresponding to
the windows in (a), (c) magnitude response for and M = 10, 20,
β = 0, 3β = 6
β = 0β = 5.44 β
β Mβ = 4.54 β = 8.96
Page 11 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
For ideal filters (Fig.5.1 and Fig.5.2) the Kaiser window has equal ripple in both the passband and
stopband. For real filters the ripples are slightly different . In design we take the common ripple as
of the desired values . As said earlier, actually is usually specified in term
of dBs: , for example then , then
. Since is a fraction of 1 then A is always ponsitive.
Kaiser has developed empirical formulae and guide for the application of the window. Following is
design steps for lowpass filters (similarly for other frequency selective filters).
1/ Specifications of edge frequencies ; ripples
2/Evaluate the minimum ripple , the cutoff frequency
, the transition width
3/ Determine the filter filter order M
4/ Determine the parameter , depending on A:
5/ Computer the window coefficients from the formula (5.40)
6/ Compute the impulse response of the desired filter which is linear phase
7/ Compute the designed impulse response .
8/ Find the frequency response to check with specifications. For bandpass
filter the two transition bandwidths are usually equal, if not we take the smaller one.
Design examples
Example
Design a linear phase lowpass filter using the Hamming window to meet the specifications
• Cutoff frequency 2.5 kHz
• Transition width 1.65 kHz
• Stopband attenuation >50dB
• Sampling frequency 10kHz
δδ = min( , )δp δs ,δp δs δ
A = −20 δlog10
δ = 0.01 A = 40dB δ = 0.001A = 60dB δ
,ωp ωs ,δp δs
A = −20 [min( , )]log10
δp δs= ( + )/2ωc ωp ωs △ω = −ωs ωp
M = A−7.952.285∆ω
, A > 21
M = , A ≤ 215.79∆ω
β
β = 0, A ≤ 21
β = 0.5842 + 0.07886(A− 21), 21 ≤ A ≤ 50(A− 21)0.4
β = 0.1102(A− 8.7), A ≥ 50
w(n)
(n)hd
h(n)= (n)w(n)hd
H(ω) = IDTFT [h(n)]
Page 12 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
Solution
The relation between the analog linear frequency samples/sec (or Hz) and the digital angular
frequency radians/sample is (Equation 1.40) is
where is the sampling frequency (samples/sec, or Hz). Thus
• Cutoff frequency rad/sample
• Transition width rad/sample
Table 5.2 shows that the Hamming satisfy (so can the Blackman) the maximum stopband attenuation
( requirement. Table 5.2 includes the relation between transition width and
window order :
Now we compute the causal impulse response of ideal lowpass filter (Equation (5.32)) for
. Notice that for even and symmetric we have linear phase FIR-1
(Fig.5.4a). The result is plotted in Fig.5.19a.
Next we evaluate the Hamming window
The result is plotted in Fig.5.19b.
The impulse response of the designed filter is the product
We can evaluale w(n) and separately as above then take the product, or evaluate the
product directly . The result is plotted in Fig.5.19c. We then take the inverse transform of to get
the frequency response :
Fig.5.19d shows , and Fig.5.19c shows .
Example
Fω
ω = 2πF
fs
fs= 2π = 0.5πωc
2.510
∆ω = 2π = 0.33π1.6510
−20 )log10δs ∆ωM
∆ω = M = = 206.6π
M⇒
6.6π
0.33π
(n)hLP
0 ≤ n ≤ 20 M h(n)
w(n) = 0.54 − 0.46 cos , 0 ≤ n ≤M = 202πn
M
h(n) = (n)w(n) , 0 ≤ n ≤M = 20hLP
(n)hLPh(n)
H(ω)
H(ω)= h(n) = h(n)∑∞
n=−∞ e−jωn ∑M
n=0 e−jωn , M = 20
|H(ω)| |H(ω)|dB
Page 13 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
We need ro extract a low frequency signal having bandwidth 200Hz and center frequency 300Hz
from a blackground noise. Design a bandpass filter having transition width 100Hz, passband
ripple 40dB, stopband ripple 60dB. The sampling frequency is 1200Hz.
Solution
The passband of the signal is from 300 – 200/2 to 300 + 200/2, i.e. from 200Hz to 400Hz. We are to
design a bandpass FIR filter to meet the specifications
• Passband: 200Hz
• Transition width: 100Hz
Figure 12. Example(linear phase lowpass filter with ) using the Hamming
window
= 0.5π, ∆ω = 0.33πωc
Page 14 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
• Passband ripple:
• Stopband ripple:
• Sampling frequency: 1200Hz
From Table 5.2 see that only the Blackman window can satisfy the stopband ripple (so can the Kaiser
window, see next subsection). Since the passband and stopband attenuations are different, we take
the smaller one in the design, i.e. = 60dB. The transition width and the filter order are, respectively,
Figure 13. Example(linear phase bandpass filter using Blackman window
(−20 )= 40dBlog10δp ( = 0.01)δp
(−20 ) = 60dB⇒ = 0.001log10δp δs
A
∆ω = 2π =100
1200
π
6
Page 15 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
Thus the Blackman window is
Ideal bandpass filter impulse response (Equation 5.10b)
where
Since M is odd we have linear phase type 2 (FIR-2) . The designed impulse response is
We then take the inverse transform of h(n) to get or the frequency response of the designed filter
(Fig.5.20).
Example
Design a highpass FIR filter using Kaiser window to meet the specifications :
• Cutoff frequency 2,5 kHz
• Transition width 0.5 kHz
• Passband ripple 0.001
• Stopband attenuation 40dB
• Sampling frequency 10kHz
Solution
First let’s derive the expression of the impule response of ideal highpass filter (Fig.5.1b) with
generalized linear phase (Fig.5.4) (Fig.5.1b) with generalized linear phase (Fig.5.4). The frequency
response of the causal highpass filter in the interval is
M = = 66.6 ≈ 6711.1π
π/6
W(n) = 0.42 − 0.5 cos + 0.08 cos , 0 ≤ n ≤M = 672πn
M
4πn
M
(n) = −hBPsin nωu
πn
sin nωl
πn
= 2π =ωu
400
1200
2π
3
= 2π =ωl200
1200
π
3
h(n)= (n)w(n)hBP
ω = [0,π]
(ω) = 0, 0 ≤ ω ≤HHP ωc
, < ω ≤ πe−j ωM
2 ωc
Page 16 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
or related to the frequency response of the lowpass filter (Equation (5.32)) as
Taking the inverse DTFT of either above expression we will get the impulse response of the ideal
highpass filter
Notice that we cannot just shift the result of the two-sided symmetric impulse response Equation
(5.10a) to get the above causal result (but must replace by before shifting).
The given specifications are interpreted as
• Cutoff frequency : rad/sample
• Transition width : rad/sample
• Passband ripple :
• Stopband ripple : dB
Thus the attenuation is
Knowing and we can determine the window order
Since dB, the ripple parameter is given by
With and , the Kaiser window (Equation (5.40)) is
The impulse response of the FIR-1 highpass filter is computed for , and the
designed impulse response is
As usual, the frequency response is the inverse DTFT of above impulse response.. Using Matlab we
(ω)HLP
(ω)= − (ω)HHP e−j ωM
2 HLP
h = − , n ≠ 0(n)
HP
sin π(n−M/2)
π(n−M/2)
sin (n−M/2)ωc
π(n−M/2)
1 − , n = 0ωcπ
δ(n) sinπn/πn
= 2π = 0.5πωc
2.510
∆ω = 2π = 0.1π0.510
= 0.001δp−20 δ = 40log10 ⇒ = 0.01δs
A = −20 [min( , )] = −20 = 60 dBlog10 δp δs log10δp
∆ω A
M = = = 72.5 ≈ 72A− 7.95
2.285∆ω
60 − 7.95
2.285(0.1π)
A > 50 β
β = 0.1102(A− 8.7)= 5.65
M/2 = 33 β = 5.65
W(n) ={ }I0 1 − ( )n−36
36
2− − − − − − − − − − √5.65(5.65)I0
(n)hHP 0 ≤ n ≤ 66
h(n)= (n)w(n)hHP
Page 17 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
can simulate all the responses. ■
Error in the Fourier design methodLet’s briefly consider the error in the Fourier design. Just like the Fourier series expansion of a signal
(section 3.1), the Fourier design method give the least mean square (LMS) error as presented here.
This also applies to the case of abupt truncation of the desired impulse , that is using the rectangular
window. Let be the error between the desired ideal frequency response and the
designed frequency response :
This error varies with frequency and is a complex quantity , the same as the frequency response. We
are interested in the error amplitude, so we take the square
Since still depends on frequency, we then take its average value:
The problem is to find so that the mean square error is smallest (i.e. least mean square -
LMS). Because the frequency response can be expressed in term of the designed filter impulse
response h(n) , we thus look for the filter impulse response for LMS error. To this end we take the
derivative and equate it to zero to find the root of h(n) for the minimum
. After some mathematics (not presented here) , we will get the impulse response
This result means that when we start the design by evaluating the impulse response from the given
(desired) filter frequency response then we will get the LMS error (i.e. no other design method can
give a smaller mean square error) .
In LMS error we emphasized the large errors ( at local frequencies). This criterion is not always
adopted , other criterion may be more privileged, such as the transition width must be as narrow as
possible, or the error must be distributed evenly in both the passband and the stopband…
ε(ω) (ω)Hd
H(ω)
ε(ω) = (ω) −H(ω)Hd
ε(ω) = ε(ω) + ε(ω) = ε(ω) (ω)∣ ∣ ∣ ∣ 2
Re2 Im2 ε∗
|ε(ω)|2
= |ε(ω) dω = ε(ω) (ω)dωε̄ 12π
∫ π
−π
|2 12π
∫ π
−π
ε∗
= [ (ω) −H(ω)] dω12π
∫π
−π
Hd [ (ω) −H(ω)]Hd2
H(ω) H(ω)H(ω)
d /dh(n)ε̄
ε̄
h(n) = (ω) dω = (n)1
2π∫ π
−π
Hd ejωn hd
Page 18 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
Digital differentiatorIn digital signal processing , sometimes we need to take the differentiation or integration of a signal .
For example the differentiation (derivation) of displacement is speed, and the differentiation of speed
is acceleration. It is interesting that the former can just be realized by a FIR filter or by an IIR filter,
whereas the latter by an IIR filter. In this section we will discuss digital differentiators (Fig.5.2)
designed by linear phase FIR-3 and FIR-4 associated with windowing. Other FIR design method ,
such as the optimal method discussed in the subsequent section , can also be used.
In an analog differentiator the output signal y(t) is related to the input signal x(t) by
For a LTI (LSI) digital system having frequency response (i.e.DTFT) , an input
will give the output (section 3.7.3):
On the other hand the derivative of the input is
By comparing the above two expressions we obtain
This is the frequency response of ideal digital differentiator. The response is purely imaginary, the
magnitude response is proportional to the frequency and the phase response is ,
independent of frequency (Fig.5.2) . Thus differentiators are generalized linear phase (Equation (5.17)
with ). Fig.5.21 shows the variation of .
y(t) =dx(t)
dt
H(ω) x(n) = ejnω
H(ω)ejωn
y(n) = H(ω)ejωn
x(n) = ejωn
y(n) = = jωdx(n)
dnejωn
H (ω) = jω , − π ≤ ω ≤ π
|H(ω)| Φ(ω) π/2
α = 0 , β = π/2 |H(ω)|
Page 19 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
Even looked so simple but the such a differentiator cannot be realized exactly in practice . Thus
approximate ciruits are used, the simplest of which is the first order differentiator which is just the
difference
Its frequency response can be found to be
whose magnitude is
This is plotted in Fig.5.21 . The approximation is surprisingly good especially at low frequency. Notice
that for small ,
Actually a differentiator is usually designed to use at the low frequency because the high response at
high frequency will enhance noise. This again means that the simple first order differentiator is very
good. The linear phase FIR filter implementing the differentiator is of FIR-4 type (
)
In order to reduce the high response at high frequency, the central differentiator is the candidate :
Figure 14. Frequency response of various types digital differentiators
y(n) = x(n) − x(n− 1)
H(ω) = 1 − = (1 − cosω) + j sinωe−jω
H(ω) = = 2 sin∣
∣ ∣
∣
∣ ∣ [ + ω](1 − cosω)2 sin2
1/2 ω
2
H(ω) ≈ (1 − 1) + jω = jω (small ω)
H(ω) = 0at ω = 0 and ≠ 0 at ω = π
y(n) = 0.5x(n) − 0.5x(n− 2)
Page 20 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
having frequency response
The magnitude response is
The response is also plotted in the same Fig.5.21. Notice also that at low . The linear
phase FIR filter implementing the differentiator is of FIR-3 type ( at both and
).
Example
For the ideal differentiator.
2. Find the expression of its two-sided impulse response . Evaluate and plot the response for
with M = 20
4. Find the expression of its causal impulse response.
6. Design a differentiator using the Hamming window of length 21.
Solution
Taking the inverse DTFT of the known frequency response we will get the two-
sided impulse response.
H(ω) = 0.5 − 0.5 = 0.5 [(1 − cos 2ω) + j sin 2ω]e−j2ω
|H(ω)| = sinω
H(ω) ≈ 0 ω
H(ω) = 0 ω = 0ω = π
−M/2 ≤ n ≤M/2
H(ω) = −jω
(n) = (ω) dωhDIF12π
∫ π
−π
Hd ejωn
H(ω) cosωndω + j (ω) dω= 12π
∫π
−π
1
2π∫
π
−π
Hd sinωn
Page 21 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
Because is an odd function while cosine is even and sine is odd, we only need to take the last
term of the above expression:
or
The last case is obtained by taking the original integral. Fig 5.22a depicts the impulse response which
is of FIR-3.
2. We cannot just shift the noncausal result Equation (5.49a) M/2 time indices , i.e. by replacing n by n
– M/2 , together the causal impulse response. Let’s start from the frequency response of a causal
linear phase differentiator ( the two-sided response is delayed by M/2 samples):
Taking the inverse transform to get the causal impulse response
Figure 15. Example impulse response having M = 20 of ideal differentiator ((a) two-sided (noncausal), (b)
causal)
(ω)Hd
(n) = j (ω) sinωndω = − ω sinωndωhDIF12π
∫π
−π
Hd1π ∫
π
0
= , n ≠ 0cos nπn
0 , n = 0
(n) = − , n = ±1,±3,±5...hDIF1n
, n = ±2,±4,±6...1n
0 , n = 0
jω
H(ω) = jω , − π ≤ ω ≤ πe−j ωM
2
Page 22 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
When putting M/2 = 0 in above Equation we will get back Equation (5.49a) as expected.
In both impusle response (5.49a) and (5.50) we can notice that , thus
the differentiator is linear phase type 3 when M is even (Fig.5.4c) or type 4 when M is odd (Fig.5.4d).
3. Window length of 21 means M + 1 = 21 and the filter order is M = 20. We can use the two-sided
impulse response in (a) and shift M/2 = 10 time indices to the future to get the causal response , or
use the causal response in (b) . Fig.5.23a is the frequency response of the differentiator with
truncation (equivalent to using rectangular window), Fig.5.23b is the frequency response of the
differentiator when using the Hamming window. The optional method (later section) is a better method
to design digital differentiator.
Downloads + History + Attribution +
(n) = − , n ≠M/2hD/Fcos(n−M/2)π
(n−M/2)
sin(n−M/2)π
π(n−M/2)2
0 , n =M/2
(n) = − (M − n)hD/F hD/F
Figure 16. Example (magnitude response of differentiator for M = 20 when (a) using truncation
(rectangular window) and (b) using the Hamming window)
Page 23 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
(http://creativecommons.org)
Licensing (/license) Terms of Use (/tos) Contact (/about/contact)
Supported by William & Flora Hewlett Foundation, Bill & Melinda Gates Foundation, 20 Million Minds
Foundation, Maxfield Foundation, Open Society Foundations, and Rice University. Powered by OpenStax
CNX.
© 1999-2015, Rice University. Except where otherwise
noted, content created on this site is licensed under a
Creative Commons Attribution 4.0 License.
Page 24 of 24FIR FILTER DESIGN: THE WINDOW DESIGN METHOD - OpenStax CNX
12/3/2015http://cnx.org/contents/d98107c1-0621-49bc-9f3b-1a72b19314c8@1/FIR-FILTER-DESIG...
Recommended