0% found this document useful (0 votes)
2 views

Experiment 15

The document outlines an experiment to implement the Discrete Fourier Transform (DFT) using the DSK6713 and MATLAB. It includes objectives, a detailed procedure for setting up the project in Code Composer Studio, and code for the DFT implementation. Additionally, it provides assignments for calculating the DFT of specific data sequences and verifying results using MATLAB.

Uploaded by

Fiza Ali
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Experiment 15

The document outlines an experiment to implement the Discrete Fourier Transform (DFT) using the DSK6713 and MATLAB. It includes objectives, a detailed procedure for setting up the project in Code Composer Studio, and code for the DFT implementation. Additionally, it provides assignments for calculating the DFT of specific data sequences and verifying results using MATLAB.

Uploaded by

Fiza Ali
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Experiment # 15

Title: Implementation of Discrete Fourier Transform (DFT) using


DSK6713 and DISPLAY the waveforms

Equipment Required: Personal computer (PC) with windows operating system


and MATLAB software
Objective:
The objective of this lab is to implement Discrete Fourier Transform on DSK 6713
Introduction:
Figure 2 shows a listing of the program DFT.c, which implements the DFT. The input
sequence is x(n). The program calculates
N−1
X ( k )=DFT {x (n)}= ∑ x (n )e−2 π nk/ N k = 0,1,2, .. . .. .. . .. N-1
n=0 ……………(1)

This can be decomposed into a sum of real components and a sum of imaginary components,

Let

1 − j2 π kn/N − j2 π kn/N
= (e )
− j2 π kn/ N
e +e
2
1
¿ ( e− j2 π kn/ N +e− j 2 π kn/ N +e j 2 π nk/ N −e j2 π kn/N )
2
1 1
¿ ( e + j 2 π kn/N +e− j 2π kn/N ) − (e j2 π kn/ N −e− j2 π kn/N )
2 2
where
1 1 1
cos(w )= (e jw +e− jw ) and sin( w )= (e jw−e− jw )⇒ j sin( w)= (e jw −e− jw )
2 2j 2
− j2 π kn/ N
e =cos(2 π kn / N )− j sin(2 π kn /N )
Eq (1) can be re written as:
N−1
X ( k )=DFT {x (n)}= ∑ x (n ) ( cos(2 π kn/ N )− j sin(2 π kn/ N ) ) k = 0,1,2,. . .. .. . .. . N-1
n=0
Or
N −1
Re {X (k )}= ∑ x (n)cos(2 π kn /N )
n=0
And
N−1
Im {X (k )}= ∑ x (n )sin (2 π nk / N )
n=0

Procedure:
1. To create the project file. Select Project  New. Type DFT for the project name. This
project file is saved in the folder DFT (within D:\program files\myprojects).

Figure -1 Code Composer Studio project creation Window

2. To add files to the project. Select Project  Add Files to Project. Look in the folder
support, Files of type Linker command files. Double-click on the Linker command file
C6713dsk.cmd to add it to the project. Click on the “+” symbol to the left of the Project
Files window within CCS to expand and verify that this Linker command file has been
added to the project.
3. Select File  New  Source File. This will open CCS editor, type the following
program in it and save it, in folder D:\program files\myprojects\DFT with
name DFT.C.

Discrete Fourier Transform program (DFT.c).


______________________________________________________________________________
//DFT.c DFT of N-point from lookup table. Output from watch window

#include <stdio.h>
#include <math.h>
void dft(short *input, short k, float *out,float *outim);//function
prototype
#define N 6 //number of data
values
float pi = 3.1416;
int j;
short input[N] = {1,1,2,2,3,3};

float out[6] = {0,0,0,0,0,0}; //init Re and Im


results
float outim[6] = {0,0,0,0,0,0};
void dft(short *input, short k, float *out,float *outim) //DFT
function
{
float sumRe = 0, sumIm = 0; //init real/imag
components
float cs = 0, sn = 0; //init cosine/sine
components
int i = 0;
for (i = 0; i < N; i++) //for N-
point DFT
{
cs = cos(2*pi*(k)*i/N); //real component
sn = sin(2*pi*(k)*i/N); //imaginary component
sumRe = sumRe + input[i]*cs; //sum of real components
sumIm = sumIm - input[i]*sn; //sum of imaginary components
}
out[k] = sumRe; //sum of real components
outim[k] = sumIm; //sum of imaginary components
}

void main()
{
int j;
while(1)
{
for (j = 0; j < N; j++)
{
dft(input,j,out,outim); //call DFT function
}
}
} _______________________________________________________________________________________________________________

FIGURE 2. DFT implementation program with input from a lookup table (DFT.c).

4. Add C source file DFT.c to the project.


5. Compiler Option
Select Project  Build Options. Figure 2.4a shows the CCS window Build Options
for the compiler.
I. Select the following for the compiler option with Basic (for Category):
a) c671x{-mv6710} (for Target Version),
b) Full Symbolic Debug (for Generate Debug Info),
c) Speed most critical (for Opt Speed vs. Size),
d) None (for Opt Level and Program Level Opt).
II. Select the Preprocessor Category and type for Define Symbols{d}: CHIP_6713
III. Select the Files Category and type for Obj Directory(-fr) D:\Program
files\My Projects\DFT\Debug

Figure-3 CCS Build options: compiler.

6. Linker Option
Click on Linker (from CCS Build Options).
I. Select the following for the compiler option with Basic (for Category):
a) Select Suppress banner
b) Select Exhaustively Read Library
c) For Output Filename (-o) type .\Debug\DFT.out
d) For Map Filename (-o) type .\Debug\DFT.map
e) For Autoinit Model: Select Run-Time Autoinitialization(-c)
f) For include Libraries type rts6700.lib
II. Click on the Advanced options
a) De-select Warn About Output Sections(-w)

Figure-4 CCS Build options: linker.

7. Building and Running the Project


I. Select Project  Rebuild All or press the toolbar with the three down arrows .
This creates an executable file DFT.out that can be loaded into the C6713 processor
and run. Note that the commands for compiling, assembling, and linking are
performed with the Build option. A log file cc_build_Debug.log is created that
shows the files that are compiled and assembled, along with the compiler options
selected. It also lists the support functions that are used.
II. Select File  Load Program in order to load DFT.out by clicking on it (CCS
includes an option to load the program automatically after a build). It should be in
the folder DFT\Debug. Select Debug  Run or use the toolbar with the “running
man.”
8. Monitoring the Watch Window
Select View  Quick Watch window, which should be displayed on the lower section of
CCS. Type input, then click on “Add to Watch.” This will display the input sequence on
which the DFT is to be performed.

Figure 5 CCS Quick Watch Dialog for input sequence

Again Select View  Quick Watch window, Type out, then click on “Add to
Watch.” This will display the real part of the output vector.

Figure 6 CCS Quick Watch Dialog for real part of output vector

Again Select View  Quick Watch window, Type outim, then click on “Add to
Watch.” This will display the imaginary part of the output vector.
Figure 7 CCS Quick Watch Dialog for imaginary part of output vector
Right click on the quick watch window and select the option Float in Main Window.

And maximize the window


Assignment#1

Calculate the DFT of the sample data sequence x(n) = {1, 2, 3, 4, 5, 6}

(i) Using Code Composer Studio

(ii) Verify the result using MATLAB.

Assignment#2

Calculate the DFT of the sample data sequence x(n) = {1, -1, 2, 1, -1, 3}

(i) Using Code Composer Studio

(ii) Verify the result using MATLAB.

Reference:

(1) Introduction to Analog and Digital Communication (Simon Haykin, Michael Moher)
(2) Digital Signal Processing and Applications with the C6713 and C6416 DSK (Rulph
Chassaing)

You might also like