DSP Notes
DSP Notes
Analog Digital
www.iammanuprasad.com
BASIC BLOCKS OF DIGITAL SIGNAL PROCESSING
Digital
Analog AD DA Analog
Pre filter Signal Post filter
input Converter Converter output
Processor
www.iammanuprasad.com
Discrete Fourier Transform (DFT)
• DFT is a powerful computation tool which allows us to evaluate the Fourier transform on a digital computer or
specifically designed hardware
• We notate like this
𝑋 𝑘 = 𝐷𝐹𝑇[𝑥 𝑛 ] 𝑥 𝑛 = 𝐼𝐷𝐹𝑇[𝑋 𝑘 ]
𝑗2𝜋
Let us define a term 𝑊𝑁 = 𝑒 − 𝑁 which is known as twiddle factor and substitute in above equations
𝑁−1 𝑁−1
1
𝑋 𝑘 = 𝑥 𝑛 𝑊𝑁𝑛𝑘 ,0 ≤ k ≤ N−1 𝑥(𝑛) = 𝑋 𝑘 𝑤𝑁−𝑛𝑘 , 0 ≤ n ≤ N − 1
𝑁
𝑛=0 𝑘=0
www.iammanuprasad.com
𝑁−1
Let us take an example 𝑗2𝜋𝑘𝑛
−
𝑋 𝑘 = 𝑥 𝑛 𝑒 𝑁 ,0 ≤ k ≤ N − 1
Q) Find the DFT of the sequence 𝑥 𝑛 = {1,1,0,0}
𝑛=0
𝑁=4 𝑘=2 3
𝑗𝜋2𝑛
3 −
𝑗2𝜋𝑘𝑛 𝑋 2 = 𝑥 𝑛 𝑒 2
−
𝑋 𝑘 = 𝑥 𝑛 𝑒 4 ,0 ≤ k ≤ N − 1 𝑛=0
𝑛=0 = 𝑥 0 + 𝑥 1 𝑒 −𝑗𝜋 + 𝑥 2 𝑒 −𝑗2𝜋 + 𝑥 3 𝑒 −𝑗3𝜋
=1+1+0+0 =2 3𝜋 3𝜋
= 1 + 1 cos − 𝑗 sin +0+0 =1+𝑗
2 2
𝑘=1 3
𝑗𝜋𝑛
𝑋 1 = 𝑥 𝑛 𝑒− 2
𝑛=0
𝑗𝜋 𝑗3𝜋
𝑋 𝑘 = 2, 1 − 𝑗, 0,1 + 𝑗
− −
=𝑥 0 +𝑥 1 𝑒 + 𝑥 2 𝑒 −𝑗𝜋 + 𝑥 3 𝑒
2 2
𝜋 𝜋
= 1 + 1 cos − 𝑗 sin + 0 + 0 = 1 − 𝑗 www.iammanuprasad.com
2 2
DFT as linear transformation (Matrix method)
DFT We can also represent the equation in matrix format
𝑁−1 1 1 1 1 … 1
𝑊𝑁𝑛𝑘 𝑋(0) 𝑁−1 𝑥(0)
𝑋 𝑘 = 𝑥 𝑛 𝑒 ,0 ≤ k ≤ N − 1 1 𝑊𝑁1 𝑊𝑁2 𝑊𝑁3 … 𝑊𝑁
𝑗2𝜋
𝑋(1) 𝑥(1)
𝑛=0 1 𝑊𝑁2 𝑊𝑁4 𝑊𝑁6 … 2(𝑁−1)
𝑊𝑁 = 𝑒 − 𝑁 𝑋(2)
= 1
𝑊𝑁 𝑥(2)
…
𝑋(3) 𝑊𝑁3 𝑊𝑁6 𝑊𝑁9 3(𝑁−1)
𝑊𝑁 𝑥(3)
⋮ …
⋮ ⋮ ⋮ ⋮ ⋮ ⋮
Lets put n = 0,1,2, … N-1 𝑋(𝑁 − 1) 2(𝑁−1) 3(𝑁−1) 𝑥(𝑁 − 1)
𝑁−1 𝑁−1 𝑁−1
1 𝑊𝑁 𝑊𝑁 𝑊𝑁 … 𝑊𝑁
(𝑁−1)𝑘
𝑋 𝑘 = 𝑥 0 . 1 + 𝑥 1 . 𝑊𝑁1𝑘 + 𝑥 2 . 𝑊𝑁2𝑘 + ⋯ + 𝑥 𝑁 − 1 𝑊𝑁 1 1 … 1
𝑋𝑁 = 𝑊𝑁 𝑥𝑁 1 𝑊𝑁−1 −(𝑁−1)
𝑘=0 𝑊𝑁−1 = ⋮ ⋱ 𝑊𝑁
⋮
𝑋 0 = 𝑥 0 + 𝑥 1 + 𝑥 2 + ⋯+ 𝑥 𝑁 − 1 𝑥𝑁 = 𝑊𝑁−1 𝑋𝑁 1 𝑊𝑁
− 𝑁−1
… 𝑊𝑁
−(𝑁−1)(𝑁−1)
𝑘=1
(𝑁−1)
𝑋 1 = 𝑥 0 + 𝑥 1 . 𝑊𝑁1 + 𝑥 2 . 𝑊𝑁2 + ⋯ + 𝑥 𝑁 − 1 𝑊𝑁 IDFT
𝑁−1
1
⋮ 𝑥(𝑛) = 𝑋 𝑘 𝑤𝑁−𝑛𝑘 , 0 ≤ n ≤ N − 1
𝑁
𝑘=0
𝑘 =𝑁−1
𝑁−1
1 ∗ Comparing we get
𝑋 𝑁 − 1 = 𝑥 0 + 𝑥 1 . 𝑊𝑁
(𝑁−1) 2(𝑁−1)
+ 𝑥 2 . 𝑊𝑁
(𝑁−1)(𝑁−1)
+ ⋯ + 𝑥 𝑁 − 1 𝑊𝑁 𝑥(𝑛) = 𝑋 𝑘 𝑤𝑁𝑛𝑘
𝑁
𝑘=0
1 ∗
𝑊𝑁−1 = 𝑊
Symbolically we can 1 𝑁 𝑁
𝑥(𝑛) = 𝑋 𝑊∗
write as
www.iammanuprasad.com 𝑁 𝑁 𝑁
Twiddle factor matrix
𝑗2𝜋 Lies on the unit circle in the complex plane from 0 to 2π angle and it gets
𝑊𝑁 = 𝑒− 𝑁 repeated for every cycle
𝑒 𝑗𝜃 = cos 𝜃 + 𝑗𝑠𝑖𝑛 𝜃
Imaginary
𝑊20 𝑊20 1 1 axis
𝑊2 = =
𝑊20 𝑊21 1 −1 𝑊 3, 𝑊 7 , 𝑊 11
𝑗 Phase change ( 00 - 3600) -
anticlockwise
www.iammanuprasad.com
Relationship of the DFT to Fourier Transform
Fourier-Transform DFT
𝑁−1 𝑁−1
𝑗2𝜋𝑘𝑛
𝑗𝜔 −𝑗𝜔𝑛 −
𝑋 𝑒 = 𝑥 𝑛 𝑒 𝑋 𝑘 = 𝑥 𝑛 𝑒 𝑁
𝑛=0 𝑛=0
www.iammanuprasad.com
Relationship of the DFT to Z-Transform
𝑗2𝜋𝑘 𝑁
Z-Transform IDFT 𝑁−1 −1
1 1− 𝑒 𝑁 𝑧
𝑋(𝑧) = 𝑋(𝑘) 𝑗2𝜋𝑘
𝑁
𝑁−1 𝑁−1 𝑘=0 1 − 𝑒 𝑁 𝑧 −1
−𝑛 1 𝑗2𝜋𝑘𝑛
𝑋 𝑍 = 𝑥 𝑛 𝑧 𝑥(𝑛) = 𝑋 𝑘 𝑒 𝑁
𝑁 𝑁−1
𝑛=0 𝑘=0 1 1 − 𝑒 𝑗2𝜋𝑘 𝑧 −𝑁
= 𝑋(𝑘) 𝑗2𝜋𝑘
𝑁
𝑘=0 1 − 𝑒 𝑁 𝑧 −1
Substitute the value of x(n)
𝑁−1 𝑁−1
1 𝑗2𝜋𝑘𝑛
= 𝑋(𝑘) 𝑒 𝑁 𝑧 −𝑛 𝑁−1
𝑁 1 − 𝑧 −𝑁 𝑋(𝑘)
𝑘=0 𝑛=0 𝑋 𝑧 = 𝑗2𝜋𝑘
𝑁−1 𝑁
N 𝑘=0 1−𝑒 𝑁 𝑧 −1
1−a
𝑎𝑛 =
𝑁−1 𝑁−1 𝑛 1−a
1 𝑗2𝜋𝑘 𝑘=0
= 𝑋(𝑘) 𝑒 𝑁 𝑧 −1 Relationship between DFT & Z- Transform
𝑁
𝑘=0 𝑛=0
www.iammanuprasad.com
Properties of Discrete Fourier Transform
Periodicity
Circular time shift
If X(k) is N-point DFT of a finite duration sequences x(n) then If X(k) is N-point DFT of a finite duration sequences x(n) then
𝑗2𝜋𝑘𝑚
𝑥 𝑛 + 𝑁 = 𝑥 𝑛 𝑓𝑜𝑟 𝑎𝑙𝑙 𝑛 𝐷𝐹𝑇 𝑥 𝑛 − 𝑚 𝑁
= 𝑋 𝑘 𝑒− 𝑁
X 𝑘 + 𝑁 = 𝑋 𝑘 𝑓𝑜𝑟 𝑎𝑙𝑙 𝑘
Proof
IDFT
𝑁−1
Linearity 1 𝑗2𝜋𝑘𝑛
𝑥(𝑛) = 𝑋 𝑘 𝑒 𝑁 , 0 ≤ n ≤ N − 1
𝑁
𝑘=0
If two finite sequences x1(n) and x2(n) are linearly combined as Put n=n-m
𝑁−1
𝑥3 𝑛 = 𝑎𝑥1 𝑛 + 𝑏𝑥2 (𝑛) 1 𝑗2𝜋𝑘(𝑛−𝑚)
𝑥(𝑛 − 𝑚) = 𝑋 𝑘 𝑒 𝑁
𝑁 Take DFT on both sides
𝑘=0
Then DFT of the sequence 𝑁−1
1 𝑗2𝜋𝑘𝑛 −𝑗2𝜋𝑘𝑚
= 𝑋 𝑘 𝑒 𝑁 𝑒 𝑁
𝑋3 𝑘 = 𝑎𝑋1 𝑘 + 𝑏𝑋2 (𝑘) 𝑁 −𝑗2𝜋𝑘𝑚
𝑘=0 𝐷𝐹𝑇{𝑥(𝑛 − 𝑚)} = 𝑋(𝑘)𝑒 𝑁
−𝑗2𝜋𝑘𝑚
𝐷𝐹𝑇 𝑥(𝑛 − 𝑚) = 𝑥(𝑛)𝑒 𝑁
𝑎𝑥1 𝑛 + 𝑏𝑥2 (𝑛) 𝑎𝑋1 𝑘 + 𝑏𝑋2 (𝑘)
www.iammanuprasad.com
Q) Consider a finite length sequences x(n) shown in figure. The five point DF of x(n) is denoted by
X(k). Plot the sequences whose DFT is
𝑗2𝜋𝑘𝑚
−4𝜋𝑘 𝑥(𝑛) 𝐷𝐹𝑇 𝑥 𝑛 − 𝑚 = 𝑋 𝑘 𝑒− 𝑁
𝑌 𝑘 = 𝑒 5 𝑋(𝑘) 2 2 𝑁
1 1
-1 0 1 2 3
Solution
𝑗2𝜋𝑘2
𝐷𝐹𝑇 𝑥 𝑛 − 2 5
= 𝑋 𝑘 𝑒− 5 ,𝑛 = 0,1, … , 4
𝑦 𝑛 = 1,0,1,2,2
-1 0 1 2 3 4
www.iammanuprasad.com
Properties of Discrete Fourier Transform
𝑗2𝜋𝑙𝑛
𝑥(𝑘 − 𝑙) = 𝑋 𝑘 𝑒 𝑁
www.iammanuprasad.com
Properties of Discrete Fourier Transform
∗
∗ ∗ ∗ 𝑁−1
𝐷𝐹𝑇 𝑥 𝑛 =𝑋 𝑁−𝑘 =𝑋 −𝑘 𝑁
𝑗2𝜋𝑘𝑛
−
𝑗2𝜋𝑛𝑁
= 𝑥 𝑛 𝑒 𝑁 𝑒 𝑁
𝑛=0
∗
𝑁−1
Proof 𝑗2𝜋𝑛 𝑁−𝑘
= 𝑥 𝑛 𝑒− 𝑁
𝑁−1 𝑛=0
𝑗2𝜋𝑘𝑛
𝐷𝐹𝑇 𝑥 𝑛 = 𝑥 𝑛 𝑒− 𝑁
𝑛=0
∗
𝐷𝐹𝑇 𝑥 𝑛 = 𝑋 𝑁−𝑘
𝑁−1
𝑗2𝜋𝑘𝑛
∗ ∗ −
𝐷𝐹𝑇 𝑥 𝑛 = 𝑥 𝑛 𝑒 𝑁
𝑛=0
www.iammanuprasad.com
Q) Let X(k) be a 14 point DFT of a length 14 real sequence x(n). The first 8 samples of X(k) are given by,
X(0) = 12,
X(1) = -1+3j ,
X(2) = 3+4j,
X(3) = 1-5j,
X(4) = -2+2j,
∗
𝐷𝐹𝑇 𝑥 𝑛 = 𝑋 𝑁−𝑘
X(5) = 6+3j,
X(6) = -2-3j,
X(7) = 10. Determine the remining samples
Solution
Given N=14
For n=8 ➔ 𝑋 8 = 𝑋 ∗ 𝑁 − 𝑘 = 𝑋 ∗ 14 − 8 = 𝑋 ∗ 6 = −2 + 3𝑗
For n=9 ➔ 𝑋 9 = 𝑋 ∗ 𝑁 − 𝑘 = 𝑋 ∗ 14 − 9 = 𝑋 ∗ 5 = 6 − 3𝑗
For n=10 ➔ 𝑋 10 = 𝑋 ∗ 𝑁 − 𝑘 = 𝑋 ∗ 14 − 10 = 𝑋 ∗ 4 = −2 − 2𝑗
For n=11 ➔ 𝑋 11 = 𝑋 ∗ 𝑁 − 𝑘 = 𝑋 ∗ 14 − 11 = 𝑋 ∗ 3 = 1 + 5𝑗
For n=12 ➔ 𝑋 12 = 𝑋 ∗ 𝑁 − 𝑘 = 𝑋 ∗ 14 − 12 = 𝑋 ∗ 2 = 3 − 4𝑗
For n=13 ➔ 𝑋 13 = 𝑋 ∗ 𝑁 − 𝑘 = 𝑋 ∗ 14 − 13 = 𝑋 ∗ 1 = −1 − 3𝑗
www.iammanuprasad.com
Linear Convolution
Consider a discrete sequence x(n) of length L and impulse sequence h(n) of length M,
the equation for linear convolution is
3
x(k) 2
∞
𝑦 𝑛 = 𝑥 𝑘 ℎ 𝑛−𝑘 1 1
𝑘=−∞
-3 -2 -1 0 1 2 3
Where length of y(n) is L+M-1
h(k) 1 1 1
Let’s discuss it with an example
www.iammanuprasad.com
∞ ∞ 3
For n=1 ➔ 𝑦 1 = 𝑥 𝑘 ℎ 1 − 𝑘 = 𝑥 𝑘 ℎ −𝑘 + 1 x(k) 2
𝑘=−∞ 𝑘=−∞ 1
1
For n=3 ➔ 𝑦 3 = 𝑥 𝑘 ℎ 3 − 𝑘 = 𝑥 𝑘 ℎ −𝑘 + 3 3 2 -1 0 1 2 3
𝑘=−∞ 𝑘=−∞ h(-k+1) 1 1 1
∞ ∞
For n=5 ➔ 𝑦 5 = 𝑥 𝑘 ℎ 5 − 𝑘 = 𝑥 𝑘 ℎ −𝑘 + 5 3 2 -1 0 1 2 3
𝑘=−∞ 𝑘=−∞ h(-k+4) 1 1 1
Solution
1 1 1
1 1 1 1
+ +
2 2 2 2
+ + 𝑦 𝑛 = 1,3,6,6,4,1
3 3 3 3
+
+
1 1 1 1
www.iammanuprasad.com
Circular Convolution
Consider two discrete sequence x1(n) & x2(n) of length N with DFTs X1(k), X2(k)
Also
𝑁−1
𝑥3 𝑛 = 𝑥1 𝑚 𝑥2 𝑛 − 𝑚 𝑁 𝑥3 𝑛 = 𝑥1 𝑛 ⊙ 𝑥2 𝑛 𝐷𝐹𝑇 𝑥1 𝑛 ⊙ 𝑥2 𝑛 = 𝑋1 𝑘 . 𝑋2 𝑘
𝑚=0
Matrix method
Solution
1 3 2 1 (1.1)+(4.-1)+(3.1)+(2.0) = 0
L = 4, M = 3
2 4 3 -1 (2.1)+(1.-1)+(4.1)+(3.0) = 5
Since lengths are not same we do zero-padding =
3 1 4 1 (3.1)+(2.-1)+(1.1)+(4.0) = 2
ℎ 𝑛 = 1, −1,1,0
4 2 1 0 (4.1)+(3.-1)+(2.1)+(2.0) = 3
𝑦 𝑛 = 0,5,2,3
www.iammanuprasad.com
Circular Convolution
Solution
L = 4, M = 3 1
ℎ 𝑛 = 1, −1,1,0
2 −1 4
0
For n=0 ➔ 𝑦 0 = 1.1 + 2.0 + 3.1 + (4. −1) =0
𝑦 𝑛 = 0,5,2,3
www.iammanuprasad.com
Linear convolution using circular convolution
Let there are two sequence x(n) with L and h(n) with length M. in linear convolution the length of output in L+M-1. In circular
convolution the length of the both input is L=M
First we have to make the length of the x(n) and h(n) by adding zeros
𝑦 𝑛 = 1,3,6,6,4,1
www.iammanuprasad.com
Filtering of long duration sequences
1) Overlap – save method
Let’s consider an input sequence x(n) of length Ls and response h(n)of length M, the steps to
follow overlap – save method is
www.iammanuprasad.com
1) Overlap – save method
Q) Find the convolution of the sequences x(n) = {3,-1,0,1,3,2,0,1,2,1} and h(n) ={1,1,1}
Solution
𝑥1 𝑛 = 3, −1,0
𝑥2 𝑛 = 1,3,2
𝑥3 𝑛 = 0,1,2
𝑥4 𝑛 = 1,0,0
www.iammanuprasad.com
1) Overlap – save method
Step 3 : Add M-1 zeros to the start to first segment, each segment (length = L) has its first M-1 points coming from
previous segment, making each of length N
𝑥1 𝑛 = 0,0,3, −1,0
M-1 = 3-1 = 2
𝑥1 𝑛 = 3, −1,0
𝑥2 𝑛 = −1,0, 1,3,2 𝑥2 𝑛 = 1,3,2
𝑥3 𝑛 = 0,1,2
𝑥4 𝑛 = 1,0,0
𝑥3 𝑛 = 3,2,0,1,2
𝑥4 𝑛 = 1,2,1,0,0
ℎ 𝑛 = 1,1,1,0,0
www.iammanuprasad.com
1) Overlap – save method
Step 5 ; Find the circular convolution of each new segments with new h(n)
Step 6 : Linearly combine each results and take sequence of length Ls+M-1 from that by discarding/removing first M-1
points
M-1 = 3-1 = 2
Check whether length of y(n) is Ls+M-1 , if yes
discard the higher sequences
𝑦 𝑛 = {3, 2, 2, 0, 4, 6, 5, 3, 3, 4, 3, 1}
Ls+M-1 = 10+3-1 = 12
www.iammanuprasad.com
1) Overlap – save method
Q) Find the convolution of the sequences x(n) = {1,2,-1,2,3,-2,-3,-1,1,1,2,-1} and h(n) ={1,2} using overlap-save method
Solution
𝑥1 𝑛 = 1, 2, −1
𝑥2 𝑛 = 2,3, −2
𝑥3 𝑛 = −3, −1,1
𝑥4 𝑛 = 1,2, −1
www.iammanuprasad.com
1) Overlap – save method
Step 3 : Add M-1 zeros to the start to first segment, each segment (length = L) has its first M-1 points coming from
previous segment, making each of length N
𝑥1 𝑛 = 0,1,2, −1
M-1 = 2-1 = 1
𝑥1 𝑛 = 1, 2, −1
𝑥2 𝑛 = −1,2,3, −2 𝑥2 𝑛 = 2,3, −2
𝑥3 𝑛 = −3, −1,1
𝑥4 𝑛 = 1,2, −1
𝑥3 𝑛 = −2, −3, −1,1
𝑥4 𝑛 = 1, 1, 2, −1
𝑥5 𝑛 = −1, 0,0,0
ℎ 𝑛 = 1, 2 , 0 , 0
www.iammanuprasad.com
1) Overlap – save method
Step 5 ; Find the circular convolution of each new segments with new h(n)
Step 6 : Linearly combine each results and take sequence of length Ls+M-1 from that by discarding/removing first M-1
points
Check whether length of y(n) is Ls+M-1 , if yes
𝑦 𝑛 = {1,4,3,0,7,4, −7, −7, −1,3,4,3, −2,0,0} discard the higher sequences
Ls+M-1 = 12+2-1 = 13
𝑦 𝑛 = {1,4,3,0,7,4, −7, −7, −1,3,4,3, −2}
www.iammanuprasad.com
Filtering of long duration sequences
2) Overlap – add method
Let’s consider an input sequence x(n) of length L1 and response h(n) of length M, the steps to
follow overlap – save method is
www.iammanuprasad.com
1) Overlap – add method
Q) Find the convolution of the sequences x(n) = {3,-1,0,1,3,2,0,1,2,1} and h(n) ={1,1,1}
Solution
𝑥1 𝑛 = 3, −1,0
𝑥2 𝑛 = 1,3,2
𝑥3 𝑛 = 0,1,2
𝑥4 𝑛 = 1,0,0
www.iammanuprasad.com
1) Overlap – add method
ℎ 𝑛 = 1,1,1,0,0
www.iammanuprasad.com
1) Overlap – add method
Step 5 ; Find the circular convolution of each new segments with new h(n)
Step 6 : Add last and first M-1 points of each segments, discard/remove excess point than L1+M-1
3, 2, 2, −1, 0
Check whether length of y(n) is L1+M-1 , if yes
1, 4, 6, 5, 2 discard the higher sequences
1, 1, 1, 0, 0
𝑦 𝑛 = {3, 2, 2, 0, 4, 6, 5, 3, 3, 4, 3, 1}
{3, 2, 2, 0, 4, 6, 5, 3, 3, 4, 3, 1, 0,0}
www.iammanuprasad.com
1) Overlap – add method
Q) Find the convolution of the sequences x(n) = {1,2,-1,2,3,-2,-3,-1,1,1,2,-1} and h(n) ={1,2} using overlap-add method
Solution
𝑥1 𝑛 = 1, 2, −1
𝑥2 𝑛 = 2,3, −2
𝑥3 𝑛 = −3, −1,1
𝑥4 𝑛 = 1,2, −1
www.iammanuprasad.com
1) Overlap – save method
ℎ 𝑛 = 1, 2 , 0 , 0
www.iammanuprasad.com
1) Overlap – save method
Step 5 ; Find the circular convolution of each new segments with new h(n)
Step 6 : Add last and first M-1 points of each segments, discard/remove excess point than L1+M-1
1, 4, 3, 2
Check whether length of y(n) is Ls+M-1 , if yes
−2, 7, 4, −4 discard the higher sequences
−3, −7, −1, 2 Ls+M-1 = 12+2-1 = 13
1, 4, 3, −2
𝑦 𝑛 = {1,4,3,0,7,4, −7, −7, −1,3,4,3, −2}
{1, 4, 3, 0, 7, 4, −7, −7, −1, 3, 4, 3, −2, }
www.iammanuprasad.com
Fast Fourier Transform (FFT)
DFT method
= 1048576 = 1047552
www.iammanuprasad.com
Fast Fourier Transform (FFT)
• DFT takes more time and resources
• Not much efficient
• Much complex
• So we come into a new algorithm to make the calculations fast known as fast Fourier Transform (FFT)
• It is a highly efficient procedure for computing the DFT of a sequence for computing the DFT of a finite
sequence and require less number of computation than that of direct evaluation of DFT
• FFT is based on decomposition and breaking the transform into smaller transform and combine them to get
total transform
• FFT make use of the symmetry and periodicity property of twiddle factor
FFT method
Complex multiplication =
𝑁
log 2 𝑁 Complex Addition= 𝑁 log 2 𝑁
2
= 1024 log 2 1024
1024
= log 2 1024 = 1024
2
= 5120
www.iammanuprasad.com
Fast Fourier Transform (FFT)
Let us recollect the twiddle factor 𝑒 −𝑗𝜃 = cos 𝜃 − 𝑗𝑠𝑖𝑛 𝜃
𝑁−1 𝑗2𝜋
− 0
𝑋 𝑘 = 𝑥 𝑛 𝑊𝑁𝑛𝑘 ,0 ≤ k ≤ N − 1
𝑊80 =𝑒 8 =1 For N=8 & k=3
𝑛=0 𝑗2𝜋 −𝑗3𝜋
𝑗2𝜋 − .3
𝑊𝑁 = 𝑒 −
𝑁 For N=8 & k=1 𝑊83 =𝑒 8 =𝑒 4
−𝑗𝜋
𝑗2𝜋 −
𝑗2𝜋
.1 3𝜋 3𝜋
𝑊𝑁𝑘 =𝑒
−
𝑁
𝑘 𝑊81 =𝑒 8 =𝑒 4 = cos − 𝑗 sin
4 4
𝜋 𝜋
For N=4 & k=0 = cos − 𝑗 sin
4 4 −1 1
𝑊83 = −𝑗
√2 √2
𝑗2𝜋 1 1
𝑊40 = 𝑒
−
4
0
=1 𝑊81 = −𝑗 = 0.7071 − 𝑗0.7071 𝑊83 = −0.7071 − 𝑗0.7071
√2 √2
=𝑒 −
2 = cos − 𝑗 sin
2 2 𝜋 𝜋
= cos − 𝑗 sin
2 2
𝑊41 = −𝑗
𝑊82 = −𝑗
www.iammanuprasad.com
Fast Fourier Transform (FFT)
• The number of output points N can be expressed as a power 𝑋(𝑘) = 𝑥𝑒 (𝑛)𝑊𝑁𝑛𝑘 + 𝑊𝑁𝑘 𝑥𝑜 (𝑛)𝑊𝑁𝑛𝑘
of 2 (N=2M) 𝑛=0 2 𝑛=0 2
We know DFT 𝑘+
𝑁
𝐹𝑟𝑜𝑚 𝑠𝑦𝑚𝑚𝑒𝑡𝑟𝑦 𝑝𝑟𝑜𝑝𝑒𝑟𝑡𝑦 ∶ 𝑊𝑁 2
= −𝑊𝑁𝑘
𝑁−1
𝑋 𝑘 = 𝑥 𝑛 𝑊𝑁𝑛𝑘
𝑛=0 Then
𝑁 𝑁
−1 −1
2 2
(2𝑛+1)𝑘 𝑁
= 𝑥 2𝑛 𝑊𝑁2𝑛𝑘 + 𝑥 2𝑛 + 1 𝑊𝑁 𝑁 𝑘− 𝑁
𝑋 𝑘 = 𝑋𝑒 𝑘− − 𝑊𝑁 2 𝑋𝑜 𝑘 − For k > N/2
𝑛=0 𝑛=0 2 2
𝑁 𝑁
−1 −1
2 2
= 𝑥 2𝑛 𝑊𝑁2𝑛𝑘 + 𝑊𝑁𝑘 𝑥 2𝑛 + 1 𝑊𝑁2𝑛𝑘
𝑛=0 𝑛=0
𝑗2𝜋
𝑗2𝜋 − 𝑁
− 2
𝑊𝑁2 = 𝑒 𝑁 =𝑒 2 = 𝑊𝑁
www.iammanuprasad.com
2
Decimation in Time (DIT)
𝑋 0 = 𝑥𝑒 0 + 𝑊80 𝑥𝑜 0 𝑋 4 = 𝑥𝑒 0 − 𝑊80 𝑥𝑜 0
𝑋 𝑘 = 𝑋𝑒 𝑘 + 𝑊𝑁𝑘 𝑋𝑜 (𝑘)
𝑁 𝑘−
𝑁
𝑁 𝑋 1 = 𝑥𝑒 1 + 𝑊81 𝑥𝑜 1 𝑋 5 = 𝑥𝑒 1 − 𝑊81 𝑥𝑜 1
𝑋 𝑘 = 𝑋𝑒 𝑘− − 𝑊𝑁 2 𝑋𝑜 𝑘 −
2 2 𝑋 2 = 𝑥𝑒 2 + 𝑊82 𝑥𝑜 2 𝑋 6 = 𝑥𝑒 2 − 𝑊82 𝑥𝑜 2
𝑋 3 = 𝑥𝑒 3 + 𝑊83 𝑥𝑜 3 𝑋 7 = 𝑥𝑒 3 − 𝑊83 𝑥𝑜 3
Example : For N = 8
This operation can be represented by a butterfly diagram
even odd
𝑥𝑒 (0) 𝑥𝑒 0 + 𝑊80 𝑥0 0 = 𝑋(0)
𝑥𝑒 0 = 𝑥(0) 𝑥𝑜 0 = 𝑥(1)
𝑥𝑒 1 = 𝑥(2) 𝑥0 1 = 𝑥(3)
𝑥𝑒 2 = 𝑥(4) 𝑥𝑜 2 = 𝑥(5)
𝑥𝑒 3 = 𝑥(6) 𝑥𝑜 3 = 𝑥(7) 𝑊80
𝑥𝑜 (0) 𝑥𝑒 0 − 𝑊80 𝑥0 0 = 𝑋(4)
𝑋 𝑘 = 𝑥𝑒 𝑘 + 𝑊8𝑘 𝑥𝑜 𝑘 , 𝑓𝑜𝑟 0 ≤ 𝑘 ≤ 3
𝑎 𝑎 + 𝑏𝑊𝑁𝑘
𝑋 𝑘 = 𝑥𝑒 𝑘 − 4 − 𝑊8𝑘−4 𝑥𝑜 𝑘 − 4 , 𝑓𝑜𝑟 4 ≤ 𝑘 ≤ 7
𝑊𝑁𝑘
𝑏
www.iammanuprasad.com 𝑎 − 𝑏𝑊𝑁𝑘
Decimation in Time (DIT)
Steps to follow
Solution
Step 1 : Find the number of input samples (N) Step 3 : Calculate the number of stages (𝑀 = log 2 𝑁)
N=4
𝑀 = log 2 𝑁 = log 2 4
Step 2 : Bit reversal
𝑀=2
x(0) 00 00 x(0) 𝑁 4
x(1) 01 10 x(2) = =2
2 2
x(2) 10 01 x(1)
x(3) 11 11 x(3)
www.iammanuprasad.com
Decimation in Time (DIT)
𝑁𝑡
𝑘= 𝑡 = 0, 1, 2, … 2𝑀−1 − 1
2𝑀
Stage =1 (𝑀 = 1) Stage =2 (𝑀 = 2)
𝑡 = 0,1
𝑡=0
𝑊40 𝑊41
for t=0
𝑁𝑡 4.0
𝑘= 𝑀 = =0 4.0
2 21 𝑘= =0
22
𝑊40
for t=1
4.1
𝑗2𝜋 𝑘= 2 =1
𝑊40 =𝑒
−
4
0
=1 2
www.iammanuprasad.com
Decimation in Time (DIT)
Step 6 : Evaluate the N point DFT using butterfly diagram
𝑥 𝑛 = 0, 1, 2, 3 𝑊40 = 1 𝑊41 = −𝑗
Stage 1 Stage 2
0 + 2.1 = 2 2 + 4.1 = 6 𝑋 0
𝑥 0 =0
𝑋 1
𝑊40 0 − 2.1 = −2 −2 + −2. −𝑗 = −2 + 2𝑗
𝑥 2 =2
𝑋 𝑘 = 6, −2 + 2𝑗, −2 − 2 − 2𝑗
www.iammanuprasad.com
Decimation in Time (DIT)
Q) Find the DFT of a sequence x(n) = {1, 2, 3, 4, 4, 3, 2, 1 } using DIT algorithm
Solution
Step 1 : Find the number of input samples (N) Step 3 : Calculate the number of stages (𝑀 = log 2 𝑁)
N=8
𝑀 = log 2 𝑁 = log 2 8
Step 2 : Bit reversal
𝑀=3
𝑁 8
= =4
2 2
www.iammanuprasad.com
Decimation in Time (DIT)
𝑁𝑡 𝑡 = 0,1,2,3
𝑘= 𝑀 𝑡 = 0, 1, 2, … 2𝑀−1 − 1
2 for t=0
8.0
Stage =2 (𝑀 = 2) 𝑘= =0 𝑊80 𝑊80 = 1
Stage =1 (𝑀 = 1) 23
𝑡 = 0,1
for t=1
𝑡=0 for t=0 8.1 1 1
𝑘= =1 𝑊81 𝑊81 = −𝑗
𝑁𝑡 8.0 8.0 23 √2 √2
𝑘= 𝑀
2
= 1 =0 𝑘= 2 =0 𝑊80
2 2 for t=2
8.2
𝑊80 for t=1 𝑘= =2 𝑊82 𝑊82 = −𝑗
23
8.1
𝑘= 2 =2 𝑊82
𝑗2𝜋 2 for t=3
− 8 0
𝑊80 =𝑒 =1 8.3 −1 1
𝑊82 = −𝑗 𝑘= 3 =3 𝑊83 𝑊82 =
√2
−𝑗
√2
2
www.iammanuprasad.com
Decimation in Time (DIT)
Step 6 : Evaluate the N point DFT using butterfly diagram
1 1 −1 1
𝑥 𝑛 = 1, 2, 3,4, 4, 3, 2, 1 𝑊80 = 1 𝑊81 = −𝑗 𝑊82 = −𝑗 𝑊83 = −𝑗
√2 √2 √2 √2
Stage 1 Stage 2 Stage 3
𝑥 0 =1 1 + 4.1 = 5 5 + 5.1 = 10 10 + 10.1 = 20 𝑋 0
1 1
−3 − 𝑗 + −1 − 3𝑗 −𝑗
√2 √2
𝑥 4 =4 1 − 4.1 = −3 −3 + 1. −𝑗 = −3 − 𝑗 −5.82 − 𝑗2.414 𝑋 1
𝑊80 = 1
𝑥 2 =3 3 + 2.1 = 5 5 − 5.1 = 0 0 𝑋 2
𝑊80 = 1
−3 − 1. −𝑗 = −3 + 𝑗 −0.172 − 𝑗0.414
𝑥 6 =2 3 − 2.1 = 1 𝑋 3
𝑊80 = 1 𝑊82 = −𝑗
𝑥 1 =2 5 10 0 𝑋 4
𝑊80 = 1
𝑥 5 =3 −1 − 3𝑗 −0.172 − 𝑗0.414 𝑋 5
−1
𝑊80 = 1 1 1
𝑊81 = −𝑗
√2 √2 Step7 : The DFT
𝑥 3 =4 5 0 0 𝑋 6 output is in normal
𝑊80 = 1 𝑊82 = −𝑗 order
𝑥 7 =1 3 −1 + 3𝑗 −5.828 + 𝑗0.414 𝑋 7
𝑊80 = 1 𝑊82 = −𝑗 −1 1
𝑊83 = −𝑗
√2 √2
𝑥1 2 = 𝑥(2) 𝑥2 2 = 𝑥(6)
𝑥2 (𝑛) [𝑥1 𝑛 − 𝑥2 𝑛 ]𝑊𝑁𝑛
𝑥1 3 = 𝑥(3) 𝑥2 3 = 𝑥(7)
𝑎 𝑎+𝑏
𝑋 2𝑘 = 𝑥1 𝑘 + 𝑥2 𝑘 , 𝑓𝑜𝑟 0 ≤ 𝑘 ≤ 3 𝑊𝑁𝑛
𝑋 2𝑘 + 1 = 𝑥1 𝑘 − 𝑥2 𝑘 𝑊8𝑘 , 𝑓𝑜𝑟 4 ≤ 𝑘 ≤ 7
𝑏
www.iammanuprasad.com [𝑎 − 𝑏]𝑊𝑁𝑛
Decimation in Frequency (DIF)
Steps to follow
Solution
Step 3 : Calculate the number of stages (𝑀 = log 2 𝑁)
Step 1 : Find the number of input samples (N)
𝑁 4
= =2
2 2
www.iammanuprasad.com
Decimation in Frequency (DIF)
𝑁𝑡
𝑘= 𝑡 = 0, 1, 2, … 2𝑀−𝑚 − 1
2𝑀−𝑚+1
Stage =1 Stage =2 (𝑀 = 2, 𝑚 = 2)
(𝑀 = 2, 𝑚 = 1)
𝑡 = 0,1 𝑡=0
for t=0
𝑊40 𝑊41 𝑁𝑡 4.0
𝑘= = =0
𝑁𝑡 4.0 2𝑀−𝑚+1 21
𝑘= = 2 =0
2𝑀−𝑚+1 2
𝑊40
for t=1
4.1
𝑘= =1
22
www.iammanuprasad.com
Decimation in Frequency (DIF)
Step 6 : Evaluate the N point DFT using butterfly diagram
𝑥 𝑛 = 0, 1, 2, 3 𝑊40 = 1 𝑊41 = −𝑗
Stage 1 Stage 2
0+2=2 2+4=6 𝑋 0
𝑥 0 =0
𝑊40 𝑊40
𝑋 2
1+3=4 2 − 4 1 = −2
𝑥 1 =1
0 − 2 1 = −2 −2 + 2𝑗 𝑋(1)
𝑥 2 =2
𝑊41
𝑊40 Step7 : The DFT output is
in bit-reversed order
𝑥 3 =3 −2 − 2𝑗 1 = −2 − 2𝑗 𝑋 3
1 − 3 − 𝑗 = 2𝑗
𝑋 𝑘 = 6, −2 + 2𝑗, −2, −2 − 2𝑗
www.iammanuprasad.com
Decimation in Frequency (DIF)
Q) Find the DFT of a sequence x(n) = {1, 2, 3, 4, 4, 3, 2, 1 } using DIF algorithm
Solution
Step 1 : Find the number of input samples (N) Step 3 : Calculate the number of stages (𝑀 = log 2 𝑁)
N=8
𝑀 = log 2 𝑁 = log 2 8
Step 2 : input sequence in normal order
𝑀=3
𝑁 8
= =4
2 2
www.iammanuprasad.com
Decimation in Frequency (DIF)
Step 5 : Calculate the twiddle factor
𝑁𝑡
𝑘 = 𝑀−𝑚+1 𝑡 = 0, 1, 2, … 2𝑀−𝑚 − 1 Stage =2 (𝑀 = 3, 𝑚 = 2)
2
Stage =1 (𝑀 = 3, 𝑚 = 1) 𝑡 = 0,1
www.iammanuprasad.com
Decimation in Frequency (DIF)
Step 6 : Evaluate the N point DFT using butterfly diagram
1 1 −1 1
𝑥 𝑛 = 1, 2, 3,4, 4, 3, 2, 1 𝑊80 = 1 𝑊81 = −𝑗 𝑊82 = −𝑗 𝑊83 = −𝑗
√2 √2 √2 √2
Stage 1 Stage 2 Stage 3
𝑥 0 =1 1+4=5 5 + 5 = 10 10 + 10 = 20 𝑋 0
𝑊80 𝑊80
𝑊80 5 + 5 = 10 𝑋 4
𝑥 1 =2 2+3=5 10 − 10 1 = 0
𝑊81
𝑊82
𝑥 2 =3 3+2=5 5−5 1=0 0 𝑋 2
𝑊82 𝑊80
5−5 −𝑗 =0
𝑥 3 =4 4+1=5 0 𝑋 6
𝑊83
1 − 4 . 1 = −3 −3 − 𝑗 −5.82 − 𝑗2.414 𝑋 1
𝑥 4 =4
1 1
2−3 −𝑗 𝑊80
√2 2 𝑊80
𝑥 5 =3 −0.707 + 𝑗0.707 −2.828 − 𝑗1.414 −0.172 − 𝑗0.414 𝑋 5
𝑊82
3 − 2 − 𝑗 = −𝑗 −3 + 𝑗 𝑋 3
𝑥 6 =2 −0.172 − 𝑗0.414
−1 1 Step7 : The DFT output
4−1 −𝑗 𝑊80
√2 √2 is in bit reversed order
𝑥 7 =1 −2.121 − 𝑗2.121 2.828 − 𝑗1.414 −5.828 + 𝑗0.414 𝑋 7
∗
𝑁−1
1
𝑥(𝑛) = 𝑋 ∗ 𝑘 𝑊𝑁𝑛𝑘
𝑁
𝑘=0
Q) Find the IDFT of the sequence X(k) = {10, -2+2j, -2, -2-2j} using DIT algorithm
x(0) 00 00 x(0)
𝑁 4
x(1) 01 10 x(2) = =2
2 2
x(2) 10 01 x(1)
x(3) 11 11 x(3)
www.iammanuprasad.com
IDFT Computation using Radix -2 FFT algorithm
𝑁𝑡
𝑘= 𝑡 = 0, 1, 2, … 2𝑀−1 − 1 Step 6 : Find the conjugates of X(k)
2𝑀 Stage =2 (𝑀 = 2)
Stage =1 (𝑀 = 1) 𝑡 = 0,1 X(k) = {10, -2+2j, -2, -2-2j}
𝑡=0 for t=0
𝑁𝑡 4.0 X*(k) = {10, -2-2j, -2, -2+2j}
𝑘= 𝑀 = 1 4.0
2 2
=0 𝑘= =0 𝑊40
22
www.iammanuprasad.com
IDFT Computation using Radix -2 FFT algorithm
Step 7 : Evaluate the IDFT using butterfly diagram
10 + (−2 ∗ 1) = 8 8 + −4 ∗ 1 = 4 𝑥∗ 0
𝑥 0 = 10
𝑥∗ 1
𝑊40 10 − −2 ∗ 1 = 12 12 + −4𝑗 ∗ −𝑗 = 8
𝑥 2 = −2
−2 − 2𝑗 + −2 + 2𝑗 . 1 = −4 𝑊40 8 − −4 ∗ 1 = 12 𝑥 ∗ (2)
𝑥 1 = −2 − 2𝑗
1
𝑥 ∗ (𝑛) = 4, 8, 12, 16 𝑥 𝑛 = {1, 2, 3, 4}
4
www.iammanuprasad.com
IDFT Computation using Radix -2 FFT algorithm
Q) Find the IDFT of the sequence X(k) = {7, 2, 3, 1+j} using DIF algorithm
Solution
x(0) 00 00 x(0)
Step 4 : Calculate the number of max butterflies in stage
x(1) 01 10 x(2)
x(2) 10 01 x(1) 𝑁 4
= =2
x(3) 11 11 x(3) 2 2
www.iammanuprasad.com
IDFT Computation using Radix -2 FFT algorithm
𝑁𝑡
𝑘= 𝑡 = 0, 1, 2, … 2𝑀−𝑚 − 1
2𝑀−𝑚+1
Step 6 : Find the conjugates of X(k)
Stage =2 (𝑀 = 2, 𝑚 = 2)
Stage =1 (𝑀 = 2, 𝑚 = 1)
𝑡 = 0,1 𝑡=0 X(k) = {7, 2, 3, 1+j}
for t=0 𝑁𝑡 4.0
𝑘= = =0
4.0 2𝑀 21
𝑊40 X*(k) = {7, 2, 3, 1-j}
𝑘= 2 =0
2
for t=1 𝑊40
4.1
𝑘= =1 𝑊41 𝑗2𝜋
− 4 0
22 𝑊40 =𝑒 =1
𝑗2𝜋
− 0
𝑊40 =𝑒 4 =1
www.iammanuprasad.com
Decimation in Frequency (DIF)
Step 7 : Evaluate the N point DFT using butterfly diagram
Stage 1 Stage 2
7 + 3 = 10 10 + 3 − 𝑗 = 13 − 𝑗 𝑋 0
𝑥 0 =7
𝑊40 𝑊40
𝑋 2
2+1−𝑗 =3−𝑗 10 − 3 − 𝑗 1 = 7 + 𝑗
𝑥 1 =2
7 − 3 .1 = 4 4 + 1 − 𝑗 .1 = 5 − 𝑗 𝑋(1)
𝑥 2 =3
𝑊41
𝑊40 Step8 : The output is in
normal order and divide it
with N
𝑥 3 =1−𝑗 4 − 1 − 𝑗 .1 = 3 + 𝑗 𝑋 3
2− 1−𝑗 −𝑗 =1−𝑗
1
𝑥 ∗ (𝑛) = 13 − 𝑗, 5 − 𝑗, 7 + 𝑗, 3 + 𝑗
4
www.iammanuprasad.com
Application of FFT
Let x1(n) and x2(n) are two real sequences of length N and let x(n) be a complex values sequence defined as x(n) =x1(n)+jx2(n)
𝑋 𝑘 = 𝑋1 𝑘 + 𝑗𝑋2 (𝑘)
𝑥 𝑛 + 𝑥 ∗ (𝑛) 𝑥 𝑛 − 𝑥 ∗ (𝑛)
𝑥1 𝑛 = 𝑥2 𝑛 =
2 2𝑗
1 1
𝑋1 𝑘 = 𝐷𝐹𝑇 𝑥(𝑛) + 𝐷𝐹𝑇 𝑥 ∗ (𝑛) 𝑋2 𝑘 = 𝐷𝐹𝑇 𝑥(𝑛) − 𝐷𝐹𝑇 𝑥 ∗ (𝑛)
2 2𝑗
𝐷𝐹𝑇 1 1
𝑥∗ 𝑛 𝑋∗ 𝑁 − 𝑘 𝑋1 𝑘 = 𝑋 𝑘 + 𝑋∗ 𝑁 − 𝑘 𝑋2 𝑘 = 𝑋 𝑘 − 𝑋∗ 𝑁 − 𝑘
2 2𝑗
www.iammanuprasad.com
Efficient computation of DFT of two real sequences
Q) Find the DFT of two sequence x1(n) = {1,3,1,2} and x2(n) = {2,5,1,3}
Solution
𝑥 𝑛 = 𝑥1 𝑛 + 𝑗𝑥2 𝑛 For n = 0,1,2,3 𝑥 𝑛 = 1 + 2𝑗, 3 + 5𝑗, 1 + 𝑗, 2 + 3𝑗
Now find the DFT of the sequence x(n) using DIT or DIF method
𝑊40 𝑊40
𝑋 2
5 + 8𝑗 −3 − 5𝑗
𝑥 1 =, 3 + 5𝑗
2 𝑋(1)
𝑥 2 = 1+𝑗 𝑗
𝑊41
𝑊40
𝑋(𝑘) = 7 + 11𝑗, 2, −3 − 5𝑗, −2 + 2𝑗
−2 + 2𝑗 𝑋 3
𝑥 3 = 2 + 3𝑗
2−𝑗
www.iammanuprasad.com
𝑋(𝑘) = 7 + 11𝑗, 2, −3 − 5𝑗, −2 + 2𝑗
𝑥1 𝑛 = 𝑔 2𝑛 𝑥2 𝑛 = 𝑔 2𝑛 + 1
𝑁−1 𝑁−1
Now follow same as the DFT computation of two real sequence 𝐺(𝑘) = 𝑥1 𝑛 𝑊𝑁𝑛𝑘 + 𝑊2𝑁
𝑘
𝑥2 𝑛 𝑊𝑁𝑛𝑘
𝑛=0 𝑛=0
1 1
𝑋1 𝑘 = 𝑋 𝑘 + 𝑋 ∗ 𝑁 − 𝑘 𝑋2 𝑘 = 𝑋 𝑘 − 𝑋∗ 𝑁 − 𝑘
2 2𝑗
www.iammanuprasad.com
Efficient computation of DFT of a 2N-point real sequence
Q) Find the DFT of the sequence x(n) = {1,3,7,2,1,2,1,3} using 4-point DFT
Now find the DFT of the sequence x(n) using DIT or DIF method
𝑊40 𝑊40
𝑋 2
8 + 5𝑗 −6
𝑥 1 = 7 + 2𝑗
−1 − 5𝑗 𝑋(1)
𝑥 2 = 1 + 2𝑗 𝑗
𝑊41
𝑊40
𝑋(𝑘) = 10 + 10𝑗, −1 − 5𝑗, −6,1 + 7𝑗
1 + 7𝑗 𝑋 3
𝑥 3 = 1 + 3𝑗
−1 − 6𝑗
www.iammanuprasad.com
𝑋(𝑘) = 10 + 10𝑗, −1 − 5𝑗, −6,1 + 7𝑗
For k=0 = 10 − 1. 10 =0
𝑋 0 = 𝑋1 0 + 𝑊80 𝑋2 0 For k=1
𝑋 1 + 4 = 𝑋1 1 − 𝑊81 𝑋2 1
= 10 + 1. 10 = 20
1 1
= −6𝑗 − 1 + 𝑗 −𝑗 = − 2 − 6𝑗
For k=1 √2 √2
For k=2
𝑋 1 = 𝑋1 1 + 𝑊81 𝑋2 1
𝑋 2 + 4 = 𝑋1 2 − 𝑊82 𝑋2 2
1 1
= −6𝑗 + 1 + 𝑗 −𝑗 = 2 − 6𝑗 = −6 − 0 −𝑗 = −6
√2 √2
For k=3
For k=2 𝑋 3 + 4 = 𝑋1 3 − 𝑊83 𝑋2 3
𝑋 2 = 𝑋1 2 + 𝑊82 𝑋2 2 −1 1
= 6𝑗 − 1 − 𝑗 −𝑗 = 2 + 6𝑗
= −6 + 0 −𝑗 = −6 √2 √2
• What is a Filter?
• Any medium through which the signal passes, whatever its form, can be regarded as a filter.
• However, we do not usually think of something as a filter unless it can modify the signal in some way. For example,
speaker wire is not considered a filter, but the speaker is
• A digital filter is just a filter that operates on digital signals, such as sound represented inside a
computer.
• It is a computation which takes one sequence of numbers (the input signal) and produces a new
sequence of numbers (the filtered output signal).
Types of Filter
www.iammanuprasad.com
YouTube - IMPLearn
Finite Impulse Response (FIR) Filters
www.iammanuprasad.com
YouTube - IMPLearn
Finite Impulse Response (FIR) Filters
• A discrete-time FIR filter of order N. The top part is an N-stage delay line with N +
1 taps. Each unit delay is a z−1 operator in the Z-transform notation.
• The output y of a linear time invariant system is determined by convolving its input
signal x with its impulse response b.
• For a discrete-time FIR filter, the output is a weighted sum of the current and a
finite number of previous values of the input.
• The operation is described by the following equation, which defines the output
sequence y[n] in terms of its input sequence x[n]:
𝑦 𝑛 = 𝑏0 𝑥 𝑛 + 𝑏1 𝑥 𝑛 − 1 + 𝑏2 𝑥 𝑛 − 2 + … + 𝑏𝑁 𝑥 𝑛 − 𝑁
𝑁−1
𝑦 𝑛 = 𝑏𝑘 𝑥 𝑛 − 𝑘
𝑘=0
𝑁−1 𝑁−1
𝑦 𝑛 = 𝑏𝑘 𝑥 𝑛 − 𝑘 ℎ(𝑛) = 𝑏𝑘 𝛿 𝑛 − 𝑘
𝑘=0 𝑘=0
The Z-transform of the impulse response yields the transfer function of the FIR filter
H(𝑧) = 𝑍 ℎ 𝑛
= ℎ 𝑛 𝑧 −𝑛
𝑛=−∞
𝑁−1
𝐻 𝑧 = 𝑏𝑛 𝑧 −𝑛
𝑛=0
www.iammanuprasad.com
YouTube - IMPLearn
Linear phase FIR filter – Symmetric Impulse response
Let h(n) be an impulse response of a system then its Fourier transform can
be expressed as (4) / (3)
𝑁−1
𝑗𝜔 −𝑗𝜔𝑛
σ𝑁−1
𝑛=0 ℎ 𝑛 sin 𝜔𝑛 sin 𝛼𝜔
𝐻 𝑒 = ℎ 𝑛 𝑒 ----------------- (1) =
𝑛=0
σ𝑁−1
𝑛=0 ℎ 𝑛 cos 𝜔𝑛 cos 𝛼𝜔
Since H(ejωn) is a complex value for linear phase FIR filter , then we can 𝑁−1 𝑁−1
represent it in terms of magnitude and phase ℎ 𝑛 sin 𝜔𝑛 cos 𝛼𝜔 = ℎ 𝑛 cos 𝜔𝑛 sin 𝛼𝜔
𝑛=0 𝑛=0
𝐻 𝑒 𝑗𝜔 = ± 𝐻 𝑒 𝑗𝜔 𝑒 −𝑗𝛼𝜔 ----------------- (2)
𝑁−1
Equating (1) & (2) 0 = ℎ 𝑛 cos 𝜔𝑛 sin 𝛼𝜔 − sin 𝜔𝑛 cos 𝛼𝜔
𝑁−1
𝑛=0
−𝑗𝜔𝑛 𝑗𝜔 −𝑗𝛼𝜔 sin 𝐴 − 𝐵 = sin 𝐴 cos 𝐵 − cos 𝐴 sin 𝐵
ℎ 𝑛 𝑒 =±𝐻 𝑒 𝑒
𝑛=0
𝑒 −𝑗𝜃 = cos 𝜃 − 𝑗 sin 𝜃 𝑁−1
𝑁−1 ℎ 𝑛 sin 𝛼 − 𝑛 𝜔 = 0
𝑗𝜔
ℎ 𝑛 cos 𝜔𝑛 − 𝑗 sin 𝜔𝑛 = ± 𝐻 𝑒 cos 𝛼𝜔 − 𝑗 sin 𝛼𝜔 𝑛=0
𝑛=0
Equating sin and cos terms The above equation will be zero when
𝑁−1
𝜃 𝜔 = −𝛼𝜔 , −𝜋 ≤ 𝜔 ≤ 𝜋 From the equations and the conditions we can conclude that FIR filter will have
𝑁−1
constant phase and group delays when the impulse response is symmetrical about 𝛼 =
2
For N is even
For N is odd
3 3 3
2 2 2 2
2 2
1 1
1 1
0 1 2 3 4 5
0 1 2 3 4 5 6
𝑁−1 6−1
𝑁−1 7−1 𝛼= = = 2.5
𝛼= = =3 2 2
2 2
ℎ 𝑛 =ℎ 𝑁−1−𝑛
ℎ 𝑛 =ℎ 𝑁−1−𝑛
ℎ 5 =ℎ 6−1−5
ℎ 5 =ℎ 7−1−5
=ℎ 0 www.iammanuprasad.com
=ℎ 1
YouTube - IMPLearn
Linear phase FIR filter – Antisymmetric Impulse response
𝜃 𝜔 = 𝛽 − 𝛼𝜔
Let h(n) be an impulse response of a system then its Fourier transform can
be expressed as (4) / (3)
𝑁−1
𝑗𝜔 −𝑗𝜔𝑛
σ𝑁−1
𝑛=0 ℎ 𝑛 sin 𝜔𝑛 sin(𝛽 − 𝛼𝜔)
𝐻 𝑒 = ℎ 𝑛 𝑒 ----------------- (1) =
𝑛=0
σ𝑁−1
𝑛=0 ℎ 𝑛 cos 𝜔𝑛 cos(𝛽 − 𝛼𝜔)
𝑁−1 𝑁−1
Since H(ejωn) is a complex value for linear phase FIR filter , then we can
represent it in terms of magnitude and phase. If only constant group delay ℎ 𝑛 sin 𝜔𝑛 cos(𝛽 − 𝛼𝜔) = ℎ 𝑛 cos 𝜔𝑛 sin(𝛽 − 𝛼𝜔)
is required 𝑛=0 𝑛=0
𝐻 𝑒 𝑗𝜔 = ± 𝐻 𝑒 𝑗𝜔 𝑒 −𝑗(𝛽−𝛼𝜔) ----------------- (2) 𝑁−1
Equating (1) & (2) 0 = ℎ 𝑛 cos 𝜔𝑛 sin(𝛽 − 𝛼𝜔) − sin 𝜔𝑛 cos(𝛽 − 𝛼𝜔)
𝑁−1 𝑛=0
𝜃 𝜔 = 𝛽 − 𝛼𝜔 , −𝜋 ≤ 𝜔 ≤ 𝜋 From the equations and the conditions we can conclude that FIR filter will have
constant group delay and not constant phase delay
www.iammanuprasad.com
YouTube - IMPLearn
Depending on the value of N and the type of symmetry of filter impulse response sequence
there are mainly 4 types of linear phase FIR filter
www.iammanuprasad.com
YouTube - IMPLearn
Case1 : Symmetrical impulse response and N - odd
ℎ 𝑛 3 To arrange the limit we assume
2 2 𝑁=7
When 𝑛 =
𝑁+1 When 𝑛 = 𝑁 − 1
2
1 1 𝑚 =𝑁−1−𝑛 𝑁+1
𝑁−1 =𝑁−1−𝑚 𝑁−1=𝑁−1−𝑚
𝛼= =3 2
2 𝑛 =𝑁−1−𝑚
0 1 2 3 4 5 6 𝑁−3
𝑚= 𝑚=0
2
Substitute in (1)
Given h(n) and find the Fourier transform H(ejω)
𝑁−3 𝑁−3
2 2
𝑁−1
𝑗𝜔 −𝑗𝜔𝑛
𝑁 − 1 −𝑗𝜔 𝑁−1
𝑗𝜔 −𝑗𝜔𝑛 𝐻 𝑒 = ℎ 𝑛 𝑒 +ℎ 𝑒 2 + ℎ 𝑁 − 1 − 𝑚 𝑒 −𝑗𝜔 𝑁−1−𝑚
𝐻 𝑒 = ℎ 𝑛 𝑒 2
𝑛=0 𝑚=0
𝑛=0
Put m=n
𝑁−1 𝑁−3 𝑁−3
Since N is odd the centre of symmetry will be at n = 2 2
2
𝑗𝜔 −𝑗𝜔𝑛
𝑁 − 1 −𝑗𝜔 𝑁−1
𝐻 𝑒 = ℎ 𝑛 𝑒 +ℎ 𝑒 2 + ℎ 𝑁 − 1 − 𝑛 𝑒 −𝑗𝜔 𝑁−1−𝑛
2
Now lets split the equation into three parts 𝑛=0 𝑛=0
www.iammanuprasad.com
YouTube - IMPLearn
Case1 : Symmetrical impulse response and N - odd
𝑁−3 𝑁−3
2 2
𝑁 − 1 −𝑗𝜔 𝑁−1
𝐻 𝑒 𝑗𝜔 = ℎ 𝑛 𝑒 −𝑗𝜔𝑛 + ℎ 𝑒 2 + ℎ 𝑛 𝑒 −𝑗𝜔 𝑁−1−𝑛
2 Let When 𝑛 =
𝑁−3
𝑛=0 𝑛=0 When 𝑛 = 0 2
𝑁−1
𝑁−1 𝑘= −𝑛 𝑁−1 𝑁−3 𝑁−1
Taking 𝑒
−𝑗𝜔
2 outside 2 0= −𝑘 = −𝑘
𝑁−1 2 2 2
𝑛= −𝑘
𝑁−3 2 𝑁−1
2 𝑘= 𝑘=1
−𝑗𝜔
𝑁−1 𝑁−1 𝑗𝜔
𝑁−1
𝑗𝜔
𝑁−1 2
𝐻 𝑒 𝑗𝜔 = 𝑒 2 ℎ + ℎ 𝑛 𝑒 −𝑗𝜔𝑛 . 𝑒 2 + 𝑒 −𝑗𝜔 𝑁−1−𝑛 . 𝑒 2 𝑁−1
2 2
𝑛=0
−𝑗𝜔
𝑁−1 𝑁−1 𝑁−1
𝐻 𝑒 𝑗𝜔 = 𝑒 2 ℎ + 2ℎ − 𝑘 cos 𝜔𝑘
2 2
𝑁−3 𝑘=1
2 𝑁−1
−𝑗𝜔
𝑁−1 𝑁−1 𝑗𝜔
𝑁−1
−𝑛 −𝑗𝜔 𝑁−1−𝑛−
2 Put k = n
=𝑒 2 ℎ +ℎ 𝑛 𝑒 2 +𝑒 𝑁−1
2 2
𝑛=0 𝑁−1 𝑁−1 𝑁−1
𝑗𝜔 −𝑗𝜔
𝐻 𝑒 =𝑒 2 ℎ + 2ℎ − 𝑛 cos 𝜔𝑛
𝑁−3
2 2
𝑛=1
2
−𝑗𝜔
𝑁−1 𝑁−1 𝑗𝜔
𝑁−1
−𝑛 −𝑗𝜔
𝑁−1
−𝑛
=𝑒 2 ℎ +ℎ 𝑛 𝑒 2 +𝑒 2
𝑁−1
2 2
𝑛=0 𝑁−1
−𝑗𝜔
𝐻 𝑒 𝑗𝜔 = 𝑒 2 𝑎 𝑛 cos 𝜔𝑛
2 cos 𝜃 = 𝑒 𝑗𝜃 + 𝑒 −𝑗𝜃 𝑛=1
𝑁−3 Where
2
−𝑗𝜔
𝑁−1 𝑁−1 𝑁−1 𝑁−1 𝑁−1
=𝑒 2 ℎ + ℎ 𝑛 2 cos 𝜔 −𝑛 𝑎 0 =ℎ 𝑎 𝑛 = 2ℎ −𝑛
2 2 2 2
𝑛=0
www.iammanuprasad.com
YouTube - IMPLearn
Case1 : Symmetrical impulse response and N - odd
𝑁−1
𝑁−1 2
𝑗𝜔 −𝑗𝜔
𝐻 𝑒 =𝑒 2 𝑎 𝑛 cos 𝜔𝑛
𝑛=1
Where
𝑁−1 𝑁−1
𝑎 0 =ℎ 𝑎 𝑛 = 2ℎ −𝑛
2 2
Amplitude Phase
𝑁−1
2
𝑗𝜔
𝑁−1
𝐻 𝑒 𝑗𝜔
= 𝑎 𝑛 cos 𝜔𝑛 ∠𝐻 𝑒 = −𝜔 = −𝛼𝜔
2
𝑛=1
www.iammanuprasad.com
YouTube - IMPLearn
Case2 : Symmetrical impulse response and N - even
ℎ 𝑛 To arrange the limit we assume
2 2 𝑁=6 𝑁 When 𝑛 = 𝑁 − 1
When 𝑛 =
2
1 1 𝑚 =𝑁−1−𝑛 𝑁
𝑁−1 =𝑁−1−𝑚
𝛼= = 2.5 2 𝑁−1=𝑁−1−𝑚
𝑛 =𝑁−1−𝑚
2
0 1 2 3 4 5 𝑁
𝑚= −1 𝑚=0
2
Substitute in (1)
Given h(n) and find the Fourier transform H(ejω)
𝑁−2 𝑁−2
2 2
𝑁−1 𝐻 𝑒 𝑗𝜔 = ℎ 𝑛 𝑒 −𝑗𝜔𝑛 + ℎ 𝑁 − 1 − 𝑚 𝑒 −𝑗𝜔 𝑁−1−𝑚
𝐻 𝑒 𝑗𝜔 = ℎ 𝑛 𝑒 −𝑗𝜔𝑛 𝑛=0 𝑚=0
𝑛=0 Put m=n
𝑁−1
Since N is even the centre of symmetry will be at n =
2 𝑁−3 𝑁−2
2 2
For symmetric impulse response with even number of samples and 𝑗𝜔 −𝑗𝜔𝑛
𝑁 − 1 −𝑗𝜔 𝑁−1
𝑁−2 𝑁 𝐻 𝑒 = ℎ 𝑛 𝑒 +ℎ 𝑒 2 + ℎ 𝑁 − 1 − 𝑛 𝑒 −𝑗𝜔 𝑁−1−𝑛
centre of symmetry lies between 𝑛 = and 2
2 2 𝑛=0 𝑛=0
2 cos 𝜃 = 𝑒 𝑗𝜃 + 𝑒 −𝑗𝜃
𝑁
2
𝑁−2 −𝑗𝜔
𝑁−1 1
2 𝐻 𝑒 𝑗𝜔 = 𝑒 2 𝑏 𝑛 cos 𝜔 𝑛 −
−𝑗𝜔
𝑁−1 𝑁−1 2
=𝑒 2 ℎ 𝑛 2 cos 𝜔 −𝑛 𝑛=1
2
𝑛=0 Where
𝑁
𝑏 𝑛 = 2ℎ −𝑛
𝑁−1 𝑁 1 2
−𝑛 = −𝑛−
2 2 2 www.iammanuprasad.com
YouTube - IMPLearn
Case2 : Symmetrical impulse response and N - even
𝑁
2
𝑗𝜔 −𝑗𝜔
𝑁−1 1
𝐻 𝑒 =𝑒 2 𝑏 𝑛 cos 𝜔 𝑛 −
2
𝑛=1
Where
𝑁
𝑏 𝑛 = 2ℎ −𝑛
2
Amplitude Phase
𝑁
2
1 𝑁−1
𝐻 𝑒 𝑗𝜔 = 𝑏 𝑛 cos 𝜔 𝑛 − ∠𝐻 𝑒 𝑗𝜔
= −𝜔 = −𝛼𝜔
2 2
𝑛=1
www.iammanuprasad.com
YouTube - IMPLearn
Case 3 : Antisymmetrical impulse response and N - odd
𝑁−1
𝑁−1 2
𝑗𝜋
−𝑗𝜔
𝐻 𝑒 𝑗𝜔 = 𝑒 2 𝑒2 𝑐 𝑛 sin 𝜔 𝑛
𝑛=1
Where
𝑁−1
𝑐 𝑛 = 2ℎ −𝑛
2
Amplitude Phase
𝑁−1
2
𝜋 𝑁−1 𝜋
𝐻 𝑒 𝑗𝜔
= 𝑐 𝑛 cos 𝜔 𝑛 ∠𝐻 𝑒 𝑗𝜔 = − 𝜔 = − 𝛼𝜔
2 2 2
𝑛=1
www.iammanuprasad.com
YouTube - IMPLearn
Case 4 : Ant symmetrical impulse response and N - even
𝑁
2
𝑗𝜔 −𝑗𝜔
𝑁−1 𝑗𝜋 1
𝐻 𝑒 =𝑒 2 𝑒2 𝑑 𝑛 sin 𝜔 𝑛 −
2
𝑛=1
Where
𝑁
𝑑 𝑛 = 2ℎ −𝑛
2
Amplitude Phase
𝑁
2
1 𝜋 𝑁−1 𝜋
𝐻 𝑒 𝑗𝜔
= 𝑑 𝑛 sin 𝜔 𝑛 − ∠𝐻 𝑒 𝑗𝜔 = − 𝜔 = − 𝛼𝜔
2 2 2 2
𝑛=1
www.iammanuprasad.com
YouTube - IMPLearn
SUMMARY
Case1 : Symmetrical impulse response and N - odd Case2 : Symmetrical impulse response and N – even
𝑁−1 𝑁
2 2
−𝑗𝜔
𝑁−1
𝑗𝜔 −𝑗𝜔
𝑁−1 1
𝐻 𝑒 𝑗𝜔
=𝑒 2 𝑎 𝑛 cos 𝜔𝑛 𝐻 𝑒 =𝑒 2 𝑏 𝑛 cos 𝜔 𝑛 −
2
𝑛=1 𝑛=1
Where Where
𝑁
𝑁−1 𝑁−1 𝑏 𝑛 = 2ℎ −𝑛
𝑎 0 =ℎ 𝑎 𝑛 = 2ℎ −𝑛 2
2 2
Case 3 : Ant symmetrical impulse response and N - odd Case 4 : Ant symmetrical impulse response and N - even
𝑁−1 𝑁
𝑁−1 2 2
𝑗𝜋 𝑁−1 𝑗𝜋 1
𝑗𝜔 −𝑗𝜔 𝑗𝜔 −𝑗𝜔
𝐻 𝑒 =𝑒 2 𝑒2 𝑐 𝑛 sin 𝜔 𝑛 𝐻 𝑒 =𝑒 2 𝑒2 𝑑 𝑛 sin 𝜔 𝑛 −
2
𝑛=1 𝑛=1
Where Where
𝑁−1 𝑁
𝑐 𝑛 = 2ℎ −𝑛 𝑑 𝑛 = 2ℎ −𝑛
2 2
www.iammanuprasad.com
YouTube - IMPLearn
Design of linear phase FIR filter
A notch / band
A to D
Sensor stop filter (50-
converter
Hz)
www.iammanuprasad.com
YouTube - IMPLearn
1. Determining specification : we need to know how strong the noise component is relative to the
desired signal and how much we need to suppress the noise. This information is necessary to find
the filter with minimum order for this application.
2. Finding a transfer function : we need to find a transfer function H(z) which will provide the
required filtering.
3. Choosing a realization structure : there are many systems which can give the obtained transfer
function and we must choose the appropriate one.
4. Implementing the filter : You have a couple of options for this step: a software implementation
(such as a MATLAB or C code) or a hardware implementation (such as a DSP, a microcontroller,
or an ASIC).
www.iammanuprasad.com
YouTube - IMPLearn
Design of linear phase FIR filter : window method
1 , 𝜔 < 𝜔𝑐
𝐻𝑑 𝜔 = ቊ
0 , 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
𝜋
1
ℎ𝑑 𝑛 = න 𝐻𝑑 𝜔 𝑒 𝑗𝜔𝑛 𝑑𝜔
2𝜋
−𝜋
𝜔𝑐
1
= න 𝑒 𝑗𝜔𝑛 𝑑𝜔
2𝜋
−𝜔𝑐
There for considering an applied shift to hd(n) and then multiplying with
window function W(n)
𝑁−1
ℎ 𝑛 = ℎ𝑑 𝑛 − ∗ 𝑊(𝑛)
2
www.iammanuprasad.com
YouTube - IMPLearn
Design of linear phase FIR filter : window method
www.iammanuprasad.com
YouTube - IMPLearn
Design of linear phase FIR filter : window methods
or or or
2𝜋𝑛 2𝜋𝑛
1 0≤𝑛≤𝑁 0.5 − 0.5 cos , 0≤𝑛≤𝑁 0.54 − 0.46 cos , 0≤𝑛≤𝑁
𝑊𝑅 𝑛 = ቊ 𝑊𝑅 𝑛 = ൞ 𝑁 𝑊𝑅 𝑛 = ൞ 𝑁
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
0 , 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒 0 , 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
www.iammanuprasad.com
YouTube - IMPLearn
Design of linear phase FIR filter : window method
Design procedure
www.iammanuprasad.com
YouTube - IMPLearn 𝜋 𝜋 𝐻𝑑 𝑒 𝑗𝜔
1 𝑓𝑜𝑟 − ≤𝜔≤
Q) Design an ideal lowpass filter with frequency response 𝐻𝑑 𝑒 𝑗𝜔 =ቐ 2 2
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒 1
find the value of h(n) for N=11 find H(z).
Solution 𝜋 𝜋
−
We can determine the desired impulse response ℎ𝑑 𝑛 by taking inverse 2 2
Fourier Transform From the figure we know 𝛼 = 0
𝜋 Since for n=0 the equation becomes infinity so lets
2
1 apply limit
ℎ𝑑 𝑛 = න 1. 𝑒 𝑗𝜔𝑛 𝑑𝜔
2𝜋 for n=0 𝑒 𝑗𝜃 − 𝑒 −𝑗𝜃
−
𝜋 sin 𝜃 =
2 𝜋𝑛 𝜋𝑛 2𝑗
sin sin 1
1 𝑗𝑛𝜋 −𝑗𝑛𝜋
ℎ 0 = lim 2 = lim 𝑛𝜋 2
= 𝑒 2 −𝑒 2 =
𝑛→0 𝑛𝜋 𝑛→0 2 2
2𝜋𝑗𝑛 2 sin 𝑛
lim =1
for n=1 𝜋 𝑛→0 𝑛
1 𝜋𝑛 𝜋𝑛 sin 1
= 2𝑗 sin sin ℎ 1 = 2 = = 0.318 = ℎ −1
= 2 𝜋
2𝜋𝑗𝑛 2 𝜋
𝑛𝜋
for n=2
sin 𝜋
ℎ 2 = =0 = ℎ −2
Truncating ℎ𝑑 𝑛 to 11 samples 2𝜋
for n=3 3𝜋 −1
sin = −0.106 = ℎ −3
ℎ 3 = 2 =
𝜋𝑛 3𝜋 3𝜋
sin 2
𝑓𝑜𝑟 = −5 ≤ 𝑛 ≤ 5
for n=4 4𝜋
ℎ𝑑 𝑛 = 𝑛𝜋 sin
ℎ 4 = 2 =0 = ℎ −4
4𝜋
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
for n=5 5𝜋 1
sin = 0.0636 = ℎ −5
ℎ 5 = 2 = www.iammanuprasad.com
5𝜋 5𝜋
YouTube - IMPLearn
Now lets find the transfer function of the filter by taking Z Transform
𝑁−1
2 5
𝐻 𝑍 = ℎ 𝑛 𝑍 −𝑛 = ℎ 𝑛 𝑍 −𝑛
𝑁−1 𝑛=−5
𝑛=−
2
= ℎ −5 𝑍 5 + ℎ −4 𝑍 4 + ℎ −3 𝑍 3 + ℎ −2 𝑍 2 + ℎ −1 𝑍1 + ℎ 0 + ℎ 1 𝑍 −1 + ℎ 2 𝑍 −2 + ℎ 3 𝑍 −3 + ℎ 4 𝑍 −4 + ℎ 5 𝑍 −5
5
= ℎ 0 + ℎ 𝑛 𝑍 𝑛 + 𝑍 −𝑛
𝑛=1
ℎ 4 = ℎ 6 = 0.318
−2 −4 −5 −6 −8 −10
𝐻′ 𝑍 = 0.0636 − 0.106𝑍 + 0.318𝑍 + 0.5𝑍 + 0.318𝑍 − 0.106𝑍 + 0.0636𝑍
ℎ 5 =0
www.iammanuprasad.com
YouTube - IMPLearn
Design of linear phase FIR filter : window method
Design Steps
ℎ 𝑛 = ℎ𝑑 𝑛 ∗ 𝑊 𝑛
Q) Design a linear phase FIR low pass filter using rectangular window by taking 7 samples of 1
window sequence and with a cut off frequency 𝜔𝑐 = 0.2𝜋 𝑟𝑎𝑑/𝑠𝑒𝑐
or
Q) Design a linear phase FIR filter low pass filter with frequency response −0.2𝜋 0.2𝜋
1 𝑓𝑜𝑟 − 𝜔𝑐 ≤ 𝜔 ≤ 𝜔
𝐻𝑑 𝑒 𝑗𝜔 = ቊ where 𝜔𝑐 = 0.2𝜋 and N=7
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
Solution Since for n=0 the equation becomes infinity so lets
apply limit
We can determine the desired impulse response
ℎ𝑑 𝑛 by taking inverse Fourier Transform for n=0 𝑒 𝑗𝜃 − 𝑒 −𝑗𝜃
sin 𝜃 =
0.2𝜋 sin 0.2𝜋𝑛 sin 0.2𝜋𝑛 2𝑗
1 ℎ 0 = lim = lim = 0.2
𝑗𝜔𝑛
𝑑
𝑛→0 𝑛𝜋 𝑛→0 𝑛𝜋 0.2
ℎ𝑑 𝑛 = න 1. 𝑒 𝑑𝜔 0.2
2𝜋 sin 𝑛
−0.2𝜋 lim =1
𝑛→0 𝑛
1 for n=1
= 𝑒 𝑗0.2𝜋𝑛 − 𝑒 −𝑗0.2𝜋𝑛 sin 0.2𝜋
2𝜋𝑗𝑛 ℎ𝑑 1 = = 0.187 = ℎ𝑑 −1
𝜋
1 sin 0.2𝜋𝑛
= 2𝑗 sin 0.2𝜋𝑛 =
2𝜋𝑗𝑛 𝑛𝜋 for n=2
sin 0.2𝜋2
Truncating ℎ𝑑 𝑛 to 7 samples ℎ𝑑 2 = = 0.151 = ℎ𝑑 −2
2𝜋
sin 0.2𝜋𝑛
𝑛𝜋 𝑓𝑜𝑟 = −3 ≤ 𝑛 ≤ 3 for n=3
ℎ𝑑 𝑛 =
sin 0.2𝜋3
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒 ℎ𝑑 3 = = 0.1009 = ℎ𝑑 −3
3𝜋
www.iammanuprasad.com
YouTube - IMPLearn FIR FILTER DESIGN USING RECTANGULAR WINDOW
Now using rectangular window sequence W(n) and multiply ℎ𝑑 𝑛 with it to get the impulse Rectangular window
response h(n)
− 𝑁−1 𝑁−1
1 0≤𝑛≤3 Since 𝛼 = 0 we get a non causal filter coefficient symmetrical about n=0 𝑊𝑅 𝑛 = ቐ1 2
≤𝑛≤
2
𝑊𝑅 𝑛 = ቊ so h(n) = h(-n)
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒 0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
3
for n=0 ℎ 0 = ℎ𝑑 0 . 𝑊𝑅 (0) = 0.2
𝐻 𝑍 = ℎ 0 + ℎ 𝑛 𝑍 𝑛 + 𝑍 −𝑛
𝑛=1
for n=1 ℎ 1 = ℎ𝑑 1 . 𝑊𝑅 (1) = 0.187 = ℎ −1
= 0.2 + 0.187 𝑍1 + 𝑍 −1 + 0.151 𝑍 2 + 𝑍 −2 + 0.1009 𝑍 3 + 𝑍 −3
for n=2 ℎ 2 = ℎ𝑑 2 . 𝑊𝑅 (2) = 0.1514 = ℎ −2
The transfer function of the realizable filter is
𝑁−1
for n=3 ℎ 3 = ℎ𝑑 3 . 𝑊𝑅 (3) = 0.1009 = ℎ −3 𝐻′ 𝑍 = 𝑍
−
2 𝐻 𝑍
𝐻 𝑍 = ℎ 𝑛 𝑍 −𝑛 = ℎ 𝑛 𝑍 −𝑛 ℎ 1 = ℎ 5 = 0.151
ℎ 0 = ℎ 6 = 0.1009
𝑁−1 𝑛=−3
𝑛=−
2
ℎ 2 = ℎ 4 = 0.187 ℎ 3 = 0.2
= ℎ −3 𝑍 3 + ℎ −2 𝑍 2 + ℎ −1 𝑍1 + ℎ 0 + ℎ 1 𝑍 −1
+ ℎ 2 𝑍 −2 + ℎ 3 𝑍 −3 www.iammanuprasad.com
YouTube - IMPLearn FIR FILTER DESIGN USING RECTANGULAR WINDOW
𝐻𝑑 𝑒 𝑗𝜔
Q) Design a linear phase FIR high pass filter with frequency response
1 1
𝜋
1 𝑓𝑜𝑟 ≤ |𝜔| ≤ 𝜋
4
𝐻𝑑 𝑒 𝑗𝜔 = ቐ 𝜋 Find the value of h(n) for N=11 and find H(z). Use rectangular window
0 𝑓𝑜𝑟 𝜔 <
4 𝜋
−𝜋 𝜋 0 𝜋
Truncating ℎ𝑑 𝑛 to 11 samples −
4
4
Solution
Since for n=0 the equation becomes infinity so lets apply
limit From the figure we know 𝛼 = 0
We can determine the desired impulse response
also symmetric
ℎ𝑑 𝑛 by taking inverse Fourier Transform
for n=0
𝜋 𝜋𝑛 𝑒 𝑗𝜃 − 𝑒 −𝑗𝜃
1 sin 𝜋𝑛 sin 1 3 sin 𝜃 =
ℎ𝑑 𝑛 = න 𝐻𝑑 𝑒 𝑗𝜔 . 𝑒 𝑗𝜔𝑛 𝑑𝜔 ℎ𝑑 0 = lim − lim 𝑛𝜋 4 =1− = 2𝑗
2𝜋 𝑛→0 𝑛𝜋 𝑛→0 4 4 4
−𝜋 4
for n=1
−
𝜋 𝜋 sin 𝑛
4 𝜋 sin 𝜋 − sin lim =1
1 ℎ𝑑 1 = 4 = −0.225 = ℎ𝑑 −1 𝑛→0 𝑛
= න 1. 𝑒 𝑗𝜔𝑛 𝑑𝜔 + න 1. 𝑒 𝑗𝜔𝑛 𝑑𝜔 𝜋
2𝜋
−𝜋 𝜋 for n=2
𝜋 4 2𝜋
𝑗𝜔𝑛 − 4 𝑗𝜔𝑛 𝜋 sin 2𝜋 − sin
1 𝑒 1 𝑒 ℎ𝑑 2 = 4 = −0.1591 = ℎ𝑑 −2
= + 2𝜋
2𝜋 𝑗𝑛 −𝜋
2𝜋 𝑗𝑛 𝜋
4 for n=3
3𝜋
−1 𝑗𝑛𝜋 −𝑗𝑛𝜋 sin 3𝜋 − sin
= 𝑒 4 − 𝑒 4 − 𝑒 𝑗𝜋𝑛 − 𝑒 −𝑗𝜋𝑛 ℎ𝑑 3 = 4 = −0.075 = ℎ𝑑 −3
2𝜋𝑗𝑛 3𝜋
for n=4
−1 𝑛𝜋 4𝜋
= 2𝑗 sin − 2𝑗 sin 𝑛𝜋 sin 4𝜋 − sin
2𝜋𝑗𝑛 4 ℎ𝑑 4 = 4 =0 = ℎ𝑑 −4
4𝜋
𝑛𝜋 for n=5
sin 𝑛𝜋 − sin 5𝜋
4 sin 5𝜋 − sin
ℎ𝑑 𝑛 = 4 = 0.045 = ℎ𝑑 −5
𝜋𝑛 ℎ𝑑 5 = www.iammanuprasad.com
5𝜋
YouTube - IMPLearn FIR FILTER DESIGN USING RECTANGULAR WINDOW
Now using rectangular window sequence WR(n) and multiply ℎ𝑑 𝑛 with it to get the impulse
response h(n) Rectangular window
𝑊𝑅 𝑛 = ቊ
1 0≤𝑛≤5 Since 𝛼 = 0 we get a non causal filter coefficient symmetrical about n=0
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒 − 𝑁−1 𝑁−1
so h(n) = h(-n) 𝑊𝑅 𝑛 = ቐ1 ≤𝑛≤
2 2
3 0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
for n=0 ℎ 0 = ℎ𝑑 0 . 𝑊𝑅 (0) = 0.75
𝐻 𝑍 = ℎ 0 + ℎ 𝑛 𝑍 𝑛 + 𝑍 −𝑛
for n=1 ℎ 1 = ℎ𝑑 1 . 𝑊𝑅 (1) = −0.225 = ℎ −1 𝑛=1
Q) Design a linear phase FIR filter high pass filter with frequency response
1 1
𝜋
1 𝑓𝑜𝑟 ≤ |𝜔| ≤ 𝜋
4
𝐻𝑑 𝑒 𝑗𝜔 = ቐ 𝜋 Find the value of h(n) for N=11 and find H(z). Using Hanning window
0 𝑓𝑜𝑟 𝜔 <
4 𝜋
−𝜋 𝜋 0 𝜋
−
Truncating ℎ𝑑 𝑛 to 11 samples 4 4
Solution
From the figure we know 𝛼 = 0
We can determine the desired impulse response Since for n=0 the equation becomes infinity so lets apply limit
also symmetric
ℎ𝑑 𝑛 by taking inverse Fourier Transform
for n=0
𝜋 𝜋𝑛 𝑒 𝑗𝜃 − 𝑒 −𝑗𝜃
1 sin 𝜋𝑛 sin 1 3 sin 𝜃 =
ℎ𝑑 𝑛 = න 𝐻𝑑 𝑒 𝑗𝜔 . 𝑒 𝑗𝜔𝑛 𝑑𝜔 ℎ𝑑 0 = lim − lim 𝑛𝜋 4 =1− = 2𝑗
2𝜋 𝑛→0 𝑛𝜋 𝑛→0 4 4 4
−𝜋 4
for n=1
−
𝜋 𝜋 sin 𝑛
4 𝜋 sin 𝜋 − sin lim =1
1 ℎ𝑑 1 = 4 = −0.225 = ℎ𝑑 −1 𝑛→0 𝑛
= න 1. 𝑒 𝑗𝜔𝑛 𝑑𝜔 + න 1. 𝑒 𝑗𝜔𝑛 𝑑𝜔 𝜋
2𝜋
−𝜋 𝜋 for n=2
𝜋 4 2𝜋
𝑗𝜔𝑛 − 4 𝑗𝜔𝑛 𝜋 sin 2𝜋 − sin
1 𝑒 1 𝑒 ℎ𝑑 2 = 4 = −0.1591 = ℎ𝑑 −2
= + 2𝜋
2𝜋 𝑗𝑛 −𝜋
2𝜋 𝑗𝑛 𝜋
4 for n=3
3𝜋
−1 𝑗𝑛𝜋 −𝑗𝑛𝜋 sin 3𝜋 − sin
= 𝑒 4 − 𝑒 4 − 𝑒 𝑗𝜋𝑛 − 𝑒 −𝑗𝜋𝑛 ℎ𝑑 3 = 4 = −0.075 = ℎ𝑑 −3
2𝜋𝑗𝑛 3𝜋
for n=4
−1 𝑛𝜋 4𝜋
= 2𝑗 sin − 2𝑗 sin 𝑛𝜋 sin 4𝜋 − sin
2𝜋𝑗𝑛 4 ℎ𝑑 4 = 4 =0 = ℎ𝑑 −4
4𝜋
𝑛𝜋 for n=5
sin 𝑛𝜋 − sin 5𝜋
4 sin 5𝜋 − sin
ℎ𝑑 𝑛 = 4 = 0.045 = ℎ𝑑 −5
𝜋𝑛 ℎ𝑑 5 = www.iammanuprasad.com
5𝜋
YouTube - IMPLearn
Hanning window
2𝜋
Since 𝛼 = 0 we get a non causal filter coefficient symmetrical 𝑊𝐻𝑛 2 = 0.5 + 0.5 cos = 0.655 = 𝑊𝐻𝑛 −2
about n=0 so h(n) = h(-n) 5
3𝜋
𝑊𝐻𝑛 3 = 0.5 + 0.5 cos = 0.345 = 𝑊𝐻𝑛 −3
5
2𝑛𝜋
𝑊𝐻𝑛 𝑛 =ቐ0.5 + 0.5 cos 0≤𝑛≤5
10
4𝜋
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒 𝑊𝐻𝑛 4 = 0.5 + 0.5 cos = 0.0945 = 𝑊𝐻𝑛 −4
5
5𝜋
𝑊𝐻𝑛 5 = 0.5 + 0.5 cos = 0 = 𝑊𝐻𝑛 −5
5
www.iammanuprasad.com
YouTube - IMPLearn FIR FILTER DESIGN USING HANNING WINDOW
Now using Hanning window sequence WHn(n) and multiply ℎ𝑑 𝑛 with it to get the impulse
response h(n)
5
ℎ 𝑛 = ℎ𝑑 𝑛 . 𝑊𝐻𝑛 𝑛 𝑓𝑜𝑟 − 5 ≤ 𝑛 ≤ 5
𝐻 𝑍 = ℎ 0 + ℎ 𝑛 𝑍 𝑛 + 𝑍 −𝑛
𝑛=1
for n=0 ℎ 0 = ℎ𝑑 0 . 𝑊𝐻𝑛 (0) = 0.75(1) = 0.75
for n=1 ℎ 1 = ℎ𝑑 1 . 𝑊𝐻𝑛 (1) = −0.225 0.905 = −0.204 = ℎ −1 = 0.75 − 0.204 𝑍1 + 𝑍 −1 − 0.104 𝑍 2 + 𝑍 −2 − 0.026 𝑍 3 + 𝑍 −3
𝑁−1
2 5
𝐻 𝑍 = ℎ 𝑛 𝑍 −𝑛 = ℎ 𝑛 𝑍 −𝑛 ℎ 0 = ℎ 1 = ℎ 9 = ℎ 10 = 0
𝑁−1 𝑛=−5
𝑛=−
2
ℎ 2 = ℎ 8 = −0.026 ℎ 4 = ℎ 6 = −0.204
5 4 3 2 1
= ℎ −5 𝑍 + ℎ −4 𝑍 + ℎ −3 𝑍 + ℎ −2 𝑍 + ℎ −1 𝑍
ℎ 3 = ℎ 7 = −0.104 ℎ 5 = 0.75
+ ℎ 0 + ℎ 1 𝑍 −1 + ℎ 2 𝑍 −2 + ℎ 3 𝑍 −3 + ℎ 4 𝑍 −4
www.iammanuprasad.com
+ ℎ 5 𝑍 −5
YouTube - IMPLearn FIR FILTER DESIGN USING HAMMING WINDOW
𝐻𝑑 𝑒 𝑗𝜔
Q) Design a linear phase FIR filter high pass filter with frequency response
1 1
𝜋
1 𝑓𝑜𝑟 ≤ |𝜔| ≤ 𝜋
4
𝐻𝑑 𝑒 𝑗𝜔 = ቐ 𝜋 Find the value of h(n) for N=11 and find H(z). Using Hamming window
0 𝑓𝑜𝑟 𝜔 <
4 𝜋
−𝜋 𝜋 0 𝜋
Truncating ℎ𝑑 𝑛 to 11 samples −
Solution 4 4
Since for n=0 the equation becomes infinity so lets apply limit From the figure we know 𝛼 = 0
We can determine the desired impulse response
also symmetric
ℎ𝑑 𝑛 by taking inverse Fourier Transform
for n=0
𝜋 𝜋𝑛 𝑒 𝑗𝜃 − 𝑒 −𝑗𝜃
1 sin 𝜋𝑛 sin 1 3 sin 𝜃 =
ℎ𝑑 𝑛 = න 𝐻𝑑 𝑒 𝑗𝜔 . 𝑒 𝑗𝜔𝑛 𝑑𝜔 ℎ𝑑 0 = lim − lim 𝑛𝜋 4 =1− = 2𝑗
2𝜋 𝑛→0 𝑛𝜋 𝑛→0 4 4 4
−𝜋 4
for n=1
−
𝜋 𝜋 sin 𝑛
4 𝜋 sin 𝜋 − sin lim =1
1 ℎ𝑑 1 = 4 = −0.225 = ℎ𝑑 −1 𝑛→0 𝑛
= න 1. 𝑒 𝑗𝜔𝑛 𝑑𝜔 + න 1. 𝑒 𝑗𝜔𝑛 𝑑𝜔 𝜋
2𝜋
−𝜋 𝜋 for n=2
𝜋 4 2𝜋
𝑗𝜔𝑛 − 4 𝑗𝜔𝑛 𝜋 sin 2𝜋 − sin
1 𝑒 1 𝑒 ℎ𝑑 2 = 4 = −0.1591 = ℎ𝑑 −2
= + 2𝜋
2𝜋 𝑗𝑛 −𝜋
2𝜋 𝑗𝑛 𝜋
4 for n=3
3𝜋
−1 𝑗𝑛𝜋 −𝑗𝑛𝜋 sin 3𝜋 − sin
= 𝑒 4 − 𝑒 4 − 𝑒 𝑗𝜋𝑛 − 𝑒 −𝑗𝜋𝑛 ℎ𝑑 3 = 4 = −0.075 = ℎ𝑑 −3
2𝜋𝑗𝑛 3𝜋
for n=4
−1 𝑛𝜋 4𝜋
= 2𝑗 sin − 2𝑗 sin 𝑛𝜋 sin 4𝜋 − sin
2𝜋𝑗𝑛 4 ℎ𝑑 4 = 4 =0 = ℎ𝑑 −4
4𝜋
𝑛𝜋 for n=5
sin 𝑛𝜋 − sin 5𝜋
4 sin 5𝜋 − sin
ℎ𝑑 𝑛 = 4 = 0.045 = ℎ𝑑 −5
𝜋𝑛 ℎ𝑑 5 = www.iammanuprasad.com
5𝜋
YouTube - IMPLearn FIR FILTER DESIGN USING HAMMING WINDOW
Hamming window
𝑊𝐻 0 = 0.54 + 0.46 = 1
2𝜋𝑛 − 𝑁−1 𝑁−1
0.54 − 0.46 cos , ≤𝑛≤
𝑊𝐻 𝑛 = ൞ 𝑁−1 2 2
0 , 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒 𝜋
𝑊𝐻 1 = 0.54 + 0.46 cos = 0.912 = 𝑊𝐻 −1
5
2𝜋
𝑊𝐻 2 = 0.54 + 0.46 cos = 0.682 = 𝑊𝐻 −2
5
Since 𝛼 = 0 we get anon causal filter coefficient symmetrical about
n=0 so h(n) = h(-n)
3𝜋
𝑊𝐻 3 = 0.54 + 0.46 cos = 0.398 = 𝑊𝐻 −3
5
2𝑛𝜋 4𝜋
𝑊𝐻 𝑛 = ቐ0.54 + 0.46 cos 10 0≤𝑛≤5 𝑊𝐻 4 = 0.54 + 0.46 cos
5
= 0.1678 = 𝑊𝐻 −4
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
5𝜋
𝑊𝐻 5 = 0.54 + 0.46 cos = 0.08 = 𝑊𝐻 −5
5
www.iammanuprasad.com
YouTube - IMPLearn FIR FILTER DESIGN USING HAMMING WINDOW
Now using Hamming window sequence WH(n) and multiply ℎ𝑑 𝑛 with it to get the impulse
response h(n)
ℎ 𝑛 = ℎ𝑑 𝑛 . 𝑊𝐻 𝑛 𝑓𝑜𝑟 − 5 ≤ 𝑛 ≤ 5 5
𝐻 𝑍 = ℎ 0 + ℎ 𝑛 𝑍 𝑛 + 𝑍 −𝑛
for n=0 ℎ 0 = ℎ𝑑 0 . 𝑊𝐻 (0) = 0.75(1) = 0.75 𝑛=1
for n=3 ℎ 3 = ℎ𝑑 3 . 𝑊𝐻 (3) = −0.075 0.398 = −0.03 = ℎ −3 The transfer function of the realizable filter is
Now lets find the transfer function of the filter by taking Z Transform = 0.0036 − 0.03𝑍 −2 − 0.1084𝑍 −3 − 0.2052𝑍 −4 + 0.75𝑍 −5
− 0.2052𝑍 −6 − 0.1084𝑍 −7 − 0.03𝑍 −8 + 00036𝑍 −10
𝑁−1
2 5
𝐻 𝑍 = ℎ 𝑛 𝑍 −𝑛 = ℎ 𝑛 𝑍 −𝑛
𝑁−1
ℎ 0 = ℎ 10 = 0.0036 ℎ 3 = ℎ 7 = −0.1084
𝑛=− 𝑛=−5
2
ℎ 1 =ℎ 9 =0 ℎ 4 = ℎ 6 = −0.2052
5 4 3 2 1
= ℎ −5 𝑍 + ℎ −4 𝑍 + ℎ −3 𝑍 + ℎ −2 𝑍 + ℎ −1 𝑍 ℎ 2 = ℎ 8 = −0.03 ℎ 5 = 0.75
+ ℎ 0 + ℎ 1 𝑍 −1 + ℎ 2 𝑍 −2 + ℎ 3 𝑍 −3 + ℎ 4 𝑍 −4
www.iammanuprasad.com
+ ℎ 5 𝑍 −5
YouTube - IMPLearn
Design of linear phase FIR filter by frequency sampling technique
In this method the ideal frequency response is sampled at sufficient number of points these samples are the DFT
coefficients of impulse response of filter. Hence impulse response of filter is determined by taking inverse DFT
Steps
1. Choose a desired frequency response 𝐻𝑑 𝑒 𝑗𝜔
2𝜋𝑘
2. Sample 𝐻𝑑 𝑒 𝑗𝜔 at N point by taking 𝜔 = 𝜔𝑘 = where k=0,1,2,3 … N-1
𝑁
3. Compute the N samples of impulse response h(n) using the equation
𝑁−1
2
1 𝑗2𝜋𝑛𝑘
ℎ 𝑛 = 𝐻 0 + 2 𝑅𝑒 𝐻 𝑘 𝑒 𝑁 , 𝑓𝑜𝑟 𝑁 = 𝑜𝑑𝑑
𝑁
𝑘=1
𝑁
−1
2
1 𝑗2𝜋𝑛𝑘
ℎ 𝑛 = 𝐻 0 + 2 𝑅𝑒 𝐻 𝑘 𝑒 𝑁 , 𝑓𝑜𝑟 𝑁 = 𝑒𝑣𝑒𝑛
𝑁
𝑘=1
4. Take Z-Transform of impulse response h(n) to get filter transfer function H(z)
𝑁−1
𝐻 𝑍 = ℎ 𝑛 𝑍 −𝑛
𝑛=0
www.iammanuprasad.com
YouTube - IMPLearn Design of linear phase FIR filter by frequency sampling technique 𝐻𝑑 𝑒 𝑗𝜔
Q) Design a linear phase FIR low pass filter with cut off frequency of 0.5π rad/sample by taking 11 1
samples of ideal frequency response
Solution
Step2: Sample 𝐻𝑑 𝑒 𝑗𝜔 at N point by taking
2𝜋𝑘 0.5𝜋
𝜔 = 𝜔𝑘 = −0.5𝜋
Step1 : Find the desired frequency response 𝑁
2𝜋𝑘
For digital sampling we are taking the limit as 0 to 2π Sampling frequency 𝜔𝑘 = for k= 0 to 10
11
𝐻𝑑 𝑒 𝑗𝜔 2𝜋 ∗ 0
for k=0 𝜔0 = =0
11
2𝜋 ∗ 1 2𝜋 ∗ 6
= 0.18𝜋 for k=6 𝜔0 = = 1.09𝜋
for k=1 𝜔0 = 11
11
2𝜋 ∗ 2 2𝜋 ∗ 7
= 0.36𝜋 for k=7 𝜔0 = = 1.27𝜋
0 0.5𝜋 𝜋 1.5𝜋 2𝜋 for k=2 𝜔0 = 11
11
2𝜋 ∗ 3 2𝜋 ∗ 8
𝜔0 = = 0.55𝜋 for k=8 𝜔0 = = 1.45𝜋
Due to symmetricity at (N-1)/2 then there will be an α for k=3 11
11 2𝜋 ∗ 9
exponential term in the expression 2𝜋 ∗ 4
= 0.73𝜋 for k=9 𝜔0 = = 1.64𝜋
for k=4 𝜔0 = 11
11 2𝜋 ∗ 10
2𝜋 ∗ 5 for k=10 𝜔0 = = 1.82𝜋
1. 𝑒 −𝑗𝛼𝜔 , 0 ≤ 𝜔 ≤ 0.5𝜋 for k=5 𝜔0 = = 0.91𝜋 11
𝐻𝑑 𝑒 𝑗𝜔 =൞ 0 , 0.5𝜋 ≤ 𝜔 ≤ 1.5𝜋 11
1. 𝑒 −𝑗𝛼𝜔 ,1.5𝜋 ≤ 𝜔 ≤ 2𝜋 𝐻 𝑘
2𝜋𝑘
𝑒 −𝑗5 11 , 𝑓𝑜𝑟 𝑘 = 0,1,2
𝑁 − 1 11 − 1 𝐻 𝑘 = 0 , 𝑓𝑜𝑟 𝑘 = 3 𝑡𝑜 8
𝑤ℎ𝑒𝑟𝑒, 𝛼 = = =5 2𝜋𝑘
2 2
𝑒 −𝑗5 11 , 𝑓𝑜𝑟 𝑘 = 9,10
0 1 2 3 4 5 6 7 8 9 10 𝑘 www.iammanuprasad.com
YouTube - IMPLearn Design of linear phase FIR filter by frequency sampling technique
5 2
1 −𝑗5
2𝜋𝑘 𝑗2𝜋𝑛𝑘 1 −𝑗5
2𝜋𝑘 𝑗2𝜋𝑛𝑘
= 1 + 2 𝑅𝑒 𝑒 11 𝑒 11 = 1 + 2 𝑅𝑒 𝑒 11 𝑒 11
11 11
𝑘=1 𝑘=1
2
1 𝑗
2𝜋𝑘
𝑛−5
= 1 + 2 𝑅𝑒 𝑒 11
11
𝑘=1
1 𝑗
2𝜋
𝑛−5 𝑗
4𝜋
𝑛−5
= 1 + 2𝑅𝑒 𝑒 11 + 2𝑅𝑒 𝑒 11
11
2𝜋𝑘
1 2𝜋 4𝜋 𝑒 −𝑗5
11 , 𝑓𝑜𝑟 𝑘 = 0,1,2
ℎ 𝑛 = 1 + 2 cos 𝑛−5 + 2 cos 𝑛−5 𝐻 𝑘 = 0 , 𝑓𝑜𝑟 𝑘 = 3 𝑡𝑜 8
11 11 11
2𝜋𝑘
𝑒 −𝑗5 11 , 𝑓𝑜𝑟 𝑘 = 9,10
www.iammanuprasad.com
YouTube - IMPLearn Design of linear phase FIR filter by frequency sampling technique
Now let’s calculate h(n) for n = 0 to 10, using symmetric condition ( h(n)=h(N-1-m) )
for n=0
1 2𝜋 4𝜋 for n=6
ℎ 0 = 1 + 2 cos 0−5 + 2 cos 0−5 = 0.0694
11 11 11
for n=1 ℎ 6 = ℎ 11 − 1 − 6 = ℎ 4 = 0.3194
1 2𝜋 4𝜋
ℎ 1 = 1 + 2 cos 1−5 + 2 cos 1−5 = −0.054 for n=7
11 11 11
for n=2 ℎ 7 = ℎ 11 − 1 − 7 = ℎ 3 = 0.0473
1 2𝜋 4𝜋
ℎ 2 = 1 + 2 cos 2−5 + 2 cos 2−5 = −0.1094 for n=8
11 11 11
for n=3
1 2𝜋 4𝜋 ℎ 8 = ℎ 11 − 1 − 8 = ℎ 2 = −0.1094
ℎ 3 = 1 + 2 cos 3−5 + 2 cos 3−5 = 0.0473
11 11 11 for n=9
for n=4
1 2𝜋 4𝜋 ℎ 9 = ℎ 11 − 1 − 9 = ℎ 1 = −0.054
ℎ 4 = 1 + 2 cos 4−5 + 2 cos 4−5 = 0.3194
11 11 11 for n=10
for n=5
1 2𝜋 4𝜋
ℎ 5 = 1 + 2 cos 5−5 + 2 cos −5 = 0.4595 ℎ 10 = ℎ 11 − 1 − 10 = ℎ 0 = 0.0694
11 11 11
www.iammanuprasad.com
YouTube - IMPLearn Design of linear phase FIR filter by frequency sampling technique
Step 4: Take Z-Transform of impulse response h(n) to get filter transfer function H(z)
10
𝐻 𝑍 = ℎ 𝑛 𝑍 −𝑛
𝑛=0
= ℎ 0 𝑍 0 + ℎ 1 𝑍 −1 + ℎ 2 𝑍 −2 + ℎ 3 𝑍 −3 + ℎ 4 𝑍 −4 + ℎ 5 𝑍 −5 + ℎ 6 𝑍 −6 + ℎ 7 𝑍 −7 + ℎ 8 𝑍 −8 + ℎ 9 𝑍 −9 + ℎ 10 𝑍 −10
www.iammanuprasad.com
YouTube - IMPLearn Design of linear phase FIR filter by frequency sampling technique
Q) Using frequency sampling method, design a band pass filter with the following specifications , sampling frequency
F=8000Hz ,cut off frequency fc1=1000Hz, fc2=3000Hz, Determine the filter coefficients for N=7
Solution
Step1 : Find the desired frequency response Step2: Sample 𝐻𝑑 𝑒 𝑗𝜔 at N point by taking
2𝜋𝑘
𝜔 = 𝜔𝑘 =
For digital sampling we are taking the limit as 0 to 2π 𝑁
1.25 π
1.71 π
1.75 π
0.75 π
0.28 π
0.57 π
0.85 π
1.14 π
1.4 π
𝑁−1 7−1 0
𝑤ℎ𝑒𝑟𝑒, 𝛼 =
2
=
2
=3 www.iammanuprasad.com
YouTube - IMPLearn Design of linear phase FIR filter by frequency sampling technique
3 2
1 −𝑗3
2𝜋𝑘 𝑗2𝜋𝑛𝑘 1 −𝑗3
2𝜋𝑘 𝑗2𝜋𝑛𝑘
= 0 + 2 𝑅𝑒 𝑒 7 𝑒 7 = 2 𝑅𝑒 𝑒 7 𝑒 7
7 7
𝑘=1 𝑘=1
2
2 𝑗
2𝜋𝑘
𝑛−3
= 𝑅𝑒 𝑒 7
7
𝑘=1
2 −𝑗
2𝜋
𝑛−3 −𝑗
4𝜋
𝑛−3
= 2𝑅𝑒 𝑒 7 + 2𝑅𝑒 𝑒 7
7
0 , 𝑓𝑜𝑟 𝑘 = 0
2𝜋𝑘
𝑒 −𝑗3
7 , 𝑓𝑜𝑟 𝑘 = 1,2
2 2𝜋 4𝜋 𝐻 𝑘 =
ℎ 𝑛 = 2 cos 𝑛−3 + 2 cos 𝑛−3 0 , 𝑓𝑜𝑟 𝑘 = 3 , 4
7 7 7 2𝜋𝑘
−𝑗3
𝑒 7 , 𝑓𝑜𝑟 𝑘 = 5,6
www.iammanuprasad.com
YouTube - IMPLearn Design of linear phase FIR filter by frequency sampling technique
for n=0
2 2𝜋 4𝜋 for n=4
ℎ 0 = 2 cos 0−3 + 2 cos 0−3 = −0.0792
7 7 7
ℎ 4 =ℎ 7−1−4 =ℎ 2 = 0.1145
for n=1
2 2𝜋 4𝜋
ℎ 1 = 2 cos 1−3 + 2 cos 1−3 = −0.321 for n=5
7 7 7
ℎ 5 =ℎ 7−1−5 =ℎ 1 = −0.321
for n=2
2 2𝜋 4𝜋
ℎ 2 = 2 cos 2−3 + 2 cos 2−3 = 0.1145 for n=6
7 7 7
ℎ 6 =ℎ 7−1−6 =ℎ 0 = −0.0792
for n=3
2 2𝜋 4𝜋
ℎ 3 = 2 cos 3−3 + 2 cos 3−3 = 0.571
7 7 7
www.iammanuprasad.com
YouTube - IMPLearn Design of linear phase FIR filter by frequency sampling technique
Step 4: Take Z-Transform of impulse response h(n) to get filter transfer function H(z)
6
𝐻 𝑍 = ℎ 𝑛 𝑍 −𝑛
𝑛=0
= ℎ 0 𝑍 0 + ℎ 1 𝑍 −1 + ℎ 2 𝑍 −2 + ℎ 3 𝑍 −3 + ℎ 4 𝑍 −4 + ℎ 5 𝑍 −5 + ℎ 6 𝑍 −6
ℎ 6 =ℎ 7−1−6 =ℎ 0 = −0.0792
ℎ 5 =ℎ 7−1−5 =ℎ 1 = −0.321
ℎ 4 =ℎ 7−1−4 =ℎ 2 = 0.1145
ℎ 3 = 0.571
www.iammanuprasad.com
YouTube - IMPLearn
Infinite Impulse Response (IIR) Filters
• The FIR filters are non recursive type filters(present input depends on the present and previous inputs)
where as IIR filters are recursive type (present input depends on the present, past and output samples)
• IIR (infinite impulse response) filters are generally chosen for applications where linear phase is not
too important and memory is limited.
• They have been widely deployed in audio equalization, biomedical sensor signal processing, IoT/IIoT
smart sensors and high-speed telecommunication/RF applications
• IIR filter have infinite-duration impulse responses, hence they can be matched to analog filters, all of
which generally have infinitely long impulse responses.
• The basic techniques of IIR filter design transform well-known analog filters into digital filters using
complex-valued mappings.
• First we design an antilog prototype filter and then transform the prototype to a digital filter, hence it is
also called indirect method
www.iammanuprasad.com
YouTube - IMPLearn
Infinite Impulse Response (IIR) Filters
• An IIR filter is categorized by its theoretically infinite impulse response, Practically speaking, it is not possible to
compute the output of an IIR using this equation. Therefore, the equation may be re-written in terms of a finite
number of poles p and zeros q, as defined by the linear constant coefficient difference equation
𝑞 𝑝
𝑦 𝑛 = 𝑏𝑘 𝑥 𝑛 − 𝑘 − 𝑎𝑘 𝑦 𝑛 − 𝑘
𝑘=0 𝑙=1
• where, a(k) and b(k) are the filter’s denominator and numerator polynomial coefficients, who’s roots are equal to
the filter’s poles and zeros respectively. Thus, a relationship between the difference equation and the z-transform
(transfer function) may therefore be defined by using the z-transform delay property such that,
∞
−𝑛
σ𝑞𝑘=0 𝑏𝑘 𝑍 −𝑘
𝐻 𝑧 = 𝑦 𝑛 𝑍 = 𝑝
1 + σ𝑘=1 𝑎𝑘 𝑍 −𝑘
𝑛=0
1. Map the desired digital filter specifications into those for an equivalent analog
filter
2. Derive the analog transfer function for the analog prototype
3. Transform the transfer function of the analog prototype into an equivalent digital
filter transfer function
www.iammanuprasad.com
YouTube - IMPLearn
Analog lowpass filter design
Mainly there are two types of analog filter designs
1. Butterworth Filter
2. Chebyshev filter
1
𝐻 𝑗Ω = 1
2𝑁 2 Where N is the order of the
Ω filter
1+
Ω𝑐
www.iammanuprasad.com
YouTube - IMPLearn
Order of the Butterworth filter
1
𝐻 𝑗Ω = 1
2𝑁 2
Ω
1 + ε2 Ω
𝑝
2
1
𝐻 𝑗Ω = 2𝑁 Ω𝑝 → Passband frequency (rad/sec)
Ω
1 + ε2 Ω𝑠 → Stopband frequency (rad/sec)
Ω𝑝
ε → Passband parameter
Taking log on both sides
λ → Stopband parameter
𝛼𝑝 → Passband attenuation
20 log 𝐻 𝑗Ω = 10 log 1 − 10 log 1 + ε2
𝛼𝑠 → Stopband attenuation
www.iammanuprasad.com
YouTube - IMPLearn
Order of the Butterworth filter
2 2𝑁
𝛼𝑝 = 10 log 1 + ε Ω𝑠 Taking log on both sides and
𝛼𝑠 = 10 log 1 + ε2
Ω𝑝 finding the value of N
0.1𝛼𝑝 = log 1 + ε2
www.iammanuprasad.com
YouTube - IMPLearn
Design an analog Butterworth filter
Q) For given specifications design an analog Butterworth filter
Solution
1
Ω𝑝 = 0.2𝜋 = 0.9 ε = 0.484
1+ ε2
1
Ω𝑠 = 0.4𝜋 = 0.2
1+ λ2 λ = 4.898
Step 1: Find the order of the filter N & round off to higher
integer
λ 4.898
log log
ε 0.484
𝑁≥ ≥ = 3.34 𝑁≈4
Ω 0.4𝜋
log 𝑠 log
Ω𝑝 0.2𝜋
www.iammanuprasad.com
YouTube - IMPLearn
Design an analog Butterworth filter
Step 2: Find the transfer function H(s) for Ωc=1 rad/sec for the values of N
1
𝐻 𝑆𝑛 =
𝑠 2 + 0.765𝑠 + 1 𝑠 2 + 1.848𝑠 + 1
Ω𝑝 0.2𝜋
Ω𝑐 = 1
= 1 = 0.24𝜋
100.1𝛼𝑝 − 1 2𝑁 ε4
1
ε = 100.1𝛼𝑝 − 1 2
www.iammanuprasad.com
YouTube - IMPLearn
Design an analog Butterworth filter
𝑠
Step 4: Find transfer function H(s) for the value of Ωc calculated by substituting 𝑠 = Ω in H(s)
c
1
𝐻 𝑆𝑛 =
𝑠 2 + 0.765𝑠 + 1 𝑠 2 + 1.848𝑠 + 1
1
𝐻 𝑠 =
𝑠 2 𝑠 𝑠 2 𝑠
+ 0.765 +1 + 1.848 +1
0.24𝜋 0.24𝜋 0.24𝜋 0.24𝜋
0.323
𝐻 𝑠 = 2
𝑠 + 0.577𝑠 + 0.057𝜋 2 𝑠 2 + 1.39𝑠 + 0.0576𝜋 2
www.iammanuprasad.com
YouTube - IMPLearn
Design an analog Butterworth filter
Q) Design an analog Butterworth filter that has a -2dB passband
attenuation at a frequency of 20 rad/sec and at least -10dB stopband
attenuation at 30 rad/sec
Solution
𝛼𝑝 = 2𝑑𝐵
Ω𝑝 = 20 𝑟𝑎𝑑/𝑠𝑒𝑐
Ω𝑠 = 30 𝑟𝑎𝑑/𝑠𝑒𝑐 𝛼𝑠 = 10𝑑𝐵
Step 1: Find the order of the filter N & round off to higher
integer
100.1𝛼𝑠 − 1 100.1∗10 − 1
log 0.1𝛼𝑝 log
10 −1 100.1∗2 − 1
𝑁≥ ≥ = 3.37 𝑁≈4
Ω 30
log 𝑠 log
20
Ω𝑝
www.iammanuprasad.com
YouTube - IMPLearn
Design an analog Butterworth filter
Step 2: Find the transfer function H(s) for Ωc=1 rad/sec for the values of N
1
𝐻 𝑆𝑛 =
𝑠 2 + 0.765𝑠 + 1 𝑠 2 + 1.848𝑠 + 1
Ω𝑝 20
Ω𝑐 = 1 = 1 = 21.386
100.1𝛼𝑝 − 1 2𝑁 100.1∗2 − 1 2∗4
www.iammanuprasad.com
YouTube - IMPLearn
Design an analog Butterworth filter
𝑠
Step 4: Find transfer function Ha(s) for the value of Ωc calculated by substituting 𝑠 = Ω in H(s)
c
1
𝐻 𝑆𝑛 =
𝑠 2 𝑠 𝑠 2 𝑠
+ 0.765 +1 + 1.848 +1
21.386 21.386 21.386 21.386
0.20921 × 106
𝐻 𝑆𝑛 = 2
𝑠 + 16.368𝑠 + 457.39 𝑠 2 + 39.51𝑠 + 457.394
www.iammanuprasad.com
YouTube - IMPLearn
Design digital filter from analog filter
Impulse invariant
Bilinear transformation
method
www.iammanuprasad.com
YouTube - IMPLearn
Design of IIR filter using Impulse invariant method
• Here we require that the impulse response of the discrete system (digital filter) be the
discrete version of the impulse response of the analogue system (filter)
• Hence the name impulse invariant
• In impulse invariant method the IIR filter is designed such that the unit impulse
response h(n) of digital filter is the sampled version of impulse response of analog filter
Z transform 𝑆 = 𝜎 + 𝑗Ω 𝑍 = 𝑟𝑒 𝑗𝜔
𝑁
𝑟𝑒 𝑗𝜔 = 𝑒 𝜎+𝑗Ω 𝑇
𝐻 𝑍 = ℎ 𝑛 𝑍 −𝑛
𝑛=0 Equating real and imaginary parts
For impulse invariant method we do the mapping as
𝑟 = 𝑒 𝜎𝑇 𝜔 = ΩT
𝑁
Case 1 :
𝜎=0
𝑅𝑒 𝑧 𝜎
𝑟 = 𝑒 0𝑇 = 1
Z - Plane S-Plane
Impulse invariant mapping map poles from s-plane’s
𝑗Ω axis to Z-plane’s unit circle
www.iammanuprasad.com
YouTube - IMPLearn
𝐼𝑚 𝑧 𝑗Ω
Case 2 :
𝑟 = 𝑒 𝜎𝑇 < 1
Z - Plane S-Plane
All S-plane poles with –ve real parts map to Z–plane
poles inside unit circle
www.iammanuprasad.com
YouTube - IMPLearn
𝐼𝑚 𝑧 𝑗Ω
Case 3 :
𝑟 = 𝑒 𝜎𝑇 > 1
Z - Plane S-Plane
Poles in right half of S-plane map to digital poles
outside unit circle
www.iammanuprasad.com
YouTube - IMPLearn
𝐻 𝑧 = ℎ 𝑛 𝑧 −𝑛
www.iammanuprasad.com
𝑛=0
YouTube - IMPLearn
1. For the given specification find Ha(s), the transfer function of analog filter
2. Select the sampling rate of the digital filter, T seconds/sample
3. Express the analog filter transfer function as the sum of single pole filters
𝑁
𝐶𝑘
𝐻𝑎 𝑠 =
𝑆 − 𝑃𝑘
𝑘=1
Solution
2 2
𝐻 𝑠 = −
2 𝑠+1 (𝑠 + 2)
𝐻 𝑠 =
𝑠 + 1 (𝑠 + 2)
2 2
𝐻 𝑠 = −
Using partial fraction method 𝑠 − −1 (𝑠 − −2 )
www.iammanuprasad.com
YouTube - IMPLearn
Design of IIR filter by impulse invariant technique
10
Q) An anlog filter has a transfer function 𝐻 𝑠 = 2 Design a digital filter equivalent to this using impulse
𝑠 +7𝑠+10
invariant method for T=0.2 sec
Solution
10 −3.33 3.33
𝐻 𝑠 = 2 𝐻 𝑠 = +
𝑠 + 7𝑠 + 10 𝑠 − −5 (𝑠 − −2 )
www.iammanuprasad.com
YouTube - IMPLearn
Design of IIR filter by impulse invariant technique
2
Q) Apply bilinear transformation to 𝐻 𝑠 =
𝑠+1 + 𝑠+2
Solution
2 1 + 𝑧 −1 2
𝐻 𝑠 = =
𝑠+1 + 𝑠+2 3 − 𝑧 −1 2
2 1−𝑧 −1
Substitute 𝑠 = at T=1sec 1 + 𝑧 −1
𝑇 1+𝑧 −1
𝐻 𝑧 =
1 − 0.33𝑧 −1
2
𝐻 𝑧 =
1 − 𝑧 −1 1 − 𝑧 −1
2 +1 + 2 +2
1 + 𝑧 −1 1 + 𝑧 −1
2
=
1 − 𝑧 −1 + 1 + 𝑧 −1 1 − 𝑧 −1
2 + 2 +2
1 + 𝑧 −1 1 + 𝑧 −1
2 1 + 𝑧 −1 2
=
2 − 2𝑧 −1 + 1 + 𝑧 −1 + 2 − 2𝑧 −1 + 2 + 2𝑧 −1
www.iammanuprasad.com
YouTube - IMPLearn
Design an analog Butterworth filter
Q) Design a digital analog Butterworth filter satisfying the constraints
𝜋
0.707 ≤ 𝐻 𝑗𝜔 ≤ 1 𝑓𝑜𝑟 0 ≤ 𝜔 ≤
2
3𝜋
𝐻 𝑗𝜔 ≤ 0.2 𝑓𝑜𝑟 ≤𝜔≤𝜋
4
using bilinear transformation. Take T=1sec
Solution
1 𝜋
= 0.707 ε=1 𝜔𝑝 =
1 + ε2 2
1 3𝜋
= 0.2 λ = 4.89 𝜔𝑠 =
4
1 + λ2
Step 2: Using the analog frequency find H(s) of the analog filter
λ 4.89
log ε log
𝑁≥ ≥ 1 ≥ 1.80
Ω log 2.414
log Ω 𝑠
𝑝
𝑁=2
1
𝐻𝑎 𝑠 =
𝑠 2 + √2𝑠 + 1
𝜋
Ω𝑝 2 tan
Ω𝑐 = = 4 = 2 𝑟𝑎𝑑/𝑠𝑒𝑐
1 1
ε𝑁 12
𝑠
To find H(s) substitute 𝑠 = Ω
𝑐 1 4
𝐻 𝑠 = 𝐻 𝑠 = 2
𝑠2 𝑠 𝑠 + 2.828𝑠 + 4
+ √2 + 1
4 2
www.iammanuprasad.com
YouTube - IMPLearn
Design an analog Butterworth filter
2 1−𝑧 −1
Step 4: Substitute 𝑠 = 𝑇 1+𝑧 −1 into the transfer function
1
𝐻 𝑠 = 2
𝑠 + 2.828𝑠 + 4
1
= 2
1 − 𝑧 −1 1 − 𝑧 −1
2 + 2.828 2 +4
1 + 𝑧 −1 1 + 𝑧 −1
4 1 + 𝑧 −1
𝐻 𝑠 =
4 1 − 𝑧 −1 + 5.656 1 − 𝑧 −2 + 4 1 + 𝑧 −1
www.iammanuprasad.com
YouTube - IMPLearn
Realisation of discrete time system
• A digital filter transfer function can be realized in a variety ways
• Realization of FIR filters
• Realization of IIR filters
• Basic elements required for implementation of an LTI digital system are adder , multiplier and
memory for storing elements
• In digital implementation the delay operation can be implemented by providing a storage register by
each unit delay is required
𝒙𝟏 𝒏 𝒂
𝒙𝟏 𝒏 + 𝒙𝟐 𝒏 𝒙 𝒏 𝒂𝒙 𝒏 Z-1
𝒙 𝒏 𝒙 𝒏−𝟏
𝒙𝟐 𝒏
www.iammanuprasad.com
YouTube - IMPLearn
www.iammanuprasad.com
YouTube - IMPLearn
Direct form realization
The direct form of FIR may be obtained by using the equation of linear convolution
𝑁−1
𝑦 𝑘 = ℎ 𝑘 𝑥 𝑛−𝑘 = ℎ 0 𝑥 𝑛 + ℎ 1 𝑥 𝑛 − 1 + ⋯+ ℎ 𝑁 − 1 𝑥 𝑛 − 𝑁 − 1
𝑘=0
Taking Z-transform
𝑌 𝑧 = ℎ 0 𝑋 𝑧 + ℎ 1 𝑋 𝑧 𝑧 −1 + ⋯ + ℎ 𝑁 − 1 𝑋 𝑧 𝑧 − 𝑁−1
𝑿 𝒛
Z-1 Z-1 Z-1 Z-1
𝒉 𝟎 𝒉 𝟏 𝒉 𝟐 𝒉 𝑵−𝟐 𝒉 𝑵−𝟏
𝒀 𝒛
www.iammanuprasad.com
YouTube - IMPLearn
Q) Determine the direct form realization of system function
𝐻 𝑧 = 1 + 2𝑧 −1 − 3𝑧 −2 − 4𝑧 −3 + 5𝑧 −4
𝑌 𝑧
𝐻 𝑧 =
𝑋 𝑧
𝐻 𝑧 = 1 + 2𝑧 −1 − 3𝑧 −2 − 4𝑧 −3 + 5𝑧 −4
𝑌 𝑧 = 𝑋 𝑧 1 + 2𝑧 −1 − 3𝑧 −2 − 4𝑧 −3 + 5𝑧 −4
𝑿 𝒛
Z-1 Z-1 Z-1 Z-1
𝟏 𝟐 −𝟑 −𝟒 𝟓
𝒀 𝒛
www.iammanuprasad.com
YouTube - IMPLearn
Cascade form realization
Q) Obtain cascade form realization of system function 𝐻 𝑧 = 1 + 2𝑧 −1 − 𝑧 −2 1 + 𝑧 −1 − 𝑧 −2
𝐻 𝑧 = 𝐻1 𝑧 𝐻2 𝑧
𝑌1 𝑧 𝑿𝟏 𝒛 𝒀𝟏 𝒛 𝑿𝟐 𝒛 𝒀 𝒛
𝐻1 𝑧 =
𝑋1 𝑧
𝑌2 𝑧
𝐻2 𝑧 =
𝑋2 𝑧 Z-1 Z-1
𝟐 𝟏
𝑌1 𝑧 = 𝑋1 𝑧 1 + 2𝑧 −1 − 𝑧 −2
Z-1 Z-1
𝑌1 𝑧 = 𝑋1 𝑧 + 2𝑋 𝑧 𝑧 −1 −𝑋 𝑧 𝑧 −2
−𝟏 −𝟏
𝑌2 𝑧 = 𝑋2 𝑧 1 + 𝑧 −1 − 𝑧 −2
𝑌2 𝑧 = 𝑋2 𝑧 + 𝑋2 𝑧 𝑧 −1 − 𝑋2 𝑧 𝑧 −2
www.iammanuprasad.com
YouTube - IMPLearn
Cascade form realization
5
Q) Obtain cascade form realization of system function 𝐻 𝑧 = 1 + 𝑧 −1 + 2𝑧 −2 + 2𝑧 −3
2
5 −1
𝐻 𝑧 = 1 + 𝑧 + 2𝑧 −2 + 2𝑧 −3
2 𝑿 𝒛 𝒀 𝒛
𝑧3 5 −1
= 3 1 + 𝑧 + 2𝑧 −2 + 2𝑧 −3
𝑧 2
1 3 5 2 Z-1
= 3 𝑧 + 𝑧 + 2𝑧1 + 2 Z-1 𝟏
𝑧 2
𝟐
The term inside the bracket equal to zero when z=-2 𝟐
1 1 −1
= 3 𝑧 1 + 2𝑧 𝑧 1 + 𝑧 + 𝑧 −2
−1 2
𝑧 2
www.iammanuprasad.com
YouTube - IMPLearn
Linear phase realization
1 1 1 1 1
Q) Realise the system function 𝐻 𝑧 = + 𝑧 −1 + 𝑧 −2 + 𝑧 −3 + 𝑧 −4 + 𝑧 −5 + 𝑧 −6
2 3 4 3 2
ℎ 0 ℎ 1 𝒉 𝟐 𝒉 𝟑 𝒉 𝟒 𝒉 𝟓 𝒉 𝟔
ℎ 0 = ℎ 6−1−0 =ℎ 5 =1
𝑿 𝒛
1 Z-1 Z-1
ℎ 1 = ℎ 6−1−1 =ℎ 4 =
3
1
ℎ 2 = ℎ 6−1−2 =ℎ 3 =
4 Z-1
𝟏 𝟏
𝟑 𝟒
𝐻 𝑧
1 −1 Z-1 Z-1
= 1 1 + 𝑧 −5 + 𝑧 + 𝑧 −4
3
1 −2
+ 𝑧 + 𝑧 −3
4
𝒀 𝒛 www.iammanuprasad.com
YouTube - IMPLearn
Linear phase realization
Q) Realise the system function using minimum number of multiplier
1 1
𝐻 𝑧 = 1 + 𝑧 −1 1 + 𝑧 −1 + 𝑧 −2 + 𝑧 −3
2 2
𝑿 𝒛 Z-1
Z-1
Z-1
Z-1
𝒀 𝒛
www.iammanuprasad.com
YouTube - IMPLearn
Conversion of lattice coefficient to direct form filter coefficient
𝑦 𝑛 = 𝑥 𝑛 + 𝛼𝑚 𝑘 𝑥 𝑛 − 𝑘
𝑘=1
The equations to convert filter coefficients to direct form FIR filter coefficients are
𝛼𝑚 0 = 1
𝛼𝑚 𝑚 = 𝐾𝑚
𝛼𝑚 𝑘 = 𝛼𝑚−1 𝑘 + 𝛼𝑚 𝑚 𝛼𝑚−1 𝑚 − 𝑘
www.iammanuprasad.com
YouTube - IMPLearn
Q) Consider an FIR filter lattice filter with coefficient K1 = ½ ,K2 = 1/3 , K3 = ¼. Determine the
FIR filter coefficients for direct form structure?
Solution 𝑚
𝑦 𝑛 = 𝑥 𝑛 + 𝛼𝑚 𝑘 𝑥 𝑛 − 𝑘
Number of stages (m) = 3 𝑘=1
𝑦 𝑛 = 𝑥 𝑛 + 𝛼𝑚 𝑘 𝑥 𝑛 − 𝑘 = 𝑥 𝑛 + 𝛼3 1 𝑥 𝑛 − 1 + 𝛼3 2 𝑥 𝑛 − 2 + 𝛼3 3 𝑥 𝑛 − 3
𝑘=1
𝑦 𝑛 = 𝑥 𝑛 + 𝛼𝑚 𝑘 𝑥 𝑛 − 𝑘
𝑘=1
The equations to convert filter coefficients to lattice form FIR filter coefficients are
𝛼𝑚−1 0 = 1
𝐾𝑚 = 𝛼𝑚 𝑚
𝛼𝑚 𝑘 − 𝛼𝑚 𝑚 𝛼𝑚 𝑚 − 𝑘
𝛼𝑚−1 𝑘 = 2 𝑓𝑜𝑟 1 ≤ 𝑘 ≤ 𝑚 − 1
1 − 𝛼𝑚 𝑚
www.iammanuprasad.com
YouTube - IMPLearn
4 3 2
A FIR filter is given by the difference equation 𝑦 𝑛 = 2𝑥 𝑛 + 5 𝑥 𝑛 − 1 + 2 𝑥 𝑛 − 2 + 3 𝑥 𝑛 − 3 Determine
its lattice form
Solution
𝑚
3
𝑦 𝑛 = 𝑥 𝑛 + 𝛼𝑚 𝑘 𝑥 𝑛 − 𝑘
𝑦 𝑛 = 𝑥 𝑛 + 𝛼𝑚 𝑘 𝑥 𝑛 − 𝑘 𝑘=1
𝑘=1
= 𝑥 𝑛 + 𝛼3 1 𝑥 𝑛 − 1 + 𝛼3 2 𝑥 𝑛 − 2 + 𝛼3 3 𝑥 𝑛 − 3
2 3 1
𝑦 𝑛 =2 𝑥 𝑛 + 𝑥 𝑛−1 + 𝑥 𝑛−2 + 𝑥 𝑛−3
5 4 3
2 3 1
𝛼3 1 = 𝛼3 2 = 𝛼 3 3 = = 𝑘3
5 4 3
𝛼2 0 = 1
www.iammanuprasad.com
YouTube - IMPLearn 2 3 1
𝛼3 1 = 𝛼3 2 = 𝛼3 3 = = 𝑘3 𝛼2 0 = 1
For m=3, k=1 5 4 3
2 1 3
𝛼3 1 − 𝛼3 3 𝛼3 2 − . 𝑚
𝛼2 1 = = 5 3 4
1 − 𝛼32 3 = 0.1687 𝑦 𝑛 = 𝑥 𝑛 + 𝛼𝑚 𝑘 𝑥 𝑛 − 𝑘
1 2
1− 3 𝑘=1
𝛼2 1 − 𝛼2 2 𝛼2 1 0.1687 − (0.6937)0.1687
𝑘1 = 𝛼1 1 = =
1 − 𝛼22 2 1 − 0.6937 2
= 0.0996
www.iammanuprasad.com
YouTube - IMPLearn
www.iammanuprasad.com
YouTube - IMPLearn
Direct form I realization
Let us consider an IIR system described by the difference equation
𝑁 𝑀
𝑦 𝑛 = − 𝑎𝑘 𝑦 𝑛 − 𝑘 + 𝑏𝑘 𝑥 𝑛 − 𝑘 𝒙 𝒏 𝒚 𝒏
𝒃𝟎 𝒘 𝒏
𝑘=1 𝑘=0
= −𝑎1 𝑦 𝑛 − 1 − 𝑎2 𝑦 𝑛 − 2 …
− 𝑎𝑁 𝑦 𝑛 − 𝑁 + 𝑤 𝑛 Z-1 Z-1
𝒃𝟏 −𝒂𝟏
Where 𝒙 𝒏−𝟏 𝒚 𝒏−𝟏
𝑤 𝑛
Z-1 Z-1
= 𝑏0 𝑥 𝑛 + 𝑏1 𝑥 𝑛 − 𝑁 + ⋯
+ 𝑏𝑀 𝑥 𝑛 − 𝑀
𝒃𝑴−𝟏 −𝒂𝑵−𝟏
Z-1 Z-1
𝒃𝑴 −𝒂𝑵
𝒙 𝒏−𝑴 𝒚 𝒏−𝑴
www.iammanuprasad.com
YouTube - IMPLearn
Direct form I realization
Q) Realise the second order digital filter
𝑦 𝑛 = 2𝑟 cos 𝜔0 𝑦 𝑛 − 1 − 𝑟 2 𝑦 𝑛 − 2 + 𝑥 𝑛 − 𝑟 cos 𝜔0 𝑥 𝑛 − 1
Solution
𝑤 𝑛 = 𝑥 𝑛 − 𝑟 cos 𝜔0 𝑥 𝑛 − 1 𝑦 𝑛 = 2𝑟 cos 𝜔0 𝑦 𝑛 − 1 − 𝑟 2 𝑦 𝑛 − 2 + 𝑤 𝑛
𝒙 𝒏 𝒚 𝒏
𝒘 𝒏
Z-1 Z-1
−𝑟 cos 𝜔0 2𝑟 cos 𝜔0
Z-1
𝑟2
www.iammanuprasad.com
YouTube - IMPLearn
Direct form I realization
Q) Obtain the direct form I realisation for the system described by difference equation
𝑦 𝑛 = 0.5𝑦 𝑛 − 1 − 0.25𝑦 𝑛 − 2 + 𝑥 𝑛 + 0.4𝑥 𝑛 − 1
Solution
𝒙 𝒏 𝒚 𝒏
𝒘 𝒏
Z-1 Z-1
0.4 0.5
Z-1
−0.25
www.iammanuprasad.com
YouTube - IMPLearn
Direct form II realization
Let us consider an IIR system described by the difference equation
𝑁 𝑀
𝑦 𝑛 = − 𝑎𝑘 𝑦 𝑛 − 𝑘 + 𝑏𝑘 𝑥 𝑛 − 𝑘
𝑘=1 𝑘=0 𝑌 𝑧 = 𝑏0 𝑊 𝑧 + 𝑏1 𝑧 −1 𝑊 𝑧 + ⋯ + 𝑏𝑀 𝑧 −𝑀 𝑊 𝑧
The system function can be represented as where
σ𝑀
𝑘=0 𝑏𝑘 𝑧
−𝑘
𝐻 𝑧 = 𝑊 𝑧 + 𝑎1 𝑧 −1 𝑊 𝑧 + 𝑎2 𝑧 −2 𝑊 𝑧 … + 𝑎𝑁 𝑧 −𝑁 𝑊 𝑧 = 𝑋 𝑧
1 + σ𝑁
𝑘=1 𝑎𝑘 𝑧
−𝑘
Let
𝑊 𝑧 = 𝑋 𝑧 − 𝑎1 𝑧 −1 𝑊 𝑧 − 𝑎2 𝑧 −2 𝑊 𝑧 … − 𝑎𝑁 𝑧 −𝑁 𝑊 𝑧
𝑌 𝑧 𝑌 𝑧 𝑊 𝑧
= .
𝑋 𝑧 𝑊 𝑧 𝑋 𝑧 Taking inverse z transform we get
𝑀
𝑌 𝑧 𝑤 𝑛 = 𝑥 𝑛 − 𝑎1 𝑤 𝑛 − 1 − 𝑎2 𝑤 𝑛 − 2 … − 𝑎𝑁 𝑤 𝑛 − 𝑁
= 𝑏𝑘 𝑧 −𝑘
𝑊 𝑧
𝑘=0
𝑦 𝑛 = 𝑏0 𝑤 𝑛 + 𝑏1 𝑤 𝑛 − 1 + ⋯ + 𝑏𝑀 𝑤 𝑛 − 𝑀
𝑊 𝑧 1
=
𝑋 𝑧 1 + σ𝑁
𝑘=1 𝑎𝑘 𝑧
−𝑘 www.iammanuprasad.com
YouTube - IMPLearn
Direct form II realization
𝑤 𝑛 = 𝑥 𝑛 − 𝑎1 𝑤 𝑛 − 1 − 𝑎2 𝑤 𝑛 − 2 … − 𝑎𝑁 𝑤 𝑛 − 𝑁
𝑦 𝑛 = 𝑏0 𝑤 𝑛 + 𝑏1 𝑤 𝑛 − 1 + ⋯ + 𝑏𝑀 𝑤 𝑛 − 𝑀
𝒙 𝒏 𝒚 𝒏
Z-1
−𝒂𝟏 𝒃𝟏
Z-1
−𝒂𝑵−𝟏 𝒃𝑴−𝟏
Z-1
−𝒂𝑵 𝒃𝑴
www.iammanuprasad.com
YouTube - IMPLearn
Direct form II realization
Q) Realise the second order digital filter using direct form II 𝑌 𝑧 𝑌 𝑧 𝑊 𝑧
= .
𝑦 𝑛 = 2𝑟 cos 𝜔0 𝑦 𝑛 − 1 − 𝑟 2 𝑦 𝑛 − 2 + 𝑥 𝑛 − 𝑟 cos 𝜔0 𝑥 𝑛 − 1 𝑋 𝑧 𝑊 𝑧 𝑋 𝑧
Solution
Taking Z - Transform
𝑌 𝑧 = 2𝑟 cos 𝜔0 𝑌 𝑧 𝑧 −1 − 𝑟 2 𝑌 𝑧 𝑧 −2 + 𝑋 𝑧 − 𝑟 cos 𝜔0 𝑋 𝑧 𝑧 −1
𝑌 𝑧 1 − 2𝑟 cos 𝜔0 𝑧 −1 + 𝑟 2 𝑧 −2 = 𝑋 𝑧 1 − 𝑟 cos 𝜔0 𝑧 −1
𝑌 𝑧 1 − 𝑟 cos 𝜔0 𝑧 −1
=
𝑋 𝑧 1 − 2𝑟 cos 𝜔0 𝑧 −1 + 𝑟 2 𝑧 −2 𝑊 𝑧 1
=
𝑌 𝑧 𝑋 𝑧 1 − 2𝑟 cos 𝜔0 𝑧 −1 + 𝑟 2 𝑧 −2
= 1 − 𝑟 cos 𝜔0 𝑧 −1
𝑊 𝑧
𝑊 𝑧 − 2𝑟 cos 𝜔0 𝑊 𝑧 𝑧 −1 + 𝑟 2 𝑊 𝑧 𝑧 −2 = 𝑋 𝑧
𝑌 𝑧 = 𝑊 𝑧 1 − 𝑟 cos 𝜔0 𝑧 −1
𝑊 𝑧 = 𝑋 𝑧 + 2𝑟 cos 𝜔0 𝑧 −1 𝑊 𝑧 − 𝑟 2 𝑧 −2 𝑊 𝑧
Inverse transform
Inverse transform
𝑦 𝑛 = 𝑤 𝑛 − 𝑟 cos 𝜔0 𝑤 𝑛 − 1 𝑤 𝑛 = 𝑥 𝑛 + 2𝑟 cos 𝜔0 𝑥 𝑛 − 1 − 𝑟 2 𝑥 𝑛 − 2
www.iammanuprasad.com
YouTube - IMPLearn
Direct form II realization
𝑦 𝑛 = 𝑤 𝑛 − 𝑟 cos 𝜔0 𝑤 𝑛 − 1 𝑧 −1 𝑤 𝑛 = 𝑥 𝑛 + 2𝑟 cos 𝜔0 𝑥 𝑛 − 1 − 𝑟 2 𝑥 𝑛 − 2
𝒙 𝒏 𝒘 𝒏 𝒚 𝒏
Z-1
𝟐𝒓 𝒄𝒐𝒔𝝎𝟎 −𝒓 𝒄𝒐𝒔𝝎𝟎
Z-1
−𝒓𝟐
www.iammanuprasad.com
YouTube - IMPLearn
Direct form II realization
Q) Determine the direct form II realisation for the following system 𝑌 𝑧 𝑌 𝑧 𝑊 𝑧
𝑦 𝑛 = −0.1𝑦 𝑛 − 1 + 0.72𝑦 𝑛 − 2 + 0.7𝑥 𝑛 − 0.252𝑥 𝑛 − 1 = .
𝑋 𝑧 𝑊 𝑧 𝑋 𝑧
Solution
Taking Z - Transform
𝑌 𝑧 0.7 − 0.252𝑧 −1
=
𝑋 𝑧 1 + 0.1𝑧 −1 − 0.72𝑧 −2 𝑊 𝑧 1
=
𝑌 𝑧 𝑋 𝑧 1 + 0.1𝑧 −1 − 0.72𝑧 −2
= 0.7 − 0.252𝑧 −1
𝑊 𝑧
𝑊 𝑧 + 0.1𝑊 𝑧 𝑧 −1 − 0.72𝑊 𝑧 𝑧 −2 = 𝑋 𝑧
𝑌 𝑧 = 𝑊 𝑧 0.7 − 0.252𝑧 −1
𝑊 𝑧 = 𝑋 𝑧 − 0.1𝑊 𝑧 𝑧 −1 + 0.72𝑊 𝑧 𝑧 −2
Inverse transform
Inverse transform
𝑦 𝑛 = 0.7𝑤 𝑛 − 0.252𝑤 𝑛 − 1 𝑤 𝑛 = 𝑥 𝑛 − 0.1𝑤 𝑛 − 1 + 0.72𝑤 𝑛 − 2
www.iammanuprasad.com
YouTube - IMPLearn
Direct form II realization
𝒙 𝒏 𝒘 𝒏 𝟎. 𝟕 𝒚 𝒏
Z-1
−𝟎. 𝟏 −𝟎. 𝟐𝟓𝟐
Z-1
𝟎. 𝟕𝟐
www.iammanuprasad.com
YouTube - IMPLearn
Cascade form realization
Let us consider an IIR system with system function
𝒚𝟏 𝒏 𝒚 𝒏
= 𝒙𝟐 𝒏
𝒙 𝒏 𝒚 𝒏 𝒙 𝒏 = 𝒙𝟏 𝒏 𝒃𝒌𝟎 𝒃𝒎𝟎
H1(z) H2(z)
Z-1 Z-1
𝑏𝑘0 + 𝑏𝑘1 𝑧 −1 + 𝑏𝑘2 𝑧 −2
𝐻1 𝑧 = −𝒂𝒌𝟏 −𝒃𝒌𝟏 −𝒂𝒎𝟏 −𝒃𝒎𝟏
1 + 𝑎𝑘1 𝑧 −1 + 𝑎𝑘2 𝑧 −2
www.iammanuprasad.com
YouTube - IMPLearn
Cascade form realization
Q) Realise the system with difference equation
3 1 1
𝑦 𝑛 = 𝑦 𝑛 − 1 − 𝑦 𝑛 − 2 + 𝑥 𝑛 + 𝑥 𝑛 − 1 in cascade form
4 8 3
𝑌 𝑧
Solution 𝐻 𝑧 =
𝑋 𝑧
Taking Z - Transform
3 1 1
𝑌 𝑧 = 𝑌 𝑧 𝑧 − 𝑌 𝑧 𝑧 + 𝑋 𝑧 + 𝑋 𝑧 𝑧 −1
−1 −2
4 8 3
3 −1 1 −2 1 −1
𝑌 𝑧 1− 𝑧 + 𝑧 =𝑋 𝑧 1+ 𝑧 1
4 8 3 1 + 𝑧 −1
𝐻1 𝑧 = 3
1 1
1 + 𝑧 −1 1 − 𝑧 −1
𝑌 𝑧 3 2
=
𝑋 𝑧 3 1
1 − 𝑧 −1 + 𝑧 −2
4 8 1
1 𝐻2 𝑧 =
1
𝑌 𝑧 1 + 𝑧 −1 1 − 𝑧 −1
= 3 4
𝑋 𝑧 1 1
1 − 𝑧 −1 1 − 𝑧 −1
2 4 www.iammanuprasad.com
YouTube - IMPLearn
1 1
1 + 𝑧 −1 𝐻2 𝑧 =
1
3
𝐻1 𝑧 =
1 1 − 𝑧 −1
4
1 − 𝑧 −1
2
1 1 1
𝑌1 𝑧 = 𝑋1 𝑧 + 𝑋1 𝑧 𝑧 + 𝑌1 𝑧 𝑧 −1
−1
𝑌2 𝑧 = X2 𝑧 + 𝑌2 𝑧
3 2 4
1 1 1
𝑦1 𝑛 = 𝑥1 𝑛 + 𝑥1 𝑛 − 1 + 𝑦1 𝑛 − 1 𝑦2 𝑛 = x2 𝑛 + 𝑦2 𝑛 − 1
3 2 4
𝒚𝟏 𝒏
𝒙 𝒏 = 𝒙𝟏 𝒏 = 𝒙𝟐 𝒏 𝒚𝟐 𝒏
Z-1 Z-1
𝟏 𝟏 𝟏
𝟑 𝟐 𝟒
www.iammanuprasad.com
YouTube - IMPLearn
Parallel form realization
A parallel form realisation of an IIR system can be obtained by performing a partial expansion
𝑁
𝐶𝑘 𝐶1 𝐶2 𝐶𝑁
𝐻 𝑧 =𝐶+ 𝐻 𝑧 =𝐶+ + + ⋯ +
1 − 𝑃𝑘 𝑧 −1 1 − 𝑃1 𝑧 −1 1 − 𝑃2 𝑧 −1 1 − 𝑃𝑁 𝑧 −1
𝑘=1
𝑌 𝑧 = 𝑐𝑋 𝑧 + 𝐻1 𝑧 𝑋 𝑧 + 𝐻2 𝑧 𝑋 𝑧 + ⋯ + 𝐻𝑁 𝑧 𝑋 𝑧
𝑪
𝒙 𝒏
H1(z)
H2(z)
Hk(z)
𝒚 𝒏
www.iammanuprasad.com
YouTube - IMPLearn
Parallel form realization
Q) Realise the system given by difference equation
𝑦 𝑛 = −0.1𝑦 𝑛 − 1 + 0.72𝑦 𝑛 − 2 + 0.7𝑥 𝑛 − 0.25𝑥 𝑛 − 2 in parallel form
Taking Z - Transform
0.7−0.25𝑧 −2
𝐻 𝑧 =
1+ 0.1𝑧 −1 −0.72𝑧 −2
−0.035𝑧 −1 +0.35
= 0.35 +
1+0.1𝑧 −1 −0.72𝑧 −2
0.206 0.144
= 0.35 + +
1 + 0.9𝑧 −1 1 − 0.8𝑧 −1
www.iammanuprasad.com
YouTube - IMPLearn
Parallel form realization
0.206 0.144
𝐻 𝑧 = 0.35 + +
1 + 0.9𝑧 −1 1 − 0.8𝑧 −1
𝟎. 𝟑𝟓
𝒙 𝒏 𝟎. 𝟐𝟎𝟔
Z-1
−𝟎. 𝟗
𝟎. 𝟏𝟒𝟒 𝒚 𝒏
Z-1
𝟎. 𝟖
www.iammanuprasad.com
YouTube - IMPLearn
www.iammanuprasad.com
YouTube - IMPLearn
Down sampling
• It is the process of reducing the sampling rate by an integer factor D or M
• Down sampled signal of x(n) can be obtained by simply keeping every
Mth sample and removing (M-1) in between samples
𝒙 𝒏 𝒚 𝒏 = 𝒙 𝑴𝒏
ꜜM
𝑥 𝑀𝑛 = 1, 2, 0, 2, 5
www.iammanuprasad.com
YouTube - IMPLearn
𝑀−1
1 𝑗
𝜔−2𝜋𝑘
𝑌 𝑒 𝑗𝜔 = 𝑋 𝑒 𝑀
𝑀
𝑘=0
www.iammanuprasad.com
YouTube - IMPLearn
𝜋 𝜋
Q) Consider a spectrum of input signal 𝑋 𝑒 𝑗𝜔 with a bandwidth of − to shown , when the signal is down
2 2
sampled by a factor D, sketch the spectrum of a down sampled signal for sampling rate reduction factor
D=2,3
𝟑𝝅 𝝅 𝝅 𝟑𝝅
-𝟐𝝅 − −𝝅 − 𝟎 𝝅 𝟐𝝅
𝟐 𝟐 𝟐 𝟐
For M/D=2
When D=2
1
1 𝑗
𝜔−2𝜋𝑘
𝑌 𝑒 𝑗𝜔 = 𝑋 𝑒 2 Bandwidth =D.BW =2π
2
𝑘=0
1 𝑗
𝜔 1 𝑗
𝜔−2𝜋
𝑌 𝑒 𝑗𝜔 = 𝑋 𝑒 2 + 𝑋 𝑒 2
2 2
www.iammanuprasad.com
YouTube - IMPLearn
1 𝜔 1 𝑗
𝜔 1 𝑗
𝜔−2𝜋
𝑋 𝑒
𝑗
2 𝑌 𝑒 𝑗𝜔 = 𝑋 𝑒 2 + 𝑋 𝑒 2
2 2 2
𝟏
𝟐
𝟕𝝅 𝟓𝝅 𝟑𝝅 𝝅 𝝅 𝟑𝝅 𝟓𝝅 𝟕𝝅
−𝟒𝝅 − −𝟑𝝅 − −𝟐𝝅 − −𝝅 − 𝟎 𝝅 𝟐𝝅 𝟑𝝅 𝟒𝝅
𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 𝟐
1 𝑗
𝜔−2𝜋
𝑋 𝑒 2
2
𝟕𝝅 𝟓𝝅 𝟑𝝅 𝝅 𝝅 𝟑𝝅 𝟓𝝅 𝟕𝝅
−𝟒𝝅 − −𝟑𝝅 − −𝟐𝝅 − −𝝅 − 𝟎 𝝅 𝟐𝝅 𝟑𝝅 𝟒𝝅
𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 𝟐
𝟕𝝅 𝟓𝝅 𝟑𝝅 𝝅 𝝅 𝟑𝝅 𝟓𝝅 𝟕𝝅
−𝟒𝝅 − −𝟑𝝅 − −𝟐𝝅 − −𝝅 − 𝟎 𝝅 𝟐𝝅 𝟑𝝅 𝟒𝝅
𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 www.iammanuprasad.com
𝟐 𝟐
YouTube - IMPLearn
𝜋 𝜋
Q) Consider a spectrum of input signal 𝑋 𝑒 𝑗𝜔 with a bandwidth of − to shown , when the signal is down
2 2
sampled by a factor D, sketch the spectrum of a down sampled signal for sampling rate reduction factor
D=2,3
𝟑𝝅 𝝅 𝝅 𝟑𝝅
-𝟐𝝅 − −𝝅 − 𝟎 𝝅 𝟐𝝅
𝟐 𝟐 𝟐 𝟐
For M/D=3
When D=3
2
1 𝑗
𝜔−2𝜋𝑘
𝑌 𝑒 𝑗𝜔
= 𝑋 𝑒 3 Bandwidth =D.BW =3π
3
𝑘=0
1 𝑗
𝜔 1 𝑗
𝜔−2𝜋 1 𝑗
𝜔−4𝜋
𝑌 𝑒 𝑗𝜔 = 𝑋 𝑒 3 + 𝑋 𝑒 3 + 𝑋 𝑒 3
3 3 3
www.iammanuprasad.com
1 𝑗
𝜔
1 𝜔 1 𝜔−2𝜋 1 𝜔−4𝜋
YouTube - IMPLearn 𝑋 𝑒 3 𝑌 𝑒 𝑗𝜔
= 𝑋 𝑒
𝑗
3 + 𝑋 𝑒
𝑗
3 + 𝑋 𝑒
𝑗
3
3 𝟏 3 3 3
𝟑
𝟕𝝅 𝟓𝝅 𝟑𝝅 𝝅 𝝅 𝟑𝝅 𝟓𝝅 𝟕𝝅
−𝟒𝝅 − −𝟑𝝅 − −𝟐𝝅 − −𝝅 − 𝟎 𝝅 𝟐𝝅 𝟑𝝅 𝟒𝝅
𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 𝟐
1 𝑗
𝜔−2𝜋
𝑋 𝑒 3
3
𝟕𝝅 𝟓𝝅 𝟑𝝅 𝝅 𝝅 𝟑𝝅 𝟓𝝅 𝟕𝝅
−𝟒𝝅 − −𝟑𝝅 − −𝟐𝝅 − −𝝅 − 𝟎 𝝅 𝟐𝝅 𝟑𝝅 𝟒𝝅
𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 𝟐
1 𝑗
𝜔−4𝜋
𝑋 𝑒 3
3
𝟕𝝅 𝟓𝝅 𝟑𝝅 𝝅 𝝅 𝟑𝝅 𝟓𝝅 𝟕𝝅
−𝟒𝝅 − −𝟑𝝅 − −𝟐𝝅 − −𝝅 − 𝟎 𝝅 𝟐𝝅 𝟑𝝅 𝟒𝝅
𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 𝟐
𝟕𝝅 𝟓𝝅 𝟑𝝅 𝝅 𝝅 𝟑𝝅 𝟓𝝅 𝟕𝝅
−𝟒𝝅 − −𝟑𝝅 − −𝟐𝝅 − −𝝅 − 𝟎 𝝅 𝟐𝝅 www.iammanuprasad.com
𝟑𝝅 𝟒𝝅
𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 𝟐
YouTube - IMPLearn
Anti-aliasing filters
• In order to avoid aliasing the input signal should be band limited to π/D for
decimation by a factor of D
Anti-aliasing
filter
𝒙 𝒏 𝒚 𝒏 = 𝒙 𝑴𝒏
h(n) ꜜM
www.iammanuprasad.com
YouTube - IMPLearn
Up sampling
• It is the process of increasing the sampling rate by an integer factor I or L
• Up sampled signal of x(n) can be obtained by a factor of L by L-1 equally
spaced zeros between each pairs of samples
𝒏
𝒙 𝒏 𝒚 𝒏 =𝒙
ꜛL 𝑳
𝑥 𝑛 = 1, 2, 3, 4, 5 for I/L=3
𝑛
𝑥 = 1, 0, 0, 2, 0, 0, 3, 0, 0, 4,0,0
𝐿
www.iammanuprasad.com
YouTube - IMPLearn
𝑌 𝑒 𝑗𝜔 = 𝑋 𝑒 𝑗𝜔𝐼
www.iammanuprasad.com
YouTube - IMPLearn
Q) The spectrum of discrete time signal is shown below. Draw the spectrum of the signal if it is upscaled by
I=2,3
𝟕𝝅 𝟓𝝅 𝟑𝝅 𝝅 𝝅 𝟑𝝅 𝟓𝝅 𝟕𝝅
−𝟒𝝅 − −𝟑𝝅 − −𝟐𝝅 − −𝝅 − 𝟎 𝝅 𝟐𝝅 𝟑𝝅 𝟒𝝅
𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 𝟐
www.iammanuprasad.com
YouTube - IMPLearn
For I or L=2
𝑌 𝑒 𝑗𝜔 = 𝑋 𝑒 𝑗2𝜔
When I=2
Bandwidth =BW/I =π
𝟑𝝅 𝝅 𝝅 𝟑𝝅
-𝟐𝝅 − −𝝅 − 𝟎 𝝅 𝟐𝝅
𝟐 𝟐 𝟐 𝟐
For I or L=3
𝑌 𝑒 𝑗𝜔 = 𝑋 𝑒 𝑗3𝜔
When I=3
𝟑𝝅 𝝅 𝝅 𝟑𝝅 www.iammanuprasad.com
-𝟐𝝅 − −𝝅 − 𝟎 𝝅 𝟐𝝅
𝟐 𝟐 𝟐 𝟐
YouTube - IMPLearn
Anti-imaging filters
• When up sampled by a factor of I, the output spectrum will have I images in each
𝜋
period with each image bandwidth to
𝐼
𝜋
• Since the frequency spectrum in the range to 0 to are unique and we have to
𝐼
filter the other images
• Hence the output of up samples is passed through a lowpass filter with band
𝜋
width
𝐼
• Since the lowpass filter is designed to avoid multiple images in output spectrum ,
it also called anti-imaging filter
Anti-imaging
filter
𝒙 𝒏 𝒚 𝒏
ꜛI h(n)
www.iammanuprasad.com
YouTube - IMPLearn
www.iammanuprasad.com
YouTube - IMPLearn
Harvard Architecture
• The term Harvard originated from the Harvard Mark 1 relay-based computer which stored instruction on
punched tape and data in relay latches
• The Harvard architectures physically separate memories for their instructions and data, requiring dedicated
buses for each of them.
• Instructions and operands can therefore be fetched simultaneously.
• Most of the DSP processors use a modified Harvard architecture with two or three memory buses; allowing
access to filter coefficients and input signals in the same cycle.
• Since it possesses two independent bus systems, the Harvard architecture is capable of simultaneous reading an
instruction code and reading or writing a memory or peripheral as part of the execution of the previous
instruction.
www.iammanuprasad.com
YouTube - IMPLearn
Pipelining
• To improve the efficiency, advanced microprocessors and digital signal processors use an approach
called pipelining in which different phases of operation and execution of instructions are carried out
in parallel.
• In modem processors the first step of execution is performed on the first instruction, and then when
the instruction passes to the next step, a new instruction is started.
• The Fetch phase(F) in which the next instruction is fetched from the address stored in the program counter.
• The decode phase (D) in which the instruction in the instruction register is decoded and the address in the program
counter is incremented
• Memory read (R) phase reads the data from the data buses and also writes data to the data buses.
• The Execute phase (X) executes the instruction currently in the instruction register and also completes the write
process.
Instruction 1 F1 D1 R1 X1
Instruction 2 F2 D2 R2 X2
Instruction 3 F3 D3 R3 X3
Instruction 4 F4 D4 R4 X4
www.iammanuprasad.com
YouTube - IMPLearn
Multiply Accumulate Unit (MAC)
• The Multiply-Accumulate (MAC) operation is the basis of many digital signal processing algorithms
• In digital signal processing, the multiply–accumulate (MAC) operation is a common step that
computes the product of two numbers and adds that product to an accumulator.
• The hardware unit that performs the operation is known as a multiplier–accumulator (MAC unit); the
operation itself is also often called a MAC
• The MAC speed applies both to finite impulse response (FIR) and infinite impulse response (IIR)
fi1ters. The complexity of the filter response dictates the number MAC operations required per
sample period.
• A multiply-accumulate step performs the following:
• Reads a 16-bit sample data (pointed to by a register)
• Increments the sample data-pointer by 2
• Reads a. 16-bit coefficient (pointed to by another register)
• Increments the coefficient register pointer by 2
• Sign Multiply (16-bit) data and coefficient 'to yield a 32~bit resu1t
• Adds the result to the contents of a 32-bit register pair for accumulate.
www.iammanuprasad.com
YouTube - IMPLearn
TMS320C67xx - Digital Signal Processor
• The TMS320 DSP family consists of fixed-point, floating-point, and multiprocessor digital signal
processors (DSPs).
• TMS320 DSPs have an architecture designed specifically for real-time signal processing.
• With a performance of up to 6000 million instructions per second (MIPS) and an efficient C
compiler, the TMS320C6000 DSPs give system architects unlimited possibilities to differentiate
their products.
• High Performance
• Ease of use
• affordable pricing
• The C6000 devices execute up to eight 32-bit instructions per cycle. The C67x CPU consists of 32
general-purpose 32-bit registers and eight functional units.
• These eight functional units contain:
• Two multipliers
• Six ALUs
www.iammanuprasad.com
YouTube - IMPLearn
TMS320C67xx DSP
Architecture
www.iammanuprasad.com
YouTube - IMPLearn
TMS320C67xx DSP
Architecture
• Central Processing Unit
(CPU)
• Program fetch unit
• Instruction dispatch unit
• Instruction decode unit
• Two data paths, each with four
functional units
• 32 32-bit registers
• Control registers
• Control logic
• Test, emulation, and interrupt
logic
www.iammanuprasad.com
YouTube - IMPLearn
TMS320C67xx DSP
Architecture
www.iammanuprasad.com
YouTube - IMPLearn
TMS320C67xx DSP Architecture
• DMA Controller (C6701 DSP only) transfers data between address ranges in the
memory map without intervention by the CPU. The DMA controller has four
programmable channels and a fifth auxiliary channel.
• EDMA Controller performs the same functions as the DMA controller. The EDMA has 16
programmable channels, as well as a RAM space to hold multiple configurations for future transfers.
• HPI is a parallel port through which a host processor can directly access the CPU’s memory space.
The host device has ease of access because it is the master of the interface. The host and the CPU can
exchange information via internal or external memory. In addition, the host has direct access to
memory-mapped peripherals.
• Expansion bus is a replacement for the HPI, as well as an expansion of the EMIF. The expansion
provides two distinct areas of functionality (host port and I/O port) which can co-exist in a system.
The host port of the expansion bus can operate in either asynchronous slave mode, similar to the HPI,
or in synchronous master/slave mode. This allows the device to interface to a variety of host bus
protocols. Synchronous FIFOs and asynchronous peripheral I/O devices may interface to the
expansion bus.
www.iammanuprasad.com
YouTube - IMPLearn
TMS320C67xx DSP Architecture
• McBSP (multichannel buffered serial port) is based on the standard serial port interface found on the
TMS320C2000 and TMS320C5000 devices. In addition, the port can buffer serial samples in
memory automatically with the aid of the DMA/EDNA controller. It also has multichannel capability
compatible with the T1, E1, SCSA, and MVIP networking standards.
• Timers in the C6000 devices are two 32-bit general-purpose timers used for these functions:
• Time events
• Count events
• Generate pulses
• Interrupt the CPU
• Send synchronization events to the DMA/EDMA controller.
• Power-down logic allows reduced clocking to reduce power consumption. Most of the operating
power of CMOS logic dissipates during circuit switching from one logic state to another. By
preventing some or all of the chip’s logic from switching, you can realize significant power savings
without losing any data or operational context.
www.iammanuprasad.com
YouTube - IMPLearn
Finite Word length Effects
• In the design of FIR Filters, the filter coefficients are determined by the system
transfer functions. These filters co-efficient are quantized/truncated while
implementing DSP System because of finite length registers.
• Only Finite numbers of bits are used to perform arithmetic operations. Typical word
length is 16 bits, 24 bits, 32 bits etc.
• This finite word length introduces an error which can affect the performance of the
DSP system.
• Input quantization error
• Co-efficient quantization error
• Overflow & round off error (Product Quantization error)
www.iammanuprasad.com
YouTube - IMPLearn
Quantization Error
• The effect of error introduced by a signal process depend upon number of factors including the.
• Type of arithmetic
• Quality of input signal
• Type of algorithm implemented
• For any system, during its functioning, there is always a difference in the values of its input and
output. The processing of the system results in an error, which is the difference of those values. The
difference between an input value and its quantized value is called a Quantization Error.
www.iammanuprasad.com
YouTube - IMPLearn
Input quantization error
• The conversion of continuous-time input signal into digital value produces an error which is known
as input quantization error. This error arises due to the representation of the input signal by a fixed
number of digits in A/D conversion process
𝑒 𝑛 = 𝑥𝑞 𝑛 − 𝑥 𝑛
www.iammanuprasad.com
YouTube - IMPLearn
Product Quantization error
• In fixed point arithmetic the product of two b-bit numbers results in 2b bits long. In DSP applications
it is necessary to round this product to b-bit number which produce an error known as product
quantization error or product round off noise
𝑥𝑞 𝑛 𝑦 𝑛 = 𝑎𝑥𝑞 𝑛 + 𝑒 𝑛
𝒂
𝑒 𝑛
• The multiplication is modelled as an infinite precision multiplier followed by an adder where round
off noise is added to the product so that overall result equals some quantization level
www.iammanuprasad.com
YouTube - IMPLearn
Coefficient quantization error
• In the design of a digital filter the coefficients are evaluated with infinite precision.
• But when they are quantized, the frequency response of the actual filter deviates
from that which would have been obtained with an infinite word length
representation and the filter may actually fail to meet the desired specifications.
• If the poles of the desired filter are close to the unit circle, then those of the filter
with quantized coefficients my lie just outside the unit circle
www.iammanuprasad.com
YouTube - IMPLearn
Coefficient quantization error
• Consider a second order IIR filter with
www.iammanuprasad.com