0% found this document useful (0 votes)
240 views63 pages

Signals and Systems Lab Manual

Signal and system full complete notes for beginners

Uploaded by

Deepak Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
240 views63 pages

Signals and Systems Lab Manual

Signal and system full complete notes for beginners

Uploaded by

Deepak Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 63

Rukmini Educational

Charitable Trust

Signals and Systems


Laboratory
Manual
IV Semester

School of Electronics and


Communication Engineering
www.reva.edu.in

Campus Address: Rukmini Knowledge Park, Kattigenahalli, Yelahanka, Bengaluru - 560 064
REVA University School of ECE

BTEC15F4200 L T P C
Signals and Systems Lab
Duration:14 Wks 0 0 2 2

Prerequisites:

Differential and Integral Calculus, Geometric series, Laplace Transform

Course Objectives:

The main objectives of this course are to:

1. To provide insight into fundamentals of Continuous and Discrete-time signals and


systems, their properties and representations through hands-on.

2. To introduce time domain representation of Linear Time invariant Systems such as


convolution sum, convolution Integral, differential equation and difference equations
representation through hands-on.

3. To provide understanding of signal representation in Fourier domain such as Fourier


transform, discrete time Fourier transform through practice.

4. To provide brief understanding of signal representation in Z-domain through hands-on.

5. To give a brief insight into application of Unilateral Z-transform to solve difference


equations through hands-on.

Course Outcomes:

On completion of this course the student will be able to:

1. Illustrate the operations on signals.


2. Compute the energy and power of a specified signal.
3. Apply convolution operation on a LTI system.
4. Demonstrate the sampling theorem.
5. Solve the specified difference equation of a LTI system.

list of Challenging Experimernts:


1. Write a general matlab program for linear convolution for any two general sequences (causal
and non-causal).
2. Write a matlab program to extend the calculation of output for other standard inputs like unit
step, ramp and sinusoid
(can use matlab inbuilt functions).

Signals and Systems Lab Manual Page |1


REVA University School of ECE

Contents

Sl. No TITLE PAGE No.


Introduction To MATLAB 3
1 MATLAB Basics 6
2 A) Generation And Plotting Of Sine Waves 11
B) Generation And Plotting Of Elementary Signals
3 Perform Operations On Dependent Variable Of a Signal. 20
4 Perform Operations On Independent Variable Of a Signal. 23
5 To Calculate Signal Power and Signal Energy 26
6 To Compute The Linear Convolution Of The Given Input Sequence 27
x(n) & The Impulse Response Of The System h(n). (Causal
Sequences)
7 To Compute The Linear Convolution Of The Given Input Sequence 31
x(n) & The Impulse Response Of The System h(n). (Non-Causal
Sequences)
8 Solve Any Given Difference Equation Of An LTI System 33
Without Initial Conditions.
9 Solve Any Given Difference Equation Of An LTI System 36
With Initial Conditions.
10 Demonstration Of Sampling Theorem 38
Texas Instruments (TI) TMS320c6713 DSK KIT
11 C Program To Generate A Sine Wave Using CCS Studio And TI 55
Processor Kit
12 C Program To Compute The Linear Convolution Of The Given Input 56
Sequence x(n) & The Impulse Response Of The System h(n) Using
Using CCS Studio And TI Processor Kit
13 Viva Question and Answers 61

Signals and Systems Lab Manual Page |2


REVA University School of ECE

MATLAB Introduction
What is MATLAB?
MATLAB is the name of a software product developed by a company called

It is very general, powerful and popular. By skill demand, it is one of the top 10 computer
languages. There is no field untouched and uninfluenced by it and is used by millions of
people from all walks of life – students, teachers, researchers etc - worldwide.
Just a pick of the several applications: MATLAB has been used in projects such as
modelling energy consumption to build smart power grids, developing control algorithms for
hypersonic vehicles, analyzing weather data to visualize the track and intensity of hurricanes,
and running millions of simulations to pinpoint optimal dosing.
Why?
BECAUSE MATLAB
• first and foremost, is easy to use. Just like how you write on paper. No variable
declarations, No dimension declarations, No type declarations, No inclusion of libraries and
so on. It is all about mathematical computations -everything from simple to most complex.
• data visualization– i.e. simple to powerful graphics like 3D and animated graphics.
• much much more - for example, symbolic math, importing and exporting of data,
programming, publishing and interfacing to hardware.
• The strength of MATLAB is its matrix-based operations. Ability to deal with several
numbers at the same time rather than one at a time.
• MATLAB handholds from conceptualization to hardware implementation and
acceptance.
• simply put, MATLAB is all about everything you need to do a job from concept to
using.
• superb documentation, embedded help, free source code, demos, videos, user fora and
shared knowledge, MATLAB based subject books....
Disclaimer and scope:
In this introduction to MATLAB, we will only be scratching the surface. Just the flavour of
matlab for understanding its usage in signals and systems lab experiments. Also nothing can
beat built-in MATLAB documentation. But we will give enough push/guidance so that the
reader can be on his own with the various help mechanisms available in MATLAB.
Versions

Signals and Systems Lab Manual Page |3


REVA University School of ECE

MATLAB has two releases every year; they are called like 2015a, 2015b, 2016a, and 2016b.
Next one is expected in Feb-Mar 2017timeframe.
Invoking MATLAB and using MATLAB as a calculator
MATLAB is easier-to-use than a calculator and yet incomparably powerful.
Let us get started! INVOKE MATLAB! By double-clicking on the MATLAB icon on your
desktop.
Let us see some examples of using MATLAB for numerical calculations – MATLAB as a
calculator.

>> What is this?


All your input to the MATLAB goes after this. It is the command prompt. You enter the
instructions/commands after this and initiate execution by pressing the [RETURN]/[ENTER]
key.
% commenting
You can comment any command after entering % after the command. Anything after % till
the end of the line would be ignored by MATLAB
To err is human, to forgive is MATLAB:
When you make typos or enter invalid commands, MATLAB lets you know with informative
messages.
>>fft(1:1e10);
Requested 10000000000x1 (74.5GB) array exceeds maximum array size preference.
Creation of arrays greater than this limit may take a long time and cause MATLAB to
become unresponsive. See array size limit or preference panel for more information.
But/And if you realize your error, there are several ways of correcting your entries.

Signals and Systems Lab Manual Page |4


REVA University School of ECE

You can erase an entire line of command, without executing by pressing the [esc] key.
You can use Up-arrow or Down-arrow keys to access previously executed commands and
execute them after making changes using the LeftArrow, RightArrow to reach the place of
correction. Any previously executed command can be reexecuted as it is – using the same
method – if no correction is needed.
ORDER OF PRECEDENCE:
MATLAB follows normal mathematical rule of operator precedence BODMAS.
() highest precedence
Mathematical constants (not comprehensive list)
pi (MATLAB is case-sensitive, so pi, Pi, pI, PI are all different, for example!)
i,j (square root of -1, as long as you did not change the value of it by assigning some other
value to it.)
>>3+5i
ans =
3.0000 + 5.0000i
All the built-in constants can be reassigned. And other variables can be created with these
values.
How to get out of a logjam?
Ctrl+C
>>a=1;while a==1,end
Ctrl+C
>>
How to get out?
Key in exit or close the MATLAB window.

