Sei sulla pagina 1di 84

VICKRAM

COLLEGE OF ENGINEERING,ENATHI-630561
Affiliated to Anna University,Trichy

2011-2012

EC1359-DIGITAL SIGNAL PROCESSING LABORATORY

VI SEMESTER

B.Tech-INFORMATION TECHNOLOGY

PREPARED BY: APPROVED BY:


Mr.Prithivirajan
(SR.LECTURER/ECE)
Mr.Antony Joe Christo Dr.VenkataKrishanan
(LECTURER/ECE) (HOD/ECE)
LIST OF EXPERIMENTS

Name of the Experiments


S.No Page Number Signature
1 Generation of Signals using MATLAB 1
Linear Convolution of Two Sequences using 3
2
MATLAB
Circular Convolution of Two Sequences using 5
3
MATLAB
Design of IIR Filters using MATLAB 7
4(A) Butterworth Lowpass Filter

Butterworth Highpass filter 9


4(B)
Butterworth Bandpass filter 11
4(C)
Butterworth Bandstop filter 13
4(D)
Chebyshev type-I filter 15
4(E)
Chebyshev Type –II filter 17
4(F)
Design of FIR Filters using MATLAB 19
5(A) Blackman Window

Rectangular Window 21
5(B)
Hamming window 23
5(C)
Hanning window 25
5(D)
Kaiser window 27
5(E)
Calculation of FFT using MATLAB 29
6
Sampling and effect of aliasing 31
7
USING TMS320C5416 PROCESSOR: 34
Study of various Addressing Modes of DSP
8
using Simple Programming Examples

Calculation of FFT 37
9
Implementation of FIR Filter 41
10
Sampling of Input Signal and Display 43
11
IIR Filter Implementation 45
12

GENERATION OF BASIC SEQUENCES

AIM:
To write a program for generation of sine wave, Cosine wave, Unit impulse,
Unit step, Unit ramp and Exponential sequence.

ALGORTHIM:

1. Clear
2. Clear all
3. Close all
4. Initialize the values of n.
5. Apply the inputs to the following sequences.
i) Sine wave signal = sin ( 0.2* pi* n)

ii) Cosine wave signal = cos (0.2* pi* n)

iii) Unit impulse = 1 for n=0


0, otherwise

iv) Unit step = 1 for n≥0


0, otherwise

v) Unit ramp = n , for n≥0


0, otherwise

vi) Exponential sequence = an

6. Plot the graphs


7. Label the graphs
8. Stop
%%%%%%%%%GENERATION OF SIGNALS%%%%%%%%%%

%CLEAR THE SCREEN


clc;
clear all;
close all;

%INITIALIZATION
n=0:15;
pi=3.14;

%SINE WAVE SIGNAL


x=sin(0.2*pi*n);

%PLOT THE SINE WAVE


subplot(2,3,1);
stem(x);

%LABEL THE SINEWAVE


title('SINE WAVE SEQUENCE');
xlabel('time-->');
ylabel('amplitude-->');

%COSINE WAVE SIGNAL


x=cos(0.2*pi*n);

%PLOT THE COSINE WAVE


subplot(2,3,2);
stem(x);

%LABEL THE COSINEWAVE


title('COSINE WAVE SEQUENCE');
xlabel('time-->');
ylabel('amplitude-->');

%EXPONENTIAL SIGNAL
x=0.8.^(-n);

%PLOT EXPONENTIAL SIGNAL


subplot(2,3,3);
stem(x);

%LABEL EXPONENTIAL SEQUENCE


title('EXPONENTIAL SEQUENCE');
xlabel('time-->');
ylabel('amplitude-->');

%RAMP SEQUENCE
x=n;

%PLOT RAMP SEQUENCE


subplot(2,3,4);
stem(x);

%LABEL RAMP SEQUENCE


title('RAMP SEQUENCE');
xlabel('time-->');
ylabel('amplitude-->');

%STEP SEQUENCE
a=length(n);
x=ones(a);

%PLOT STEP SEQUENCE


subplot(2,3,5);
stem(x);

%LABEL STEP SEQUENCE


title('STEP SEQUENCE');
xlabel('time-->');
ylabel('amplitude-->');

%IMPULSE SEQUENCE
x=1;

%PLOT IMPULSE SEQUENCE


subplot(2,3,6);
stem(0,x);

%LABEL IMPULSE SEQUENCE


title('IMPULSE SEQUENCE');
xlabel('time-->');
ylabel('amplitude-->');

RESULT:
Thus the program for generation of basic sequences have been done and
verified.

LINEAR CONVOLUTION

AIM:

To write a program to convolute the two input sequences using linear


convolution.

ALGORTHIM:

9. Clear
10. Clear all
11. Close all
12. Enter the first sequence x(n)
13. Enter the second sequence h(n)
14. The convoluted signal is denoted as
y(n) = Σ x(m) h(n-m)
15. Plot the graphs
16. Label the graphs
17. Stop
ENTER THE FIRST SEQUENCE[1 2 3 4]

ENTER THE SECOND SEQUENCE[3 4 5]

OUTPUT IS:

z=

3 10 22 34 31 20
%%%%%%%%LINEAR CONVOLUTION%%%%%%%%%

%CLEAR THE SCREEN


clc;
clear all;
x=input('ENTER THE FIRST SEQUENCE');
y=input('ENTER THE SECOND SEQUENCE');
z=conv(x,y);

%PLOT THE FIRST SEQUENCE


subplot(3,1,1);
stem(x);

%LABEL THE FIRST SEQUENCE


title('FIRST SEQUENCE');
xlabel('time-->');
ylabel('amplitude-->');

%PLOT THE SECOND SEQUENCE


subplot(3,1,2);
stem(y);

%LABEL THE SECOND SEQUENCE


title('SECOND SEQUENCE');
xlabel('time-->');
ylabel('amplitude-->');

%PLOT THE OUTPUT SEQUENCE


subplot(3,1,3);
stem(z);

%LABEL THE OUTPUT SEQUENCE


title('OUTPUT SEQUENCE');
xlabel('time-->');
ylabel('amplitude-->');

%DISPLAY THE OUTPUT


disp('THE OUTPUT IS:');z
RESULT:

Thus the program for linear convolution was verified and the output was
obtained.

CIRCULAR CONVOLUTION

AIM:

To write a program to convolute the two input sequences using circular


convolution.

ALGORTHIM:

1. Clear
2. Clear all
3. Close all
4. Get the two input sequences g(n) and h(n)
5. Find the length of two input sequences.
6. Determine their value of K by using the formula
K = mod( n-m , 1 ) +1

7. Find the value of y by using the formula


