DSP Lab3

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

NATIONAL UNIVERSITY HO CHI MINH CITY

UNIVERSITY OF TECHNOLOGY


DIGITAL SIGNAL PROCESSING


REPORT
CONVOLUTION (CT & DT SIGNALS)

Instructor: Prof. Lê Tiến Thường


Class: TT01
Group: 10
Student’s Fullname:
Truong Thanh An 2010836
Pham Gia Khanh 2051132

Ho Chi Minh City, December 5th 2022

1
2
Contents
1. Abstract................................................................................................
2. Introduction.........................................................................................
3. Code......................................................................................................
4. Result....................................................................................................
5. Conclusion..........................................................................................

3
1. Abstract
This report outlines step to perform a Convulation of two given signals using the
TMS320C5515 eZDSPTM USB stick development tool. The report includes a MatLab
demostration of the signals, skecth by hand and programming to caculate y(t) and y(n).

4
2. Introduction
In this lab, we focus on calculating convolution of continuous-time signals and
discrete-time signals by using MATLAB and Code Composer Studio through C5515
kit.
In problem 1, we use the function heaviside to obtain the unit step signal graph.
Then, we use the delay and addition properties to sketch the required waveforms. To
calculate the convolution immediately, we use the function conv().

5
3. Code
Problem 1:
a)
 x1(t) = x2(t)
t=-3:0.001:3; %create time interval
a=heaviside(t); %a= u(t): unit step signal
b=heaviside(t-1); %b= u(t-1)
plot(t,a-b); %plot signal u(t) – u(t-1)
axis([-1 2 -1 2]); %limit the range of axes
grid on;
title('x1(t)= x2(t)');

 x3(t)
t = -2:0.001:2; %create time interval
a=heaviside(t); %a= u(t): unit step signal
b=heaviside(t-0.5); %b= u(t-0.5)
c=-heaviside(t-0.5); %c= -u(t-0.5)
d=-heaviside(t-1); %d= -u(t-1)
x3= plot (t,a-b+c-d); %plot signal u(t) – 2u(t-0.5) + u(t-1)
axis([-1 2 -2 2]); %limit the range of axes
grid on;
title('x3(t)');

 x4(t)
t = -2:0.001:2; %create time interval
a=-heaviside(t); %a= -u(t)
b=-heaviside(t-0.5); %b= -u(t-0.5)
c=heaviside(t-0.5); %c= u(t-0.5)
d=heaviside(t-1); %d= u(t-1)
x4= plot (t,a-b+c-d); %plot signal -u(t) + 2u(t-0.5) - u(t-1)
grid on;
axis([-1 2 -2 2]);
title('x4(t)')

b)
 y1(t)
t=-3:3; %create time interval
a=heaviside(t); %a= u(t)
b=heaviside(t-1); %b= u(t-1)
x1=a-b; %signal x1(t)= u(t) – u(t-1)
m=conv(x1,x1); %calculate the convolution m= x1(t)*x1(t)

6
t1=-3:6/(length(m)-1):3; %create time interval t1 has the same size as
m
plot(t1,m);
grid on;
axis ([-1 2 -1 1]);
title ('y1')

 y2(t)
t = -2:2;
a1=heaviside(t);
b1=heaviside(t-0.5);
c1=-heaviside(t-0.5);
d1=-heaviside(t-1);
x3= a1-b1+c1-d1; %signal x3(t)= u(t) – 2u(t-0.5) + u(t-1)
a2=-heaviside(t);
b2=-heaviside(t-0.5);
c2=heaviside(t-0.5);
d2=heaviside(t-1);
x4= a2-b2+c2-d2; %signal x3(t)= -u(t) + 2u(t-0.5) - u(t-1)
m=conv(x3,x4); %calculate the convolution m= x3(t)*x4(t)
t1=-2:4/(length(m)-1):2;
plot(t1,m);
axis ([-1 2 -1 1]);
grid on;
title ('y2')

Problem 2:
 x1(n)
f=1;
fs= 8e3;
ts=0:0.125:1;
x= heaviside(8*f*ts/fs)- heaviside(8*f*ts/fs-1);
stem (ts,x);
axis([-0.5 1.5 0 2]);
grid on;
title ('x1(n)')

Problem 3:
void main( void )
{
int x[50],h[50],y[50],b[50],t,c[50];

7
float a;
int i,j,m,n;
//input length of x[n] and h[n]
printf("\n enter length of x1");
scanf("%d",&m);
printf("\n enter length of x2");
scanf("%d",&n);
//input element of x[n] and h[n]
printf("\n input element x1");
for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf("\n input element x2");
for(i=0;i<n;i++)
scanf("%d",&h[i]);
//assign 0s to the expand x[n] and h[n]
for(i=m;i<=m+n-1;i++)
x[i]=0;
for(i=n;i<=m+n-1;i++)
h[i]=0;
//Discrete fromula
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]);
}
}
printf("\n y(n)");
for(i=0;i < m+n-1;i++){
printf("\n y[%d]=%d",i,y[i]);}
//calculate y(t) is have from y(t)=t (0<t<1) or y(t)=0(t<0,t>1)
a=1/8
for(i=0;i<8;i++){
b[i]=0;
for(int a=0;a<=1;a+(t/8)){
b[i]=a;
}
}
printf("\n y(n)");
for(i=0;i <4;i++){

8
printf("\n y[%d]=%f",i,b[i]);}
4. Result
Problem 1:
a)

9
b)

10
Problem 2:

Problem 3:

11
5. Conclusion
In this lab session we learn more about Convolution and how to perfrom it by
using programming like Matlab and CSS.The experiment also help us gained can be
very usefull in future learning and experiment.Although we didn’t complete all the
given task,we have the basic idea from lab 2 but haven’t manage to display the result on
the OLED bar.

12

You might also like