DSP Report Lab3 Official
DSP Report Lab3 Official
1. ABSTRACT.................................................................................................................1
2. INTRODUCTION.......................................................................................................1
3. DISCRETE FOURIER TRANSFORM.....................................................................1
4. MATLAB CODE TO SKETCH CONTINUOUS SIGNAL X(t) AND
CALCULATE DFT/FFT OF X(t)..............................................................................2
5. MATLAB CODE TO SKETCH DISCRETE SIGNAL X(n) AND CALCULATE
DFT/FFT OF X(n).......................................................................................................4
6. C++ PROGRAM TO CALCULATE 128-DFT/FFT OF X(n), X(t) AND
EXPORT AS DAT FILE.............................................................................................6
7. MATLAB CODE TO SKETCH THE RESULT OF C5515/35-BASED
SIMULATION AND COMPARE WITH RESULT FROM MATLAB BASED
SIMULATION.............................................................................................................8
8. CONCLUSION............................................................................................................9
9. REFERENCE...............................................................................................................9
1. ABSTRACT:
This report outlines steps to generate and calculate 128 - DFT of a given signal using
TMS320C5515 eZDSPTM USB Stick Development Tool. The report includes a
Matlab-based demonstration and hardware-based programming. The two outcomes
are also analyzed and compared.
2. INTRODUCTION
LCD of TMS320C5515/35 is a 96x16 OLED display screen which has 96 columns and
16 rows. The display screen is divided into two regions, so actually we have two 96x8
to display a text.
To know about how to use the OLED, we refer to the existing samples code in the lcd-
osd9616 project, which include the code for the oled. The changes are mainly come
from the oled_test.c source code. Further information about how to configure the LCD
modules is from the pdf file which was downloaded by follow the link written on the
board during lab 2. This SSD1306 driver allow us to:
The DFT can be computed efficiently in practice using a fast Fourier transform
(FFT) algorithm.
FFT algorithms are so commonly employed to compute DFTs that the term "FFT" is
often used to mean "DFT" in colloquial settings. Formally, there is a clear distinction:
"DFT" refers to a mathematical transformation or function, regardless of how it is
computed, whereas "FFT" refers to a specific family of algorithms for computing DFTs.
In this lab session, we will generate and calculate 128-DFT of the following signal:
x=3*sin(100*pi*t)+2*sin(250*pi*t)
Using Matlab, TMS320C5515 eZDSPTM USB Stick Development Tool. Then, the results
of Matlab and C5515 are compared.
2
4. MATLAB CODE TO SKETCH CONTINUOUS SIGNAL X(t)
AND CALCULATE DFT/FFT OF X(t):
Based on the above techniques, we have designed matlab code to sketch CT signal
X1,X2 to calculate Y1,Y2
x=3*sin(100*pi*t)+2*sin(250*pi*t);
%sketch the signal
figure(1);
plot(t,x);
ylabel('Amplitude');
xlabel('Time');
%take 128-FFT of the given signal
X=fft(x,128);
X=fftshift(X);
%sketch the FFT
f = (0:127)*(1000/128);
figure(2);
stem(f,abs(X));
ylabel('Amplitude');
xlabel('Frequency');
4.2. Result:
CT of signal x(t)
3
128-DFT/FFT of x(t):
4
5.2. Result
DT signal of x(n)
128-DFT/FFT of x(t)
5
6. C++ PROGRAM TO CALCULATE 128-DFT/FFT OF X(n), X(t) AND EXPORT
AS DAT FILE
C Code:
// C program for the above approach
#include <math.h>
#include <stdio.h>
// Driver Code
int main()
{
FILE *fileout1; fileout1=fopen("C:\Users\skyle\Desktop\
lab3.dat ","w+"); int len ;
printf("Input the length of "
"the sequence: ");
scanf("%d4", &len);
float xn[len];
float Xr[len];
float Xi[len];
int i, k, n, N ;
N=128;
6
float pi=3.14159265;
for (i = 0; i < len; i++) {
xn[i]=3*sin(100*pi*i/400)+2*sin(250*pi*i/400);
}
for (k = 0; k < N; k++) {
Xr[k] = 0;
Xi[k] = 0;
for (n = 0; n < len; n++) {
Xr[k]
= (Xr[k]
+ xn[n] * cos(2 * 3.141592 * k * n / N));
Xi[k]
= (Xi[k]
- xn[n] * sin(2 * 3.141592 * k * n / N));
}
fprintf(fileout1,"%f + %fi\n",Xr[k], Xi[k]);
printf("%f + %fi\n", Xr[k], Xi[k]);
}
fclose(fileout1);
return 0;
}
7
7. MATLAB CODE TO SKETCH THE RESULT OF C5515/35-BASED
SIMULATION AND COMPARE WITH RESULT FROM MATLAB BASED
SIMULATION
We use Matlab code to get data from lab4.dat file and sketch the C5515/35-based
simulation
7.2. Matlab Code:
clear ;
test = importdata("C:\Users\skyle\Desktop\lab3.dat");
V = str2double(test);
% subplot(2,1,2);
f =(0:127)*(400/128);
stem(f,abs(V));
ylabel('Amplitude');
xlabel('Frequency');
7.3. Result:
8
8. CONCLUSION
The results of the two simulations are identical.
Through this practice, we learned how to generate given signal samples for a given Fs.
This helps us better understand how an arbitrary signal is sampled. The results are almost
identical. We also know that sample rate affects the results, each result with a different
sample rate has a different form. The cause may be due to mismatched sampling frequency, a
sine wave is sampled at different positions during its different periods.
9. REFERENCE
[1] Texas Instruments, C5515 eZDSP USB Stick Development Tool description and features,
http://www.ti.com/tool/tmdx5515ezdsp
[2] MATLAB TUTORIAL - DISCRETE FOURIER TRANSFORM (DFT),
https://www.bogotobogo.com/Matlab/Matlab_Tutorial_DFT_Discrete_Fourier_Transform.php