Professional Documents
Culture Documents
DEPARTMENT OF ECE
Dr.KVSRIT
Page 1
MPDSP LAB
DEPARTMENT OF ECE
Dr.KVSRIT
Page 2
MPDSP LAB
DEPARTMENT OF ECE
Dr.KVSRIT
Page 3
MPDSP LAB
1)
Generation of random signal and plot the same as a waveform showing all the
specifications
a) Generation of Sinusoidal signal
AIM :
PROGRAM :
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 SIGNAL
Enter Number of Samples : 16
DEPARTMENT OF ECE
Dr.KVSRIT
Page 4
MPDSP LAB
RESULT:- Thus the MATLAB program for generation of Sinusoidal signal was performed and
the output was verified.
DEPARTMENT OF ECE
Dr.KVSRIT
Page 5
MPDSP LAB
DEPARTMENT OF ECE
Dr.KVSRIT
Page 6
MPDSP LAB
OUTPUT
Enter the number of cycles in a square wave....:: 3
Enter the period of the square wave ....:: 4
RESULT:- Thus the MATLAB program for generation Square wave was performed and the
output was verified.
DEPARTMENT OF ECE
Dr.KVSRIT
Page 7
MPDSP LAB
Dr.KVSRIT
Page 8
MPDSP LAB
a) Linear Convolution
AIM :
Dr.KVSRIT
Page 9
MPDSP LAB
y(i)=0;
for j=1:m+n-1
if(j<i+1)
y(i)=y(i)+x(j)*h(i-j+1);
end
end
end
subplot(2,2,[3,4]),stem(y);
title('convolution of x(n) & h(n) is :');
xlabel('---->n');
ylabel('---->y(n)');grid;
OUTPUT :
RESULT : The linear convolution of two sequences is verified by using MATLAB program.
DEPARTMENT OF ECE
Dr.KVSRIT
Page 10
MPDSP LAB
b) Auto Correlation
AIM :
Sequences.
Dr.KVSRIT
Page 11
MPDSP LAB
OUTPUT :
RESULT :
DEPARTMENT OF ECE
Dr.KVSRIT
Page 12
MPDSP LAB
c) Cross Correlation
AIM :
Sequences.
Dr.KVSRIT
Page 13
MPDSP LAB
disp(yy');
title('y=cross correlastion of x & j');
OUTPUT :
RESULT :
DEPARTMENT OF ECE
Dr.KVSRIT
Page 14
MPDSP LAB
Dr.KVSRIT
Page 15
MPDSP LAB
title('Inverse DTFT')
xlabel('N')
ylabel('Magnitude')
OUTPUT :
RESULT :
DEPARTMENT OF ECE
Dr.KVSRIT
Page 16
MPDSP LAB
DEPARTMENT OF ECE
Dr.KVSRIT
Page 17
MPDSP LAB
OUTPUT:
DEPARTMENT OF ECE
Dr.KVSRIT
Page 18
MPDSP LAB
6) FIR filters
AIM
SOFTWARE
MATLAB software
PROGRAM
DEPARTMENT OF ECE
Dr.KVSRIT
Page 19
MPDSP LAB
y=kaiser(n1);
disp('kaiser window filter response');
end
%LPF
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);plot(o/pi,m);
title('LPF');
ylabel('Gain in dB-->');
xlabel('(a) Normalized frequency-->');
%HPF
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,2);plot(o/pi,m);
title('HPF');
ylabel('Gain in dB-->');
xlabel('(b) Normalized frequency-->');
%BPF
wn=[wp ws];
b=fir1(n,wn,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,3);plot(o/pi,m);
title('BPF');
ylabel('Gain in dB-->');
xlabel('(c) Normalized frequency-->');
%BSF
b=fir1(n,wn,'stop',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,4);plot(o/pi,m);
title('BSF');
ylabel('Gain in dB-->');
xlabel('(d) Normalized frequency-->');
DEPARTMENT OF ECE
Dr.KVSRIT
Page 20
MPDSP LAB
OUTPUT:
DEPARTMENT OF ECE
Dr.KVSRIT
Page 21
MPDSP LAB
Dr.KVSRIT
Page 22
MPDSP LAB
III B.Tech-II Sem (ECE)
7) IIR filters
AIM
SOFTWARE
MATLAB software
PROGRAM
DEPARTMENT OF ECE
Dr.KVSRIT
Page 23
MPDSP LAB
DEPARTMENT OF ECE
Dr.KVSRIT
Page 24
MPDSP LAB
Dr.KVSRIT
Page 25
MPDSP LAB
DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING
1)
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
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 sinewave.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 ProjectSelect sinewave.c
5. Add the linker command file hello.cmd
Project -> Add files to Project (path: C:\CCstudio\tutorial\dsk6713\hello\hello.cmd)
6. Add the run time support library file rts6700.lib
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 sinewave.out file (from project folder lcconv\Debug) using FileLoad Program
10. Run the program using DebugRun or F5
11. To view the output graphically Select ViewGraphTime and Frequency
12. Repeat the steps 2 to 11 for square wave
PROGRAM: (a)
DEPARTMENT OF ECE
Dr.KVSRIT
Page 26
MPDSP LAB
#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);
}
}
PROGRAM: (b)
#include <stdio.h>
#include <math.h>
int a[1000];
void main()
{
int i,j=0;
int b=5;
for(i=0;i<10;i++)
{
for (j=0;j<=50;j++)
{
a[(50*i)+j]=b;
}
b=b*(-1) ;
}
}
DEPARTMENT OF ECE
Dr.KVSRIT
Page 27
MPDSP LAB
DEPARTMENT OF ECE
Dr.KVSRIT
Page 28
MPDSP LAB
Square wave:-
Result:- The sine wave and square wave has been obtained.
DEPARTMENT OF ECE
Dr.KVSRIT
Page 29
MPDSP LAB
2)
AIM:
LINEAR CONVOLUTION
To verify Linear Convolution
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)
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 using project 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 ViewGraph Time and Frequency
DEPARTMENT OF ECE
Dr.KVSRIT
Page 30
MPDSP LAB
12. observe the values in the output window.
PROGRAM:
DEPARTMENT OF ECE
Dr.KVSRIT
Page 31
MPDSP LAB
Output:-
DEPARTMENT OF ECE
Dr.KVSRIT
Page 32
MPDSP LAB
3)
AIM:
PROGRAM:
#include<stdio.h>
#include<math.h>
#define pi 3.1415
int n,N,c;
float wr[64],wt[64];
void main()
{
printf("\n enter no. of samples,N= :");
scanf("%d",&N);
printf("\n enter choice of window function\n 1.rect \n 2. triang \n c= :");
scanf("%d",&c);
printf("\n elements of window function are:");
switch(c)
{
case 1:
for(n=0;n<=N-1;n++)
{
wr[n]=1;
printf(" \n wr[%d]=%f",n,wr[n]);
}
break;
case 2:
DEPARTMENT OF ECE
Dr.KVSRIT
Page 33
MPDSP LAB
for(n=0;n<=N-1;n++)
{
wt[n]=1-(2*(float)n/(N-1));
printf("\n wt[%d]=%f",n,wt[n]);
}
break;
}
}
OUTPUT:
DEPARTMENT OF ECE
Dr.KVSRIT
Page 34
MPDSP LAB
RESULT:
Here we designed FIR filter Using CC studio.
DEPARTMENT OF ECE
Dr.KVSRIT
Page 35
MPDSP LAB
4)
AIM:
//iirfilters
#include<stdio.h>
#include<math.h>
int i,w,wc,c,N;
float H[100];
float mul(float, int);
void main()
{
printf("\n enter order of filter ");
scanf("%d",&N);
printf("\n enter the cutoff freq ");
scanf("%d",&wc);
printf("\n enter the choice for IIR filter 1. LPF 2.HPF ");
scanf("%d",&c);
switch(c)
{
case 1:
for(w=0;w<100;w++)
{
H[w]=1/sqrt(1+mul((w/(float)wc),2*N));
printf("H[%d]=%f\n",w,H[w]);
}
DEPARTMENT OF ECE
Dr.KVSRIT
Page 36
MPDSP LAB
break;
case 2:
for(w=0;w<=100;w++)
{
H[w]=1/sqrt(1+mul((float)wc/w,2*N));
printf("H[%d]=%f\n",w,H[w]);
}
break;
}
}
float mul(float a,int x)
{
for(i=0;i<x-1;i++)
a*=a;
return(a);
}
OUTPUT:
DEPARTMENT OF ECE
Dr.KVSRIT
Page 37
MPDSP LAB
RESULT:
Here we designed IIR filter Using CC studio.
DEPARTMENT OF ECE
Dr.KVSRIT
Page 38