Signals and Systems Lab Manual Page |5


REVA University School of ECE

1. MATLAB BASICS

In these examples, the results are stored in ‘ans’. So the latest result overwrites the previous
‘ans’.

Sl.
Arithmetic operations MATLAB Expressions
No.
01 2.7183 + 3.1416 2.7183 + 3.1416
02 1947-1857 1947-1857
03 60x60 60*60
04 25 2^5
05 25 2^5 / (2^5-1)
25 − 1
06
3*(sqrt(5)-1) / (sqrt(5)+1)^2-1

07 Area=πr2 with r = π1/3-1 Area=pi*(pi^(1/3)-1)^2

Sl. Exponential and


MATLAB Expressions
No. Logarithms
01 e3 exp(3)
02 ln(e3) log(exp(3))
03 log10(e3) log10(exp(3))
04 log10(105) log10(10^5)
05 eπ√163 exp(pi*sqrt(163))

Signals and Systems Lab Manual Page |6


REVA University School of ECE

Sl.
Trigonometric functions MATLAB Expressions
No.
01 sin (π/6) sin(pi/6)
02 cos (π) cos(pi)
03 tan (π/2 tan(pi/2)
04 Sin2 π/6 + cos2 π/6 (sin(pi/6))^2 + (cos(pi/6))^2

Example:
Given a=3; b=2;c=5; d=3;

1. Evaluate the following MATLAB assignment statements:


a) y = a*b+c*d;
b) y = a*(b+c)*d;
c) y = (a*b)+(c*d);
d) y = a^b^d;
e) y = a^(b^d);

a) y = a*b+c*d
= 3*2+5*3 => 6+15 => 21 => y = 21

b) y = a*(b+c)*d
= 3*(2+5)*3 => 3*7*3 => y = 63

c) y = (a*b)+(c*d)
= (3*2)+(5*3) => 6+15 => y = 21

d) y = a^b^d;
= 3^2^3 => 9^3 => y = 729

e) y = a^(b^d)
= 3^(2^3) => 3^8 => y = 6561

Signals and Systems Lab Manual Page |7


REVA University School of ECE

Matrices MATLAB command


A =[1 2 5; 3 9 0];
1.

A = [1 3 9;5 10 15; 0 0 -5];


OR
2

Initializing with
builtin functions MATLAB
Comments
in MATLAB / Expression
OCTAVE
1. A =
Creates 2X2 with 0’s
zeros(2);
2. B =
Creates 2X3 with 0’s
zeros(2,3);
3. C =
Creates 2X3 with 1’s
ones(2,3);

4. D = Creates 3X3 with diagonal elements


eye(3); as 1

5. E = Creates 3X3 with diagonal elements


4*eye(3); as 4

Array operations:
1. .* => Element by element multiplication
2. ./ => Element by element left division
3. .\ => Element by element right division
4. .^ => Element by element exponentiation

Signals and Systems Lab Manual Page |8


REVA University School of ECE

MATRIX PROBLEMS:

1. Assume

Signals and Systems Lab Manual Page |9


REVA University School of ECE

Simple x, y Plots

MATLAB Code for the given equation y= x2-10x+15


%MATLAB Code for the given equation y= x2-10x+15
clc;
x=0:1:10;
y=x.^2-10.*x+15;
plot(x,y); % plots the value x and y in continuous form
xlabel('x');
ylabel('y');
title('plot of y vs x');
grid on;

output:

%MATLAB Code for the given equation y= x2-10x+15


clc;
x=0:1:10;
y=x.^2-10.*x+15;
stem(x,y); % plots the value x and y in discrete form
xlabel('x');
ylabel('y');
title('plot of y vs x');
grid on;
output:

Signals and Systems Lab Manual P a g e | 10


REVA University School of ECE

2. A) GENERATION AND PLOTTING OF SINE WAVES


Theory:
Sinusoids are the building block of analog signal processing. All real world signals can be
represented as an infinite sum of sinusoidal functions via a Fourier series.

%MATLAB Code for the given equation y= A sin(2πft)


clc;
t=0:0.00001:0.01;
A=10;
f=200;
y=A*sin(2*pi*f*t);
plot(t,y);
xlabel('time axis');
ylabel('Amplitude');
title('sine wave plot');

%MATLAB Code for the given equation y= A cos(2?ft)


clc;
t=0:0.00001:0.01;
A=10;
f=200;
y=A*cos(2*pi*f*t);
plot(t,y);
xlabel('time axis');
ylabel('Amplitude');
title('cosine wave plot');

%MATLAB Code to plot both sine and cosine in one figure window
clc;
t=0:0.00001:0.01;
A=10;
f=200;
y1=A*sin(2*pi*f*t);
y2=A*cos(2*pi*f*t);
plot(t,y1,t,y2);
xlabel('time axis');
ylabel('Amplitude');
title('sine/cosine wave plot');

%MATLAB Code to plot both sine and cosine in separate figure window
clc;
t=0:0.00001:0.01;
A=10;
f=200;
y1=A*sin(2*pi*f*t);
y2=A*cos(2*pi*f*t);
figure(1);

Signals and Systems Lab Manual P a g e | 11


REVA University School of ECE

plot(t,y1);
xlabel('time axis');
ylabel('Amplitude');
title('sine wave plot');

figure(2);
plot(t,y2);
xlabel('time axis');
ylabel('Amplitude');
title('cosine wave plot');

%MATLAB Code to plot both sine and cosine by dividing the figure window:
clc;
t=0:0.00001:0.01;
A=10;
f=200;
y1=A*sin(2*pi*f*t);
y2=A*cos(2*pi*f*t);

subplot(2,1,1);
% Divides the figure window into 2 rows, 1 column and 1st position respectively
plot(t,y1); % plots the waveform in continuous form
xlabel('time axis');
ylabel('Amplitude');
title('sine wave plot');

subplot(2,1,2);
% Divides the figure window into 2 rows, 1 column and 2nd position respectively
plot(t,y2);
xlabel('time axis');
ylabel('Amplitude');
title('cosine wave plot');

Signals and Systems Lab Manual P a g e | 12


REVA University School of ECE

2. B) GENERATION AND PLOTTING OF ELEMENTRY SIGNALS


Theory:
An impulse (Dirac delta function) is defined as a signal that has an infinite magnitude and
an infinitesimally narrow width with an area under it of one, centered at zero.
It is not, in reality, possible to generate such a signal, but it can be sufficiently approximated
with large amplitude, narrow pulse, to produce the theoretical impulse response in a network
to a high degree of accuracy. The symbol for an impulse is δ(t).
Note: If an impulse is used as an input to a system, the output is known as the impulse
response. The impulse response defines the system because all possible frequencies are
represented in the input.
A unit step function is a signal that has a magnitude of zero before zero and a magnitude of
one after zero. The symbol for a unit step is u(t).
Note: If a step is used as the input to a system, the output is called the step response. The step
response shows how a system responds to a sudden input, similar to turning on a switch. The
period before the output stabilizes is called the transient part of a signal. The step response
can be multiplied with other signals to show how the system responds when an input is
suddenly turned on.
%Matlab code for unit impulse signal generation:

