Upload
cik-zie-jer
View
220
Download
0
Embed Size (px)
Citation preview
8/13/2019 Lab 5 Long Repot
1/24
Title: TMS320C6713 Fast Fourier Transform (FFT)
1.0 Objectives
At the end of this laboratory, student should able to:
i) Implement FFT using TMS320C6713 DSK.
ii) Analyze the frequency content of signal by implementing FFT on the targeted
DSK through a digital oscilloscope.
iii) Apply Matlab programming and compare the programming result with the
experimental result.
2.0 Equipment
i) TMS320C6713 DSKii) Signal generator
iii) Digital oscilloscope
iv) PC/workstation (installed with Code Composer Studio and Real Time DSP
Training System softwares)
3.0 Safety Guide
i) The DSK board should be handled carefully as some of the modules are very
fragile.
ii) Do not touch on unlikely components or parts (electrostatics energy from the
body might disturb the components attributes)
iii) Always wear the Lab Coat and shoes (fully-covered) when attending the lab
session.
8/13/2019 Lab 5 Long Repot
2/24
4.0 Theory
4.1 Fourier Transform
The Fourier Transform converts signals from a time domain to a frequency
domain. It is the basic method for many sound analysis and visualization algorithms.
Fourier transform can convert many type of signal that made up from sine and cosine
function into magnitudes and phases. The example of Fourier Transform graph is as
shown in the Figure 1 and Figure 2 below. [1]
Figure 1: Analog signal Figure 2: Fourier transform signal
From the Figure 1, we are taking 32 real valued points and the signal is then
undergoes Fourier transform and gets the signal shows in Figure 2. For the Fourier
transform, the plotting only takes consider the magnitude of the signal. The first 16 points
gives the result in Figure 2 while the other 16 points are the mirror image due to the
symmetry analog signal.
Notice spikes at entries 2, 5, and 7, which correlate to the periods of the
components of the input function. The complex value associated to the magnitude at 2 is
-1.3787+2.35648 i. The real and imaginary parts are of similar magnitude and are larger
than surrounding values. The similarity in magnitude is because the phase of the 2 t
component comes from two equal amplitude parts.
The component of the period 5 piece is 2.61789 1.00959 i, where the real and
imaginary parts have slightly more separation in magnitude. This is because the phase of
that part is "less" out of sync with the overall period of the signal. This combination of
magnitude and phase in each output entry gives the "strength" and relationship between
the various frequencies underlying the signal.
8/13/2019 Lab 5 Long Repot
3/24
4.2 Fast Fourier Transform
The fast Fourier transform (FFT) is a discrete Fourier transform algorithm that
reduces the number of computations needed for N points from 2N 2 to 2Nlog 2 N. If the
function that want to be transform in non harmonic frequency, the response of the FFT
will look like a sinc function. Spectrum leakage can happen in FFT but it can be reduce
apodization using apodization function. However, aliasing reduction is at the expense of
broadening the spectral response. [2]
FFTs were first discussed by Cooley and Tukey (1965), although Gauss had
actually described the critical factorization step as early as 1805 (Bergland 1969, Strang
1993). A discrete Fourier transform can be computed using an FFT by means of
the Danielson-Lanczos lemma if the number of points N is a power of two. If the numberof points N is not a power of two, a transform can be performed on sets of points
corresponding to the prime factors of N which is slightly degraded in speed.
The Fast Fourier Transform (FFT) is essentially the high speed implementation of
the DFT. The two approaches for implementing the FFT are decimation in time (DIT)
and decimation in frequency (DIF).
The DIT is:
= 2=
+ ( ) 2=
The DIF is:
= 22 1
=0
+ 22 1
=0
8/13/2019 Lab 5 Long Repot
4/24
The frequency resolution of the FFT and DFT can be calculated by using the
equation below:
= where f res is the frequency resolution of FFT
f s is the sampling frequency
N is the FFT sample size
Calculation of the frequency obtained at the oscilloscope by following the steps below:
FFT sample size, N=1024 samples and sampling frequency, f s=8000 Hz are given
Frequency resolution, f res =
= = 80001024 = 7.8125 Hz
Sampling interval, T s =1
=1
8000 = 0.125 ms
Time duration between 2 peaks = division between 2-peak horizontal time-scale
= 8 divisions 20ms = 96 ms
Sample size between 2 peaks, n = =96
0.125 = 768 samples
Sample size for half peak,2 =
768
2 = 384 samples
Half FFT sample size,2 = 1024
2 = 512 samples
Peak FFT sample size, 512 384 = 128 samples
Peak frequency, f pk = f res 128 samples
= 7.8125 128 = 1000 Hz
4.3 Nyquist Sampling Theorem
Nyquist sampling theorem for digitalization on an analog signal is defined as the
minimum constrain on the sampling frequency of the analog signal. The sampling
frequency is refers to the number of samples that the system needs to process every
second of signal. For a perfect reconstruction, the Nyquist sampling criterion constrains
the minimum sampling rate to be greater than or equal to twice the maximum frequency
content in the signal. [3]
8/13/2019 Lab 5 Long Repot
5/24
In the equation form, Nyquist theorem can be written as:
2 where: f s is sampling frequency
f m is modulation or analog frequency
5.0 Procedures
5.1 Hardware Connectivity:
1) The connection was constructed as shown below in Figure 3.
2) The signal generator was set to sine wave 1000Hz, 2Vp-p. The signal was
monitored at the oscilloscope channel 1.
3) The TMS320C6713 DSK board was connected and the power was turned on.
Figure 3: Hardware connection diagram
5.2 Software Connectivity
Code Compose Studio
1) The DSK CCStudio icon on the workstation was double-clicked.
2) Debug Connect menu was used to establish a connection to DSK board.3)
The Fast Fourier Transform (FFT).pjt Code Compose was opened. It was locatedin the directory C:\CCStudio\real time dsp training system\Fast Fourier Transform
(FFT).
4) The file Fast Fourier Transform (FFT).pjt was chosen by choosing Project Open.
8/13/2019 Lab 5 Long Repot
6/24
Reviewing the Source Code:
1) In the Project View Window, Fast Fourier Transform (FFT).pjt was double-
clicked and the Source Folder was selected in the Project View Window.
2) fft.e file was double-clicked in the Project View to open the source code of the
program.
Build and Run the Program:
1) Project Rebuild all was chosen. All the files in the project were recompiled,reassembled, and relinked by the program. The process was continued only when
the build f rame at the bottom of the window displays message 0 Warning and 0
Error.
2) Fast Fourier Transform (FFT).out file was loaded by selecting File Load
Program. A file browser dialog was opened. Fast Fourier Transform (FFT).out
file was selected in the Debug directory in the file browser and the Open button
was hit to load the executable file. The compiled executable was reloaded every
time changes have been made to the program.
3) Debug Run option wa s selected under the Debug menu to run the program.
4) When the program is indeed running correctly, the program was stopped by
clicking Halt toolbar button on Debug Halt option.
Observation and Results:1) The FFT spectrum of fundamental frequency 1000Hz (at function generator) was
monitored at the digital oscilloscope channel 2. The oscilloscopes horizontal time
scale was set at 20ms (or until get 2 spectrums appeared at the monitor). The
run/stop button at the oscilloscope control panel was pressed and the FFT of the
output spectrum was calculated.
2) The accuracy of the result from channel 2 was compared with the theory from
DFT calculation.
3) The frequency at the signal generator was changed to 2 kHz and 4 kHz. Based on
all the result of this experiment, the fundamental frequency that aliasing
phenomenon occurred was determined. The detail was also explained and
discussed.
8/13/2019 Lab 5 Long Repot
7/24
6.0 Results
1) Fundamental frequency = 1000 Hz
Figure 4: Frequency set 1000Hz at signal generator
Figure 5: Waveform with 1000Hz frequency from signal generator
Figure 6: FFT spectrum at channel 2 in oscilloscope for 1000Hz
8/13/2019 Lab 5 Long Repot
8/24
Calculation of spectrum obtained for fundamental frequency = 1000 Hz
Time division = 20 ms
Amplitude division = 500 mV
FFT sample size, N = 1024 samples
Sampling frequency, f s = 8000 Hz
Frequency resolution, f res =
=8000
1024
= 7.8125 Hz
Sampling interval, T s =1
=
1
8000
= 0.125 ms
Time duration between 2 peaks = no of division time/division
= 4.8 divisions 20ms/div
= 96 ms
Sample size between 2 peaks, n =
=96
0.125
= 768 samples
Sample size for half peak,2 =
768
2
= 384 samples
Half FFT sample size,2 =
1024
2
= 512 samples
Peak FFT sample size, 512 384 = 128 samplesPeak frequency, f pk = f res 128 samples
= 7.8125 128 = 1000 Hz
8/13/2019 Lab 5 Long Repot
9/24
2) Fundamental frequency = 2000 Hz
Figure 7: Frequency set 2000Hz at signal generator
Figure 8: Waveform with 2000Hz frequency from signal generator
Figure 9: FFT spectrum at channel 2 in oscilloscope for 2000Hz
8/13/2019 Lab 5 Long Repot
10/24
Calculation of spectrum obtained for fundamental frequency = 2000 Hz
Time division = 20 ms
Amplitude division = 500 mV
FFT sample size, N = 1024 samples
Sampling frequency, f s = 8000 Hz
Frequency resolution, f res =
=8000
1024
= 7.8125 Hz
Sampling interval, T s =1
=
1
8000
= 0.125 ms
Time duration between 2 peaks = no of division time/division
= 3.2 divisions 20ms/div
= 64 ms
Sample size between 2 peaks, n =
=64
0.125
= 512 samples
Sample size for half peak,2 =
512
2
= 256 samples
Half FFT sample size,2 =
1024
2
= 512 samples
Peak FFT sample size, 512 256 = 256 samples
Peak frequency, f pk = f res 256 samples
= 7.8125 256 = 2000 Hz
8/13/2019 Lab 5 Long Repot
11/24
3) Fundamental frequency = 4 kHz,
Figure 10: Frequency set 4000Hz at signal generator
Figure 11: Waveform with 4000Hz frequency from signal generator
Figure 12: FFT spectrum at channel 2 in oscilloscope for 4000Hz
8/13/2019 Lab 5 Long Repot
12/24
Calculation of spectrum obtained for fundamental frequency = 4000 Hz
Time division = 50 ms
Amplitude division = 500 mV
FFT sample size, N = 1024 samples
Sampling frequency, f s = 8000 Hz
Frequency resolution, f res =
=8000
1024
= 7.8125 Hz
Sampling interval, T s =1
=
1
8000
= 0.125 ms
Time duration between 2 peaks = no of division time/division
= 8.0 divisions 50ms/div
= 400 ms
Sample size between 2 peaks, n =
=400
0.125
= 3200 samples
Sample size for half peak,2 =
3200
2
= 1600 samples
Half FFT sample size,2 =
1024
2
= 512 samples
Peak FFT sample size, 512 1600 = 1088 samplesPeak frequency, f pk = f res 1088 samples
= 7.8125 1088 = 8500 Hz
8/13/2019 Lab 5 Long Repot
13/24
Observation:
Fundamental frequency, f m (Hz) Peak frequency, f pk (Hz)
1000 1000
2000 2000
4000 8500
Table 1: Result obtained
When the fundamental frequency, f m is at 1000 Hz and 2000 Hz, the calculation of the
output spectrum give back the value of the fundamental frequency. But when
fundamental frequency, f m is at 4000 Hz, the calculation of the output spectrum gives
result of 8500 Hz instead of the desired value 4000 Hz.
Therefore this means that the fundamental frequency that aliasing phenomenon occur at
the spectrum is at 4000 Hz.
7.0 Exercise
1) A continuous time signal is defined as = cos 2 1000 + 12
cos 2 2000
i) If the signal is sampled at 8000Hz, what is the suitable sample size for DFT that
can represent both signal components?
Solution:
Sampling frequency, f s = 8000 Hz
Frequency resolution, f res = f 1 f 2
= 2000 1000
= 1000
Sample size, N =
,
, =
8000
1000
= 8
8/13/2019 Lab 5 Long Repot
14/24
ii) Plot the DFT of the signal by using Matlab for N = 16 and N = 32.
Figure 13: Matlab coding to plot DFT
8/13/2019 Lab 5 Long Repot
15/24
Figure 14: Graph obtained for N=16
Figure 15: Graph obtained for N=32
8/13/2019 Lab 5 Long Repot
16/24
2) A discrete-time signal is defined as = cos4
.
i) Calculate he DFT for N = 8 and N = 16.
( ) = cos ( /4)
( ) = [ 4 + 42
]
= 21
=0
= 12 4 +12
4 21
=0
For N = 8,
= 12 4 +12
4 2 881
=0
= 12 2
8(1 )
7
=0
+12
2 8 (1+ )7
=0
= 0 + 1 ( )
For 0 , the function is maximum when 0 = 12
28
(1 )7
=0
0 = 12 2
8(0)
7
=0
0 = 12 17
=0
0 = 82 = 4 This is true if ( 1 ) = 0, thus k = 1.
8/13/2019 Lab 5 Long Repot
17/24
For 1 , the function is maximum when
1 = 12 2
8(1+ )
7
=0
1 = 12 2
8(0)
7
=0
1 = 12 17
=0
1 = 82 = 4This is true if ( 1 + ) = 0, thus k = -1. However, the value -1 is not in the range of
k, 0 k 7. Since the DFT is derived from the DFS that has a period of N = 8.Thus, the value of k = -1 also equal to k = 8-1 = 7.
Substitute k = 7 into 1 ,
1 = 12 2
8(1+7)
7
=0
1 = 12 27
=0
1 = 12 17
=0
1 = 82 = 4Thus, the results shows that the function is maximum at k=7.
For N = 16,
= 12 4 + 12 4 2
16
16
1
=0
= 12 2
8(1 2 )
15
=0
+12
2 8 (1+ 2 )15
=0
= 0 + 1 ( )
8/13/2019 Lab 5 Long Repot
18/24
For 0 , the function is maximum when 0 = 12
28
(1 2 )15
=0
0 =12
2
8(0)
15
=0
0 = 12 115
=0
0 = 162 = 8This is true if ( 1 2 ) = 0, thus k = 2.
For 1 , the function is maximum when 1 = 12
28
(1+2
)15
=0
1 = 12 2
8(0)
15
=0
1 = 12 115
=0
1 = 162 = 8This is true if ( 1 + 2 ) = 0, thus k = -2. However, the value of -2 is not in the range
of k, 0 k 15. Since the DFT is derived from the DFS that has a period of N =16. Thus, the value of k = -2 also equal to k = 16-2 = 14.
Substitute k = 14 into 1 , 1 = 12
28
(1+142
)15
=0
1 = 12 215
=0
1 = 12 115
=0
1 = 162 = 8Thus, the results shows that the function is maximum at to k=14.
8/13/2019 Lab 5 Long Repot
19/24
ii) Plot the DFT by using Matlab.
For N=8 and N=16
Figure 16: Matlab coding to plot DFT
8/13/2019 Lab 5 Long Repot
20/24
Figure 17: Graph obtained for N=8
Figure 18: Graph obtained for N=16
8/13/2019 Lab 5 Long Repot
21/24
3) A continuous time signal is defined as = cos 2 1000 + 12
sin 2 1250
i) If the signal is sampled at 8000Hz, what is the suitable sample size for DFT that
can represent both signal components?
Solution:
Sampling frequency, f s = 8000 Hz
Frequency resolution, f res = f 1 f 2
= 1250 1000
= 250
Sample size, N = ,
,
=8000
250
= 32
ii) Plot the DFT of the signal by using Matlab
Figure 19: Matlab coding to plot DFT
8/13/2019 Lab 5 Long Repot
22/24
Figure 20: Graph obtained for N=16
8.0 Discussions:
1) Discrete Fourier Transform (DFT) decomposes the sequence of values into
components of different frequencies, forming the peaks at the frequency
spectrum displayed at the oscilloscope. DFT can be implemented by using
Digital Signal Processing Processor in hardware experiment or Matlab software
in computer calculation.
2) DFT can be computed efficiently in practice by using FFT (Fast Fourier
Transform) algorithm. Both of these methods are almost same but FFT has
better performance as compared to DFT in its simplicity. Calculation by using
FFT is far more time efficient than DFT therefore FFT is more suitable to be use
when doing experiment in laboratory.
3) In doing experiment which involves hardware, firstly we have to make sure that
the connections between hardware are correct. Connections also have to be
made thoroughly to avoid measurement error and signal leakage.
4) In this experiment, the TMS320C6713 DSK hardware operates according to the
coding in the software. When the coding run, it set the TMS320C6713 DSK to
operates at sampling frequency, f s=8000Hz and number of sample N=1024.
8/13/2019 Lab 5 Long Repot
23/24
5) When the program runs, waveform is obtained on the digital oscilloscope. From
the waveform, peak frequency was calculated as shown in the result. By
comparing the calculation result (peak frequency) and the fundamental
frequency, we can say that at 1000 Hz and 2000 Hz, no aliasing occur. But at
4000Hz, aliasing occur.
6) According to the Nyquist Theorem, f s 2f m where, f s is the sampling frequency
and f m is the maximum frequency of the signal. Aliasing or the overlapping of
the signals will occur if Nyquist rate is not fulfilled.
Using Nyquist Theorem, f s 2f m
8 kHz 2f m
f m4 kHz
Theoretically for sampling frequency f s = 8000 Hz, aliasing will not occur forthe modulation frequency f m = 4000 Hz. But in our experiment, aliasing start to
occur at modulation frequency of 4000 Hz.
7) Although in our experiment we had set our frequency to not exceed 4 kHz and
expecting aliasing should not be occurred, aliasing do occur at 4 kHz. This is
because of the fluctuation of the frequency cause the unstable performance of
the signal. Besides, the value of frequency gives out by the function generator
might not stable as the frequency increase. There might be some tolerance in the
measured value.
8) Aliasing causes different signals to become indistinguishable in sampling. It is
also known as distortion that happens as the signal reconstructed from samples
becomes different from the original continuous signal.
9) From the experiment, it is known that when the sampling frequency increases,
the sample size between two peaks will decrease. This is known by according to
Ts=1/f s.
10) Using Matlab software enables us to do DFT and obtain answer in easier way. It
gives accurate result since the computational done by the computer.
11) For the signal that has more than one frequency, we need to determine the
suitable number of sample N. This is to avoid spectrum leakage to occur in our
DFT graph.
8/13/2019 Lab 5 Long Repot
24/24
9.0 Conclusion
After completing the lab session, students were able to implement FFT using
TMS320C6713 DSK. The method of obtaining the output waveform can be demonstrate
and explained. Besides that, students are also able to analyze the frequency content by
implementing FFT on the targeted DSK through a digital oscilloscope. It can be conclude
that the sampling frequency should be at least twice the modulation frequency to avoid
aliasing occur as stated in the Nyquist sampling theorem. Lastly, Matlab program was
applied to obtain result for any DFT problem.
10.0 Reference
[1] L, Christ. Introduction , The Fast Fourier Transform , pp. 1-2, 2010
[2] W. Eric, Fast Fourier Transform , (MathWorld A Wolfram Web Resources),[online], http://mathworld.wolfram.com/FastFourierTransform.html (Accessed:
2 September 2013).
[3] A. K. Shoab, Sampling Rate Consideration , Digital Design of Signal
Processing Systems: A Practical Approach , United Kingdom: Wiley, 2011, pp.
7-45
http://mathworld.wolfram.com/FastFourierTransform.htmlhttp://mathworld.wolfram.com/FastFourierTransform.html