DSP Lab Manual
DSP Lab Manual
DSP Lab Manual
4.
3.Code of conduct
All students must observe the Dress Code while in the laboratory.
Students who turn up late to the labs will in no case be permitted to perform the
experiment scheduled for the day.
After completion of the experiment, certification of the staff in-charge concerned in the
observation book is necessary.
All students are responsible for the damage (caused if any) of equipment/work
benches/computing system.
Students are strictly PROHIBITED from taking out any items from the laboratory.
Students are NOT allowed to work alone in the laboratory without the Lab Supervisor.
Students should be present in the labs for the total scheduled duration.
Students are expected to prepare thoroughly to perform the experiment before coming to
Laboratory.
Turn off the power supply of the work bench or shut down the computing system.
Please check the laboratory notice board regularly for updates regarding lab sessions.
4.Precautions
1.
Select your HDL File before you simulate and synthesize Using Xilinx /any
equivalent tool.
2.
Check JTAG cable connections to down load design to the Target device on
FPGA/CPLD demo board.
3.
4.
5.
5.List of Experiments
The programs shall be implemented in software (Using MATLAB / Lab view / C programming/ OCTAVE
Equivalent) and hardware (Using TI / Analog devices / Motorola / Equivalent DSP processors).
1. Generation of Sinusoidal waveform / signal based on recursive difference equations
2. To find DFT / IDFT of given DT signal
3. To find frequency response of a given system given in (Transfer Function/ D.E form).
4. Implementation of FFT of given sequence
5. Determination of Power Spectrum of a given signal(s).
6. Implementation of LP FIR filter for a given sequence
7. Implementation of HP FIR filter for a given sequence
8. Implementation of LP IIR filter for a given sequence
9. Implementation of HP IIR filter for a given sequence
10. Generation of Sinusoidal signal through filtering
11. Generation of DTMF signals
12. Implementation of Decimation Process
13. Implementation of Interpolation Process
14. Implementation of I/D sampling rate converters
15. Audio application such as to plot a time and frequency display of microphone plus a cosine using DSP.
Read a .wav file and match with their respective spectrograms.
16. Noise removal: Add noise above 3 KHz and then remove, interference suppression using 400 Hz tone.
17. Impulse response of first order and second order systems.
Note: Any 12of the above experiments from each part are to be conducted
7.Session Plan
S. No
1
Week
No.
1
Activity
Generation of Sinusoidal
Remarks
Prerequisite
DT signal
As per JNTU
Syllabus(ICA
Subject,Unit 7)
Implementation of FFT of
given sequence .
Determination of Power
As per JNTU
Syllabus(ICA
Subject,Unit 7)
As per JNTU Syllabus
Implementation of LP FIR
filter for a given sequence
.
7. Implementation of HP FIR
As per JNTU
Syllabus(STLD
Subject Unit-2)
As per JNTU Syllabus
8. Implementation of LP IIR
9. Implementation of HP IIR
10
12
12. Implementation of
Decimation Process
13
13. Implementation of
Interpolation Process
14
10
15
10
16
11
11
Introduction:
(ii) Current Directory Browser and Search Path : MATLAB file operations use the current
directory and the search path as reference points. Any file required to run must either be in the
current directory or on the search path.
(iii) Workspace Browser and Array Editor :The MATLAB workspace consists of the set of
variables (named arrays) built up during a MATLAB session and stored in memory. The variables
can be added to the workspace by using functions, running M-files, and loading saved
workspaces. To delete variables from the workspace, select the variables and select Edit > Delete.
Array Editor : Double-click a variable in the Workspace browser, or use open var variable name,
to see it in the Array Editor. Use the Array Editor to view and edit a visual representation of
variables in the workspace.
(iv) Editor/Debugger : Editor/Debugger is used to create and debug M-files, which are
programs to run MATLAB functions. The Editor/Debugger provides a graphical
user interface for text editing, as well as for M-file debugging. To create or edit an M-file use File
> New or File > Open, or use the edit function.
The important commands/ functions are as below :
1. clc (Remove items from workspace, freeing up system memory) clears all input and output
from the Command Window display, giving "clean screen." After using clc, the scroll bar cannot
be used to see the history of functions, but still the up arrow can be used to recall statements from
the command history.
2. close (Remove specified figure): close deletes the current figure or the specified figure(s). It
optionally returns the status of the close operation.
3. xlabel, ylabel, zlabel (Label x-, y-, and z-axis) : Each axes graphics object can have one
label for the x-, y-, and z-axis. The label appears beneath its respective axis in a two-dimensional
plot and to the side or beneath the axis in a three-dimensional plot.
xlabel('string') labels the x-axis of the current axes.
ylabel(...) and zlabel(...) label the y-axis and z-axis, respectively, of the current axes.
4.title( Add title to current axes) : Each axes graphics object can have one title. The title is located
at the top and in the center of the axes.
title('string') outputs the string at the top and in the center of the current axes.
5. figure (create figure graphics object) : figure creates figure graphics objects. Figure objects
are the individual windows on the screen in which MATLAB displays graphical output.
6. subplot (Create axes in tiled positions): subplot divides the current figure into rectangular
panes that are numbered row wise. Each pane contains an axes object. Subsequent plots are output
to the current pane.
h = subplot(m,n,p) or subplot(mnp) breaks the figure window into an m-by-n matrix of small
axes, selects the pth axes object for the current plot, and returns the axes handle. The axes are
counted along the top row of the figure window, then the second row, etc. For example,
subplot(2,1,1), plot(income)
subplot(2,1,2), plot(outgo) plots income on the top half of the window and outgo on the bottom
half.
stem (Plot discrete sequence data) : A two-dimensional stem plot displays data as lines
extending from a baseline along the x-axis. A circle (the default) or other marker whose y-position
represents the data value terminates each stem.
stem(Y) Plots the data sequence Y as stems that extend from equally spaced and automatically
generated values along the x-axis. When Y is a matrix, stem plots all elements in a row against the
same x value.
stem(X,Y) plots X versus the columns of Y. X and Y must be vectors or matrices of the same
size. Additionally, X can be a row or a column vector and Y a matrix with length(X) rows.
bar(Plot bar graph (vertical and horizontal)) : A bar graph displays the values in a vector or
matrix as horizontal or vertical bars.
bar(Y) draws one bar for each element in Y. If Y is a matrix, bar groups the bars produced by the
elements in each row. The x-axis scale ranges from 1 up to length(Y) when Y is a vector, and 1 to
size(Y,1), which is the number of rows, when Y is a matrix.
barh(...) and h = barh(...) create horizontal bars. Y determines the bar length. The vector x is a
vector defining the y-axis intervals for horizontal bars.
plot ( 2-D line plot) :
plot(Y) Plots the columns of Y versus their index if Y is a real number. If Y is complex, plot(Y)
is equivalent to plot(real(Y),imag(Y)). In all other uses of plot, the imaginary component is
ignored.
plot(X1,Y1,...) Plots all lines defined by Xn versus Yn pairs. If only Xn or Yn is a matrix, the
vector is plotted versus the rows or columns of the matrix,
depending on whether the vector's row or column dimension matches the matrix. If Xn is a scalar
and Yn is a vector, disconnected line objects are created and plotted as discrete points vertically at
Xn.
input (Request user input) : The response to the input prompt can be any MATLAB expression,
which is evaluated using the variables in the current workspace.
user_entry = input('prompt') Displays prompt as a prompt on the screen, waits for input from
the keyboard, and returns the value entered in user_entry. user_entry = input('prompt', 's') returns
the entered string as a text variable rather than as a variable name or numerical value.
zeros (Create array of all zeros) :
B = zeros(n) Returns an n-by-n matrix of zeros. An error message appears if n is not a scalar.
[h,w] = freqz(ha) returns the frequency response vector h and the corresponding frequency
vector w for the adaptive filter ha. When ha is a vector of adaptive filters, freqz returns the matrix
h. Each column of h corresponds to one filter in the vector ha.
abs (Absolute value and complex magnitude) :
abs(X) returns an array Y such that each element of Y is the absolute value of the
corresponding element of X.
fft (Discrete Fourier transform) :
Y = fft(X) Y = fft(X) returns the discrete Fourier transform (DFT) of vector X, computed with a
fast Fourier transform (FFT) algorithm.
mod (Modulus after division) :
M = mod(X,Y) returns X - n.*Y where n = floor(X./Y). If Y is not an integer and the
quotient X./Y is within round off error of an integer, then n is that integer. The inputs X and Y
must be real arrays of the same size, or real scalars.
sqrt (Square root) :
B = sqrt(X) returns the square root of each element of the array X. For the elements of
X that are negative or complex, sqrt(X) produces complex results.
ceil (Round toward infinity) :
B = ceil(A) rounds the elements of A to the nearest integers greater than or equal to A. For
complex A, the imaginary and real parts are rounded independently.
fir1(Window-based finite impulse response filter design) :
b = fir1(n,Wn) returns row vector b containing the n+1 coefficients of an order n lowpass
FIR filter. This is a Hamming-window based, linear-phase filter with normalized cutoff frequency
Wn. The output filter coefficients, b, are ordered in descending powers of z.
buttord (Butterworth filter order and cutoff frequency) :
[n,Wn] = buttord(Wp,Ws,Rp,Rs)
returns the lowest order, n, of the digital
Butterworth filter that loses no more than Rp dB in the passband and has at least Rs dB of
attenuation in the stopband. The scalar (or vector) of corresponding cutoff frequencies, Wn, is
also returned. Use the output arguments n and Wn in butter.
fliplr (Flip matrix left to right) :
B = fliplr(A) returns A with columns flipped in the left-right direction, that is, about a
vertical axis.If A is a row vector, then fliplr(A) returns a vector of the same length with the order
of its elements reversed. If A is a column vector, then fliplr(A) simply returns A.
Experiment No: 1
Aim: . Generation of Sinusoidal waveform
Apparatus require d: A PC with Mat lab version 2008a.
MATLAB Program :
clc;
clear all;
close all;
t=0:.01:2*pi;
%generation of sine signals%
y1=sin(t);
y2=sin(3*t)/3;
y3=sin(5*t)/5;
y4=sin(7*t)/7;
y5=sin(9*t)/9;
%y = sin(t) + sin(3*t)/3 + sin(5*t)/5 + sin(7*t)/7 + sin(9*t)/9; %
y = y1+y2+y3+y4+y5;
plot (t,y,t,y1,t,y2,t,y3,t,y4,t,y5);
legend ('y','y1','y2','y3','y4','y5');
title ('generation of sum of sinusoidal signals');
grid on;
ylabel ('---> Amplitude');
xlabel ('---> t');
Output:
Res ult:- Thus the MATLAB program for sum of sinusoidal signals was performed and the
output was verified.
Experiment No: 2
Aim: To find DFT / IDFT of given DT signal
Apparatus require d: A PC with Mat lab version 2008a.
MATLAB Program:
DFT :
%prog for computing discrete Fourier Transform
clc;clear all;close all;
x =input('Enter the sequence ');
%x =[0 1 2 3 4 5 6 7]
IDFT :
% prog for inverse discrete Fourier Transform (IDFT)
clc;clear all;close all;
x =input('Enter length of DFT ');
t = 0:pi/x:pi;
num =[0.05 0.033 0.008];
den =[0.06 4 1];
trans = tf(num,den);
[freq,w] =freqz(num,den,x); grid on;
subplot(2,1,1);plot(abs(freq),'k');
disp(abs(freq));
ylabel('Magnitude');
xlabel('Frequency index');
title('Magnitude Response');
Output :
DFT :
DFT is x = 28.0000
-4.0000
-4.0000 + 9.6569i
-4.0000 + 4.0000i
-4.0000 + 1.6569i
-4.0000 - 1.6569i
-4.0000 - 4.0000i
-4.0000 - 9.6569i
IDFT :
DFT
10
8
Im a g in a ry a x is ------>
6
4
2
0
-2
-4
-6
-8
-10
4
5
Real axis------>
IDFT
Magnitude Response
M a g n it u d e
0.02
0.015
0.01
0.005
1.5
2.5
Frequency index
3.5
Experiment No: 3
Aim: To find frequency response of a given system given in (Transfer Function/ Differential
equation form).
Apparatus require d: A PC with Mat lab version 2008a.
MATLAB Program:
clc
close all
x=1
num=[10];
dem=[0.01 1.2 1.0];
c=tf(num,dem); %Specify transfer functions
w=0:0.1:10;
H=freqresp(c,w);
for i=1:1:101
p(i)=abs(H(:,:,i))
end
plot(w,p)
grid;
title('frequency response of sencond order system')
xlabel('w')
ylabel('Amplitude')
OUTPUT WAVE FORM:
Result:- Thus the MATLAB program for Frequency Response of Transfer function was
performed and the output was verified.
Experiment No: 4
outputs:
y=
00100
enter the length of the FFT sequence: 10
1.0000 0.3090 - 0.9511i -0.8090 - 0.5878i -0.8090 + 0.5878i 0.3090 + 0.9511i
1.0000 0.3090 - 0.9511i -0.8090 - 0.5878i -0.8090 + 0.5878i 0.3090 + 0.9511i
Experiment No: 5
Experiment No: 6
In this equation, x(k) and y(n) represent the input to and output from the filter at time n. h(n-k) is
the transversal filter coefficients at time n. These coefficients are generated by using FDS
(Filter Design Software or Digital filter design package).
FIR filter is a finite impulse response filter. Order of the filter should be specified. Infinite
response is truncated to get finite impulse response. placing a window of finite length does
this. Types of windows available are Rectangular, Barlett, Hamming, Hanning, Blackmann
window
etc. This FIR filter is an all zero filter.
PROCEDURE:
1. Enter the passband ripple (rp) and stopband ripple (rs).
2. Enter the passband frequency (fp) and stopband frequency (fs).
3. Enter the sampling frequency (f).
4. Calculate the analog passband edge frequency (wp) and stop band edge frequency (ws)
wp=2*fp/f ws=2*fs/f
5. Calculate the order of the filter using the following formula,
[Use ceil( ) for rounding off the value of n to the nearest integer] if n is an
odd number, then reduce its value by 1.
6. Generate (n+1)th point window coefficients.For example boxcar(n+1) generates a rectangular
window. y=boxcar(n+1)
7. Design an nth order FIR filter using the previously generated (n+1) length window function.
b=fir1(n,wp,y)
8. Find the frequency response of the filter by using freqz( ) function. [h,o]=freqz(b,a,k) This
function returns k-point complex frequency response vector h and k-point frequency vector o
in radians/samples of the filter.
Input:
rp = 0.05
rs = 0.04
fp = 1500
fs = 2000
f = 8000
In this equation, x(k) and y(n) represent the input to and output from the filter at time n. h(n-k) is
the transversal filter coefficients at time n. These coefficients are generated by using FDS
(Filter Design Software or Digital filter design package).
FIR filter is a finite impulse response filter. Order of the filter should be specified. Infinite
response is truncated to get finite impulse response. placing a window of finite length does
this. Types of windows available are Rectangular, Barlett, Hamming, Hanning, Blackmann
window
etc. This FIR filter is an all zero filter.
PROCEDURE:
1. Enter the passband ripple (rp) and stopband ripple (rs).
2. Enter the passband frequency (fp) and stopband frequency (fs).
3. Enter the sampling frequency (f).
4. Calculate the analog passband edge frequency (wp) and stop band edge frequency (ws)
wp=2*fp/f ws=2*fs/f
5. Calculate the order of the filter using the following formula,
[Use ceil( ) for rounding off the value of n to the nearest integer] if n is an
odd number, then reduce its value by 1.
6. Generate (n+1)th point window coefficients.For example boxcar(n+1) generates a rectangular
window. y=boxcar(n+1)
7. Design an nth order FIR filter using the previously generated (n+1) length window function.
b=fir1(n,wp,high,y)
8. Find the frequency response of the filter by using freqz( ) function. [h,o]=freqz(b,a,k) This
function returns k-point complex frequency response vector h and k-point frequency vector o
Here a=1.
9. Calculate the magnitude of the frequency response in decibels (dB). m= 20*log10(abs(h))
10. Plot the magnitude response [magnitude in dB Vs normalized frequency (o/pi)]
11. Give relevant names to x- and y- axes and give an appropriate title for the plot
MATLAB Program:
clc;
close all;
clear all;
rp=0.05%input('enter the passband ripple');
rs=0.06%input('enter the stopband ripple');
fp=1000%input('enter the passband frequency');
fs=2000%input('enter the stopband frequency');
f=8000%input('enter the sampling freq');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n1=n+1;
if(rem(n,2)~=0)
n1=n;
n=n-1;
end
y=boxcar(n1);
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
an=angle(h);
figure(1)
plot(o/pi,m);
title('******** HIGH PASS FIR FILTER RESPONSE ********');
ylabel('GAIN in db--->');
xlabel('Normalised Frequency--->');
figure(2)
plot(o/pi,an);
Experiment No: 8
Result: Butter worth Digital and analog low pass IIR filters are implemented using
MATLAB.
Experiment No: 9
Aim: Implementation of High Pass IIR filter for given sequence.
Apparatus require d: A PC with Mat lab version 2008a.
MATLAB Program:
clc;
close all;
clear all;
format long
rp=input('enter the passband ripple');
rs=input('enter stopband ripple');
wp=input('enter passband freq');
ws=input('enter stopband freq');
fs=input('enter sampling freq');
w1=2*wp/fs;
w2=2*ws/fs;
%Analog HPF
[n,wn]= buttord(w1,w2,rp,rs);
[b,a]=butter(n,wn,'high','s');
w=0:.01:pi;
[h,om]=freqs(b,a,w);
m=20*log10(abs(h));
an=angle(h); figure(1)
plot(om/pi,m);
title('**** Analog Output Magnitude *****');
ylabel('gain in db...>');
xlabel('normalised freq..>');
figure(2)
plot(om/pi,an);
title('**** Analog Output Phase ****');
xlabel('normalised freq..>');
ylabel('phase in radians...>');
n
wn
%Digital HPF
[n,wn]= buttord(w1,w2,rp,rs);
[b,a]=butter(n,wn,'high');
w=0:.01:pi;
[h,om]=freqz(b,a,w); m=20*log10(abs(h));
an=angle(h);
figure(3)
plot(om/pi,m);
title('**** Digital Output Magnitude *****');
ylabel('gain in db...>');
xlabel('normalised freq..>');
figure(4)
plot(om/pi,an);
title('**** Digital Output Phase ****');
xlabel('normalised freq..>');
ylabel('phase in radians...>');
n
wn
Input:
rp = 0.5000 rs = 100 wp = 1200 ws = 2400 fs = 8000
Output:
n = 13
wn = 0.32870936151976
n = 13
wn = 0.32870936151976
Result: Butter worth Digital and analog low pass IIR filters are implemented using
MATLAB.
. Experiment No: 10
Aim: Generation of DTMF signal.
Apparatus require d: A PC with Mat lab version 2008a.
MATLAB Program:
%Generation of Dual Tone Multi Frequency Signal
%%%%first lets generate the tweive freq program
clc;
symbol={'1','2','3','4','5','6','7','8','9','*','0','#'};
lfg=[697 770 852 941];
hfg=[1209 1336 1477];
f= [];
for r=1:4,
for c=1:3,
f=[ f [lfg(r);hfg(c)] ];
end
end
f'
%next generate and visualize the DTMF tones
fs=8000;
N=800;
t=(0:N-1)/fs;
pit=2*pi*t;
tones=zeros(N,size(f,2));
for tonechoice=1:12
%%generetate tone
a=f(:,tonechoice);
b=a*pit;
sinb=sin(b);
c=sum(sinb);
tones(:,tonechoice)=c';
%%plot tone
subplot(4,3,tonechoice),plot(t*1e3,tones(:,tonechoice));
title(['symbol"',symbol{tonechoice},'":[',num2str(f(1,tonechoice)),',',num2str(f(2,
tonechoice)),']'])
set(gca,'xlim',[0 25]);
ylabel('amplitude')
if tonechoice>9,xlabel('time(ms)');
end
end
OUTPUT:
Experiment No: 11
Aim: Implementation of Decimation Process.
Apparatus require d: A PC with Mat lab version 2008a.
MATLAB Program:
clc;
clear all;
close all;
N=250 ;
n=0:1:N-1;
x=sin(2*pi*n/15);
M=2;
figure(1)
stem(n,x);
grid on;
xlabel('No.of.Samples');
ylabel('Amplitude');
title('Original Sequence');
a=1;
b=fir1(5,0.5,'Low');
y=filter(b,a,x);
figure(2)
stem(n,y);
grid on;
xlabel('No.of.Samples');
ylabel('Amplitude');
title('Filtered Sequence'); x1=y(1:M:N);
n1=1:1:N/M;
figure(3)
stem(n1-1,x1);
grid on;
xlabel('No.of.Samples');
ylabel('Amplitude');
title('Decimated Sequence');
Result: This MATLAB program has been written to perform Decimation on the Given Input
Sequence.
Experiment No: 12
Aim: Implementation of Interpolation Process.
Apparatus require d: A PC with Mat lab version 2008a.
MATLAB Program:
clc;
clear all;
close all;
N=125;
n=0:1:N-1;
x=sin(2*pi*n/15);
L=2;
figure(1)
stem(n,x);
grid on;
xlabel('No.of.Samples');
ylabel('Amplitude');
title('Original Sequence');
x1=[zeros(1,L*N)];
n1=1:1:L*N;
j =1:L:L*N;
x1(j)=x;
figure(2)
stem(n1-1,x1);
grid on;
xlabel('No.of.Samples');
ylabel('Amplitude');
title('Upsampled Sequence');
a=1;
b=fir1(5,0.5,'Low');
y=filter(b,a,x1);
figure(3)
stem(n1-1,y);
grid on;
xlabel('No.of.Samples');
ylabel('Amplitude');
title('Interpolated Sequence');
Result: This MATLAB program has been written to perform interpolation on the Given Input
Sequence.
Experiment No: 13
Aim: To write a MATLAB program to find the impulse response of a LTI system defined by a
difference equation:
y(n) + 0.7y(n-1) 0.45y(n-2) 0.6y(n-3) = 0.8x(n) 0.44x(n-1) + 0.36x(n-2) + 0.2x(n-3)
Apparatus require d: A PC with Mat lab version 2008a.
MATLAB Program:
clc;
clear all;
close all;
N = input ('Enter the required length of impulse response N = ');
n = 0 : N-1;
b = input ('Enter the co-efficients of x(n), b = ');
a = input ('Enter the co=efficients of y(n), a = ');
% Impulse response of the LTI system given by the difference equation
x = [1, zeros(1,N-1)];
y = impz (b,a,N);
subplot (2,1,1);
stem (n,y,r);
xlabel ('time');
ylabel ('amplitude');
title ('IMPULSE RESPONSE');
grid on;
% Pole Zero distribution of the LTI system given by the difference equation
subplot (2,1,2);
zplane (b,a);
xlabel ('Real part');
ylabel ('Imaginary part');
title ('Poles and Zeros of H[z] in Z-plane');
grid on;
Output : Enter the required length of impulse response N = 40
Enter the co-efficients of x(n), b = [0.8 -0.44 0.36 0.02]
Enter the co=efficients of y(n), a = [1 0.7 -0.45 -0.6]
Result:-Thus the MATLAB program for Impulse Response of Difference Equation was
performed and the output was verified
are
The primary reason for using a DSP instead of a traditional microprocessor is speed: the
ability to move samples into the device and carry out the needed mathematical operations,
and output the processed data. The usual way of specifying the fastness of a DSP is: fixed
point systems are often quoted in MIPS (million integer operations per second). Likewise,
floating point devices can be specified in MFLOPS (million floating point operations per
second).
TMS320
Family:
The Texas Instruments TMS320 family o f DSP devices covers a wide range, from a 16-bit
fixed- point device to a single-chip parallel-processor device. In the past, DSPs were
used only in specialized applications. Now they are in many mass- market consumer
products that are continuously entering new market segments. The Texas Instruments
TMS320 family of DSP devices and their typical applications are mentioned below.
C1x, C2x, C2xx, C5x, and C54x: The width of the data bus on these devices is 16 bits. All
have
modified Harvard architectures. They have been used in toys, hard disk drives, modems,
cellular phones, and active car suspensions.
C3x: The width of the data bus in the C3x series is 32 bits. Because of the reasonable cost
and floating-point performance, these are suitable for many applica tions. These include
almost any filters, analyzers, hi- fi systems, voice- mail, imaging, bar-code readers,
motor control, 3D graphics, or scientific processing.
C4x: This range is designed for parallel processing. The C4x devices have a 32 -bit data bus
and
The DSK is US B port interfaced platform that allows to efficiently develop and
test applications for the C6713. With extensive host PC and target DSP software support, the
DSK provides ease-of- use and capabilities that are attractive to DSP engineers.
The 6713 DSP S tarter K it (DSK) is a low-cost platform which lets customers evaluate
and develop applications for the Texas Instruments C67X DSP family.
The primary features of the DSK are:
225 MHz TMS320C6713 F loating Point DSP
AIC23 Stereo Codec
Four Position User DIP Switch a nd Four User LEDs
On-board F lash and S DRAM
TIs Code Composer S tudio development tools are bundled with the 6713DSK providing
the user with an industrial-strength integrated development environment for C and
assembly programming.
Code Composer Studio communicates with the DSP using an on-board JTAG emulator through a
USB interface.
The TMS320C6713 DSP is the heart of the system. It is a core member of Texas Instruments
C64X line of fixed point DSPs whose distinguishing features are an extremely high performance
225MHz VLIW DSP core and 256Kbytes of internal memory. O n-chip peripherals include a
32- bit external memory interface (EMIF ) with integrated SDRAM controller, 2 multichannel buffered serial ports (McBSPs), two on-board timers and an enhanced DMA controller
(EDMA). The 6713 represents the high end of TIs C6700 floating point DSP line both in
terms of computational performance and on-chip resources.
The 6713 has a significant amount of internal memory so many applications will have all
codeand data on-chip. External accesses are done through the EMIF which can connect to
both synchronous and asynchronous memories. The EMIF signals are also brought out to
standard TI expansion bus connectors so additional functionality can be added on daughter card
modules.
DSPs are frequently used in audio processing applications so the DSK includes an onboard codec called the AIC23. Codec stands for coder/decoder,the job of the AIC23 is to code
analog input samples into a digital format for the DSP to process, then decode data coming
out of the DSP to generate the processed analog output. Digitial data is sent to and from
the codec on McBSP1.
TMS320C6713 DSK Overview Block Diagram
The DSK has 4 light emitting diodes (LEDs) and 4 DIP switches that allow users to interact
with programs through simple LED displays and user input on the switches. Many of the
included examples make use of these user interfaces Options.
The DSK implements the logic necessary to tie board components together in a
programmable logic device called a CPLD. In addition to random glue logic, the CP
LD implements a set of 4 software programmable registers that can be used to access the onboard LEDs and DIP switches as well as control the daughter card interface.
data signals via file I/O, multi-processor debugging, automated testing and customization via a
C- interpretive scripting language and much more.
CODE COMPOSER FEATURES INCLUDE:
IDE
Debug IDE
Advanced watch windows
Integrated editor
File I/O, Probe Points, and graphical algorithm scope probes
Advanced graphical signal analysis
Interactive profiling
Automated testing and customization via scripting
Visual project management system
Compile in the background while editing and debugging
Multi-processor debugging
Help on the target DSP
3. file.asm: assembly source program created by the user, by the C compiler,or by the linear
optimizer.
4. file.sa: linear assembly source program. The linear optimizer uses file.sa as input to
produce an assembly program file.asm
5. file.h: header support file.
6. file.lib: library file, such as the run-time support library file rts6701.lib.
9. file.out: executable file created by the linker to be loaded and run on the proces s or.
Proce dure to wo rk o n co de compos e r s tudio
Enter the source code and save the file with . C extension.
5. To add the c program to the project
Project Add files to project <source file>
8. To compile
Project Compile file ( or use icon or ctrl+F7 )
9. To build or link
Project b uild (or use F7 ) (which will create a .out file in project folder)
10. To load the program:
File Load Program <select the .out file in debug folder in project folder> This
will load our program into the board.
11.To run the program
Debug Run
12. Observe the output in output window.
11. To see the Graph go to View and select time/frequency in the Graph, And give the correct
Start address provided in the program, Display data can be taken as per user
EXPERIMENT : 1
Aim:- To generate a sine wave and square wave using C6713 simulator
Equipments: Operating S ystem - Windows XP
Software - CC STUDIO 3
DSK 6713 DSP Trainer kit.
USB Cable
Power supply
Procedure :1. Open Code Composer Setup and select C6713 simulator, click save and quit
2. Start a new project using Project New pull down menu, save it in a separate
directory(C:\My projects) with file name sine wave.pjt3. Create a new source file using F ile
New Source file menu and save it in the project folder(sinewave.c)
4. Add the source file (sinewave.c) to the project
Project Add files to Project Select sinewave.c
5. Add the linker command file hello.cmd
Project Add files to Project
(path: C :\CCstudio \tutorial\dsk6713\hello \hello.cmd)
6. Add the run time support library file rts6700.lib
Project Add files to Project
(path: C\CCStudio\cgtools\lib\rts6700.lib)
7. Compile the program using project Compile menu or by Ctrl+F7
8. Build the program using projec t Build menu or by F7
9. Load the sinewave.out file (from project folder lcconv\Debug) using
File Load Program
10. Run the program using Debug Run or F5
11. To view the output graphically
Select View Graph Time and Frequency
12. Repeat the steps 2 to 11 for square wave.
Program
Sine Wave
#include <stdio.h>
#include <math.h>
float a[500];
void main()
{
int i=0;
for(i=0;i<500;i++)
{
a[i]=sin(2*3.14*10000*i);
}
}
Square wave
#include <stdio.h>
#include <math.h>
int a[1000];
void main()
{
int i,j=0; int b=5;
for(i=0;i<10;i++)
{
for (j=0;j<=50;j++)
{
a[(50*i)+j]=b;
}
b=b*(-1) ;
}}
Output:Sine wav
Square wave:-
Result:- The sine wave and square wave has been obtained.
EXPERIMENT : 2
Aim:- To verify FIR filters using C6713 simulator.
Equipments: Operating S ystem - Windows XP
Software - CC STUDIO 3
DSK 6713 DSP Trainer kit.
USB Cable
Power supply
Procedure :1. Open Code Composer Setup and select C6713 simulator, click save and quit
2. Start a new project using Project New pull down menu, save it in a separate
directory(C:\My projects) with file name sine wave.pjt3. Create a new source file using F ile
New Source file menu and save it in the project folder(sinewave.c)
4. Add the source file (sinewave.c) to the project
Project Add files to Project Select sinewave.c
5. Add the linker command file hello.cmd
Project Add files to Project
(path: C :\CCstudio \tutorial\dsk6713\hello \hello.cmd)
6. Add the run time support library file rts6700.lib
Project Add files to Project
(path: C\CCStudio\cgtools\lib\rts6700.lib)
7. Compile the program using project Compile menu or by Ctrl+F7
8. Build the program using projec t Build menu or by F7
9. Load the sinewave.out file (from project folder lcconv\Debug) using
File Load Program
10. Run the program using Debug Run or F5
11. To view the output graphically
Select View Graph Time and Frequency
12. Repeat the steps 2 to 11 for square wave.
PROGRAM:
// FIR Lowpass Filter program in C language using CC Studio
#include<stdio.h>
#include<math.h>
main()
{
int k,N,n,x,y;
static float h[10],hd[10],w[10];
printf("enter the no of samples N");
scanf("%d",&N);
y=(N-1)/2;
x=-y;
for(n=x;n<=y;n++)
{
if(n!=0)
{
hd[n]=(sin(n*1.57)/3.14*n);
}
else
hd[n]=0.5;
}
printf("select the window: 1.rectangular 2.triangular 3.hanning 4.hamming 5.blackmann");
scanf("%d",&k);
switch(k)
{
case 1:
for(n=x;n<=y;n++)
w[n]=1;
break;
case 2:
for(n=x;n<=y;n++)
w[n]=1-((abs(n)*2)/(N-1));
break;
case 3:
for(n=x;n<=y;n++)
w[n]=0.5+(0.5*cos((6.28*n)/(N-1)));
break;
case 4:
for(n=x;n<=y;n++)
w[n]=0.54+(0.46*cos((6.28*n)/(N-1)));
break;
case 5:
for(n=x;n<=y;n++)
w[n]=0.42+(0.5*cos((6.28*n)/(N-1)))+(0.08*cos((12.56*n)/(N-1)));
break;
default:
printf("wrong choice is entered");
}
for(n=x;n<=y;n++)
{
h[n]=hd[n]*w[n];
printf("output is %f\t",h[n]);
}
}
Result:
enter the no of samples N 5
select the window: 1.rectangular 2.triangular 3.hanning 4.hamming 5.blackmann 1
output is 0.001014 output is 0.318471 output is 0.500000 output is 0.318471 output is 0.001014
FIR Low Pass Filter Rectangular Window Graph:
Result:
enter the no of samples N 5
select the window: 1.rectangular 2.triangular 3.hanning 4.hamming 5.blackmann 2
output is 0.000000 output is 0.318471 output is 0.500000 output is 0.318471 output is 0.000000
FIR Low Pass Filter Triangular Window Graph:
Result:
enter the no of samples N 5
select the window: 1.rectangular 2.triangular 3.hanning 4.hamming 5.blackmann 3
output is 0.000000 output is 0.159362 output is 0.500000 output is 0.159362 output is 0.000000
Result:
enter the no of samples N 5
select the window: 1.rectangular 2.triangular 3.hanning 4.hamming 5.blackmann 4
output is 0.000081 output is 0.172091 output is 0.500000 output is 0.172091 output is 0.000081
Result:
enter the no of samples N 5
select the window: 1.rectangular 2.triangular 3.hanning 4.hamming 5.blackmann 5
output is 0.000000 output is 0.108407 output is 0.500000 output is 0.108407 output is 0.000000
Program:
// FIR High pass Filter program in C language using CC Studio
#include<stdio.h>
#include<math.h>
static float h[20],hd[20],w[20];
main()
{
int k,n,N,x,y;
printf("Enter the number of samples");
scanf("%d",&N);
y=(N-1)/2;
x=-y;
for(n=x;n<=y;n++)
{
if(n!=0)
{
hd[n]=((sin(n*3.14))-(sin(n*1.57)))/(n*3.14);
}
else
hd[n]=0.5;
}
printf("Select the window");
printf("1.Rectangular Window 2.Triangular window 3.Hanning window 4.Hamming window
5.Blackmann window");
scanf("%d",&k);
switch(k)
{
case 1:
for(n=x;n<=y;n++)
w[n]=1;
break;
case 2:
for(n=x;n<=y;n++)
w[n]=1-((abs(n)*2)/(N-1));
break;
case 3:
for(n=x;n<=y;n++)
w[n]=0.5+(0.5*cos((6.28*n)/(N-1)));
break;
case 4:
for(n=x;n<=y;n++)
w[n]=0.54+(0.46*cos((6.28*n)/(N-1)));
break;
case 5:
for(n=x;n<=y;n++)
w[n]=0.42+(0.5*cos((6.28*n)/(N-1))+(0.08*cos((12.5*n)/(N-1))));
break;
default:
printf("\n Wrong choice is entered,Please Enter the correct choice\n");
break;
}
for(n=x;n<=y;n++)
{
h[n]=hd[n]*w[n];
printf("\n The Output is: %f \t",h[n]);
}
}
Result:
Enter the number of samples 5
Select the window 1.Rectangular Window 2.Triangular window 3.Hanning window 4.Hamming
window 5.Blackmann window 1
The Output is: -0.000761
The Output is: -0.317964
The Output is: 0.500000
The Output is: -0.317964
The Output is: -0.000761
Result:
Enter the number of samples 5
Select the window 1.Rectangular Window 2.Triangular window 3.Hanning window 4.Hamming
window 5.Blackmann window 2
The Output is: 0.000000
The Output is: -0.317964
The Output is: 0.500000
The Output is: -0.317964
The Output is: 0.000000
Result:
Enter the number of samples 5
Select the window 1.Rectangular Window 2.Triangular window 3.Hanning window 4.Hamming
window 5.Blackmann window 3
The Output is: -0.000000
The Output is: -0.159109
The Output is: 0.500000
The Output is: -0.159109
The Output is: -0.000000
Result:
Enter the number of samples 5
Select the window 1.Rectangular Window 2.Triangular window 3.Hanning window 4.Hamming
window 5.Blackmann window 4
The Output is: -0.000061
The Output is: -0.171817
The Output is: 0.500000
The Output is: -0.171817
The Output is: -0.000061
Result:
Enter the number of samples 5
Select the window 1.Rectangular Window 2.Triangular window 3.Hanning window 4.Hamming
window 5.Blackmann window 5
The Output is: 0.000000
The Output is: -0.108238
The Output is: 0.500000
The Output is: -0.108238
The Output is: 0.000000
PROGRAM:
// FIR LP/HP Filter program in C language using CC Studio
#include<stdio.h>
#include<math.h>
#define pi 3.1415
int n,N,c;
float wr[64],wt[64];
void main()
{
printf("\n enter no. of samples,N= :");
scanf("%d",&N);
printf("\n enter choice of window function\n 1.rect \n 2. triang \n c= :");
scanf("%d",&c);
printf("\n elements of window function are:");
switch(c)
{
case 1:
for(n=0;n<=N-1;n++)
{
wr[n]=1;
printf(" \n wr[%d]=%f",n,wr[n]);
}
break;
case 2:
for(n=0;n<=N-1;n++)
{
wt[n]=1-(2*(float)n/(N-1));
printf("\n wt[%d]=%f",n,wt[n]);
}
break;
}
}
Result:
enter no. of samples, N=:64
enter choice of window function
1.rect
2.triang
c=:1
elements of window function are:
wr[0]=1.000000 wr[1]=1.000000 wr[2]=1.000000 wr[3]=1.000000
wr[4]=1.000000 wr[5]=1.000000 wr[6]=1.000000 wr[7]=1.000000
wr[8]=1.000000 wr[9]=1.000000 wr[10]=1.000000 wr[11]=1.000000
wr[12]=1.000000 wr[13]=1.000000 wr[14]=1.000000 wr[15]=1.000000
wr[16]=1.000000 wr[17]=1.000000 wr[18]=1.000000 wr[19]=1.000000
wr[20]=1.000000 wr[21]=1.000000 wr[22]=1.000000 wr[23]=1.000000
wr[24]=1.000000 wr[25]=1.000000 wr[26]=1.000000 wr[27]=1.000000
wr[28]=1.000000 wr[29]=1.000000 wr[30]=1.000000 wr[31]=1.000000
wr[32]=1.000000 wr[33]=1.000000 wr[34]=1.000000 wr[35]=1.000000
wr[36]=1.000000 wr[37]=1.000000 wr[38]=1.000000 wr[39]=1.000000
wr[40]=1.000000 wr[41]=1.000000 wr[42]=1.000000 wr[43]=1.000000
wr[44]=1.000000 wr[45]=1.000000 wr[46]=1.000000 wr[47]=1.000000
wr[48]=1.000000 wr[49]=1.000000 wr[50]=1.000000 wr[51]=1.000000
wr[52]=1.000000 wr[53]=1.000000 wr[54]=1.000000 wr[55]=1.000000
wr[56]=1.000000 wr[57]=1.000000 wr[58]=1.000000 wr[59]=1.000000
wr[60]=1.000000 wr[61]=1.000000 wr[62]=1.000000 wr[63]=1.000000
Result:
enter no. of samples, N= :64
enter choice of window function
1.rect
2.triang
c=:2
elements of window function are:
wt[0]=1.000000 wt[1]=0.968254 wt[2]=0.936508 wt[3]=0.904762
wt[4]=0.873016 wt[5]=0.841270 wt[6]=0.809524 wt[7]=0.777778
wt[8]=0.746032 wt[9]=0.714286 wt[10]=0.682540 wt[11]=0.650794
wt[12]=0.619048 wt[13]=0.587302 wt[14]=0.555556 wt[15]=0.523810
wt[16]=0.492063 wt[17]=0.460317 wt[18]=0.428571 wt[19]=0.396825
wt[20]=0.365079 wt[21]=0.333333 wt[22]=0.301587 wt[23]=0.269841
wt[24]=0.238095 wt[25]=0.206349 wt[26]=0.174603 wt[27]=0.142857
wt[28]=0.111111 wt[29]=0.079365 wt[30]=0.047619 wt[31]=0.015873
wt[32]=-0.015873 wt[33]=-0.047619 wt[34]=-0.079365 wt[35]=-0.111111
wt[36]=-0.142857 wt[37]=-0.174603 wt[38]=-0.206349 wt[39]=-0.238095
wt[40]=-0.269841 wt[41]=-0.301587 wt[42]=-0.333333 wt[43]=-0.365079
wt[44]=-0.396825 wt[45]=-0.428571 wt[46]=-0.460317 wt[47]=-0.492064
wt[48]=-0.523810 wt[49]=-0.555556 wt[50]=-0.587302 wt[51]=-0.619048
wt[52]=-0.650794 wt[53]=-0.682540 wt[54]=-0.714286 wt[55]=-0.746032
wt[56]=-0.777778 wt[57]=-0.809524 wt[58]=-0.841270 wt[59]=-0.873016
wt[60]=-0.904762 wt[61]=-0.936508 wt[62]=-0.968254 wt[63]=-1.000000
EXPERIMENT : 3
Aim:- To verify IIR filters using C6713 simulator.
Equipments: Operating S ystem - Windows XP
Software - CC STUDIO 3
DSK 6713 DSP Trainer kit.
USB Cable
Power supply
Procedure :1. Open Code Composer Setup and select C6713 simulator, click save and quit
2. Start a new project using Project New pull down menu, save it in a separate
directory(C:\My projects) with file name sine wave.pjt3. Create a new source file using F ile
New Source file menu and save it in the project folder(sinewave.c)
4. Add the source file (sinewave.c) to the project
Project Add files to Project Select sinewave.c
5. Add the linker command file hello.cmd
Project Add files to Project
(path: C :\CCstudio \tutorial\dsk6713\hello \hello.cmd)
6. Add the run time support library file rts6700.lib
Project Add files to Project
(path: C\CCStudio\cgtools\lib\rts6700.lib)
7. Compile the program using project Compile menu or by Ctrl+F7
8. Build the program using projec t Build menu or by F7
9. Load the sinewave.out file (from project folder lcconv\Debug) using
File Load Program
10. Run the program using Debug Run or F5
11. To view the output graphically
Select View Graph Time and Frequency
12. Repeat the steps 2 to 11 for square wave.
PROGRAM:
// IIR Filter C Program
#include<stdio.h>
#include<math.h>
int i,w,wc,c,N;
float H[100];
float mul(float,int);
void main()
{
printf("\n Enter order of filter");
scanf("%d",&N);
printf("\n Enter the cut off frequency");
scanf("%d",&wc);
printf("\n Enter the choice for IIR Filter 1.LPF 2.HPF");
scanf("%d",&c);
switch(c)
{
case 1:
for(w=0;w<100;w++)
{
H[w]=1/sqrt(1+mul((w/(float)wc),2*N));
printf("H[%d]=%f\n",w,H[w]);
}
break;
case 2:
for(w=0;w<=100;w++)
{
H[w]=1/sqrt(1+mul((float)wc/w,2*N));
printf("H[%d]=%f\n",w,H[w]);
}
break;
}
}
float mul(float a,int x)
{
for(i=0;i<x-1;i++)
a*=a;
return(a);
}
Result:
Enter order of filter 2
Enter the cut off frequency 50
Enter the choice for IIR Filter 1.LPF 2.HPF 2
H[0]=0.000000
H[1]=0.000000
H[2]=0.000003
H[3]=0.000013
H[4]=0.000041
H[5]=0.000100
.
.
.
H[95]=0.997069
H[96]=0.997304
H[97]=0.997517
H[98]=0.997712
H[99]=0.997890
H[100]=0.998053
IIR High Pass Filter Graph:
H[95]=0.076509
H[96]=0.073388
H[97]=0.070423
H[98]=0.067605
H[99]=0.064926
IIR Low Pass Filter Graph:
EXPERIMENT : 4
Aim:- To Perform Audio applications such as to plot a time and frequency display of microphone
plus a cosine using DSP. Read a wav file and match with their respective spectrograms. using C6713
simulator.
Equipments: Operating S ystem - Windows XP
Software - CC STUDIO 3
DSK 6713 DSP Trainer kit.
USB Cable
Power supply
Procedure :1. Open Code Composer Setup and select C6713 simulator, click save and quit
2. Start a new project using Project New pull down menu, save it in a separate
directory(C:\My projects) with file name sine wave.pjt3. Create a new source file using F ile
New Source file menu and save it in the project folder(sinewave.c)
4. Add the source file (sinewave.c) to the project
Project Add files to Project Select sinewave.c
5. Add the linker command file hello.cmd
Project Add files to Project
(path: C :\CCstudio \tutorial\dsk6713\hello \hello.cmd)
6. Add the run time support library file rts6700.lib
Project Add files to Project
(path: C\CCStudio\cgtools\lib\rts6700.lib)
7. Compile the program using project Compile menu or by Ctrl+F7
8. Build the program using projec t Build menu or by F7
9. Load the sinewave.out file (from project folder lcconv\Debug) using
File Load Program
10. Run the program using Debug Run or F5
{
j = j - k; k = k/2; } j = j + k; if (i<j)
{
temp1.real = (Y[j]).real;
temp1.imag = (Y[j]).imag;
(Y[j]).real = (Y[i]).real;
(Y[j]).imag = (Y[i]).imag;
(Y[i]).real = temp1.real;
(Y[i]).imag = temp1.imag;
}
}
return;
}
Spectrogram_RTDX.m For spectrogram plot using RTDX with MATLAB
clc;
ccsboardinfo %board info
cc=ccsdsp('boardnum',0); %set up CCS object
reset(cc); %reset board
visible(cc,1); %for CCS window enable(cc.rtdx); %
enable RTDX
if ~isenabled(cc.rtdx);
error('RTDX is not enabled')
end
cc.rtdx.set('timeout',50); %set 50sec timeout for RTDX open(cc,'spectrogram1.pjt'); %
open CCS project
load(cc,'./debug/spectrogram1.out'); %load executable file
run(cc); %run program
configure(cc.rtdx,2048,1); %configure one RTDX channel
open(cc.rtdx,'ochan','r');%open output channel
pause(3) %wait for RTDX channel to open
enable(cc.rtdx,'ochan'); %enable channel from DSK
isenabled(cc.rtdx,'ochan');
M = 256; %window size
N = round(M/2);
B = 128; %No. of blocks (128)
fs = 8000; %sampling rate
t=(1:B)*(M/fs); %spectrogram axes generation
EXPERIMENT : 5
Aim:- To
1) Add noise above 3kHz and then remove (using adaptive filters)
2) Interference suppression using 400 Hz tone
DSK6713_AIC23_CodecHandle hCodec;
int l_input, r_input,l_output, r_output,T; /* Initialize the board support library, must be called first */
DSK6713_init();
hCodec = DSK6713_AIC23_openCodec(0, &config); /* Start the codec */
DSK6713_AIC23_setFreq(hCodec, 1);
EXPERIMENT : 6
Aim:- Implementation of FFT using C6713 simulator.
Equipments: Operating S ystem - Windows XP
Software - CC STUDIO 3
DSK 6713 DSP Trainer kit.
USB Cable
Power supply
Procedure :1. Open Code Composer Setup and select C6713 simulator, click save and quit
2. Start a new project using Project New pull down menu, save it in a separate
directory(C:\My projects) with file name sine wave.pjt3. Create a new source file using F ile
New Source file menu and save it in the project folder(sinewave.c)
4. Add the source file (sinewave.c) to the project
Project Add files to Project Select sinewave.c
5. Add the linker command file hello.cmd
Project Add files to Project
(path: C :\CCstudio \tutorial\dsk6713\hello \hello.cmd)
6. Add the run time support library file rts6700.lib
Project Add files to Project
(path: C\CCStudio\cgtools\lib\rts6700.lib)
7. Compile the program using project Compile menu or by Ctrl+F7
8. Build the program using projec t Build menu or by F7
9. Load the sinewave.out file (from project folder lcconv\Debug) using
File Load Program
10. Run the program using Debug Run or F5
{
temp1.real = (Y[j]).real;
temp1.imag = (Y[j]).imag;
(Y[j]).real = (Y[i]).real;
(Y[j]).imag = (Y[i]).imag;
(Y[i]).real = temp1.real;
(Y[i]).imag = temp1.imag;
}
}
return;
}
OUTPUT: