fft2 algorithm

Upload: minh-nhat

Post on 03-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/28/2019 FFT2 Algorithm

    1/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien

    1

    DISCRETE FOURIER TRANSFORM (DFT)

    AND FAST FOURIER TRANSFORM (FFT)

    ALGORITHM

    Lectured by Assoc Prof. Dr. Thuong Le-Tien

    DIGITAL SIGNAL PROCESSING

  • 7/28/2019 FFT2 Algorithm

    2/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien

    2

    1. Frequency resolution and windowing

    Spectrum of sampled analog signal

    But if the replicas overlap they will contribute to the right hand side of spectrum

    In terms of the time samples x(nT), the original sampled spectrum

    and its time-windowed version are given by:

    )( fX

    )( fXL

  • 7/28/2019 FFT2 Algorithm

    3/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien

    3

    Rectangular window of length L

    Then define the windowed signal

    The DTFT of windowed signal is

    Where W( ) is the DTFT of the rectangular window w(n)

  • 7/28/2019 FFT2 Algorithm

    4/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien

    4

    Setting W(n) = 1

    Magnitude spectrum

    of rectangular window

    Rectangular window width

  • 7/28/2019 FFT2 Algorithm

    5/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien

    5

  • 7/28/2019 FFT2 Algorithm

    6/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien

    6

    These equation can be rewritten to give the minimum number of samples required

    To achieve a desired freq resolution f. The smaller the desired separation, theLonger the data record

    The Hamming window

    At its center, n=(L-1)/2, the value of w(n) is 0.54+0.46 = 1, and at its endpoint,

    n=0 and n=L-1, its value is 0.54-0.46 = 0.08

    For any type of window, the effective of the

    mainlobe is inversely proportional to L

    c is a constant and always c=>1

    Frequency resolution

  • 7/28/2019 FFT2 Algorithm

    7/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien

    7

    Hamming window in the time and frequency domain

    The minimum resolvable frequency difference

  • 7/28/2019 FFT2 Algorithm

    8/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien

    8

    Example:

    A signal consisting of four sinusoids of frequencies of 1, 1.5, 2.5, and 2.75kHz, is sampled at a rate of 10 kHz. What is the minimum number of

    samples that should be collected for the frequency spectrum to exhibit four

    distinct peaks at these frequencies? How many samples should be collected

    if they are going to be preprocessed by a Hamming window and then Fourier

    transformed?

    Solution:

    The smallest frequency separation that must be resolved by the DFT is

    f = 2.75-2.5=0.25 kHz, for rectangular window:

    Because the mainlobe width of the Hamming window is twice as wide as

    that of the rectangular window, it follows that twice as many samples must

    be collected, that is L=80 then c can be calculated to be c=2

  • 7/28/2019 FFT2 Algorithm

    9/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien

    9

    Example:

    A 10ms portion of a signal is sampled at a rate of 10kHz. It is known

    that the signal consists of two sinusoids of frequencies f1=1kHz and

    f2=2khz. It is also known that the signal contains a third component

    of frequency f3 that lies somewhere between f1 and f2.a. How close to f1 could f3 be in order for the spectrum of the collected

    samples to exhibit three distinct peak? How close to f2 could f3 be?

    b. What are the answers if the collected samples are windowed by a

    Hamming window?

    Solution:

    The total number of samples collected is L= fsTL =10x10=100.

    The frequency resolution of the rectangular window is

    f = fs/L = 10/100 = 0.1kHz

    Thus the closest f3

    to f1

    and f2

    will be

    f3 = f1 + f = 1.1kHz and f3 = f2 - f = 1.9kHz

    In the hamming case, the minimum resolvable frequency separation doubles,

    That is,

    f = cfs/L = 2.10/100 = 0.2kHz which give f3 = 1.2kHz or f3 = 1.8kHz

  • 7/28/2019 FFT2 Algorithm

    10/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien

    10

    2. DTFT computation

    2.1. DTFT at a single frequency

    Rectangular and hamming windows with L=40 and 100

    DTFT of length-L signal

  • 7/28/2019 FFT2 Algorithm

    11/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien

    11

    Equivalent Nyquist Interval

    2.2. DFT over frequency range: Compute DFT over

  • 7/28/2019 FFT2 Algorithm

    12/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien

    12

    2.3. DFT

    The N points DFT of a L-length signal defined the DFT frequency as follows,

    The only difference between DFT and DTFT is that the former has its N

    frequencies distributed evenly over the full Nyquist interval [0, 2 ) whereas

    the later has them distributed over any desired subinterval.

  • 7/28/2019 FFT2 Algorithm

    13/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien

    13

    Evaluation of z-transform

    Nth roots of unity for N=8

    The periodicity of X( ) with a period of 2 or

    DFT X(k)=X( k) in the index k with period N

    N-point DTFTs over [0,2 ) and over subinterval [ a, b), for N=10

  • 7/28/2019 FFT2 Algorithm

    14/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien

    14

    2.4. Zeros padding

    Note that evaluation at the N frequencies DFT are the same for the cases of padding

    D zeros at front or delay D samples

  • 7/28/2019 FFT2 Algorithm

    15/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien

    15

    The DTFT and DFT

    2.5. The matrix form of DFT

    Denoted

    Where the matrix components

    defined by twiddle factors

    (matrix form of DFT)

  • 7/28/2019 FFT2 Algorithm

    16/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien

    16

    The twiddle factor defined by

    For example: L=N and N=2, 4, 8

    The corresponding 2-point and 4-point DFT matrices are:

  • 7/28/2019 FFT2 Algorithm

    17/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien

    17

    And the 2-point and 4ponit DFT of a length 2 and length 4 signals will be

    Thus, the 2-point DFT is formed by taking the sum and difference of the two time

    Samples. It will be a convenience starting point for the merging in FFT by hand.

  • 7/28/2019 FFT2 Algorithm

    18/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien

    18

    Twiddle factor look up tables for N=2, 4, 8

    5. Modulo N reduction

    Example L=4N

  • 7/28/2019 FFT2 Algorithm

    19/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien

    19

    Example: Determine the mod-4 and mod-3 reduction of the length-8 signal vector

    For N=4 and N=3

    For n=0, 1, 2, , N-1

  • 7/28/2019 FFT2 Algorithm

    20/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien

    20

    Periodic extension interpretation of mod-N reduction of a signal

    The connection of the mod-N reduction to the DFT is the theorem that the

    Length-N wrapped signal x~ has the same N-point DFT as the originalUnwrapped signal x, that is:

  • 7/28/2019 FFT2 Algorithm

    21/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien

    21

    The DFT matrices A and A~ have the same definition, except they differ in

    their dimensions, which are NxL and NxN, respectively. We can write the

    DFT of x~ in the compact matrix form:

    In general A is partitioned in the form:

  • 7/28/2019 FFT2 Algorithm

    22/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien

    22

  • 7/28/2019 FFT2 Algorithm

    23/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien 23

    N-point DFTs of the full and wrapped signal are equivalent

  • 7/28/2019 FFT2 Algorithm

    24/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien 24

    Example: Compute the 4-point DFT of the length-8 signal in two way: (a) working

    With the full unwrapped vector x and (b) computing the DFT of its mod-4 reduction

    Solution: The corresponding DFT is

    The same DFT can be computed by the DFT matrix x~ acted on the wrapped signal x~

    The two methods are the same

  • 7/28/2019 FFT2 Algorithm

    25/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien 25

    6. Inverse DFTThe problem for inverse DFt is the length L of signal greater than N-point DFT,

    i.e. the matrix A is not invertible

    The inverse DFT defined by

    Where IN is the N-dimensional identity matrix and is the complexconjugate of , obtained by conjugating every matrix element of .

    For example, for N=4, we can verify easily:

    *~A

    A~A~

  • 7/28/2019 FFT2 Algorithm

    26/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien 26

    Similar for FFT

    Example for an inverse 4-point DFT

  • 7/28/2019 FFT2 Algorithm

    27/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien 27

    Therefore the alternative form of IDFT

    DFT and IDFT

    In term of the DFT frequencies k , we have Xk = X( k ) and

  • 7/28/2019 FFT2 Algorithm

    28/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien 28

    7. Sampling of periodic signals and DFT

    Discrete Fourier series (DFS)

    X~ is periodic in n with period N

    Sampling rate is a multiple of the fundamental frequency of signal

    Taking the Nyquist interval to be the right-sided one [0, fs], we note that

    harmonics within that interval are none other than the N DFT frequencies

  • 7/28/2019 FFT2 Algorithm

    29/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien 29

    Given an integer m, we determine its quotient and reminder of the division

    And therefore the corresponding harmonic will be

    Defining the aliased Fourier series amplitudes

  • 7/28/2019 FFT2 Algorithm

    30/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien 30

    If the sampled signal x(nT) be reconstructed by an ideal reconstructor,

    the aliased analog waveform is

    Example: determine the aliased signal xal(t) resulting by sampling a square

    Wave of frequency f1=1 Hz. For a sampling rate of fs = 4Hz, consider one period

    Consisting of N=4 samples and perform its 4-point DFT

    The Fourier coefficients:

    Corresponding to the harmonic

    Where f3 = 3 was replaced by its negative version f3-fs = 3-4 = -1. It follows thatthe aliased signal will be

  • 7/28/2019 FFT2 Algorithm

    31/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien 31

    Similarly, for N=8 corresponding to fs=8 Hz, we perform the 8-point DFT of one

    period of the square wave, and divide by 8 to get the aliased amplitudes

    These amplitudes corresponding to the frequencies fk = k f1

  • 7/28/2019 FFT2 Algorithm

    32/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien 32

    8. Fast Fourier Transform FFT

    Is a fast implementation of DFT. It is based on a divide and conquer

    approach in which the DFT computation is divided into smaller, simpler,

    problems and the final DFT is rebuilt from the simpler DFTs.

    It is required the initial dimension of N to be power of two

    The problem of computing the N-point DFT is replaced by the simpler problems

    Of computing two (N/2)-point DFT. Each of these is replaced by two (N/4)-point

    DFTs , and so on.

  • 7/28/2019 FFT2 Algorithm

    33/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien 33

    The summation index n ranges over both even and odd values in the range

    [0,N-1]. By grouping the even-indexed and odd-indexed terms, we get

    To determine the proper range of summation over n, we consider the twoTerms seperately. For even-indexed terms, the index 2n must be within the

    range [0,N-1]. But, because N is even (a power of two), the upper limit

    N-1 will be odd. Therefore, the highest even index will be N-2,

    12/0220 NnNn

    Similarly, for the odd-indexed terms, we must have

    1120 Nn

    12/02201121 NnNnnn

  • 7/28/2019 FFT2 Algorithm

    34/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien 34

  • 7/28/2019 FFT2 Algorithm

    35/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien 35

  • 7/28/2019 FFT2 Algorithm

    36/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien 36

    The butterfly merging builds

    upper and lower halves of length-N DFT

  • 7/28/2019 FFT2 Algorithm

    37/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien 37

    and N=8

  • 7/28/2019 FFT2 Algorithm

    38/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien 38

    The typical algorithm consists of three conceptual parts:

    1. Shuffling the N-dimensional input into N one-dimensional signals

    2. Performing N one-point DFTs

    3. Merging the N one-point DFTs into one N-point DFT

  • 7/28/2019 FFT2 Algorithm

    39/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien 39

  • 7/28/2019 FFT2 Algorithm

    40/41

    DSP lectured by Assoc. Prof. Dr.Thuong Le-Tien 40

    Example: Using FFT algorithm, compute the 4-point wrapped signal

    (5, 0, -3, 4)

    Solution:

    The DFT merging stage merges the two 2-DFTs into the final 4-DFT

  • 7/28/2019 FFT2 Algorithm

    41/41

    DSP l t d b A P f D 41

    Example: Using FFT algorithm, compute 8-point DFT of the 8 point signal