0% found this document useful (0 votes)
2 views60 pages

DSP LAB Manual - ECE -KNCET (2)

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 60

Introduction about MAT LAB

What is MATLAB: MATLAB expansion is MATrixLABoratory.

MATLAB is a high-level technical computing language and interactive environment for algorithm
development, data visualization, data analysis, and numeric computation.

MATLAB can be installed on Unix, Windows and Mac.

Strengths of MATLAB:

MATLAB is relatively easy to learn.

MATLAB code is optimized to be relatively quick when performing matrixoperations.

MATLAB may behave like a calculator or as a programming language.

MATLAB is interpreted, errors are easier to fix.

Although primarily procedural, MATLAB does have some object-orientedelements.

Other Features:

2-D and 3-D graphics functions for visualizing data.

Tools for building custom graphical user interfaces .

Functions for integrating MATLAB based algorithms with external applicationsand languages, such
as C, C++, Fortran, Java, COM, and Microsoft Excel.

Weaknesses of MATLAB:

MATLAB is NOT a general purpose programming language.

MATLAB is an interpreted language (making it for the most part slower than a compiled language
such as C++).

MATLAB is designed for scientific computation and is not suitable for some things (such as parsing
text).

The MATLAB system consists of five main parts:

1. The MATLAB language, this is a high level matrix/array language with control flow statements,
functions data structure input/output, and object oriented programming features. It allows both
“programming in the large” to create complete large and complex application programs.

Digital Signal Processing Lab Manual Page 1


2. The MATLAB working environment. it includes facilities for managing the variables in your
workspace and importing and exporting data. It also includes tools for developing,
managing ,debugging and profiling M-files, MATLAB’s applications

3. Handle Graphics, this is the MATLAB graphics system. It includes high level commands for two
dimensional data visualization, image processing , and animation and presentation graphics .It also
includes low level commands that allows the user to fully customize the appearance of graphics as well
as to build complete Graphical User Interface on your MATLAB applications

4. The MATLAB mathematical function library. This is a vast collection of computational and complex
arithmetic ranging from elementary functions like sum, sine, cosine and complex arithmetic to more
sophisticated function like matrix inverse, matrix eigen values ,Bessel functions and fast Fourier
Transforms.

5. The MATLAB Application program Interface (API). This is a library that allows the user to write C
and FORTRAN programs that interact with MATLAB. It includes facilities for calling routines from
MATLAB(dynamic linking),calling MATLAB as a computational engine, and for reading and writing
MAT-files.

Simulink:

Simulink a companion program to MATLAB is an interactive system for simulating nonlinear


dynamic system. it is a graphical mouse driven program that allows the user to model a system by
drawing a block diagram on the screen and manipulating it dynamically. it can work with liner, nonlinear,
continues – time ,discrete time multivariable and multi rate systems.

Block sets are add ins to simulink that provide additional libraries of blocks for specializing
applications like communications signals processing and power systems.

Real-time workshop is a program that allows the user to generate C code from block diagrams and to
run it on a variety of real time systems.

M-files:

Like most other programming language, MATLAB provides mathematical expressions, but unlike
most programming language, these expressions involve entire matrices. Files that contain code in the
MATLAB language are called M-files .M-files can be creating using a text editor, and can be used as any
other MATLAB function or command.

Digital Signal Processing Lab Manual Page 2


There are two kinds of M-files

1. Scripts which do not accept input arguments or return output arguments. They operate on data in
the workspace.

2. Functions, which can accept input arguments or return output arguments. Internal variables are
local to the function.

Toolboxes:

MATLAB features a family of application –specific solution called toolboxes. Toolboxes are
comprehensive collations of MATLAB functions (M-files) that extend the MATLAB environment to solve
particular classes of problems. Areas in which toolboxes are available include signal processing, control
systems neural networks, fuzzy logic wavelets, Simulation and, many others.

Signal processing Toolbox:

The signal processing toolbox in MATLAB facilities in analysis of signals and design of systems. This
contains a list of functions pertaining to the various areas of signal processing.

 Waveform generation and plotting :eg:sine, chirp


 Filter analysis and implementation:eg: conv,Filter
 Liner system and transformation :eg:residuez,convmtx
 IIR Filter design :eg:buffer,besself
 FIR Filter deign :eg:cremez
 IIR Filter order selection :eg:buttord
 Transforms : eg.dft,fft
 Statistical signal processing eg:.csd,pcov
 Windows eg:boxcar,triang
 Parametric modeling eg: invfreqz.
 specialized operations eg: buffer deconv.
 analog prototype design buttap, besselap.
 frequency translation eg.lp2bs,lp2bp.
 filter discretization eg: bilinear.
 interactive tools eg: sptool.

Exp.No: 1
GENERATION OF INPUT SIGNALS
Digital Signal Processing Lab Manual Page 3
Date:
AIM:

To generate the following standard input signals

1. Unit impulse Signal.


2. Unit step Signal.
3. Unit ramp Signal.
4. Exponential Signal.
5. Sine Wave.
6. Cosine Wave.

APPARATUS REQUIRED:

1. Hardware: IBM PC or compatible

2. Software: Mat lab 7.0 or higher

ALGORITHM:

1. Clear all the variables.

2. Assign the signals unit impulse, unit step, unit ramp, exponential, sine and cosine signals.

3. Assign the time in X axis and amplitude in Y axis.

4. Get the input values of each signal

5. Execute the programs for each given input signal.

6. Plot the waveform.

7. Stop the program.

Digital Signal Processing Lab Manual Page 4


GENERATION OF SIGNALS
%unit impulse signal
clc;
clear all;
close all;
t=-5:1:5
y=[zeros(1,5),ones(1,1),zeros(1,5)];
figure(1);
subplot(2,2,1);
stem(t,y);
xlabel('time-->');
ylabel('Amplitude-->');
title('unit impulse signal');
%unit step signal
N=10;
x=[zeros(1,5),ones(1,5)];
n=0:1:N-1;
subplot(2,2,2);
stem(n,x);
xlabel('time-->');
ylabel('Amplitude-->');
title('unit step signal');
%unit ramp sequence
n=6;
t1=0:n;
subplot(2,2,3);
stem(t1,t1);
xlabel('time-->');
ylabel('Amplitude-->');
title('unit ramp signal');
%exponential signal
n=.5;
t=-5:1:5;
y=exp(-n*-t);
subplot(2,2,4);
stem(t,y);
xlabel('time-->');
ylabel('Amplitude-->');
title('unit exponentail signal');
%sine signal
f=100;
t=1/f;
t1=0:t:10;
x=sin(2*pi*t1);
figure(2);
subplot(2,1,1);
plot(t1,x);
xlabel('time-->');
ylabel('Amplitude-->');
title('sine signal');

Digital Signal Processing Lab Manual Page 5


%cosine signal
f=100;
t=1/f;
t1=0:t:10;
y=cos(2*pi*t1);
subplot(2,1,2);
plot(t1,y);
xlabel('time-->');
ylabel('Amplitude-->');
title('cosine signal');

GENERATION OF SIGNALS

unit impulse signal unit step signal


1 1
Amplitude-->

Amplitude-->

0.5 0.5

0 0
-5 0 5 0 5 10
time--> time-->
unit ramp signal unit exponentail signal
6 15
Amplitude-->

Amplitude-->

4 10

2 5