clc;
clear all;
close all;
disp('Unit Impulse Signal Generation'); % disp is used to display messages on the
command window
N = input('Enter no of samples:'); % input is used to read the values through console
n = -N : 1 : N;
x = inline('1*(n==0)');
stem(n,x(n));
xlabel('Sample');
ylabel('Amplitude');
title('Unit Impulse Signal');

Output:
Unit Impulse Signal Generation
Enter no of samples: 10

Signals and Systems Lab Manual P a g e | 13


REVA University School of ECE

% MATLAB Code for Generalised Impulse Sequence

% generates impulse sequence delayed by c, in a, between the positions d and e


% to see the unit sample we should satisfy d<=c<=e

% OUTPUT ARGUMENTS
% a the output sequence name
% b position vector for output sequence plotting

% INPUT ARGUMENTS
% c delay of the impulse sequence
% d start position for plotting c
% e end position for plotting e
clc;
clear all;
close all;

c= input(' Enter delay of the impulse sequence c: ');


d= input ('Enter start position for plotting d: ');
e= input (' Enter end position for plotting e: ');
if c<d,
error('impulse sample will not be seen within the range of positions given')
end
n= d:e;
x = inline('1*(n==c)');
stem(n,x(c,n));
xlabel('sample position');
ylabel('sample value');
title('plot of the sequence');

Signals and Systems Lab Manual P a g e | 14


REVA University School of ECE

Output:
Enter delay of the impulse sequence c: 3
Enter start position for plotting d: -10
Enter end position for plotting e: 10

% MATLAB code for unit step signal generation:


clc;
clear all;
close all;
disp('Unit Step Signal Generation');
N = input('Enter no of samples: ');
n = -N : 1 : N;
x = inline('1*(n>=0)');
stem(n,x(n));
xlabel('Sample');
ylabel('Amplitude');
title('Unit Step Signal');

Output:
Unit Step Signal Generation
Enter no of samples: 10

Signals and Systems Lab Manual P a g e | 15


REVA University School of ECE

% MATLAB Code for Generalised Step Sequence

% generates step sequence delayed by c, in a, between the positions d and e


% generates step sequence indirectly using the impulse sequence generation.

% OUTPUT ARGUMENTS
% a the output sequence name
% b position index for output sequence plotting

% INPUT ARGUMENTS
% c delay of the impulse sequence
% d start position for plotting
% e end position for plotting
clc;
clear all;
close all;
c= input(' Enter delay of the impulse sequence c: ');
d= input ('Enter start position for plotting d: ');
e= input (' Enter end position for plotting e: ');
if c<d,
error('impulse sample will not be seen within the range of positions given')
end
n= d:e;
x = inline('1*(n>=c)');
stem(n, x(c,n));
xlabel('sample position');
ylabel('sample value');
title('plot of the desired sequence');

Signals and Systems Lab Manual P a g e | 16


REVA University School of ECE

Output:
Enter delay of the step sequence c: 3
Enter start position for plotting d: -10
Enter end position for plotting e: 10

% MATLAB code for unit ramp signal generation:

clc;
clear all;
close all;
disp('Unit Ramp Signal Generation');
N = input('Enter no of samples: ');
n = -N : N;
r= inline ('n.*(n>=0)');
stem (n, r(n));
xlabel('Sample');
ylabel('Amplitude');
title('Unit Ramp Signal');

Output:
Unit Ramp Signal Generation
Enter no of samples: 10
Max Amplitude: 10

Signals and Systems Lab Manual P a g e | 17


REVA University School of ECE

% MATLAB Code for Generalised Ramp Sequence

% generates ramp sequence delayed by c, in a, between the indices d and e


% a the output sequence name
% b position index for output sequence plotting
% c delay of the impulse sequence
% d start position for plotting
% e end position for plotting
clc;
clear all;
close all;
c= input(' Enter delay of the ramp sequence: ');
d= input ('Enter start position for plotting d: ');
e= input (' Enter end position for plotting e: ');
if c<d,
error('impulse sample will not be seen within the range of positions given')
end
n= d:e ;
r= inline ('(n-c).*(n>=c)');
stem(n, r(c,n));
xlabel('sample position');
ylabel('sample value');
title('plot of the desired sequence');

Output:
Enter delay of the ramp sequence: 3
Enter start position for plotting d: -10
Enter end position for plotting e: 10

Signals and Systems Lab Manual P a g e | 18


REVA University School of ECE

Signals and Systems Lab Manual P a g e | 19


REVA University School of ECE

3. PERFORM OPERATIONS ON DEPENDENT VARIABLE OF A


SIGNAL.
% MATLAB Code for Addition/Subtraction of two sequences

% x1 first sequence
% n1 first sequence start position
% x2 second sequence
% n2 second sequence start position
% y restulting sequence
% n resulting sequence positin vector

clc;
clear all;
close all;
x1= input('Enter the first sequence: ');
n1= input('Enter the first sequence start position: ');
x2= input('Enter the second sequence: ');
n2= input('Enter the second sequence position: ');

MIN = min(n1,n2);
MAX = max (n1+length(x1)-1,n2+length(x2)-1);
n=MIN:MAX;
y1=zeros(1,length(n));
y2=y1;
a=n1(1)-MIN+1;
b=n2(1)-MIN+1;
y1(a:a+length(x1)-1)=x1;
y2(b:b+length(x2)-1)=x2;
y = y1+y2;% sequence addition, y1-y2 for sequence subtraction
disp(y);
subplot(3,1,1)
stem(n,y1)
title(' Signal x1' );
subplot(3,1,2)
stem(n,y2)
title(' Signal x2');
subplot(3,1,3)
stem(n,y)
title(' Signal y, addition of x1 and x2')

Output:

Enter the first sequence: [2 4 5 6]


Enter the first sequence start position: 1
Enter the second sequence: [-5 3 6 9]
Enter the second sequence position: 0
Addition Output:
-5 5 10 14 6

Signals and Systems Lab Manual P a g e | 20


REVA University School of ECE

% MATLAB Code for Multiplication of two sequences


% x1 first sequence
% n1 first sequence start position
% x2 second sequence
% n2 second sequence start position
% y restulting sequence
% n resulting sequence positin vector

clc;
clear all;
close all;
x1= input('Enter the first sequence: ');
n1= input('Enter the first sequence start position: ');
x2= input('Enter the second sequence: ');
n2= input('Enter the second sequence position: ');

MIN = min (n1, n2);


MAX = max (n1+length(x1)-1, n2+length(x2)-1);
n=MIN: MAX;
y1=zeros (1, length (n));
y2=y1;
a=n1 (1)-MIN+1;
b=n2 (1)-MIN+1;
y1 (a: a+length(x1)-1) =x1;
y2 (b: b+length(x2)-1) =x2;
y = y1.*y2; % sequence multiplication
disp(' Multiplication output');
disp(y);

Signals and Systems Lab Manual P a g e | 21


REVA University School of ECE

subplot(3,1,1)
stem(n,y1)
title(' Signal x1' );
subplot(3,1,2)
stem(n,y2)
title(' Signal x2');
subplot(3,1,3)
stem(n,y)
title(' Signal y, multiplication of x1 and x2')

Output:

Enter the first sequence: [2 4 5 7]


Enter the first sequence start position: 0
Enter the second sequence: [4 3 5 -4]
Enter the second sequence position: 1
Multiplication output
0 16 15 35 0

Signals and Systems Lab Manual P a g e | 22


REVA University School of ECE

4. PERFORM OPERATIONS ON INDEPENDENT VARIABLE OF A


SIGNAL.

% MATLAB Code for Shifting a Signal

clc;
clear all;
close all;

n1=input('Enter the amount to be delayed: ');


n2=input('Enter the amount to be advanced: ');
n=-2:2;
x=[-2 3 0 1 5];
subplot(3,1,1);
stem(n,x);
title('Signal x(n)');
m=n+n1;
y=x;
subplot(3,1,2);
stem(m,y);
title('Delayed signal x(n-n1)');
t=n-n2;
z=x;
subplot(3,1,3);
stem(t,z);
title('Advanced signal x(n+n2)');

Output:

Enter the amount to be delayed: 2


Enter the amount to be advanced: 3

Signals and Systems Lab Manual P a g e | 23


REVA University School of ECE

Signal x(n)
5

-5
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
Delayed signal x(n-n1)
5

-5
0 0.5 1 1.5 2 2.5 3 3.5 4
Advanced signal x(n+n2)
5

-5
-5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1

% MATLAB Code for plotting reflection a Signal

clc;
clear all;
close all;

n=-1:2;
x=[3 -1 0 -4];
subplot(2,1,1)
stem(n,x);
axis([-3 3 -5 5]);
title('Signal x(n)');
c=fliplr(x);
y=fliplr(-n);
subplot(2,1,2);
stem(y,c);
axis([-3 3 -5 5]);
title('Reflected Signal x(-n)');

Signals and Systems Lab Manual P a g e | 24


REVA University School of ECE

Output:

Signals and Systems Lab Manual P a g e | 25


REVA University School of ECE

5. TO CALCULATE SIGNAL POWER AND SIGNAL ENERGY

% MATLAB Code for Calculating Signal Power and Signal Energy

clc;
clear all;
close all;
x=[3 -1 1 -4];

power=sum(abs(x).^2)/length(x);
disp(power);

Energy=sum(abs(x).^2);
disp(Energy);

Output:

6.7500

27

Signals and Systems Lab Manual P a g e | 26


REVA University School of ECE

6. TO COMPUTE THE LINEAR CONVOLUTION OF THE GIVEN


INPUT SEQUENCE x(n) & THE IMPULSE RESPONSE OF THE
SYSTEM h(n). (CAUSAL SEQUENCES)

Theory:
 The output y[n] of a LTI (linear time invariant) system can be obtained by convolving
the input x[n] with the system’s impulse response h[n].
 The convolution sum is

 x[n] and h[n] can be both finite or infinite duration sequences.


 Even if one (or both) of the sequences is infinite (say, h[n]=(0.9)n u[ n] ), we can
analytically evaluate the convolution formula to get a functional form (closed form
solution) of y[n].
 If both the sequences are of finite duration, then we can use the matlab function
‘conv’ to evaluate the convolution sum to obtain the output y[n]. Convolution is
implemented as polynomial multiplication (refer matlab help).
 The length of y[n] = xlength + hlength -1.
 The conv function assumes that the two sequences begin at n=0 and is invoked by
y=conv(x,h).
 Even if one of the sequences begin at other values of n, say n=-3,or n=2; then we need
to provide a beginning and end point to y[n] which are ybegin=xbegin+hbegin and
yend=xend+hend respectively.

Algorithm:
1. Input the two sequences as x1, x2
2. Convolve both to get output y.
3. Plot the sequences.

Matlab Implementation:
Matlab recognizes index 1 to positive maximum. Index 0 is also not recognized. The timing
information for a sequence is provided by another vector, say n=-3:5; creates a vector with
values from -3 to 5 with an increment of 1.
During plotting, the time vector size and the sequence size should be the same, i.e., the
number of elements in the sequence x1 and in its time vector n1 should be the same.
Similarly for x2 and y.

Signals and Systems Lab Manual P a g e | 27


REVA University School of ECE

Matlab Program:
% CAUSAL SEQUENCES
%main part of computation

clc;
clear all;
close all;
x=input('Enter first sequence: ');
h=input('Enter second sequence: ');
y=conv(x,h);
disp('linear con of x & h is y= ');
disp(y);

% graphical display part


subplot(3,1,1); % Divides the fig window into 3-rows, 1-Column & 1st position
stem(x); % To display ‘x’ input in figure window
xlabel('time index n');
ylabel('amplitude ');
title('plot of x(n)');

subplot(3,1,2); % Divides the fig window into 3-rows, 1-Column & 2nd position
stem(h); % To display ‘h’ input in figure window
xlabel('time index n');
ylabel('amplitude ');
title('plot of h(n)');

subplot (3,1,3); % Divides the fig window into 3-rows, 1-Column & 3rd position
stem(y); % To display ‘y’ output in figure window
xlabel('time index n');
ylabel('amplitude ');
title('convolution output');

Signals and Systems Lab Manual P a g e | 28


REVA University School of ECE

Calculations:-
h(n)= Impulse response of a system due to impulse input function.
y(n)= x(n) * h(n)

let, x(n) = [1 2 3] = δ(n) + 2δ(n-1) + 3δ(n-2)


h(n) = [1 2 3 4] = δ(n) + 2δ(n-1) + 3δ(n-2) + 4δ(n-3)

x(n)*h(n) = [δ(n)+2δ(n-1)+3δ(n-2)] * [δ(n)+2δ(n-1) + 3δ(n-2)+4δ(n-3)]

Using convolution property of the two delayed unit impulse sequence we get,
x(n)*h(n) = δ(n)+2δ(n-1) +3δ(n-2) + 4δ(n-3)
+2δ(n-1) + 4δ(n-2) + 6δ(n-3) + 8δ(n-4)
+3δ(n-2) + 6δ(n-3) + 9δ(n-4) +12δ(n-5)
x(n)*h(n) = δ(n) + 4δ(n-1) +10δ(n-2) +16δ(n-3) +17δ(n-4) +12δ(n-5)

Therefore, x(n)*h(n) = [1, 4, 10, 16, 17, 12]

Output :

Enter first sequence: [1 2 3]


Enter second sequence: [1 2 3 4]
linear con of x & h is y=
1 4 10 16 17 12

Signals and Systems Lab Manual P a g e | 29


REVA University School of ECE

Signals and Systems Lab Manual P a g e | 30


REVA University School of ECE

7. TO COMPUTE THE LINEAR CONVOLUTION OF THE GIVEN


INPUT SEQUENCE x(n) & THE IMPULSE RESPONSE OF THE
SYSTEM h(n). (NON-CAUSAL SEQUENCES)

Matlab Program:
% Two sided sequences (Non- Causal Sequences)
% Main part of computation

x= [3 11 7 0 -1 4 2]; % first sequence


n1=-3:3; % time vector of first sequence
h=[2 3 0 -5 2 1]; % second sequence
n2=-1:4; % time vector of second sequence
ybegin=n1(1)+n2(1); % add first elements of time vector
yend=n1(length(x))+n2(length(h)); % add last elements of time vector

ny=[ybegin:yend];
y=conv(x,h);
disp('linear con of x & h is y=');
disp(y); % Displays the value of ‘y’ on Terminal window

%graphical display with time info


