Unit - 5
FIR Filter Design & Realization
Linear phase is a property of a filter, where the phase response of the filter is a linear function of frequency. The result is that all frequency components of the input signal are shifted in time (usually delayed) by the same constant amount, which is referred to as the phase delay. And consequently, there is no phase distortion due to the time delay of frequencies relative to one another. Linear-phase filters have a symmetric impulse response. The FIR filter has linear phase if its unit sample response satisfies the following condition: h(n) = h(M − 1 − n) n = 0, 1, 2, . . . , N − 1 The Z transform of the unit sample response is given as
H[z] =
Symmetric impulse response with M=odd Then h(n) = h(M − 1 − n) and (z = ejω)
H() = |H()|ei∠H()
For M=even
H() = |H()|ei∠H()
Linear phase is a property of a filter, where the phase response of the filter is a linear function of frequency. The result is that all frequency components of the input signal are shifted in time (usually delayed) by the same constant amount, which is referred to as the phase delay. And consequently, there is no phase distortion due to the time delay of frequencies relative to one another. Linear-phase filters have a symmetric impulse response. The FIR filter has linear phase if its unit sample response satisfies the following condition: h(n) = h(M − 1 − n) n = 0, 1, 2, . . . , N − 1 The Z transform of the unit sample response is given as
H[z] =
Symmetric impulse response with M=odd Then h(n) = h(M − 1 − n) and (z = ejω)
H() = |H()|ei∠H()
For M=even
H() = |H()|ei∠H()
Windowing method
Let the frequency response of the desired LTI system we wish to approximate be given by
Hd(ej) =
Where hd(n) is the corresponding impulse response.
Consider obtaining a casual FIR filter that approximates hd(n) by letting
h[n] =
The FIR filter then has frequency response
H(ej) =
Note that since we can write
hd(n) = 1/2π
We are actually forming a finite Fourier series approximation to Hd(ej)
Since the ideal Hd(ej) may contain discontinuities at the band edges, truncation of the Fourier series will result in the Gibbs phenomenon.
To allow for a less abrupt Fourier series truncation and hence reduce Gibbs phenomenon oscillations, we may generalize h [n] by writing
h[n] = hd [n] [n]
Where [n] is a finite duration window function of length M +1.
Rectangular Window
This is the simplest window function but provides the worst performance from the viewpoint of stopband attenuation. The width of main lobe is 4π/N
ωR(n) = 1 for n=0,1,M-1
= 0 otherwise
Magnitude response of rectangular window is
|WR(ω)| =
Fig: Rectangular Window
Bartlett (Triangular) Window
Bartlett Window is also Triangular window. The width of main lobe is 8π/M
ωt(n) = 1-
Fig: Bartlett Window
Hanning Window
This is a raised cosine window function given by:
W(n) = ½ [ 1 – cos (2πn/(M-1))] ]
W(ω) = 0.5WR(ω) +0.25[WR (ω - 2π/M) + WR (ω - 2π/M)]
Fig: Hanning Window
Hamming Window
This is a modified version of the raised cosine window
W(n) = [ 0.54 - 0.46 cos (2πn/(M – 1))]]
W(ω) = 0.54WR(ω) +0.23[WR (ω - 2π/M) + WR (ω - 2π/M)]
Fig: Hamming Window
Blackman Window
This is a 2nd -order raised cosine window
W(n) = [ 0.42 – 0.5 cos (2πn/(M – 1)) + 0.08 cos (4 πn/(M-1))]]
W(ω) = 0.42WR(ω) +0.25[WR (ω - 2π/M) + WR (ω -2π/M)]+ 0.04[WR (ω -4π/M) + WR (ω - 4π/M)]
Fig: Blackman Window
Key takeaway
Window name
| Window function |
Rectangular | R(n) = |
Triangular
| r(n) = 1 – |
Hamming | w(n) = | 0.54 – 0.46 cos (2πn/(N – 1))| |
Hanning | w(n) = | 0.5 – 0.5 cos (2πn/(N – 1))| |
Blackman | w(n) = | 0.42 – 0.5 cos (2πn/(N – 1)) + 0.08 cos (4πn/(N – 1)) + | |
Window name | Transition width of main lobe | Min. Stopband attenuation | Peak value of side lobe |
Rectangular | -21dB | -21dB | |
Hanning | -44dB | -31dB | |
Hamming | -53dB | -41Db | |
Barlett | -25dB | -25Db | |
Blackman | -74dB | -57Db |
Example
Q1) Design a LPF using rectangular window for the desired frequency response of a low pass filter given by ωc = π/2 rad/sec, and take M=11. Find the values of h(n). Also plot the magnitude response.
Sol:
r= M-1/2 = 5
By taking inverse Fourier transform
hd (n) = 1/2π
= 1/2π
= 1/2π
hd (n) = 1/2π
hd(n) =
For n ≠ 5 and c = π/2 , r = (M – 1)/2 = 5
hd(n) =
For n = 5 hdb (n) = 0/0, Using L’Hospital Rule
Where π = 3.1416
hd(0) =
hd(1) =
hd(2) =
hd(3) =
hd(4) =
hd(5) =
hd(6) =
hd(7) =
hd(8) =
hd(9) =
hd(10) =
The given window is rectangular window ω(n) = 1 for 0 ≤ n ≤ 10
=0 Otherwise
This is rectangular window of length M=11. h(n) = hd (n)ω(n) = hd (n) for 0 ≤ n ≤ 10
H[z]=
The impulse response is symmetric with M=odd=11
H(z) = h ((M – 1)/2)
= h(5) z-5 + h(0) [z-1 + z-9] + h(n) [z-n + zM – 1- n]
= h(5) z-5 + h(0) [z-0 + z-10] + h(1)[z-1+z-9] + h(2)[z-2 + z-8] + h(3)[z-3 + z-7] + h(4)[z-4 + z-6]
|H(ej) = 0.5 + 2h(0) cos 5 + 2h(1) cos 4 + 2h(2) cos 3 + 2h(3) cos 2 + 2h(4) cos
= 0.5 + 0.127 cos 5 - 0.212 cos 3 + 0.636 cos
|H(ej)| = 0.5 + 0.127 cos 5 - 0.212 cos 3 + 0.636 cos
|H(ej)| = 20 log |H(ej)|
| |H(ej)| | |H(ej)|dB |
0 0.1π 0.2π 0.3π 0.4π 0.5π 0.6π 0.7π 0.8π 0.9π 1.0π | 1.0151 0.9808 0.9535 1.0758 0.9952 0.5 0.0048 0.0758 0.467 0.0192 0.0512 | -0.44 -0.17 -0.41 +0.63 -0.04 -6.02 -46.37 -22.41 -26.65 -34.35 -25.74 |
Response
Q2) The desired frequency response of low pass filter is given by Hd (ejω) = e−j3ω − 3π/ 4 ≤ ω ≤ 3π/ 4 and 0 for 3π /4 ≤ |ω| ≤ π Determine the frequency response of the FIR if Hamming window is used with N=7
Sol
t = M-1/2 = 3
hd (n) = 1/2π
= 1/2π
= 1/2π
hd (n) = 1/2π
hd(n) =
For n ≠ 3 and c = 3π/4, r = (M – 1)/2 = 3
hd(n) =
For n = 3 hdb (n) = 0/0, Using L’Hospital Rule
Where π = 3.1416
hd(0) =
hd(1) = - 0.159
hd(2) =
hd(3) =
hd(4) =
hd(5) =
hd(6) =
The given window is hamming window
w(n) = 0.54 – 0.46 cos (2πn/(M – 1))
w(0) = 0.54 – 0.46cos(0/6) = 0.08
w(1) = 0.54 – 0.46cos(2π/6) = 0.31
w(2) = 0.54 – 0.46cos(4π/6) = 0.77
w(3) = 0.54 – 0.46cos(6π/6) = 1
w(4) = 0.54 – 0.46cos(8π/6) = 0.77
w(5) = 0.54 – 0.46cos(10π/6) = 0.31
w(6) = 0.54 – 0.46cos(12π/6) = 0.08
To calculate the value of h(n)
h(n) = hd(n)w(n)
h(0) = hd(0)w(0) = 0.075 0.08 = 0.006
h(1) = hd(1)w(1) = -0.1159 0.31 = -0.049
h(2) = hd(2)w(2) = 0225 0.77 = 0.173
h(3) = hd(3)w(3) = 0.750 1 = 0.75
h(4) = hd(4)w(4) = 0225 0.77 = 0.173
h(5) = hd(5)w(5) = - 0.1159 0.31 = - 0.049
h(6) = hd(6)w(6) = 0.075 0.08 = 0.006
The frequency response is symmetric with M=odd=7
|H(ej)| = h
= h(3) + 2
= h(3) + 2h(0) cos 3 + 2h(1) cos 2 + 2h(2) cos
= 0.75 + 0.012 cos 3 - 0.98 cos 2 + 0.346 cos
|H(ej)|dH = 20 log |H(ej)|
| |H(ej)| | |H(ej)|dB |
0 0.1π 0.2π 0.3π 0.4π 0.5π 0.6π 0.7π 0.8π 0.9π 1.0π | 1.0100 1.0068 0.9959 1.9722 0.9265 0.8480 0.7321 0.5883 0.4435 0.3346 0.2940 | 0.0864 0.0592 -0.0354 -0.2445 -0.6631 -1.4321 -2.7089 – 4.6077 – 7.0620 – 9.5095 – 10.633 |
RESPONSE
Q3) Design the FIR filter using Hanning window
Sol:
(n) = 0.5 ( 1 – cos (2πn/( - 1)))
(0) = 0.5 ( 1 – cos (2πn/6))=0
(1) = 0.5 ( 1 – cos (2πn/6))=0.25
(2) = 0.5 ( 1 – cos (2πn/6))=0.75
(3) = 0.5 ( 1 – cos (2πn/6))=1
(4) = 0.5 ( 1 – cos (2πn/6))=0.75
(5) = 0.5 ( 1 – cos (2πn/6))=0.25
(6) = 0.5 ( 1 – cos (2πn/6))=0
To calculate the value of h(n) = hd(n)w(n)
h(0) = hd(0)w(0) = 0.01497 0 = 0
h(1) = hd(1)w(1) = 0.014472 0.25 = 0.03618
h(2) = hd(2)w(2) = 026785 0.75 = 0.20089
h(3) = hd(3)w(3) = 0.31831 1 = 0.31831
h(4) = hd(4)w(4) = 0.26875 0.75 = 0.20089
h(5) = hd(5)w(5)=0.014472 0.25 = 0.03618
h(6) = hd(6)w(6) = 0.01497 0 = 0
Q4) Design an FIR filter (lowpass) using rectangular window with passband gain of 0 dB, cut-off frequency of 200 Hz, sampling frequency of 1 kHz. Assume the length of the impulse response as 7.
Sol:
Fc = 200 Hz, Fs = 1000 Hz
fc = Fc/Fs = 200/1000 = 0.2 cycles/sample
c = 2π * fc = 2π 0.2 – 0.4 π rad
M = 7
τ = (M – 1)/2 = (7 – 1)/2 = 3
c = 0.4 π
hd(n) = 1/2π
= 1/2π
= 1/2π
When n ≠ 3
hd(n) = sin[0.4π(n – 3)]/π(n-3)
When n = 3
hd(n) = 0.4π/π = 0.4
Calculating h(n)
As it is rectangular window h(n) = w(n)=hd(n)=h(n)
For M=7
n | h(n) |
0 | -0.062341 |
1 | 0.093511 |
2 | 0.302609 |
3 | 0.4 |
4 | -0.062341 |
5 | 0.093511 |
6 | 0.302609 |
Q5) Using rectangular window design a lowpass filter with passband gain of unity, cut-off frequency of 1000 Hz, sampling frequency of 5 kHz. The length of the impulse response should be 7.
Sol:
Fc = 100 Hz, Fs = 5000 Hz
fc = Fc/Fs = 1000/5000 = 0.2 cycles / sample
c = 2πfc = 2π 0.2 – 0.4 π rad
M = 7
The filter specifications (ωc and M=7) are similar to the previous example. Hence same filter coefficients are obtained.
h (0) =-0.062341, h(1)=0.093511, h(2)=0.302609 h(3)=0.4, h(4)=0.302609, h(5)=0.093511, h(6)=-0.062341
Q6) Design a HPF using Hamming window. Given that cut-off frequency the filter coefficients hd (n) for the desired frequency response of a low pass filter given by ωc = 1rad/sec, and take M=7. Also plot the magnitude response.
Sol:
τ = M – ½ = 5
By taking inverse Fourier transform
hd(n) = 1/2π
Hd(ej) =
hd(n) = 1/2π
= 1/2π
= 1/2π
hd(n)
τ = 3 hd(n) =
The given window function is Hamming window. In this case
h(n) = hd (n) (n) for 0 ≤ n ≤ 6
w(n) = 0.54 – 0.46 cos (2πn/(M – 1))
h(n) = 1/(π – 3) [ sin π(n – 3) – sin ( n – 3)] [ 0.54 – 0.46 cos ]
n | h(n) |
0 | -0.00119 |
1 | -0.00448 |
2 | -0.2062 |
3 | 0.6816 |
4 | -0.00119 |
5 | -0.00448 |
6 | -0.2062 |
The magnitude response of a symmetric FIR filter with M = odd is
|H(ej)| = h
For M=7
|H(ej)| = h(3) + 2
= h(3) + 2h(0) cos 3 + 2 h (1) cos 2 + 2h (2) cos
= 0.75 + 0.012 cos 3 - 0.98 cos 2 + 0.346 cos
Q7) Design an ideal bandpass filter having frequency response Hde(jω) for π/ 4 ≤ |ω| ≤ 3π/ 4. Use rectangular window with N=11 in your design.
Sol:
The length of the filter with given is related by
τ = (M – 1)/2 = (11 – 1)/2 = 5
And c = π/4 rad/sample c = 3π/4 rad/sample
The given window is rectangular hence
h(n) = (n) (n) = hd(n)
For n=0,1,2,…,10 estimate the FIR filter coefficients h(n).
The frequency sampling method is use to design recursive and non-recursive FIR filters for both standard frequency selective filters and with arbitrary frequency response. The main idea of the frequency sampling design method is that a desired frequency response can be approximated by sampling it at N evenly spaced points and then obtaining N-point filter response.
A continuous frequency response is then calculated as an interpolation of the sampled frequency response. The approximation error would then be exactly zero at the sampling frequencies and would be finite in frequencies between them. The smoother the frequency response being approximated, the smaller will be the error of interpolation between the sample points.
There are two distinct types of Non-Recursive Frequency Sampling method of FIR filter design, depending on where the initial frequency sample occurred. The type 1 designs have the initial point at ω=0, whereas the type 2 designs have the initial point at f=1/2N or ω=π/N.
Procedure for Type I design
Choose the desired frequency response
Hd()
Samples
Hd()
At N points by taking
= k = 2πk/N,
Where
k = 0, 1, 2, 3, . . . , N - 1
Generate the sequence H(k). To obtain a good approximation of the desired frequency response, a sufficiently large number of the frequency samples should be taken
H(k) = Hd() | = 2πk/N for k = 0,1, . . . ,
The N points inverse DFT of the sequence H (k) gives the impulse response of the filter h (n). For a practical realization of the filter, samples of impulse response should be real. This can happen if all the complex terms appears in conjugate pairs.
Desired filter coefficients
h(n) = ln vDFT{H(k)} = 1/N
For linear phase filter with positive symmetrical impulse response,
h(n) = 1/N
4) take z transform of the impulse response h (n) to get the filter transfer function H (z)
H(z) =
Procedure for Type 2 Design
(Same steps as above expect step 2)
2) Samples Hd() at N points by taking = k = 2π/2N (2k + 1) where
k = 0, 1, 2, 3, . . . , (N – 1) generate the sequence H (z)
H(k) = Hd()| = π k(2k + 1)/N for k = 0, 1, . . . , N - 1
Type 2 frequency samples gives additional flexibility in the design method to satisfy the desired frequency response at a second possible set of frequencies.
Consider a signal that consists of several frequency components passing through a filter.
The phase delay (Tp) of the filter is the amount of time delay each frequency component of the signal suffers in going through the filter.
The group delay (Tg) is the average time delay the composite signal suffers at each frequency.
Tp = - θ()/
Tg = - dθ()/d
Where Θ(w) is the phase angle
A filter is said to have a linear phase response if,
θ() = - α
θ() = β - α
Where α and β are constants
For Example
For ideal LPF
H(ej) =
Magnitude response= |H(ej)| = k
Phase response θ() = < H(ej) = - wα
Follows: y[n] = kx[nn – α] Linear phase implies that the output is a replica of x[n] {LPF} with a time shift of .
Symmetric impulse response will yield near phase FIR filters.
Positive symmetry of impulse response
h(n) = h(N – n – 1), n=0,1,…,(N-1)/2 (N odd)
N=0,1,…(N/2)-1 (N even)
Negative symmetry of impulse response:
h(n) = - h(N – n – 1), n=0,1,…,(N-1)/2 (N odd)
n=0,1,…(N/2)-1 (N even)
α = (N – 1)/2
β = π/2
Types of FIR linear phase systems
1. Type I FIR linear phase system
The impulse response is positive symmetric and N an odd integer.
h[n] = h[N – 1 – n] 0 ≤ n ≤ (N – 1)/2
The frequency response is
Where a[0] = h[(N – 1)/2]
a[n] = 2h[((N – 1)/2) – n] n=1,2,…,(N-1)/2
2. Type II FIR linear phase system
The impulse response is positive symmetric and N is an even integer
h[n] = h[N – 1 – n], 0 ≤ n ≤ (N/2) - 1
The frequency response is
Where
b[n] = 2h[N/2 – n] n = 1,2, ... N/2
3. Type III FIR linear phase system
The impulse response is negative-symmetric and N an odd integer
h[n] = - h[N – 1 – n] 0 ≤ n ≤ (N – 1)/2
Where
a[n] = 2h[((N – 1)/2) – n] n = 1,2, ... ( N – 1)/2
Key takeaway
There are two distinct types of Non-Recursive Frequency Sampling method of FIR filter design, depending on where the initial frequency sample occurred. The type 1 designs have the initial point at ω=0, whereas the type 2 designs have the initial point at f=1/2N or ω=π/N.
It is a full band differentiator filter on the input signal to differentiate all its frequency components. This object uses an FIR equi ripple filter design to design the differentiator filter. The ideal frequency response of the differentiator is D(ω)=jω for −π≤ω≤π.
The direct form is obtained from
Based on the above equation, we need the current input sample and M−1 previous samples of the input to produce an output point. For M=5, we can simply obtain the following diagram from Equation 1.
On the other hand, for a linear-phase FIR filter, we observe the following symmetry in coefficients of the difference equation
The structure obtained from the above equation is shown in Figure 2. While Figure 1 requires five multipliers, employing the symmetry of a linear-phase FIR filter, we can implement the filter using only three multipliers. This example shows that for an odd M, the symmetry property reduces the number of multipliers of an (M−1)th-order FIR filter from M to M+1/2.
Cascade form
The cascade structure is obtained from the system function H(z). The idea is to decompose the target system function into a cascade of second-order FIR systems. In other words, we need to find second-order systems which satisfy
Where P is the integer part of M/2. For example, M=5, H(z) will be a polynomial of degree four which can be decomposed into two second-order sections. Each of these second-order filters can be realized using a direct form structure. It is desirable to set a pair of complex-conjugate roots for each of the second-order sections so that the coefficients become real.
Assume that we need to implement the nine-tap FIR filter given by the following table using a cascade structure.
k | 4 | 3 and 5 | 2 and 6 | 1 and 7 | 0 and 8 |
bk | 0.3333 | 0.2813 | 0.1497 | 0 | -0.0977 |
Solution:
The system function of this filter is
H(z) = - 0.0977 + 0.1497 z-2 + 0.2813 z-3 + 0.3333 z-4+ 0.2813 z-5 + 0.1497 z-6 – 0.0977 z-8
It can be show H(z) = GH1(z) H2(z)H3(z)H4(z)
Where
G = - 0.0977
H1(z) = (1 - 2.5321 z-1 + z-2)
H2(z) = (1 – 0.3474z-1 + z-2)
H3(z) = (1 + 1.8794z-1 + z-2)
H4(z) = (1 + z-1 + z-2)
Linear phase structure
The symmetry (or anti symmetry) property of a linear-phase FIR filter can be exploited to reduce the number of multipliers into almost half of that in the direct form implementations • Consider a length-7 Type 1 FIR transfer function with a symmetric impulse response:
- H(z) = h[0] + h[1](z-1) + h[2](z-2) + h[3](z-3) + h[2]z-4 + h[1]z-5 + h[0]z-6
- H(z) = h[0](1 + z-6) + h[1](z-1 + z-5) + h[2](z-2+z-4) + h[3](z-3)
We obtain the realization shown below
- A similar decomposition can be applied to a Type 2 FIR transfer function
- For example, a length-8 Type 2 FIR transfer function can be expressed as
- H(z) = h[0](1 + z-7) + h[1](z-1 + z-6) + h[2](z-2 + z-5) + h[3](z-3 + z-4)
The Type 1 linear-phase structure for a length-7 FIR filter requires 4 multipliers, whereas a direct form realization requires 7 multipliers
Examples
Q) Draw using the cascade form for the LTI system whose transfer function is
H(z) =
A) Hence H(z) can be factorized as
B) H(z) = (1 – [0.309 + j0.9511]z-1)(1 – [0.309 – j0.9511]z-1) ( 1 – [ - 0.809 + j0.5878]z-1)(1 – [ - 0.809 – j 0.5878]z-1)
Although it can be realized with first-order sections, complex coefficients are needed, which implies higher computational cost. To guarantee real-valued coefficients, we group the sections of complex conjugates together.
H(z) = ( 1 – 0.618 z-1 + z-2)( 1 + 1.618 z-1 + z-2)
= (1 + 1.618z-1 + z-2)(1 – 0.618z-1 + z-2)
References:
1. Digital signal processing- A practical approach Second Edition, 2002.E. C. Ifeachar, B. W. Jarvis Pearson Education
2. Sanjit K. Mitra, ‘Digital Signal Processing – A Computer based approach’
3. S. Salivahanan, A Vallavaraj, C. Gnanapriya, ‘Digital Signal Processing’, 2nd Edition McGraw Hill.
4. A. NagoorKani, ‘Digital Signal Processing’, 2nd Edition McGraw Hill.
5.P. Ramesh Babu, ‘Digital Signal Processing’ Scitech
Unit - 5
FIR Filter Design & Realization
Linear phase is a property of a filter, where the phase response of the filter is a linear function of frequency. The result is that all frequency components of the input signal are shifted in time (usually delayed) by the same constant amount, which is referred to as the phase delay. And consequently, there is no phase distortion due to the time delay of frequencies relative to one another. Linear-phase filters have a symmetric impulse response. The FIR filter has linear phase if its unit sample response satisfies the following condition: h(n) = h(M − 1 − n) n = 0, 1, 2, . . . , N − 1 The Z transform of the unit sample response is given as
H[z] =
Symmetric impulse response with M=odd Then h(n) = h(M − 1 − n) and (z = ejω)
H() = |H()|ei∠H()
For M=even
H() = |H()|ei∠H()
Linear phase is a property of a filter, where the phase response of the filter is a linear function of frequency. The result is that all frequency components of the input signal are shifted in time (usually delayed) by the same constant amount, which is referred to as the phase delay. And consequently, there is no phase distortion due to the time delay of frequencies relative to one another. Linear-phase filters have a symmetric impulse response. The FIR filter has linear phase if its unit sample response satisfies the following condition: h(n) = h(M − 1 − n) n = 0, 1, 2, . . . , N − 1 The Z transform of the unit sample response is given as
H[z] =
Symmetric impulse response with M=odd Then h(n) = h(M − 1 − n) and (z = ejω)
H() = |H()|ei∠H()
For M=even
H() = |H()|ei∠H()
Windowing method
Let the frequency response of the desired LTI system we wish to approximate be given by
Hd(ej) =
Where hd(n) is the corresponding impulse response.
Consider obtaining a casual FIR filter that approximates hd(n) by letting
h[n] =
The FIR filter then has frequency response
H(ej) =
Note that since we can write
hd(n) = 1/2π
We are actually forming a finite Fourier series approximation to Hd(ej)
Since the ideal Hd(ej) may contain discontinuities at the band edges, truncation of the Fourier series will result in the Gibbs phenomenon.
To allow for a less abrupt Fourier series truncation and hence reduce Gibbs phenomenon oscillations, we may generalize h [n] by writing
h[n] = hd [n] [n]
Where [n] is a finite duration window function of length M +1.
Rectangular Window
This is the simplest window function but provides the worst performance from the viewpoint of stopband attenuation. The width of main lobe is 4π/N
ωR(n) = 1 for n=0,1,M-1
= 0 otherwise
Magnitude response of rectangular window is
|WR(ω)| =
Fig: Rectangular Window
Bartlett (Triangular) Window
Bartlett Window is also Triangular window. The width of main lobe is 8π/M
ωt(n) = 1-
Fig: Bartlett Window
Hanning Window
This is a raised cosine window function given by:
W(n) = ½ [ 1 – cos (2πn/(M-1))] ]
W(ω) = 0.5WR(ω) +0.25[WR (ω - 2π/M) + WR (ω - 2π/M)]
Fig: Hanning Window
Hamming Window
This is a modified version of the raised cosine window
W(n) = [ 0.54 - 0.46 cos (2πn/(M – 1))]]
W(ω) = 0.54WR(ω) +0.23[WR (ω - 2π/M) + WR (ω - 2π/M)]
Fig: Hamming Window
Blackman Window
This is a 2nd -order raised cosine window
W(n) = [ 0.42 – 0.5 cos (2πn/(M – 1)) + 0.08 cos (4 πn/(M-1))]]
W(ω) = 0.42WR(ω) +0.25[WR (ω - 2π/M) + WR (ω -2π/M)]+ 0.04[WR (ω -4π/M) + WR (ω - 4π/M)]
Fig: Blackman Window
Key takeaway
Window name
| Window function |
Rectangular | R(n) = |
Triangular
| r(n) = 1 – |
Hamming | w(n) = | 0.54 – 0.46 cos (2πn/(N – 1))| |
Hanning | w(n) = | 0.5 – 0.5 cos (2πn/(N – 1))| |
Blackman | w(n) = | 0.42 – 0.5 cos (2πn/(N – 1)) + 0.08 cos (4πn/(N – 1)) + | |
Window name | Transition width of main lobe | Min. Stopband attenuation | Peak value of side lobe |
Rectangular | -21dB | -21dB | |
Hanning | -44dB | -31dB | |
Hamming | -53dB | -41Db | |
Barlett | -25dB | -25Db | |
Blackman | -74dB | -57Db |
Example
Q1) Design a LPF using rectangular window for the desired frequency response of a low pass filter given by ωc = π/2 rad/sec, and take M=11. Find the values of h(n). Also plot the magnitude response.
Sol:
r= M-1/2 = 5
By taking inverse Fourier transform
hd (n) = 1/2π
= 1/2π
= 1/2π
hd (n) = 1/2π
hd(n) =
For n ≠ 5 and c = π/2 , r = (M – 1)/2 = 5
hd(n) =
For n = 5 hdb (n) = 0/0, Using L’Hospital Rule
Where π = 3.1416
hd(0) =
hd(1) =
hd(2) =
hd(3) =
hd(4) =
hd(5) =
hd(6) =
hd(7) =
hd(8) =
hd(9) =
hd(10) =
The given window is rectangular window ω(n) = 1 for 0 ≤ n ≤ 10
=0 Otherwise
This is rectangular window of length M=11. h(n) = hd (n)ω(n) = hd (n) for 0 ≤ n ≤ 10
H[z]=
The impulse response is symmetric with M=odd=11
H(z) = h ((M – 1)/2)
= h(5) z-5 + h(0) [z-1 + z-9] + h(n) [z-n + zM – 1- n]
= h(5) z-5 + h(0) [z-0 + z-10] + h(1)[z-1+z-9] + h(2)[z-2 + z-8] + h(3)[z-3 + z-7] + h(4)[z-4 + z-6]
|H(ej) = 0.5 + 2h(0) cos 5 + 2h(1) cos 4 + 2h(2) cos 3 + 2h(3) cos 2 + 2h(4) cos
= 0.5 + 0.127 cos 5 - 0.212 cos 3 + 0.636 cos
|H(ej)| = 0.5 + 0.127 cos 5 - 0.212 cos 3 + 0.636 cos
|H(ej)| = 20 log |H(ej)|
| |H(ej)| | |H(ej)|dB |
0 0.1π 0.2π 0.3π 0.4π 0.5π 0.6π 0.7π 0.8π 0.9π 1.0π | 1.0151 0.9808 0.9535 1.0758 0.9952 0.5 0.0048 0.0758 0.467 0.0192 0.0512 | -0.44 -0.17 -0.41 +0.63 -0.04 -6.02 -46.37 -22.41 -26.65 -34.35 -25.74 |
Response
Q2) The desired frequency response of low pass filter is given by Hd (ejω) = e−j3ω − 3π/ 4 ≤ ω ≤ 3π/ 4 and 0 for 3π /4 ≤ |ω| ≤ π Determine the frequency response of the FIR if Hamming window is used with N=7
Sol
t = M-1/2 = 3
hd (n) = 1/2π
= 1/2π
= 1/2π
hd (n) = 1/2π
hd(n) =
For n ≠ 3 and c = 3π/4, r = (M – 1)/2 = 3
hd(n) =
For n = 3 hdb (n) = 0/0, Using L’Hospital Rule
Where π = 3.1416
hd(0) =
hd(1) = - 0.159
hd(2) =
hd(3) =
hd(4) =
hd(5) =
hd(6) =
The given window is hamming window
w(n) = 0.54 – 0.46 cos (2πn/(M – 1))
w(0) = 0.54 – 0.46cos(0/6) = 0.08
w(1) = 0.54 – 0.46cos(2π/6) = 0.31
w(2) = 0.54 – 0.46cos(4π/6) = 0.77
w(3) = 0.54 – 0.46cos(6π/6) = 1
w(4) = 0.54 – 0.46cos(8π/6) = 0.77
w(5) = 0.54 – 0.46cos(10π/6) = 0.31
w(6) = 0.54 – 0.46cos(12π/6) = 0.08
To calculate the value of h(n)
h(n) = hd(n)w(n)
h(0) = hd(0)w(0) = 0.075 0.08 = 0.006
h(1) = hd(1)w(1) = -0.1159 0.31 = -0.049
h(2) = hd(2)w(2) = 0225 0.77 = 0.173
h(3) = hd(3)w(3) = 0.750 1 = 0.75
h(4) = hd(4)w(4) = 0225 0.77 = 0.173
h(5) = hd(5)w(5) = - 0.1159 0.31 = - 0.049
h(6) = hd(6)w(6) = 0.075 0.08 = 0.006
The frequency response is symmetric with M=odd=7
|H(ej)| = h
= h(3) + 2
= h(3) + 2h(0) cos 3 + 2h(1) cos 2 + 2h(2) cos
= 0.75 + 0.012 cos 3 - 0.98 cos 2 + 0.346 cos
|H(ej)|dH = 20 log |H(ej)|
| |H(ej)| | |H(ej)|dB |
0 0.1π 0.2π 0.3π 0.4π 0.5π 0.6π 0.7π 0.8π 0.9π 1.0π | 1.0100 1.0068 0.9959 1.9722 0.9265 0.8480 0.7321 0.5883 0.4435 0.3346 0.2940 | 0.0864 0.0592 -0.0354 -0.2445 -0.6631 -1.4321 -2.7089 – 4.6077 – 7.0620 – 9.5095 – 10.633 |
RESPONSE
Q3) Design the FIR filter using Hanning window
Sol:
(n) = 0.5 ( 1 – cos (2πn/( - 1)))
(0) = 0.5 ( 1 – cos (2πn/6))=0
(1) = 0.5 ( 1 – cos (2πn/6))=0.25
(2) = 0.5 ( 1 – cos (2πn/6))=0.75
(3) = 0.5 ( 1 – cos (2πn/6))=1
(4) = 0.5 ( 1 – cos (2πn/6))=0.75
(5) = 0.5 ( 1 – cos (2πn/6))=0.25
(6) = 0.5 ( 1 – cos (2πn/6))=0
To calculate the value of h(n) = hd(n)w(n)
h(0) = hd(0)w(0) = 0.01497 0 = 0
h(1) = hd(1)w(1) = 0.014472 0.25 = 0.03618
h(2) = hd(2)w(2) = 026785 0.75 = 0.20089
h(3) = hd(3)w(3) = 0.31831 1 = 0.31831
h(4) = hd(4)w(4) = 0.26875 0.75 = 0.20089
h(5) = hd(5)w(5)=0.014472 0.25 = 0.03618
h(6) = hd(6)w(6) = 0.01497 0 = 0
Q4) Design an FIR filter (lowpass) using rectangular window with passband gain of 0 dB, cut-off frequency of 200 Hz, sampling frequency of 1 kHz. Assume the length of the impulse response as 7.
Sol:
Fc = 200 Hz, Fs = 1000 Hz
fc = Fc/Fs = 200/1000 = 0.2 cycles/sample
c = 2π * fc = 2π 0.2 – 0.4 π rad
M = 7
τ = (M – 1)/2 = (7 – 1)/2 = 3
c = 0.4 π
hd(n) = 1/2π
= 1/2π
= 1/2π
When n ≠ 3
hd(n) = sin[0.4π(n – 3)]/π(n-3)
When n = 3
hd(n) = 0.4π/π = 0.4
Calculating h(n)
As it is rectangular window h(n) = w(n)=hd(n)=h(n)
For M=7
n | h(n) |
0 | -0.062341 |
1 | 0.093511 |
2 | 0.302609 |
3 | 0.4 |
4 | -0.062341 |
5 | 0.093511 |
6 | 0.302609 |
Q5) Using rectangular window design a lowpass filter with passband gain of unity, cut-off frequency of 1000 Hz, sampling frequency of 5 kHz. The length of the impulse response should be 7.
Sol:
Fc = 100 Hz, Fs = 5000 Hz
fc = Fc/Fs = 1000/5000 = 0.2 cycles / sample
c = 2πfc = 2π 0.2 – 0.4 π rad
M = 7
The filter specifications (ωc and M=7) are similar to the previous example. Hence same filter coefficients are obtained.
h (0) =-0.062341, h(1)=0.093511, h(2)=0.302609 h(3)=0.4, h(4)=0.302609, h(5)=0.093511, h(6)=-0.062341
Q6) Design a HPF using Hamming window. Given that cut-off frequency the filter coefficients hd (n) for the desired frequency response of a low pass filter given by ωc = 1rad/sec, and take M=7. Also plot the magnitude response.
Sol:
τ = M – ½ = 5
By taking inverse Fourier transform
hd(n) = 1/2π
Hd(ej) =
hd(n) = 1/2π
= 1/2π
= 1/2π
hd(n)
τ = 3 hd(n) =
The given window function is Hamming window. In this case
h(n) = hd (n) (n) for 0 ≤ n ≤ 6
w(n) = 0.54 – 0.46 cos (2πn/(M – 1))
h(n) = 1/(π – 3) [ sin π(n – 3) – sin ( n – 3)] [ 0.54 – 0.46 cos ]
n | h(n) |
0 | -0.00119 |
1 | -0.00448 |
2 | -0.2062 |
3 | 0.6816 |
4 | -0.00119 |
5 | -0.00448 |
6 | -0.2062 |
The magnitude response of a symmetric FIR filter with M = odd is
|H(ej)| = h
For M=7
|H(ej)| = h(3) + 2
= h(3) + 2h(0) cos 3 + 2 h (1) cos 2 + 2h (2) cos
= 0.75 + 0.012 cos 3 - 0.98 cos 2 + 0.346 cos
Q7) Design an ideal bandpass filter having frequency response Hde(jω) for π/ 4 ≤ |ω| ≤ 3π/ 4. Use rectangular window with N=11 in your design.
Sol:
The length of the filter with given is related by
τ = (M – 1)/2 = (11 – 1)/2 = 5
And c = π/4 rad/sample c = 3π/4 rad/sample
The given window is rectangular hence
h(n) = (n) (n) = hd(n)
For n=0,1,2,…,10 estimate the FIR filter coefficients h(n).
The frequency sampling method is use to design recursive and non-recursive FIR filters for both standard frequency selective filters and with arbitrary frequency response. The main idea of the frequency sampling design method is that a desired frequency response can be approximated by sampling it at N evenly spaced points and then obtaining N-point filter response.
A continuous frequency response is then calculated as an interpolation of the sampled frequency response. The approximation error would then be exactly zero at the sampling frequencies and would be finite in frequencies between them. The smoother the frequency response being approximated, the smaller will be the error of interpolation between the sample points.
There are two distinct types of Non-Recursive Frequency Sampling method of FIR filter design, depending on where the initial frequency sample occurred. The type 1 designs have the initial point at ω=0, whereas the type 2 designs have the initial point at f=1/2N or ω=π/N.
Procedure for Type I design
Choose the desired frequency response
Hd()
Samples
Hd()
At N points by taking
= k = 2πk/N,
Where
k = 0, 1, 2, 3, . . . , N - 1
Generate the sequence H(k). To obtain a good approximation of the desired frequency response, a sufficiently large number of the frequency samples should be taken
H(k) = Hd() | = 2πk/N for k = 0,1, . . . ,
The N points inverse DFT of the sequence H (k) gives the impulse response of the filter h (n). For a practical realization of the filter, samples of impulse response should be real. This can happen if all the complex terms appears in conjugate pairs.
Desired filter coefficients
h(n) = ln vDFT{H(k)} = 1/N
For linear phase filter with positive symmetrical impulse response,
h(n) = 1/N
4) take z transform of the impulse response h (n) to get the filter transfer function H (z)
H(z) =
Procedure for Type 2 Design
(Same steps as above expect step 2)
2) Samples Hd() at N points by taking = k = 2π/2N (2k + 1) where
k = 0, 1, 2, 3, . . . , (N – 1) generate the sequence H (z)
H(k) = Hd()| = π k(2k + 1)/N for k = 0, 1, . . . , N - 1
Type 2 frequency samples gives additional flexibility in the design method to satisfy the desired frequency response at a second possible set of frequencies.
Consider a signal that consists of several frequency components passing through a filter.
The phase delay (Tp) of the filter is the amount of time delay each frequency component of the signal suffers in going through the filter.
The group delay (Tg) is the average time delay the composite signal suffers at each frequency.
Tp = - θ()/
Tg = - dθ()/d
Where Θ(w) is the phase angle
A filter is said to have a linear phase response if,
θ() = - α
θ() = β - α
Where α and β are constants
For Example
For ideal LPF
H(ej) =
Magnitude response= |H(ej)| = k
Phase response θ() = < H(ej) = - wα
Follows: y[n] = kx[nn – α] Linear phase implies that the output is a replica of x[n] {LPF} with a time shift of .
Symmetric impulse response will yield near phase FIR filters.
Positive symmetry of impulse response
h(n) = h(N – n – 1), n=0,1,…,(N-1)/2 (N odd)
N=0,1,…(N/2)-1 (N even)
Negative symmetry of impulse response:
h(n) = - h(N – n – 1), n=0,1,…,(N-1)/2 (N odd)
n=0,1,…(N/2)-1 (N even)
α = (N – 1)/2
β = π/2
Types of FIR linear phase systems
1. Type I FIR linear phase system
The impulse response is positive symmetric and N an odd integer.
h[n] = h[N – 1 – n] 0 ≤ n ≤ (N – 1)/2
The frequency response is
Where a[0] = h[(N – 1)/2]
a[n] = 2h[((N – 1)/2) – n] n=1,2,…,(N-1)/2
2. Type II FIR linear phase system
The impulse response is positive symmetric and N is an even integer
h[n] = h[N – 1 – n], 0 ≤ n ≤ (N/2) - 1
The frequency response is
Where
b[n] = 2h[N/2 – n] n = 1,2, ... N/2
3. Type III FIR linear phase system
The impulse response is negative-symmetric and N an odd integer
h[n] = - h[N – 1 – n] 0 ≤ n ≤ (N – 1)/2
Where
a[n] = 2h[((N – 1)/2) – n] n = 1,2, ... ( N – 1)/2
Key takeaway
There are two distinct types of Non-Recursive Frequency Sampling method of FIR filter design, depending on where the initial frequency sample occurred. The type 1 designs have the initial point at ω=0, whereas the type 2 designs have the initial point at f=1/2N or ω=π/N.
It is a full band differentiator filter on the input signal to differentiate all its frequency components. This object uses an FIR equi ripple filter design to design the differentiator filter. The ideal frequency response of the differentiator is D(ω)=jω for −π≤ω≤π.
The direct form is obtained from
Based on the above equation, we need the current input sample and M−1 previous samples of the input to produce an output point. For M=5, we can simply obtain the following diagram from Equation 1.
On the other hand, for a linear-phase FIR filter, we observe the following symmetry in coefficients of the difference equation
The structure obtained from the above equation is shown in Figure 2. While Figure 1 requires five multipliers, employing the symmetry of a linear-phase FIR filter, we can implement the filter using only three multipliers. This example shows that for an odd M, the symmetry property reduces the number of multipliers of an (M−1)th-order FIR filter from M to M+1/2.
Cascade form
The cascade structure is obtained from the system function H(z). The idea is to decompose the target system function into a cascade of second-order FIR systems. In other words, we need to find second-order systems which satisfy
Where P is the integer part of M/2. For example, M=5, H(z) will be a polynomial of degree four which can be decomposed into two second-order sections. Each of these second-order filters can be realized using a direct form structure. It is desirable to set a pair of complex-conjugate roots for each of the second-order sections so that the coefficients become real.
Assume that we need to implement the nine-tap FIR filter given by the following table using a cascade structure.
k | 4 | 3 and 5 | 2 and 6 | 1 and 7 | 0 and 8 |
bk | 0.3333 | 0.2813 | 0.1497 | 0 | -0.0977 |
Solution:
The system function of this filter is
H(z) = - 0.0977 + 0.1497 z-2 + 0.2813 z-3 + 0.3333 z-4+ 0.2813 z-5 + 0.1497 z-6 – 0.0977 z-8
It can be show H(z) = GH1(z) H2(z)H3(z)H4(z)
Where
G = - 0.0977
H1(z) = (1 - 2.5321 z-1 + z-2)
H2(z) = (1 – 0.3474z-1 + z-2)
H3(z) = (1 + 1.8794z-1 + z-2)
H4(z) = (1 + z-1 + z-2)
Linear phase structure
The symmetry (or anti symmetry) property of a linear-phase FIR filter can be exploited to reduce the number of multipliers into almost half of that in the direct form implementations • Consider a length-7 Type 1 FIR transfer function with a symmetric impulse response:
- H(z) = h[0] + h[1](z-1) + h[2](z-2) + h[3](z-3) + h[2]z-4 + h[1]z-5 + h[0]z-6
- H(z) = h[0](1 + z-6) + h[1](z-1 + z-5) + h[2](z-2+z-4) + h[3](z-3)
We obtain the realization shown below
- A similar decomposition can be applied to a Type 2 FIR transfer function
- For example, a length-8 Type 2 FIR transfer function can be expressed as
- H(z) = h[0](1 + z-7) + h[1](z-1 + z-6) + h[2](z-2 + z-5) + h[3](z-3 + z-4)
The Type 1 linear-phase structure for a length-7 FIR filter requires 4 multipliers, whereas a direct form realization requires 7 multipliers
Examples
Q) Draw using the cascade form for the LTI system whose transfer function is
H(z) =
A) Hence H(z) can be factorized as
B) H(z) = (1 – [0.309 + j0.9511]z-1)(1 – [0.309 – j0.9511]z-1) ( 1 – [ - 0.809 + j0.5878]z-1)(1 – [ - 0.809 – j 0.5878]z-1)
Although it can be realized with first-order sections, complex coefficients are needed, which implies higher computational cost. To guarantee real-valued coefficients, we group the sections of complex conjugates together.
H(z) = ( 1 – 0.618 z-1 + z-2)( 1 + 1.618 z-1 + z-2)
= (1 + 1.618z-1 + z-2)(1 – 0.618z-1 + z-2)
References:
1. Digital signal processing- A practical approach Second Edition, 2002.E. C. Ifeachar, B. W. Jarvis Pearson Education
2. Sanjit K. Mitra, ‘Digital Signal Processing – A Computer based approach’
3. S. Salivahanan, A Vallavaraj, C. Gnanapriya, ‘Digital Signal Processing’, 2nd Edition McGraw Hill.
4. A. NagoorKani, ‘Digital Signal Processing’, 2nd Edition McGraw Hill.
5.P. Ramesh Babu, ‘Digital Signal Processing’ Scitech
Unit - 5
FIR Filter Design & Realization
Linear phase is a property of a filter, where the phase response of the filter is a linear function of frequency. The result is that all frequency components of the input signal are shifted in time (usually delayed) by the same constant amount, which is referred to as the phase delay. And consequently, there is no phase distortion due to the time delay of frequencies relative to one another. Linear-phase filters have a symmetric impulse response. The FIR filter has linear phase if its unit sample response satisfies the following condition: h(n) = h(M − 1 − n) n = 0, 1, 2, . . . , N − 1 The Z transform of the unit sample response is given as
H[z] =
Symmetric impulse response with M=odd Then h(n) = h(M − 1 − n) and (z = ejω)
H() = |H()|ei∠H()
For M=even
H() = |H()|ei∠H()
Linear phase is a property of a filter, where the phase response of the filter is a linear function of frequency. The result is that all frequency components of the input signal are shifted in time (usually delayed) by the same constant amount, which is referred to as the phase delay. And consequently, there is no phase distortion due to the time delay of frequencies relative to one another. Linear-phase filters have a symmetric impulse response. The FIR filter has linear phase if its unit sample response satisfies the following condition: h(n) = h(M − 1 − n) n = 0, 1, 2, . . . , N − 1 The Z transform of the unit sample response is given as
H[z] =
Symmetric impulse response with M=odd Then h(n) = h(M − 1 − n) and (z = ejω)
H() = |H()|ei∠H()
For M=even
H() = |H()|ei∠H()
Windowing method
Let the frequency response of the desired LTI system we wish to approximate be given by
Hd(ej) =
Where hd(n) is the corresponding impulse response.
Consider obtaining a casual FIR filter that approximates hd(n) by letting
h[n] =
The FIR filter then has frequency response
H(ej) =
Note that since we can write
hd(n) = 1/2π
We are actually forming a finite Fourier series approximation to Hd(ej)
Since the ideal Hd(ej) may contain discontinuities at the band edges, truncation of the Fourier series will result in the Gibbs phenomenon.
To allow for a less abrupt Fourier series truncation and hence reduce Gibbs phenomenon oscillations, we may generalize h [n] by writing
h[n] = hd [n] [n]
Where [n] is a finite duration window function of length M +1.
Rectangular Window
This is the simplest window function but provides the worst performance from the viewpoint of stopband attenuation. The width of main lobe is 4π/N
ωR(n) = 1 for n=0,1,M-1
= 0 otherwise
Magnitude response of rectangular window is
|WR(ω)| =
Fig: Rectangular Window
Bartlett (Triangular) Window
Bartlett Window is also Triangular window. The width of main lobe is 8π/M
ωt(n) = 1-
Fig: Bartlett Window
Hanning Window
This is a raised cosine window function given by:
W(n) = ½ [ 1 – cos (2πn/(M-1))] ]
W(ω) = 0.5WR(ω) +0.25[WR (ω - 2π/M) + WR (ω - 2π/M)]
Fig: Hanning Window
Hamming Window
This is a modified version of the raised cosine window
W(n) = [ 0.54 - 0.46 cos (2πn/(M – 1))]]
W(ω) = 0.54WR(ω) +0.23[WR (ω - 2π/M) + WR (ω - 2π/M)]
Fig: Hamming Window
Blackman Window
This is a 2nd -order raised cosine window
W(n) = [ 0.42 – 0.5 cos (2πn/(M – 1)) + 0.08 cos (4 πn/(M-1))]]
W(ω) = 0.42WR(ω) +0.25[WR (ω - 2π/M) + WR (ω -2π/M)]+ 0.04[WR (ω -4π/M) + WR (ω - 4π/M)]
Fig: Blackman Window
Key takeaway
Window name
| Window function |
Rectangular | R(n) = |
Triangular
| r(n) = 1 – |
Hamming | w(n) = | 0.54 – 0.46 cos (2πn/(N – 1))| |
Hanning | w(n) = | 0.5 – 0.5 cos (2πn/(N – 1))| |
Blackman | w(n) = | 0.42 – 0.5 cos (2πn/(N – 1)) + 0.08 cos (4πn/(N – 1)) + | |
Window name | Transition width of main lobe | Min. Stopband attenuation | Peak value of side lobe |
Rectangular | -21dB | -21dB | |
Hanning | -44dB | -31dB | |
Hamming | -53dB | -41Db | |
Barlett | -25dB | -25Db | |
Blackman | -74dB | -57Db |
Example
Q1) Design a LPF using rectangular window for the desired frequency response of a low pass filter given by ωc = π/2 rad/sec, and take M=11. Find the values of h(n). Also plot the magnitude response.
Sol:
r= M-1/2 = 5
By taking inverse Fourier transform
hd (n) = 1/2π
= 1/2π
= 1/2π
hd (n) = 1/2π
hd(n) =
For n ≠ 5 and c = π/2 , r = (M – 1)/2 = 5
hd(n) =
For n = 5 hdb (n) = 0/0, Using L’Hospital Rule
Where π = 3.1416
hd(0) =
hd(1) =
hd(2) =
hd(3) =
hd(4) =
hd(5) =
hd(6) =
hd(7) =
hd(8) =
hd(9) =
hd(10) =
The given window is rectangular window ω(n) = 1 for 0 ≤ n ≤ 10
=0 Otherwise
This is rectangular window of length M=11. h(n) = hd (n)ω(n) = hd (n) for 0 ≤ n ≤ 10
H[z]=
The impulse response is symmetric with M=odd=11
H(z) = h ((M – 1)/2)
= h(5) z-5 + h(0) [z-1 + z-9] + h(n) [z-n + zM – 1- n]
= h(5) z-5 + h(0) [z-0 + z-10] + h(1)[z-1+z-9] + h(2)[z-2 + z-8] + h(3)[z-3 + z-7] + h(4)[z-4 + z-6]
|H(ej) = 0.5 + 2h(0) cos 5 + 2h(1) cos 4 + 2h(2) cos 3 + 2h(3) cos 2 + 2h(4) cos
= 0.5 + 0.127 cos 5 - 0.212 cos 3 + 0.636 cos
|H(ej)| = 0.5 + 0.127 cos 5 - 0.212 cos 3 + 0.636 cos
|H(ej)| = 20 log |H(ej)|
| |H(ej)| | |H(ej)|dB |
0 0.1π 0.2π 0.3π 0.4π 0.5π 0.6π 0.7π 0.8π 0.9π 1.0π | 1.0151 0.9808 0.9535 1.0758 0.9952 0.5 0.0048 0.0758 0.467 0.0192 0.0512 | -0.44 -0.17 -0.41 +0.63 -0.04 -6.02 -46.37 -22.41 -26.65 -34.35 -25.74 |
Response
Q2) The desired frequency response of low pass filter is given by Hd (ejω) = e−j3ω − 3π/ 4 ≤ ω ≤ 3π/ 4 and 0 for 3π /4 ≤ |ω| ≤ π Determine the frequency response of the FIR if Hamming window is used with N=7
Sol
t = M-1/2 = 3
hd (n) = 1/2π
= 1/2π
= 1/2π
hd (n) = 1/2π
hd(n) =
For n ≠ 3 and c = 3π/4, r = (M – 1)/2 = 3
hd(n) =
For n = 3 hdb (n) = 0/0, Using L’Hospital Rule
Where π = 3.1416
hd(0) =
hd(1) = - 0.159
hd(2) =
hd(3) =
hd(4) =
hd(5) =
hd(6) =
The given window is hamming window
w(n) = 0.54 – 0.46 cos (2πn/(M – 1))
w(0) = 0.54 – 0.46cos(0/6) = 0.08
w(1) = 0.54 – 0.46cos(2π/6) = 0.31
w(2) = 0.54 – 0.46cos(4π/6) = 0.77
w(3) = 0.54 – 0.46cos(6π/6) = 1
w(4) = 0.54 – 0.46cos(8π/6) = 0.77
w(5) = 0.54 – 0.46cos(10π/6) = 0.31
w(6) = 0.54 – 0.46cos(12π/6) = 0.08
To calculate the value of h(n)
h(n) = hd(n)w(n)
h(0) = hd(0)w(0) = 0.075 0.08 = 0.006
h(1) = hd(1)w(1) = -0.1159 0.31 = -0.049
h(2) = hd(2)w(2) = 0225 0.77 = 0.173
h(3) = hd(3)w(3) = 0.750 1 = 0.75
h(4) = hd(4)w(4) = 0225 0.77 = 0.173
h(5) = hd(5)w(5) = - 0.1159 0.31 = - 0.049
h(6) = hd(6)w(6) = 0.075 0.08 = 0.006
The frequency response is symmetric with M=odd=7
|H(ej)| = h
= h(3) + 2
= h(3) + 2h(0) cos 3 + 2h(1) cos 2 + 2h(2) cos
= 0.75 + 0.012 cos 3 - 0.98 cos 2 + 0.346 cos
|H(ej)|dH = 20 log |H(ej)|
| |H(ej)| | |H(ej)|dB |
0 0.1π 0.2π 0.3π 0.4π 0.5π 0.6π 0.7π 0.8π 0.9π 1.0π | 1.0100 1.0068 0.9959 1.9722 0.9265 0.8480 0.7321 0.5883 0.4435 0.3346 0.2940 | 0.0864 0.0592 -0.0354 -0.2445 -0.6631 -1.4321 -2.7089 – 4.6077 – 7.0620 – 9.5095 – 10.633 |
RESPONSE
Q3) Design the FIR filter using Hanning window
Sol:
(n) = 0.5 ( 1 – cos (2πn/( - 1)))
(0) = 0.5 ( 1 – cos (2πn/6))=0
(1) = 0.5 ( 1 – cos (2πn/6))=0.25
(2) = 0.5 ( 1 – cos (2πn/6))=0.75
(3) = 0.5 ( 1 – cos (2πn/6))=1
(4) = 0.5 ( 1 – cos (2πn/6))=0.75
(5) = 0.5 ( 1 – cos (2πn/6))=0.25
(6) = 0.5 ( 1 – cos (2πn/6))=0
To calculate the value of h(n) = hd(n)w(n)
h(0) = hd(0)w(0) = 0.01497 0 = 0
h(1) = hd(1)w(1) = 0.014472 0.25 = 0.03618
h(2) = hd(2)w(2) = 026785 0.75 = 0.20089
h(3) = hd(3)w(3) = 0.31831 1 = 0.31831
h(4) = hd(4)w(4) = 0.26875 0.75 = 0.20089
h(5) = hd(5)w(5)=0.014472 0.25 = 0.03618
h(6) = hd(6)w(6) = 0.01497 0 = 0
Q4) Design an FIR filter (lowpass) using rectangular window with passband gain of 0 dB, cut-off frequency of 200 Hz, sampling frequency of 1 kHz. Assume the length of the impulse response as 7.
Sol:
Fc = 200 Hz, Fs = 1000 Hz
fc = Fc/Fs = 200/1000 = 0.2 cycles/sample
c = 2π * fc = 2π 0.2 – 0.4 π rad
M = 7
τ = (M – 1)/2 = (7 – 1)/2 = 3
c = 0.4 π
hd(n) = 1/2π
= 1/2π
= 1/2π
When n ≠ 3
hd(n) = sin[0.4π(n – 3)]/π(n-3)
When n = 3
hd(n) = 0.4π/π = 0.4
Calculating h(n)
As it is rectangular window h(n) = w(n)=hd(n)=h(n)
For M=7
n | h(n) |
0 | -0.062341 |
1 | 0.093511 |
2 | 0.302609 |
3 | 0.4 |
4 | -0.062341 |
5 | 0.093511 |
6 | 0.302609 |
Q5) Using rectangular window design a lowpass filter with passband gain of unity, cut-off frequency of 1000 Hz, sampling frequency of 5 kHz. The length of the impulse response should be 7.
Sol:
Fc = 100 Hz, Fs = 5000 Hz
fc = Fc/Fs = 1000/5000 = 0.2 cycles / sample
c = 2πfc = 2π 0.2 – 0.4 π rad
M = 7
The filter specifications (ωc and M=7) are similar to the previous example. Hence same filter coefficients are obtained.
h (0) =-0.062341, h(1)=0.093511, h(2)=0.302609 h(3)=0.4, h(4)=0.302609, h(5)=0.093511, h(6)=-0.062341
Q6) Design a HPF using Hamming window. Given that cut-off frequency the filter coefficients hd (n) for the desired frequency response of a low pass filter given by ωc = 1rad/sec, and take M=7. Also plot the magnitude response.
Sol:
τ = M – ½ = 5
By taking inverse Fourier transform
hd(n) = 1/2π
Hd(ej) =
hd(n) = 1/2π
= 1/2π
= 1/2π
hd(n)
τ = 3 hd(n) =
The given window function is Hamming window. In this case
h(n) = hd (n) (n) for 0 ≤ n ≤ 6
w(n) = 0.54 – 0.46 cos (2πn/(M – 1))
h(n) = 1/(π – 3) [ sin π(n – 3) – sin ( n – 3)] [ 0.54 – 0.46 cos ]
n | h(n) |
0 | -0.00119 |
1 | -0.00448 |
2 | -0.2062 |
3 | 0.6816 |
4 | -0.00119 |
5 | -0.00448 |
6 | -0.2062 |
The magnitude response of a symmetric FIR filter with M = odd is
|H(ej)| = h
For M=7
|H(ej)| = h(3) + 2
= h(3) + 2h(0) cos 3 + 2 h (1) cos 2 + 2h (2) cos
= 0.75 + 0.012 cos 3 - 0.98 cos 2 + 0.346 cos
Q7) Design an ideal bandpass filter having frequency response Hde(jω) for π/ 4 ≤ |ω| ≤ 3π/ 4. Use rectangular window with N=11 in your design.
Sol:
The length of the filter with given is related by
τ = (M – 1)/2 = (11 – 1)/2 = 5
And c = π/4 rad/sample c = 3π/4 rad/sample
The given window is rectangular hence
h(n) = (n) (n) = hd(n)
For n=0,1,2,…,10 estimate the FIR filter coefficients h(n).
The frequency sampling method is use to design recursive and non-recursive FIR filters for both standard frequency selective filters and with arbitrary frequency response. The main idea of the frequency sampling design method is that a desired frequency response can be approximated by sampling it at N evenly spaced points and then obtaining N-point filter response.
A continuous frequency response is then calculated as an interpolation of the sampled frequency response. The approximation error would then be exactly zero at the sampling frequencies and would be finite in frequencies between them. The smoother the frequency response being approximated, the smaller will be the error of interpolation between the sample points.
There are two distinct types of Non-Recursive Frequency Sampling method of FIR filter design, depending on where the initial frequency sample occurred. The type 1 designs have the initial point at ω=0, whereas the type 2 designs have the initial point at f=1/2N or ω=π/N.
Procedure for Type I design
Choose the desired frequency response
Hd()
Samples
Hd()
At N points by taking
= k = 2πk/N,
Where
k = 0, 1, 2, 3, . . . , N - 1
Generate the sequence H(k). To obtain a good approximation of the desired frequency response, a sufficiently large number of the frequency samples should be taken
H(k) = Hd() | = 2πk/N for k = 0,1, . . . ,
The N points inverse DFT of the sequence H (k) gives the impulse response of the filter h (n). For a practical realization of the filter, samples of impulse response should be real. This can happen if all the complex terms appears in conjugate pairs.
Desired filter coefficients
h(n) = ln vDFT{H(k)} = 1/N
For linear phase filter with positive symmetrical impulse response,
h(n) = 1/N
4) take z transform of the impulse response h (n) to get the filter transfer function H (z)
H(z) =
Procedure for Type 2 Design
(Same steps as above expect step 2)
2) Samples Hd() at N points by taking = k = 2π/2N (2k + 1) where
k = 0, 1, 2, 3, . . . , (N – 1) generate the sequence H (z)
H(k) = Hd()| = π k(2k + 1)/N for k = 0, 1, . . . , N - 1
Type 2 frequency samples gives additional flexibility in the design method to satisfy the desired frequency response at a second possible set of frequencies.
Consider a signal that consists of several frequency components passing through a filter.
The phase delay (Tp) of the filter is the amount of time delay each frequency component of the signal suffers in going through the filter.
The group delay (Tg) is the average time delay the composite signal suffers at each frequency.
Tp = - θ()/
Tg = - dθ()/d
Where Θ(w) is the phase angle
A filter is said to have a linear phase response if,
θ() = - α
θ() = β - α
Where α and β are constants
For Example
For ideal LPF
H(ej) =
Magnitude response= |H(ej)| = k
Phase response θ() = < H(ej) = - wα
Follows: y[n] = kx[nn – α] Linear phase implies that the output is a replica of x[n] {LPF} with a time shift of .
Symmetric impulse response will yield near phase FIR filters.
Positive symmetry of impulse response
h(n) = h(N – n – 1), n=0,1,…,(N-1)/2 (N odd)
N=0,1,…(N/2)-1 (N even)
Negative symmetry of impulse response:
h(n) = - h(N – n – 1), n=0,1,…,(N-1)/2 (N odd)
n=0,1,…(N/2)-1 (N even)
α = (N – 1)/2
β = π/2
Types of FIR linear phase systems
1. Type I FIR linear phase system
The impulse response is positive symmetric and N an odd integer.
h[n] = h[N – 1 – n] 0 ≤ n ≤ (N – 1)/2
The frequency response is
Where a[0] = h[(N – 1)/2]
a[n] = 2h[((N – 1)/2) – n] n=1,2,…,(N-1)/2
2. Type II FIR linear phase system
The impulse response is positive symmetric and N is an even integer
h[n] = h[N – 1 – n], 0 ≤ n ≤ (N/2) - 1
The frequency response is
Where
b[n] = 2h[N/2 – n] n = 1,2, ... N/2
3. Type III FIR linear phase system
The impulse response is negative-symmetric and N an odd integer
h[n] = - h[N – 1 – n] 0 ≤ n ≤ (N – 1)/2
Where
a[n] = 2h[((N – 1)/2) – n] n = 1,2, ... ( N – 1)/2
Key takeaway
There are two distinct types of Non-Recursive Frequency Sampling method of FIR filter design, depending on where the initial frequency sample occurred. The type 1 designs have the initial point at ω=0, whereas the type 2 designs have the initial point at f=1/2N or ω=π/N.
It is a full band differentiator filter on the input signal to differentiate all its frequency components. This object uses an FIR equi ripple filter design to design the differentiator filter. The ideal frequency response of the differentiator is D(ω)=jω for −π≤ω≤π.
The direct form is obtained from
Based on the above equation, we need the current input sample and M−1 previous samples of the input to produce an output point. For M=5, we can simply obtain the following diagram from Equation 1.
On the other hand, for a linear-phase FIR filter, we observe the following symmetry in coefficients of the difference equation
The structure obtained from the above equation is shown in Figure 2. While Figure 1 requires five multipliers, employing the symmetry of a linear-phase FIR filter, we can implement the filter using only three multipliers. This example shows that for an odd M, the symmetry property reduces the number of multipliers of an (M−1)th-order FIR filter from M to M+1/2.
Cascade form
The cascade structure is obtained from the system function H(z). The idea is to decompose the target system function into a cascade of second-order FIR systems. In other words, we need to find second-order systems which satisfy
Where P is the integer part of M/2. For example, M=5, H(z) will be a polynomial of degree four which can be decomposed into two second-order sections. Each of these second-order filters can be realized using a direct form structure. It is desirable to set a pair of complex-conjugate roots for each of the second-order sections so that the coefficients become real.
Assume that we need to implement the nine-tap FIR filter given by the following table using a cascade structure.
k | 4 | 3 and 5 | 2 and 6 | 1 and 7 | 0 and 8 |
bk | 0.3333 | 0.2813 | 0.1497 | 0 | -0.0977 |
Solution:
The system function of this filter is
H(z) = - 0.0977 + 0.1497 z-2 + 0.2813 z-3 + 0.3333 z-4+ 0.2813 z-5 + 0.1497 z-6 – 0.0977 z-8
It can be show H(z) = GH1(z) H2(z)H3(z)H4(z)
Where
G = - 0.0977
H1(z) = (1 - 2.5321 z-1 + z-2)
H2(z) = (1 – 0.3474z-1 + z-2)
H3(z) = (1 + 1.8794z-1 + z-2)
H4(z) = (1 + z-1 + z-2)
Linear phase structure
The symmetry (or anti symmetry) property of a linear-phase FIR filter can be exploited to reduce the number of multipliers into almost half of that in the direct form implementations • Consider a length-7 Type 1 FIR transfer function with a symmetric impulse response:
- H(z) = h[0] + h[1](z-1) + h[2](z-2) + h[3](z-3) + h[2]z-4 + h[1]z-5 + h[0]z-6
- H(z) = h[0](1 + z-6) + h[1](z-1 + z-5) + h[2](z-2+z-4) + h[3](z-3)
We obtain the realization shown below
- A similar decomposition can be applied to a Type 2 FIR transfer function
- For example, a length-8 Type 2 FIR transfer function can be expressed as
- H(z) = h[0](1 + z-7) + h[1](z-1 + z-6) + h[2](z-2 + z-5) + h[3](z-3 + z-4)
The Type 1 linear-phase structure for a length-7 FIR filter requires 4 multipliers, whereas a direct form realization requires 7 multipliers
Examples
Q) Draw using the cascade form for the LTI system whose transfer function is
H(z) =
A) Hence H(z) can be factorized as
B) H(z) = (1 – [0.309 + j0.9511]z-1)(1 – [0.309 – j0.9511]z-1) ( 1 – [ - 0.809 + j0.5878]z-1)(1 – [ - 0.809 – j 0.5878]z-1)
Although it can be realized with first-order sections, complex coefficients are needed, which implies higher computational cost. To guarantee real-valued coefficients, we group the sections of complex conjugates together.
H(z) = ( 1 – 0.618 z-1 + z-2)( 1 + 1.618 z-1 + z-2)
= (1 + 1.618z-1 + z-2)(1 – 0.618z-1 + z-2)
References:
1. Digital signal processing- A practical approach Second Edition, 2002.E. C. Ifeachar, B. W. Jarvis Pearson Education
2. Sanjit K. Mitra, ‘Digital Signal Processing – A Computer based approach’
3. S. Salivahanan, A Vallavaraj, C. Gnanapriya, ‘Digital Signal Processing’, 2nd Edition McGraw Hill.
4. A. NagoorKani, ‘Digital Signal Processing’, 2nd Edition McGraw Hill.
5.P. Ramesh Babu, ‘Digital Signal Processing’ Scitech