Y= y+ g(m) * h(k)
8. Plot the graphs
9. Label the graphs
10. Stop
1

z=

1 4

z=

1 4 8

z=

1 4 8 8

n=

0 1 2 3

THE RESULTANT OUTPUT IS:

z=

1 4 8 8
%%%%%%%%%CIRCULAR CONVOLUTION%%%%%%

%CLEAR THE SCREEN


clc;
clear all;
close all;

%INPUT
g=[1 2 4 0]
h=[1 2]

%LENGTH OF THE INPUT


L=length(g);
M=length(h);

%ZERO PADDING
if L>M
h=[h zeros(1,L-M)];
else
g=[g zeros(1,M-L)];
L=M;
end;

%OUTPUT
for n=1:L
y=0;
for M=1:L
k=mod(n-M,L)+1;
y=y+g(M)*h(k);
end
z(n)=y
end

%PLOT THE INPUT


n=0:L-1
figure(1);
subplot(3,1,1);
stem(n,g,'.');

%TITLE
title('CIRCULAR CONVOLUTION');
%PLOT THE INPUT
subplot(3,1,2);
stem(n,h,'*');

%LABEL
ylabel('amplitude-->');

%PLOT THE OUTPUT


subplot(3,1,3);
stem(n,z,'r.');

%LABEL
xlabel('time-->')

%DISPLAY THE OUTPUT


disp('THE RESULTANT OUTPUT IS:');z
RESULT:

Thus the program for circular convolution was verified and the output was
obtained.

BUTTERWORTH LOWPASS FILTER

AIM:

To write a program to design a Butterworth lowpass filter

ALGORTHIM:

1. Clear
2. Clear all
3. Close all
4. Get the pass band and stop band ripples
5. Get the pass band and stop band frequencies.
6. Get the sampling frequency.
7. Calculate the order of the filter
i. N ≥ log( λ/ ξ ) / log (1/ k)
8. Find the filter co- efficient.
9. Plot the phase and magnitude responses.
10. Label the graphs
11. Stop
Enter the passband ripple0.5
Enter the stopband ripple40
Enter the passband frequency1200
Enter the stopband frequency2400
Enter the sampling frequency10000

>> 1 4 8 8
%%%%%%%%%BUTTER WORTH LOW PASS FILTER%%%%%%%%

%CLEAR THE SCREEN


clc;
clear all;
close all;
format long;

%INPUT
rp=input('Enter the passband ripple');
rs=input('Enter the stopband ripple');
wp=input('Enter the passband frequency');
ws=input('Enter the stopband frequency');
fs=input('Enter the sampling frequency');

%OUTPUT
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs);
[b,a]=butter(n,wn);
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);

%PLOT THE GAIN


subplot(2,1,1);
plot(om/pi,m);

%TITLE
title('BUTTER WORTH LOW PASS FILTER');

%LABEL THE OUTPUT


ylabel('gain in db-->');
xlabel('(a)normalized frequency-->');

%PLOT THE PHASE


subplot(2,1,2);
plot(om/pi,an);

%LABEL THE OUTPUT


xlabel('(b)normalized frequency-->');
ylabel('phase in radians-->');

RESULT:

Thus the design of Butterworth lowpass filter has been done and verified.

BUTTERWORTH HIGHPASS FILTER

AIM:

To write a program to design a Butterworth highpass filter

ALGORTHIM:

1. Clear
2. Clear all
3. Close all
4. Get the pass band and stop band ripples
5. Get the pass band and stop band frequencies.
6. Get the sampling frequency.
7. Calculate the order of the filter
i. N ≥ log( λ/ ξ ) / log (1/ k)
8. Find the filter co- efficient.
9. Plot the phase and magnitude responses.
10. Label the graphs
11. Stop

Enter the passband ripple0.5


Enter the stopband ripple40
Enter the passband frequency1200
Enter the stopband frequency2500
Enter the sampling frequency10000
%%%%%%%%BUTTER WORTH HIGH PASS FILTER%%%%%%

%CLEAR THE SCREEN


clc;
clear all;
close all;
format long;

%INPUT
rp=input('Enter the passband ripple');
rs=input('Enter the stopband ripple');
wp=input('Enter the passband frequency');
ws=input('Enter the stopband frequency');
fs=input('Enter the sampling frequency');

%OUTPUT
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs);
[b,a]=butter(n,wn,'high');
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);

%PLOT THE GAIN


subplot(2,1,1);
plot(om/pi,m);

%TITLE
title('BUTTER WORTH HIGH PASS FILTER');

%LABEL THE OUTPUT


ylabel('gain in db-->');
xlabel('(a)normalized frequency-->');

%PLOT THE PHASE


subplot(2,1,2);
plot(om/pi,an);

%LABEL THE OUTPUT


xlabel('(b)normalized frequency-->');
ylabel('phase in radians-->');

RESULT:

Thus the design of Butterworth highpass filter has been done and verified.

BUTTERWORTH BANDPASS FILTER

AIM:

To write a program to design a Butterworth bandpass filter

ALGORTHIM:

1. Clear
2. Clear all
3. Close all
4. Get the pass band and stop band ripple
5. Get the pass band and stop band frequency
6. Get the sampling frequency
7. Calculate the order of the filter
i. N ≥ log ( λ/ ξ ) / log (1/ k)
8. Find the filter co- efficients
9. Plot the phase and magnitude responses.
10. Label the graphs
11. Stop

Enter the passband ripple0.5


Enter the stopband ripple40
Enter the passband frequency1200
Enter the stopband frequency2400
Enter the sampling frequency10000

wn =

0.24000000000000 0.48000000000000
>>

%%%%%%BUTTER WORTH BAND PASS FILTER%%%%%%

%CLEAR THE SCREEN


clc;
clear all;
close all;
format long;

%INPUT
rp=input('enter the passband ripple');
rs=input('Enter the stopband ripple');
wp=input('Enter the passband frequency');
ws=input('Enter the stopband frequency');
fs=input('Enter the sampling frequency');
%OUTPUT
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs);wn=[w1,w2]
[b,a]=butter(n,wn,'bandpass');
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);

%PLOT THE GAIN


subplot(2,1,1);
plot(om/pi,m);

%TITLE
title('BUTTER WORTH BAND PASS FILTER');

%LABEL THE OUTPUT


ylabel('gain in db-->');
xlabel('(a)normalized frequency-->');

%PLOT THE PHASE


subplot(2,1,2);
plot(om/pi,an);

%LABEL THE OUTPUT


xlabel('(b)normalized frequency-->');
ylabel('phase in radians-->');

RESULT:

Thus the design of Butterworth bandpass filter has been done and verified.

BUTTERWORTH BANDSTOP FILTER

AIM:

To write a program to design a Butterworth bandstop filter

ALGORTHIM:

1. Clear
2. Clear all
3. Close all
4. Get the pass band and stop band ripples
5. Get the pass band and stop band frequencies.
6. Get the sampling frequency.
7. Calculate the order of the filter
i. N ≥ log ( λ/ ξ ) / log (1/ k)
8. Find the filter co- efficient.
9. Plot the phase and magnitude responses.
10. Label the graphs
11. Stop

Enter the passband ripple0.5


Enter the stopband ripple40
Enter the passband frequency1200
Enter the stopband frequency2400
Enter the sampling frequency10000

wn =
0.24000000000000 0.48000000000000

%%%%%%%BUTTER WORTH BAND STOP FILTER%%%%%%%%

%CLEAR THE SCREEN


clc;
clear all;
close all;
format long;

%INPUT
rp=input('Enter the passband ripple');
rs=input('Enter the stopband ripple');
wp=input('Enter the passband frequency');
ws=input('Enter the stopband frequency');
fs=input('Enter the sampling frequency');

%OUTPUT
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs);
wn=[w1,w2]
[b,a]=butter(n,wn,'stop');
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);

%PLOT THE GAIN


subplot(2,1,1);
plot(om/pi,m);

%TITLE
title('BUTTER WORTH BAND STOP FILTER');

%LABEL THE OUTPUT


ylabel('gain in db-->');
xlabel('(a)normalized frequency-->');

%PLOT THE PHASE


subplot(2,1,2);
plot(om/pi,an);

%LABEL THE OUTPUT


xlabel('(b)normalized frequency-->');
ylabel('phase in radians-->');

RESULT:

Thus the design of Butterworth bandstop filter has been done and verified.

CHEBYSHEV TYPE-I FILTER

AIM:

To write a program to design a chebyshev type-I filter

ALGORTHIM:

1. Clear
2. Clear all
3. Close all
4. Initialize the pass band, stop band attenuation and frequency.
5. Find the order and cut off frequency.
6. Find the filter co- efficient.
7. Plot the phase and magnitude responses.
8. Label the graphs
9. Stop

>>
astop =

15
chebyshev type 1 filter
0

-50
gain-->

-100

-150

-200
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
frequency-->
4

2
gain-->

-2

-4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
frequency-->

%%%%%%%%%%CHEBYSHEV TYPE-I FILTER%%%%%%%%

%CLEAR THE SCREEN


clc;
clear all;
close all;

%PASS BAND AND STOP BAND ATTENUATION AND FREQUENCY


apass=1;
astop=15
wp=2*pi;
ws=3*pi;

%ORDER AND CUTOFF FREQUENCY


[n,wn]=cheb1ord(wp\pi,ws\pi,apass,astop);

%OUTPUT
[b,a]=cheby1(n,apass,wn);
w=0:.01:pi;
[h,ph]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);

%PLOT THE GAIN


subplot(2,1,1);
plot(ph/pi,m);
grid;
title('chebyshev type 1 filter');

%LABEL THE GRAPH


ylabel('gain-->');
xlabel('frequency-->');

%PLOT THE PHASE


subplot(2,1,2);
plot(ph/pi,an);
grid;

%LABEL THE GRAPH


ylabel('gain-->');
xlabel('frequency-->');

[b,a]=cheby1(n,apass,wn);

RESULT:

Thus the design of chebyshev type- I filter has been done and verified.

CHEBYSHEV TYPE-II FILTER

AIM:

To write a program to design a chebyshev type-II filter

ALGORTHIM:
1. Clear
2. Clear all
3. Close all
4. Initialize the pass band, stop band attenuation and frequency.
5. Find the order and cut off frequency.
6. Find the filter co- efficient.
7. Plot the phase and magnitude responses.
8. Label the graphs
9. Stop

>>
astop =

15
chebyshev type 2 filter
20

0
gain-->

-20

-40

-60
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
frequency-->
2

1
gain-->

-1

-2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
frequency-->

%%%%%%%%%CHEBYSHEV TYPE-II FILTER%%%%%%%%%

%CLEAR THE SCREEN


clc;
clear all;
close all;

%PASS BAND AND STOP BAND ATTENUATION AND FREQUENCY


apass=1;
astop=15
wp=2*pi;
ws=3*pi;

%ORDER AND CUTOFF FREQUENCY


[n,wn]=cheb1ord(wp\pi,ws\pi,apass,astop);

%OUTPUT
[b,a]=cheby2(n,apass,wn);
w=0:.01:pi;
[h,ph]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);

%PLOT THE GAIN


subplot(2,1,1);
plot(ph/pi,m);
grid;
title('chebyshev type 2 filter');

%LABEL THE GRAPH


ylabel('gain-->');
xlabel('frequency-->');

%PLOT THE PHASE


subplot(2,1,2);
plot(ph/pi,an);
grid;

%LABEL THE GRAPH


ylabel('gain-->');
xlabel('frequency-->');

[b,a]=cheby2(n,apass,wn);

RESULT:

Thus the design of chebyshev type- II filter has been done and verified.

BLACKMAN WINDOW

AIM:

To write a program to design a Blackman window sequence.

ALGORTHIM:

1. Clear
2. Clear all
3. Close all
4. Get the pass band and stop band ripples.
5. Get the pass band and stop band frequencies.
6. Get the sampling frequency.
7. Find the filter co – efficient.
8. Calculate the values of the Blackman window sequence for each low
pass, high pass, band pass and band stop filter.
9. Plot the graphs.
10. Label the graphs.
11. Stop.

Enter the passband ripple0.05


Enter the stopband ripple0.04
Enter the passband frequency1500
Enter the stopband frequency2000
Enter the sampling frequency9000
>>
%%%%%%%%%BLACKMAN WINDOW%%%%%%%

%CLEAR THE SCREEN


clc
clear all;
close all;

%input
rp=input('Enter the passband ripple');
rs=input('Enter the stopband ripple');
fp=input('Enter the passband frequency');
fs=input('Enter the stopband frequency');
f=input('Enter the sampling frequency');

