You are on page 1of 58

VICKRAM

COLLEGE OF ENGINEERING, ENATHI-630561

Affiliated to Anna University, TRICHY

OCTOBER 2010 PRACTICAL RECORD

NAME : ....................................................................... ID : ...........................LAB: ..............................................

VICKRAM
COLLEGE OF ENGINEERING, ENATHI-630561

BONAFIDE CERTIFICATE STUDENT NAME :_____________________________________________ DEGREE :__________ BRANCH :_________________ SEM : ________ REGISTER NUMBER :_________________________________________ This is to certify that this is the bonafide record of work done by the above student in the _________________________________________________ Laboratory during the academic year 20 - 20

Signature of the Staff-Incharge

Signature of the H.O.D

Submitted for the practical Examination held at Vickram college of Engineering, Enathi on_______________

Internal Examiner

External Examiner

S.No

Date

Name of the Experiment

Page

Signature of Teacher

S.No

Date

Name of the Experiment

Page

Signature of Teacher

OUTPUT: GENERATION OF SIGNALS

PROGRAM: %%%%%%%%%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-->');

OUTPUT: LINEAR CONVOLUTION: ENTER THE FIRST SEQUENCE[1 2 3 4] ENTER THE SECOND SEQUENCE[3 4 5] OUTPUT IS: z= 3 10 22 34 31 20
F 4 a m p lit u d e - - > 2 0 1 1 . 5 2 S 5 a m p lit u d e - - > E . 5 3 t im e - - > C O N D S 2 3 E Q . 5 U E N 4 C E IR S T S E Q U E N C E

. 2 1

. 4 1

. 6 1 O

. 8 2 t im U T P

2 . 2 2 . 4 2 . 6 2 . 8 3 e - - > U T S E Q U E N C

4 a m p lit u d e - - > 2 0 1

0 0 1 . 5 2 2 . 5 3 . 5 4 4 t im e - - > 3 . 5 5 5 . 5 6

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

OUTPUT: CIRCULAR CONVOLUTION: 1 z= 1 z= 1 z= 1 n= 0 1 2 3 4 8 8 4 8 4

THE RESULTANT OUTPUT IS: z= 1 4 8


4 2 0 2 a m p l it u d e - - > 1

8
C IR C U L A R C O N V O L U T IO N

0 . 5

1 . 5

2 . 5

0 . 5

1 . 5

2 . 5

1 0 5

0 . 5

1 . 5 t im e - - >

2 . 5

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

OUTPUT: BUTTERWORTH LOWPASS FILTER: 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
B 2 0 0 U T T E R W O R T H L O W P A S S F IL T E R

g a in in d b - - >

- 2 0 0

- 4 0 0 0

0 . 1

0 . 2

0 . 3 0 . 4 0 . 5 0 . 6 0 . 7 0 . 8 0 . 9 1 ( a ) n o r m a liz e d fr e q u e n c y - - >

4 p h a s e in r a d ia n s - - > 2 0 - 2 - 4 0

0 . 1

0 . 2

0 . 3 0 . 4 0 . 5 0 . 6 0 . 7 0 . 8 0 . 9 1 ( b ) n o r m a liz e d fr e q u e n c y - - >

PROGRAM: %%%%%%%%%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-->');

OUTPUT: BUTTERWORTH HIGHPASS FILTER Enter the passband ripple0.5 Enter the stopband ripple40 Enter the passband frequency1200 Enter the stopband frequency2500 Enter the sampling frequency10000

B 2 0 0

T T E

T H

IG

F IL T E

g a in i n d b - - >

- 2 0 0

- 4 0 0 0

0 . 1

0 . 2

0 . 3 0 . 4 0 . 5 0 . 6 0 . 7 0 . 8 0 . 9 1 ( a ) n o r m a liz e d fr e q u e n c y - - >

4 p h a s e in r a d i a n s - - > 2 0 - 2 - 4 0

0 . 1

0 . 2

0 . 3 0 . 4 0 . 5 0 . 6 0 . 7 0 . 8 0 . 9 1 ( b ) n o r m a liz e d fr e q u e n c y - - >

PROGRAM: %%%%%%%%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-->');

OUTPUT: BUTTERWORTH BANDPASS FILTER: 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 >>

B 2 0 0 0 - 2 0 0 - 4 0 0 - 6 0 0 0

T T E

T H

IL T E

g a in in d b - - >

0 . 1

0 . 2

0 . 3 0 . 4 0 . 5 0 . 6 0 . 7 0 . 8 0 . 9 1 ( a ) n o r m a liz e d fr e q u e n c y - - >

4 p h a s e in r a d ia n s - - > 2 0 - 2 - 4 0

0 . 1

0 . 2

0 . 3 0 . 4 0 . 5 0 . 6 0 . 7 0 . 8 0 . 9 1 ( b ) n o r m a liz e d fr e q u e n c y - - >

PROGRAM: %%%%%%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-->');

OUTPUT: BUTTERWORTH BANDSTOP FILTER 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

B 0

T T E

T H

T O

IL T E

g a in in d b - - >