subplot(3,1,1); % Divides the fig window into 3-rows, 1-Column & 1st position
stem(n1,x); % To display ‘x’ input in figure window
xlabel('time index n');
ylabel('amplitude ');
title('plot of x(n)');

subplot(3,1,2); % Divides the fig window into 3-rows, 1-Column & 2nd position
stem(n2,h);
xlabel('time index n');
ylabel('amplitude ');
title('plot of h(n)');

subplot (3,1,3); % Divides the fig window into 3-rows , 1-Column & 3rd position
stem(ny,y);
xlabel('time index n');
ylabel('amplitude ');
title('convolution output');

Signals and Systems Lab Manual P a g e | 31


REVA University School of ECE

Calculations:-
x = [3 11 7 0 -1 4 2] h = [2 3 0 -5 2 1]
↑ ↑
x*h = [ 3δ(n+3)+11δ(n+2)+7δ(n+1)-1δ(n-1)+4δ(n-2)+2δ(n-3)]*[ 2 δ(n+1)+3 δ(n)-5 δ(n-2)+2δ(n-3)+δ(n- 4)]

= 6δ(n+4)+22δ(n+3)+14δ(n+2)- 2δ(n)+ 8δ(n-1)+ 4δ(n-2)


+9δ(n+3)+ 33δ(n+2)+21δ(n+1) - 3δ(n-1)+12δ(n-2)+6δ(n-3)
-15δ(n+1)-55δ(n)-35δ(n-1) +5δ(n-3)-20δ(n-4)-10δ(n-5)
+6δ(n)+22δ(n-1)+14δ(n-2) - 2δ(n-4)+8δ(n-5)+4δ(n-6)
+3δ(n-1)+11δ(n-2)+7δ(n-3) δ(n-5)+4δ(n-6)+2δ(n-7)
6δ(n+4)+31δ(n+3)+47δ(n+2)+6δ(n+1)-51δ(n)-5δ(n-1)+41δ(n-2)+18δ(n-3)-22δ(n-4)-3δ(n-5)+8δ(n-6)+2δ(n-7)
Therefore, y = [6, 31, 47, 6, -51, -5, 41, 18, -22, -3, 8, 2]
Output:
x = [3 11 7 0 -1 4 2] n1 = [-3 -2 -1 0 1 2 3]
h = [ 2 3 0 -5 2 1] n2 = [-1 0 1 2 3 4]
linear con of x & h is y=
6 31 47 6 -51 -5 41 18 -22 -3 8 2

CHALLENGE EXPERIMENT:
3. Write a general matlab program for linear convolution for any two general sequences
(causal and non-causal).

Signals and Systems Lab Manual P a g e | 32


REVA University School of ECE

8. SOLVE ANY GIVEN DIFFERENCE EQUATION OF AN LTI


SYSTEM WITHOUT INITIAL CONDITIONS.
Theory:

Fig. of LTI system


A discrete time LTI system (also called digital filters) as shown in Fig. is represented by :
 A linear constant coefficient difference equation, for example,
y [ n]+a1 y [ n−1]−a2 y [ n−2]=b0 x [n]+b1 x [ n−1]+b2 x [ n−2 ] ;
 A system function H(z) (obtained by applying Z transform to the difference equation).

 A frequency response function obtained by applying DFT on the impulse response


h[n] (or by replacing z with ejΩ in H(z)) to get

 Given the difference equation or H(z), the impulse response of the LTI system is
found using filter or impz matlab/gnu-octave functions. If the difference equation
contains past samples of output, i.e., y[n-1], y[n-2], etc , then its impulse response is
of infinite duration (IIR). For such systems the impulse response is computed for a
large value of n, say n=100 (to approximate n=∞).
 Given only the input sequence x[n] and the output sequence y[n], we can find the
