Вы находитесь на странице: 1из 81

DHANALAKSHMI SRINIVASAN INSTITUTE OF

TECHNOLOGY
(Approved by AICTE, New Delhi & affiliated to Anna University Chennai)

Samayapuram, Trichy- 621112

EC6511/DIGITAL SIGNAL PROCESSING LABOROTORY


(Fifth Semester)

DEPARTMENT OF ELECTRONICS AND COMMUNICATION


ENGINEERING
DHANALAKSHMI SRINIVASAN GROUP OF INSTITUTIONS
Approved by AICTE, New Delhi &

Affiliated to Anna University, Chennai.

COLLEGE NAME:DHANALSKSHMI SRINIVASAN INSTITUTE OF TECHNOLOGY


Samayapuram, Trichy – 621 112

RECORD BOOK

Name :…………………………………………………………………

Reg No. :………………………………………………………………….

Department :………………………………………………………………….

Semester :………………………………………………………………….

Subject code :……………………………………………………………….....

Subject name :……………………………………………………………….....

Certified that, this is the Bonafide record of the Practical’s done for the above subject
Laboratory during the period………………………………..

Staff In Charge Head of the Department

Submitted for Anna University /Board Practical Examination held at Dhanalakshmi


Srinivasan Institute of technology Samayapuram, Trichy on
…………………………..…………………...

Internal Examiner External Examiner


CONTENTS

EXP DATE NAME OF THE EXPERIMENT PG MARKS SIGN


NO NO
Completed/Not completed Average:

Signature:
EX.NO.1(A) GENERATION OF SEQUENCES
DATE:

AIM:

To generate different types of functional and random sequences using MATLAB.

SOFTWARE REQUIRED:

MATLAB R2010

PROGRAM LOGIC:

 Get the amplitude and frequency of the signal.


 Illustrate appropriate functions.
 Plot the signal
 Give label to x & y axis.
 Give the title to generated signal.

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:

Enter the Amplitude : 5

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

Enter the Amplitude:5

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

Enter the Value:2

Enter the Value:3

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:

Thus the signals are successfully generated using MATLAB.


EX. NO: 1(B) CORRELATION
DATE:

AIM:

To perform the correlation of two sequences in MATLAB.

SOFTWARE REQUIRED:

MATLAB R2010

PROGRAM LOGIC:

 Get the values from first sequence.


 Get the values of second sequence.
 Perform correlation of two sequences.
 Plot the first sequence.
 Plot the second sequence.
 Plot the output sequence.

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

enter the matrix 1[1 2 3 4]

enter the matrix 2[2 3 4 5]

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:

 Get the values from input sequence.


 Get the values of impulse sequence.
 Perform linear convolution of sequence.
 Plot the input sequence.
 Plot the impulse sequence.
 Plot the output sequence.

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

Enter the input sequence:[1 2 3 4 5 6 7 8 9]

Enter the impulse sequence:[1 2 3]

1 2 3 4 5 6 7 8 9

1 2 3

1 4 10 16 22 28 34 40 46 42 27

input sequence x impulse sequence h


10 3

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:

 Get the input sequence values.


 Get the impulse sequence values.
 Find FFT for the input sequence.
 Find FFT for the output sequence.
 Multiply FFT for values of input and impulse sequence.
 Find inverse FFT for the output sequence.
 Plot the input sequence.
 Plot the impulse sequence.
 Plot the output sequence.

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

Enter the input sequence:[1 2 2 1]

Enter the impulse sequence:[1 2 3 1]

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:

 Get the sequence and length of sequence.


 Perform DFT function.
 Find absolute value and Phase of DFT sequence X(K).
 Plot the input sequence and magnitude and phase of DFT.

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

Enter the input sequence : [ 2 2 2 2 1 1 1 1 ]

2 2 2 2 1 1 1 1

12.0000 1.0000 -0.0000 1.0000 0 1.0000 -0.0000 1.0000

0 -2.4142 -0.0000 -0.4142 -0.0000 0.4142 -0.0000 2.4142

input sequence real part of output


