DSP Projects Call 9952749533
DSP Projects Call 9952749533
Email: [email protected]
[email protected]
Cell: 9952749533
www.researchprojects.info
PAIYANOOR, OMR, CHENNAI
Call For Research Projects Final
year students of B.E in EEE, ECE,
EI, M.E (Power Systems), M.E
(Applied Electronics), M.E (Power
Electronics)
Ph.D Electrical and Electronics.
Students can assemble their hardware in our
Research labs. Experts will be guiding the
projects.
Discrete Fourier Transform
&
Fast Fourier Transform
Review
The DTFT provides the frequency-domain (w)
representation for absolutely summable sequences.
The z-transform provides a generalized frequency-
domain (z) representation for arbitrary sequences.
Two features in common:
Defined for infinite-length sequences
Functions of continuous variable (w or z)
From the numerical computation viewpoint, these two
features are troublesome because one has to evaluate
infinite sums at uncountably infinite frequencies.
Review
To use Matlab, we have to truncate sequences and
then evaluate the expression at finitely many points.
The evaluation were obviously approximations to the
exact calculations.
In other words, the DTFT and the z-transform are not
numerically computable transform.
Introduction
Therefore we turn our attention to a numerically computable
transform.
It is obtained by sampling the DTFT transform in the frequency
domain (or the z-transform on the unit circle).
We develop this transform by analyzing periodic sequences.
From FT analysis we know that a periodic function can always
be represented by a linear combination of harmonically related
complex exponentials (which is form of sampling).
This give us the Discrete Fourier Series representation.
We extend the DFS to finite-duration sequences, which leads to
a new transform, called the Discrete Fourier Transform.
Introduction
The DFT avoids the two problems mentioned above
and is a numerically computable transform that is
suitable for computer implementation.
The numerical computation of the DFT for long
sequences is prohibitively time consuming.
Therefore several algorithms have been developed to
efficiently compute the DFT.
These are collectively called fast Fourier transform
(or FFT) algorithms.
The Discrete Fourier Series
Definition: Periodic sequence
~
x ( n) ~
x (n kN ), n, k
N: the fundamental period of the sequences
From FT analysis we know that the periodic functions can be
synthesized as a linear combination of complex exponentials
whose frequencies are multiples (or harmonics) of the
fundamental frequency (2pi/N).
From the frequency-domain periodicity of the DTFT, we
conclude that there are a finite number of harmonics; the
frequencies are {2pi/N*k,k=0,1,…,N-1}.
The Discrete Fourier Series
A periodic sequence can be expressed as
N 1
~ 1 ~ j 2N kn
x ( n)
N
X (k )e , n 0,1,
k 0
~
{ X ( K ), k 0,1, } are called the discrete Fourier series
coefficients, which are given by
N 1
~ ~ j 2N kn
X ( k ) x ( n)e , k 0,1,
n 0
n 0
N 1
~ ~ 1 ~
x (n) IDFS[ X (k )]
N
X ( k )W nk
N
k 0
Example 5.1
DFT : DEFINATION
2. Linearity
If X1(k) and X2(k) are the N-point DFT
of x1(n) and x2(n),
ax1(n) + bx2(n) DFT aX1(k) + bX2(k)
3. Circular Shifting
Let x(n) be a sequence of length N and X(k) is N
-point DFT, thus the sequence, x,(n) obtained from
x(n) by shifting x(n) cyclically by m units. Then,
x,(n) DFT X(k)e-j2km/N
4. Parseval’s Theorem
if x(n) DFT X(k) and
y(n) DFT Y(k)
thus, N 1 y*(n) = 1/N Y (k)
N 1*
x ( n) X (k )
k 0
n0
DFT : RELATIONSHIP WITH z-TRANSFORM
= x ( n )e
n
-j2nk/N
EXAMPLE 1:
Find the DFT for the following finite length sequence,
x(n) = { ¼, ¼, ¼ }
Solution :
1. Determine the sequence length, N
N = 3, k = 0,1,2
2. Use DFT formula to determine X(k)
N 1
X(k) = e-j2nk/N , k = 0, 1, 2
x ( n)
n 0+ ¼ + ¼ = ¾
X(0) = ¼
X(1) = ¼ + ¼e-j2/3 + ¼e-j4/3
= ¼ + ¼ [cos (2/3) – jsin(2/3) + ¼ [cos (4/3) –jsin(4/3)
= ¼ + ¼ [-0.5 – j0.866] + ¼ [ -0.5 + j0.866]
= ¼ + ¼ [-1] = 0
Continued from Examples 1:
Thus,
X(k) = { ¾, 0, 0}
Examples 2:
Given the following the finite length sequences,
x(n) = {1,1,2,2,3,3}
Perform DFT for this sequences.
Solution :
1. Determine the sequence length, N = 6.
2. Use DFT formula to determine X(k).
x ( n)
X(0) = 12, X(1) = -1.5 + j2.598
X(2) = -1.5 + j0.866, X(3) = 0
n 0– j0.866, X(5) = -1.5 – j2.598
X(4) = -1.5
Thus,
X(k) = {12, -1.5 + j2.598, -1.5 + j0.866, 0, -1.5 – j0.866,
-1.5 – j2.598}
Examples 3:
Find the DFT for the convolution of 2 sequences :
x1(n) = {2, 1, 2, 1} & x2(n) = {1, 2, 3, 4}
Solution :
1. Determine the sequence length for each
sequence, N = 4. Thus, k = 0,1,2,3
2. Perform DFT for each sequences,
(i) X1(0) = 6, X1(1) = 0, X1(2) = 2, X2(3) = 0
X1(k) = {6,0,2,0}
3. Perform Convolution by :
X3(k) = X1(k) X2(k)
= {60, 0, -4, 0}
IDFT : DEFINATION
EXAMPLES 5:
Obtain the finite length sequence, x(n) from the DFT sequence in Example 3.
Solution :
1. The sequence in Example 3 is :
X3(k) = {60, 0, -4, 0}
2. Use IDFT formula to obtain x(n):
X (k )
x3(0) = 14, x3(1) = 16, x3(2) = 14, x3(3) = 16
k 0
The X(k) will be the summation of x(0)e-j2(0)k/8 until x(7)e-j2(7)k/8 For the
eight terms, there will be 64 multiplication (82) and 56 addition (8 x (8-
1))
where, WN = e-j2/N
IFFT : DEFINATION
~
x ( n)
x (n), 0 n N 1 ~ N 1
X ( k ) x ( n) e
j 2N k n
0, elsewhere n 0
~
X (k ) X ( z ) | j 2 k
z e N
n 0 n 0
~
X ( k ) X (e ) | w 2 k
jw
N
2 2
Let w1 , and wk k kw1
N N
X (k ) X (e jwk ) X (e jkw1 )
The DFS is obtained by evenly sampling the DTFT at w1 intervals.
The interval w1 is the sampling interval in the frequency domain. It is called
frequency resolution because it tells us how close are the frequency samples.
Sampling and construction in the
z-domain
~
X (k ) X ( z ) | j 2 k
, k 0,1,2,
DFS & z- z e N
transform j 2N km
x ( m) e x ( m )W km
N
m m
~ 1 ~ N 1
1 N 1 km
IDFS x ( n)
N
X ( k )W kn
N
N k 0 m
x ( m )W W
N N
kn
k 0
1 N 1 k ( n m )
x ( m ) WN x(m) (n m rN )
m N k 0 m r
x(m) (n m rN ) x(n rN )
m r r
Comments
When we sample X(z) on the unit circle, we
obtain a periodic sequence in the time domain.
This sequence is a linear combination of the
original x(n) and its infinite replicas, each
shifted by multiples of N or –N.
If x(n)=0 for n<0 and n>=N, then there will be
no overlap or aliasing in the time domain.
Comments
x ( n) ~
x (n) for 0 n N 1
~ ~ 1 0 n N 1
x ( n ) x ( n ) RN ( n ) x ( n )
0 else
n 0 n 0 n 0 N k 0
1 N 1 ~ N 1 kn n 1 N 1 ~ N 1 k 1 n
X ( k ) W N z X ( k ) WN z
N k 0
n 0 N k 0 n0
1 N 1
~ 1 WN kN z N
N
X (k ) 1 W k z 1 WN-kN=1
k 0 N
N N 1 ~
1 z X (k )
X ( z)
N
1 W k z 1
k 0 N
The DTFT Interpolation Formula
~
1 e jwN N 1
X (k ) N 1
~ 1 e jwN
X (e )
jw
N
1 e j 2k / N e jw X (k )
N 1 e j 2k / N e jw
k 0 k 0
sin wN
2 jw N21
An interpolation polynomial
( w) e
N sin 2
w
Note that the DFT X(k) is also an N-point sequence, that is, it is not
defined outside of 0<=n<=N-1.
DFT X(k) is the primary interval of X~(k).
N 1
~ 1
x(n) IDFT [ X (k )] x (n) RN (n)
N
X (k )WNkn ,0 n N 1
k 0
Matlab Implementation
X WN x
1 *
x WN X
N
1 1 1
1 W 1 WN( N 1)
WN WNkn
0 k, n N 1
N
( N 1) ( N 1) 2
1 W N WN
Zero-padding is an operation in which more zeros are appended
to the original sequence. The resulting longer DFT provides
closely spaced samples of the discrete-times Fourier transform
of the original sequence.
The zero-padding gives us a high-density spectrum and
provides a better displayed version for plotting. But it does not
give us a high-resolution spectrum because no new information
is added to the signal; only additional zeros are added in the
data.
To get high-resolution spectrum, one has to obtain more data
from the experiment or observations.
Properties of the DFT
1. Linearity: DFT[ax1(n)+bx2(n)]=aDFT[x1(n)]+bDFT[x2(n)]
N3=max(N1,N2): N3-point DFT
2. Circular folding:
x(0) k 0
x(( n)) N
x( N k ) 1 k N 1
X ( 0) k 0
DFT [ x((n)) N ] X (( k )) N
X (N k ) 1 k N 1
Matlab: x=x(mod(-n,N)+1)
Properties of the DFT
3. Conjugation: DFT [ x * (n)] X * (( k )) N
4. Symmetry properties for real sequences:
Let x(n) be a real-valued N-point sequence
X (k ) X * ((k )) N
Re[ X (k )] Re[ X (( k )) N ] : circular even sequence
Im[ X (k )] Im[ X (( N k )) N ] : circular odd sequence
| X (k ) || X ((k )) N |
X (k ) X (( k )) N
Comments:
Circular symmetry
Periodic conjugate symmetry
About 50% savings in computation as well as in storage.
X(0) is a real number: the DC frequency
X(N/2)(N is even) is also real-valued: Nyquist component
Circular-even and circular-odd components:
1
xec (n) [ x(n) x(( n)) N ] DFT [ xec (n)] Re[ X (k )] Re[ X (( k )) N ]
2
1
xoc (n) [ x(n) x((n)) N ] DFT [ xoc (n)] Im[ X (k )] Im[ X ((k )) N ]
2
n 0 N k 0
| X ( k ) |2
Energy spectrum
N
Power spectrum X (k )
2
N
Linear convolution using the DFT
In general, the circular convolution is an aliased version of the
linear convolution.
If we make both x1(n) and x2(n) N=N1+N2-1 point sequences by
padding an appropriate number of zeros, then the circular
convolution is identical to the linear convolution.
N 1
x4 ( n) x1 (n) x2 (n) x1 (k ) x2 ((n k )) N RN (n)
m 0
N 1
x1 (k ) x2 (n k rN ) RN (n)
m 0 r
N1 1
x1 (k ) x2 (n k rN ) RN (n) x3 (n rN ) RN (n)
r m 0 r
Error Analysis
When N=max(N1,N2) is chosen for circular convolution, then
the first (M-1) samples are in error, where M=min(N1,N2).
e(n) x4 x3 x3 (n rN ) RN (n) x3 (n)
r
x3 (n rN ) RN (n) N max( N1 , N 2 )
r 0
e(n) [ x3 (n N ) x3 (n N )]RN (n)
x3 (n N ) 0 n N 1
n=0,1,…(N1+N2-1)-N
X3(n) is also causal
Block Convolution
Segment the infinite-length input sequence into smaller sections (or blocks),
process each section using the DFT, and finally assemble the output sequence
from the outputs of each section. This procedure is called a block convolution
operation.
Let us assume that the sequence x(n) is sectioned into N-point sequence and
that the impulse response of the filter is an M-point sequence, where M<N.
We partition x(n) into sections, each overlapping with the previous one by
exactly (M-1) samples, save at last (N-M+1) output samples, and finally
concatenate these outputs into sequence.
To correct for the first (M-1) samples in the first output block, we set the first
(M-1) samples in the first input blocks to zero.
The Fast Fourier Transform
Although the DFT is computable transform, the
straightforward implementation is very inefficient,
especially when the sequence length N is large.
In 1965, Cooley and Tukey showed the a procedure to
substantially reduce the amount of computations
involved in the DFT.
This led to the explosion of applications of the DFT.
All these efficient algorithms are collectively known
as fast Fourier transform (FFT) algorithms.
The FFT
Using the Matrix-vector multiplication to
implement DFT:
X=WNx (WN: N*N, x: 1*N, X: 1*N)
takes N×N multiplications and (N-1)×N
additions of complex number.
Number of complex mult. CN=O(N2)
A complex multiplication requires 4 real
multiplications and 2 real additions.
Goal of an Efficient computation
The total number of computations should be linear
rather than quadratic with respect to N.
Most of the computations can be eliminated using the
symmetry and periodicity properties
k (n N ) (k N )n
W kn
N W N W N
WNkn N / 2 WNkn
CN=N×log2N
If N=2^10, CN=will reduce to 1/100 times.
Decimation-in-time: DIT-FFT, decimation-in-frequency: DIF-FFT
4-point DFT→FFT example
3
X (k ) x(n)W4nk , 0 k 3; W4 e j 2 / 4 j
n 0
n Ml m, 0 l L 1, 0 m M 1
k p Lq, 0 p L 1, 0 q M 1
Divide-and-combine approach
M 1L 1
X ( p, q ) x (l , m )W ( Ml m )( p Lq )
N
m 0 l 0
M 1
mp L 1 Mlp
WN x(l , m)WN WNLmq
m0 l 0
M 1 mq
mp L 1 lp
Twiddle factor WN x(l , m)WL WM
m0 l 0
L po int DFT
M po int DFT
W8
1
pm mq
( p, q ) F ( p, m) W2
m 0
G (0,0) G (0,1)
G (1,0) G (1,1) W 00 W 01
*
2 2
G (2,0) G (2,1) W 10 W 11
2 2
G (3,0) G (3,1)
Number of multiplications
A 4-point DFT is divided into two 2-point
DFTs, with one intermedium matrix mult.
number of multiplications=
4×4cplx→ 2 ×1+ 1 ×4 cplx 16 →6
A 8-point DFT is divided into two 4-point
DFTs, with one intermedium matrix mult.
8×8→2 ×6 + 2×4 64 →20
For 16-point DFT:
16×16→2 ×20 + 2×8 256 →56
Radix-2 FFT Algorithms
Let N=2v; then we choose M=2 and L=N/2 and divide x(n) into
two N/2-point sequence.
This procedure can be repeated again and again. At each stage
the sequences are decimated and the smaller DFTs combined.
This decimation ands after v stages when we have N one-point
sequences, which are also one-point DFTs.
The resulting procedure is called the decimation-in-time FFT
(DIF-FFT) algorithm, for which the total number of complex
multiplications is: CN=Nv= N*log2N;
using additional symmetries: CN=Nv= N/2*log2N
Signal flowgraph in Figure 5.19
Decimation-in-frequency FFT
In an alternate approach we choose L=2, M=N/2 and
follow the steps in (5.49).
We can get the decimation-frequency FFT (DIF-FFT)
algorithm.
Its signal flowgraph is a transposed structure of the
DIT-FFT structure.
Its computational complexity is also equal to CN=Nv=
N/2*log2N
Matlab Implementation
Function: X = fft(x,N)
If length(x)<N, x is padded with zeros.
If the argument N is omitted, N=length(x)
If x is matrix, fft computes the N-point DFT of each
column of x
It is written in machine languag and not use the
Matlab command. Therefore, it executes very fast.
It is written as a mixed-radix algorithm.
N=2v; N=prime number, it is reduced to the raw DFT.
Fast Convolutions
Use the circular convolution to implement the linear
convolution and the FFT to implement the circular
convolution.
The resulting algorithm is called a fast convolution algorithm.
If we choose N=2v and implement the radix-2 FFT, then the
algorithm is called a high-speed convolution.
If x1(n) is N1-point, x2(n) is N2-point, then
log 2 ( N1 N 2 1)
N 2
Compare the linear convolution and the high-speed conv.
High-speed Block Convolution
Overlap-and-save method
We can now replace the DFT by the radix-2
FFT algorithm to obtain a high-speed overlap-
and-save algorithm.
Discrete Fourier transform
x0 , x1 ,..., x N 1
Maps a set of input
points to another
set of output
DFT points.
N 1 2 The operation is
j ik
X k xi e N reversible.
i 0
X 0 , X 1 ,..., X N 1
Roots of the unity
• What are the Nth roots of unity? (0, j) imaginary
If N = 8 then we have
2 2
j 0 j 1
e 8
,e 8
2 2
j 2 j 3 real
e 8
,e 8
2 2 (-1, 0) (1, 0)
j 4 j 5
e 8
,e 8
2 2
j 6 j 7
e 8
,e 8
2 (0, -j)
j
Define WN e N
Calculating the DFT
N 1 2 N 1
j ik
X k xi e N
xiW N ik
i 0 i 0
X 0 1 1 1 1 ... 1 x0
X 1 W 1
W 2
W 3 N 1
... WN x1
1 N N N
i 0
N / 2 1 2 ( 2 i ) k N / 2 1 2 ( 2 i 1) k
j j
Xk
i 0
x2 i e N
i 0
x2i 1e N
N / 2 1 2ik N / 2 1 2ik
j j
Xk i 0
x2 i e N /2
WNk i 0
x2i 1e N /2
x0 X 0e X0
e
W80
x2 magic X 1 X1
W81
x4 box X 2e X2
W82
x6 X 3e X3
W83
x1 o W84
X 0 X4
5
o W
magic X
8
x3 1 X5
o W86
x5 box X 2 X6
7
x7 o W
X 3
8
X7
Note
WNk N / 2 WNk
that
Now let’s apply the idea recursively
X 0e
x0 X 0ee X0
W40 X 1e W80
x4 X 1ee X1
W41 X 2e W81
x2 X 0eo W42 X2
X e W82
x6 X 1eo 3
3
3
X3
W 4 W8
X 0o W84
x1 X 0oe X4
W40 X 1o W 5
x5 X 1oe 8
W41 X 2o X5
W86
x3 X 0oo X6
W42 o
x7 X W 7
X 1oo 3 8
X7
W43
One more time
x0 X 0ee X 0e
X0
x4 X ee
1
W40 X 1e W80
eo W41 X 2e W81 X1
x2 X 0
W42 X2
x6 X e W82
3
eo X3
X 1 W 4
3
W 8
3
x1 X oe
0 X 0o W84
X4
x5 X oe
1
W40 X 1o W 8
5
X oo W41 X 2o X5
x3 0 W86
W42 X6
x7 X o
W 7
3
oo 3
8
X7
X 1
W 4
• How many operations do we need now?
• What is the execution time on a general purpose CPU?
• What is the execution time on a FPGA? How many resources u need?
Another way to visualize FFT computations
How can we determine the order of the first inputs?
x0 Butte X0
Butte Butte
X4
x4 r r r
x2 fly fly
Butte fly
Butte X2
Butte
x6 r r X6
r
fly fly fly
x1
Butte Butte Butte X1
x5 r r r X5
x3 fly fly fly
Butte Butte Butte X3
x7 r r r X7
fly fly fly
Savings so far …
We have split the DFT computation into two halves:
N 1
X[k] x[n]WN nk
k 0
( N/ 2)1 ( N/ 2)1
x[2r]WN / 2 WN x[2r 1]WNrk/ 2
rk k
Have we gained anything? Consider the nominal number of multiplications for
n0 n0
Original form produces multiplications
New form produces multiplications
SoN 8already ahead ….. Let’s keep going!!
we’re
8 2 64
2(4 2 ) 8 40
Signal flowgraph notation
In generalizing this formulation, it is most convenient to adopt a graphic
approach …
Signal flowgraph notation describes the three basic DSP operations:
Addition
x[n]
x[n]+y[n]
y[n]
Multiplication by a constant a
x[n] ax[n]
Delay
z-1
x[n] x[n-1]
Signal flowgraph representation
of 8-point DFT
X[k] G[k] WNk H[k]
Recall that the DFT is now of the form
The DFT in (partial) flowgraph notation:
Continuing with the
decomposition …
So why not break up into additional DFTs? Let’s take the
upper 4-point DFT and break it up into two 2-point DFTs:
The complete decomposition into
2-point DFTs
Now let’s take a closer look at
the 2-point DFT
The expression for the 2-point DFT is:
1 1
X[k] x[n]W2nk x[n]e j 2nk / 2
n0 n0
Evaluating for k 0,1 we obtain
WNr
WNr N / 2
N /2
Since N 1
W we can reducing computation by 2 by
premultiplying by
WNr 1
WNr 1
Bit reversal of the input
first stages of the 8-point FFT:
Consider the binary representation of the
indices of the input:
natural order
Computing in this fashion means we never have to compute bit
reversal explicitly