impulse function h[n] by using the inverse operation deconv. (The conv operation
convolves 2 sequences x[n] and h[n] to obtain the output y[n]. If both y[n] and x[n]
are finite then the impulse response is finite (FIR).
 The de-convolution operation is valid only if the LTI system is ‘invertible’.
Matlab Implementation:
FILTER One-dimensional digital filter.
Y = FILTER(B,A,X) filters the data in vector X with the filter described by vectors A
and B to create the filtered data Y. The filter is a "Direct Form II Transposed"
implementation of the standard difference equation:
a(1)*y(n) = b(1)*x(n) + b(2)*x(n-1) + ... + b(nb+1)*x(n-nb)
- a(2)*y(n-1) - ... - a(na+1)*y(n-na)
If a(1) is not equal to 1, FILTER normalizes the filter coefficients by a(1).

Signals and Systems Lab Manual P a g e | 33


REVA University School of ECE

% matlab program to find Impulse Response given the difference equation with zero initial
condition:
clc;
N=5;
b= [1 0.5]; % numerator coefficients
a=[1 -0.63 0.72]; % denominator coefficients
x=[1,zeros(1,N-1)]; % x=[1 0 0 0 0];
y=filter (b,a,x);

disp('the impluse response of the system without initial conditions');


disp(y);

stem(y);
title('impluse response of the system without initial conditions');

Calculations:-
y[n]-0.63y[n-1]+0.72y[n-2] = x[n]+0.5x[n-1]
y[n] = 0.63y[n-1]-0.72y[n-2]+ x[n]+0.5x[n-1]
n=0; y[0] = 0.63y[0-1]-0.72y[0-2]+x[0]+0.5x[0-1]

y[0] = 1

n=1; y[1] = 0.63y[1-1]-0.72y[1-2]+x[1]+0.5x[1-1]

= (0.63)(1)+(0.5)(1)
y[1] = 1.13

n=2; y[2] = 0.63y[2-1]-0.72y[2-2]+x[2]+0.5x[2-1]

= (0.63)(1.13)-(0.72)(1)
y[2] = -0.008100

n=3; y[3] = 0.63y[3-1]-0.72y[3-2]+x[3]+0.5x[3-1]

= (0.63)(-0.008100)-(0.72)(1.13)

Signals and Systems Lab Manual P a g e | 34


REVA University School of ECE

y[3] = -0.818703
n=4; y[4] = 0.63y[4-1]-0.72y[4-2]+x[4]+0.5x[4-1]

= (0.63)(-0. 8187)-(0.72)(-0.0081)
y[4] = -0.509949

Result:
the impluse response of the system without initial conditions
1.0000 1.1300 -0.0081 -0.8187 -0.5100

Signals and Systems Lab Manual P a g e | 35


REVA University School of ECE

9. SOLVE ANY GIVEN DIFFERENCE EQUATION OF AN LTI


SYSTEM WITH INITIAL CONDITIONS.

% matlab program to find Impulse Response given the difference equation with initial
condition:
clc;
N=5;
b= [1 0.5]; % numerator coefficients
a=[1 -0.63 0.72]; % denominator coefficients
x=[1,zeros(1,N-1)]; % x=[1 0 0 0 0];
zi=filtic(b,a,[1 2]); % with initial conditions y(-1) = 1 and y(-2) = 2
y=filter (b,a,x,zi);
disp('the impluse response of the system with initial conditions');
disp(y);

stem(y);
title('impluse response of the system with initial conditions');

Calculations:-
y[n]-0.63y[n-1]+0.72y[n-2] = x[n]+0.5x[n-1]
y[n] = 0.63y[n-1]-0.72y[n-2]+ x[n]+0.5x[n-1]

initial condition is, y(-1)=1; y(-2)=2;


n=0; y[0] = 0.63y[0-1]-0.72y[0-2]+x[0]+0.5x[0-1]
= (0.63)(1) – (0.72)(2) + 1 + (0.5)(0)
= 0.63-1.44+1
y[0] = 0.19
n=1; y[1] = 0.63y[1-1]-0.72y[1-2]+x[1]+0.5x[1-1]
= 0.63y[0]-0.72y[-1]+x[1]+0.5x[0]
= (0.63)(0.19) – (0.72)(1) + 0 + (0.5)(1)
y[1] = -0.1003

n=2; y[2] = 0.63y[2-1]-0.72y[2-2]+x[2]+0.5x[2-1]


= 0.63y[1]-0.72y[0]+x[2]+0.5x[1]
= (0.63)(-0.1003) – (0.72)(0.19) + 0+ (0.5)(0) => -0.06318-0.1368
y[2] = -0.1999

Signals and Systems Lab Manual P a g e | 36


REVA University School of ECE

n=3; y[3] = 0.63y[3-1]-0.72y[3-2]+x[3]+0.5x[3-1]


= 0.63y[2]-0.72y[1]+x[3]+0.5x[2]
= (0.63)(-0.1999) – (0.72)(-0.1003) + 0+ (0.5)(0) => -0.125937+0.072216
y[3] = -0.0537

n=4; y[4] = 0.63y[4-1]-0.72y[4-2]+x[4]+0.5x[4-1]


= 0.63y[3]-0.72y[2]+x[4]+0.5x[3]
= (0.63)(-0.0537) – (0.72)(-0.1999) + 0 + (0.5)(0) => -0.033831+0.143928
y[4] = 0.1100

Result:
the impluse response of the system with initial conditions
0.1900 -0.1003 -0.2000 -0.0538 0.1101

CHALLENGE EXPERIMENT:
1. Write a matlab program to extend the calculation of output for other standard inputs
like unit step, ramp and sinusoid (can use matlab inbuilt functions).

Signals and Systems Lab Manual P a g e | 37


REVA University School of ECE

10. DEMONSTRATION OF SAMPLING THEOREM


clc

clear all;

close all;

tfinal=0.05;

t=0:0.00005:tfinal;

f1=input('Enter first analog frequency');

f2=input('Enter second analog frequency');

%define input analog signal

xt=cos(2*pi*f1*t)+cos(2*pi*f2*t);

fm=max(f1,f2);

%simulate condition for undersampling i.e., fs < 2fm

fs=1.3*fm;

Ts=1/fs;

n=0:Ts:tfinal;

%Generate the undersampled signal

xn=cos(2*pi*f1*n)+cos(2*pi*f2*n);

%plot the analog & sampled signals

figure(1)

subplot(3,1,1);

plot(t,xt)

xlabel('t')

ylabel('x(t)')

title('Original analog signal');

subplot(3,1,2);

Signals and Systems Lab Manual P a g e | 38


REVA University School of ECE

stem(n,xn)

xlabel('n')

ylabel('x(n)')

title('Under sampled signal');

subplot(3,1,3);

plot(t,xt,'b',n,xn,'r*-');

xlabel('t')

ylabel('x(t) & xr(t)')

title('Reconstructed analog signal after under sampling');

legend('original analog signal','reconstructed signal after sampling')

%condition for Nyquist plot

fs=2*fm;

Ts=1/fs;

n=0:Ts:tfinal;

%Generate the nyquist sampled signal

xn=cos(2*pi*f1*n)+cos(2*pi*f2*n);

%plot the analog & sampled signals

figure(2)

subplot(3,1,1);

plot(t,xt)

xlabel('t')

ylabel('x(t)')

title('Original analog signal');

subplot(3,1,2);

stem(n,xn)

Signals and Systems Lab Manual P a g e | 39


REVA University School of ECE

xlabel('n')

ylabel('x(n)')

title('Nyquist sampled signal');

subplot(3,1,3);

plot(t,xt,'b',n,xn,'r*-');

xlabel('t')

ylabel('x(t) & xr(t)')

title('Reconstructed analog signal after nyquist sampling');

legend('original analog signal','reconstructed signal after sampling')

%condition for oversampling

fs=5*fm;

Ts=1/fs;

n=0:Ts:tfinal;

%Generate the oversampled signal

xn=cos(2*pi*f1*n)+cos(2*pi*f2*n);

%plot the analog & sampled signals

figure(3)

subplot(3,1,1);

plot(t,xt)

xlabel('t')

ylabel('x(t)')

title('Original analog signal');

subplot(3,1,2);

stem(n,xn)

xlabel('n')

Signals and Systems Lab Manual P a g e | 40


REVA University School of ECE

ylabel('x(n)')

title('Over sampled signal');

subplot(3,1,3);

plot(t,xt,'b',n,xn,'r*-');

xlabel('t')

ylabel('x(t) & xr(t)')

title('Reconstructed analog signal after 0ver sampling');

legend('original analog signal','reconstructed signal after sampling')

Output:

Enter first analog frequency 100


Enter second analog frequency 200

Fig 1 : Under Sampling

Signals and Systems Lab Manual P a g e | 41


REVA University School of ECE

Fig 2: Nyquist Rate Sampling

Fig 3: Over Sampling

Signals and Systems Lab Manual P a g e | 42


REVA University School of ECE

TMS320C6713 DSK

The C6713 DSK has a TMS320C6713 DSP onboard that allows full-speed verification of
code with Code Composer Studio. The C6713 DSK provides:
 A USB Interface
 SDRAM and ROM
 An analog interface circuit for Data conversion (AIC)
 An I/O port
 Embedded JTAG emulation support

Connectors on the C6713 DSK provide DSP external memory interface (EMIF) and
peripheral signals that enable its functionality to be expanded with custom or third party
daughter boards.

The DSK provides a C6713 hardware reference design that can assist you in the development
of your own C6713-based products. In addition to providing a reference for interfacing the
DSP to various types of memories and peripherals, the design also addresses power, clock,
JTAG, and parallel peripheral interfaces.
The C6713 DSK includes a stereo codec. This analog interface circuit (AIC) has the
following characteristics:

High-Performance Stereo Codec


 90-dB SNR Multibit Sigma-Delta ADC (A-weighted at 48 kHz)
 100-dB SNR Multibit Sigma-Delta DAC (A-weighted at 48 kHz)
 1.42 V – 3.6 V Core Digital Supply: Compatible With TI C54x DSP Core
Voltages
 2.7 V – 3.6 V Buffer and Analog Supply: Compatible Both TI C54x DSP
Buffer Voltages
 8-kHz – 96-kHz Sampling-Frequency Support

Software Control Via TI McBSP-Compatible Multiprotocol Serial Port


 I 2 C-Compatible and SPI-Compatible Serial-Port Protocols
 Glueless Interface to TI McBSPs

Audio-Data Input/output Via TI McBSP-Compatible Programmable Audio Interface


 I 2 S-Compatible Interface Requiring Only One McBSP for both ADC and
DAC
 Standard I 2 S, MSB, or LSB Justified-Data Transfers
 16/20/24/32-Bit Word Lengths

Signals and Systems Lab Manual P a g e | 43


REVA University School of ECE

The C6713DSK has the following features:


The 6713 DSK is a low-cost standalone development platform that enables customers to
evaluate and develop applications for the TI C67XX DSP family. The DSK also serves as a
hardware reference design for the TMS320C6713 DSP. Schematics, logic equations and
application notes are available to ease hardware development and reduce time to market.
The DSK uses the 32-bit EMIF for the SDRAM (CE0) and daughter card expansion interface
(CE2 and CE3). The Flash is attached to CE1 of the EMIF in 8-bit mode.
An on-board AIC23 codec allows the DSP to transmit and receive analog signals. McBSP0
is used for the codec control interface and McBSP1 is used for data. Analog audio I/O is
done through four 3.5mm audio jacks that correspond to microphone input, line input, line
output and headphone output. The codec can select the microphone or the line input as the
active input. The analog output is driven to both the line out (fixed gain) and headphone
(adjustable gain) connectors. McBSP1 can be re-routed to the expansion connectors in
software.
A programmable logic device called a CPLD is used to implement glue logic that ties the
board components together. The CPLD has a register based user interface that lets the user
configure the board by reading and writing to the CPLD registers. The registers reside at the
midpoint of CE1.

The DSK includes 4 LEDs and 4 DIP switches as a simple way to provide the user with
interactive feedback. Both are accessed by reading and writing to the CPLD registers.
An included 5V external power supply is used to power the board. On-board voltage
regulators provide the 1.26V DSP core voltage, 3.3V digital and 3.3V analog voltages. A
voltage supervisor monitors the internally generated voltage, and will hold the board in reset
until the supplies are within operating specifications and the reset button is released. If
desired, JP1 and JP2 can be used as power test points for the core and I/O power supplies.
Code Composer communicates with the DSK through an embedded JTAG emulator with a
USB host interface. The DSK can also be used with an external emulator through the
external JTAG connector.

TMS320C6713 DSP Features

 Highest-Performance Floating-Point Digital Signal Processor (DSP):


 Eight 32-Bit Instructions/Cycle
 32/64-Bit Data Word
 300-, 225-, 200-MHz (GDP), and 225-, 200-, 167-MHz (PYP) Clock Rates
 3.3-, 4.4-, 5-, 6-Instruction Cycle Times
 2400/1800, 1800/1350, 1600/1200, and 1336/1000 MIPS /MFLOPS
 Rich Peripheral Set, Optimized for Audio
 Highly Optimized C/C++ Compiler
 Extended Temperature Devices Available

Signals and Systems Lab Manual P a g e | 44


REVA University School of ECE

 Advanced Very Long Instruction Word (VLIW) TMS320C67x™ DSP Core


 Eight Independent Functional Units:
 Two ALUs (Fixed-Point)
 Four ALUs (Floating- and Fixed-Point)
 Two Multipliers (Floating- and Fixed-Point)
 Load-Store Architecture With 32 32-Bit General-Purpose Registers
 Instruction Packing Reduces Code Size
 All Instructions Conditional
 Instruction Set Features
 Native Instructions for IEEE 754
 Single- and Double-Precision
 Byte-Addressable (8-, 16-, 32-Bit Data)
 8-Bit Overflow Protection
 Saturation; Bit-Field Extract, Set, Clear; Bit-Counting; Normalization
 L1/L2 Memory Architecture
 4K-Byte L1P Program Cache (Direct-Mapped)
 4K-Byte L1D Data Cache (2-Way)
 256K-Byte L2 Memory Total: 64K-Byte L2 Unified Cache/Mapped RAM, and 192K-
Byte Additional L2 Mapped RAM
 Device Configuration
 Boot Mode: HPI, 8-, 16-, 32-Bit ROM Boot
 Endianness: Little Endian, Big Endian
 32-Bit External Memory Interface (EMIF)
 Glueless Interface to SRAM, EPROM, Flash, SBSRAM, and SDRAM
 512M-Byte Total Addressable External Memory Space
 Enhanced Direct-Memory-Access (EDMA) Controller (16 Independent Channels)
 16-Bit Host-Port Interface (HPI)
 Two Multichannel Audio Serial Ports (McASPs)
 Two Independent Clock Zones Each (1 TX and 1 RX)
 Eight Serial Data Pins Per Port:
Individually Assignable to any of the Clock Zones
 Each Clock Zone Includes:
 Programmable Clock Generator
 Programmable Frame Sync Generator
 TDM Streams From 2-32 Time Slots

Signals and Systems Lab Manual P a g e | 45


REVA University School of ECE

 Support for Slot Size:


8, 12, 16, 20, 24, 28, 32 Bits
 Data Formatter for Bit Manipulation
 Wide Variety of I2S and Similar Bit Stream Formats
 Integrated Digital Audio Interface Transmitter (DIT) Supports:
 S/PDIF, IEC60958-1, AES-3, CP-430 Formats
 Up to 16 transmit pins
 Enhanced Channel Status/User Data
 Extensive Error Checking and Recovery
 Two Inter-Integrated Circuit Bus (I2C Bus™) Multi-Master and Slave Interfaces
 Two Multichannel Buffered Serial Ports:
 Serial-Peripheral-Interface (SPI)
 High-Speed TDM Interface
 AC97 Interface
 Two 32-Bit General-Purpose Timers
 Dedicated GPIO Module With 16 pins (External Interrupt Capable)
 Flexible Phase-Locked-Loop (PLL) Based Clock Generator Module
 IEEE-1149.1 (JTAG ) Boundary-Scan-Compatible
 Package Options:
 208-Pin PowerPAD™ Plastic (Low-Profile) Quad Flatpack (PYP)
 272-BGA Packages (GDP and ZDP)
 0.13-µm/6-Level Copper Metal Process
 CMOS Technology

 3.3-V I/Os, 1.2 -V Internal (GDP & PYP)


 3.3-V I/Os, 1.4-V Internal (GDP)(300 MHz only)

Signals and Systems Lab Manual P a g e | 46


REVA University School of ECE

TMS320C6713 DSK Overview Block Diagram

INTRODUCTION TO CODE COMPOSER STUDIO


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 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

Signals and Systems Lab Manual P a g e | 47


REVA University School of ECE

Procedure for interfacing programs using CODE COMPOSER STUDIO6.1.3


1. Open Code Composer Studio 6.1.3 icon which is created on the desktop.

2. You will get workspace Launcher window in workspace select the drive other than
‘C’ and create a new folder by your SRN and click OK.

Signals and Systems Lab Manual P a g e | 48


REVA University School of ECE

3. Click on project and select New CCS Project in that select the desired properties as
given in the picture and click on Finish button.

Signals and Systems Lab Manual P a g e | 49


REVA University School of ECE

NOTE:
For real time programs select hello.cmd file and for non-real programs select C6713.cmd

4. Once you click on finish button you will get a CCS editor window, in that type the C
program and at the end click on SAVE button.

Signals and Systems Lab Manual P a g e | 50


REVA University School of ECE

5. To rename the file name instead of main.c Right click on main.c which is in project
explorer window and select Rename icon or press F2 button.

6. You will get a new Rename Resource window there you give a new file name with
extension ‘.C’ and click ‘OK’.

Signals and Systems Lab Manual P a g e | 51


REVA University School of ECE

7. Now to build the project click on HAMMER symbol which is on the top left
of editor window.

Note:
If any error occurs in the program that will be displayed in the console window which is at
the bottom of editor window. Clear that error again click on save button and repeat the same
above step.

8. After building the project to debug the program click on BUG symbol which is
on the top left of editor window.

9. Now to RUN the program click on Resume or F8 button which is on the top left
of editor window.

10. In the console window you can observe the output values.

Signals and Systems Lab Manual P a g e | 52


REVA University School of ECE

For the very first time after installation of CCS software the following properties has to be
modified.

Signals and Systems Lab Manual P a g e | 53


REVA University School of ECE

Signals and Systems Lab Manual P a g e | 54


REVA University School of ECE

11 C PROGRAM TO GENERATE A SINE WAVE USING CCS STUDIO


AND TI PROCESSOR KIT

#include <stdio.h>
#include<math.h>

#define FREQ 500


float m[127];
void main()
{
int i=0;

for(i=0;i<127;i++)
{
m[i]=sin(2*3.14*FREQ*i/24000);
printf("%f\n",m[i]);
}
}

NOTE:

Procedure is given in page number 48 to run code composer studio v6.1.3. Follow the steps.

Signals and Systems Lab Manual P a g e | 55


REVA University School of ECE

12 C PROGRAM TO COMPUTE THE LINEAR CONVOLUTION OF


THE GIVEN INPUT SEQUENCE x(n) & THE IMPULSE RESPONSE OF
THE SYSTEM h(n) USING USING CCS STUDIO AND TI PROCESSOR
KIT

Linear Convolution Involves the following operations.


1. Folding 2. Multiplication 3. Addition 4. Shifting

These operations can be represented by a Mathematical Expression as follows:

x[ ]= Input signal Samples


h[ ]= Impulse response co-efficient.
y[ ]= Convolution output.
n = No. of Input samples
h = No. of Impulse response co-efficient.

Algorithm to implement ‘C’ or Assembly program for Convolution:


Eg: x[n] = {1, 2, 3, 4}
h[k] = {1, 2, 3, 4}
Where: n=4, k=4. : Values of n & k should be a multiple of 4.
If n & k are not multiples of 4, pad with zero’s to make multiples
of 4
r= n+k-1 : Size of output sequence.
= 4+4-1
= 7.
r= 0 1 2 3 4 5 6
n= 0 x[0]h[0] x[0]h[1] x[0]h[2] x[0]h[3]
1 x[1]h[0] x[1]h[1] x[1]h[2] x[1]h[3]
2 x[2]h[0] x[2]h[1] x[2]h[2] x[2]h[3]
3 x[3]h[0] x[3]h[1] x[3]h[2] x[3]h[3]

Output: y[r] = { 1, 4, 10, 20, 25, 24, 16}.


NOTE: At the end of input sequences pad ‘n’ and ‘k’ no. of zero’s

Signals and Systems Lab Manual P a g e | 56


REVA University School of ECE

/* C program to implement linear convolution */


#include<stdio.h>
int y[20];

main()
{
int m=3; /*Length of i/p samples sequence*/
int n=4; /*Length of impulse response Co-efficient */
int i=0,j;
int x[15]={1,2,3,4,0,0,0,0,0,0}; /*Input Signal Samples*/
int h[15]={1,2,3,0,0,0,0,0,0}; /*Impulse Response Co-efficient*/
for(i=0;i<m+n-1;i++)
{
y[i]=0;
for(j=0;j<=i;j++)
y[i]+=x[j]*h[i-j];
}
for(i=0;i<m+n-1;i++)
printf("%d\n",y[i]);
}

Calculations:
x[n] = [1 2 3 4]—> L1=4 h[n] = [1 2 3]—> L2=3
L=L1+L2-1 => 4+3-1=>6 L=6
y[n]=x[n].h[n]

y[n]= Σ x[n].h[n]
-∞
Now,
5
y[n]= Σ x[n].h[n]
K=0

Signals and Systems Lab Manual P a g e | 57


REVA University School of ECE

5
n=0, y[0] = Σ x[k].h[0-k]
K=0

y[0] = 1
5
n=1, y[1] = Σ x[0].h[1-k]
K=0

=>(1)(2)+(2)(1) =>2+2
y[1] = 4
5
n=2, y[2] = Σ x[0].h[2-k]
K=0

=> (1)(3)+(2)(2)+(3)(1) => 3+4+3


y[2]= 10

5
n=3, y[3] = Σ x[0].h[3-k]
K=0

=>(2)(3)+(3)(2)+(4)(1) => 6+6+4


y[3]= 16

5
n=4, y[4] = Σ x[0].h[4-k]
K=0

=>(3)(3)+(4)(2) =>9+8 => 17


y[4] = 17

Signals and Systems Lab Manual P a g e | 58


REVA University School of ECE

5
n=5, y[5] = Σ x[0].h[5-k]
K=0

=>(4)(3) =>12
y[5]= 12

y[n] = [1 4 10 16 17 12]

LINEAR CONVOLUTION GRAPH PROPERTIES SETTING:

Signals and Systems Lab Manual P a g e | 59


REVA University School of ECE

Result: y(n) = {1 4 10,16,17,12}

NOTE:

Procedure is given in page number 48 to run code composer studio v6.1.3. Follow the steps.

Signals and Systems Lab Manual P a g e | 60


REVA University School of ECE

SAMPLE VIVA QUESTIONS

1. What is the function of ‘clc’ in matlab tool?


CLC clears the command window and homes the cursor.

2. What is the function of ‘clear all’ in matlab tool?


CLEAR removes all variables from the workspace.

3. What is the function of ‘close all’ in matlab tool?


CLOSE ALL closes all the open figure windows.

4. What is the function of ‘figure’ in matlab tool?


FIGURE, by itself, creates a new figure window, and returns its handle.

5. What is the function of ‘subplot’ in matlab tool?


Subplot divides the figure window into rows, columns and position For example
subplot(3,1,1) means the figure window divides into 3 rows, 1column and 1st position.

6. What is the function of ‘plot’ in matlab tool?


PLOT Linear plot.
PLOT(X,Y) plots vector Y versus vector X. If X or Y is a matrix, then the vector is plotted
versus the rows or columns of the matrix, which ever line up. If X is a scalar and Y is a
vector, length (Y) disconnected points are plotted.

7. What is the function of ‘stem’ in matlab tool?


STEM Discrete sequence or "stem" plot.
STEM(Y) plots the data sequence Y as stems from the x axis terminated with circles for the
data value. STEM(X,Y) plots the data sequence Y at the values specified in X.

8. What is the function of ‘xlabel’ in matlab tool?


XLABEL X-axis label. XLABEL('text') adds text beside the X-axis on the current axis.

9. What is the function of ‘ylabel’ in matlab tool?


YLABEL Y-axis label. YLABEL('text') adds text beside the Y-axis on the current axis.

10. What is the function of ‘title’ in matlab tool?


TITLE Graph title. TITLE('text') adds text at the top of the current axis.

11. What is the function of ‘conv’ in matlab tool?


CONV Convolution and polynomial multiplication.
C = CONV(A, B) convolves vectors A and B. The resulting vector is
LENGTH(A)+LENGTH(B)-1.

Signals and Systems Lab Manual P a g e | 61

You might also like