2 15

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:

Thus the DFT of the sequence was generated using MATLAB.


EX NO: 3(B) INVERSE DISCRETE FOURIER TRANSFORM
DATE:

AIM:
To find the IDFT of the given sequence using MATLAB

SOFTWARE REQURED:

MATLAB R2010

PROGRAM LOGIC:

 Get the sequence.


 Get the length of the sequence.
 Initialize the scale for k and n.
 Use the appropriate function to generate the required transform.
 Add title to the transform.

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

Enter the input sequence:[1 2 3 4]

1 2 3 4

2.5000 -0.5000 -0.5000 -0.5000

0 -0.5000 0.0000 0.5000

real part of input iimaginary part of input


4 1

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:

 Get the pass band and stop band frequencies.


 Get the order of the filter and the sampling frequency.
 Get the choice of the windowing technique among Blackman, Hamming, Hanning
and rectangular.
 Design a FIR LPF using suitable windowing function.
 Plot the frequency response of the filter.
 Specify the suitable x-axis and y axis label.

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

passband frequency in rad/sec:20


stopband frequency in rad/sec:30
order of the filter:25
sampling frequency:100
Enter the choice:
1:blackman
2:Hamming
3:Hanning
4:Rectangular

BLACKMAN WINDOW

FIR LOW PASS FILTER DESIGN


0

-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

FIR LOW PASS FILTER DESIGN


0
NORMALIZED FREQUENCY (in rad/sec)---->

-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

FIR LOW PASS FILTER DESIGN


0

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

 Start the program.


 Get the passband and stopband frequency.
 Calculate the order of the filter.
 Determine the magnitude and phase using ‘abs’ and ‘angle’.
 Plot the magnitude and phase angle values with normalized frequency.
 Stop the program.

PROGRAM:

Low pass 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,'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)');

High pass 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)');

Band pass 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)');

Band stop 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)

magnitude response(lowpass filter) phase response(lowpass filter)


200 4

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

IIR FILTER(HIGHPASS FILTER)

magnitude response(highpass filter) phase response(highpass filter)


200 4
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
IIR FILTER(BANDPASS FILTER)

magnitude response(bandpass filter) phase response(bandpass filter)


200 4

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

IIR FILTER (BANDSTOP FILTER)

magnitude response(bandstop filter) phase response(bandstop filter)


100 4
phase in radians
magnitude in db

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:

Start the program

Get the passband and stopband frequency.

Get the sampling frequency.

Calculate the order of the filter.

Obtain the Numerator and denominator coefficient of the filter function.

Plot the frequency response of the filter using bilinear and impulse invariant

transformation.

Specify suitable x axis and y axis label.

Specify suitable title for the signal.

If needed grid can be turned ON

PROGRAM:

Program for the IIR filter using bilinear transformation method:

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’);

Program for the IIR filter using impulse invariant 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:

 Start the program


 Get the input frequency
 Generate the signal for given frequency
 Get the sampling frequency
 Sample the generated signal with sampled frequency
 Plot the original sample
 Stop the program

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

enter the sequence length N:10

enter the up-sampling factor L:2

analog signal sampled signal


2 2

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:

Thus the up sampling of the signal using MATLAB is performed.


EX NO: 6(B) DOWN SAMPLING/DECIMATION
DATE

AIM:
To perform the down sampling of the signal using MATLAB.

SOFTWARE REQUIRED:

MATLAB R2010

PROGRAM LOGIC:

 Start the program


 Get the input frequency
 Generate the signal for given frequency
 Get the sampling frequency
 Sample the generated signal with sampled frequency
 Plot the original sample
 Stop the program

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

enter the sequence length N:10

enter the down-sampling factor M:2

analog signal sampled signal


2 2

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:

Thus the down sampling of the signal using MATLAB is performed.


EX.NO:7 EQUALIZATION

DATE:

AIM:
To design an equalization by using MATLAB.

APPARATUS REQUIRED:

MATLAB R2009

PROGRAM LOGIC:

Start the program