0 0
0 2 4 6 -5 0 5
time--> time-->

Digital Signal Processing Lab Manual Page 6


sine signal
1

0.5
Amplitude-->

-0.5

-1
0 1 2 3 4 5 6 7 8 9 10
time-->
cosine signal
1

0.5
Amplitude-->

-0.5

-1
0 1 2 3 4 5 6 7 8 9 10
time-->

Digital Signal Processing Lab Manual Page 7


THEORY:

Unit Impulse:

δ (n) = 1 for n=0


= 0 for n≠0
Unit Step:

u(n) = 1 for n ≥ 0
= 0 for n < 0
Unit Ramp:

ur(n) )= 1 for n ≥ 0
= 0 for n < 0
Exponential Sequence:

x (n)=an for all n;

Sine Sequence:

S (n)= sin(2*π*f*n); for all n

Cosine Sequence:

C (n) = cos (2* π *f*n); for all n

RESULT:

Thus the above standard signals have been generated by using the MATLAB.

Exp.No: 2 VERIFICATION OF SAMPLING THEOREM

(SAMPLING AND EFFECT OF ALIASING)


Date:

AIM:

Digital Signal Processing Lab Manual Page 8


To sample the signal and observe the aliasing effect of that signal using MATLAB 7.0.

APPARATUS REQUIRED:
Hard ware: IBM PC or compatible

Soft ware :Matlab 7.0 or higher

ALGORITHM:

1. Get the input frequency and number of samples.


2. The input signal is sampled at the frequencies fs1=2fm, fs2>2fm and fs3<2fm.
3. Plot the input and sampled signal at various frequencies.
% PROGRAM FOR SAMPLING AND EFFECT OF ALIASING

clc;
clear all;
close all;
N=input('Enter the number of samples N= ');
fm=input('Enter the frequency');
t=0:0.01:N;
x=cos(2*pi*fm*t);
subplot(3,2,1);
plot(t,x);
xlabel('Time');
ylabel('Amplitude');
title('Input Signal');
fs1=fm;
fs2=2*fm;
fs3=5*fm;
n=0:0.08:N;
y=cos(2*pi*fm*n);
subplot(3,2,2);
stem(n,y,'r');
xlabel('Time');
ylabel('Amplitude');
title('Sampling Signal');
y1=cos(2*pi*n*fm/fs1);
subplot(3,2,3);
stem(n,y1,'g');
xlabel('Time');
ylabel('Amplitude');
title('Sampling Signal with fs<2fm');
y2=cos(2*pi*n*fm/fs2);
subplot(3,2,4);
stem(n,y2);
xlabel('Time');
ylabel('Amplitude');
title('Sampling Signal with fs=2fm');
y3=cos(2*pi*n*fm/fs3);
subplot(3,2,5);
stem(n,y3);

Digital Signal Processing Lab Manual Page 9


xlabel('Time');
ylabel('Amplitude');
title('Sampling Signal with fs>2fm');

OUTPUT

Input Signal Sampling Signal


1 1
Amplitude

Amplitude
0 0

-1 -1
0 5 10 0 5 10
Time Time
Sampling Signal with fs<2fm Sampling Signal with fs=2fm
1 1
Amplitude

Amplitude

0 0

-1 -1
0 5 10 0 5 10
Time Time
Sampling Signal with fs>2fm
1
Amplitude

-1
0 5 10
Time

RESULT:

Thus the MATLAB program for Sampling and aliasing has been successfully executed.

Exp.No: 3
CALCULATION OF FFT
Date:
AIM:

Digital Signal Processing Lab Manual Page 10


To write the program for calculating the N-point FFT and IFFT of given input sequence using
MATLAB 7.0.

APPARATUS REQUIRED:
Hard ware: IBM PC or compatible

Software :Matlab 7.0 or higher

ALGORITHM:

1. Get the input sequence and its length.


2. Calculate the Fast Fourier Transform and Inverse Fast Fourier Transform of given sequence using
user defined function.
3. Plot the magnitude and phase response of FFT sequence.
4. Plot the IFFT response.

% CALCULATION OF FFT AND IFFT


clc;
clear all;
close all;
x=input('x(n)=');
N=length(x);
n=input('n=');
y=fft(x,n);
v=0:1:N-1;
t=0:1:n-1;
subplot(2,2,1);
stem(v,x);
xlabel('Time');
ylabel('Amplitude');
title('Input Signal');
subplot(2,2,2);
stem(t,abs(y));
xlabel('Time');
ylabel('Amplitude');
title('Magnitude Response');
subplot(2,2,3);
stem(t,angle(y));
xlabel('Time');
ylabel('Amplitude');
title('Phase Response');
disp('fft x(n)=1');
disp(y);
y1=ifft(y,n);
subplot(2,2,4);
stem(t,y1);
xlabel('Time');
ylabel('Amplitude');
title('IFFT Response');
disp('ifft X(K)');
disp(y1);
OUTPUT:
Digital Signal Processing Lab Manual Page 11
x(n)=[1 0 0 1 0 1 0 1]
n=8
fft x(n)=1
Columns 1 through 5
4.0000 0.2929 + 0.7071i 1.0000 + 1.0000i 1.7071 + 0.7071i -2.0000
Columns 6 through 8
1.7071 - 0.7071i 1.0000 - 1.0000i 0.2929 - 0.7071i
ifft X(K)
1 0 0 1 0 1 0 1

Input Signal Magnitude Response


1 4

3
Amplitude

Amplitude
0.5 2

0 0
0 2 4 6 8 0 2 4 6 8
Time Time
Phase Response IFFT Response
4 1
Amplitude

Amplitude

2
0.5
0

-2 0
0 2 4 6 8 0 2 4 6 8
Time Time

RESULT:

Thus the Matlab program for the N-point FFT and IFFT of given input sequence was calculated.

Digital Signal Processing Lab Manual Page 12


Exp.No: 4
CONVOLUTION OF SIGNALS
Date:
AIM:

To write the program for finding the linear and circular convolution of two signals using MATLAB 7.0

APPARATUS REQUIRED:
Hard ware: IBM PC or compatible

Soft ware :Matlab 7.0 or higher

LINEAR CONVOLUTION:

ALGORITHM:
1. Get the number of samples.
2. Generate the output sequence of the given two input signals using‘conv’ command.
3. Plot the graph.

% PROGRAM FOR LINEAR CONVOLUTION

clc;
clear all;
close all;
x=input('Enter the first sample');
N1=length(x);
h=input('Enter the second sample');
N2=length(h);
n=0:1:N1-1;
subplot(2,2,1);
stem(n,x);
xlabel('Time');
ylabel('Amplitude');
title('X Sequence Response');
n=0:1:N2-1;
subplot(2,2,2);
stem(n,h);
xlabel('Time');
ylabel('Amplitude');
title('H Sequence Response');
y=conv(x,h);
N=N1+N2-1;
n=0:1:N-1;
subplot(2,2,3);
stem(n,y);
xlabel('Time');
ylabel('Amplitude');
title('Convolution of X&H Response');

Digital Signal Processing Lab Manual Page 13


Enter the first sample[1 2]

Enter the second sample[1 2 4]

CIRCULAR CONVOLUTION:
ALGORITHM:
1. Get the number of samples.
2. Generate the sequence for the given two input signals using ‘zeros’ and ‘ones’ matrix command.
3. Generate the convoluted output sequence of the given two input signals using ‘conv’ command.
4. Plot the graph.