%output
wp=2*fp/f;
ws=2*fs/f;
num=-20*log(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n1=n+1;
if(rem(n,2)~=0);
n1=n;
n=n-1;
end
y=blackman(n1);

%Low pass filter


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('low pass filter');
ylabel('gain in db--->');
xlabel('(a) normalized frequency--->');

%High pass filter


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('high pass filter');
ylabel('gain in db--->');
xlabel('(b) normalized frequency--->');

%Band pass filter


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('band pass filter');
ylabel('gain in db--->');
xlabel('(c) normalized frequency--->');
%Band stop filter
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('band stop filter');
ylabel('gain in db--->');
xlabel('(d) normalized frequency--->');

RESULT:

Thus the design of Blackman window has been done and verified.

RECTANGULAR WINDOW

AIM:

To write a program to design a Rectangular window sequence.

ALGORTHIM:

1. Clear
2. Clear all
3. Close all
4. Get the pass band and stop band ripples.
5. Get the pass band and stop band frequencies.
6. Get the sampling frequency.
7. Find the filter co – efficient.
8. Calculate the values of the rectangular window sequence for each low
pass, high pass, band pass and band stop filter.
9. Plot the graphs.
10. Label the graphs.
11. Stop.

Enter the passband ripple0.05


Enter the stopband ripple0.04
Enter the passband frequency1400
Enter the stopband frequency2500
Enter the sampling frequency9000
%%%%%%%%%RECTANGULAR WINDOW%%%%%%%%%%

%CLEAR THE SCREEN


clc
clear all;
close all;

%input
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
fp=input('enter the passband frequency');
fs=input('enter the stopband frequency');
f=input('enter the sampling frequency');

%output
wp=2*fp/f;
ws=2*fs/f;
num=-20*log(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n1=n+1;
if(rem(n,2)~=0);
n1=n;
n=n-1;
end
y=boxcar(n1);

%Low pass filter


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('low pass filter');
ylabel('gain in db--->');
xlabel('(a) normalized frequency--->');

%High pass filter


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('high pass filter');
ylabel('gain in db--->');
xlabel('(b) normalized frequency--->');

%Band pass filter


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('band pass filter');
ylabel('gain in db--->');
xlabel('(c) normalized frequency--->');

%Band stop filter


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('band stop filter');
ylabel('gain in db--->');
xlabel('(d) normalized frequency--->');

RESULT:

Thus the design of rectangular window has been done and verified.

HAMMING WINDOW

AIM:

To write a program to design a Hamming window sequence.

ALGORTHIM:

1. Clear
2. Clear all
3. Close all
4. Get the pass band and stop band ripples.
5. Get the pass band and stop band frequencies.
6. Get the sampling frequency.
7. Find the filter co – efficient.
8. Calculate the values of the hamming window sequence for each low
pass, high pass, band pass and band stop filter.
9. Plot the graphs.
10. Label the graphs.
11. Stop.

Enter the passband ripple0.05


Enter the stopband ripple0.04
Enter the passband frequency1200
Enter the stopband frequency2400
Enter the sampling frequency9000
>>
low pass filter high pass filter
20 50

gain in db---> 0

gain in db--->
0
-20

-40
-50
-60

-80 -100
0 0.5 1 0 0.5 1
(a) normalized frequency---> (b) normalized frequency--->
band pass filter band stop filter
0 20

-20
0
gain in db--->

gain in db--->
-40
-20
-60
-40
-80

-100 -60
0 0.5 1 0 0.5 1
(c) normalized frequency---> (d) normalized frequency--->

%%%%%%%%%%HAMMING WINDOW%%%%%%%%%

%CLEAR THE SCREEN


clc;
clear all;
close all;
%input
rp=input('Enter the passband ripple');
rs=input('Enter the stopband ripple');
fp=input('Enter the passband frequency');
fs=input('Enter the stopband frequency');
f=input('Enter the sampling frequency');

%output
wp=2*fp/f;
ws=2*fs/f;
num=-20*log(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n1=n+1;
if(rem(n,2)~=0);
n1=n;
n=n-1;
end
y=hamming(n1);

%low pass filter


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('low pass filter');
ylabel('gain in db--->');
xlabel('(a) normalized frequency--->');

%high pass filter


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('high pass filter');
ylabel('gain in db--->');
xlabel('(b) normalized frequency--->');

%band pass filter


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('band pass filter');
ylabel('gain in db--->');
xlabel('(c) normalized frequency--->');

%band stop filter


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('band stop filter');
ylabel('gain in db--->');
xlabel('(d) normalized frequency--->');

RESULT:

Thus the design of hamming window has been done and verified.

HANNING WINDOW

AIM:

To write a program to design a Hanning window sequence.

ALGORTHIM:

1. Clear
2. Clear all
3. Close all
4. Get the pass band and stop band ripples.
5. Get the pass band and stop band frequencies.
6. Get the sampling frequency.
7. Find the filter co – efficient.
8. Calculate the values of the hanning window sequence for each low pass,
high pass, band pass and band stop filter.
9. Plot the graphs.
10. Label the graphs.
11. Stop.

Enter the passband ripple0.05


Enter the stopband ripple0.04
Enter the passband frequency1200
Enter the stopband frequency2400
Enter the sampling frequency9000
>>
low pass filter high pass filter
50 50

0
gain in db--->

gain in db--->
0
-50
-50
-100

-150 -100
0 0.5 1 0 0.5 1
(a) normalized frequency---> (b) normalized frequency--->
band pass filter band stop filter
0 20

0
gain in db--->

gain in db--->
-50
-20

-40
-100
-60

-150 -80
0 0.5 1 0 0.5 1
(c) normalized frequency---> (d) normalized frequency--->

%%%%%%%%%HANNING WINDOW%%%%%%%%%%%

%CLEAR THE SCREEN


clc
clear all;
close all;

%input
rp=input('Enter the passband ripple');
rs=input('Enter the stopband ripple');
fp=input('Enter the passband frequency');
fs=input('Enter the stopband frequency');
f=input('Enter the sampling frequency');

%output
wp=2*fp/f;
ws=2*fs/f;
num=-20*log(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n1=n+1;
if(rem(n,2)~=0);
n1=n;
n=n-1;
end
y=hanning(n1);

%low pass filter


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('low pass filter');
ylabel('gain in db--->');
xlabel('(a) normalized frequency--->');

%high pass filter


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('high pass filter');
ylabel('gain in db--->');
xlabel('(b) normalized frequency--->');

%band pass filter


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('band pass filter');
ylabel('gain in db--->');
xlabel('(c) normalized frequency--->');
%band stop filter
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('band stop filter');
ylabel('gain in db--->');
xlabel('(d) normalized frequency--->');

RESULT:

Thus the design of hanning window has been done and verified.

KAISER WINDOW

AIM:

To write a program to design a Kaiser window sequence.

ALGORTHIM:

1. Clear
2. Clear all
3. Close all
4. Get the pass band and stop band ripples.
5. Get the pass band and stop band frequencies.
6. Get the sampling frequency.
7. Find the filter co – efficient.
8. Calculate the values of the Kaiser window sequence for each low pass,
high pass, band pass and band stop filter.
9. Plot the graphs.
10. Label the graphs.
11. Stop.

Enter the passband ripple0.05


Enter the stopband ripple0.04
Enter the passband frequency1200
Enter the stopband frequency2400
Enter the sampling frequency9000
Enter the beta value6
low pass filter high pass filter
50 50

0
gain in db--->

gain in db--->
0
-50
-50
-100

-150 -100
0 0.5 1 0 0.5 1
(a) normalized frequency---> (b) normalized frequency--->
band pass filter band stop filter
0 10

0
gain in db--->

gain in db--->
-50
-10

-20
-100
-30

-150 -40
0 0.5 1 0 0.5 1
(c) normalized frequency---> (d) normalized frequency--->

%%%%%%%%%%%%KAISER WINDOW%%%%%%%%%%

%CLEAR THE SCREEN


clc;
clear all;
close all;

%input
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
fp=input('enter the passband frequency');
fs=input('enter the stopband frequency');
f=input('enter the sampling frequency');
beta=input('enter the beta value');

%output
wp=2*fp/f;
ws=2*fs/f;
num=-20*log(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n1=n+1;
if(rem(n,2)~=0);
n1=n;
n=n-1;
end
y=kaiser(n1,beta);

%low pass filter


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('low pass filter');
ylabel('gain in db--->');
xlabel('(a) normalized frequency--->');

%high pass filter


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('high pass filter');
ylabel('gain in db--->');
xlabel('(b) normalized frequency--->');

%band pass filter


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('band pass filter');
ylabel('gain in db--->');
xlabel('(c) normalized frequency--->');
%band stop filter
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('band stop filter');
ylabel('gain in db--->');
xlabel('(d) normalized frequency--->');

RESULT:

Thus the design of Kaiser window has been done and verified.

FAST FOURIER TRANSFORM

AIM:

To write a program for finding fast fourier transform.

ALGORTHIM:

1. Clear
2. Clear all
3. Close all
4. Get the input sequences in matrix form.
5. Calculate the length.
6. Apply the inputs in the given formula
1. X(k) = Σ x(n) e –jл2nk / N
7. Plot the graphs.
8. Label the graphs.
9. Stop.

Enter the sequence[1 2 3 4 5 6]


enter the length of fft 6
the resultant output is

y=

21.0000 -3.0000 + 5.1962i -3.0000 + 1.7321i -3.0000 -3.0000 - 1.7321i


-3.0000 - 5.1962i

>>
6

2
Imaginary axis-->

-2

-4

-6
-5 0 5 10 15 20 25
Real axis-->

%%%%%%%%%FAST FOURIER TRANSFORM%%%%%%%%%%

%CLEAR THE SCREEN

clc;
close all;
clear all;

%INPUT
x=input('enter the sequence');
n=input('enter the length of fft');
%OUTPUT
y=fft(x,n);

%PLOT THE GRAPH


stem(y);

%LABEL THE GRAPH


ylabel('Imaginary axis-->');
xlabel('Real axis-->');

disp('the resultant output is');y

RESULT:

Thus the program for fast fourier transform has been done and verified.

SAMPLING OF SIGNALS

AIM:

To write a program for sampling of signals.

ALGORTHIM:

1. Clear
2. Clear all
3. Close all
4. Compute the signal modulated, carrier, and amplitude modulated signal.
5. Compute the 128 point DFT computation of the signal.
6. Plot the signals
7. Label the signals.
8. Stop
Modulated Signal x(n) Carrier Signal xa(n)
2 1

1 0.5

amplitude

amplitude
0 0

-1 -0.5

-2 -1
0 100 200 300 0 100 200 300
n--> n-->
Amplitude modulated Signal xam(n)
2

1
amplitude

-1

-2
0 100 200 300
n-->
128 point DFT of the signal for 0 ? n ? 127 xamp(n)
35

30

25

20
amplitude

15

10

-5
0 20 40 60 80 100 120 140
n-->

128 point DFT of the signal for 0 ? n ? 99 xam(n)


30

25

20

15
amplitude

10

-5

-10

-15
0 20 40 60 80 100 120 140
n-->

%%%%%%%%%%SAMPLING OF SIGNALS%%%%%%%%
clc;
close all;
clear all;
f1=1/128;
f2=5/128;
n=0:255;
fc=50/128;
x=cos(2*pi*f1*n)+cos(2*pi*f2*n);
xa=cos(2*pi*fc*n);
xamp=x.*xa;
subplot(2,2,1);
plot(n,x);
title('Modulated Signal x(n)');
xlabel('n-->');
ylabel('amplitude');

subplot(2,2,2);
plot(n,xa);
title('Carrier Signal xa(n)');
xlabel('n-->');
ylabel('amplitude');

subplot(2,2,3);
plot(n,xamp);
title('Amplitude modulated Signal xam(n)')
xlabel('n-->');
ylabel('amplitude');

%128 point DFT of the signal for 0 ≤ n ≤ 127


n=0:127;
figure;
n1=128;
f1=1/128;
f2=5/128;
fc=50/128;
x=cos(2*pi*f1*n)+cos(2*pi*f2*n);
xc=cos(2*pi*fc*n);
xa=cos(2*pi*fc*n);
xamp=x.*xa;
xam=fft(xamp,n1);
stem(n,xam);
title('128 point DFT of the signal for 0 ≤ n ≤ 127 xamp(n)');
xlabel('n-->');
ylabel('amplitude');

%128 point DFT of the signal for 0 ≤ n ≤ 99


n=0:99;
figure;
n2=0:n1-1;
f1=1/128;
f2=5/128;
fc=50/128;
x=cos(2*pi*f1*n)+cos(2*pi*f2*n);
xc=cos(2*pi*fc*n);
xa=cos(2*pi*fc*n);
xamp=x.*xa;
for i=1:100;
xamp1(i)=xamp(i);
end
xam=fft(xamp1,n1);
stem(n2,xam);
title('128 point DFT of the signal for 0 ≤ n ≤ 99 xam(n)');
xlabel('n-->');
ylabel('amplitude');

RESULT:

Thus the program for sampling of signals has been done and verified.
STUDY OF VARIOUS ADDRESSING MODES OF DSP USING SIMPLE
PROGRAMMING EXAMPLES

AIM:

To write a program to perform addition, Subtraction, Multiplication and


division operations using TMS320c5416 Processor.

1.ADDITION
ALGORTHIM:

1. Initialize the memory for input & output.


2. Load the memory with data pointer.
3. Perform the addition operation.
4. Store the result.
5. End.
PROGRAM:
INP1 .SET 0H
INP2 .SET 1H
OUT .SET 2H
.mmregs
.text
START:
LD #140H , DP
RSBX CPL
NOP
NOP
NOP
NOP
LD INP1,A
ADD INP2,A
STL A,OUT
HLT: B HLT

OUTPUT:

SD A000
Substitute Data A000:05C0-0003
Substitute Data A001:0003-0003
Substitute Data A002:1000-.
#GO 0000
Executing....
Vi Microsystems Pvt. Ltd.
Chennai - 96
Micro5416 Serial Monitor
#SD A002

Substitute Data A002:0006-


2.SUBTRACTION
ALGORTHIM:

1. Initialize the memory for input & output.


2. Load the memory with data pointer.
3. Perform the Subtraction operation.
4. Store the result.
5. End.

PROGRAM:
INP1 .SET 0H
INP2 .SET 1H
OUT .SET 2H

.mmregs
.text

START:
LD #140H , DP
RSBX CPL
NOP
NOP
NOP
NOP
LD INP1,A
SUB INP2,A
STL A,OUT
HLT: B HLT

OUTPUT:

SD A000

Substitute Data A000:0003-0006


Substitute Data A001:0003-0002
Substitute Data A002:0006-.
#GO 0000
Executing....

Vi Microsystems Pvt. Ltd.


Chennai - 96

Micro5416 Serial Monitor

#SD A002

Substitute Data A002:0004-

3. MULTIPLICATION
ALGORTHIM:

1. Initialize the memory for input & output.


2. Load the memory with data pointer.
3. Perform the multiplication operation.
4. Store the result.
5. End.

PROGRAM:

.mmregs
.text

START:

STM #140H,ST0
STM #40H, PMST
STM #0A000H,AR0
ST #2H,*AR0
LD *AR0+,T
ST #4H,*AR0
MPY *AR0+,A
STL A,*AR0
HLT: B HLT

OUTPUT:
GO 0000
Executing....

Vi Microsystems Pvt. Ltd.


Chennai - 96

Micro5416 Serial Monitor

#SD A002

Substitute Data A002:0008-

4.DIVISION
ALGORTHIM:
1. Initialize the memory for input & output.
2. Load the memory with data pointer.
3. Perform the division operation.
4. Store the result.
5. End.

PROGRAM:

DIVID .SET 0H
DIVIS .SET 1H
OUT .SET 2H
.mmregs
.text
START:
STM #140H,ST0
RSBX CPL
RSBX FRCT
NOP
NOP
NOP
NOP
LD DIVID,A
RPT #0FH
SUBC DIVIS,A
STL A, OUT
HLT: B HLT

OUTPUT:
SD A000

Substitute Data A000:0002-0004


Substitute Data A001:0004-0002
Substitute Data A002:0008-.
#GO 0000
Executing....
Vi Microsystems Pvt. Ltd.
Chennai - 96
Micro5416 Serial Monitor
#SD A002
Substitute Data A002:0002-

RESULT:

Thus the programs for addition, subtraction, multiplication and division


operations are executed successfully using DSP processor

TRIANGULAR WAVE GENERATION


AIM:
To write a program for triangular wave generation using TMs320C5416
processor.

ALGORTHIM:

1. Initialize the value.


2. Generate the loop to increment the value.
3. Generate the loop to decrement the value.
4. Store the data in the required memory place.
5. End

PROGRAM:

DATA .SET 0H
.mmREGS
.text

START:
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
NOP
REP:
ST #0H,DATA
INC:
LD DATA,A
ADD #1H,A
STL A, DATA
PORTW DATA, #04H
CMPM DATA, #0FFFFH
BC INC,NTC
DEC:
LD DATA,A
SUB #1H,A
STL A,DATA
PORTW DATA, #04H
CMPM DATA,#00H
BC DEC,NTC
B REP

RESULT:

Thus the program for triangular wave generation was executed successfully.

8-POINT FAST FOURIER TRANSFORM


AIM:
To write a program for 8-point FFT using TMS320C5416 processor.

ALGORTHIM:

1. Initialize the memory for input and output.


2. Get the inputs in the memory location A200.
3. Perform FFT operation.
4. Store the results in A400 memory location.
5. End

PROGRAM:

INPUT .SET 9200H


REV .SET 9300H
INC .SET 9400H
TWIDC .SET 9500H
TWIDS .SET 9550H
BFY .SET 0H
BFYC .SET 1H
DNS .SET 2H
DNSC .SET 3H
GRP .SET 4H
GRPC .SET 5H
STG .SET 6H
STGC .SET 7H
K .SET 8H
INCTF .SET 9H
AX .SET 0AH
BX .SET 0BH
CX .SET 0CH
DX .SET 0DH
ACMBD .SET 0EH
ADPBC .SET 0FH
AR10 .SET 10H
AR11 .SET 11H
AR12 .SET 12H
AR13 .SET 13H
AR14 .SET 14H
ATEMP .SET 15H
BTEMP .SET 16H

.mmregs
.text
START:
STM #40H,PMST
RSBX CPL
STM #120H,ST0
RSBX FRCT
NOP
NOP
CALL BIT_REV
CALL INCLUDE
ST #1H,BFY
ST #4H,GRP
ST #2H,DNS
ST #3H,STG
LD STG,A
SUB #1H,A
STL A,STGC

STM #TWIDC,AR0
RPT #3H
MVPD TABCOS,*AR0+

STM #TWIDS,AR0
RPT #3H
MVPD TABSIN,*AR0+
STM #2H,AR5 ;AR5 = STAGE LOOP
STGLOP:
ST #0H,K
LD BFY,A
SUB #1H,A
STL A,BFYC
LD GRP,A
SUB #1H,A
STL A,GRPC
LD DNS,A
STLM A,AR0
SUB #1H,A
STL A,DNSC
LD DNSC,A
LD GRP,A
CMPM GRP,#4H ;N/2=8/2=4H
BC NO_CHG,NTC
LD #0H,A
NO_CHG:
STL A,INCTF
LD GRPC,A
STLM A,AR3 ;AR3 = GROUP LOOP
STM #INC,AR1
GRPLOP:
ST #0H,K ;k is initially 0 in all groups
LD BFYC,A
STLM A,AR4 ;AR4 = BFLY LOOP
BFYLOP:
LD *AR1+0,A
CALL MUL
LD DNS,A
STLM A,AR0
LD *AR1-0,A
CALL ADDSUB
LD K,A
ADD INCTF,A
STL A,K
BANZ BFYLOP,*AR4-
LD DNS,A
STLM A,AR0
LD *AR1+0,A
BANZ GRPLOP,*AR3-
MPY BFY,#2,A ;BFY * 2 = BFY
STL A,BFY
MPY DNS,#2,A ;DNS * 2 = DNS
STL A,DNS
STLM A,AR0
LD GRP,A
STL A,-1,GRP ;GRP / 2 = GRP
BANZ STGLOP,*AR5-
HLT: B HLT

MUL:
STM #TWIDC,AR2
LD K,A
STLM A,AR0
NOP
NOP
LD *AR2+0,A
LD *AR2,A
STL A,CX
STM #TWIDS,AR2
LD K,A
STLM A,AR0
LD *AR2+0,A
LD *AR2,A
STL A,DX
LD *AR1+,A
STL A,AX
LD *AR1-,A
STL A,BX
LD AX,A
STLM A,T
MPY CX,A ;A*C
LD BX,B
STLM B,T
MPY DX,B ;B*D
SUB B,A ;AC-BD -> A
STL A,-8,ACMBD
LD AX,A
STLM A,T
MPY DX,A ;A*D
LD BX,B
STLM B,T
MPY CX,B ;B*C
ADD A,B ;AD+BC -> B
STL B,-8,ADPBC
LD ACMBD,A
STL A,*AR1+
LD ADPBC,A
STL A,*AR1-
LD DNS,A
STLM A,AR0
RET

ADDSUB:
LD *AR1+0,A
STL A,ATEMP
LD *AR1-0,B
STL B,BTEMP
ADD A,B
STL B,*AR1
LD ATEMP,A
SUB BTEMP,A
LD *AR1+0,B
STL A,*AR1-0
LD *AR1+,A
LD *AR1+0,A
STL A,ATEMP
LD *AR1-0,B
STL B,BTEMP
ADD A,B
STL B,*AR1
LD ATEMP,A
SUB BTEMP,A
LD *AR1+0,B
STL A,*AR1-0
LD *AR1-,A
LD *+AR1(2),A
LDM AR1,A
STL A,AR10
RET
BIT_REV:
STM #INPUT,AR4
STM #REV,AR5
STM #4H,AR0 ;N/2
STM #7H,BRC ;N-1
RPTB REPREV
LD *AR4+0B,A

REPREV: STL A,*AR5+


RET
INCLUDE:
STM #REV,AR1
STM #INC,AR2
STM #7H,BRC
RPTB REPINC
LD *AR1+,A
STL A,*AR2+
LD #0H,A
REPINC: STL A,*AR2+
RET

TABCOS:
.word 00100H
.word 000B5H
.word 00000H
.word 0FF4BH
TABSIN:
.word 00000H
.word 0FF4BH
.word 0FF00H
.word 0FF4BH

RESULT:

Thus the program for 8-point FFT was executed successfully.


OUTPUT:

SD 0A200

Substitute Data A200:E055-0700


Substitute Data A201:EBAA-0B00
Substitute Data A202:B055-0F00
Substitute Data A203:F7AA-0B00
Substitute Data A204:8055-0700
Substitute Data A205:FBAA-0300
Substitute Data A206:9255-0000
Substitute Data A207:AFAA-0300
Substitute Data A208:DFAA-.
#GO 0000
Executing....
Vi Microsystems Pvt. Ltd.
Chennai - 96

Micro5416 Serial Monitor

#SD A400

Substitute Data A400:3900-


Substitute Data A401:0000-
Substitute Data A402:0000-
Substitute Data A403:E5B0-
Substitute Data A404:FF00-
Substitute Data A405:0000-
Substitute Data A406:0000-
Substitute Data A407:03B0-
Substitute Data A408:0100-
Substitute Data A409:0000-
Substitute Data A40A:0000-
Substitute Data A40B:FC50-
Substitute Data A40C:FF00-
Substitute Data A40D:0000-
Substitute Data A40E:0000-.

FIR FILTER DESIGN(HIGH PASS FIR FILTER)


AIM:

To write a program to design a FIR high pass filter using TMS320C5416


processor with the following specifications.

Sampling freq : 43khz


Cut-off freq : 2khz
N : 52
Filter type : High pass filter
Window type : Rectangular

ALGORTHIM:

1. Make all the x(n) zero initially


2. Read the data from the adc.
3. Store the adc data in x(0)
4. Make the pointer to point the x(n_end)
5. Perform the convolution of x(n) and the coefficients h(n) using
MACD instruction.
6. Send the convolution output to the dac
7. Repeat from step 2.

PROGRAM:

.mmregs
.text
START:
STM #01h,ST0 ;intialize the data page pointer
RSBX CPL ;Make the processor to work using DP
RSBX FRCT ;reset the fractional mode bit
NOP
NOP
;*****loop to make all x(n) zero initially*****
STM #150H,AR1 ;initialize ar1 to point to x(n)
LD #0H,A ;make acc zero
RPT #34H
STL A,*AR1+ ;make all x(n) zero

;*****to read the adc data and store it in x(0)*****


LOOP:
PORTR 06,0 ;start of conversion

CHK_BUSY:
PORTR 07,0 ;check for busy
BITF 0,#20H
BC CHK_BUSY,TC
PORTR 04,0 ;read the adc data
LD 0,A
AND #0FFFH,A ;AND adc data with 0fffh for 12 bit adc
XOR #0800H,A ;recorrect the 2's complement adc data
SUB #800H,A ;remove the dc shift
STM #150H,AR1 ;initialize ar1 with x(0)
STL A,*AR1 ;store adc data in x(0)
STM #183H,AR2 ;initialize ar2 with x(n_end)
;*****start of convolution*****
LD #0H,A ;sum is 0 initially
RPT #33H
MACD *AR2-,TABLE,A ;convolution process
STH A,1,0H
LD 0H,A
ADD #800H,A ;add the dc shift to the convolution output
STL A,1H
PORTW 1H,04H ;send the output to the dac
B LOOP

TABLE:
.word 0FCEFH
.word 62H
.word 0FD50H
.word 14AH
.word 0FE1BH
.word 28FH
.word 0FF11H
.word 3E5H
.word 0FFD1H
.word 4ECH
.word 0FFF5H
.word 54FH
.word 0FF28H
.word 4DAH
.word 0FD38H
.word 398H
.word 0FA2EH
.word 1DDH
.word 0F627H
.word 55H
.word 0F131H
.word 4BH
.word 0EA6DH
.word 568H
.word 0D950H
.word 459EH
.word 459EH
.word 0D950H
.word 568H
.word 0EA6DH
.word 4BH
.word 0F131H
.word 55H
.word 0F627H
.word 1DDH
.word 0FA2EH
.word 398H
.word 0FD38H
.word 4DAH
.word 0FF28H
.word 54FH
.word 0FFF5H
.word 4ECH
.word 0FFD1H
.word 3E5H
.word 0FF11H
.word 28FH
.word 0FE1BH
.word 14AH
.word 0FD50H
.word 62H
.word 0FCEFH

RESULT:

Thus the program for FIR high pass filter was executed successfully.
SAMPLING OF SIGNALS

AIM:

To write a program for sampling of signals using TMS320C5416 processor.

PROGRAM:

B3 .SET 0F000H
B2 .SET 0F00H
B1 .SET 00F0H
B0 .SET 000FH
DATA .SET 0H
TXD .SET 1H
FS .SET 2H

.mmregs
.text
START:
STM #0140h,ST0
RSBX CPL
RSBX FRCT
NOP
NOP
NOP
NOP
STM #9200H,AR1
STM #360,AR2
ST #01H,10H
PORTW 10H,0AH
LOOP:
PORTR 06,0
CHK_BUSY:
ST #02H,10H
PORTW 10H,0AH
PORTR 07,0
BITF 0,#20H
BC CHK_BUSY,TC
ST #04H,10H
PORTW 10H,0AH
PORTR 04,0
LD 0,A
AND #0FFFH,A
XOR #0800H,A
STL A,*AR1+
ST #1000H,FS
RPT FS
NOP
BANZ LOOP,*AR2-
REPSER:
LD #25H,A
CALL TXDATA
STM #0140h,ST0
RSBX CPL
NOP
NOP
NOP
NOP
LD FS,A
STL A,DATA
CALL SERIAL
STM #259,AR7
STM #9200H,AR6
REPYN:
ST #55H,10H
PORTW 10H,0AH
LD *AR6+,A
STL A,DATA
CALL SERIAL
BANZ REPYN,*AR7-
LD #40H,A
CALL TXDATA
STM #0140h,ST0
RSBX CPL
NOP
NOP
NOP
NOP
; CALL DELAY
B REPSER
SERIAL:
LD DATA,A
AND #B3,A ;1st digit (from msb)
SFTL A,-12
CALL HEXASC
CALL TXDATA
STM #0140h,ST0
RSBX CPL
NOP
NOP
NOP
NOP
; CALL DELAY
LD DATA,A
AND #B2,A ;1st digit (from msb)
SFTL A,-8
CALL HEXASC
CALL TXDATA
STM #0140h,ST0
RSBX CPL
NOP
NOP
NOP
NOP
; CALL DELAY
LD DATA,A
AND #B1,A ;1st digit (from msb)
SFTL A,-4
CALL HEXASC
CALL TXDATA
STM #0140h,ST0
RSBX CPL
NOP
NOP
NOP
NOP
; CALL DELAY
LD DATA,A
AND #B0,A ;1st digit (from msb)
CALL HEXASC
CALL TXDATA
STM #0140h,ST0
RSBX CPL
NOP
NOP
NOP
NOP
; CALL DELAY
RET
HEXASC:
ADD #30H,A
LD A,B
SUB #3AH,B
BC LESS9,BLT
ADD #7H,A
LESS9:
RET
TXDATA:
CALL 8C41H ; 8C38H for 5416 mode 1
SSBX INTM
rpt #2ffh ;delay
nop
RET
DELAY:
STM #0H,AR3
DEL1: STM #02FFFH,AR2
DEL: LD #0H,A
ADD #1H,A
BANZ DEL,*AR2-
BANZ DEL1,*AR3-
RET

RESULT:

Thus the program for Sampling of signals was executed successfully.

IIR FILTER DESIGN(HIGH PASS FIR FILTER)


AIM:

To write a program to design an IIR butterworth filter using TMS320C5416


processor with the following specifications.

Filter type : High pass filter


Filter order :2
Filter design type : Butterworth
Pass band attenuation : 3db
First corner freq : 0.2
Second corner freq : 0.24
Sampling freq : 50Khz
Cut-off freq : 10Khz

ALGORTHIM:

1. Make all the x(n) zero initially


2. Read the data from the adc.
3. Store the adc data.
4. Make the pointer to point the x(n_end)
5. Perform the convolution of x(n) and the coefficients h(n)
6. Send the convolution output to the dac
7. End

PROGRAM:

;FROM PCDSP COEFFICIENTS

XN .SET 0H
XNM1 .SET 1H
XNM2 .SET 2H
YN .SET 3H
YNM1 .SET 4H
YNM2 .SET 5H
XN1 .SET 6H
XN1M1 .SET 7H
XN1M2 .SET 8H
YN1 .SET 9H
YN1M1 .SET 0AH
YN1M2 .SET 0BH
TEMP .SET 0CH
A10 .SET 0100H
A11 .SET 0FFEDH
A12 .SET 002CH
B10 .SET 0100H
B11 .SET 0FE00H
B12 .SET 0100H
.mmregs
.text
START:
STM #40H,PMST
RSBX CPL
STM #01H,ST0
RSBX FRCT
NOP
NOP
NOP
;initialize xn,x(n-1),x(n-2),yn,y(n-1),y(n-2)
ST #0H,XN
ST #0H,XNM1
ST #0H,XNM2
ST #0H,YN
ST #0H,YNM1
ST #0H,YNM2
ST #0H,XN1
ST #0H,XN1M1
ST #0H,XN1M2
ST #0H,YN1
ST #0H,YN1M1
ST #0H,YN1M2
REPEAT:
;to read data from ADC
PORTR 06,20 ;start of conversion
CHK_BUSY: ;check status
PORTR 07,20
BITF 20,#20H
BC CHK_BUSY,TC
PORTR 04,20 ;read ADC data
LD 20,A
AND #0FFFH,A
XOR #0800H,A ;to correct 2's complement
SUB #800H,A
STL A,XN ;xn
STL A,TEMP
;
LD #0H,B ;sum = B = 0
LD #B10,A ;b0 = T
STLM A,T
MPY XN,A ;b0*xn = A
SFTL A,-8
ADD A,B ;b0*xn =B

LD #B11,A ;b0 = T
STLM A,T
MPY XNM1,A ;b0*xn = A
SFTL A,-8
ADD A,B ;b0*xn =B
LD #B12,A ;b0 = T
STLM A,T
MPY XNM2,A ;b0*xn = A
SFTL A,-8
ADD A,B ;b0*xn =B

LD #A11,A ;b0 = T
STLM A,T
MPY YNM1,A ;b0*xn = A
SFTL A,-8
SUB A,B ;b0*xn =B

LD #A12,A ;b0 = T
STLM A,T
MPY YNM2,A ;b0*xn = A
SFTL A,-8
SUB A,B ;b0*xn =B
STL B,YN
STL B,XN1

LD YNM1,A
STL A,YNM2
LD YN,A
STL A,YNM1
LD XNM1,A
STL A,XNM2
LD XN,A
STL A,XNM1

LD YN,A
ADD #800H,A
STL A,YN
PORTW YN,04H
B REPEAT

RESULT:

Thus the program for IIR butterworth filter was executed successfully.

Potrebbero piacerti anche