Specify x label coordinate level
Specify y label coordinate level
Using format equalization signal is obtained
If needed grids can be turned on.

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

input signal constellation


4

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.8 Transmission'channel: Real


Transmission'channel: Imaginary
0.6
Amplitude

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

Magnitude Response (dB)

-5

-10
Magnitude (dB)

-15

-20

-25

-30

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9


Normalized Frequency ( rad/sample)
RESULT:

Thus the equalization has been designed successfully.


EX NO:8 STUDY OF ARCHITECTURE OF DIGITAL SIGNAL PROCESSOR
DATE :

256

256
Cache Control Cache Control
Memory Protect L1P Memory Protect L2
Bandwidth Mgmt Bandwidth Mgmt

256 256

256 256 Power Down


Instruction Fetch
Interrupt
C674x Controller
Fixed/Floating Point CPU
IDMA
Register Register
File A File B 256

64 64
Bandwidth Mgmt CFG

Memory Protect L1D EMC 32 Configuration


Peripherals
Cache Control Bus
MDMA SDMA

8 x 32 64 6464 64

32K Bytes High


L1D
RAM/ Performance
Cach
e Switch Fabric

BLOCK DIAGRAM

Description

The TMS320C6745/6747 device is a low-power digital signal processor based on a


TMS320C674x DSP core. It consumes significantly lower power than other members
of the TMS320C6000™ platform of DSPs.

The TMS320C6745/6747 device enables original-equipment manufacturers (OEMs)


and original-design manufacturers (ODMs) to quickly bring to market devices
featuring high processing performance .

The TMS320C6745/6747 DSP core uses a two-level cache-based architecture. The


Level 1 program cache (L1P) is a 32-KB direct mapped cache and the Level 1 data
cache (L1D) is a 32-KB 2-way set-associative cache. The Level 2 program cache (L2P)
consists of a 256-KB memory space that is shared between program and data space.
L2 memory can be configured as mapped memory, cache, or combinations of the two.
Although the DSP L2 is accessible by other hosts in the system, an additional 128KB of
RAM shared memory (TMS320C6747 only) is available for use by other hosts without
affecting DSP performance.

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:

Thus the architecture of digital signal processor is studied.


EX NO:9 MAC OPERATION USING VARIOUS ADDRESSING MODES

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:

 Code composer studio V4

ALGORITHM:

 Start the program


 Initialize all registers
 Give the input in A2 and A3 registers
 Initialize the routine
 Set the data page and store result in A4 registers.
 Run and execute the program.

PROGRAM:

Addition-direct addressing mode:

.text ; Indicates that what follows is code


.def _c_int00 ; This symbol is defined in this file but
used in another file
_c_int00:
MVKL 0xC0000000,A1
MVKH0xC0000000,A1
MVKL 0x12345678,A2 ; first input
MVKH0x12345678,A2
MVKL 0x8799F593,A3 ; second input
MVKH0x8799F593,A3
ADD A2,A3,A4
STW A4,*A1
NOP
NOP
.END

Addition-indirect addressing mode:

.text ; Indicates that what follows is code


.def _c_int00 ; This symbol is defined in this file but
used in another file
_c_int00:
MVKL 0xC0000000,A1
MVKH0xC0000000,A1
MVKL 0xC0000004,A2 ; first input
MVKH0xC0000004,A2
LDW *A1,A3
NOP 5
LDW *A2,A4
NOP 5
ADDSP A3,A4,A5
NOP 4
MVKL 0xC0000008,A4 ; second input
MVKH0xC0000008,A4
STW A5,*A4
NOP
NOP

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)

void SPI_Write(unsigned short Data);