X Sequence Response H Sequence Response


2 4

1.5 3
Amplitude

1 Amplitude 2

0.5 1

0 0
0 0.5 1 0 0.5 1 1.5 2
Time Time
Convolution of X&H Response
8

6
Amplitude

0
0 1 2 3
Time

% PROGRAM FOR CIRCULAR CONVOLUTION

clc;
clear all;
close all;
x=input('enter the input signal');
h=input('enter the impulse signal');
n2=length(x);
n3=length(h);
if(n2==n3)
n=max(n2,n3)
x1=[x,zeros(1,n-n2)];
h1=[h,zeros(1,n-n3)];

Digital Signal Processing Lab Manual Page 14


m=[0:1:n-1];
s=h1(mod(-m,n)+1);
for N=1:1:n;
m=N-1;
P=0:1:n-1;
H(N,:)=s(mod(P-m,n)+1);
end;
Y=x1*H;
display(Y);
figure(1);
subplot(2,2,1);
stem(x);
xlabel('-->N');
ylabel('-->amplitude');
title('input sequencex(n)');
subplot(2,2,2);
stem(h);
xlabel('-->N');
ylabel('-->amplitude');
title('impulse sequence h(N)');
subplot(2,2,[3,4]);
stem(Y);
xlabel('-->N');
ylabel('-->amplitude');
title('output sequence y(N)');
else
disp('the length of x(n)and h(n) should be equal');
end

Enter the first sequence[1 2 4]


Enter the second sequence[1 2 3]
Convolution of x & h is
9 4 8

Digital Signal Processing Lab Manual Page 15


X Sequence Response H Sequence Response
4 2

3 1.5
Amplitude

Amplitude
2 1

1 0.5

0 0
0 0.5 1 1.5 2 0 0.5 1
Time Time
Convolution of X&H Response
10
Amplitude

0
1 1.5 2 2.5 3
Time

RESULT

Thus theMatlab program for Linear and Circular Convolution of the two sequences through
Fast Fourier Transformation was successfully executed.

Exp.No: 5.a
DESIGN OF FIR FILTER USING RECTANGULAR WINDOW
Date:

AIM:

To design a FIR filter using Rectangular window with MATLAB 7.0.

APPARATUS REQUIRED:

Hard ware: IBM PC or compatible

Digital Signal Processing Lab Manual Page 16


Soft ware :Matlab 7.0 or higher

ALGORITHM:

1. Get the pass band and stop band ripple and frequency.
2. Get the sampling frequency.
3. Find the order of filter ‘N’.
4. Design the low pass, high pass, band pass and band stop filter.
5. Plot the magnitude response of all filters.
PROGRAM:
clc;
clear all;
close all;
rp=input('Pass band ripple=');
rs=input('Stop band ripple=');
fs=input('Stop band frequency in rad/sec=');
fp=input('Pass band frequency in rad/sec=');
f=input('Sampling frequency in rad/sec=');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(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,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('LOW PASS FILTER')
%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,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('HIGH PASS FILTER')
%BAND PASS FILTER
wn=[wp,ws];
x=fir1(n,wn,y);
[h,o]=freqz(b,1,256);

Digital Signal Processing Lab Manual Page 17


subplot(2,2,3);
plot(o/pi,m,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('BAND PASS FILTER')
%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,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('BAND STOP FILTER')

Pass band ripple=0.05


Stop band ripple=0.04
Stop band frequency in rad/sec=2000
Pass band frequency in rad/sec=1500
Sampling frequency in rad/sec=9000

n=

18

Digital Signal Processing Lab Manual Page 18


LOW PASS FILTER HIGH PASS FILTER
50 50

Gain in db---->

Gain in db---->
0 0

-50 -50

-100 -100
0 0.5 1 0 0.5 1
Normalized frequency----> Normalized frequency---->
BAND PASS FILTER BAND STOP FILTER
50 10
Gain in db---->

Gain in db---->
0 0

-50 -10

-100 -20
0 0.5 1 0 0.5 1
Normalized frequency----> Normalized frequency---->

RESULT:

Thus FIR Filter using Rectangular windowis designed by using Matlab.

Exp.No: 5.b
DESIGN OF FIR FILTER USING HAMMING WINDOW
Date:

AIM:

To design a FIR filter using Hamming window with MATLAB 7.0.

APPARATUS REQUIRED:

Digital Signal Processing Lab Manual Page 19


Hard ware: IBM PC or compatible

Soft ware :Matlab 7.0 or higher

ALGORITHM:
1. Get the pass band and stop band ripple and frequency.
2. Get the sampling frequency.
3. Find the order of filter N.
4. Design the lowpass, High pass, Band pass and Band stop filter.
5. Plot the magnitude response of all the filters.
PROGRAM:

clc;
clear all;
close all;
rp=input('Pass band ripple=');
rs=input('Stop band ripple=');
fs=input('Stop band frequency in rad/sec=');
fp=input('Pass band frequency in rad/sec=');
f=input('Sampling frequency in rad/sec=');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(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,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('LOW PASS FILTER')
%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,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('HIGH PASS FILTER')
%BAND PASS FILTER
wn=[wp,ws];

Digital Signal Processing Lab Manual Page 20


x=fir1(n,wn,y);
[h,o]=freqz(b,1,256);
subplot(2,2,3);
plot(o/pi,m,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('BAND PASS FILTER')
%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,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('BAND STOP FILTER')

Pass band ripple=0.02


Stop band ripple=0.01
Stop band frequency in rad/sec=1700
Pass band frequency in rad/sec=1200
Sampling frequency in rad/sec=9000

n = 30

Digital Signal Processing Lab Manual Page 21


LOW PASS FILTER HIGH PASS FILTER
50 50

Gain in db---->

Gain in db---->
0
-50
-50
-100

-150 -100
0 0.5 1 0 0.5 1
Normalized frequency----> Normalized frequency---->
BAND PASS FILTER BAND STOP FILTER
50 5

0
Gain in db---->

Gain in db---->
0
-5
-50
-10

-100 -15
0 0.5 1 0 0.5 1
Normalized frequency----> Normalized frequency---->

RESULT:

Thus FIR Filter using Hamming window is designed by using Matlab.

Digital Signal Processing Lab Manual Page 22


Exp.No: 5.c
DESIGN OF FIR FILTER USING HANNING WINDOW
Date:

AIM:

To design a FIR filter using Hanning window with MATLAB 7.0.

APPARATUS REQUIRED:

Hard ware: IBM PC or compatible

Soft ware :Matlab 7.0 or higher

ALGORITHM:
1. Get the pass band and stop band ripple and frequency.
2. Get the sampling frequency.
3. Find the order of filter N.
4. Design the lowpass,Highpass,Band pass and Band stop filter.
5. Plot the magnitude response of all the filters.

PROGRAM OF FIR FILTER USING HANNING WINDOW

clc;
clear all;
close all;
rp=input('Pass band ripple=');
rs=input('Stop band ripple=');
fs=input('Stop band frequency in rad/sec=');
fp=input('Pass band frequency in rad/sec=');
f=input('Sampling frequency in rad/sec=');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(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);
Digital Signal Processing Lab Manual Page 23
plot(o/pi,m,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('LOW PASS FILTER')
%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,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('HIGH PASS FILTER')
%BAND PASS FILTER
wn=[wp,ws];
x=fir1(n,wn,y);
[h,o]=freqz(b,1,256);
subplot(2,2,3);
plot(o/pi,m,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('BAND PASS FILTER')
%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,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('BAND STOP FILTER')

Pass band ripple=0.03


Stop band ripple=0.01
Stop band frequency in rad/sec=2000
Pass band frequency in rad/sec=1400
Sampling frequency in rad/sec=8000

n= 21

Digital Signal Processing Lab Manual Page 24


LOW PASS FILTER HIGH PASS FILTER
50 50

Gain in db---->

Gain in db---->
0
-50
-50
-100

-150 -100
0 0.5 1 0 0.5 1
Normalized frequency----> Normalized frequency---->
BAND PASS FILTER BAND STOP FILTER
50 5

0
Gain in db---->

Gain in db---->
0
-5
-50
-10

-100 -15
0 0.5 1 0 0.5 1
Normalized frequency----> Normalized frequency---->

RESULT:

Thus FIR Filter using Hanning window is designed by using Matlab.

Digital Signal Processing Lab Manual Page 25


Exp.No: 5.d
DESIGN OF FIR FILTER USING BLACKMANN WINDOW
Date:

AIM:

To design a FIR filter using Blackmann window with MATLAB 7.0.

APPARATUS REQUIRED:

Hard ware: IBM PC or compatible

Soft ware :Matlab 7.0 or higher

ALGORITHM:
1. Get the pass band and stop band ripple and frequency.
2. Get the sampling frequency.
3. Find the order of filter N.
4. Design the lowpass,Highpass,Band pass and Band stop filter.
5. Plot the magnitude response of all the filters.

PROGRAM OF FIR FILTER USING BLACKMANN WINDOW

clc;
clear all;
close all;
rp=input('Pass band ripple=');
rs=input('Stop band ripple=');
fs=input('Stop band frequency in rad/sec=');
fp=input('Pass band frequency in rad/sec=');
f=input('Sampling frequency in rad/sec=');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(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);
Digital Signal Processing Lab Manual Page 26
plot(o/pi,m,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('LOW PASS FILTER')
%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,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('HIGH PASS FILTER')
%BAND PASS FILTER
wn=[wp,ws];
x=fir1(n,wn,y);
[h,o]=freqz(b,1,256);
subplot(2,2,3);
plot(o/pi,m,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('BAND PASS FILTER')
%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,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('BAND STOP FILTER')

Pass band ripple=0.03


Stop band ripple=0.01
Stop band frequency in rad/sec=2500
Pass band frequency in rad/sec=2000
Sampling frequency in rad/sec=7000

n = 22

Digital Signal Processing Lab Manual Page 27


LOW PASS FILTER HIGH PASS FILTER
50 50

0 0

Gain in db---->

Gain in db---->
-50 -50

-100 -100

-150 -150
0 0.5 1 0 0.5 1
Normalized frequency----> Normalized frequency---->
BAND PASS FILTER BAND STOP FILTER
50 5

0
Gain in db---->

Gain in db---->
0
-50
-5
-100

-150 -10
0 0.5 1 0 0.5 1
Normalized frequency----> Normalized frequency---->

RESULT:

Thus FIR Filter using Blackman window is designed by using Matlab.

Digital Signal Processing Lab Manual Page 28


Exp.No: 6 BUTTERWORTH DIGITAL IIR FILTER

Date:

AIM:

To design a Butterworth digital IIR filter using MATLAB 7.0.

APPARATUS REQUIRED:

Hard ware: IBM PC or compatible

Soft ware :Matlab 7.0 or higher

ALGORITHM:

1. Start the program and specify the input datas for each type of filters.
2.Find the order of the filter using built function.
3.Find the number and denominator polynomials for calculation of transfer function.
4.Plot the frequency response and gain for low pass,high pass, band pass and band stop IIR butterworth
filter.
5.Stop the program

PROGRAM:
clc;
clear all;
close all;
N=8;
wn=0.4;
[num,den]=butter(N,wn,'s');
w=(0:0.01:2);
h=freqs(num,den,w);
subplot(2,2,1);
plot(w/2*pi,(abs(h)),'linewidth',2.5);
title('butterworth low pass filter');
grid on;
xlabel('frequency in hz');
ylabel('gain in db');
[num,den]=butter(N,wn,'high','s');
h=freqs(num,den,w);
subplot(2,2,2);
plot(w/2*pi,(abs(h)),'linewidth',2.5);
title('butterworth high pass filter');
grid on;
xlabel('frequency in hz');
ylabel('gain in db');
Digital Signal Processing Lab Manual Page 29
N=8;
wp=0.4;
ws=0.6;
wn=[wp ws];
[num,den]=butter(N,wn,'s');
h=freqs(num,den,w);
subplot(2,2,3);
plot(w/2*pi,(abs(h)),'linewidth',2.5);
title('butterworth band pass filter');
grid on;
xlabel('frequency in hz');
ylabel('gain in db');
N=8;
wp=0.4;
ws=0.6;
wn=[wp ws];
[num,den]=butter(N,wn,'stop','s');
h=freqs(num,den,w);
subplot(2,2,4);
plot(w/2*pi,(abs(h)),'linewidth',2.5);
title('butterworth band stop filter');
grid on;
ylabel('gain in db');
xlabel('frequency in hz');

butterworth low pass filter butterworth high pass filter


1 1
gain in db

gain in db

0.5 0.5

0 0
0 1 2 3 4 0 1 2 3 4
frequency in hz frequency in hz
butterworth band pass filter butterworth band stop filter
1.5 1.5
gain in db

gain in db

1 1

0.5 0.5

0 0
0 1 2 3 4 0 1 2 3 4
frequency in hz frequency in hz

RESULT:

Thus the digital butterworth IIR Filteris designed by using Matlab program.

Digital Signal Processing Lab Manual Page 30


Exp.No: 7
DECIMATION BY POLYPHASE DECOMPOSITION
Date:

AIM:

To write a program to compute Convolution and m-fold decimation by poly phase decomposition

APPARATUS REQUIRED:
Hard ware: IBM PC or compatible

Soft ware :Matlab 7.0 or higher

ALGORITHM:
1. Get the input sequence.
2. Get the filter coefficients and also the decimation factor.
3. Find the response by using convolution.
4. Plot the graph.

PROGRAM

Clear all;
clc;
close all;
x=input('enter the input sequence');
h=input('enter the FIR filter coefficients');
M=input('enter the decimation factor');
N1=length(x);
n=0:1:N1-1;
subplot(2,1,1);
stem(n,x);
xlabel('time');
ylabel('amplitude');
title('X sequence response');
N2=length(h);
n=0:1:N2-1;
subplot(2,1,2);
stem(n,h);
xlabel('time');
ylabel('amplitude');
title('H sequence response');
H=length(h);
P=floor((H-1)/M)+1;
r=reshape([reshape(h,1,H),zeros(1,P*M-H)],M,P);
X=length(x);
Y=floor((X+H-2)/M)+1;
U=floor((X+M-2)/M)+1;
R=zeros(1,X+P-1);

Digital Signal Processing Lab Manual Page 31


for m=1:M
R=R+conv(x(1,:),r(m,:));
end
disp(R);
N=length(R);
n=0:1:N-1;
figure(2);
stem(n,R);
xlabel('time');
ylabel('amplitude');
title('Decimation of polyphase decomposition sequence response');

X sequence response
4

3
amplitude

0
0 0.5 1 1.5 2 2.5 3
time
H sequence response
1
amplitude

0.5

0
0 0.5 1 1.5 2 2.5 3
time

Digital Signal Processing Lab Manual Page 32


Decimation of polyphase decomposition sequence response
15

10
amplitude

0
0 0.5 1 1.5 2 2.5 3 3.5 4
time

RESULT:
Thus a program for Convolution and m-fold decimation by poly phase decomposition is computed
using MATLAB.

Digital Signal Processing Lab Manual Page 33


Exp.No: 8 STUDY OF ADDRESSING MODES
Date:

AIM:
To study about direct, indirect and immediate addressing modes in TMS320C50 debugger.

APPARATUS REQUIRED:

1.System with TMS 320C50 debugger software


2.TMS 320C50 Kit.

ALGORITHM:
IMMEDIATE ADDRESSING MODE:

1. Initialize data pointer with 100H data.


2. Load the accumulator with first data.
3. Add the second data with accumulator content.
4. Store the accumulator content in specified address location.

DIRECT ADDRESSING MODE:

1. Initialize data pointer with 100H data.


2. Load the accumulator with first data, whose address is specified in the instruction.
3. Add the accumulator content with second data, whose address is specified in the instruction.
4. Store the accumulator content in specified address location.

IN-DIRECT ADDRESSING MODE:

1. Load the auxiliary register with address location of first data.


2. The auxiliary register (AR0) is modified indirectly as # symbol.
3. Load the second data into accumulator and perform addition operation.
4. Store the result.

Digital Signal Processing Lab Manual Page 34


Exp.No: 8 IMPLEMENTATION OF LINEAR AND CIRCULAR
Date: CONVOLUTION

AIM:
To write a program to find the Convolution of two sequences X(n) and H(n) using TMS320C50 debugger.

APPARATUS REQUIRED:

1.System with TMS 320C50 debugger software


2. TMS 320C50 Kit

LINEAR CONVOLUTION
ALGORITHM:
1. Start the program.
2. LPD will load the 9LSB’s of address data memory.Location or immediate value into the data pointer (DP)
register.
3. Load auxiliary register (LAR) loads the content of the address data memory location into the designated
auxilary register.
4. Then ZC clears the content of accumulator too.
5. MAR modify current AR and ARP as specified.
6. The RPT load the 8 bit LSBs of the addressed value of the RPT.
7. The SACL store the 16 LSBs of the accumulator into the addressed data memory.
8. MUL is used to multiply the content of T register.
9. The LTP would load the contents of the addressed data memory location into T register.
10. ADD will add the content of the memory.
11. LACC is used to load the content of the addressed data memory into accumulator.

Digital Signal Processing Lab Manual Page 35


PROGRAM:
.mmregs
.text
START:

LDP #02H
LAR AR1,#8100H ; x(n) datas
lar ar0,#08200H ;h(n) datas
LAR AR3,#8300H ;y(n) starting
LAR AR4,#0006 ;N1+N2-1;
to fold the h(n) values
************************
lar ar0,#8203H ; data mem 8200 to program mem c100(tblw)
lacc #0c100h ; Iniltialize Program Memory
mar *,ar0 ; Auxilary Register Pointer for AR0 Reg to the 8203 address
rpt #3 ; Repeat the Next instruction 3 times
tblw *- ; to move 8203- 8200 to c100- c103;
padding of zerros for x(n) values
;**********************************
lar ar6,#8104h ;padding N1 - 1 zeros for first input Sequence.8100 to 8103 for input datas.8104 to 8106
are padding zero datas.
mar *,ar6 ; AuxilaryReg Pointer for AR6 point to the 8104 address
lacc #0h ; Load ACC to Zero
rpt #2h ; Repeat the next instruction to 2 times
sacl *+ ; Load ACC value to data memory location(8104 to 8106) and inc the
dma ;convalution operation starts
;******************************
LOP: MAR *,AR1 ; Point to the first input seq data memory address location
LACC *+ ; load data memory value to ACC
SACL 050H ; Load ACC value to 150th Program memory location(LDP is 2, memory
location start from 100 to 17F)
LAR AR2,#0153H ; Load data to AR2 reg
MAR *,AR2 ; point to the program memory location
ZAP ; ACC = 0,Preg0 = 0
RPT #03H ;N1-1 times so that N1 times
MACD 0C100H,*- ;convolution Multiplication
APAC ;toaccmulate the final product sample
MAR *,AR3 ; Point to the output data memory Location
SACL *+ ; Store ACC value to data memory location and inc the data memory address
MAR *,AR4 ; Load data value to AR reg
BANZ LOP,*- ; Continue the loop operation when N = 0
H: B H ; Halt the Program

Digital Signal Processing Lab Manual Page 36


;INPUT ( x(n) )
;8100 - 1
;8101 - 2
;8102 - 3
;8103 - 4
;INPUT ( h(n) )
; 8200 - 5
; 8201 - 6
; 8202 - 7
; 8203 - 8
;OUTPUT ( y(n) )
; 8300 - 5H
; 8301 - 10H
; 8302 - 22H
; 8303 - 3CH
; 8304 - 3DH
; 8305 - 34H
; 8306 - 20H

CIRCULAR CONVOLUTION
ALGORITHM:
1. Start the Program.
2. Load the LSB’s of the address data memory location.
3. Load the contents of the address data memory location into auxiliaryregister.
4. Modify the current AR as specified.
5. Load the content of addressed data memory location.
6. Store the 16 LSBs of the accumulator into the address data memorylocation.
7. Load the content in ARL Z.0
8. Branch the contents of entire auxiliary register.
9. Load the content AR.1,AR.2,AR.0
10. Store the content of the accumulator’
11. Modify the current AR as specified.
12. Stop the program.

Digital Signal Processing Lab Manual Page 37


;----------------------------------------------------------------------------

; CIRCULAR CONVOLUTION (4*4 MATRIX)

;----------------------------------------------------------------------------
.mmregs
.text
START:
LDP #100H ; Data page
LAR AR2,#8200H ; X2(n)
LAR AR1,#8400H ; Re_arange X2(n)
LAR AR4,#8300H ; Output Memory
LAR AR3,#03H ; Count; Re_Arrange the Data of X2(n):

;------------------------------
MAR *,AR2; Modify aux Reg as data memory
LACC*,AR1 ; load data mem value acc& change Aux Reg
SACL *+,AR2 ; store acc data to data memory location
LAR AR2,#(8200h+3h) ; X2(N) End of location Rearranged input seq
LAR AR0,#2H ; load data to AR regRe_arange:
LACC *-,AR1 ;load (AR2 -> 8203) data memory value to acc & change Aux reg
SACL *+,AR0 ;store acc data to data memory location(AR1 -> 8401) BANZ
Re_arange,*-,AR2 ; Repeat the instruction when AR0 is reach zero\;Multiply &Accumulate:

;----------------------

Next_YN:
LAR AR1,#8100H ; Load data to aux regits for 1st i/p seq data
LAR AR2,#8400H ; Load data to aux regits for 2st i/p seq data
LAR AR0,#3H ;Load data to aux regits for output length
ZAC
SACL 0H ; load acc data to data mem location of 0H
MAR *,AR1 ; point to data memory location
LT *+,AR2 ; load data to TREG0 & change aux Reg
Loop_MAC:
MPY *+,AR1 ;multiply data(X2(n)) memory value to TREG0 value and store output to preg
LTP *+,AR0 ;load data memory value to treg0 and store preg value to acc
ADD 0H ; add data its for continues addition
SACL 0H ; store acc data to 0h location
BANZ Loop_MAC,*-,AR2 ; repeat the AR0 when reach zero
LACC 0H ; load 0h location value into acc
MAR *,AR4 ; modify aux reg for output data store
SACL *+ ;store acc data to output data memory location; Shift X2(n) Values:

;--------------------
LAR AR1,#(8400h+3h) ;load data value to arregits for rearrange the second i/p seq
LAR AR2,#2H ; load data to ar reg.
LAR AR0,#2H ; Index Value 2H
MAR *,AR1 ;modify AR reg value as data memory
LACC *- ;load data mem value to acc&dec
Digital Signal Processing Lab Manual Page 38
SACL 1H ; load acc data to 1H location

Shift_X2N:
LACC *+ ;load data memory value to acc
SACL *0-,AR2 ; dec the mem location & change arreg
BANZ Shift_X2N,*-,AR1 ; Repeat the loop
MAR *+ ;inc the arreg
LACC 1H ; load 1H data memvakue to acc
SACL *,AR3 ; store acc data to data mem location
BANZ Next_YN,*- ; Branch Loop
NOP
H: B H

;X1(n) = 8100 - 0002;


8101 – 0001;
8102 – 0002;
8103 - 0001;

;X2(n) = 8200 - 0001


; 8201 - 0002
; 8202 - 0003
; 8203 - 0004

;OUTPUT:

; 8300 - 000E

; 8301 - 0010

; 8302 - 000E

; 8303 - 0010

RESULT:

Digital Signal Processing Lab Manual Page 39


Exp.No: 9 SAMPLING OF SIGNALS
Date:

AIM:
To write a program to convert analog signals into digital signals using TMS320C50 debugger.

APPARATUS REQUIRED:
1. System with TMS 320C50 debugger software
2. TMS 320C50 Kit.
3. CR0
4. Function Generator

ALGORITHM:
1. Initialize data pointer with 100H data
2. give the analog signal as input
3. Introduce the time delay as per required.
4. Observe the discrete signal as output
5. Plot the graph.

PROGRAM:

.MMREGS
.TEXT
START:
LDP #0100H ; Load Data Page Pointer
NOP
ADC_Start:
IN 0,06H ; ADC Start of Conversion
NOP
NOP
NOP
IN 0,04H ; ADC Data Read
RPT #0FH ; Delay
NOP
LACC 0H
AND #0FFFH ; 12 Bit ADC
SACL 0H
OUT 0,04H ; DAC Data Write
B ADC_Start
NOP
NOP
.END

Digital Signal Processing Lab Manual Page 40


MODEL GRAPH:

RESULT:
Thus the analog signal was converted into digital signal using TMS320C50 debugger.

Digital Signal Processing Lab Manual Page 41


Exp.No: 10 WAVEFORM GENERATION
Date:

AIM:
To write a program to generate Triangle Wave,SineWave,Square Wave and SawTooth Wave
using TMS320C50 debugger.
APPARATUS REQUIRED:
1.System with TMS 320C50 debugger software
2.TMS 320C50 Kit.
3.CR0
4.Function Generator.
ALGORITHM:
TRIANGLE WAVE GENERATION:
1. Start the program.
2. Load the LSBs of the address data memory location.
3. Write full 16 bit pattern into address data memory location.
4. Load the content of address data memory location.
5. Add the content of address data memory location.
6. Store the data of accumulator into address data memory location.
7. Modify the current AR as specified.
8. Repeat the step 2,3.
9. Subtract the contents of address data memory location.
10. Repeat the steps 5,6,7.
11. Stop the program.

SINE WAVE GENERATION:


1. Start the program
2. Load the LSBs of the address data memory location
3. Write full 16 bit pattern into address data memory location.
4. Load the content of address data memory location.Specify the address of a subroutine.
5. Multiply the content of the register.
6. Load the content of the register into accumulator.
7. Store the 16 LSBs of the accumulator into the address data memory location.
8. Modify the current AR & ARP as specified.
9. Branch the contents of entire auxiliary register.
10. Load the content of address data memory location.
11. Repeat the Step.
12. Stop the program.

SQUARE WAVE GENERATION:


1. Start the program
2. Load the content of address data memory location.
3. Store the 16 LSBs of the accumulator into the address data memory location.
4. Load the content of address data memory location.
5. Complement the contents of the accumulator.
6. Stop the program.

Digital Signal Processing Lab Manual Page 42


SAWTOOTH WAVE GENERATION:
1. Start the program.
2. Load the LSBs of the address data memory location
3. Load the content of address data memory location into accumulator.
4. Store the 16 LSBs of the accumulator into the address data memory location
5. Write 16 bit value from from a data memory location to the specified I/O Port.
6. Add the content of address data memory location.
7. Subtract the content of the register.
8. Branch the program memory address if the specified conditions are met.
9. Stop the program.

PROGRAM FOR TRIANGLE:

AMPLITUDE .SET 4
FREQ .SET 350
TEMP .SET 0
;
.mmregs
.text
START:
LDP #100H
splk #0,TEMP
CONT1:
lar AR2,#FREQ
CONT:
out TEMP,4
LACC TEMP
ADD #AMPLITUDE
SACL TEMP
MAR *,AR2
BANZ CONT,*-
LAR AR2,#FREQ
CONTx:
OUT TEMP,4
LACC TEMP
SUB #AMPLITUDE
SACL TEMP
MAR *,AR2
BANZ CONTx
B CONT1
.end

PROGRAM FOR SQUARE WAVE:


.mmregs
.text
start:
ldp #100h
lacc #0fffh ;change this value for amplitude.
loop: sacl 0
Digital Signal Processing Lab Manual Page 43
rpt #0ffh ;change this value for frequency.
out 0,04 ;address for dac.
cmpl
b loop
.end

PROGRAM FOR SAWTOOTH WAVEFORM:


.MMREGS
.TEXT
START:
LDP #120H
LACC #0H ;change lower amplitude
SACL 0
LOOP: LACC 0
OUT 0,04H
ADD #05h ;change frequency
SACL 0
SUB #0FFFh ;change upper amplitude
BCND LOOP,LEQ
B START
.END

PROGRAM FOR SINE WAVE:


;Sine Wave Generation. With these default values sine generated is 100 Hz.
INCFREQ .set 10 ;minimum value 1 - change for increasing frequency
;every count will increase frequency in steps of 100hz
DECFREQ .set 0 ;minimu value 0 - change for decreasing frequency
;every count will decrease frequency by half
LENGTH .set 360
AMPLITUDE .set 5
delay .set 7 ;change to increase/decrease frequency in
;different steps;

TEMP .set 0
TEMP1 .set 1

.mmregs
.text
START:
LDP #100H
SPLK #TABLE,TEMP ;load start address of table
lar AR2,#( (LENGTH/INCFREQ)+(LENGTH*DECFREQ) )-1
lar ar3,#DECFREQ ;repeat counter for reducing frequency
CONT:
CALL DELAY
LACC TEMP ;load address of sine value
TBLR TEMP1 ;read sine data to TEMP1

LT TEMP1
MPY #AMPLITUDE
PAC
SACL TEMP1
Digital Signal Processing Lab Manual Page 44
mar *,ar3
banz repeat,*-
lar ar3,#DECFREQ ;repeat counter for reducing frequency
LACC TEMP
ADD #INCFREQ ;increase table value
repeat:
SACL TEMP ;store it
OUT TEMP1,4 ;send sine data to DAC
MAR *,AR2
BANZ CONT,*-
b START

DELAY:
lar ar7,#delay
mar *,ar7
back: banz back,*-
ret

;
TABLE
.word 100
.word 101
.word 103
.word 105
.word 106
.word 108
.word 110
.word 112
.word 113
.word 115
.word 117
.word 119
.word 120
.word 122
.word 124
.word 125
.word 127
.word 129
.word 130
.word 132
.word 134
.word 135
.word 137
.word 139
.word 140
.word 142
.word 143
.word 145
.word 146
.word 148
.word 150
Digital Signal Processing Lab Manual Page 45
.word 151
.word 152
.word 154
.word 155
.word 157
.word 158
.word 160
.word 161
.word 162
.word 164
.word 165
.word 166
.word 168
.word 169
.word 170
.word 171
.word 173
.word 174
.word 175
.word 176
.word 177
.word 178
.word 179
.word 180
.word 181
.word 182
.word 183
.word 184
.word 185
.word 186
.word 187
.word 188
.word 189
.word 189
.word 190
.word 191
.word 192
.word 192
.word 193
.word 193
.word 194
.word 195
.word 195
.word 196
.word 196
.word 197
.word 197
.word 197
.word 198
.word 198
.word 198
.word 199
Digital Signal Processing Lab Manual Page 46
.word 199
.word 199
.word 199
.word 199
.word 199
.word 199
.word 199
.word 200
.word 199
.word 199
.word 199
.word 199
.word 199
.word 199
.word 199
.word 199
.word 198
.word 198
.word 198
.word 197
.word 197
.word 197
.word 196
.word 196
.word 195
.word 195
.word 194
.word 193
.word 193
.word 192
.word 192
.word 191
.word 190
.word 189
.word 189
.word 188
.word 187
.word 186
.word 185
.word 184
.word 183
.word 182
.word 181
.word 180
.word 179
.word 178
.word 177
.word 176
.word 175
.word 174
.word 173
.word 171
Digital Signal Processing Lab Manual Page 47
.word 170
.word 169
.word 168
.word 166
.word 165
.word 164
.word 162
.word 161
.word 160
.word 158
.word 157
.word 155
.word 154
.word 152
.word 151
.word 149
.word 148
.word 146
.word 145
.word 143
.word 142
.word 140
.word 139
.word 137
.word 135
.word 134
.word 132
.word 130
.word 129
.word 127
.word 125
.word 124
.word 122
.word 120
.word 119
.word 117
.word 115
.word 113
.word 112
.word 110
.word 108
.word 106
.word 105
.word 103
.word 101
.word 99
.word 98
.word 96
.word 94
.word 93
.word 91
.word 89
Digital Signal Processing Lab Manual Page 48
.word 87
.word 86
.word 84
.word 82
.word 80
.word 79
.word 77
.word 75
.word 74
.word 72
.word 70
.word 69
.word 67
.word 65
.word 64
.word 62
.word 60
.word 59
.word 57
.word 56
.word 54
.word 53
.word 51
.word 49
.word 48
.word 47
.word 45
.word 44
.word 42
.word 41
.word 39
.word 38
.word 37
.word 35
.word 34
.word 33
.word 31
.word 30
.word 29
.word 28
.word 26
.word 25
.word 24
.word 23
.word 22
.word 21
.word 20
.word 19
.word 18
.word 17
.word 16
.word 15
Digital Signal Processing Lab Manual Page 49
.word 14
.word 13
.word 12
.word 11
.word 10
.word 10
.word 9
.word 8
.word 7
.word 7
.word 6
.word 6
.word 5
.word 4
.word 4
.word 3
.word 3
.word 2
.word 2
.word 2
.word 1
.word 1
.word 1
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 1
.word 1
.word 1
.word 2
.word 2
.word 2
.word 3
.word 3
.word 4
.word 4
.word 5
.word 6
Digital Signal Processing Lab Manual Page 50
.word 6
.word 7
.word 7
.word 8
.word 9
.word 10
.word 10
.word 11
.word 12
.word 13
.word 14
.word 15
.word 16
.word 17
.word 18
.word 19
.word 20
.word 21
.word 22
.word 23
.word 24
.word 25
.word 26
.word 28
.word 29
.word 30
.word 31
.word 33
.word 34
.word 35
.word 37
.word 38
.word 39
.word 41
.word 42
.word 44
.word 45
.word 47
.word 48
.word 50
.word 51
.word 53
.word 54
.word 56
.word 57
.word 59
.word 60
.word 62
.word 64
.word 65
.word 67
.word 69
Digital Signal Processing Lab Manual Page 51
.word 70
.word 72
.word 74
.word 75
.word 77
.word 79
.word 80
.word 82
.word 84
.word 86
.word 87
.word 89
.word 91
.word 93
.word 94
.word 96
.word 98
.word 100
.end

RESULT:

Digital Signal Processing Lab Manual Page 52


Exp.No: 11.a DESIGN OF FIR FILTER-LOW PASS FILTER
Date:

AIM:
To design a FIR low pass filter in serial mode.
APPARATUS REQUIRED:
1.System with VI debugger software
2.TMS 320C50 Kit.
3.CR0
ALGORITHM:
1. Start the program.
2. Initialize the C table value.
3. Load the auxillary register with 0200H.
4. Modify the auxillary register zero.
5. Block the C table to the program.
6. Set configuration control bit.
7. Load the data pointer with 0AH.
8. Initialize the analog to digital conversion.
9. Load the auxillary register 1 with 0300 content.
10. Load the accumulator in 8000H.
11. AND the accumulator with 0FFFH.
12. Subtract the accumulator content with data 800H.
13. Modify the auxillary register 1.
14. Store the accumulator data in 8000H.
15. Load the auxillary register 1 with content 0333H.
16. Zero the accumulator register.
17. Multiply the accumulator with data.
18. Load the program register, with PM bits to accumulator.
19. Load the auxillary register 1 with content 0300H.
20. Add accumulator content with 800H.
21. Shift the accumulator right 1 bit.
22. Store the accumulator content in 8200 location.
23. Branch the program to step 7.

Digital Signal Processing Lab Manual Page 53


* Approximation type: Window design - Blackmann Window
* Filter type: Lowpass filter
* Filter Order: 52

* Cutoff frequency in KHz = 3.000000


.mmregs
.text
B START
CTABLE:
.word 0FFE7H ;Filter coefficients n=0
.word 0FFD3H
.word 0FFC6H
.word 0FFC4H
.word 0FFD0H
.word 0FFECH
.word 018H
.word 051H
.word 08CH
.word 0B9H
.word 0C2H
.word 092H
.word 01AH
.word 0FF5FH
.word 0FE78H
.word 0FD9AH
.word 0FD10H
.word 0FD30H
.word 0FE42H
.word 071H
.word 03B5H
.word 07CAH
.word 0C34H
.word 01054H
.word 01387H
.word 01547H
.word 01547H
.word 01387H
.word 01054H
.word 0C34H
.word 07CAH
.word 03B5H
.word 071H
.word 0FE42H
.word 0FD30H
.word 0FD10H
.word 0FD9AH
.word 0FE78H
.word 0FF5FH
.word 01AH
.word 092H
.word 0C2H
.word 0B9H
.word 08CH
.word 051H
.word 018H
.word 0FFECH
.word 0FFD0H
.word 0FFC4H
.word 0FFC6H
.word 0FFD3H
.word 0FFE7H ;Filter coefficients n=52

Digital Signal Processing Lab Manual Page 54


*
* Move the Filter coefficients
* from program memory to data memory
*
START:
LAR AR0,#0200H ;move DATA to auxilary register

MAR *,AR0 ; denotes auxilary register as address


RPT #33H ; Repeat the next instruction for 33h times
BLKP CTABLE,*+ ; Load Program Memory Data to data Memory(200h)
SETC CNF ; Configure BLOCK B0 as Program Memory
*
* Input data and perform convolution
*
ISR: LDP #0AH ; load data pointer
LACC #0H

SACL 0H

IN 0,06H ;soc

IN 0,4 ;adc read. store in dma.i/p data will


store in dma oh

NOP ;delay
NOP ;delay
LAR AR1,#0300H ;move 300h to auxilary register

MAR *,AR1 ;denotes auxilary register 1 as address


LACC 0H ;loaddma value to acc
AND #0FFFH ;andacc value with fffh
SUB #800H ;sub acc value with 800h (2's complement)
SACL * ;move acc value to AR1
LAR AR1,#333H ;move 333h to auxilary register 1
MPY #0 ;multiply 0 with treg
ZAC ; load data memory value to acc
RPT #33H ; Repeat the next instruction for 33h times
MACD 0FF00H,*- ;CONVOLUTION OPERATION
APAC ;movepreg to acc
LAR AR1,#0300H ; move 300h to auxilary register 1
SACH * ;move acc value to 333h location (MSB)
LACC * ; load 333h value to acc
ADD #800h ;ADD 800h with acc
SACL * ;move acc value to AR1 location
OUT *,4 ;dac output
NOP ;delay
B ISR ;endless loop
.end

Digital Signal Processing Lab Manual Page 55


TABULATION:

S.No. Frequency(Hz) Vout(v) Vout/Vin Gain in db=


20log Vout/Vin

RESULT:

Thus the program for designing a FIR low pass filter in serial mode was
Performed

Digital Signal Processing Lab Manual Page 56


Exp.No: 11.b DESIGN OF FIR FILTER- HIGH PASS FILTER
Date:

AIM:
To design a FIR high pass filter in serial mode.
APPARATUS REQUIRED:
1.System with VI debugger software
2.TMS 320C50 Kit.
3.CR0
ALGORITHM:
1. Start the program.
2. Initialize the C table value.
3. Load the auxillary register with 0200H.
4. Modify the auxillary register zero.
5. Block the C table to the program.
6. Set configuration control bit.
7. Load the data pointer with 0AH.
8. Initialize the analog to digital conversion.
9. Load the auxillary register 1 with 0300 content.
10. Load the accumulator in 8000H.
11. AND the accumulator with 0FFFH.
12. Subtract the accumulator content with data 800H.
13. Modify the auxillary register 1.
14. Store the accumulator data in 8000H.
15. Load the auxillary register 1 with content 0333H.
16. Zero the accumulator register.
17. Multiply the accumulator with data.
18. Load the program register, with PM bits to accumulator.
19. Load the auxillary register 1 with content 0300H.
20. Add accumulator content with 800H.
21. Shift the accumulator right 1 bit.
22. Store the accumulator content in 8200 location.
23. Branch the program to step 7.

Digital Signal Processing Lab Manual Page 57


PROGRAM:
Approximation type: Window design - Blackmann Window

* Filter type: highpass filter

* Filter Order: 52
* Cutoff frequency in KHz = 3.000000

.mmregs
.text
B START
CTABLE:
.word 0FCD3H
.word 05H
.word 0FCB9H
.word 087H
.word 0FD3FH
.word 01ADH
.word 0FE3DH
.word 0333H
.word 0FF52H
.word 04ABH
.word 0FFF8H
.word 0595H
.word 0FFACH
.word 0590H
.word 0FE11H
.word 047CH
.word 0FB0BH
.word 029DH
.word 0F6BAH
.word 0AEH
.word 0F147H
.word 01CH
.word 0E9FDH
.word 04C5H
.word 0D882H
.word 044BCH
.word 044BCH
.word 0D882H
.word 04C5H
.word 0E9FDH
.word 01CH
.word 0F147H
.word 0AEH
.word 0F6BAH
.word 029DH
.word 0FB0BH
.word 047CH
.word 0FE11H
.word 0590H
.word 0FFACH
.word 0595H
.word 0FFF8H
.word 04ABH
.word 0FF52H
.word 0333H
.word 0FE3DH
.word 01ADH
.word 0FD3FH
.word 087H

Digital Signal Processing Lab Manual Page 58


.word 0FCB9H
.word 05H
.word 0FCD3H
;--------------------------------------------------------------------------------------------
----
* Move the Filter coefficients
* from program memory to data memory
*--------------------------------------------------------------------------------------------
-----
START:
LAR AR0,#0200H ;move 200h to auxilary register
MAR *,AR0 ;denotes auxilary register as address
RPT #33H ; Repeat the next instruction for 33h times
BLKP CTABLE,*+ ; Load Program Memory Data to data Memory(200h)
SETC CNF ;Configure BLOCK B0 as Program Memory
*--------------------------------------------------------------------------------------------
---------------------------
* Input data and perform convolution
*--------------------------------------------------------------------------------------------
---------------------------
ISR: LDP #0AH ;load data pointer
LACC #0 ;set acc to zero
SACL 0 ; load dma 0h to zero
IN 0,06H ;soc
NOP ;delay
IN 0,4 ;adc input. i/p data will store in dma oh
NOP ;delay
NOP ;delay
NOP ;delay
NOP ;delay
LAR AR1,#0300H ;move 300h to auxilary register
MAR *,AR1 ;denotes auxilary register 1 as address
LACC 0H ;loaddma value to acc
AND #0FFFH ;addfffh with acc value .
SUB #800H ;sub 800h with acc value (2's complement)
SACL * ;load acc value to the address 300h
LAR AR1,#333H ;move 333h to auxilary register 1
MPY #0 ; multiply 0 with treg
ZAC ;CLEAR ACC
RPT #33H ;Repeat the next instruction for 33h times
MACD 0FF00H,*- ; CONVOLUTION OPERATION
APAC ; move preg to acc
LAR AR1,#0300H ; move 300h to auxilary register
SACH * ;LOADaccmsb DATA to data memory location
LACC * ;move AR1 value to acc
ADD #800H ;add 800h with acc value
SACL * ; load acc data with dma AR1
OUT *,4 ;dac out
NOP ;delay
B ISR ;endless loop
.end

Digital Signal Processing Lab Manual Page 59


TABULATION:

S.No. Frequency(Hz) Vout(v) Vout/Vin Gain in db=


20log Vout/Vin

RESULT:
Thus the program for designing a FIR high pass filter in serial mode was performed.

Digital Signal Processing Lab Manual Page 60

You might also like