- 1 0 0

- 2 0 0

- 3 0 0 0

0 . 1 0 . 2 0 . 3 0 . 4 0 . 5 0 . 6 0 . 7 0 . 8 0 . 9 1 ( a ) n o r m a liz e d fr e q u e n c y - - >

4 p h a s e in r a d ia n s - - > 2 0 - 2 - 4 0

0 . 1 0 . 2 0 . 3 0 . 4 0 . 5 0 . 6 0 . 7 0 . 8 0 . 9 1 ( b ) n o r m a liz e d fr e q u e n c y - - >

PROGRAM: %%%%%%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-->');

OUTPUT: BLACKMAN WINDOW: Enter the passband ripple0.05 Enter the stopband ripple0.04 Enter the passband frequency1500 Enter the stopband frequency2000 Enter the sampling frequency9000 >>

lo w 5 0

p a s s

filt e r 5 0 g a in in d b - - - > 0 - 5 0 - 1 0 0

h ig h

p a s s

filt e r

g a in in d b - - - >

0 - 5 0 - 1 0 0 - 1 5 0 0 ( a ) 0

- 1 0 . 5 1 n o r m a liz e d fr e q b a n d p a s s filt e r 1 g a in in d b - - - > 0 . 5 1 n o r m a liz e d 0

5 0 0 0 . 5 1 u (e b n ) c ny o- -r -m > a l i z e d fr e q u e n c y - - - > b a n d s t o p filt e r 0

g a in in d b - - - >

- 5 0

- 1 0 - 2 0

- 1 0 0

- 1 5 0 0 ( c )

- 3 0 0 0 . 5 1 f r e q u (e d n ) c ny o- -r -m > a l i z e d

fr e q u e n c y - - - >

PROGRAM: %%%%%%%%%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--->');

OUTPUT: RECTANGULAR WINDOW: Enter the passband ripple0.05 Enter the stopband ripple0.04 Enter the passband frequency1400 Enter the stopband frequency2500 Enter the sampling frequency9000
lo 5 0 w p a s s filt e r 5 0 h ig h p a s s filt e r

g a in in d b - - - >

- 5

g a in in d b - - - >

- 5

- 1

0 0

0 ( a

0 . 5 ) n o r m b a n d

1 a p a liz e s s

0 0 0 0 . 5 1 d f r e( b q ) u en no cr m y - a - l - i >z e filt e r b a n d s t o p 5 0

- 1

fr e q filt e r

g a in in d b - - - >

- 5

g a in in d b - - - >

- 5

- 1

0 0

0 ( c ) n

0 . 5 o r m

1 a liz e d

- 1

0 0 0 f r e( d q ) u

en

0 . 5 no cr m y

1 - a - l - i >z e d fr e q u e n c y -

PROGRAM: %%%%%%%%%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--->');

OUTPUT: HAMMING WINDOW: Enter the passband ripple0.05 Enter the stopband ripple0.04 Enter the passband frequency1200 Enter the stopband frequency2400 Enter the sampling frequency9000
lo w 5 0 p a s s filt e r 5 0 h ig h p a s s filt e r

g a in in d b - - - >

- 5 0

g a in in d b - - - >

- 5 0

- 1 0 0 0 ( a ) 0

- 1 0 . 5 1 n o r m a liz e d fr e b a n d p a s s filt e 2 0

0 0 0 0 . 5 1 q ( bu )e nn co yr m- - a > l i z e d fr e q u e n c r b a n d s t o p filt e r 0

y - - - >

g a in in d b - - - >

- 5 0

g a in i n d b - - - > ) 0 . 5 n o r m 1 a liz e d

- 2 0 - 4 0 - 6 0 0 0 . 5 1 f r e q ( du )e nn co yr m- - a > l i z e d -