void Sent_to_SPI(unsigned short Value);
unsigned short i,j=0,High,Value=0;
const float sampf = 11000.0; // Sampling frquency is fixed
const int inpf = 1000; // change the input frquency from 1khz to 8khz(1000 to 8000)
float sampt;
double teta;
signed short value;
int count,nsamp;
void main()
{
spidac_init();
DAC_CS_HIGH();
sampt = 1/sampf;
nsamp = sampf/inpf;
while(1)
{
for(count=0;count<nsamp;count++)
{
teta = (2 * PI * inpf * sampt * count);
value = sin(teta)*2048;
Sent_to_SPI(value);
}
}
}
void Sent_to_SPI(unsigned short Value)
{
DAC_CS_LOW();
Value = (0x0FFF & Value);
Value = (0x0800 ^ Value);
SPI_Write(Value);
for(j=0;j<10;j++);
DAC_CS_HIGH();
}

/****************************/
/* 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;
}

Square Waveform Generation:

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

void delay_ms(Uint32 Ms); // Delay Time


void SPI_Write(unsigned short Data);
void Sent_to_SPI(unsigned short Value);
unsigned short i,j=0,High,Value=0;
void main()
{
// gpio_dir01 = (Uint32 *)0x01E26010; //GPIO Banks 0 and 1
Direction Register
// gpio_out_data01 = (Uint32 *)0x01E26014; //GPIO Banks 0 and 1 Output Data
Register
// *gpio_dir01 = 0xF000FFFF; // 0-output , 1-input
//
spidac_init();
DAC_CS_HIGH();
while(1)
{
Sent_to_SPI(0x0FFF);
delay_ms(1);
Sent_to_SPI(0x0);
delay_ms(1);
}
}

/***************/
/* 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;

// Wait for transmit ready


while( SPI_SPIBUF & 0x10000000 );
/* Write 1 byte */
SPI_SPIDAT1 = Data;
while((SPI_SPIBUF & 0x20000000)==1);

// // Wait for receive data ready


// while ( SPI_SPIBUF & ( 0x80000000 ) );
/* Read 1 byte */
receive = SPI_SPIBUF;
}

Sawtooth Waveform Generation:

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

void delay_ms(Uint32 Ms); // Delay Time


void SPI_Write(unsigned short Data);
unsigned short i,j=0,High,Value=0;
void main()
{
spidac_init();
DAC_CS_HIGH();

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;

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

// // Wait for receive data ready


// while ( SPI_SPIBUF & ( 0x80000000 ) );
/* Read 1 byte */
receive = SPI_SPIBUF;

}
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);

printf("\n Enter the Cutoff Freq ");


scanf("%d",&wc);

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]);
}
}

float mul(float a,int x)


{
for(i=0;i<x-1;i++)
a*=a;
return(a);
}

High 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 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]);
}

float mul(float a,int x)


{
for(i=0;i<x-1;i++)
a*=a;
return(a);
}
RESULT:
Thus the implementation of IIR filter process was done and output was observed using
TMS320C6745 processor and executed successfully.
EX NO: 15 FINITE WORD LENGTH EFFECTS

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,
};

// lets consider input sample to the system


unsigned intISample[10] = {0xFAE, 0x111, 0x86C, 0xDA5, 0x7B8, 0x6E8, 0x645, 0x79D, 0xA12, 0xC68
};

float OSample1[10];
float OSample2[10];

void main()
{
unsignedint i=0,j=0;
unsignedint n=0;
unsignedint k=0;

for(i=0;i<N;i++) // Clearing the output memory


{
OSample1[i]=0;
OSample2[i]=0;
}

for(n=0;n<N;n++) // Convolution of input sample and filter coefficents


{
for(k=0;k<=n;k++) // Covolution without truncated
OSample1[n] = (OSample1[n]) + ((ISample[k])*(coeff1[n-k]));
}

for(n=0;n<N;n++) // Convolution of input sample and filter coefficents


{
for(k=0;k<=n;k++) // Covolution with truncated
OSample2[n] = (OSample2[n]) + ((ISample[k])*(coeff2[n-k]));
}

printf("\nEffect of Finite Word Length on Accuracy of Filter Coefficients ");


printf("\nwithout word length & with word length");
for(j=0;j<N;j++)
printf("\n%f %f",OSample1[j],OSample2[j]);

RESULT:
Thus finite word length effects have been implemented and output was observed using
TMS320C6745 processor and executed successfully.

Вам также может понравиться