You are on page 1of 75

Digital Signal Processing Lab Manual

DIGITAL SIGNAL PROCESSING


LAB MANUAL
III YEAR II SEMESTER (ECE)

Presented by:

BHASKAR ENGINEERING COLLEGE


Yenkapally, Moinabad, Ranga Reddy.Dist-500075.

Dep of ECE

BEC

Digital Signal Processing Lab Manual

JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD


III Year B.Tech. ECE - II Sem

L T/P/D C
0 -/3/- 2

DIGITAL SIGNAL PROCESSING LAB


The programs shall be implemented in software (Using MATLAB / Lab view / C programming/
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/ Differential
equation 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: - Minimum of 12 experiments has to be conducted.

Dep of ECE

BEC

Digital Signal Processing Lab Manual


CONTENTS
List of experiments using Mat lab

Page No.

Introduction to MATLAB

1) Generation of Basic Signals

11

2) Sum of sinusoidal signals

17

3) Impulse response of the difference equation

19

4) Frequency response of a system given in

21

Difference equation form


5) Determination of Power Spectrum

23

6) FIR Low pass Filter design

25

7) FIR High pass Filter design

29

8) IIR Low pass Filter design

33

9) IIR High pass Filter design

36

10) Fast Fourier Transform

39

11) DFT / IDFT of given DT signal

41

12) Implementation of Decimation Process

43

13) Implementation of Interpolation Process

46

14) Implementation of I/D sampling rate

48

converters
List of experiments using CC Studio
Introduction to DSP processors, TMS 320C6745 DSK
Introduction to CC STUDIO

55

1) Generation of Sine wave and Square wave

63

2) Linear Convolution

68

3) Impulse response of first order and second

72

order systems

Dep of ECE

BEC

Digital Signal Processing Lab Manual

INRODUCTION
MATLAB: MATLAB is a software package for high performance numerical computation and
Visualization provides an interactive environment with hundreds of built in functions for Technical
computation, graphics and animation. The MATLAB name stands for Matrix Laboratory

At its core, MATLAB is essentially a set (a toolbox) of routines (called mfiles or mex files)
that sit on your computer and a window that allows you to create new variables with names (e.g.
voltage and time) and process those variables with any of those routines (e.g. plot voltage against
time, find the largest voltage, etc). It also allows you to put a list of your processing requests together
in a file and save that combined list with a name so that you can run all of those commands in the
same order at some later time. Furthermore, it allows you to run such lists of commands such that

Dep of ECE

BEC

Digital Signal Processing Lab Manual


you pass in data and/or get data back out (i.e. the list of commands is like a function in most
programming languages). Once you save a function, it becomes part of your toolbox (i.e. it now
looks to you as if it were part of the basic toolbox that you started with). For those with computer
programming backgrounds: Note that MATLAB runs as an interpretive language (like the old
BASIC). That is, it does not need to be compiled. It simply reads through each line of the function,
executes it, and then goes on to the next line. (In practice, a form of compilation occurs when you
first run a function, so that it can run faster the next time you run it.)

MATLAB Windows:
MATLAB works with through three basic windows
Command Window: This is the main window .it is characterized by MATLAB command Prompt
>> when you launch the application program MATLAB puts you in this window all Commands
including those for user-written programs, are typed in this window at the MATLAB Prompt
Graphics window: the output of all graphics commands typed in the command window are Flushed
to the graphics or figure window, a separate gray window with white background color The user can
create as many windows as the system memory will allow
Edit window: This is where you write edit, create and save your own programs in files called M
files.
Input-output:
MATLAB supports interactive computation taking the input from the screen and flushing, the Output
to the screen. In addition it can read input files and write output files
Data Type: the fundamental data type in MATLAB is the array. It encompasses several distinct
data objects- integers, real numbers, matrices, character strings, structures and cells. There is no need
to declare variables as real or complex, MATLAB automatically sets the variable to be real.
Dimensioning: Dimensioning is automatic in MATLAB. No dimension statements are required for
vectors or arrays .we can find the dimensions of an existing matrix or a vector with the size and
length commands.

Dep of ECE

BEC

Digital Signal Processing Lab Manual

Where to work in MATLAB?


All programs and commands can be entered either in the
a)Command window
b) As an M file using Mat lab editor
Note: Save all M files in the folder 'work' in the current directory. Otherwise you have to
Locate the file during compiling.

Typing quit in the command prompt>> quit, will close MATLAB Matlab Development
Environment.

For any clarification regarding plot etc, which are built in functions type help topic
i.e. help plot

Basic Instructions in Mat lab


1. T = 0: 1:10
This instruction indicates a vector T which as initial value 0 and final value 10 with an
Increment of 1
Therefore T = [0 1 2 3 4 5 6 7 8 9 10]
2. F= 20: 1: 100
Therefore F = [20 21 22 23 24 100]
3. T= 0:1/pi: 1
Therefore T= [0, 0.3183, 0.6366, 0.9549]
4. Zeros (1, 3)
The above instruction creates a vector of one row and three columns whose values are
Zero

Dep of ECE

BEC

Digital Signal Processing Lab Manual


Output= [0 0 0]
5. Zeros (2, 4)
Output =0000
0000
6. Ones (5, 2)
The above instruction creates a vector of five rows and two columns
Output =11
11
11
11
11
7. a = [ 1 2 3]
a.*b = [4 10 18]
8. if C= [2 2 2]
b.*C results in [8 10 12]
b = [4 5 6]
9. Plot (t, x)
If x = [6 7 8 9]

t = [1 2 3 4]

This instruction will display a figure window which indicates the plot of x versus t

Dep of ECE

BEC

Digital Signal Processing Lab Manual


10. Stem (t, x):This instruction will display a figure window as shown

11. Subplot: This function divides the figure window into rows and columns.
Subplot (2 2 1) divides the figure window into 2 rows and 2 columns 1 represent number of
the figure

Subplot (3 1 2) divides the figure window into 3 rows and 1 column 2 represent number
of the figure
12. Conv
Syntax: w = conv(u,v)
Description: w = conv(u,v) convolves vectors u and v. Algebraically, convolution is the same
Operation as multiplying the polynomials whose coefficients are the elements of u and v.

13. Disp
Dep of ECE

BEC

Digital Signal Processing Lab Manual


Syntax: disp(X)
Description: disp(X) displays an array, without printing the array name. If X contains a text
String, the string is displayed. Another way to display an array on the screen is to type its name, but
this prints a leading "X=," which is not always desirable. Note that disp does not display empty
arrays.
14. xlabel
Syntax: xlabel('string')
Description: xlabel('string') labels the x-axis of the current axes.
15. ylabel
Syntax : ylabel('string')
Description: ylabel('string') labels the y-axis of the current axes.
16. Title
Syntax: title ('string')
Description: title ('string') outputs the string at the top and in the center of the current axes.
17. grid on
Syntax : grid on
Description: grid on adds major grid lines to the current axes.
18. FFT Discrete Fourier transforms.
FFT(X) is the discrete Fourier transform (DFT) of vector X. For matrices, the FFT operation
is Applied to each column. For N-D arrays, the FFT operation operates on the first non-singleton
Dimension.
FFT(X, N) is the N-point FFT, padded with zeros if X has less than N points and truncated
if it has more.
19. ABS Absolute value.
ABS(X) is the absolute value of the elements of X. When X is complex, ABS(X) is the
complex
Modulus (magnitude) of the elements of X.

20. ANGLE Phase angle.


Dep of ECE

BEC

Digital Signal Processing Lab Manual


ANGLE (H) returns the phase angles, in radians, of a matrix with complex elements.
21. INTERP Resample data at a higher rate using low pass interpolation.
Y = INTERP(X,L) resample the sequence in vector X at L times the original sample rate.
The resulting resembled vector Y is L times longer, LENGTH(Y) = L*LENGTH(X).
22. DECIMATE Resample data at a lower rate after low pass filtering.
Y = DECIMATE(X, M) resamples the sequence in vector X at 1/M times the original
Sample rate. The resulting resampled vector Y is M times shorter, i.e., LENGTH(Y) =CEIL
(LENGTH(X)/M). By default, DECIMATE filters the data with an 8th order Chebyshev Type I low
pass filter with cutoff frequency .8*(Fs/2)/R, before resampling.

Dep of ECE

10

BEC

Digital Signal Processing Lab Manual

1. GENERATION OF SIGNALS
Aim:- To generate the following signals using MAT LAB 2009
1. Unit impulse signal
2. Unit step signal
3. Unit ramp signal
4. Exponential growing signal
5. Exponential decaying signal
6. Sine signal
7. Cosine signal
Apparatus Required:- System with MAT LAB 2009
Algorithm:1. Get the number of samples.
2. Generate the unit impulse, unit step using ones, zeros matrix command.
3. Generate ramp, sine, cosine and exponential signals using corresponding general formula.
4. Plot the graph.

Procedure:1) Open MATLAB


2) Open new M- file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window

Program:
Dep of ECE

11

BEC

Digital Signal Processing Lab Manual


1. Unit impulse signal
clc;
clear all;
close all;
disp('UNIT I MPUL SE SIGNAL ');
N=input(' Enter Number of Samples: ');
n=-N:1:N;
x=[zeros(1, N) 1 zeros(1, N)];
stem(n, x);
xlabel('Time');
ylabel('Amplitude');
title('Impulse Response');
Output:UNIT I MP UL SE SIGNAL
Enter Number of Samples: 6

2. Unit step signal


clc;
clear all;
close all;
disp('UNIT STE P SIGN AL');
N=input ('Enter Number of Samples : ');
n=-N: 1: N;
x= [zeros(1, N) 1 ones (1, N)];
stem(n, x);
xlabel('Time');

Dep of ECE

12

BEC

Digital Signal Processing Lab Manual


ylabel('Amplitude');
title('Unit Step Response');
Output:UNIT ST E P SIGNAL
Enter Number of Samples: 6

3. Unit ramp signal


clc;
clear all;
close all;
disp('UNIT RA MP SIGN AL');
N=input(' Enter Number of Samples : ');
a=input('Enter Amplitude : ');
n=0:1: N;
x=a *n;

stem(n, x);
xlabel('Time');
ylabel('Amplitude');
title('Unit Ramp Response');
Output:UNIT RA MP SIGNAL
Enter Number of Samples: 6
Enter Amplitude: 20

Dep of ECE

13

BEC

Digital Signal Processing Lab Manual


4. Exponential decaying signal
clc;
clear all;
close all;
disp('E XPONE NT IAL DE C AYING SIGNAL ');
N=input (' Enter Number of Samples: ');
a=0.5;
n=0:1:N;
x=a. ^ n;
stem(n, x);
xlabel('Time');
ylabel('Amplitude');
title('Exponential Decaying Signal Response');
Output: E XPONE NT IAL DE CAYIN G SIGNAL
Enter Number of Samples: 6

5. Exponential growing signal


clc;
clear all;
close all;
disp('E XPONE NT IAL GR O WING SIGNAL ');
N=input(' Enter Number of Samples : ');
a=0. 5;
n=0: 1: N;

Dep of ECE

14

BEC

Digital Signal Processing Lab Manual


x=a.^ -n;
stem(n, x);
xlabel('Time');
ylabel('Amplitude');
title ('Exponential Growing Signal Response');
Output:E XPONE NT IAL GRO WING SIGN AL
Enter Number of Samples: 6

6. Cosine signal
clc;
clear all;
close all;
dis p('COSINE SIGNAL ');
N=input(' Enter Number of Samples : ');
n=0: 1: N;
x=cos(n);
stem(n, x);

xlabel('Time');
ylabel('Amplitude');
title('Cosine Signal');
Output:COSINE SIGN AL
Enter Number of Samples : 16

Dep of ECE

15

BEC

Digital Signal Processing Lab Manual

7. Sine signal
clc;
clear all;
close all;
disp('SINE SIGNAL ');
N=input(' Enter Number of Samples : ');
n=0: 1: N;
x=sin (n);
stem(n, x);
xlabel('Time');
ylabel('Amplitude');
title('sine Signal');
Output:SINE SIGN AL
Enter Number of Samples: 16
Result:- Thus the MATLAB program for generation of all basic signals was performed and the
output was verified.

Dep of ECE

16

BEC

Digital Signal Processing Lab Manual

2. Sum Of Sinusoidal Signals


Aim: - To write a MATLAB program to find the sum of sinusoidal signals.
Apparatus required: System with MAT LAB 2009
Procedure:1) Open MATLAB
2) Open new M- file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
Program:% sum of sinusoidal signals
clc;
clear all;
close all;
tic;
t=0: 01: 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;
plot(t,y,t,y1,t,y2,t,y3,t,y4,t,y5);
Dep of ECE

17

BEC

Digital Signal Processing Lab Manual

legend('y','y1','y2','y3','y4',' y5');
title ('generation of sum of sinusoidal signals');
grid on;
ylabel('---> Amplitude');
xlabel('---> t');
toc;

Output:Result: - Thus the MATLAB program for sum of sinusoidal signals was performed and the
output was Verified.

Dep of ECE

18

BEC

Digital Signal Processing Lab Manual

3. Impulse Response of the Difference Equation


Aim: - To find the impulse response of the following difference equation
y(n)-y(n-1)+0.9y(n-2)= x(n)
Apparatus Used: - System with MAT LAB 2009.
Procedure:1) Open MATLAB
2) Open new M- file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
Program:clc;
clear all;
close all;
disp('Difference Equation of a digital system');
N=input ('Desired Impulse response length = ');
b=input ('Coefficients of x[n] terms = ');
a=input ('Coefficients of y[n] terms = ');
h=impz(b,a,N);
disp('Impulse response of the system is h = ');
disp(h);
n=0:1: N-1;
figure (1);
stem (n,h);

Dep of ECE

19

BEC

Digital Signal Processing Lab Manual

xlabel('time index');
ylabel('h[n]');
title('Impulse response');
figure(2);
zplane(b,a);
xlabel('Real part');
ylabel('Imaginary part');
title('Poles and Zeros of H[z] in Z-plane');
Output:Difference Equation of a digital system
Desired Impulse response length = 100
Coefficients of x[n] terms = 1
Coefficients of y[n] terms = [1 -1 0.9]
Result:-Thus the MATLAB program for Impulse Response of Difference Equation was
performed and the output was verified

Dep of ECE

20

BEC

Digital Signal Processing Lab Manual

4. Frequency Response Of A Given System Given In


(Transfer Function/ Difference equation form)
Aim: - To find the frequency response of the following difference equation
y(n) 5 y(n1) = x(n) + 4 x(n1)
Apparatus Used: - System with MAT LAB 6.5.
Procedure:1) Open MATLAB
2) Open new M- file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
Program:b = [1, 4]; %Numerator coefficients
a = [1, -5]; %Denominator coefficients
w = -2*pi: pi/256: 2*pi;
[h] = freqz(b, a, w);
subplot(2, 1, 1), plot(w, abs(h));
xlabel('Frequency \omega');
ylabel('Magnitude');
grid on;
subplot(2, 1, 2);
plot(w, angle(h));
xlabel('Frequency \omega');
ylabel('Phase - Radians');
Dep of ECE

21

BEC

Digital Signal Processing Lab Manual

grid on;
Output:Result: - Thus the MATLAB program for Frequency Response of Difference Equation was
performed and the output was verified.
Note: - If the transfer function is given instead of difference equation the n perform the inverse ZTransform and obtain the difference equation and then find the frequency response for the
difference equation using Matlab.

Dep of ECE

22

BEC

Digital Signal Processing Lab Manual

5. Determination Of Power Spectrum


Aim: To obtain power spectrum of given signal using MATLAB.
Apparatus Used:- System with MAT LAB 2009.
Theory: In statistical signal processing the power spectral density is a positive real function of a
frequency variable associated with a stationary stochastic process, or a deterministic function of
time, which has dimensions of power per Hz, or energy per Hz. It is often called simply the spectrum
of the signal. Intuitively, the spectral density captures the frequency content of a stochastic process
and helps identify periodicities. The PSD is the FT of autocorrelation function, R() of the signal if
the signal can be treated as a wide-sense stationary random process.
Procedure:1) Open MATLAB
2) Open new M- file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
Program:%Power spectral density
t = 0:0.001:0.6;
x = sin(2*pi*50*t)+sin(2*pi*120*t);
y = x + 2*randn(size(t));
figure,plot(1000*t(1:50),y(1:50));
title('Signal Corrupted with Zero-Mean Random Noise');
xlabel('time (milliseconds)');
Y = fft(y,512);
%The power spectral density, a measurement of the energy at various frequencies, is:

Pyy = Y.* conj(Y) / 512;


Dep of ECE

23

BEC

Digital Signal Processing Lab Manual

f = 1000*(0:256)/512;
figure,plot(f,Pyy(1:257));
title('Frequency content of y');
xlabel('frequency (Hz)');

Output:Result: - Thus the MATLAB program for Power Spectral Density was performed and the
output was verified.

Dep of ECE

24

BEC

Digital Signal Processing Lab Manual

6. FIR Low Pass Filter Design


Aim: - To Design FIR LP Filter using Rectangular/Triangular/kaiser Windowing Technique.
Apparatus Used:- System with MAT LAB 2009.
Algorithm:1) Enter the pass band ripple (rp) and stop band ripple (rs).
2) Enter the pass band frequency (fp) and stop band frequency (fs).
3) Get the sampling frequency (f), beta value.
4) Calculate the analog pass band edge frequencies, w1 and w2.
w1 = 2*fp/f
w2 = 2*fs/f
5) Calculate the numerator and denominator
6) Use an If condition and ask the user to choose either Rectangular Window or Triangular
Window or Kaiser window..
7) Use rectwin,triang,kaiser commands
8) Calculate the magnitude of the frequency response in decibels (dB
m=20*log10(abs(h))
9) Plot the magnitude response [magnitude in dB Vs normalized frequency (om/pi)]
10) Give relevant names to x and y axes and give an appropriate title for the plot.
11) Plot all the responses in a single figure window.[Make use of subplot]
Procedure:1) Open MATLAB
2) Open new M- file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
Dep of ECE

25

BEC

Digital Signal Processing Lab Manual

Program:%FIR Filter design window techniques


clc;
clear all;
close all;
rp=input('enter passband ripple');
rs=input('enter the stopband ripple');
fp=input('enter passband freq');
fs=input('enter stopband freq');
f=input('enter sampling freq ');
beta=input('enter beta value);
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
c=input('enter your choice of window function 1. rectangular 2. triangular 3.kaiser: \n ');
if(c==1)
y=rectwin(n1);
disp('Rectangular window filter response');
Dep of ECE

26

BEC

Digital Signal Processing Lab Manual

end
if (c==2)
y=triang(n1);
disp('Triangular window filter response');
end
if(c==3)
y=kaiser(n1,beta);
disp('kaiser window filter response');
end
%LPF
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
plot(o/pi,m);
title('LPF');
ylabel('Gain in dB-->');
xlabel('(a) Normalized frequency-->');
Output:enter pass band ripple0.02
enter the stop band ripple0.01
enter pass band freq1000
enter stop band freq1500
enter sampling freq10000
enter beta value
enter your choice of window function 1. rectangular 2. triangular 3.kaiser:
Dep of ECE

27

BEC

Digital Signal Processing Lab Manual

1
Rectangular window filter response
enter your choice of window function 1. Rectangular 2. triangular 3.kaiser:
2
Triangular window filter response
enter beta value5
enter your choice of window function 1. rectangular 2. triangular 3.kaiser:
3
kaiser window filter response
Result:- Thus FIR LP Filter is designed for Rectangular/triangular/kaiser windowing techniques
using MATLAB.

Dep of ECE

28

BEC

Digital Signal Processing Lab Manual

7. FIR High Pass Filter Design


Aim: - To Design FIR HP Filter using Rectangular/Triangular/kaiser Windowing Technique.
Apparatus Used:- System with MAT LAB 2009.
Algorithm:1) Enter the pass band ripple (rp) and stop band ripple (rs).
2) Enter the pass band frequency (fp) and stop band frequency (fs).
3) Get the sampling frequency (f), beta value.
4) Calculate the analog pass band edge frequencies, w1 and w2.
w1 = 2*fp/f
w2 = 2*fs/f
5) Calculate the numerator and denominator
6) Use an If condition and ask the user to choose either Rectangular Window or Triangular
window or Kaiser window..
7) Use rectwin,triang,kaiser commands
8) Calculate the magnitude of the frequency response in decibels (dB
m=20*log10(abs(h))
9) Plot the magnitude response [magnitude in dB Vs normalized frequency (om/pi)]
10) Give relevant names to x and y axes and give an appropriate title for the plot.
11) Plot all the responses in a single figure window.[Make use of subplot]
Procedure:1) Open MATLAB
2) Open new M- file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
Dep of ECE

29

BEC

Digital Signal Processing Lab Manual


Program:%FIR Filter design window techniques
clc;
clear all;
close all;
rp=input('enter pass band ripple');
rs=input('enter the stop band ripple');
fp=input('enter pass band freq');
fs=input('enter stop band freq');
f=input('enter sampling freq ');
beta=input('enter beta value');
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
c=input('enter your choice of window function 1. rectangular 2. triangular 3.kaiser: \n ');
if(c==1)
y=rectwin(n1);
disp('Rectangular window filter response');
end
Dep of ECE

30

BEC

Digital Signal Processing Lab Manual

if (c==2)
y=triang(n1);
disp('Triangular window filter response');
end
if(c==3)
y=kaiser(n1,beta);
disp('kaiser window filter response');
end
%HPF
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
plot(o/pi,m);
title('HPF');
ylabel('Gain in dB-->');
xlabel('(b) Normalized frequency-->');
Output:enter pass band ripple0.02
enter the stop band ripple0.01
enter pass band freq1000
enter stop band freq1500
enter sampling freq10000
enter beta value
enter your choice of window function 1. rectangular 2. triangular 3.kaiser:
1
Dep of ECE

31

BEC

Digital Signal Processing Lab Manual

Rectangular window filter response


enter your choice of window function 1. rectangular 2. triangular 3.kaiser:
2
triangular window filter response
enter beta value5
enter your choice of window function 1. rectangular 2. triangular 3.kaiser:
3
kaiser window filter response
Result: - Thus FIR HP Filter is designed for Rectangular/triangular/kaiser windowing techniques
using MATLAB.

Dep of ECE

32

BEC

Digital Signal Processing Lab Manual

8. IIR Low Pass Filter Design


Aim: -To Design and generate IIR Butterworth Analog LP Filter using MATLAB
Apparatus Required:- System with MAT LAB 2009.
Algorithm:1) Enter the pass band ripple (rp) and stop band ripple (rs).
2) Enter the pass band frequency (fp) and stop band frequency (fs).
3) Get the sampling frequency (f).
4) Calculate the analog pass band edge frequencies, w1 and w2.
w1 = 2*fp/f
w2 = 2*fs/f
5) Calculate the order and 3dB cutoff frequency of the analog filter. [Make use of the following
function]
[n,wn]=buttord(w1,w2,rp,rs,s)
6) Design an nth order analog lowpass Butter worth filter using the following statement.
[b,a]=butter(n,wn,s)
7) Find the complex frequency response of the filter by using freqs( )
function
[h,om]=freqs(b,a,w)
where, w = 0:.01:pi
This function returns complex frequency response vector h and frequency vector om in
Radians/samples of the filter.
8) Calculate the magnitude of the frequency response in decibels (dB
m=20*log10(abs(h))
9) Plot the magnitude response [magnitude in dB Vs normalized frequency (om/pi)]
10) Calculate the phase response using an = angle(h)
11) Plot the phase response [phase in radians Vs normalized frequency (om/pi)]
Dep of ECE

33

BEC

Digital Signal Processing Lab Manual

12) Give relevant names to x and y axes and gives an appropriate title for the plot.
13) Plot all the responses in a single figure window.[Make use of subplot]
Procedure:1) Open MATLAB
2) Open new M- file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
Program:% IIR filters
clc;
clear all;
close all;
warning off;
disp('enter the IIR filter design specifications');
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
wp=input('enter the passband freq');
ws=input('enter the stopband freq');
fs=input('enter the sampling freq');
w1=2*wp/fs;w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs,'s');
disp('Frequency response of IIR HPF is:');
[b,a]=butter(n,wn,'low','s');
Dep of ECE

34

BEC

Digital Signal Processing Lab Manual


w=0:.01: pi;
[h,om]=freqs(b,a,w);
% Find the order n and cut off frequency
% Find the filter co-efficients of LPF
% Plot the frequency response
m=20*log10(abs(h));
subplot(2,1,1);
plot(om/pi,m);
title('magnitude response of IIR Low Pass filter is:');
xlabel('(a) Normalized freq. -->');
ylabel('Gain in dB-->');
an=angle(h);
subplot(2,1,2);
plot(om/pi,an);
title('phase response of IIR Low Pass filter is:');
xlabel('(b) Normalized freq. -->');
ylabel('Phase in radians-->');
Output:enter the IIR filter design s pacifications
enter the pass band ripple 0. 15
enter the stop band ripple 60
enter the pass band freq1500
enter the stop band freq3000
enter the sampling freq7000
Frequency response of IIR L PF is:
Result:- Thus IIR Low Pass Filter is designed using MATLAB.
Dep of ECE

35

BEC

Digital Signal Processing Lab Manual


9. IIR High Pass Filter Design
Aim: -To Design and generate IIR Butterworth Analog HP Filter using MATLAB
Apparatus Required:- System with MAT LAB 2009.
Algorithm:1) Enter the pass band ripple (rp) and stop band ripple (rs).
2) Enter the pass band frequency (fp) and stop band frequency (fs).
3) Get the sampling frequency (f).
4) Calculate the analog pass band edge frequencies, w1 and w2.
w1 = 2*fp/f
w2 = 2*fs/f
5) Calculate the order and 3dB cutoff frequency of the analog filter. [Make use of the following
function]
[n,wn]=buttord(w1,w2,rp,rs,s)
6) Design an nth order analog high pass Butter worth filter using the following statement.
[b,a]=butter (n,wn,high,s)
7) Find the complex frequency response of the filter by using freqs( ) function
[h,om]=freqs(b,a,w) where, w = 0:.01:pi
This function returns complex frequency response vector h and frequency vector om in
radians/samples of the filter.
8) Calculate the magnitude of the frequency response in decibels (dB
m=20*log10(abs(h))
9) Plot the magnitude response [magnitude in dB Vs normalized frequency (om/pi)]
10) Calculate the phase response using an = angle (h)
11) Plot the phase response [phase in radians Vs normalized frequency (om/pi)]
12) Give relevant names to x and y axes and gives an appropriate title for the plot.
13) Plot all the responses in a single figure window. [Make use of subplot]
Dep of ECE

36

BEC

Digital Signal Processing Lab Manual

Procedure:1) Open MATLAB


2) Open new M- file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
Program:% IIR filters
clc;
clear all;
close all;
warning off;
disp('enter the IIR filter design specifications');
rp=input('enter the pass band ripple');
rs=input('enter the stop band ripple');
wp=input('enter the pass band freq');
ws=input('enter the stop band freq');
fs=input('enter the sampling freq');
w1=2*wp/fs;w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs,'s');
disp('Frequency response of IIR HPF is:');
[b,a]=butter (n, wn,'high','s');
% Find the order n and cut off frequency
% Find the filter co-efficients of HPF
Dep of ECE

37

BEC

Digital Signal Processing Lab Manual

w=0:.01:pi;
[h,om]=freqs(b,a,w);
% Plot the frequency response
m=20*log10(abs(h));
subplot(2,1,1);
plot(om/pi,m);
title('magnitude response of IIR High Pass filter is:');
xlabel('(a) Normalized freq. -->');
ylabel('Gain in dB-->');
an=angle(h);
subplot(2,1,2);
plot(om/pi,an);
title('phase response of IIR High Pass filter is:');
xlabel('(b) Normalized freq. -->');
ylabel('Phase in radians-->');
Output:enter the IIR filter design specifications
enter the pass band ripple 0. 15
enter the stop band ripple 60
enter the pass band freq1500
enter the stop band freq3000
enter the sampling freq7000
Frequency response of IIR HPF is:
Result:- Thus IIR High Pass Filter is designed using MATLAB.

Dep of ECE

38

BEC

Digital Signal Processing Lab Manual

10. Implementation Of FFT


Aim: To perform the FFT of signal x(n) using Mat lab.
Apparatus require d: System with MAT LAB 2009.
Theory: - A fast Fourier transform (FFT) is an efficient algorithm to compute the discrete Fourier
transform (DFT) and its inverse. FFTs are of great importance to a wide variety of applications,
from digital signal processing and solving partial differential equations to algorithms for quick
multiplication of large integers.
Evaluating the sums of DFT directly would take O(N 2) arithmetical operations. An FFT
is an algorithm to compute the same result in only O(N log N) operations. In general, such
algorithms depend upon the factorization of N, but there are FFTs with O(N log N) complexity
for all N, even for prime N. Since the inverse DFT is the same as the DFT, but with the opposite
sign in the exponent and a 1/N factor, any FFT algorithm can easily be adapted for it as well.
Algorithm:
1) Get the input sequence
2) Number of DFT point (m) is 8
3) Find out the FFT function using MATLAB function.
4) Display the input & outputs sequence using stem function
Procedure:1) Open MATLAB
2) Open new M- file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window

Dep of ECE

39

BEC

Digital Signal Processing Lab Manual


Program:
clear all;
N=8;
m=8;
a=input('Enter the input sequence');
n=0:1:N-1;
subplot(2,2,1);
stem(n,a);
xlabel('Time Index n');
ylabel('Amplitude');
title('Sequence');
x=fft(a,m);
k=0:1:N-1;
subplot(2,2,2);
stem(k,abs(x));
ylabel('magnitude');
xlabel('Frequency Index K');
title('Magnitude of the DFT sample');
subplot(2,2,3);
stem(k,angle(x));
xlabel('Frequency Index K');
ylabel('Phase');
title('Phase of DFT sample');
ylabel('Convolution');
Output:Enter the input sequence [1 1 1 1 0 0 0 0]
Result:- Thus Fast Fourier Transform is Performed using Matlab.

Dep of ECE

40

BEC

Digital Signal Processing Lab Manual

11. Discrete Fourier Transform (DFT)


Aim:- To perform the DFT of signal x(n) using Mat lab.
Apparatus require d: A PC with Mat Lab 2009.
Theory:- Discrete Fourier Transform (DFT) is used for performing frequency analysis of
discrete time signals. DFT gives a discrete frequency domain representation whereas the other
transforms are continuous in frequency domain. The N point DFT of discrete time signal x[n] is
given by the equation The inverse DFT allows us to recover the sequence x[n] from the frequency
samples. X(k) is a complex number (remember ejw=cosw + jsinw). It has both magnitude and phase
which are plotted versus k. These plots are magnitude and phase spectrum of x[n]. The k gives us
the frequency information. Here k=N in the frequency domain corresponds to sampling frequency
(fs). Increasing N, increases the frequency resolution, i.e., it improves the spectral characteristics of
the sequence. For example if fs=8kHz and N=8 point DFT, then in the resulting spectrum, k=1
corresponds to 1kHz frequency. For the same fs and x[n], if N=80 point DFT is computed, then in
the resulting spectrum, k=1 corresponds to 100Hz frequency. Hence, the resolution in frequency is
increased. Since N L, increasing N to 8 from 80 for the same x[n] implies x[n] is still the same
sequence (<8), the rest of x[n] is padded with zeros. This implies that there is no further information
in time domain, but the resulting spectrum has higher frequency resolution. This spectrum is known
as high density spectrum (resulting from zero padding x[n]). Instead of zero padding, for higher N,
if more number of points of x[n] are taken (more data in time domain), then the resulting spectrum is
called a high resolution spectrum.
Procedure:1) Open MATLAB
2) Open new M- file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
Program:
clc;
x1 = input('Enter the sequence:');
n = input('Enter the length:');

Dep of ECE

41

BEC

Digital Signal Processing Lab Manual


m = fft(x1,n);
disp('N-point DFT of a given sequence:');
disp(m);
N = 0:1:n-1;
subplot(2,2,1);
stem(N,m);
xlabel('Length');
ylabel('Magnitude of X(k)');
title('Magnitude spectrum:');
an = angle(m);
subplot(2,2,2);
stem(N, an);
xlabel('Length');
ylabel('Phase of X(k)');
title('Phase spectrum:');
Output:Enter the sequence:[1 1 0 0]
Enter the length:4
N-point DFT of a given sequence:
Columns 1 through 3
2.0000
Column 4
1.0000 + 1.0000i
1.0000 - 1.0000i
0
Result: - Thus Discrete Fourier Transform is Performed using Matlab.
Dep of ECE

42

BEC

Digital Signal Processing Lab Manual

12. Implementation Of Decimation Process


Aim:- To perform Decimation process using Mat lab.
Apparatus require d: System with MAT LAB 2009.
Theory:-Sampling rate conversion (SRC) is a process of converting a discrete-time signal at a given
rate to a different rate. This technique is encountered in many application areas such as:

Digital Audio
Communications systems
Speech Processing
Antenna Systems
Radar Systems etc

Sampling rates may be changed upward or downward. Increasing the sampling rate is called
interpolation, and decreasing the sampling rate is called decimation. Reducing the sampling rate
by a factor of M is achieved by discarding every M-1 samples, or, equivalently keeping every
Mth sample. Increasing the sampling rate by a factor of L (interpolation by factor L) is achieved
by inserting L-1 zeros into the output stream after every sample from the input stream of
samples. This system can perform SRC for the following cases:
Decimation by a factor of M
Interpolation by a factor of L
SRC by a rational factor of L/M.
Decimator:
To reduce the sampling rate by an integer factor M, assume a new sampling period
The re-sampled signal is
The system for performing this operation, called down-sampler, is shown below:
Down-sampling generally results in aliasing. Therefore, in order to prevent aliasing, x(n)
should be filtered prior to down-sampling with a low-pass filter that has a cutoff frequency
The cascade of a low-pass filter with a down-sampler illustrated below and is called
decimator.

Dep of ECE

43

BEC

Digital Signal Processing Lab Manual

Procedure:1) Open MATLAB


2) Open new M- file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
Program:% Illustration of Decimation Process
clc;
close all;
clear all;
M = input('enter Down-sampling factor : ');
N = input('enter number of samples :');
n = 0:N-1;
x = sin(2*pi*0.043*n) + sin(2*pi*0.031*n);
y = decimate(x,M,'fir');
subplot(2,1,1);
stem(n,x(1:N));
title('Input Sequence');
xlabel('Time index n');
ylabel('Amplitude');
subplot(2,1,2);
m = 0 :( N/M)-1;
stem(m,y(1:N/M));
Dep of ECE

44

BEC

Digital Signal Processing Lab Manual

title('Output Sequence');
xlabel('Time index n');ylabel('Amplitude');
Output:enter Down-sampling factor : 3
enter number of samples :100
Result: - Thus Decimation Process is implemented using Mat lab.
Note: - Observe the Output Sequence for Different values of M.

Dep of ECE

45

BEC

Digital Signal Processing Lab Manual

13. Implementation Of Interpolation Process


Aim:- To perform interpolation process using Mat lab.
Apparatus require d:- System with MAT LAB 2009..
Theory: - To increase the sampling rate by an integer factor L. If xa(t) is sampled with a
sampling frequency fs = 1/Ts, then
To increase the sampling rate by an integer factor L, it is necessary to extract the samples
from x(n). The samples of xi(n) for values of n that are integer multiples of L are easily extracted
from x(n) as follows:
The system performing the operation is called up-sampler and is shown below:
After up-sampling, it is necessary to remove the frequency scaled images in xi(n), except those
that are at integer multiples of 2. This is accomplished by filtering xi(n) with a low-pass filter
that has a cutoff frequency of /L and a gain of L. In the time domain, the low-pass filter inter polates between the samples at integer multiples of L as shown below and is called interpolator.
Procedure:1) Open MATLAB
2) Open new M- file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6)For the output see command window\ Figure window
Program:% Illustration of Interpolation Process
clc;
close all;
clear all;
L = input('Up-sampling factor = ');
Dep of ECE

46

BEC

Digital Signal Processing Lab Manual

N = input('enter number of samples :');


n = 0:N-1;
x = sin(2*pi*0.043*n) + sin(2*pi*0.031*n);
y = interp(x,L);
subplot(2,1,1);
stem(n,x(1:N));
title('Input Sequence');
xlabel('Time index n');
ylabel('Amplitude');
subplot(2,1,2);
m = 0:(N*L)-1;
stem(m,y(1:N*L));
title('Output Sequence');
xlabel('Time index n');
ylabel('Amplitude');
Output:Result: - Thus Interpolation Process is implemented using Mat lab.
Note: - Observe the Output Sequence for Different values of L.

Dep of ECE

47

BEC

Digital Signal Processing Lab Manual

14. Implementation Of I/D Sampling Rate Converters


Aim:- To study sampling rate conversion by a rational form using MATLAB
Apparatus require d: Syste m with MAT L AB 6. 5.
Theory:SRC by rational factor: SRC by L/M requires performing an interpolation to a sampling rate which is
divisible by both L and M. The final output is then achieved by decimating by a factor of M. The
need for a non-integer sampling rate conversion appears when the two systems operating at different
sampling rates have to be connected, or when there is a need to convert the sampling rate of the
recorded data into another sampling rate for further processing or reproduction. Such applications
are very common in telecommunications, digital audio, multimedia and others. An example is
transferring data from compact disc (CD) system at a rate of 44.1 kHz to a digital audio tape at 48
kHz. This can be achieved by increasing the data rate of the CD by a factor of 48/44.1, a non-integer.
Illustration for sampling rate converter is: If M>L, the resulting operation is a decimation process by
a non- integer, and when M<L it is interpolation. If M=1, the generalized system reduces to the
simple integer interpolation and if L=1 it reduces to integer decimation.
Procedure:1) Open MATLAB
2) Open new M- file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
Program:clc;
close all;
clear all;
L = input('Enter Up-sampling factor :');
M = input('Enter Down-sampling factor :');
N = input('Enter number of samples :');
n = 0:N-1;

Dep of ECE

48

BEC

Digital Signal Processing Lab Manual


x = sin(2*pi*0.43*n) + sin(2*pi*0.31*n);
y = resample(x,L,M);
subplot(2,1,1);
stem(n,x(1:N));
axis([0 29 -2.2 2.2]);
title('Input Sequence');
xlabel('Time index n'); ylabel('Amplitude');
subplot(2,1,2);
m = 0:(N*L/M)-1;
stem(m,y(1:N*L/M));
axis([0 (N*L/M)-1 -2.2 2.2]);
title('Output Sequence');
xlabel('Time index n'); ylabel('Amplitude');
Output:Enter Up-sampling factor: 7
Enter Down-sampling factor: 2
Enter number of samples: 30
Result: - Thus sampling rate conversion by a rational form is performed using MATLAB
Note: - Observe the Output Sequence for Different values of L & M.

Dep of ECE

49

BEC

Digital Signal Processing Lab Manual

CYCLE 2

Dep of ECE

50

BEC

Digital Signal Processing Lab Manual

INTRODUCTION TO DSP PROCESSORS


A digital signal processor (DSP) is an integrated circuit designed for highspeed data manipulations, and is used in audio, communications, image manipulation, and other
Data-acquisition and data-control applications. The microprocessors used in personal computers
are optimized for tasks involving data movement and inequality testing. The typical applications
requiring such capabilities are word processing, database management, spread sheets, etc. When
it comes to mathematical computations the traditional microprocessor are deficient particularly
where real-time performance is required. Digital signal processors are microprocessors
optimized for basic mathematical calculations such as additions and multiplications.
Fixed versus Floating Point:
Digital Signal Processing can be divided into two categories, fixed point and
floating point which refer to the format used to store and manipulate numbers within the devices.
Fixed point DSPs usually represent each number with a minimum of 16 bits, although a different
length can be used. There are four common ways that these 216 i,e., 65,536 possible bit patterns
can represent a number. In unsigned integer, the stored number can take on any integer value
from 0 to 65,535, signed integer uses two's complement to include negative numbers from 32,768 to 32,767. With unsigned fraction notation, the 65,536 levels are spread uniformly
between 0 and 1 and the signed fraction format allows negative numbers, equally spaced
between -1 and 1.
The floating point DSPs typically use a minimum of 32 bits to store each value. This results in
many more bit patterns than for fixed point, 232 i,e., 4,294,967,296 to be exact. All floating point
DSPs can also handle fixed point numbers, a necessity to implement counters, loops, and signals
coming from the ADC and going to the DAC. However, this doesn't mean that fixed point math
will be carried out as quickly as the floating point operations; it depends on the internal
architecture.

Dep of ECE

51

BEC

Digital Signal Processing Lab Manual


C versus Assembly:
DSPs are programmed in the same languages as other scientific and engineering applications,
usually assembly or C. Programs written in assembly can execute faster, while programs written
in C are easier to develop and maintain. In traditional applications, such as programs run on PCs
and mainframes, C is almost always the first choice. If assembly is used at all, it is restricted to
short subroutines that must run with the utmost speed.
How fast are DSPs?
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 of DSP devices covers a wide range, from a 16-bit fixedpoint 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 applications. These include almost any
filters, analyzers, hi-fi systems, voice- mail, imaging, bar-code readers, motor control, 3D
graphics, or scientific processing.

Dep of ECE

52

BEC

Digital Signal Processing Lab Manual


C4x: This range is designed for parallel processing. The C4x devices have a 32-bit data bus and
are floating-point. They have an optimized on-chip communication channel, which enables a
number of them to be put together to form a parallel-processing cluster. The C4x range devices
have been used in virtual reality, image recognition, telecom routing, and parallel-processing
systems.
C6x: The C6x devices feature VelociTI , an advanced very long instruction word (VLIW)
architecture developed by Texas Instruments. Eight functional units, including two multipliers
and six arithmetic logic units (ALUs), provide 1600 MIPS of cost-effective performance. The
C6x DSPs are optimized for multi-channel, multifunction applications, including wireless base
stations, pooled modems, remote-access servers, digital subscriber loop systems, cable modems,
and multi-channel telephone systems.
Typical Applications for the TMS320 Family
The TMS320 DSPs offer adaptable approaches to traditional signal-processing problems and
support complex applications that often require multiple operations to be performed
simultaneously.

Dep of ECE

53

BEC

Digital Signal Processing Lab Manual

INTRODUCTION TO TMS 320 C6713 DSK


The highperformance board features the TMS320C6713 floating-point DSP. Capable of
performing 1350 million floating point operations per second, the C6713 DSK the most powerful
DSK development board.

Dep of ECE

54

BEC

Digital Signal Processing Lab Manual


The DSK is USB port interfaced platform that allows efficiently developing and testing
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 Starter 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 Floating Point DSP


AIC23 Stereo Codec
Four Position User DIP Switch and Four User LEDs
On-board Flash and SDRAM

TIs Code Composer Studio 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. On-chip peripherals include a 32- bit external
memory interface (EMIF) with integrated SDRAM controller, 2 multi-channel 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 onchip resources. The 6713 has a significant amount of internal memory so many applications will
have all code and 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 on-board 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. Digital data is sent to and from the codec on McBSP1.

TMS320C6745 DSK Overview Block Diagram


Dep of ECE

55

BEC

Digital Signal Processing Lab Manual

Dep of ECE

56

BEC

Digital Signal Processing Lab Manual


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 CPLD implements a set of 4 software programmable registers that can be used to
access the on-board LEDs and DIP switches as well as control the daughter card interface.
DSK hardware installation
Shut down and power off the PC
Connect the supplied USB port cable to the board
Connect the other end of the cable to the USB port of PC
Plug the other end of the power cable into a power outlet
Plug the power cable into the board
The user LEDs should flash several times to indicate board is operational
When you connect your DSK through USB for the first time on a Windows
Loaded PC the new hardware found wizard will come up. So, install the drivers
(The CCS CD contains the require drivers for C6745 DSK).
Install the CCS software for C6745 DSK.

Troubleshooting DSK Connectivity


If Code Composer Studio IDE fails to configure your port correctly, perform the following steps:
Test the USB port by running DSK Port test from the start menu Use Start Programs Texas
InstrumentsComposer Studio Code Composer Studio
C6745 DSK Tools DSK Diagnostic Utilities
The below Screen will appear
Select 6745 DSK Diagnostic Utility Icon from Desktop
The Screen Look like as below
Select Start Option
Utility Program will test the board
After testing Diagnostic Status you will get PASS

INTRODUCTION TO CODE COMPOSER STUDIO


Dep of ECE

57

BEC

Digital Signal Processing Lab Manual


Code Composer is the DSP industry's first fully integrated development environment (IDE) with
DSP-specific functionality. With a familiar environment liked MS-based C++TM, Code
Composer lets you edit, build, debug, profile and manage projects from a single unified
environment. Other unique features include graphical signal analysis, injection/extraction of data
signals via file I/O, multi-processor debugging, automated testing and customization via a Cinterpretive 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
Useful Types of Files
You will be working with a number of files with different extensions. They include:
1. file.pjt: to create and build a project named file.
2.
file.c: C source program.
3. file.asm: assembly source program created by the user, by the C compiler, or by the linear
optimizer.
Dep of ECE

58

BEC

Digital Signal Processing Lab Manual


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.
Digital Signal Processing Lab Manual
Page 64

Department of Electronics and Communication

6. file.lib: library file, such as the run-time support library file rts6701.lib.
7. file.cmd: linker command file that maps sections to memory.
8. file.obj: object file created by the assembler.
9. file.out: executable file created by the linker to be loaded and run on the processor.
Procedure to work on code composer studio
1.Click on CCStudio 3.1 on the desktop
Now the target is not connected in order to connect Debugconnect
2. To create project, Project New
Digital Signal Processing Lab Manual
Page 65

Department of Electronics and Communication

3. Give project name and click on finish.


Dep of ECE

59

BEC

Digital Signal Processing Lab Manual


4. Click on File New Source File, To write the Source Code
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>
6. To add rts6700.lib to the project
Project Add files to project rts6700.lib
Path: C:\CCstudio\c6000\lib\rts6700.lib
Note: Select Object & library files (*.o, *.l) in Type of file
Digital Signal Processing Lab Manual
Page 66

Department of Electronics and Communication

7. To add hello.cmd to the project


Project Add files to project hello.cmd
Path: C:\CCstudio\tutorial\dsk6713\hello1\hello.cmd
Note: Select Linker command file (*.cmd) in Type of file
8. To compile
Project Compile file ( or use icon or ctrl+F7 )
9. To build or link
Project build (or use F7 ) (which will create a .out file in project folder)
Digital Signal Processing Lab Manual
Page 67

Dep of ECE

60

BEC

Digital Signal Processing Lab Manual

Department of Electronics and Communication

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
Digital Signal Processing Lab Manual
Page 68

Department of Electronics and Communication

1. Generation of sine wave and square wave


Aim:- To generate a sine wave and square wave using C6713 simulator
Equipments:Operating System - Windows XP
Software - CC STUDIO 3
DSK 6713 DSP Trainer kit.
USB Cable
Dep of ECE

61

BEC

Digital Signal Processing Lab Manual


Power supply
Procedure:1. Open Code Composer Setup and select C6713 simulator, click save and quit
2. Start a new project using ProjectNew pull down menu, save it in a separate directory
(C:\My projects) with file name sine wave.pjt
3. Create a new source file using File New Source file menu and save it in the project
folder(sinewave.c)
4. Add the source file (sinewave.c) to the project
ProjectAdd files to Project Select sinewave.c
5. Add the linker command file hello.cmd
ProjectAdd files to Project
(path: C:\CCstudio\tutorial\dsk6713\hello\hello.cmd)
6. Add the run time support library file rts6700.lib
ProjectAdd 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 projectBuild 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 GraphTime and Frequency
12. Repeat the steps 2 to 11 for square wave
Digital Signal Processing Lab Manual
Page 69

Dep of ECE

62

BEC

Digital Signal Processing Lab Manual

Department of Electronics and Communication

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++)
Dep of ECE

63

BEC

Digital Signal Processing Lab Manual


{
for (j=0;j<=50;j++)
{
a [(50*i)+j]=b;
}
b=b*(-1);
}
}

Output:Sine wave
Square wave:Result: - The sine wave and square wave has been obtained.

2. Linear Convolution
Aim: -To verify Linear Convolution.
Equipments:

Operating System - 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 linearconv.pjt
3. Create a new source file using File New Source file menu and save it in the project
folder (linearconv.c)

Dep of ECE

64

BEC

Digital Signal Processing Lab Manual


4. Add the source file (linearconv.c) to the project
Project Add files to Project Select linearconv.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 usingproject Compile menu or by Ctrl+F7
8. Build the program using project Build menu or by F7
9. Load the linearconv.out file (from project folder impulse response\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. Observe the values in the output window.
Program:
// Linear convolution program in c language using CC Studio
#include<stdio.h>
int x[15],h[15],y[15];
main ()
{
int i,j,m,n;
printf("\n enter value for m");
scanf("%d",&m);
printf("\n enter value for n");
Dep of ECE

65

BEC

Digital Signal Processing Lab Manual


scanf("%d",&n);
printf("Enter values for i/p x(n):\n");
for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf("Enter Values for i/p h(n) \n");
for (i=0;i<n; i++)
scanf("%d",&h[i]);
// padding of zeros
for(i=m;i<=m+n-1;i++)
x[i]=0;
for (i=n;i<=m+n-1;i++)
h[i]=0;
/* convolution operation */
for(i=0;i<m+n-1;i++)
{
y[i]=0;
for (j=0;j<=i;j++)
{
y[i]=y[i]+(x[j]*h[i-j]);
}
}
//displaying the o/p
for(i=0;i<m+n-1;i++)
printf("\n The Value of output y[%d]=%d",i,y[i]);
}
Output:Dep of ECE

66

BEC

Digital Signal Processing Lab Manual


Enter value for m 4
Enter value for n 4
Enter values for i/p 1234
Enter Values for n 1234
The Value of output y[0]=1
The Value of output y[1]=4
The Value of output y[2]=10
The Value of output y[3]=20
The Value of output y[4]=25
The Value of output y[5]=24
The Value of output y[6]=16
Precautions:
1) Switch ON the computer only after connecting USB cable and make sure the DSP kit is ON.
2) Perform the diagnostic check before opening code composer studio.
3) All the connections must be tight.
Result: - Thus linear convolution of 2 sequences is verified using CC Studio.

