ANALOG AND DIGITAL SIGNAL PROCESSING ADSP - Chapter 8 Fm n N fnt ( ) e j2mn N X() X() 2 X() X() 3 W Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2 W W 3 W W x () x () x () 2 x () 3
2 Chapter 8 Discrete Fourier Transform (DFT), FFT Introduction to discrete Fourier transform Time-limited signal made periodic Negative aspect and solution of the periodicity Mathematical approach to the DFT Basic concept DFT application example Fast Fourier transform (FFT) Matrix formulation - Intuitive development Applications Choosing the sampling frequency Windowing - Blind FFT output interpretation Problems Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2
INTRODUCTION TO DISCRETE FOURIER TRANSFORM: Basic concept: In previous chapters, we dealt with the Fourier Series and the Fourier Transforms of continuous waveforms. When it comes to computing one of them from a real signal (continuous or discretized), we face a practical problem: 3 In most situations we exactly know our signal within a time-window starting at t and ending at t 2 ; however, we totally ignore what happened before t and what will happen after t 2. SOLUTION: To make PERIODIC the Time limited signal Example : Signal made Time PERIODIC limited signal with period T (T = t 2 t ) t t 2 Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2
Example cont 2 25 3 35 4 4 2 4 6 8 Decaying sine-wave approximate frequency: Hz ( samples/cycle) 256 samples for period of the periodic signal T = µs 256 = 25.6ms ( 4Hz) Fourier Series coefficient magnitudes: Fseries n 5 Number of samples g Hz khz 2kHz 3kHz 25 4 = Hz (harmonic 24 or 25 multiplied by fundamental frequency) 2 3 4 5 6 7 8 9 n Harmonic number (ts = µs) Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2 4kHz
Magnitude Spectrum after Sampling 2 3 4 5 6 7 8 9 4 Frequency [Hz] fs/2 Potential problems due to the time-limited signal made periodic: Discontinuities Generate unwanted high frequencies components Example 2: 2 256 256 52 5 Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2
Example 3: Pure sine-wave a) Integer number of periods 8 khz sine-wave Acquisition window. 5 4 5 4..5.2 time [s] 6 Sampling frequency: fs =.24 MHz, number of samples: N = 24 Sampled 8kHz sinewave 2 3 4 5 6 7 8 9 samples Sampled 8kHz sinewave 2 3 4 5 6 7 8 9 samples Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2
Example 3: Pure sine-wave b) Non-integer number of periods 7.5 khz sine-wave Tw. 5 4 5 4..5.2 7 Tw: acquisition time window, ts: sampling interval Tw = Fundamental frequency: f = 5 5 5 5 2 25 3 35 4 Magnitude of Fourier Coefficients 8 khz Hn Harmonic number / Tw = fs / N = khz 5 5 N ts = N / fs 7.5 khz 5 5 2 25 3 35 4 Hn Harmonic number Discontinuities in the time-domain many spectral components Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2
SOLUTION: WINDOWING Sampled 7.5kHz sinewave xw n A sin 2 28 n 75.5 cos 2 n 8 24 2 3 4 5 6 7 8 9 samples 2 2 3 4 5 6 7 8 9 8 2 2 3 4 5 6 7 8 9 samples Cosine type window Windowed sampled 7.5kHz sinewave 2 3 4 5 6 7 8 9 samples windowed sampled 7.5 khz sine + period. 2 3 4 Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2 8 6 4 2 Magnitude of Fourier Coefficients g Hn Harmonic number
5 8 g 5 7.5 khz without windowing 6 4 2 7.5 khz with windowing 5 5 2 25 3 35 4 Hn Harmonic number 2 3 4 Hn Harmonic number 9 w(t) window x(t) X x(t) w(t) = xw(t) X(jω) * WINDOWING DOWNSIDE: xw(t) W(jω) = XW(jω) Frequency domain convolution of the window spectrum with the signal spectrum! Broadening of the signal spectrum Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2
MATHEMATICAL APPROACH OF THE DFT Basic concept: If f(t) is our continuous waveform, fd(t) is its discretized version: f(t) fd() t n f( n ts) ( t n ts) Where ts is the time between consecutive samples. By definition, the Fourier Transform of fd(t) is: Ffdt ( ()) Fd( ) n fn ( ts) ( n n ts) e j t dt Fd( ) Previously, we introduced a time-limitation. The simplest way to do this is to set the lower bound of the summation at and the upper bound at N-, thus limiting the total number of samples considered to N. Rewriting Fd() gives: Fdw( ) N n Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2 n fn ( ts) e j nts fn ( ts) e j nts WDFT
The letter W used to characterize this new definition refers to window since our discretized waveform f(n ts) is effectively windowed, that is, multiplied by a time-window function. In order to illustrate the implication of the WDFT, consider a pulse represented by 8 equally spaced samples (N=8): Fdw ( ) 7 n fnts ( ) e j n ts e j ts e j ts e j 2 ts e j 3 ts From this set of samples, we get the following spectrum (with ts = ) : Fdw 2 3 4 5 6 7 n ( ) 4 2 8 6 4 2 2 4 6 8 The periodicity in comes from the sampling theorem (period: 2/ts = s ). Since the theoretical Power Spectrum (from its Fouriertransform)ofapulseexpendfrom- to +, that produces a noticeable aliasing (blue)! Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2
If the initial waveform is artificially made periodic with a period of 8ts, then we can compute the Fourier coefficients by using the definition of the Fourier series. The next figures compare the spectrum obtained by the two approaches: Fourier Series Coefficients and Discrete Fourier Transform. m 2 4 2 Fourier Series 2 3 4 5 6 7 8 It can be easily shown that the Fourier Series Coefficients can be obtained by simply sampling the Discrete Fourier Transform. What is commonly referred to as the Discrete Fourier Transform (DFT) is, in reality, a Discrete- Time Fourier Series (DTFS) derived after transforming a limited number of samples (8 in our example) into a discrete periodic waveform. The fundamental frequency of this new signal is /(N ts). Thus, the spectral lines will appear at m/(n ts) Hz where m is an integer. 4 2 Discrete Fourier Transform Fdw ( ) 2 3 4 5 6 Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2
So finally, we can write the DTFS or DFT in the most common form as: F 2 m N ts Fm ( ) n N fn ( ts) e j2 m n N DFT 3 The inverse DFT is: f( n ts) N m N Fm ( ) e j2 m n InvDFT As already mentioned in the beginning of this chapter, due to the limited number of samples used in the computation of the WDFT, numerous problems can appear that one has to be aware of. N Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2
SIMPLE DFT APPLICATIONS # (integer number of cycle) f(t) = cos(2t) ; a cosine function with a period of s, sampled every ts second, Tw = ts (N-) N = 6, ts = /6 T = s 4 cos 2 t.2.4.6.8 N F m n t j2mn cos2nts N e Tw t n ts F m cos 2nts 5 5 5 5 5 Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2 m n
SIMPLE DFT APPLICATIONS #2 (non-integer number of cycle) f(t) = cos(2t) ; N = 6, ts = /2 Tw =.25s cos 2 t cos 2 nts 5 N F m n.5 j2mn N cos2ntse t Tw F m 5 5 5 5 5 Since the number of periods used to compute the WDFT is not an integer number, a discontinuity in the time domain is created, thus generating artifacts (unwanted high frequencies spectral components) in the power spectrum. In order to solve this problem, various window types have been proposed, each one of them with particular benefits and draw-backs!! The optimum choice will depend upon the features one wishes to emphasize. Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2 n
FAST FOURIER TRANSFORM (FFT) 6 The FFT is simply an algorithm that can compute the discrete Fourier transform much more rapidly than other available algorithms. In the case of the DFT, the approximate number of multiplication grows with the square of N. If Ncanbewrittenas2 K (where K is an integer), a substantial saving can be achieved on the number of multiplication which becomes in the order of : 2Nlog 2 N. Many algorithms have been designed and the interested reader is encouraged to refer to one of the classical text books covering this topic. A simple matrix factoring example is used to intuitively justify the FFT algorithm. Matrix formulation Consider the discrete Fourier transform: 8- Fm ( ) N n j2m n N f ()e n (8-) describes the computation of N equations. Let N = 4 and 8-2 W e 8-3 F ( ) f ( ) W f ( ) W f ( 2) W f ( 3) W F ( ) f ( ) W f ( ) W f ( 2) f ( 3) W 3 F2 ( ) f ( ) W f ( ) f ( 2) W 4 f ( 3) W 6 F3 ( ) f ( ) W f ( ) W 3 f ( 2) W 6 f ( 3) W 9 8-4 j2 mn m N (8-4) reveals that since W and f o (n) are complex matrices, thus N 2 complex multiplication and N (N-) complex additions are necessary to perform the required matrix computation. Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2 F ( ) F ( ) F2 ( ) F3 ( ) W W W W W W W 3 W W 4 W 6 N W W 3 W 6 W 9 f ( ) f ( ) f ( 2) f ( 3)
INTUITIVE DEVELOPMENT To illustrate the FFT algorithm, it is convenient to choose the number of sample points of f o (n) accordingtotherelation N=2,where is an integer. The first step in developing the FFT algorithm for this example is to rewrite (8-4) as: 7 8-5 F ( ) F ( ) F2 ( ) F3 ( ) W W 3 The next step is to factor the square matrix in (8-5) as follows: W W 3 W f ( ) f ( ) f ( 2) f ( 3) 8-7 Matrix Eq. (8-5) was derived from (8-4) by using the relationship W m n = W m n mod(n). Than: 8-6 W 6 = The method of factorization is based on the theory of the FFT algorithm. It is easily shown that multiplication of the two matrices of (8-7) yields the square matrix of (8-5) with the exception that rows and 2 have been interchanged (the rows are numbered,, 2 and 3). F ( ) F2 ( ) F ( ) F3 ( ) Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2 W W W 3 W W f ( ) f ( ) f ( 2) f ( 3)
Having accepted the fact that (8-7) is correct, although the result is scrambled, one should then examine the number of multiplication required to compute the equation. First let: 8-8 f ( ) f ( ) f ( 2) f ( 3) W W f ( ) f ( ) f ( 2) f ( 3) Element f () is computed by one complex multiplication and one complex addition. 8-9 f ( ) f ( ) W f ( 2) 8 Element f () is also determined by one complex multiplication and one complex addition. Only one complex addition is required to compute f (2). This from the fact that W = - ; hence: where the complex multiplication W f (2) has already been computed in the determination of f (). By the same reasoning, f (3) is computed by only one complex addition and no multiplications. The intermediate vector f (n) is then determined by four complex additions and two complex multiplications. Let us continue by completing the computation of (8-7): 8- F ( ) F2 ( ) F ( ) F3 ( ) f 2 ( ) f 2 ( ) f 2 ( 2) f 2 ( 3) 8- W f ( 2) f ( ) f ( 2) f ( ) W f ( 2) W W 3 f ( ) f ( ) f ( 2) f ( 3) Term f 2 () is computed by one complex multiplication and addition! 8-2 f 2 ( ) f ( ) W f ( ) Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2
Element f 2 () is computed by one addition because W =-. By similar reasoning, f 2 (2) is determined by one complex multiplication and addition, and f 2 (3) by only one addition. Thus: - Computation of F(m) by means of Eq. (8-7) requires a total of: - Computation of F(m) by (8-4) requires: four complex multiplication and eight complex additions sixteen complex multiplication and twelve complex additions 9 However, the matrix factoring procedure does introduce one discrepancy. That is: 8-3 Fscrab( m) F ( ) F2 ( ) F ( ) F3 ( ) instead of Fm ( ) This rearrangement is inherent in the matrix factoring process and is a minor problem because it is straightforward to generalize a technique for unscrambling Fscrab(m) and obtain F(m). F ( ) F ( ) F2 ( ) F3 ( ) Thus, if N can be written as 2 K (where K is an integer), a substantial saving can be achieved on the number of multiplication which becomes in the order of : 2Nlog 2 N. Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2
APPLICATIONS # CHOOSING THE SAMPLING FREQUENCY 3dB 2 fs = 5 khz 2 Hz - Hz-2 3dB 2 - -2 2kHz fs = 7.6 khz 2kHz Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2
APPLICATIONS fs = 5 khz, 248 samples (). khz, 5V (sinus) (3) Hz, V (square-wave) #2 WINDOWING No-window after windowing (Hanning) 2 Hz Power Spectrum 4dB 2-2 -4 4kHz Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2
APPLICATIONS #3 ACQUISITION WINDOW (Tw) LENGTH fs = 5 khz, X samples (). khz, 5V (sinus) (3) Hz, V (square-wave) 892 samples 22 248 samples 32768 samples Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2
APPLICATIONS #4 FFT FFT 2 Power Spectrum 3 Hz square-wave, Vpp - sampling frequency : 5 khz 44 e-3 FFT -27dB 2Log FFT 23.9 e-3 FFT 2 7dBm Power Spectrum Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2
APPLICATIONS Consider the following Power Spectrum (red and green): #5 BLIND FFT INTERPRETATION 3Hz 2.5kHz.5kHz What signals produced these spectrums? Chirp (5 Hz 2 khz) + Band-passed filtered (5Hz 2 khz) Gaussian noise 4ms Band-passed filtered (5Hz 2 khz) Gaussian noise 4ms 24 Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2
PROBLEMS Problem 8. In p.8-4, prove that F = 8 Problem 8.2 With f(nt) = (t 5T) and N = 6, determine F m for m < 8 25 Problem 8.3 With N = 8, compute the module, the real and imaginary part of F(m) for m < 4 f() = f(2) = f(4) = f(6) = and f() = f(3) = f(5) = f(7) = - Problem 8.4 (SystemView) The input signal x(t) of an acquisition system has the following form : x(t) = A sin( t) + B Sqw(t), Sqw(t) : symmetrical square-wave of ms period The sampling rate (fs) can be chosen between 5 khz and khz and f is smaller then khz. Draw several possible FFT plots (magnitude) you may obtain when varying the following parameters: fs, N, with and without windowing, f, A/B Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2
PROBLEMS Problem 8.5 (SystemView) The input signal x(t) of an acquisition system has the following form : x(t) = A sin( t) + B sin( t) + C sin( 2 t) + D sin( 3 t) with f = khz, f = f + f, f 2 = f + f, f 3 = f 2 + f, f = 5 Hz A, B C and D can take the following values: + or (constant over the sampling window) Assume that fs = /T = 2 khz, how do you choose N? Problem 8.6 Problem 8.7 26 Chap. 8 Discrete Fourier Transform (DFT), FFT Prof. J.-P. Sandoz, 2-2