Академический Документы
Профессиональный Документы
Культура Документы
TECHNOLOGY
(Approved by AICTE, New Delhi & affiliated to Anna University Chennai)
RECORD BOOK
Name :…………………………………………………………………
Department :………………………………………………………………….
Semester :………………………………………………………………….
Certified that, this is the Bonafide record of the Practical’s done for the above subject
Laboratory during the period………………………………..
Signature:
EX.NO.1(A) GENERATION OF SEQUENCES
DATE:
AIM:
SOFTWARE REQUIRED:
MATLAB R2010
PROGRAM LOGIC:
PROGRAM:
Sine waveform
clear all
a=input('Enter the Amplitude:');
t=0:0.01:2;
y=a*sin(2*pi*t);
plot(t,y);
xlabel('Timeperiod');
ylabel('Amplitude');
title('Sinewave');
Cosine waveform
clear all
a=input('Enter the Amplitude:');
t=0:0.01:2;
y=a*cos(2*pi*t);
plot(t,y);
xlabel('Timeperiod');
ylabel('Amplitude');
title('cosinewave');
Straight line
clear all
a=input('Enter the Value:');
x=input('Enter the Value:');
b=input('Enter the Value:');
y=(a*x)+b;
stem(x,y);
xlabel('x');
ylabel('y');
title('StraightLine');
Ramp waveform
clear all
x=0:10;
y=x;
plot(x,y);
xlabel('x->');
ylabel('ramp x->');
title('Rampwave');
Exponential waveform
clear all
n=0:0.1:5;
y=exp(n);
plot(n,y);
xlabel('n');
ylabel('exp(n)');
title('Exponential wave');
Unit step
clear all
y=ones(1,5);
plot(y);
xlabel('Timeperiod');
ylabel('Amplitude');
title('UNIT STEP');
Unit impulse
clear all
n=-3:1:3;
y=[zeros(1,3),ones(1,1),zeros(1,3)];
subplot(1,1,1);
stem(n,y);
xlabel('Time');
ylabel('Amplitude');
title('Unit Impulse');
OUTPUT:
Sinewave
5
1
Amplitude
-1
-2
-3
-4
-5
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Timeperiod
cosinewave
5
1
Amplitude
-1
-2
-3
-4
-5
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Timeperiod
Enter the Value:1
StraightLine
5
4.5
3.5
2.5
y
1.5
0.5
0
1 1.2 1.4 1.6 1.8 2 2.2 2.4 2.6 2.8 3
x
Rampwave
10
6
ramp x->
0
0 1 2 3 4 5 6 7 8 9 10
x->
Exponential wave
150
100
exp(n)
50
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
n
UNIT STEP
2
1.8
1.6
1.4
1.2
Amplitude
0.8
0.6
0.4
0.2
0
1 1.5 2 2.5 3 3.5 4 4.5 5
Timeperiod
RESULT:
AIM:
SOFTWARE REQUIRED:
MATLAB R2010
PROGRAM LOGIC:
PROGRAM:
clear all
a=input ('Enter the first sequence:');
b=input ('Enter the second sequence:');
y=xcorr(a,b);
Subplot(2,2,1);
stem(a);
Title('first sequence a');
Subplot(2,2,2);
stem(b);
Title('second sequence b');
Subplot(2,2,3);
stem(y);
Title('output sequence y');
disp(a);
disp(b);
disp(y);
OUTPUT: CORRELATION OF TWO SIGNALS
input 1 input 2
4 6
3
4
amplitude
amplitude
2
2
1
0 0
1 2 3 4 1 2 3 4
time time
cross auto
40 30
30
20
amplitude
amplitude
20
10
10
0 0
0 2 4 6 8 0 2 4 6 8
time time
RESULT:
Thus the correlations of two sequences are performed by using MATLAB and output
is verified successfully.
EX. NO: 2 (A) LINEAR CONVOLUTION
DATE:
AIM:
To perform linear convolution of two sequences in MATLAB.
SOFTWARE REQUIRED:
MATLAB R2010
PROGRAM LOGIC:
PROGRAM:
clear all
x=input ('Enter the input sequence:');
h=input ('Enter the impulse sequence:');
y=conv(x,h);
Subplot(2,2,1);
stem(x);
Title('input sequence x');
Subplot(2,2,2);
stem(h);
Title('impulse sequence h');
Subplot(2,2,3);
stem(y);
Title('output sequence y');
disp(x);
disp(h);
disp(y);
OUTPUT: LINEAR CONVOLUTION
1 2 3 4 5 6 7 8 9
1 2 3
1 4 10 16 22 28 34 40 46 42 27
2
5
1
0 0
0 5 10 1 1.5 2 2.5 3
output sequence y
60
40
20
0
0 5 10 15
RESULT:
Thus the linear convolutions of two sequences are performed by using MATLAB and
output is verified successfully.
EX.NO: 2(B) CIRCULAR CONVOLUTION
DATE:
AIM:
To perform circular convolution of two sequence in MATLAB.
SOFTWARE REQUIRED:
MATLAB R2010
PROGRAM LOGIC:
PROGRAM:
clear all
x=input('Enter the input sequence:');
h=input('Enter the impulse sequence:');
x1=fft(x);
h1=fft(h);
N=length(x);
for n=1:N
y1(n)=x1(n)*h1(n);
end
y=ifft(y1);
subplot(2,2,1);
stem(x);
title('input x');
subplot(2,2,2);
stem(h);
title('input h');
subplot(2,2,3);
stem(y);
title('output y')
disp(x);
disp(h);
disp(y);
OUTPUT: CIRCULAR CONVOLUTION
1 2 2 1
1 2 3 1
11 9 10 12
input x input h
2 3
1.5
2
1
1
0.5
0 0
1 2 3 4 1 2 3 4
output y
15
10
0
1 2 3 4
RESULT:
Thus circular convolutions of two sequences were performed using MATLAB and output is
verified successfully.
EX NO: 3(A) DISCRETE FOURIER TRANSFORM
DATE:
AIM:
To find the DFT of the given sequence using MATLAB.
SOFTWARE REQURED:
MATLAB R2010
PROGRAM LOGIC:
PROGRAM:
clear all
x=input('Enter the input sequence:');
N=length(x);
for k=1:N
sum=0;
for n=1:N
sum=sum+(x(n)*exp(-1i*2*pi*(n-1)*(k-1)/N));
end
y(k)=sum;
end
subplot(2, 2, 1);
stem(x);
xlabel('n');
ylabel('x(n)');
title('input sequence');
subplot(2, 2, 2);
stem(real(y));
xlabel('k');
ylabel('x(k)');
title('real part of output');
subplot(2, 2, 3);
stem(imag(y));
xlabel('k');
ylabel('x(k)');
title('imaginary part of output');
disp(x);
disp(real(y));
disp(imag(y));
OUTPUT:
DFT
2 2 2 2 1 1 1 1
1.5 10
x(n)
x(k)
1 5
0.5 0
0 -5
0 2 4 6 8 0 2 4 6 8
n k
imaginary part of output
4
2
x(k)
-2
-4
0 2 4 6 8
k
RESULT:
AIM:
To find the IDFT of the given sequence using MATLAB
SOFTWARE REQURED:
MATLAB R2010
PROGRAM LOGIC:
PROGRAM:
clear all
x=input('Enter the input sequence:');
N=length(x);
for n=1:N
sum=0;
for k=1:N
sum=sum+(x(k)*exp(1i*2*pi*(n-1)*(k-1)/N));
end
y(n)=sum/N;
end
subplot(2,2,1);
stem(real(x));
xlabel('k');
ylabel('x(k)');
title('real part of input');
subplot(2,2,2);
stem(imag(x));
xlabel('k');
ylabel('x(k)');
title('imaginary part of input');
subplot(2,2,3);
stem(real(y));
xlabel('n');
ylabel('x(n)');
title('real part of output');
subplot(2,2,4);
stem(imag(y));
xlabel('n');
ylabel('x(n)');
title('imaginary part of output');
disp(x);
disp(real(y));
disp(imag(y));
OUTPUT: INVERSE DISCRETE FOURIER TRANSFORM
1 2 3 4
3 0.5
x(k)
x(k)
2 0
1 -0.5
0 -1
1 2 3 4 1 2 3 4
k k
real part of output iimaginary part of output
3 1
2
0.5
x(n)
x(n)
1
0
0
-1 -0.5
1 2 3 4 1 2 3 4
n n
RESULT:
Thus the IDFT of the given sequence was generated using MATLAB.
EX NO: 4 DESIGN OF FIR FILTERS
DATE:
AIM:
To design FIR filter by windowing technique using MATLAB.
SOFTWARE REQURED:
MATLAB R2010
PROGRAM LOGIC:
PROGRAM:
clear all
fp=input('passband frequency in rad/sec:');
fs=input('stopband frequency in rad/sec:');
N=input('order of the filter:');
fsamp=input('sampling frequency:');
wp=2*(fp/fsamp);
ws=2*(fs/fsamp);
win=input('Enter the choice:\n1:blackman\n2:Hamming\n3:Hanning\n4:Rectangular\n');
if(win==1)
w=blackman(N);
elseif(win==2)
w=hamming(N);
elseif(win==3)
w=hanning(N);
elseif(win==4)
w=boxcar(N);
end
b=fir1(N-1,wp,w);
[b,w1]=freqz(b,1,256);
g=20*log10(abs(h));
grid on;
plot(w1,g);
grid on;
title('FIR LOW PASS FILTER DESIGN');
xlabel(‘MAGNITUDE (in dB)--- >’);
ylabel(‘NORMALIZED FREQUENCY (in rad/sec)---->’);
OUTPUT: FIR FILTER
BLACKMAN WINDOW
-5
NORMALIZED FREQUENCY (in rad/sec)---->
-10
-15
-20
-25
-30
-35
-40
-45
0 0.5 1 1.5 2 2.5 3 3.5
MAGNITUDE (in dB)--- >
HAMMING WINDOW
-10
-20
-30
-40
-50
-60
0 0.5 1 1.5 2 2.5 3 3.5
MAGNITUDE (in dB)--- >
HANNING WINDOW
FIR LOW PASS FILTER DESIGN
0
NORMALIZED FREQUENCY (in rad/sec)---->
-10
-20
-30
-40
-50
-60
-70
0 0.5 1 1.5 2 2.5 3 3.5
MAGNITUDE (in dB)--- >
RECTANGULAR WINDOW
-5
NORMALIZED FREQUENCY (in rad/sec)---->
-10
-15
-20
-25
-30
-35
-40
-45
-50
0 0.5 1 1.5 2 2.5 3 3.5
MAGNITUDE (in dB)--- >
RESULT:
Thus the FIR filter was designed by windowing technique using MATLAB.
EX NO:5(A) DESIGN OF IIR FILTERS
DATE:
AIM:
To design a IIR filter butterworth Low pass filter,High pass filter,Band pass filter and Band
stop filter using MATLAB.
SOFTWARE REQURED:
MATLAB R2010
PROGRAM LOGIC:
PROGRAM:
clear all
ap=0.5;
as=50;
fp=1000;
fs=2000;
f=5000;
wp=2*fp/f;
ws=2*fs/f;
wn=[wp,ws];
[n,wn]=buttord(wp,ws,ap,as);
[b,a]=butter(n,wn,'low');
w=0:0.01:pi;
h=freqz(b,a,w);
p=angle(h);
mag=20*log10(abs(h));
subplot(2,2,1);
plot(w/pi,mag);
grid;
xlabel('normalized frequency');
ylabel('magnitude in db');
title('magnitude response(lowpass filter)');
subplot(2,2,2);
plot(w/pi,p);
grid;
xlabel('normalized frequency');
ylabel('phase in radians');
title('phase response(lowpass filter)');
clear all
ap=0.5;
as=50;
fp=1000;
fs=2000;
f=5000;
wp=2*fp/f;
ws=2*fs/f;
wn=[wp,ws];
[n,wn]=buttord(wp,ws,ap,as);
[b,a]=butter(n,wn,'high');
w=0:0.01:pi;
h=freqz(b,a,w);
p=angle(h);
mag=20*log10(abs(h));
subplot(2,2,1);
plot(w/pi,mag);
grid;
xlabel('normalized frequency');
ylabel('magnitude in db');
title('magnitude response(highpass filter)');
subplot(2,2,2);
plot(w/pi,p);
grid;
xlabel('normalized frequency');
ylabel('phase in radians');
title('phase response(highpass filter)');
clear all
ap=0.5;
as=50;
fp=1000;
fs=2000;
f=5000;
wp=2*fp/f;
ws=2*fs/f;
wn=[wp,ws];
[n]=buttord(wp,ws,ap,as);
[b,a]=butter(n,wn,'bandpass');
w=0:0.01:pi;
h=freqz(b,a,w);
p=angle(h);
mag=20*log10(abs(h));
subplot(2,2,1);
plot(w/pi,mag);
grid;
xlabel('normalized frequency');
ylabel('magnitude in db');
title('magnitude response(bandpass filter)');
subplot(2,2,2);
plot(w/pi,p);
grid;
xlabel('normalized frequency');
ylabel('phase in radians');
title('phase response(bandpass filter)');
clear all
ap=0.5;
as=50;
fp=1000;
fs=2000;
f=5000;
wp=2*fp/f;
ws=2*fs/f;
wn=[wp,ws];
[n]=buttord(wp,ws,ap,as);
[b,a]=butter(n,wn,'stop');
w=0:0.01:pi;
h=freqz(b,a,w);
p=angle(h);
mag=20*log10(abs(h));
subplot(2,2,1);
plot(w/pi,mag);
grid;
xlabel('normalized frequency');
ylabel('magnitude in db');
title('magnitude response(bandstop filter)');
subplot(2,2,2);
plot(w/pi,p);
grid;
xlabel('normalized frequency');
ylabel('phase in radians');
title('phase response(bandstop filter)');
OUTPUT: IIR FILTER (LOW PASS FILTER)
phase in radians
magnitude in db
2
0
0
-200
-2
-400 -4
0 0.5 1 0 0.5 1
normalized frequency normalized frequency
2
0
0
-200
-2
-400 -4
0 0.5 1 0 0.5 1
normalized frequency normalized frequency
IIR FILTER(BANDPASS FILTER)
phase in radians
magnitude in db
2
0
0
-200
-2
-400 -4
0 0.5 1 0 0.5 1
normalized frequency normalized frequency
0 2
-100 0
-200 -2
-300 -4
0 0.5 1 0 0.5 1
normalized frequency normalized frequency
RESULT:
Thus the IIR butterworth Low pass, high pass, band pass, band stop filter is designed using
MATLAB.
EX NO:5(B) DESIGN OF IIR FILTERS
DATE:
AIM:
To design a IIR filter by bilinear and impulse invariant transformation method using
MATLAB.
SOFTWARE REQURED:
MATLAB R2009
PROGRAM LOGIC:
Plot the frequency response of the filter using bilinear and impulse invariant
transformation.
PROGRAM:
clc;
wp=input(‘Enter the passband edge frequency in rad/sec:’);
αp=input(‘Enter the passband ripple in dB:’);
ws=input(‘Enter the stopband edge frequency in rad/sec:’);
αs=input(’Enter the stopband ripple in dB:’);
fs=input (‘Enter the sampling frequency:’);
*n,wn+=buttord (wp,ws,αp,αs);
disp(‘The order of the filter is N=1);
disp(n);
*num,den+=butter(n,wn,’s’);
[b,a]=bilinear(num,den,fs);
freqz(b,a,512,fs);
grid on;
x label(‘Frequency(in Hz)’);
y label (‘Gain (in db’);
title(‘Frequency response using bilinear transformstion method’);
Clc;
clear;
wp=input(‘Enter the passband edge frequency in rad/sec:’);
αp=input(‘Enter the passband ripple in dB:’);
ws=input(‘Enter the stopband edge frequency in rad/sec:’);
αs=input(’Enter the stopband ripple in dB:’);
fs=input (‘Enter the sampling frequency:’);
*n,wn+=buttord (wp,ws,αp,αs,’s’);
disp(‘the order of the filter N=1’);
disp(n);
*num,den+=butter(n,wn,’s’);
[b,a]=IMP invar(num,den,fs);
freqz(b,a,512,fs);
grid on;
x label(‘Frequency(in Hz)’);
y label (‘Gain (in db)’);
title(‘Frequency response using impulse invariant transformation method’);
OUTPUT:
RESULT:
Thus the IIR filter has been designed successfully and the output is verified.
EX.NO:6(A) UP SAMPLING/INTERPOLATION
DATE:
AIM:
To perform the up sampling of the signal using MATLAB.
SOFTWARE REQUIRED:
MATLAB R2010
PROGRAM LOGIC:
PROGRAM:
Up sampling
N=input(' Enter the sequence length N:');
L=input(' Enter the upsampling factor L:');
f1=0.01;
f2=0.2;
t=0:1:N-1;
x=sin(2*pi*f1*t)+sin(2*pi*f2*t);
x1=zeros(1,L*N);
t1=1:1:L*N;
j=1:L:L*N;
x1(j)=x;
subplot(3,1,1);
plot(t,x);
xlabel('time-->');
ylabel('amplitude-->');
title('analog signal');
subplot(3,1,2);
stem(t,x);
xlabel('n-->');
ylabel('amplitude-->');
title('sampled signal');
subplot(3,1,3);
stem(t1-1,x1);
xlabel('n-->');
ylabel('amplitude===>');
title('upsampled signal');
OUTPUT: UPSAMPLING
1 1
amplitude
amplitude
0 0
-1 -1
0 5 10 0 5 10
time n
upsampled signal
2
1
amplitude
-1
0 5 10 15 20
n
RESULT:
AIM:
To perform the down sampling of the signal using MATLAB.
SOFTWARE REQUIRED:
MATLAB R2010
PROGRAM LOGIC:
PROGRAM:
Down sampling
clc;
clear all;
close all;
N=input(' Enter the sequence length N:');
M=input(' Enter the downsampling factor M:');
f1=0.05;
f2=0.2;
t=0:1:N-1;
x=sin(2*pi*f1*t)+sin(2*pi*f2*t);
x1=x(1:M:N);
t1=1:1:N/M;
subplot(3,1,1);
plot(t,x);
xlabel('time-->');
ylabel('amplitude-->');
title('analog signal');
subplot(3,1,2);
stem(t,x);
xlabel('n-->');
ylabel('amplitude-->');
title('sampled signal');
subplot(3,1,3);
stem(t1-1,x1);
xlabel('n-->');
ylabel('amplitude===>');
title('downsampled signal');
OUTPUT: DOWN SAMPLING
1 1
amplitude
amplitude
0 0
-1 -1
0 5 10 0 5 10
time n
downsampled signal
2
1
amplitude
-1
0 1 2 3 4
n
RESULT:
DATE:
AIM:
To design an equalization by using MATLAB.
APPARATUS REQUIRED:
MATLAB R2009
PROGRAM LOGIC:
PROGRAM:
clc;
clearall;
closeall;
ntr=5000;
j=sqrt(-1);
s=sign(randn(1,ntr)).*(2+sign(randn(1,ntr)))+...
j*sign(randn(1,ntr)).*(2+sign(randn(1,ntr)));
plot(s,'o');
axis([-4 4 -4 4]);
axis('square');
xlabel('Re\{s(n)\}');
ylabel('Im\{s(n)\}');
title('input signal constellation');
%Transmission channel
b=exp(j*pi/5)*[0.2 0.7 0.9];
a=[1 -0.7 0.4];
channel=dfilt.df2t(b,a);
hFV=fvtool(channel,'analysis','impulse');
legend(hFV,'Transmission''channel');
set(hFV,'color',[1 1 1]);
%Receive channel
sig=sqrt(1/16*(4*18+8*10+4*2))/sqrt(1000)*norm(impz(channel));
V=sig*(randn(1,ntr) + j*randn(1,ntr))/sqrt(2);
x=filter(channel,s) + V;
plot(x,'.');
xlabel('Re\{x[n]\}');
ylabel('Im\{x[n]\}');
axis([-40 40 -40 40]);
axis('square');
title('Received signal x[n]');
set(gcf,'color',[1 1 1]);
%Training signal
d=[zeros(1,10) s(1:ntr-10)];
%Training equalization
P0=100*eye(20);
lam=0.99;
h=adaptfilt.rls(20,lam,P0);
ntrain=1:2000;
[y,e]=filter(h,x(ntrain),d(ntrain));
plot(y(1001:2000),'.');
xlabel('Re\{y[n]\}');
ylabel('Im\{y[n]\}');
axis([-5 5 -5 5]);
axis('square');
title('Equalized signal y[n]');
set(gcf,'Color',[1 1 1])
OUTPUT: EQUALIZATION
1
Im{s(n)}
-1
-2
-3
-4
-4 -3 -2 -1 0 1 2 3 4
Re{s(n)}
Impulse Response
1.2
0.4
0.2
-0.2
0 2 4 6 8 10 12 14 16 18 20
Samples
Equalized signal y[n]
5
1
Im{y[n]}
-1
-2
-3
-4
-5
-5 0 5
Re{y[n]}
-5
-10
Magnitude (dB)
-15
-20
-25
-30
256
256
Cache Control Cache Control
Memory Protect L1P Memory Protect L2
Bandwidth Mgmt Bandwidth Mgmt
256 256
64 64
Bandwidth Mgmt CFG
8 x 32 64 6464 64
BLOCK DIAGRAM
Description
The peripheral set includes: a 10/100 Mbps Ethernet MAC (EMAC) with a
management data
input/output (MDIO) module; two I2C Bus interfaces; 3 multichannel audio serial ports
(McASPs) with 16/9 serializers and FIFO buffers; two 64-bit general-purpose timers
each configurable (one configurable as watchdog); a configurable 16-bit host-port
interface (HPI) [TMS320C6747 only]; up to 8 banks of 16 pins of general-purpose
input/output (GPIO) with programmable interrupt/event generation modes,
multiplexed with other peripherals; 3 UART interfaces (one with both RTS and CTS);
three enhanced high-resolution pulse width modulator (eHRPWM) peripherals; three
32-bit enhanced capture (eCAP) module peripherals which can be configured as 3
capture inputs or 3 auxiliary pulse width modulator (APWM) outputs; two 32-bit
enhanced quadrature encoded pulse (eQEP) peripherals; and 2 external memory
interfaces: an asynchronous and SDRAM external memory interface (EMIFA) for
slower memories or peripherals, and a higher speed memory interface (EMIFB) for
SDRAM.
The Ethernet Media Access Controller (EMAC) provides an efficient interface between
the TMS320C6745/6747 device and the network. The EMAC supports both 10Base-T
and 100Base-TX, or 10 Mbps and 100 Mbps in either half- or full-duplex mode.
Additionally, an MDIO interface is available for PHY configuration.
The rich peripheral set provides the ability to control external peripheral devices and
communicate with external processors. For details on each of the peripherals, see the
related sections later in this document and the associated peripheral reference
guides.
Result:
DATE:
AIM:
To perform the MAC operation using various addressing modes of digital signal processor by
addition using TMS320C6745 processor.
APPARATUS REQUIRED:
Hardware required:
TMS320C6745 Processor
USB cable
Personal computer
Software required:
ALGORITHM:
PROGRAM:
RESULT:
Thus the MAC operations using various addressing modes are performed using
TMS320C6745 processor.
EX NO:10 IMPLEMENTATION OF LINEAR CONVOLUTION
DATE:
AIM:
To implement linear convolution using TMS320C6745 processor.
APPARATUS REQUIRED:
Hardware required:
TMS320C6745 Processor
USB cable
Personal computer
Software required:
Code composer studio V4
PROCEDURE:
Create a new project.
Add source file to the project and type the program.
Save the program.
Paste the library files in the workspace location.
Create a target configuration file.
Build the project.
Connect the USB cable to the kit and turn it on.
Debug the active project and view the memory.
Type the address and give the input at particular location.
Give the input as follows:
x(n): 0xc0001000-0000001…, h(n):0x0001030-00000001…
Run and Halt the program.
See the output at 0xc0001050.
PROGRAM:
#include<stdio.h>
#define xn 4
#define hn 4
void main()
{
int *x,*h,*y,i,n,k;
x = (int *)0xc0001000;
h = (int *)0xc0001030;
y = (int *)0xc0001050;
for(i=0;i<(xn+hn-1);i++)
{
y[i]=0;
x[xn+i]=0;
h[hn+i]=0;
}
for(n=0;n<(xn+hn-1);n++)
{
for(k=0;k<=n;k++)
y[n] = (y[n]) + ((x[k])*(h[n-k]));
}
printf("ALL PROCESSED");
while(1);
}
RESULT:
Thus the implementation of linear convolution was done using TMS320c6745 processor and
executed successfully.
EX NO:11 IMPLEMENTATION OF CIRCULAR CONVOLUTION
Date:
AIM:
To implement circular convolution using TMS320C6745 processor.
APPARATUS REQUIRED:
Hardware required:
TMS320C6745 Processor
USB cable
Personal computer
Software required:
Code composer studio V4
PROCEDURE:
Create a new project.
Add source file to the project and type the program.
Save the program.
Paste the library files in the workspace location.
Create a target configuration file.
Build the project.
Connect the USB cable to the kit and turn it on.
Debug the active project and view the memory.
Type the address and give the input at particular location.
Give the input as follows:
x(n): 0xc0001000-0000001…, h(n):0x0001030-00000001…
Run and Halt the program.
See the output at 0xc0001050.
PROGRAM:
#include <stdio.h>
int rot(int *x);
void main()
{
int *in1,*in2,*out,*temp,i,sum=0,j;
in1 = (int *)0xc0001000;
in2 = (int *)0xc0001030;
out = (int *)0xc0001050;
temp = (int *)0xc0002000;
for(i=0;i<4;i++)
{
if(i == 1)
temp[i+2] = in1[i];
else if(i == 3)
temp[i-2] = in1[i];
else
temp[i] = in1[i];
}
for(i=0;i<4;i++)
{
sum = 0;
for(j=0;j<4;j++)
{
sum+=(in2[j] * temp[j]);
}
out[i] = sum;
rot(temp);
}
printf("ALL PROCESSED");
while(1);
}
rot(int *x)
{
int t;
t = x[0];
x[0] = x[3];
x[3] = x[2];
x[2] = x[1];
x[1] = t;
}
RESULT:
Thus the implementation of circular convolution was done using TMS320c6745 processor
and executed successfully.
EX NO:12 FFT IMPLEMENTATION
DATE:
AIM:
To implement Fast Fourier Transform using TMS320C6745 processor.
APPARATUS REQUIRED:
Hardware required:
TMS320C6745 Processor
USB cable
Personal computer
Software required:
Code composer studio V4
PROCEDURE:
Create a new project.
Add source file to the project and type the program.
Save the program.
Paste the library files in the workspace location.
Create a target configuration file.
Build the project.
Connect the USB cable to the kit and turn it on.
Debug the active project and view the memory. When the program halts, then follow
the steps,
View watch window
Type the following:
Input
Real_part
Imag_part
At this array location the input and output is displayed here.
PROGRAM:
#include <stdio.h>
float x[8],t[8],s1[8],s2r[8],s2i[8],Xr[8],Xi[8],Yr[8],Yi[8];
float T[8] = {1,2,3,4,4,3,2,1};
const float W0r = 1,
W0i = 0,
W1r = 0.707,
W1i = -0.707,
W2r = 0,
W2i = -1,
W3r = -0.707,
W3i = -0.707;
void main()
{
int i=0,j=0;
for(i=0;i<8;i++)
{
t[i] = 0;
x[i] = 0;
s1[i] = 0;
s2r[i] = 0;
s2i[i] = 0;
Xr[i] = 0;
Xi[i] = 0;
Yr[i] = 0;
Yi[i] = 0;
t[i] = T[i];
}
// Bit reversal process
x[0] = t[0];
x[1] = t[4];
x[2] = t[2];
x[3] = t[6];
x[4] = t[1];
x[5] = t[5];
x[6] = t[3];
x[7] = t[7];
// stage one process
s1[0] = (int)(x[0] + (x[1] * W0r));
s1[1] = (int)(x[0] - (x[1] * W0r));
s1[2] = (int)(x[2] + (x[3] * W0r));
s1[3] = (int)(x[2] - (x[3] * W0r));
s1[4] = (int)(x[4] + (x[5] * W0r));
s1[5] = (int)(x[4] - (x[5] * W0r));
s1[6] = (int)(x[6] + (x[7] * W0r));
s1[7] = (int)(x[6] - (x[7] * W0r));
// stage two process
s2r[0] = (s1[0] + (s1[2] * W0r));
s2i[0] = 0;
s2r[1] = s1[1];
s2i[1] = (s1[3] * W2i);
s2r[2] = (s1[0] - (s1[2] * W0r));
s2i[2] = 0;
s2r[3] = s1[1];
s2i[3] = - (s1[3] * W2i);
s2r[4] = (s1[4] + (s1[6] * W0r));
s2i[4] = 0;
s2r[5] = s1[5];
s2i[5] = (s1[7] * W2i);
s2r[6] = (s1[4] - (s1[6] * W0r));
s2i[6] = 0;
s2r[7] = s1[5];
s2i[7] = -(s1[7] * W2i);
// output
// complex multiplication for B * Wn
Yr[0] = (s2r[4] * W0r) - (s2i[4] * W0i);
Yi[0] = (s2r[4] * W0i) + (s2i[4] * W0r);
Yr[1] = (s2r[5] * W1r) - (s2i[5] * W1i);
Yi[1] = (s2r[5] * W1i) + (s2i[5] * W1r);
Yr[2] = (s2r[6] * W2r) - (s2i[6] * W2i);
Yi[2] = (s2r[6] * W2i) + (s2i[6] * W2r);
Yr[3] = (s2r[7] * W3r) - (s2i[7] * W3i);
Yi[3] = (s2r[7] * W3i) + (s2i[7] * W3r);
Yr[4] = (s2r[4] * W0r) - (s2i[4] * W0i);
Yi[4] = (s2r[4] * W0i) + (s2i[4] * W0r);
Yr[5] = (s2r[5] * W1r) - (s2i[5] * W1i);
Yi[5] = (s2r[5] * W1i) + (s2i[5] * W1r);
Yr[6] = (s2r[6] * W2r) - (s2i[6] * W2i);
Yi[6] = (s2r[6] * W2i) + (s2i[6] * W2r);
Yr[7] = (s2r[7] * W3r) - (s2i[7] * W3i);
Yi[7] = (s2r[7] * W3i) + (s2i[7] * W3r);
// complex addition for A + BWn
j=0;
for(i=0;i<4;i++)
{
Xr[i] = s2r[j] + Yr[i];
Xi[i] = s2i[j] + Yi[i];
j++;
}
// complex subtraction for A - BWn
j=0;
for(i=4;i<8;i++)
{
Xr[i] = s2r[j] - Yr[i];
Xi[i] = s2i[j] - Yi[i];
j++;
}
printf(" Real & Imaginary");
for(i=0;i<8;i++)
{
printf("\n %f %f ",Xr[i],Xi[i]);
}
}
RESULT:
Thus the FFT implementation was done using TMS320c6745 processor and executed
successfully.
EX NO:13 WAVEFORM GENERATION
DATE:
AIM:
To generate waveforms such as sawtooth, square and sine using TMS320c6745 processor.
APPARATUS REQUIRED:
Hardware required:
TMS320C6745 Processor
USB cable
Personal computer
CRO
Function generator
Software required:
Code composer studio V4
PROCEDURE:
Create a new project
Add source file to the project and type the program
Save the program
Paste the library files in the workspace location
Create a target configuration file
Build the project
Connect the USB cable to the kit and turn it on
Debug the active project
The input signal is given to ADC port and output is taken from DAC port.
Set the input signal
Run the program to see the output in the CRO and halt the program
PROGRAM:
Sinewave Generation:
#include <stdio.h>
#include<math.h>
#include "c6745.h"
#include "spidac.h"
#define PI 3.14
#define DAC_CS_LOW(); SPI_SPIPC3 = 0x0; //(CS=Low:Enable)
#define DAC_CS_HIGH(); SPI_SPIPC3 = 0x1; //(CS=High:Disable)
/****************************/
/* SPI 16 bit Data to Dac */
/****************************/
void SPI_Write(unsigned short Data)
{
unsigned short receive;
Data = ( 0x3000 | Data );
/* Clear any old data */
receive = SPI_SPIBUF;
// Wait for transmit ready
while( SPI_SPIBUF & 0x10000000 );
/* Write 1 byte */
SPI_SPIDAT1 = Data;
while((SPI_SPIBUF & 0x20000000)==1);
receive = SPI_SPIBUF;
}
#include <stdio.h>
#include "c6745.h"
#include "spidac.h"
#define DAC_CS_LOW(); SPI_SPIPC3 = 0x0; //(CS=Low:Enable)
#define DAC_CS_HIGH(); SPI_SPIPC3 = 0x1; //(CS=High:Disable)
//Uint32 *gpio_dir01,*gpio_out_data01;
//
//#define LDAC_HIGH(); *gpio_out_data01 = 0x00010000; //
PF1(BL=High:ON)
//#define LDAC_LOW(); *gpio_out_data01 = 0x00000000;
// PF1(BL=Low:OFF)
/***************/
/* 1 ms Delay */
/***************/
void delay_ms(Uint32 Ms)
{
Uint32 i;
while(Ms>0)
{
for(i=0;i<16660;i++);
Ms--;
}
}
void Sent_to_SPI(unsigned short Value)
{
// LDAC_HIGH();
for(j=0;j<10;j++);
DAC_CS_LOW();
for(j=0;j<10;j++);
Value = (0x0FFF & Value);
SPI_Write(Value);
for(j=0;j<10;j++);
DAC_CS_HIGH();
for(j=0;j<10;j++);
// LDAC_LOW();
for(j=0;j<10;j++);
}
/****************************/
/* SPI 16 bit Data to Dac */
/****************************/
void SPI_Write(unsigned short Data)
{
unsigned short receive;
Data = ( 0x3000 | Data );
/* Clear any old data */
receive = SPI_SPIBUF;
#include <stdio.h>
#include "c6745.h"
#include "spidac.h"
#define DAC_CS_LOW(); SPI_SPIPC3 = 0x0; //(CS=Low:Enable)
#define DAC_CS_HIGH(); SPI_SPIPC3 = 0x1; //(CS=High:Disable)
while(1)
{
for(i=0;i<4096;i++)
{
// for(j=0;j<10;j++);
DAC_CS_LOW();
// for(j=0;j<10;j++);
Value = (0x0FFF & i);
` SPI_Write(Value);
for(j=0;j<10;j++);
DAC_CS_HIGH();
// for(j=0;j<10;j++);
}
}
}
/***************/
/* 1 ms Delay */
/***************/
void delay_ms(Uint32 Ms)
{
Uint32 i;
while(Ms>0)
{
for(i=0;i<16660;i++);
Ms--;
}
}
/****************************/
/* GLCD SPI Sent Data 8 bit */
/****************************/
void SPI_Write(unsigned short Data)
{
unsigned short receive;
}
RESULT:
Thus the waveforms are generated using TMS320C6745 processor.
EX NO:14(A) IMPLEMENTATION OF FIR FILTER
DATE:
AIM:
To implement the FIR filter using TMS320c6745 processor.
APPARATUS REQUIRED:
Hardware required:
TMS320C6745 Processor
USB cable
Personal computer
CRO
Function generator
Software required:
Code composer studio V4
PROCEDURE:
Create a new project
Add source file to the project and type the program
Save the program
Paste the library files in the workspace location
Create a target configuration file
Build the project
Connect the USB cable to the kit and turn it on
Debug the active project
The input signal is given to ADC port and output is taken from DAC port
Set the input signal
Run the program to see the output in the CRO and halt the program
PROGRAM:
#include <stdio.h>
#include <math.h>
#include "c6745.h"
#include "spiadc.h"
#include "spidac.h"
#define DAC_CS_LOW(); SPI0_SPIPC3 = 0x0; //(CS=Low:Enable)
#define DAC_CS_HIGH(); SPI0_SPIPC3 = 0x1; //(CS=High:Disable)
void SPI_Write(unsigned short Data);
unsigned short i,j=0,High,Value=0;
signed int adc_value;
int Eff[23] = {139, 0, 233, 582, 0, 0, 0, 1796, 2285,
0, 0, 19012, 0, 0, 2285, 1796, 0, 0,
0, 582, 233, 0, 139
};
void main( void )
{
static Uint8 spiadcbuf[3];
int i,xval[50];
int temp,k,coeff[53]={0},sum;
coeff[0] = 0x090E;
coeff[1] = 0x0F45C;
coeff[2] = 0x04C00;
coeff[3] = 0x0E4D7;
coeff[4] = 0x0517C;
coeff[5] = 0x0517C;
coeff[6] = 0x0E4D7;
coeff[7] = 0x0104C;
coeff[8] = 0x0F45C;
coeff[9] = 0x090E ;
C6745_init();
spiadc_init();
spidac_init();
for(i=0;i<52;i++)
{
xval[i]=0;
}
while(1)
{
spiadcbuf[0] = 0x01; // setup command
spiadcbuf[1] = 0xBF;
spiadcbuf[2] = 0x00;
spiadc_cycle(spiadcbuf, 3); // Execute spiadc read cycle
adc_value = ((spiadcbuf[1]&0x0f) << 8)| spiadcbuf[2];
// FILTER FUNCTION
// adc_value = adc_value ^ 0x0800;
xval[0] = adc_value;
sum = 0x0;
for(k=0;k<23;k++)
{
temp = (xval[k])*(Eff[k]);
sum = sum + temp;
}
sum = sum >> 15;
SPI_Write(sum);
for(i=23;i>=0;i--)
{
xval[i+1] = xval[i];
}
}
}l,
/****************************/
/* GLCD SPI Sent Data 8 bit */
/****************************/
void SPI_Write(unsigned short Data)
{
unsigned short receive;
DAC_CS_LOW();
Data = ( 0x3000 | Data );
/* Clear any old data */
receive = SPI0_SPIBUF;
// Wait for transmit ready
while( SPI0_SPIBUF & 0x10000000 );
/* Write 1 byte */
SPI0_SPIDAT1 = Data;
while((SPI0_SPIBUF & 0x20000000)==1);
/* Read 1 byte */
receive = SPI0_SPIBUF;
for(j=0;j<10;j++);
DAC_CS_HIGH();
}
RESULT:
Thus the implementation of FIR filter process was done and output was observed using
TMS320C6745 processor and executed successfully.
EX NO:14(B) IMPLEMENTATION OF IIR FILTER
DATE:
AIM:
To implement the IIR filter using TMS320c6745 processor.
APPARATUS REQUIRED:
Hardware required:
TMS320C6745 Processor
USB cable
Personal computer
CRO
Function generator
Software required:
Code composer studio V4
PROCEDURE:
Create a new project
Add source file to the project and type the program
Save the program
Paste the library files in the workspace location
Create a target configuration file
Build the project
Connect the USB cable to the kit and turn it on
Debug the active project
The input signal is given to ADC port and output is taken from DAC port.
Set the input signal
Run the program to see the output in the CRO and halt the program
PROGRAM:
Low pass filter:
#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 IIR LP Filter:");
scanf("%d",&N);
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]);
}
}
#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 IIR HP Filter: ");
scanf("%d",&N);
printf("\n Enter the Cutoff Freq: ");
scanf("%d",&wc);
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]);
}
DATE:
AIM:
To implement finite word length effects using TMS320c6745 processor.
APPARATUS REQUIRED:
Hardware required:
TMS320C6745 Processor
USB cable
Personal computer
Software required:
Code composer studio V4
PROCEDURE:
Create a new project
Add source file to the project and type the program
Save the program
Paste the library files in the workspace location
Create a target configuration file
Build the project
Connect the USB cable to the kit and turn it on
Debug the active project
The input signal is given to ADC port and output is taken from DAC port. Set the input signal
Run the program to see the output and halt the program
PROGRAM:
#include<stdio.h>
#include <math.h>
#define N 10 // Order of filter
#define PI 3.14
// Filter Coefficents without finite word length effect (or without truncated values)
float coeff1[10] = {
8.6589421428571428571428571428571,
6.7794628518236352561053631471054,
3.8972346426831024540136532012540,
1.7564427498245744124212425412421,
0.9897547424241245242575225821010,
4.1489257262414010254101210211256,
7.7854962145874965135871587526322,
9.6587900787865645342354687900978,
2.9786543211246679087664433221121,
0.0975313354566778980909887654329,
};
// Filter Coefficents with finite word length effect (truncated values)
float coeff2[10] = {
8.65,
6.77,
3.89,
1.75,
0.98,
4.14,
7.78,
9.65,
2.97,
0.09,
};
float OSample1[10];
float OSample2[10];
void main()
{
unsignedint i=0,j=0;
unsignedint n=0;
unsignedint k=0;
RESULT:
Thus finite word length effects have been implemented and output was observed using
TMS320C6745 processor and executed successfully.