3. Impulse response of first order and second order systems


Aim:- To find Impulse response of a first order and second order system.
Equipments:

Operating System - 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 ProjectNew pull down menu, save it in a separate directory
(C:\My projects) with file name impulseresponse.pjt
Dep of ECE

67

BEC

Digital Signal Processing Lab Manual


3. Create a new source file using FileNew Source file menu and save it in the project folder
(firstorder.c)
4. Add the source file (firstorder.c) to the project
ProjectAdd files to ProjectSelect firstorder.c
5. Add the linker command file hello.cmd
ProjectAdd files to Project
(path: C:\CCstudio\tutorial\dsk6713\hello\hello.cmd)
6. Add the run time support library file rts6700.lib
ProjectAdd files to Project
(Path: C\CCStudio\cgtools\lib\rts6700.lib)
7. Compile the program using projectCompile menu or by Ctrl+F7
8. Build the program using projectBuild menu or by F7
9. Load the firstorder.out file (from project folder impulse response\Debug) using
File Load Program
10. Run the program using DebugRun or F5
11. To view the output graphically
Select View Graph Time and Frequency
12. Repeat the steps 2 to 11 for secondorder
For first order difference equation.
Program:
#include<stdio.h>
#define Order 1
#define Len 5
float h[Len] = {0.0,0.0,0.0,0.0,0.0},sum;
void main()
{
Dep of ECE

68

BEC

Digital Signal Processing Lab Manual


int j, k;
float a[Order+1] = {0.1311, 0.2622};
float b[Order+1] = {1, -0.7478};
for(j=0; j<Len; j++)
{
sum = 0.0;
for(k=1; k<=Order; k++)
{
if((j-k)>=0)
sum = sum+(b[k]*h[j-k]);
}
if(j<=Order)
h[j] = a[j]-sum;
else
h[j] = -sum;
printf("%f", j, h[j]);
}
}
Output:
0.131100 0.360237 0.269385 0.201446 0.150641.
Digital Signal Processing Lab Manual
Page 77

Department of Electronics and Communication


Dep of ECE

69

BEC

Digital Signal Processing Lab Manual

Find out the impulse response of second order difference equation.


Program:
#include<stdio.h>
#define Order 2
#define Len 5
float h[Len] = {0.0,0.0,0.0,0.0,0.0},sum;
void main()
{
int j, k;
float a[Order+1] = {0.1311, 0.2622, 0.1311};
float b[Order+1] = {1, -0.7478, 0.2722};
for(j=0; j<Len; j++)
{
sum = 0.0;
for(k=1; k<=Order; k++)
{
if ((j-k) >= 0)
sum = sum+(b[k]*h[j-k]);
}
if (j <= Order)
h[j] = a[j]-sum;
else
h[j] = -sum;
printf (" %f ,h[j]);
}
Dep of ECE

70

BEC

Digital Signal Processing Lab Manual


}
Output:
0.131100 0.360237 0.364799 0.174741 0.031373
Result:- Impulse response of a first order and second order system is performed using CC
Studio
Digital Signal Processing Lab Manual
Page 78

General Procedure to work C6745:


1.

Open Code Composer Studio v4 .

2.

In WorkSpace Launcher.

a.
BROWSE Select the project location and make one new folder, MAKE NEW FOLDER
Type the Workspace name, OK OK.
3.

FILE NEW CCS PROJECT

a.

Project name: Type your project name.

b.

Tick use default location.

c.

Project type: C6000.

d.

Tick Debug And Release.

e.

Output type: Executable.

f.

Device Variant : generic C67XX Device.

g.

Device Endianness : little

h.

Code Generation Tools: TI v6.1.12.

i.

Run time support library: automatic.

j.

Target content: none.

4.

FILE NEW SOURCE FILE

Dep of ECE

NEXT

NEXT NEXT.

FINISH

71

BEC

Digital Signal Processing Lab Manual


a.
Source file: Type your projectname.c (.c extension is must).
b.

Type the program.

c.

FILE SAVE.

5.

Paste the following board library files in workspace location.

a.

Common folder (contains header files)

b.

Gel folder (contains gel file)

c.

Library folder(contains library files)

6.

Paste the Linker file in the project location.(linker file is available in cd)

Note: Those folders and linker file are availble at cd.


7.

PROJECT PROPERTIES C/C++ BUILD BASIC OPTION

a.

Target processor version (--silicon version, -mv) : 6400+

OK.

a.
IN C/C++ BUILD, INCLUDE OPTIONS (Add dir to #include search path(--include path,I)) select this add icon and add the following three path by individually

"${Diag}../../common/header"

"${XDAIS_CG_ROOT}/packages/ti/xdais"

"${C6000_CSL_CG_ROOT}/include"

8.

FILE NEW TARGET CONFIGURATION FILE

a.

file name: projectname. ccxml (.ccxml extension is must)

b.

Connection: Texas Instrument XDS100 v1 USB Emulator.

c.
Device: TMS320C6745. SAVE TARTGET CONFIGURATION C674X_0
BROWSE, browse the workspace location, open the gel folder and select the GEL file. OPEN
SAVE.
9.

In C/C++ Project window, Right click the project REBUILD PROJECT.

10.

Connections :

a.

Connect the usb cable, PC to KIT.

b.

Connect the 5v adapter and Power on the kit.

11.

TARGET DEBUG ACTIVE PROJECT.(Then see out at corresponding place after run)

Dep of ECE

72

BEC

Digital Signal Processing Lab Manual


12.
VIEW MEMORY.(if program needs any input, give before run ex:linear convolution)
13.
In right side, memory window will open. Type the adrress and give the input at particular
location.Give the input as follow:
X(n)
h(n)
0xC0001000 00000001...
14.

TARGET RUN.

15.

TARGET HALT.

0xC0001030 00000001....

See the Output at Particular location:


0xC0001050 00000001........

EXP NO 1: GENERATION OF SINUSOIDAL SIGNAL

AIM:
To generate the waveforms of Sine Wave signal

SOFTWARE USED:
CC Studio v4

HARDWARE USED:

DSP Kit (TMS 320C6745)


PROGRAM:
#include<stdio.h>
#include<math.h>
#define PI 3.14

void main()

Dep of ECE

73

BEC

Digital Signal Processing Lab Manual


{
const float sampf = 1024000.0;// Sampling frquency is fixed
const int inpf = 4000; // change the input frquency from 1khz to 8khz(1000 to 8000)
float sampt;
double teta;
short value;
int i,count,nsamp,value1;

sampt = 1/sampf;
nsamp = sampf/inpf;

printf("\n Sampling Frequency is : %f",sampf);


printf("\n Sampling Time is :%f",sampt);
printf("\n Input Frequency is : %d",inpf);
printf("\n The number of Sample is : %d",nsamp);

for(count=0;count<nsamp;count++)
{
teta = (2 * PI * inpf * sampt * count);
printf("\nteta = %lf",teta);

value = sin(teta)*1024;
printf("\t sin %lf Value is : %d",teta,value);

Dep of ECE

74

BEC

Digital Signal Processing Lab Manual


}

Dep of ECE

75

BEC

You might also like