Lab 5 Long Repot
Lab 5 Long Repot
Lab 5 Long Repot
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.
ii) 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.
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]
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.35648i. 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.
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 2N2 to 2Nlog2N. 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 number of 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).
2 +
()
=
=
=0
2 +
1 2
=0
The frequency resolution of the FFT and DFT can be calculated by using the equation below: = where fres is the frequency resolution of FFT fs 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, fs=8000 Hz are given Frequency resolution, fres =
8000
= = 1024 = 7.8125 Hz
Time duration between 2 peaks = division between 2-peak horizontal time-scale = 8 divisions 20ms = 96 ms Sample size between 2 peaks, n = Sample size for half peak, 2 = Half FFT sample size, 2 =
2 768 2 96 0.125
= 768 samples
= 384 samples
1024
= 512 samples
Peak FFT sample size, 512 384 = 128 samples Peak frequency, fpk = fres 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]
In the equation form, Nyquist theorem can be written as: 2 where: fs is sampling frequency fm 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.
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 located in the directory C:\CCStudio\real time dsp training system\Fast Fourier Transform (FFT). 4) The file Fast Fourier Transform (FFT).pjtwas chosen by choosing Project Open.
Reviewing the Source Code: 1) In the Project View Window, Fast Fourier Transform (FFT).pjt was doubleclicked 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 frame 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 was 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.
Time division = 20 ms Amplitude division = 500 mV FFT sample size, N = 1024 samples Sampling frequency, fs = 8000 Hz Frequency resolution, fres =
8000
= 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
= 512 samples Peak FFT sample size, 512 384 = 128 samples Peak frequency, fpk = fres 128 samples = 7.8125 128 = 1000 Hz
Time division = 20 ms Amplitude division = 500 mV FFT sample size, N = 1024 samples Sampling frequency, fs = 8000 Hz Frequency resolution, fres =
8000
= 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
= 512 samples Peak FFT sample size, 512 256 = 256 samples Peak frequency, fpk = fres 256 samples = 7.8125 256 = 2000 Hz
Time division = 50 ms Amplitude division = 500 mV FFT sample size, N = 1024 samples Sampling frequency, fs = 8000 Hz Frequency resolution, fres =
8000
= 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
= 512 samples Peak FFT sample size, 512 1600 = 1088 samples Peak frequency, fpk = fres 1088 samples = 7.8125 1088 = 8500 Hz
Observation: Fundamental frequency, fm (Hz) 1000 2000 4000 Table 1: Result obtained Peak frequency, fpk (Hz) 1000 2000 8500
When the fundamental frequency, fm 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, fm 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.
cos 22000
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, fs = 8000 Hz Frequency resolution, fres = f1 f2 = 2000 1000 = 1000 Sample size, N = = 1000 =8
8000 , ,
ii) Plot the DFT of the signal by using Matlab for N = 16 and N = 32.
2) A discrete-time signal is defined as = cos i) Calculate he DFT for N = 8 and N = 16. () = cos (/4) () = [ =
=0 1
4
+ 4 ] 2
2
=
=0
1 1 2 4 + 4 2 2
For N = 8,
81
=
=0
1 1 2 8 4 + 4 2 2
7
1 = 2
=0
2 (1 ) 8
1 + 2
=0
2 (1+ ) 8
=0 7
2 (1 ) 8
=0 7
2 (0) 8
1
=0
=4
=0 7
2 (1+ ) 8
=0 7
2 (0) 8
1 1 = 2
8 2
1
=0
1 = = 4 This 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 1 = 2 1 1 = 2
7
=0 7
2 (1+7) 8
2
=0 7
1 1 = 2
8
1
=0
For N = 16,
161
=
=0
1 1 2 4 + 4 16 2 2
2 (1 ) 8 2
1 = 2
15
=0
1 + 2
15
=0
2 (1+ ) 8 2
= 0 + 1 ()
=0 15
2 (1 ) 8 2
=0 15
2 (0) 8
1 =8
=0 16 2
=0 15
2 (1+ ) 8 2
=0 15
2 (0) 8
1 2
2
1
=0
16
=8
This 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 1 = 2 1 = 1 = 1 = 1 2
15
=0 15
2 14 (1+ ) 8 2
2
=0 15
1 2
2
1
=0
16
=8
ii) Plot the DFT by using Matlab. For N=8 and N=16
1 2
sin 21250
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, fs = 8000 Hz Frequency resolution, fres = f1 f2 = 1250 1000 = 250 Sample size, N = =
, , 8000 250
= 32
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, fs=8000Hz and number of sample N=1024.
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. According to the Nyquist Theorem, fs 2fm where, fs is the sampling frequency and fm 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, fs 2fm 8 kHz 2fm fm4 kHz Theoretically for sampling frequency fs = 8000 Hz, aliasing will not occur for the modulation frequency fm = 4000 Hz. But in our experiment, aliasing start to occur at modulation frequency of 4000 Hz.
6)
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/fs.
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.
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