- 1 0 0 0 ( c

fr e q u e n c

y - - - >

>>

PROGRAM: %%%%%%%%%%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--->');

OUTPUT: HANNING WINDOW: Enter the passband ripple0.05 Enter the stopband ripple0.04 Enter the passband frequency1200 Enter the stopband frequency2400 Enter the sampling frequency9000 >>

lo w 5 0 g a in in d b - - - >

p a s s

filt e r 5 0 g a in in d b - - - >

h ig h

p a s s

filt e r

0 - 5 0 - 1 0 0 - 1 5 0 0 ( a ) 0

- 5 0

- 1 0 . 5 1 n o r m a liz e d fr e q b a n d p a s s filt e r 5 g a in in d b - - - >

0 0 0 0 . 5 1 u ( e b n ) c n y o - -r -m > a l i z e d fr e q u e n c y - - - > b a n d s t o p filt e r 0

g a in in d b - - - >

- 5 0

- 1 0 0

- 5 0

- 1 5 0 0 ( c )

0 . 5 1 n o r m a liz e d

- 1 0 0 0 0 . 5 1 f r e q u ( e d n ) c n y o - -r -m > a l i z e d

fr e q u e n c y - - - >

PROGRAM: %%%%%%%%%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--->');

OUTPUT: KAISER WINDOW: 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

lo w 5 0 g a in i n d b - - - >

p a s s

filt e r 5 0 g a i n in d b - - - >

h ig h

p a s s

filt e r

0 - 5 0 - 1 0 0 - 1 5 0 0 ( a ) 0

- 5 0

- 1 0 0 0 . 5 1 0 0 . 5 1 n o r m a liz e d f r e q u( b e ) n n o r- m - >a l i z e d c y fr e q u e n c y - - - > b a n d p a s s filt e r b a n d s t o p filt e r 2 0 g a i n in d b - - - > 0 . 5 1 n o r m a liz e d

g a in i n d b - - - >

- 5 0

- 1 0 0

- 2 0

- 1 5 0 0 ( c )

- 4 0 0 0 . 5 1 f r e q u( d e ) n n o r- m - >a l i z e d c y -

fr e q u e n c y - - - >

PROGRAM: %%%%%%%%%%%%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--->');

OUTPUT: FAST FOURIER TRANSFORM Enter the sequence[1 2 3 4 5 6] enter the length of fft 6 the resultant output is y= Columns 1 through 4 21.000000000000000 -3.000000000000000 + 5.196152422706632i -3.000000000000000 + 1.732050807568877i -3.000000000000000 Columns 5 through 6 -3.000000000000000 - 1.732050807568877i -3.000000000000000 5.196152422706632i >>

2 I m a g in a r y a x is - - >

- 2

- 4

- 6 1

1 . 5

2 . 5

3 R

3 . 5 4 e a l a x

4 . 5 5 is - - >

5 . 5

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

OUTPUT: SAMPLING OF SIGNALS:

M o d u la t e d S ig n a l x (n ) 2 1 0 -1 -2 am plitude am plitude 1 0 .5 0 -0 . 5 -1

C a r rie r S ig n a l x a (n )

100

200

300

100 n -->

200

300

n --> A m p lit u d e m o d u la t e d S ig n a l x a m (n ) 2 1 am plitude 0 -1 -2

100 n -->

200

300

PROGRAM: %%%%%%%%%%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');

STUDY OF VARIOUS ADDRESSING MODES OF DSP USING SIMPLE PROGRAMMING EXAMPLES PROGRAMS: 1.ADDITION 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 2.SUBTRACTION 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

3. MULTIPLICATION .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 4.DIVISION 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

SQUARE WAVE GENERATION

PROGRAM: DATA .SET 0H .mmregs .text START: STM #140H,ST0 ;initialize the data page pointer RSBX CPL ;make the processor to work using DP NOP NOP NOP NOP REP: ST #0H,DATA ;send 0h to the dac CALL DELAY ;delay for some time ST #0FFFH,DATA ;send 0fffh to the dac CALL DELAY ;delay for some time B REP ;repeat the same DELAY: STM #0FFFH,AR1 DEL1: PORTW DATA,04H BANZ DEL1,*AR1RET

8-POINT FAST FOURIER TRANSFORM PROGRAM: INPUT REV INC TWIDC TWIDS BFY BFYC DNS DNSC GRP GRPC STG STGC K INCTF AX BX CX DX ACMBD ADPBC AR10 AR11 AR12 AR13 AR14 ATEMP BTEMP .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .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 9200H 9300H 9400H 9500H 9550H 0H 1H 2H 3H 4H 5H 6H 7H 8H 9H 0AH 0BH 0CH 0DH 0EH 0FH 10H 11H 12H 13H 14H 15H 16H

SUB STL

#1H,A 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,*AR4LD DNS,A STLM A,AR0

LD *AR1+0,A BANZ GRPLOP,*AR3MPY 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,*AR5HLT: 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,*AR1LD DNS,A STLM A,AR0 RET ADDSUB: LD STL LD STL ADD STL LD SUB LD STL LD LD STL LD STL ADD STL LD SUB LD STL LD LD LDM STL RET BIT_REV: STM STM STM STM RPTB LD *AR1+0,A A,ATEMP *AR1-0,B B,BTEMP A,B B,*AR1 ATEMP,A BTEMP,A *AR1+0,B A,*AR1-0 *AR1+,A *AR1+0,A A,ATEMP *AR1-0,B B,BTEMP A,B B,*AR1 ATEMP,A BTEMP,A *AR1+0,B A,*AR1-0 *AR1-,A *+AR1(2),A AR1,A A,AR10 #INPUT,AR4 #REV,AR5 #4H,AR0 ;N/2 #7H,BRC ;N-1 REPREV *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 RET TABCOS: .word .word .word .word TABSIN: .word .word .word .word

A,*AR2+

00100H 000B5H 00000H 0FF4BH 00000H 0FF4BH 0FF00H 0FF4BH

FIR FILTER DESIGN(HIGH PASS FIR FILTER) 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 .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word

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

SAMPLING OF SIGNALS PROGRAM: B3 B2 B1 B0 DATA TXD FS .SET .SET .SET .SET .SET .SET .SET 0F000H 0F00H 00F0H 000FH 0H 1H 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,*AR2REPSER: 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,*AR7LD #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,*AR2BANZ DEL1,*AR3RET