You are on page 1of 156

DIGITAL SIGNAL PROCESSING

LABORATORY MANUAL


Prescribed for

B.Tech Applied Electronics and Instrumentation Engineering
SEVENTH SEMESTER


Prepared by

ANEESH V
Assistant Professor
Department of Applied Electronics and Instrumentation Engineering
MZCE, Kadammanitta








MOUNT ZION COLLEGE OF ENGINEERING KADAMMANITTA

CONTENTS
Introduction
Syllabus
MATLAB programming
1. Familiarization of MATLAB
2. Generation of basic signals.
3. Generation of periodic signals.
4. Generation of complex signals.
5. Discrete Fourier Transform (DFT) and its inverse (IDFT)
6. Spectrum analysis
7. Spectrum folding and unfolding
8. Linear convolution.
9. Circular convolution.
10. Linear convolution of long duration sequence.
11. IIR filter design
a. Butterworth filters
b. Chebyshev type-I IIR filters.
c. Chebyshev type-II IIR filters.
d. Elliptical IIR filters.
12. FIR filter design
a. FIR filter design using windowing method.
b. Equiripple FIR filters.
c. FIR filter design using frequency sampling method
13. Random sequence generation.
14. Sampling rate conversion by a rational factor
15. Z transform
Assembly language programming
16. Familiarization of DSP kit
17. Generation of basic signals.
18. Generation of periodic signals.
19. Generation of complex signals.
20. Discrete Fourier Transform (DFT) and its inverse (IDFT).
21. Linear convolution.
22. Circular convolution.
23. Real time Implementation of IIR filters.
24. Real timeImplementation of FIR filters.
25. Real Time Implementation of sine wave
Viva-voce Questions
Previous YearsUniversity Exam Questions
Expected Model Questions






















INTRODUCTION

Digital Signal Processing (DSP) is a key research area in the domain of Electronic and
Communication. It provides a basis for various application fields like Speech processing,
Video Processing, Compression techniques etc. MATLAB is a high-performance language for
technical computing, integrating computation, visualization, and programming in an easy-to-
use environment where problems and solutions are expressed in familiar mathematical notation.
It can be used in the simulation of various DSP algorithms. The DSP lab helps to give hands-
on-experience in the use of software and hardware for DSP applications.

The Kerala University has included this lab in the fifth semester of its Bachelor of
Technology (B.Tech) Degree in Electronics and Communication (ECE) coursework. It is of 4
credits and consists of 4 hours laboratory work each week. The students are familiar with the
key concepts in the current semester and the lab helps them to get a broader picture and a real-
time experience in DSP.

The lab has two parts
Programming in MATLAB
Programming in Digital Signal Processors

The first part can be done using the MATLAB software installed in a PC. The second
part, using Digital Signal Processors, can be done in C language or Assembly language
programming. This requires TMS 320 processors or any other suitable DSP processors. These
are available as DSP kits in the market for educational purposes which includes Code
Composer Studio (CCS) for simulation and emulation and starter kits/processors kits for code
downloading and running.









MATLAB PROGRAMMING
Experiment N0.1

FAMILIARIZATION WITH MATLAB

Aim:
To familiarize with Matlab commands and built in functions.

The name MATLAB stands for MATrix LABoratory produced and provided by
Mathworks Inc.,U.S.A. It is a matrix based powerful software package for scientific and
engineering numerical computations and visualization. Complex numerical problems can be
solved in a fraction of time than required with other high level languages. It provides an
interactive environment with hundreds of built in functions for technical computations,
graphics and animation. The user can create his own functions also.

Matlab offers several optional tool boxes such as signal processing, control systems,
neural networks etc. It is a command driven software and has online help facility.

Matlab has three basic windows namely command window, graphics window and edit
window. Command window is characterized by the prompt >>. All commands and ready to
run program file names can be typed here. Graphic window gives the display of the figures as
the result of the program.Edit window is to create program files with an extension .m.

Some of the important commands in Matlab:
Help: Lists topics on which Help is available
Helpcommand name: Provides help on the topic selected.
Demo: Runs the Demo program
Who: Lists variables currently in the workspace
Whos: Lists variables currently in the workspace with their size
Clear:Clears the workspace and variables are removed
Clear x,y,z: Clears only variables x,y and z
Quit: QuitsMatlab


Some of the frequently used Built-in functions in Signal Processing Tool Box:

filter(b,a,x)=Y:It filters the data in vector x with the filter described by vectors a and b
to create the filtered data y.
fft(x):It is the DFT of vector x.
ifft(x): It is the IDFT of vector x.
conv(a,b):It convolves vectors a and b,the resulting vector is length(a)+length(b)-1
deconv(b,a):It deconvolves vector a out of vector b.
abs(x): It gives the absolute value of the elements of x.
angle(h):It returns the phase angles of a matrix with complex elements in radians.
stem(x,y):It plots the data sequence y at the values specified in x.
plot(x,y):It plots vector y versus vector x.
title(text):It adds text at the top of the current axis.
xlabel(text):It adds text beside the x-axis on the current axis.
ylabel(text):It adds text beside the y-axis on the current axis.












Experiment No. 2

GENERATION OF BASIC SIGNALS

Aim:
To generate the following waveforms
Impulse
Unit step
Rectangular
Random

Theory:

A signal can be used to represent any variable of interest as a function of time,
temperature, pressure etc. Signals carry some amount of information in them. One of the
methods to classify signals is on the basis of their time characteristics as
Continuous -time signals: The function is defined continuously in time.
Discrete time signals: they are defined in discrete time instants only.
Both of these signals can have any amplitude(continuous in amplitude).Digital signals have
discrete amplitude levels.A continuous time signal is called periodic if
+ = ()
Here T is called the period of the signal.The signals which do not satisfy the above conditions
are called aperiodic or non-periodic signals.An important classification of aperiodic signals is
the singularity functions. They can be used to represent more complicated signals. Delta, step,
ramp, etc are examples of such functions.

Important Basic Signals
1. I mpulse Function
In discrete domain it is defined as
=
1, = 0
0, 0

2. Step Function
The discrete-time unit step function is defined as
=
1, 0
0, < 0

3. Ramp signal
The ramp signal can be generated from the mathematical expression
= , 0
4. Exponential signal
The exponential signal can be generated from the mathematical expression
=

, 0
0, < 0

;

In MATLAB, these functions can be generated and be displayed using stem function
Algorithm:

Generation of Impulse Waveform
Step 1: reset the registers and files
Step2: enter the range and instant at which the impulse occur
Step3: generate the impulse
Step4:display the figure with suitable labels

Generation of Step function
Step 1: reset the registers and files
Step 2: enter the instant at which the step occurs
Step 3: generate the step appropriately
Step4:display the figure with suitable labels

Generation of Ramp waveform
Step 1: reset the registers and files
Step 2: enter the range and the time of occurrence of the rectangular pulse
Step 3: generate the pulse appropriately
Step4:display the figure with suitable labels

Generation of Exponential Waveform
Step 1: reset the registers and files
Step 2: enter the range
Step3: generate the appropriate signal using rand function in MATLAB
Step4:display the figure with suitable labels
Program:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Generation of somebasicwaveforms
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clc;
clear all;
close all;
n0=input('Enter the value at which impulse occurs or step starts: ');
n1=input('Enter the value of lower limit: ');
n2=input('Enter the value of upper limit: ');
n3=input('Enter the length of ramp: ');
a=input('Enter the magnitude of the step or exponential function: ');
b=input('Enter the scaling factor of exponential function: ');
n=[n1:n2];

% Impulse signal
x=[(n-n0)==0];
subplot(221)
stem(n,x);
title(['IMPULSE SIGNAL AT TIME INSTANT ',int2str(n0)]);
xlabel('time');
ylabel('amplitude');

% Step signal
x=a*[(n-n0)>= 0];
subplot(222)
stem(n,x);
title(['STEP SIGNAL STARTING AT ',int2str(n0)]);
xlabel('time');
ylabel('amplitude');
axis([n1,n2,-a-5,a+5]);

% Ramp signal
t=0:1:n3;
subplot(223)
stem(t);
title('RAMP SIGNAL');
xlabel('time');
ylabel('amplitude');

% Exponential signal
t1=0:.1:1;
y1=a*exp(b*t1);
subplot(224)
stem(t1,y1);
title('EXPONENTIAL SIGNAL');
xlabel('time');
ylabel('amplitude');

Output:

Enter the value at which impulse occurs or step starts: 5
Enter the value of lower limit: -2
Enter the value of upper limit: 10
Enter the length of ramp: 10
Enter the magnitude of the step or exponential function: 2
Enter the scaling factor of exponential function: 2


Graph:














-5 0 5 10
0
0.5
1
IMPULSE SIGNAL AT TIME INSTANT 5
time
a
m
p
l
i
t
u
d
e
0 5 10
-5
0
5
STEP SIGNAL STARTING AT 5
time
a
m
p
l
i
t
u
d
e
0 5 10 15
0
5
10
RAMP SIGNAL
time
a
m
p
l
i
t
u
d
e
0 0.5 1
0
5
10
15
EXPONENTIAL SIGNAL
time
a
m
p
l
i
t
u
d
e
Experiment No. 3
GENERATION OF PERIODIC WAVEFORMS

Aim:
To generate the following periodic waveforms
Sinusoidal
Square
Triangular
Ramp

Theory:

A signal may be periodic or non-periodic. A continuous time signal is called periodic if
+ = ()
Here T is called the period of the signal.
For a discrete time signal,
+ = ()
Here N is called the sampling period.
The general expression for a continuous-time sinusoid is = ( +) where
A is the amplitude, is the frequency in radians/second and is the phase angle in radians.
This signal is always periodic and the period of this signal is defined by =
2

.The square
wave is also periodic and its duty cycle is 50% i.e., it has equal ON and OFF time in one
period.It can be generated by adding the odd harmonics of a sinusoidal signal.
A triangular wave is periodic and in one period it is defined by
=
1 ; || 1
0;


.
It has even symmetry. A ramp pulsedoes not have any symmetry.They can have rising slope or
falling slope depending on the definition.



Algorithm:
Generation of Sinusoidal signals
Step 1: reset the registers and files
Step 2: enter the frequency
Step 3: plot the signal using functions available in MATLAB
Step 4: display the figure with suitable labels

Generation of Square waveform
Step 1: reset the registers and files
Step 2: generate an appropriate square wave using function available in MATLAB
Step 3: display the figure with suitable labels
OR
Step 1: reset the registers and files
Step 2: generate a square pulse and repeat it using function available in MATLAB
Step 3: display the figure with suitable labels
OR
Step 1: reset the registers and files
Step 2: enter the frequency of sinusoidal
Step 3: enter the number of harmonics to be added
Step 4: generate the signal and add all the harmonics to the signal.
Step 5: display the figure with suitable labels

Generation of Triangular waveform
Step 1: reset the registers and files
Step 2: generate a triangular pulse using appropriate logic and repeat it using function
available in MATLAB
Step 3: display the figure with suitable labels

Generation of Ramp Waveform
Step 1: reset the registers and files
Step 2: generate a ramp pulse using appropriate logic
Step 3: display the figure with suitable labels



Program:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Generation of some periodicsignals
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc;
clear all;
close all;
f=input('Enter the frequency: ');
N=input('Enter the no: of cycles: ');
a=input('Enter the amplitude: ')
T=1/f;
t=0:.001:N*T;

% Sine wave
x1=a*sin(2*pi*f*t);
subplot(221)
plot(t,x1);
title('SINE WAVE');
xlabel('time');
ylabel('amplitude');
axis([0 N*T -a-0.5 a+0.5]);

% Square wave
x2=a*square(2*pi*f*t);
subplot(222)
plot(t,x2);
title('SQUARE WAVE');
xlabel('time');
ylabel('amplitude');
axis([0 N*T -a-0.5 a+0.5]);

% Triangular wave
x3=a*sawtooth(2*pi*f*t,0.5);
subplot(223)
plot(t,x3);
title('TRIANGULAR WAVE');
xlabel('time');
ylabel('amplitude');
axis([0 N*T -a-0.5 a+0.5]);

% Sawtooth wave
x4=a*sawtooth(2*pi*f*t,0.3);
subplot(224)
plot(t,x4);
title('SAWTOOTH WAVE');
xlabel('time');
ylabel('amplitude');
axis([0 N*T -a-0.5 a+0.5]);

Output:
Enter the frequency: 2
Enter the no: of cycles: 5
Enter the amplitude: 3





Graph:
0 0.5 1 1.5 2 2.5
-2
0
2
SINE WAVE
time
a
m
p
l
i
t
u
d
e
0 0.5 1 1.5 2 2.5
-2
0
2
SQUARE WAVE
time
a
m
p
l
i
t
u
d
e
0 0.5 1 1.5 2 2.5
-2
0
2
TRIANGULAR WAVE
time
a
m
p
l
i
t
u
d
e
0 0.5 1 1.5 2 2.5
-2
0
2
SAWTOOTH WAVE
time
a
m
p
l
i
t
u
d
e
Experiment No.4

GENERATION OF COMPLEX WAVEFORMS

Aim:

To generate the following waveforms
Amplitude Modulation
Frequency Modulation
Pulse Width Modulator

Theory:

In modulation a high frequency carrier signal is used to carry the message signal, also
known as the modulating signal. Amplitude Modulation and frequency modulation are two
important analog modulation systems. Amplitude modulation is the process of changing the
amplitude of the carrier wave in accordance with the amplitude of the modulating signal.
If the modulating signal is

sin


And carrier wave is

sin


Then the AM wave is defined as

(1 +sin

) sin


Where, m
a
is the modulation index whose value is between 0 and 1.
Frequency modulation is the process by which the frequency of the carrier wave is altered in
accordance with the instantaneous amplitude of the modulating signal.
The FM wave is defined as

sin(

sin

)
where,

is the modulation index of FM,

is the frequency
deviation given by

.
Pulse Width Modulation (PWM) is also known as pulse duration modulation or pulse
length modulation. The message signal controls the variation of the pulse width. The message
signal may vary the trailing or leading edge of the carrier pulses in order to accommodate the
information.
The inbuilt function for implementing various types of modulation techniques is
modulate( ). demod( ) function is used for implementing demodulation. ammod( ) and fmmod( )
are the functions for implementing amplitude modulation and frequency modulation
respectively. Various other functions used for implementing other types of modulation
techniques are pmmod( ), ssbmod( ), fskmod( ), pskmod( ), etc.

Algorithm:

Generation of AM
Step 1: reset the registers and files
Step 2: enter the amplitude and frequency of the message signal and carrier signal
Step 3: generate the message and carrier signal
Step 4: generate the amplitude modulated waveform using the equation
Step 5: display the figure with suitable labels

Generation of FM
Step 1: reset the registers and files
Step 2: enter the amplitude and frequency of the message signal and carrier signal
Step 3: generate the message and carrier signal
Step 4: generate the frequency modulated waveform using the equation
Step 5: display the figure with suitable labels

Generation of PWM
Step 1: reset the registers and files
Step 2: generate a triangular waveform as carrier
Step 3: generate a sinusoidal message signal
Step 4: generate PWM waveform by comparing the two signals
Step 5: display the figure with suitable labels
OR
Step 1: reset the registers and files
Step 2: enter the sampling frequency and frequency of the carrier signal
Step 3: generate the message signal
Step 4: use modulate function in MATLAB to generate the PWM waveform
Step 5: display the figure with suitable labels



Program:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Generation of AM, FM and PWM
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc;
clear all;
close all;
Vm=input('Enter the amplitude of the modulating signal: ');
fm=input('Enter the frequency of modulating signal: ');
Vc=input('Enter the amplitude of the carrier signal: ');
fc=input('Enter the frequency of the carrier signal: ');
t=0:0.0001:1;
Xm=Vm*sin(2*pi*fm*t);%modulating signal
Xc=Vc*sin(2*pi*fc*t);%carrier signal

% Amplitude Modulation
m=Vm/Vc;
xAM=Vc*(1+ m*sin(2*pi*fm*t)).*sin(2*pi*fc*t); % AM signal

% Frequency Modulation
k=((fc-fm)/fm);
xFM=Vc*cos(2*pi*fc*t +(k*sin(2*pi*fm*t))); % FM signal

% Pulse Width Modulation
for i=1:length(t)
if Xm(i)<Xc(i)
xPWM(i)=0;
else
xPWM(i)=1;
end
end
subplot(211)
plot(t,Xm)
title('MODULATING SIGNAL')
xlabel('time')
ylabel('amplitude')
subplot(212)
plot(t,Xc)
title('CARRIER SIGNAL')
xlabel('time')
ylabel('amplitude')
figure
subplot(311)
plot(t,xAM)
title('AMPLITUDE MODULATED SIGNAL')
xlabel('time')
ylabel('amplitude')
subplot(312)
plot(t,xFM)
title('FREQUENCY MODULATED SIGNAL')
xlabel('time')
ylabel('amplitude')
subplot(313)
plot(t,xPWM)
axis([0 1 -0.5 1.5])
title('PULSE WIDTH MODULATED SIGNAL')
xlabel('time')
ylabel('amplitude')


Output:
Enter the amplitude of the modulating signal: 3
Enter the frequency of modulating signal: 5
Enter the amplitude of the carrier signal: 5
Enter the frequency of the carrier signal: 50

Graph:

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-4
-2
0
2
4
MODULATING SIGNAL
time
a
m
p
l
i
t
u
d
e
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-5
0
5
CARRIER SIGNAL
time
a
m
p
l
i
t
u
d
e

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%PWM Waveform Using Built-in Function
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc;
clear all;
close all;
t=linspace(0,1,20);
t1=linspace(0,1,200);
fc=input('enter carrier frequency : ');
fs=input('enter sampling frequency : ');
x=(((sin(2*pi*fc*t))/2)+.5);
y=modulate(x,fc,fs,'pwm','centered');
subplot(2,1,1);
plot(t,x);
axis([0 1 -1 2])
title('input waveform','fontweight','bold')
xlabel('sample points')
ylabel('amplitude')
subplot(2,1,2);
plot(t1,y);
axis([0 1 -1 2])
title('PWM Waveform','fontweight','bold')
xlabel('sample points')
ylabel('amplitude')

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-10
0
10
AMPLITUDE MODULATED SIGNAL
time
a
m
p
l
i
t
u
d
e
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-5
0
5
FREQUENCY MODULATED SIGNAL
time
a
m
p
l
i
t
u
d
e
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-0.5
0
0.5
1
1.5
PULSE WIDTH MODULATED SIGNAL
time
a
m
p
l
i
t
u
d
e
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%the sampling frequency should be twice
%the maximum frequency.
%the number of points should be limited
%depending on the value of fc and fs.
%when fc=1 and fs=10, t=50, t1=100
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Output:
enter carrier frequency : 1
enter sampling frequency : 10

Graph:










0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-1
0
1
2
input waveform
sample points
a
m
p
l
i
t
u
d
e
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-1
0
1
2
PWM Waveform
sample points
a
m
p
l
i
t
u
d
e
Experiment No.6

DISCRETE FOURIER TRANSFORM (DFT)AND ITS INVERSE (IDFT

Aim:
To write a matlab program for finding the magnitude and phase spectrum of a 4-point
Fast Fourier transform of a given sequence and also find its inverse Fourier transform.

Thoery:
The direct evaluation of DFT using the formula
= ()
2/
1
=0

requires N
2
complex multiplications and N(N-1) complex additions .Thus for reasonably large
values of N direct evaluation of DFT requires an inordinate amount of computation. By using
FFT algorithms the number of computations can be reduced. For an N point DFT, the number
of complex multiplications required using FFT is N/2 log N.
The inverse DFT (IDFT) is given by
=
1

()
2 /
1
=0

Using DFT we can analyze the frequency components present in a signal. Inbuilt functions for
implementing dft and idft are fft( ) and ifft( ) respectively.

Algorithm:

Generation of DFT
Step 1: reset the registers and files
Step 2: enter the sequence and the value of N
Step 3: Implement the equation of DFT
Step 4: display the figure with suitable labels

Generation of IDFT
Step 1: reset the registers and files
Step 2: enter the DFT of the sequence and the value of N
Step 3: Implement the equation of IDFT
Step 4: display the figure with suitable labels
Program:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DFT using the inbuilt function fft()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear all
close all
x=input('Enter the input sequence: ');
y=fft(x);
r=ifft(y);

% Input sequence
subplot(221);
stem(x);
title('input sequence');
xlabel('time');
ylabel('amplitude');

% Magnitude and phase plot of DFT
subplot(222);
stem(y);
title('magnitude plot');
xlabel('time');
ylabel('amplitude');

subplot(223);
stem(angle(y));
title('phase plot');
xlabel('time');
ylabel('Amplitude');

% IDFT
subplot(224);
stem(r);
title('inverse fft');
xlabel('time');
ylabel('Amplitude');


Output:
Enter the input sequence: [1 2 3 0]









Graph:


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DFT without using the inbuilt function fft()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear all
close all
x=input('Enter the input sequence: ');
N=length(x);
for k=1:N
for n=1:N
e(k,n)=exp(-i*2*pi*(k-1)*(n-1)/N);
f(k,n)=exp(i*2*pi*(k-1)*(n-1)/N);
end
end
xk=e*x';
y=f*xk;

% Input sequence
subplot(221);
stem(x);
title('input sequence');
1 2 3 4
0
1
2
3
input sequence
time
a
m
p
l
i
t
u
d
e
1 2 3 4
0
2
4
6
magnitude plot
time
a
m
p
l
i
t
u
d
e
1 2 3 4
-4
-2
0
2
4
phase plot
time
A
m
p
l
i
t
u
d
e
1 2 3 4
0
5
10
15
inverse fft
time
A
m
p
l
i
t
u
d
e
xlabel('time');
ylabel('amplitude');

% Magnitude and phase plot of DFT
subplot(222);
stem(abs(xk));
title('magnitude plot');
xlabel('time');
ylabel('amplitude');

subplot(223);
title('phase plot');
stem(angle(xk));
xlabel('time');
ylabel('Amplitude');

% IDFT
subplot(224);
title('inverse fft');
stem(abs(y));
xlabel('time');
ylabel('Amplitude');

Output:
Enter the input sequence: [1 2 3 0]

Graph:


1 2 3 4
0
1
2
3
input sequence
time
a
m
p
l
i
t
u
d
e
1 2 3 4
0
2
4
6
magnitude plot
time
a
m
p
l
i
t
u
d
e
1 2 3 4
-4
-2
0
2
4
phase plot
time
A
m
p
l
i
t
u
d
e
1 2 3 4
0
5
10
15
inverse fft
time
A
m
p
l
i
t
u
d
e
Experiment No.6

SPECTRUM ANALYSIS

Aim:
To write matlab program for analyzing the spectrum of a signal

Theory:
A signal can be transformed from time domain to frequency domain using the fourier
transform. Thus we can obtain the spectrum. It will give the frequency components present in a
signal.If we know the sampling frequency

, then the frequency of the k


th
frequency
component of N-point DFT of a signal is given by

; = 0, 1, , 1
The right-most end of the horizontal axis of the spectrum represents the sampling
frequency; the center of each horizontal axis represents one-half the sampling frequency, or the
Nyquist folding frequency. Thus, the frequency represented by the center of the horizontal
axis represents the frequency specified by a value of f
s
/2. The peaks to the right of the folding
frequency are mirror images of the peaks to the left of the folding frequency.
In matlab, special functions like periodogram and spectrum.welch can be used for
finding the spectrum.

Algorithm:

Generation of Spectrum
Step 1: reset the registers and files
Step 2: enter the signals whose spectrum are to be calculated and the value of N
Step 3: take the DFT of the signals
Step 4: set the frequency axis using its equation
Step 5: display the figure with suitable labels

Program:
%%%%%%%%%%%%%%%%%%%
% Spectrum analysis
%%%%%%%%%%%%%%%%%%%
clc
clear all
close all
f1=input('Enter the frequency of the first sine wave: ');
f2=input('Enter the frequency of the second sine wave: ');
fs=input('Enter the sampling frequency: ');
N=input('Enter the value of N for performing DFT: ');
t=0:.001:1;
x1=sin(2*pi*f1*t);
x2=sin(2*pi*f2*t);
x3=rand(1,length(t));

y1=x1+x2; % sum of 2 sine waves.
z1=fft(y1,N);
p1=z1.*conj(z1);

y2=x1+x2+x3; % sum of 2 sine waves with noise
z2=fft(y2,N);
p2=z2.*conj(z2);

if N/2 ==0
f=(0: N/2 -1)*fs/N;
else
f=(0:(N-1)/2)*fs/N;
end

subplot(221)
plot(f,abs(z1(1:N/2)));
title('FREQUENCY SPECTRUM OF SUM OF 2 SINE WAVES');
xlabel('frequency');
ylabel('gain');
subplot(222)
plot(f,abs(z2(1:N/2)));
title('FREQUENCY SPECTRUM OF SUM OF 2 SINE WAVES WITH NOISE');
xlabel('frequency');
ylabel('gain');
subplot(223)
plot(f,abs(p1(1:N/2)));
title('POWER SPECTRUM OF SUM OF 2 SINE WAVES');
xlabel('frequency');
ylabel('gain');
subplot(224)
plot(f,abs(p2(1:N/2)));
title('POWER SPECTRUM OF SUM OF 2 SINE WAVES WITH NOISE');
xlabel('frequency');
ylabel('gain');

figure
Hs=spectrum.welch;
psd(Hs,y1,'fs',fs)

figure
periodogram(y1,[],'onesided',N,fs)

Output:
Enter the frequency of the first sine wave: 100
Enter the frequency of the second sine wave: 200
Enter the sampling frequency: 1000
Enter the value of N for performing DFT: 512

Graph:

0 200 400 600
0
100
200
300
FREQUENCY SPECTRUM OF "y1"
frequency
g
a
i
n
0 200 400 600
0
100
200
300
FREQUENCY SPECTRUM OF SUM OF "y2"
frequency
g
a
i
n
0 200 400 600
0
2
4
6
x 10
4
POWER SPECTRUM OF "y1"
frequency
g
a
i
n
0 200 400 600
0
2
4
6
8
x 10
4
POWER SPECTRUM OF "y2"
frequency
g
a
i
n




0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
-70
-60
-50
-40
-30
-20
-10
Frequency (kHz)
P
o
w
e
r
/
f
r
e
q
u
e
n
c
y

(
d
B
/
H
z
)
Power Spectral Density Estimate via Welch
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
-350
-300
-250
-200
-150
-100
-50
0
Frequency (kHz)
P
o
w
e
r
/
f
r
e
q
u
e
n
c
y

(
d
B
/
H
z
)
Power Spectral Density Estimate via Periodogram
Experiment No.7

SPECTRUM FOLDING AND UNFOLDING

Aim:
To implement spectrum folding and unfolding

Theory:
The spectrum of a signal can be obtained by taking its Fourier transform. The right-
most end of the horizontal axis of the spectrum represents the sampling frequency; the center
of each horizontal axis represents one-half the sampling frequency, or the Nyquist folding
frequency. Thus, the frequency represented by the center of the horizontal axis represents the
frequency specified by a value of f
s
/2. The peaks to the right of the folding frequency are
mirror images of the peaks to the left of the folding frequency. In other words, given a set of
samples of a sinusoid, the spectral analysis process is unable to determine whether the peak is
above or below the folding frequency, so the energy is equally distributed between two peaks
on opposite sides of the folding frequency. The peaks are always symmetrical to the folding
frequency due to the frequency folding at that frequency.As the frequency of each sinusoid
approaches the folding frequency, the two mirror-image peaks corresponding to that sinusoid
merge into a single peak with twice the height at the folding frequency.
The folded spectrum of a sequence with N samples is equivalent to the spectrum of the
sequence multiplied by (1)

; = 0, 1, , 1 . That means if

() , then
1

2
. Here,

2
represents the folded spectrum. In discrete case, if

() then 1


1
2
.
Inbuilt function fftshift( ) is used for finding the folded spectrum and ifftshift( ) is used
for unfolding it.

Program:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Generation of spectrum folding and unfolding
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear all
close all
% x=input('Enter the input sequence: ');
f=input('Enter the signal frequency: ');
fs=input('Enter the sampling frequency: ');
N=input('Enter the value of N such that N>length(x): ');
t=0:1/fs:1;
x=sin(2*pi*f*t);
f1=(0:N-1)*fs/N;
y1=fft(x,N);
y2=fftshift(y1); % folded spectrum: equivalent to the spectrum of
((-1)^n)*x
y3=ifftshift(y2); % unfolded spectrum
z1=ifft(y1); % equivalent to x
z2=ifft(y2); % equivalent to ((-1)^n)*x
subplot(311)
stem(t,x);
title('ORIGINAL SIGNAL');
xlabel('time');
ylabel('amplitude');
subplot(312)
stem(f1,abs(y1));
title('SPECTRUM');
xlabel('frequency');
ylabel('amplitude');
subplot(313)
stem(f1,abs(y2));
title('FOLDED SPECTRUM');
xlabel('frequency');
ylabel('amplitude');
figure
subplot(311)
stem(f1,abs(y3));
title('UNFOLDED SPECTRUM');
xlabel('frequency');
ylabel('amplitude');
subplot(312)
stem(z1);
title('RECONSTRUCTED SIGNAL FROM THE ORIGINAL SPECTRUM');
xlabel('time');
ylabel('amplitude');
subplot(313)
stem(z2);
title('RECONSTRUCTED SIGNAL FROM THE FOLDED SPECTRUM');
xlabel('time');
ylabel('amplitude');

Output:
Enter the signal frequency: 2
Enter the sampling frequency: 100
Enter the value of N such that N>length(x): 128




Graph:


0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-1
0
1
ORIGINAL SIGNAL
time
a
m
p
l
i
t
u
d
e
0 10 20 30 40 50 60 70 80 90 100
0
50
SPECTRUM
frequency
a
m
p
l
i
t
u
d
e
0 10 20 30 40 50 60 70 80 90 100
0
50
FOLDED SPECTRUM
frequency
a
m
p
l
i
t
u
d
e
0 10 20 30 40 50 60 70 80 90 100
0
50
UNFOLDED SPECTRUM
frequency
a
m
p
l
i
t
u
d
e
0 20 40 60 80 100 120 140
-1
0
1
RECONSTRUCTED SIGNAL FROM THE ORIGINAL SPECTRUM
time
a
m
p
l
i
t
u
d
e
0 20 40 60 80 100 120 140
-1
0
1
RECONSTRUCTED SIGNAL FROM THE FOLDED SPECTRUM
time
a
m
p
l
i
t
u
d
e
Experiment No.8

LINEAR CONVOLUTION

Aim:
To implement linear convolution using the following methods
Direct implementation using formula
Convolution using DFT

Theory:
The operator stands for the linear convolution operation. The convolution between
two signals x[n] and h[n] is represented symbolically as
= () ()
and is defined by
= ( )

=

It can be used to find the response of a system to any input signal. Then ()represents the
input and represents the impulse response of the system.Convolution is commutative,
associative and distributive. The identity operator for convolution is the delta function. conv( )
is the inbuilt function for finding the convolution of two sequences.

Algorithm:
Direct Implementation of formula
Step 1: reset the registers and files
Step 2: enter the sequences
Step 3: find the length of the sequence
Step 4: find the length of convolved sequence
Step 5: implement linear convolutionusing its formula
Step 6: cross verify using conv( ) function in MATLAB
Step 7: display the output sequence with suitable labels

Convolution using DFT
Step 1: reset the registers and files
Step 2: enter the sequences
Step 3: find the length of the sequences
Step 4: fix the length of the convoluted sequence as the maximum of the lengths of the
two sequences
Step 5: make the lengths of both sequences equal to the length of the convoluted sum.
Step 6: find the dft of both sequences
Step 7: find the product of dft transformed sequences
Step 8: take inverse idft of the product
Step 9: cross verify using conv() function in MATLAB
Step 10: display the output sequence with suitable labels

Program
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Convolution using the equation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc;
close all;
clear all;

x=input('Enter the input sequence: '); %input sequence
st_x=input('Enter the starting position of the input sequence: ');
%time of start of input sequence
h=input('Enter the impulse response: ');%impulse response
coefficients
st_h=input('Enter the starting position of the impulse response: ');
%time of start of the impulse response

n1=length(x);
n2=length(h);
end_x=n1+st_x-1;
end_h=n2+st_h-1;
nx=st_x:end_x; %time of existence of input sequence
nh=st_h:end_h; %time of existence of impulse response

ny=st_x+st_h:end_x+end_h;% calculating the time of existence of the
convoluted sum.
N=n1+n2-1; % length of the final sequence
y=zeros(1,N);

x1=[x,zeros(1,N-n1)];
h1=[h,zeros(1,N-n2)];
for i=1:N
for j=1:i
y(i)=y(i)+ x1(j)*h1(i-j+1); % convoluted sum using the
equation
end
end
y1=conv(x,h);

% First sequence
subplot(221)
stem(nx,x)
title('FIRST SEQUENCE');
xlabel('Time');
ylabel('Amplitude');

% Second sequence
subplot(222)
stem(nh,h)
title('SECOND SEQUENCE');
xlabel('Time');
ylabel('Amplitude');

% Convolution using equation
subplot(223)
stem(ny,y)
title('CONVOLUTION USING EQUATION');
xlabel('Time');
ylabel('Amplitude');

% Convolution using conv()
subplot(224)
stem(ny,y1)
title('CONVOLUTION USING conv()');
xlabel('Time');
ylabel('Amplitude');

Output:
Enter the input sequence: [1 2 0 1]
Enter the starting position of the input sequence: 1
Enter the impulse response: [2 2 1 1]
Enter the starting position of the impulse response: 1
















Graph:



%%%%%%%%%%%%%%%%%%%%%%%
% Convolution Using DFT
%%%%%%%%%%%%%%%%%%%%%%%
clc;
close all;
clear all;

x=input('Enter the input sequence: '); %input sequence
st_x=input('Enter the starting position of the input sequence: ');
%time of start of input sequence
h=input('Enter the impulse response: ');%impulse response
coefficients
st_h=input('Enter the starting position of the impulse response: ');
%time of start of the impulse response

n1=length(x);
n2=length(h);
end_x=n1+st_x-1;
end_h=n2+st_h-1;
nx=st_x:end_x; %time of existence of input sequence
nh=st_h:end_h; %time of existence of impulse response

0 1 2 3
0
0.5
1
1.5
2
FIRST SEQUENCE
Time
A
m
p
l
i
t
u
d
e
0 1 2 3
0
0.5
1
1.5
2
SECOND SEQUENCE
Time
A
m
p
l
i
t
u
d
e
0 2 4 6
0
2
4
6
CONVOLUTION USING EQUATION
Time
A
m
p
l
i
t
u
d
e
0 2 4 6
0
2
4
6
CONVOLUTION USING conv()
Time
A
m
p
l
i
t
u
d
e
ny=st_x+st_h:end_x+end_h; % calculating the time of existence of the
convoluted sum
N=n1+n2-1; % length of the final sequence
y=zeros(1,N);
x1=[x,zeros(1,N-n1)];
h1=[h,zeros(1,N-n2)];

for k=1:N
for n=1:N
e(k,n)=exp(-i*2*pi*(k-1)*(n-1)/N);
f(k,n)=exp(i*2*pi*(k-1)*(n-1)/N);
end
end
xk=e*x1';
hk=e*h1';
yk=xk.*hk;
y=round(abs(f*yk/N));

y1=round(ifft(fft(x1).*fft(h1)));

% First sequence
subplot(221)
stem(nx,x)
title('FIRST SEQUENCE');
xlabel('Time');
ylabel('Amplitude');

% Second sequence
subplot(222)
stem(nh,h)
title('SECOND SEQUENCE');
xlabel('Time');
ylabel('Amplitude');

% Convolution without using fft()
subplot(223)
stem(ny,y)
title('CONVOLTUION WITHOUT USING fft()');
xlabel('Time');
ylabel('Amplitude');

% Convolution with the function fft()
subplot(224)
stem(ny,y1)
title('CONVOLTUION USING fft()');
xlabel('Time');
ylabel('Amplitude');

Output:
Enter the input sequence: [1 2 0 1]
Enter the starting position of the input sequence: 0
Enter the impulse response: [2 2 1 1]
Enter the starting position of the impulse response: 0

Graph:



0 1 2 3
0
0.5
1
1.5
2
FIRST SEQUENCE
Time
A
m
p
l
i
t
u
d
e
0 1 2 3
0
0.5
1
1.5
2
SECOND SEQUENCE
Time
A
m
p
l
i
t
u
d
e
0 2 4 6
0
2
4
6
CONVOLTUION WITHOUT USING fft()
Time
A
m
p
l
i
t
u
d
e
0 2 4 6
0
2
4
6
CONVOLTUION USING fft()
Time
A
m
p
l
i
t
u
d
e
Experiment No. 9

CIRCULAR CONVOLUTION

Aim:

To implement circular convolution using the following methods
Direct implementation using formula
Convolution using DFT
One application: linear convolution using circular convolution.

Theory:

The operator stands for the circular convolution operation. The circular convolution
between two signals x[n] and h[n] is represented symbolically as

and is defined by

It can be used to find the response of a system to any input signal. Then x[n] represents
the input and h[n] represents the impulse response of the system.Circular convolution is
commutative, associative and distributive. The identity operator for convolution is the delta
function.

Algorithm:

Direct Implementation of formula
Step 1: reset the registers and files
Step 2: enter the sequences
Step 3: find the length of the sequences
Step 4: find the circular convolution of the sequencesusing its formula
Step 6: display the output sequence with suitable labels

Convolution using DFT
Step 1: reset the registers and files
Step 2: enter the sequences
Step 3: find the length of the sequences
Step 4: fix the length of the convoluted sequence as the maximum of the lengths of the
two sequences
Step 5: make the lengths of both sequences equal to the length of the convoluted sum.
Step 6: find the dft of both sequences
Step 7: find the product of dft transformed sequences
Step 8: take inverse idft of the product
Step 9: cross verify using circonv function in MATLAB
Step 10: display the output sequence with suitable labels

Program:

%%%%%%%%%%%%%%%%%%%%%%
% Circular Convolution
%%%%%%%%%%%%%%%%%%%%%%
clc
clear all
close all
x=input('Enter the input sequence: '); %input sequence
h=input('Enter the impulse response: ');%impulse response
coefficients

n1=length(x);
n2=length(h);
N=max(n1,n2); % length of the final sequence
if n1<N
x=[x,zeros(1,N-n1)];
else
h=[h,zeros(1,N-n2)];
end
x1=x;
y=zeros(1,N);
c=x';
c1=c;
% Circular convoluted sum using the equation with using the function
circshift()
for j=1:N-1
a=circshift(x',j); % using the function circshift()
c=[c,a];
end
y=c*h';

% Circular convoluted sum using the equation without using the
function circshift()
for j=1:N-1
x1=[x1(N),x1(1:N-1)]; % without using the function circshift()
c1=[c1,x1'];
end
y1=c1*h';

% Circular convoluted sum using fft without using the function fft()
for k=1:N
for n=1:N
e(k,n)=exp(-i*2*pi*(k-1)*(n-1)/N);
f(k,n)=exp(i*2*pi*(k-1)*(n-1)/N);
end
end
xk=e*x';
hk=e*h';
yk=xk.*hk;
y2=round(abs(f*yk/N));

% Circular convoluted sum using fft()
y3=round(ifft(fft(x).*fft(h)));

% First sequence
subplot(321)
stem(x)
title('FIRST SEQUENCE');
xlabel('Time');
ylabel('Amplitude');

% Second sequence
subplot(322)
stem(h)
title('SECOND SEQUENCE');
xlabel('Time');
ylabel('Amplitude');

% Circular Convolution using equation
subplot(323)
stem(y)
title('CONVOLUTION USING circshift()');
xlabel('Time');
ylabel('Amplitude');

% circular convolution without using any of the matlab functions
subplot(324)
stem(y1)
title('CONVOLUTION WITHOUT USING circshift()');
xlabel('Time');
ylabel('Amplitude');

% Circular convolution using fft without using fft()
subplot(325)
stem(y2)
title('CONVOLUTION USING fft()');
xlabel('Time');
ylabel('Amplitude');

% Circular convolution using fft with using fft()
subplot(326)
stem(y3)
title('CONVOLUTION WITHOUT USING fft()');
xlabel('Time');
ylabel('Amplitude');


Output:
Enter the input sequence: [1 2 0 1]
Enter the impulse response: [2 2 1 1]

Graph:


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Linear convolution using circular Convolution
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clc
clear all
close all
x=input('Enter the input sequence: '); %input sequence
1 2 3 4
0
1
2
FIRST SEQUENCE
Time
A
m
p
l
i
t
u
d
e
1 2 3 4
0
1
2
SECOND SEQUENCE
Time
A
m
p
l
i
t
u
d
e
1 2 3 4
0
5
10
CONVOLUTION USING circshift()
Time
A
m
p
l
i
t
u
d
e
1 2 3 4
0
5
10
CONVOLUTION WITHOUT USING circshift()
Time
A
m
p
l
i
t
u
d
e
1 2 3 4
0
5
10
CONVOLUTION USING fft()
Time
A
m
p
l
i
t
u
d
e
1 2 3 4
0
5
10
CONVOLUTION WITHOUT USING fft()
Time
A
m
p
l
i
t
u
d
e
h=input('Enter the impulse response: ');%impulse response
coefficients

n1=length(x);
n2=length(h);
N=n1+n2-1; % length of the final sequence
x1=[x,zeros(1,N-n1)];
h1=[h,zeros(1,N-n2)];
y=zeros(1,N);
c=x1';
for j=1:N-1
a=circshift(x1',j); % using the function circshift()
c=[c,a];
end
y=c*h1';
y1=conv(x,h);

% First sequence
subplot(221)
stem(x)
title('FIRST SEQUENCE');
xlabel('Time');
ylabel('Amplitude');

% Second sequence
subplot(222)
stem(h)
title('SECOND SEQUENCE');
xlabel('Time');
ylabel('Amplitude');

% Linear convolution using circular convolution
subplot(223)
stem(y)
title('LINEAR USING CIRCULAR');
xlabel('Time');
ylabel('Amplitude');

% Linear convolution using conv()
subplot(224)
stem(y1)
title('LINEAR CONVOLUTION USING conv()');
xlabel('Time');
ylabel('Amplitude');

Output:
Enter the input sequence: [1 2 0 1]
Enter the impulse response: [2 2 1 1]



Graph:
1 2 3 4
0
0.5
1
1.5
2
FIRST SEQUENCE
Time
A
m
p
l
i
t
u
d
e
1 2 3 4
0
0.5
1
1.5
2
SECOND SEQUENCE
Time
A
m
p
l
i
t
u
d
e
0 2 4 6 8
0
2
4
6
LINEAR USING CIRCULAR
Time
A
m
p
l
i
t
u
d
e
0 2 4 6 8
0
2
4
6
LINEAR CONVOLUTION USING conv()
Time
A
m
p
l
i
t
u
d
e
Experiment No.10

LINEAR CONVOLUTION OF LONG DURATION SEQUENCE

Aim:

To implement linear convolution of long duration sequence using the following methods
Overlap add method
Overlap save method

Theory:

The operator stands for the linear convolution operation. The convolution between
two signals x[n] and h[n] is represented symbolically as
= () ()
and is defined by
= ( )

=

It can be used to find the response of a system to any input signal. Then () represents the
input and represents the impulse response of the system.
Convolution is commutative, associative and distributive. The identity operator for convolution
is the delta function.
Overlap add and overlap save are the two methods used for the simulation of linear
convolution of two sequences if one of the sequences consists of a large number of samples.
Here we are using the property that linear convolution can be computed using circular
convolution.

Algorithm:

Overlap add method
Step 1: reset the registers and files
Step 2: enter the sequences
Step 3: enter the number of new data points to be selected from the first sequence to
form the blocks.
Step 4: find the length of the sequences
Step 5: find the length of convolved sequence
Step 6: find the number of blocks and length of each block.
Step 7: perform blocking
Step 8: find the circular convolution of each block with the impulse response.
Step 9: eliminate the first overlap elements from each block to form the final output.

Overlap add method
Step 1: reset the registers and files
Step 2: enter the sequences
Step 3: enter the number of new data points to be selected from the first sequence to
form the blocks.
Step 4: find the length of the sequences
Step 5: find the length of convolved sequence
Step 6: find the number of blocks and length of each block.
Step 7: perform blocking
Step 8: find the circular convolution of each block with the impulse response.
Step 9: eliminate the first overlap elements from each block to form the final output.

Program:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Linear Convolution of long duration sequence
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear all
close all
x=input('Enter the long duration sequence: ');
h=input('Enter the impulse response: ');
l=input('Enter the length of new data points to be selected from
x(n) in order to make each block: ');
nx=length(x);
m=length(h);
y=conv(x,h);

subplot(211);
stem(x);
title('LONG DURATION SEQUENCE');
xlabel('n --->');
ylabel('Amplitude');
subplot(212);
stem(h);
title('IMPULSE RESPONSE')
xlabel('n --->');
ylabel('Amplitude')
figure
subplot(311);
stem(y);
title('CONVOLUTION USING conv()')
xlabel('n --->');
ylabel('Amplitude');

L=l+m-1; % Length of each block.
L_c=nx+m-1; % Length of convoluted sum.
x=[x,zeros(1,L-1)]; % For avoiding dimension mismatch
h=[h,zeros(1,L-m)]; % To make the length of h(n) equal to length of
each block.
c=[];
for i=0:L-1
a=circshift(h',i);
c=[c,a]; % Circular convolution matrix using the impulse
response.
end

% OVERLAP SAVE
N1=ceil(L_c/l); % No: of blocks.
x1=[zeros(1,m-1),x(1:l)]; % First block.
k=l;
os_c=x1;
for i=1:N1-1
x1=[x1(L-m+2:L),x(k+1:k+l)];
os_c=[os_c;x1]; % Matrix whose each row represents each block
k=k+l;
end
circon_block1=c*os_c'; % Matrix whose each column represents the
circular convolution of each block
cir_con1=circon_block1(m:L,:); % To ignore first m-1 elements from
each block
lin_con1=reshape(cir_con1,1,l*N1); % To make the linear convoluted
matrix in the row form.

subplot(312);
stem(lin_con1(1:L_c));
title('CONVOLUTION USING OVERLAP SAVE METHOD')
xlabel('n --->');
ylabel('Amplitude')

% OVERLAP ADD
N2=ceil(nx/l); % No: of blocks.
k=0;
os_a=[];
for i=1:N2
x1=[x(k+1:k+l),zeros(1,m-1)];
os_a=[os_a;x1]; % Matrix whose each row represents each block
k=k+l;
end
circon_block2=c*os_a'; % Matrix whose each column represents the
circular convolution of each block
c1=circon_block2';
k2=0;
for i=1:N2
b=[zeros(1,k2),c1(i,:),zeros(1,L_c-L-k2)];
if i~=N2
c2(i,:)=b;
else
c2(i,:)=b(1,1:L_c);
end
k2=k2+l;
end
lin_con2=sum(c2); % Linear convolution is equal to the sum of all
rows of c2

subplot(313);
stem(lin_con2(1:L_c));
title('CONVOLUTION USING OVERLAP ADD METHOD')
xlabel('n --->');
ylabel('Amplitude');

Output:
Enter the long duration sequence: [1 3 2 4 5 6 0 8 9 5 7 8]
Enter the impulse response: [1 2 2 1]
Enter the length of new data points to be selected from x(n) in order
to make each block: 4

Graph:

0 2 4 6 8 10 12
0
5
10
LONG DURATION SEQUENCE
n --->
A
m
p
l
i
t
u
d
e
1 1.5 2 2.5 3 3.5 4
0
0.5
1
1.5
2
IMPULSE RESPONSE
n --->
A
m
p
l
i
t
u
d
e



















0 5 10 15
0
50
CONVOLUTION USING conv()
n --->
A
m
p
l
i
t
u
d
e
0 5 10 15
0
50
CONVOLUTION USING OVERLAP SAVE METHOD
n --->
A
m
p
l
i
t
u
d
e
0 5 10 15
0
50
CONVOLUTION USING OVERLAP ADD METHOD
n --->
A
m
p
l
i
t
u
d
e
Experiment No.11

IIR FILTER DESIGN

IIR FILTERS:
IIR filters have infinite frequency response and nonlinear phase. The classical IIR
filters are Butterworth, Chebyshev Types I and II, elliptical and Bessel filters.

Butterworth Filter:
The Butterworth filter provides the best Taylor Series approximation to the ideal low-
pass filter response at analog frequencies = 0 and = ; for any order N, the magnitude
squared response has 2N-1 zero derivatives at these locations (maximally flat at = 0 and =
). Response is monotonic overall, decreasing smoothly from = 0 to = .| (j )| =
at =1.

Chebyshev Type1:
The Chebyshev Type I filter minimizes the absolute difference between the ideal and
actual frequency response over the entire pass-band by incorporating an equal ripple of R
p
dB
in the pass-band. Stop-band response is maximally flat. The transition from pass-band to stop-
band is more rapid than for the Butterworth filter. | (j )| = 10
Rp/20
at =1.

Chebyshev Type II:
The Chebyshev Type II filter minimizes the absolute difference between the ideal and
actual frequency response over the entire stop-band by incorporating an equal ripple of Rs dB
in the stop-band. Pass-band response is maximally flat. The stop-band does not approach zero
as quickly as the type I filter (and does not approach zero at all for even-valued filter order n).
The absence of ripple in the pass-band, however, is often an important advantage. . | (j )| =
10
Rs/20
at =1.

Elliptical Filter:
Elliptical filters are equiripple in both the pass-band and stop-band. They generally
meet filter requirements with the lowest order of any supported filter type. Given a filter order
n, pass-band ripple R
p
in decibels, and stop-band ripple R
s
in decibels, elliptic filters minimize
transition width. | (j )| = 10
Rp/20
at =1.


Design:
The classic IIR filter design technique includes the following steps.
Find an analog low-pass filter with cutoff frequency of 1 and translate this
"prototype" filter to the desired band configuration
Transform the filter to the digital domain.
Discretize the filter.
The toolbox provides functions for each of these steps.

Design Task Available functions
Analog low-pass prototype
buttap, cheb1ap, besselap, ellipap,
cheb2ap
Frequency transformation lp2lp, lp2hp, lp2bp, lp2bs
Discretization bilinear, impinvar

Alternatively, the butter, cheby1, cheby2, ellip, and besself functions perform all steps
of the filter design and the buttord, cheb1ord, cheb2ord, and ellipord functions provide
minimum order computation for IIR filters. These functions are sufficient for many design
problems, and the lower level functions are generally not needed. But if you do have an
application where you need to transform the band edges of an analog filter, or discretize a
rational transfer function, this section describes the tools with which to do so.














Experiment No.11a

BUTTERWORTH DIGITAL IIR FILTERS

Aim:
To design butterworth analog
Low pass filter
High pass filter
Band pass filter
Band stop filter
using matlab built in filter functions

Theory:

Analog butterworth filter is designed by approximating the ideal frequency response
using an error function. The error is selected such that the magnitude is maximally flat in the
pass band and monotonically decreasing in the stop band. The magnitude response of low pass
filter is given by

()
2
=
1
1 +

2

The matlab function used for finding the order of butterworth filter is
[N,Wn] = buttord(W
P,
W
s
,R
P
,R
s
)
The matlab function used for finding the order of butterworth filter is
[b,a] = butter(N,Wn,type)

Algorithm:

Generation of filter coefficients
Step 1: reset the registers and files
Step 2: enter values of ripples in the passband and stopband and the cut-off frequencies.
Step 3: find out the order of the filter using the inbuilt function.
Step 4: determine the filter coefficients
Step 5: plot the magnitude and phase responses of LPF, HPF, BPF and BSF



Program:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Butterworth Digital filters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear all
close all
rp=input('Enter passband ripple: ');
rs=input('Enter stopband ripple: ');
fs1=input('Enter first stopband freq in hz: ');
fp1=input('Enter first passband freq in hz: ');
fp2=input('Enter second passband freq in hz: ');
fs2=input('Enter second stopband freq in hz: ');
fs=input('Enter sampling freq in hz: ');
wp1=2*fp1/fs;
ws1=2*fs1/fs;
wp2=2*fp2/fs;
ws2=2*fs2/fs;
w=0:.01:pi;

% LPF
[n1,wn1]=buttord(wp1,ws1,rp,rs);
[b1,a1]=butter(n1,wn1);
[h1,om1]=freqz(b1,a1,w);
m1=20*log10(abs(h1));
an1=angle(h1);
subplot(221);
plot(om1/pi,m1);
title('MAGNITUDE RESPONSE OF LPF');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(222);
plot(om1/pi,an1);
title('PHASE RESPONSE OF LPF');
xlabel('normalised freq');
ylabel('phase in rad');

% HPF
% [n2,wn2]=buttord(wp,ws,rp,rs);
[b2,a2]=butter(n1,wn1,'high');
w=0:.02:pi;
[h2,om2]=freqz(b2,a2,w);
m2=20*log10(abs(h2));
an2=angle(h2);
subplot(223);
plot(om2/pi,m2);
title('MAGNITUDE RESPONSE OF HPF');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(224);
plot(om2/pi,an2);
title('PHASE RESPONSE OF HPF');
xlabel('normalised freq');
ylabel('phase in rad');

% BPF
wp=[wp1,wp2];
ws=[ws1,ws2];
[n3,wn3]=buttord(wp,ws,rp,rs);
[b3,a3]=butter(n3,wn3,'bandpass');
[h3,om3]=freqz(b3,a3,w);
m3=20*log10(abs(h3));
an3=angle(h3);
figure;
subplot(221);
plot(om3/pi,m3);
title('MAGNITUDE RESPONSE OF BPF');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(222);
plot(om3/pi,an3);
title('PHASE RESPONSE OF BPF');
xlabel('normalised freq');
ylabel('phase in rad');

% BSF
% [n3,wn3]=buttord(wp,ws,rp,rs);
[b4,a4]=butter(n3,wn3,'stop');
[h4,om4]=freqz(b4,a4,w);
m4=20*log10(abs(h4));
an4=angle(h4);
subplot(223);
plot(om4/pi,m4);
title('MAGNITUDE RESPONSE OF BSF');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(224);
plot(om4/pi,an4);
title('PHASE RESPONSE OF BSF');
xlabel('normalised freq');
ylabel('phase in rad');

Output:
Enter passband ripple: .2
Enter stopband ripple: 5
Enter first stopband freq in hz: 200
Enter first passband freq in hz: 300
Enter second passband freq in hz: 1000
Enter second stopband freq in hz: 1100
Enter sampling freq in hz: 2500

Graph:


0 0.5 1
-400
-300
-200
-100
0
MAGNITUDE RESPONSE OF LPF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF LPF
normalised freq
p
h
a
s
e

i
n

r
a
d
0 0.5 1
-300
-200
-100
0
100
MAGNITUDE RESPONSE OF HPF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF HPF
normalised freq
p
h
a
s
e

i
n

r
a
d
0 0.5 1
-400
-300
-200
-100
0
MAGNITUDE RESPONSE OF BPF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF BPF
normalised freq
p
h
a
s
e

i
n

r
a
d
0 0.5 1
-200
-100
0
100
MAGNITUDE RESPONSE OF BSF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF BSF
normalised freq
p
h
a
s
e

i
n

r
a
d
Experiment No.11b

CHEBYSHEV TYPE-I DIGITAL IIR FILTERS

Aim:
To write matlab programs for the following chebyshev type 1 digital filters
Chebyshev type 1 low pass filter
Chebyshev type 1 high pass filter
Chebyshev type 1 band pass filter
Chebyshev type 1 band stop filter

Theory:
To design IIR Chebyshev digital filter, first an analog filter transfer function is
determined using the given specifications. Then the analog filter transfer function is converted
to a digital filter transfer function by using either impulse invariance transformation or bilinear
transformation. All digital IIR filter design analysis is done in the z-domain.The magnitude
response of low pass filter of a chebyshevtype-I filter is given by

()
2
=
1
1 +


The matlab function used for finding the order of chebyshevtype-I filter is
[N,Wn] = cheb1ord(W
P,
W
s
,R
P
,R
s
)
The matlab function used for finding the order of chebyshevtype-Ifilter is
[b,a] = cheby1(N,R
p
,Wn,type)

Algorithm:

Generation of filter coefficients
Step 1: reset the registers and files
Step 2: enter values of ripples in the passband and stopband and the cut-off frequencies.
Step 3: find out the order of the filter using the inbuilt function.
Step 4: determine the filter coefficients
Step 5: plot the magnitude and phase responses of LPF, HPF, BPF and BSF




Program:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Chebyshev type I Digital filters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear all
close all
rp=input('Enter passband ripple: ');
rs=input('Enter stopband ripple: ');
fs1=input('Enter first stopband freq in hz: ');
fp1=input('Enter first passband freq in hz: ');
fp2=input('Enter second passband freq in hz: ');
fs2=input('Enter second stopband freq in hz: ');
fs=input('Enter sampling freq in hz: ');
wp1=2*fp1/fs;
ws1=2*fs1/fs;
wp2=2*fp2/fs;
ws2=2*fs2/fs;
w=0:.01:pi;

% LPF
[n1,wn1]=cheb1ord(wp1,ws1,rp,rs);
[b1,a1]=cheby1(n1,rp,wn1);
[h1,om1]=freqz(b1,a1,w);
m1=20*log10(abs(h1));
an1=angle(h1);
subplot(221);
plot(om1/pi,m1);
title('MAGNITUDE RESPONSE OF LPF');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(222);
plot(om1/pi,an1);
title('PHASE RESPONSE OF LPF');
xlabel('normalised freq');
ylabel('phase in rad');

% HPF
% [n1,wn1]=cheb1ord(wp1,ws1,rp,rs);
[b2,a2]=cheby1(n1,rp,wn1,'high');
w=0:.02:pi;
[h2,om2]=freqz(b2,a2,w);
m2=20*log10(abs(h2));
an2=angle(h2);
subplot(223);
plot(om2/pi,m2);
title('MAGNITUDE RESPONSE OF HPF');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(224);
plot(om2/pi,an2);
title('PHASE RESPONSE OF HPF');
xlabel('normalised freq');
ylabel('phase in rad');

% BPF
wp=[wp1,wp2];
ws=[ws1,ws2];
[n3,wn3]=cheb1ord(wp,ws,rp,rs);
[b3,a3]=cheby1(n3,rp,wn3,'bandpass');
[h3,om3]=freqz(b3,a3,w);
m3=20*log10(abs(h3));
an3=angle(h3);
figure;
subplot(221);
plot(om3/pi,m3);
title('MAGNITUDE RESPONSE OF BPF');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(222);
plot(om3/pi,an3);
title('PHASE RESPONSE OF BPF');
xlabel('normalised freq');
ylabel('phase in rad');

% BSF
% [n3,wn3]=cheb1ord(wp,ws,rp,rs);
[b4,a4]=cheby1(n3,rp,wn3,'stop');
[h4,om4]=freqz(b4,a4,w);
m4=20*log10(abs(h4));
an4=angle(h4);
subplot(223);
plot(om4/pi,m4);
title('MAGNITUDE RESPONSE OF BSF');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(224);
plot(om4/pi,an4);
title('PHASE RESPONSE OF BSF');
xlabel('normalised freq');
ylabel('phase in rad');

Output:
Enter passband ripple: 20
Enter stopband ripple: 50
Enter first stopband freq in hz: 100
Enter first passband freq in hz: 250
Enter second passband freq in hz: 850
Enter second stopband freq in hz: 1000
Enter sampling freq in hz: 2500
Graph:


0 0.5 1
-300
-200
-100
0
MAGNITUDE RESPONSE OF LPF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF LPF
normalised freq
p
h
a
s
e

i
n

r
a
d
0 0.5 1
-400
-300
-200
-100
0
MAGNITUDE RESPONSE OF HPF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF HPF
normalised freq
p
h
a
s
e

i
n

r
a
d
0 0.5 1
-400
-300
-200
-100
0
MAGNITUDE RESPONSE OF BPF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF BPF
normalised freq
p
h
a
s
e

i
n

r
a
d
0 0.5 1
-200
-150
-100
-50
0
MAGNITUDE RESPONSE OF BSF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF BSF
normalised freq
p
h
a
s
e

i
n

r
a
d
Experiment No.11c

CHEBYSHEV TYPE II DIGITAL FILTERS

Aim:
To write matlab programs for the following chebyshev type 2 digital filters
Chebyshev type 2 low pass filter
Chebyshev type 2 high pass filter
Chebyshev type 2 band pass filter
Chebyshev type 2 band stop filter

Theory:
To design IIR Chebyshev digital filter, first an analog filter transfer function is
determined using the given specifications. Then the analog filter transfer function is converted
to a digital filter transfer function by using either impulse invariance transformation or bilinear
transformation.All digital IIR filters design analysis are done in the z-domain.The magnitude
response of low pass filter of a chebyshevtype-I filter is given by

()
2
=
1
1 +


The matlab function used for finding the order of chebyshevtype-I filter is
[N,Wn] = cheb2ord(W
P,
W
s
,R
P
,R
s
)
The matlab function used for finding the order of chebyshevtype-Ifilter is
[b,a] = cheby2(N,R
s
,Wn,type)

Algorithm:

Generation of filter coefficients
Step 1: reset the registers and files
Step 2: enter values of ripples in the passband and stopband and the cut-off frequencies.
Step 3: find out the order of the filter using the inbuilt function.
Step 4: determine the filter coefficients
Step 5: plot the magnitude and phase responses of LPF, HPF, BPF and BSF




Program:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Chebyshev type IIDigital filters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear all
close all
rp=input('Enter passband ripple: ');
rs=input('Enter stopband ripple: ');
fs1=input('Enter first stopband freq in hz: ');
fp1=input('Enter first passband freq in hz: ');
fp2=input('Enter second passband freq in hz: ');
fs2=input('Enter second stopband freq in hz: ');
fs=input('Enter sampling freq in hz: ');
wp1=2*fp1/fs;
ws1=2*fs1/fs;
wp2=2*fp2/fs;
ws2=2*fs2/fs;
w=0:.01:pi;

% LPF
[n1,wn1]=cheb2ord(wp1,ws1,rp,rs);
[b1,a1]=cheby2(n1,rs,wn1);
[h1,om1]=freqz(b1,a1,w);
m1=20*log10(abs(h1));
an1=angle(h1);
subplot(221);
plot(om1/pi,m1);
title('MAGNITUDE RESPONSE');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(222);
plot(om1/pi,an1);
title('PHASE RESPONSE');
xlabel('normalised freq');
ylabel('phase in rad');

% HPF
% [n1,wn1]=cheb2ord(wp1,ws1,rp,rs);
[b2,a2]=cheby2(n1,rs,wn1,'high');
w=0:.02:pi;
[h2,om2]=freqz(b2,a2,w);
m2=20*log10(abs(h2));
an2=angle(h2);
subplot(223);
plot(om2/pi,m2);
title('MAGNITUDE RESPONSE');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(224);
plot(om2/pi,an2);
title('PHASE RESPONSE');
xlabel('normalised freq');
ylabel('phase in rad');

% BPF
wp=[wp1,wp2];
ws=[ws1,ws2];
[n3,wn3]=cheb2ord(wp,ws,rp,rs);
[b3,a3]=cheby2(n3,rs,wn3,'bandpass');
[h3,om3]=freqz(b3,a3,w);
m3=20*log10(abs(h3));
an3=angle(h3);
figure;
subplot(221);
plot(om3/pi,m3);
title('MAGNITUDE RESPONSE');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(222);
plot(om3/pi,an3);
title('PHASE RESPONSE');
xlabel('normalised freq');
ylabel('phase in rad');

% BSF
% [n3,wn3]=cheb2ord(wp,ws,rp,rs);
[b4,a4]=cheby2(n3,rs,wn3,'stop');
[h4,om4]=freqz(b4,a4,w);
m4=20*log10(abs(h4));
an4=angle(h4);
subplot(223);
plot(om4/pi,m4);
title('MAGNITUDE RESPONSE');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(224);
plot(om4/pi,an4);
title('PHASE RESPONSE');
xlabel('normalised freq');
ylabel('phase in rad');

Output:
Enter passband ripple: 20
Enter stopband ripple: 50
Enter first stopband freq in hz: 100
Enter first passband freq in hz: 250
Enter second passband freq in hz: 850
Enter second stopband freq in hz: 1000
Enter sampling freq in hz: 2500

Graph:


0 0.5 1
-150
-100
-50
0
MAGNITUDE RESPONSE OF LPF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF LPF
normalised freq
p
h
a
s
e

i
n

r
a
d
0 0.5 1
-400
-300
-200
-100
0
MAGNITUDE RESPONSE OF HPF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF HPF
normalised freq
p
h
a
s
e

i
n

r
a
d
0 0.5 1
-150
-100
-50
0
MAGNITUDE RESPONSE OF BPF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF BPF
normalised freq
p
h
a
s
e

i
n

r
a
d
0 0.5 1
-150
-100
-50
0
50
MAGNITUDE RESPONSE OF BSF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF BSF
normalised freq
p
h
a
s
e

i
n

r
a
d
Experiment No.11d

ELLIPTICAL IIR FILTERS

Aim:
To write matlab programs for the following elliptical IIR digital filters
Elliptical low pass filter
Elliptical high pass filter
Elliptical band pass filter
Elliptical band stop filter

Theory:
Elliptical filters have ripples in both the pass-band and stop-band. They generally meet
filter requirements with the lowest order of any supported filter type. Given a filter order n,
pass-band ripple R
p
in decibels, and stop-band ripple R
s
in decibels, elliptic filters minimize
transition width. | (j )| = 10
Rp/20
at =1.
The matlab function used for finding the order of chebyshevtype-I filter is
[N,Wn] = ellipord(W
P,
W
s
,R
P
,R
s
)
The matlab function used for finding the order of chebyshevtype-Ifilter is
[b,a] = ellip(N,R
P
,R
s
,Wn,type)

Algorithm:

Generation of filter coefficients
Step 1: reset the registers and files
Step 2: enter values of ripples in the passband and stopband and the cut-off frequencies.
Step 3: find out the order of the filter using the inbuilt function.
Step 4: determine the filter coefficients
Step 5: plot the magnitude and phase responses of LPF, HPF, BPF and BSF

Program:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Elliptical Digital filters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear all
close all
rp=input('Enter passband ripple: ');
rs=input('Enter stopband ripple: ');
fs1=input('Enter first stopband freq in hz: ');
fp1=input('Enter first passband freq in hz: ');
fp2=input('Enter second passband freq in hz: ');
fs2=input('Enter second stopband freq in hz: ');
fs=input('Enter sampling freq in hz: ');
wp1=2*fp1/fs;
ws1=2*fs1/fs;
wp2=2*fp2/fs;
ws2=2*fs2/fs;
w=0:.01:pi;

% LPF
[n1,wn1]=ellipord(wp1,ws1,rp,rs);
[b1,a1]=ellip(n1,rp,rs,wn1);
[h1,om1]=freqz(b1,a1,w);
m1=20*log10(abs(h1));
an1=angle(h1);
subplot(221);
plot(om1/pi,m1);
title('MAGNITUDE RESPONSE');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(222);
plot(om1/pi,an1);
title('PHASE RESPONSE');
xlabel('normalised freq');
ylabel('phase in rad');

% HPF
% [n1,wn1]=ellipord(wp1,ws1,rp,rs);
[b2,a2]=ellip(n1,rp,rs,wn1,'high');
w=0:.02:pi;
[h2,om2]=freqz(b2,a2,w);
m2=20*log10(abs(h2));
an2=angle(h2);
subplot(223);
plot(om2/pi,m2);
title('MAGNITUDE RESPONSE');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(224);
plot(om2/pi,an2);
title('PHASE RESPONSE');
xlabel('normalised freq');
ylabel('phase in rad');

% BPF
wp=[wp1,wp2];
ws=[ws1,ws2];
[n3,wn3]=ellipord(wp,ws,rp,rs);
[b3,a3]=ellip(n3,rp,rs,wn3,'bandpass');
[h3,om3]=freqz(b3,a3,w);
m3=20*log10(abs(h3));
an3=angle(h3);
figure
subplot(221);
plot(om3/pi,m3);
title('MAGNITUDE RESPONSE');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(222);
plot(om3/pi,an3);
title('PHASE RESPONSE');
xlabel('normalised freq');
ylabel('phase in rad');

% BSF
% [n3,wn3]=ellipord(wp,ws,rp,rs);
[b4,a4]=ellip(n3,rp,rs,wn3,'stop');
[h4,om4]=freqz(b4,a4,w);
m4=20*log10(abs(h4));
an4=angle(h4);
subplot(223);
plot(om4/pi,m4);
title('MAGNITUDE RESPONSE');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(224);
plot(om4/pi,an4);
title('PHASE RESPONSE');
xlabel('normalised freq');
ylabel('phase in rad');

Output:
Enter passband ripple: 50
Enter stopband ripple: 100
Enter first stopband freq in hz: 100
Enter first passband freq in hz: 250
Enter second passband freq in hz: 850
Enter second stopband freq in hz: 1000
Enter sampling freq in hz: 2500







Graph:


0 0.5 1
-150
-100
-50
0
50
MAGNITUDE RESPONSE
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE
normalised freq
p
h
a
s
e

i
n

r
a
d
0 0.5 1
-400
-300
-200
-100
0
MAGNITUDE RESPONSE
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE
normalised freq
p
h
a
s
e

i
n

r
a
d
0 0.5 1
-400
-300
-200
-100
0
MAGNITUDE RESPONSE
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE
normalised freq
p
h
a
s
e

i
n

r
a
d
0 0.5 1
-100
-50
0
50
MAGNITUDE RESPONSE
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE
normalised freq
p
h
a
s
e

i
n

r
a
d
Experiment No.12

FIR FILTER DESIGN

Finite Impulse Response (FIR) filters are of non-recursive type, whereby the present
output sample depends om the present input sample and previous input samples. Digital filters
with finite-duration impulse response (all-zero, or FIR filters) have both advantages and
disadvantages compared to infinite-duration impulse response (IIR) filters.
FIR filters have the following primary advantages:
They can have exactly linear phase.
They are always stable.
The design methods are generally linear.
They can be realized efficiently in hardware.
The filter startup transients have finite duration.

The primary disadvantage of FIR filters is that they often require a much higher filter order
than IIR filters to achieve a given level of performance. Correspondingly, the delay of these
filters is often much greater than for equal performances IIR filter. Different methods for
designing FIR filters are
1) Using windows
2) Using equiripple approximation
3) Using frequency sampling method














Experiment No.12a

FIR FILTER USING WINDOWING

Aim:
To write matlab programs for implementing the following types of FIR filters using
various types of windows.
Low pass filter
High pass filter
Band pass filter
Band stop filter

Theory:

In signal processing, a window function (also known as an apodization function or
tapering function
[1]
) is a mathematical function that is zero-valued outside of some chosen
interval. For instance, a function that is constant inside the interval and zero elsewhere is called
a rectangular window, which describes the shape of its graphical representation. When another
function or a signal (data) is multiplied by a window function, the product is also zero-valued
outside the interval: all that is left is the part where they overlap; the view through the
window. Applications of window functions include spectral analysis, filter design, and
beamforming.
Different types of windows used for designing FIR filters are
1) Rectangular window:
The rectangular window is sometimes known as a Dirichlet window. It is the
simplest window, taking a chunk of the signal without any other modification at all,
which leads to discontinuities at the endpoints (unless the signal happens to be an exact
fit for the window length, as used in multitone testing, for instance). The first side-lobe
is only 13 dB lower than the main lobe, with the rest falling off at about 6 dB per
octave.Main lobe width is 4/N and minimum stop band attenuation is 21 dB. The
window function is given by
=
1; 0 1
0;


The matlab function used for implementing this window is rectwin(N).
2) Triangular or Bartlett window:
Triangular window is otherwise known as Bartlett window. The first side-lobe
is 25 dB lower than the main lobe. Main lobe width is 8/N and minimum stop band
attenuation is 25 dB. For N even, the window function is given by
=
2

; 0 /2
2
2

2
1


For N odd, the window function is given by
=
2

; 0 ( 3)/2
2
2( )

;
1
2
1


The matlab function used for implementing this window is bartlett(N).
3) Hanning window
This is a raised cosine window which multiplies the central Fourier coefficients
by approximately unity and smoothly truncates the Fourier coefficients toward the end
of the filter. The first side-lobe is 31 dB lower than the main lobe. Main lobe width is
8/N and minimum stop band attenuation is 44 dB. The window function is given by
=
0.51 +
2
1
; 0 1
0 ;


The matlab function used for implementing this window is hann(N).
4) Hamming window:
This is also raised cosine window which multiplies the central Fourier
coefficients by approximately unity and smoothly truncates the Fourier coefficients
toward the end of the filter. The first side-lobe is 41 dB lower than the main lobe. Main
lobe width is 8/N and minimum stop band attenuation is 53 dB. The window function
is given by
=
0.54 +0.46
2
1
; 0 1
0 ;


The matlab function used for implementing this window is hamm(N).
5) Blackmann window
The first side-lobe is 57 dB lower than the main lobe. Main lobe width is 12/N
and minimum stop band attenuation is 74 dB. The additional cosine term reduces the
sidelobes.
=
0.42 +0.5
2
1
+ 0.08
4
1
; 0 1
0 ;


The matlab function used for implementing this window is blackmann(N).
6) Kaiser window
The Kaiser window is an approximation to the prolate-spheroidal window, for
which the ratio of the main-lobe energy to the side-lobe energy is maximized. For a
Kaiser window of a particular length, the parameter controls the side-lobe height. For
a given , the side-lobe height is fixed with respect to window length. The window
function is given by
=

1
2
1

;
1
2
0 ;


Where is the adjustable parameter and
0
is the modified zeroth order Bessel
function of the first kind given by

0
= 1 +
1
!

=1

The matlab function used for implementing this window is kaiser(N,beta). The above
command computes an N
th
order Kaiser window with parameter beta.

Algorithm:

Generation of filter coefficients
Step 1: reset the registers and files
Step 2: enter values of ripples in the passband and stopband and the cut-off frequencies.
Step 3: implement the desired frequency response of the filter.
Step 4: implement the window function
Step 5: determine the filter coefficients by multiplying the desired response with the
window function
Step 6: plot the magnitude and phase responses of LPF, HPF, BPF and BSF

Program:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% FIR filterusing variouswindow functions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear all
close all
N=input('Enter the order: ');
rp=input('Enter passband ripple: ');
rs=input('Enter stopband ripple: ');
wc=input('Enter the cut-off frequency of LPF & HPF: ');
wc1=input('Enter first cut-off frequency in radians: ');
wc2=input('Enter second cut-off frequency in radians: ');
w=0:.01:pi;
n=0:N-1;
a=1;
alpha=(N-1)/2;
eps=10^-6;
wn=rectwin(N); % rectangular window
% wn=bartlett(N); % triangular or bartlett window
% wn=hann(N); % hanning window
% wn=hamming(N); % hamming window
% wn=blackmann(N); % blackmann window
% wn=kaiser(N); % kaiser window

% LPF
hd=sin(wc*(n-alpha+eps))./(pi*(n-alpha+eps));
b1=hd.*wn';
[h1,om1]=freqz(b1,a,w);
m1=20*log10(abs(h1));
an1=angle(h1);
subplot(221);
plot(om1/pi,m1);
title('MAGNITUDE RESPONSE OF LPF');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(222);
plot(om1/pi,an1);
title('PHASE RESPONSE OF LPF');
xlabel('normalized frequency --> ');
ylabel('phase in radians -- >');

% HPF
hd=(sin(pi*(n-alpha+eps))-sin(wc*(n-alpha+eps)))./(pi*(n-
alpha+eps));
b1=hd.*wn';
[h1,om1]=freqz(b1,a,w);
m1=20*log10(abs(h1));
an1=angle(h1);
subplot(223);
plot(om1/pi,m1);
title('MAGNITUDE RESPONSE OF HPF');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(224);
plot(om1/pi,an1);
title('PHASE RESPONSE OF HPF');
xlabel('normalized frequency --> ');
ylabel('phase in radians -- >');

% BPF
hd=(sin(wc2*(n-alpha+eps))-sin(wc1*(n-alpha+eps)))./(pi*(n-
alpha+eps));
b1=hd.*wn';
[h1,om1]=freqz(b1,a,w);
m1=20*log10(abs(h1));
an1=angle(h1);
figure
subplot(221);
plot(om1/pi,m1);
title('MAGNITUDE RESPONSE OF BPF');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(222);
plot(om1/pi,an1);
title('PHASE RESPONSE OF BPF');
xlabel('normalized frequency --> ');
ylabel('phase in radians -- >');

% BPF
hd=(sin(pi*(n-alpha+eps))-sin(wc2*(n-alpha+eps))+sin(wc1*(n-
alpha+eps)))./(pi*(n-alpha+eps));
b1=hd.*wn';
[h1,om1]=freqz(b1,a,w);
m1=20*log10(abs(h1));
an1=angle(h1);
subplot(223);
plot(om1/pi,m1);
title('MAGNITUDE RESPONSE OF BSF');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(224);
plot(om1/pi,an1);
title('PHASE RESPONSE OF BSF');
xlabel('normalized frequency --> ');
ylabel('phase in radians -- >');

Output:
Enter the order: 25
Enter passband ripple: 10
Enter stopband ripple: 20
Enter the cut-off frequency of LPF & HPF: pi/2
Enter first cut-off frequency in radians: pi/4
Enter second cut-off frequency in radians: 3*pi/4







Graph using rectangular window:


0 0.5 1
-100
-50
0
50
MAGNITUDE RESPONSE OF LPF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF LPF
normalized frequency -->
p
h
a
s
e

i
n

r
a
d
i
a
n
s

-
-

>
0 0.5 1
-150
-100
-50
0
50
MAGNITUDE RESPONSE OF HPF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF HPF
normalized frequency -->
p
h
a
s
e

i
n

r
a
d
i
a
n
s

-
-

>
0 0.5 1
-100
-50
0
50
MAGNITUDE RESPONSE OF BPF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF BPF
normalized frequency -->
p
h
a
s
e

i
n

r
a
d
i
a
n
s

-
-

>
0 0.5 1
-100
-50
0
50
MAGNITUDE RESPONSE OF BSF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF BSF
normalized frequency -->
p
h
a
s
e

i
n

r
a
d
i
a
n
s

-
-

>
Graph using rectangular window:


0 0.5 1
-100
-50
0
50
MAGNITUDE RESPONSE OF LPF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF LPF
normalized frequency -->
p
h
a
s
e

i
n

r
a
d
i
a
n
s

-
-

>
0 0.5 1
-100
-50
0
50
MAGNITUDE RESPONSE OF HPF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF HPF
normalized frequency -->
p
h
a
s
e

i
n

r
a
d
i
a
n
s

-
-

>
0 0.5 1
-100
-50
0
50
MAGNITUDE RESPONSE OF BPF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF BPF
normalized frequency -->
p
h
a
s
e

i
n

r
a
d
i
a
n
s

-
-

>
0 0.5 1
-100
-50
0
50
MAGNITUDE RESPONSE OF BSF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF BSF
normalized frequency -->
p
h
a
s
e

i
n

r
a
d
i
a
n
s

-
-

>
Experiment No.12b

EQUIRIPPLE FIR FILTER

Aim:
To write matlab programs for the following equiripple FIR digital filters
Equiripple low pass filter
Equiripple high pass filter
Equiripple band pass filter
Equiripple band stop filter

Theory:

Equiripple filter designs minimize the maximum ripple in the passbands and stopbands.
firpm() designs a linear-phase FIR filter using the Parks-McClellan algorithm. The Parks-
McClellan algorithm uses the Remez exchange algorithm and Chebyshev approximation
theory to design filters with an optimal fit between the desired and actual frequency responses.
The filters are optimal in the sense that the maximum error between the desired frequency
response and the actual frequency response is minimized. Filters designed this way exhibit an
equiripple behavior in their frequency responses and are sometimes called equiripple filters.
firpm() exhibits discontinuities at the head and tail of its impulse response due to this
equiripple nature.

Algorithm:

Generation of filter coefficients
Step 1: reset the registers and files
Step 2: enter values of ripples in the passband and stopband and the cut-off frequencies.
Step 3: determine the deviations in pass band and stop band.
Step 4: determine the order using the inbuilt function
Step 5: determine the filter coefficients.
Step 6: plot the magnitude and phase responses of LPF, HPF, BPF and BSF

Program:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% FIR Filter Design-Equiripple Linear Phase for BPF
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear all
close all
rp=input('Enter passband ripple: ');
rs=input('Enter stopband ripple: ');
fs1=input('Enter first stopband freq in hz: ');
fp1=input('Enter first passband freq in hz: ');
fp2=input('Enter second passband freq in hz: ');
fs2=input('Enter second stopband freq in hz: ');
fs=input('Enter sampling freq in hz: ');
w=0:.01:pi;
dp=(10^(rp/20)-1)/(10^(rp/20)+1); % pass band deviation
ds=10^(-rs/20); % stop band deviation

% LPF
dev=[dp ds]; % deviation vector
a=[1 0]; % desired amplitudes
f=[fp2 fs2]; % frequency vector
[n1,fo1,ao1,w1]=firpmord(f,a,dev,fs);
b1=firpm(n1,fo1,ao1,w1);
[h1,om1]=freqz(b1,1,w);
m1=20*log10(abs(h1));
an1=angle(h1);
subplot(421);
plot(om1/pi,m1);
title('MAGNITUDE RESPONSE');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(422);
plot(om1/pi,an1);
title('PHASE RESPONSE');
xlabel('normalised freq');
ylabel('phase in rad');

% HPF
dev=[ds dp]; % deviation vector
a=[0 1]; % desired amplitudes
f=[fs1 fp1]; % frequency vector
[n2,fo2,ao2,w2]=firpmord(f,a,dev,fs);
b2=firpm(n2,fo2,ao2,w2);
[h2,om2]=freqz(b2,1,w);
m2=20*log10(abs(h2));
an2=angle(h2);
subplot(423);
plot(om2/pi,m2);
title('MAGNITUDE RESPONSE');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(424);
plot(om2/pi,an2);
title('PHASE RESPONSE');
xlabel('normalised freq');
ylabel('phase in rad');

% BPF
dev=[ds dp ds]; % deviation vector
a=[0 1 0]; % desired amplitudes
f=[fs1 fp1 fp2 fs2]; % frequency vector
[n3,fo3,ao3,w3]=firpmord(f,a,dev,fs);
b3=firpm(n3,fo3,ao3,w3);
[h3,om3]=freqz(b3,1,w);
m3=20*log10(abs(h3));
an3=angle(h3);
subplot(425);
plot(om3/pi,m3);
title('MAGNITUDE RESPONSE');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(426);
plot(om3/pi,an3);
title('PHASE RESPONSE');
xlabel('normalised freq');
ylabel('phase in rad');

% BSF
dev=[dp ds dp]; % deviation vector
a=[1 0 1]; % desired amplitudes
f=[fs1 fp1 fp2 fs2]; % frequency vector
[n4,fo4,ao4,w4]=firpmord(f,a,dev,fs);
b4=firpm(n4,fo4,ao4,w4);
[h4,om4]=freqz(b4,1,w);
m4=20*log10(abs(h4));
an4=angle(h4);
subplot(427);
plot(om4/pi,m4);
title('MAGNITUDE RESPONSE');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(428);
plot(om4/pi,an4);
title('PHASE RESPONSE');
xlabel('normalised freq');
ylabel('phase in rad');

Output:
Enter passband ripple: 5
Enter stopband ripple: 20
Enter first stopband freq in hz: 300
Enter first passband freq in hz: 400
Enter second passband freq in hz: 1000
Enter second stopband freq in hz: 1100
Enter sampling freq in hz: 2500

Graph:


0 0.5 1
-60
-40
-20
0
20
MAGNITUDE RESPONSE
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE
normalised freq
p
h
a
s
e

i
n

r
a
d
0 0.5 1
-60
-40
-20
0
20
MAGNITUDE RESPONSE
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE
normalised freq
p
h
a
s
e

i
n

r
a
d
0 0.5 1
-100
-50
0
50
MAGNITUDE RESPONSE
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE
normalised freq
p
h
a
s
e

i
n

r
a
d
0 0.5 1
-100
-50
0
50
MAGNITUDE RESPONSE
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE
normalised freq
p
h
a
s
e

i
n

r
a
d
Experiment No.12c

FIR FILTER DESIGN-FREQUENCY SAMPLING METHOD

Aim:
To write matlab programs for the following FIR filters using frequency sampling
method
Low pass filter
High pass filter
Band pass filter
Band stop filter

Theory:

The frequency-sampling method for FIR filter design is perhaps the simplest and most
direct technique imaginable when a desired frequency response has been specified. It consists
simply of uniformly sampling the desired frequency response in the interval (0, 2) and
performing the inverse DFT to obtain the corresponding finite impulse response. The main
merits of frequency sampling technique are unlike the window method, this technique can be
used for any given magnitude response and it is useful for the design of non-prototype filters
where the desired magnitude response can take any irregular shape.

Algorithm:

Generation of filter coefficients
Step 1: reset the registers and files
Step 2: enter values of ripples in the passband and stopband and the cut-off frequencies.
Step 3: determine the frequency vector
Step 4: determine the magnitude of the desired filters in pass band and stop band.
Step 5: determine the filter coefficients by using the inbuilt function fir2( )
Step 6: plot the magnitude and phase responses of LPF, HPF, BPF and BSF

Program:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% FIR Filter Design-Frequency sampling method (LPF)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear all
close all

% fir2() is used for designing the FIR filter using frequency
sampling method.

wc=input('Enter the cut-off frequency: '); % frequency in hertz
wc1=input('Enter the lower cut-off frequency: '); % frequency in
hertz
wc2=input('Enter the higher cut-off frequency: '); % frequency in
hertz
N=input('Enter the order: '); % you can also find out the order by
using firpmord().
f1=2*pi*(0:N-1)./N; % frequency vector for finding out the samples.
f=f1/max(f1); % normalizing the frequency vector
a=1;
w=0:.01:pi;

% Low Pass Filter
for i=1:N
if f1(i)<=wc
m_l(i)=1;
else
m_l(i)=0;
end
end
b_l=fir2(N,f,m_l);
[h1,om1]=freqz(b_l,a,w);
m1=20*log10(abs(h1));
an1=angle(h1);
subplot(221);
plot(om1/pi,m1);
grid on
title('MAGNITUDE RESPONSE OF LPF');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(222);
plot(om1/pi,an1);
grid on
title('PHASE RESPONSE OF LPF');
xlabel('normalized frequency --> ');
ylabel('phase in rad -->');

% High Pass Filter
for i=1:N
if f1(i)>=wc
m_h(i)=1;
else
m_h(i)=0;
end
end
b_h=fir2(N,f,m_h);
[h2,om2]=freqz(b_h,a,w);
m2=20*log10(abs(h2));
an2=angle(h2);
subplot(223);
plot(om2/pi,m2);
grid on
title('MAGNITUDE RESPONSE OF HPF');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(224);
plot(om2/pi,an2);
grid on
title('PHASE RESPONSE OF HPF');
xlabel('normalized frequency --> ');
ylabel('phase in rad -->');

% Band Pass Filter
for i=1:N
if f1(i)<=wc1 || f1(i)>=wc2
m_p(i)=0;
else
m_p(i)=1;
end
end
b_p=fir2(N,f,m_p);
[h3,om3]=freqz(b_p,a,w);
m3=20*log10(abs(h3));
an3=angle(h3);
figure
subplot(221);
plot(om3/pi,m3);
grid on
title('MAGNITUDE RESPONSE OF BPF');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(222);
plot(om3/pi,an3);
grid on
title('PHASE RESPONSE OF BPF');
xlabel('normalized frequency --> ');
ylabel('phase in rad -->');

% Band Stop Filter
for i=1:N
if f1(i)<=wc1 || f1(i)>=wc2
m_s(i)=1;
else
m_s(i)=0;
end
end
b_s=fir2(N,f,m_s);
[h4,om4]=freqz(b_s,a,w);
a=[1 0 1]; % desired amplitudes
m4=20*log10(abs(h4));
an4=angle(h4);
subplot(223);
plot(om4/pi,m4);
grid on
title('MAGNITUDE RESPONSE OF BSF');
xlabel('normalized frequency --> ');
ylabel('Gain in db -->');
subplot(224);
plot(om4/pi,an4);
grid on
title('PHASE RESPONSE OF BSF');
xlabel('normalized frequency --> ');
ylabel('phase in rad -->');

Output:
Enter the cut-off frequency: pi/3
Enter the lower cut-off frequency: pi/2
Enter the higher cut-off frequency: 6*pi/4
Enter the order: 30

Graph:

0 0.5 1
-150
-100
-50
0
50
MAGNITUDE RESPONSE OF LPF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF LPF
normalized frequency -->
p
h
a
s
e

i
n

r
a
d

-
-
>
0 0.5 1
-100
-50
0
50
MAGNITUDE RESPONSE OF HPF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF HPF
normalized frequency -->
p
h
a
s
e

i
n

r
a
d

-
-
>



















0 0.5 1
-150
-100
-50
0
50
MAGNITUDE RESPONSE OF BPF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF BPF
normalized frequency -->
p
h
a
s
e

i
n

r
a
d

-
-
>
0 0.5 1
-150
-100
-50
0
50
MAGNITUDE RESPONSE OF BSF
normalized frequency -->
G
a
i
n

i
n

d
b

-
-
>
0 0.5 1
-4
-2
0
2
4
PHASE RESPONSE OF BSF
normalized frequency -->
p
h
a
s
e

i
n

r
a
d

-
-
>
Experiment No.13

RANDOM SEQUENCE GENERATOR

Aim:
To write matlab program for generating random sequences like Gaussian, Rayleigh,
Unform, etc.

Theory:
Noise appears as random in nature. But we need to generate random sequences for
some applications. Different functions used for generating random sequences are randint( ),
rand( ), randn( ), randperm( ), etc. randint( ) function is used for generating an array of random
integers within a certain interval. rand( ) returns a pseudorandom, scalar value drawn from a
uniform distribution on the unit interval.randn( ) returns a pseudorandom, scalar value drawn
from a normal distribution with mean 0 and standard deviation 1. randperm(n) returns a
random permutation of the integers 1:n.

Program:

%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Random sequence generator
%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear all
close all
y1=randint(1,10,[2,10]); %output is an array of random integers
y2=randperm(14); %output is an array of random integers
y3=rand(1,10);
y4=randn(1,10);
subplot(221);
stem(y1);
title('RANDOM SEQUENCE HAVING ONLY INTEGERS IN THE INTERVAL
(2,10)');
xlabel('n -->');
ylabel('amplitude');
subplot(222);
stem(y2);
title('RANDOM SEQUENCE HAVING THE PERMUTATION OF ALL NUMBERS IN THE
INTERVAL (1,14)');
xlabel('n -->');
ylabel('amplitude');
subplot(223);
stem(y3);
title('RANDOM SEQUENCE HAVING FLOATING POINT NUMBERS IN THE INTERVAL
(0,1)');
xlabel('n -->');
ylabel('amplitude');
subplot(224);
stem(y4);
title('RANDOM SEQUENCE HAVING FLOATING POINT NUMBERS IN THE INTERVAL
(-a,a)');
xlabel('n -->');
ylabel('amplitude');

Graph:

1 2 3 4 5 6 7 8 9 10
0
2
4
6
8
RANDOM SEQUENCE HAVING ONLY INTEGERS IN THE INTERVAL (2,10)
n -->
a
m
p
l
i
t
u
d
e
0 2 4 6 8 10 12 14
0
5
10
15
RANDOM SEQUENCE HAVING THE PERMUTATION OF ALL NUMBERS IN THE INTERVAL (1,14)
n -->
a
m
p
l
i
t
u
d
e


















1 2 3 4 5 6 7 8 9 10
0
0.5
1
RANDOM SEQUENCE HAVING FLOATING POINT NUMBERS IN THE INTERVAL (0,1)
n -->
a
m
p
l
i
t
u
d
e
1 2 3 4 5 6 7 8 9 10
-2
-1
0
1
2
RANDOM SEQUENCE HAVING FLOATING POINT NUMBERS IN THE INTERVAL (-a,a)
n -->
a
m
p
l
i
t
u
d
e
Experiment No.14

SAMPLING BY RATIONAL FACTOR

Aim:
To write matlab program for sampling a given signal by a rational factor.

Theory:
Sampling means the process of converting a continuous time signal to a discrete signal.
It is performed by multiplying the original signal with dirac function in the time domain. In
matlab, after interpolating the decimated version of the original sequence we will get the
sampled signal with rational factor as the sampling rate.

Program:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Sampling rate conversion by a rational factor
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear all
close all

% DOWNSAMPLING
t=0:.05:1;
f=input('Enter sig frq: ');
M=input('Enter down sampling ratio: ');
x=sin(2*pi*f*t);
subplot(221);
stem(x);
title('ORIGINAL SIGNAL');
xlabel('n -->');
ylabel('amplitude -->');
y1=x(1:M:length(x));
subplot(222);
stem(y1);
title('DOWNSAMPLED VERSION');
xlabel('n -->');
ylabel('amplitude -->');

% UPSAMPLING
L=input('Enter the up sampling ratio: ');
y2=[];
for i=1:length(x)
y2=[y2,x(i),zeros(1,L-1)];
end
subplot(223);
stem(y2);
title('UPSAMPLED VERSION');
xlabel('n -->');
ylabel('amplitude -->');

% RATIONAL SAMPLING RATE
num=input('Enter the numerator of the rational sampling rate: ');
deno=input('Enter the denominator of the rational sampling rate: ');
y3=[];
for i=1:length(x)
y3=[y3,x(i),zeros(1,num-1)];
end
y4=y3(1:deno:length(y3));
subplot(224);
stem(y4);
title('SAMPLING BY A RATIONAL FACTOR');
xlabel('n -->');
ylabel('amplitude -->');

Output:
Enter the sig frq: .5
Enter the down sampling ratio: 2
Enter the up sampling ratio: 2
Enter the numerator of the rational sampling rate: 2
Enter the denominator of the rational sampling rate: 3

Graph:

0 10 20 30
0
0.5
1
ORIGINAL SIGNAL
n -->
a
m
p
l
i
t
u
d
e

-
-
>
0 5 10 15
0
0.5
1
DOWNSAMPLED VERSION
n -->
a
m
p
l
i
t
u
d
e

-
-
>
0 20 40 60
0
0.5
1
UPSAMPLED VERSION
n -->
a
m
p
l
i
t
u
d
e

-
-
>
0 5 10 15 20
0
0.5
1
SAMPLING BY A RATIONAL FACTOR
n -->
a
m
p
l
i
t
u
d
e

-
-
>
Experiment No.15

Z - TRANSFORM

Aim:
To write matlab program for computing Z-transform.

Theory:
Z-transform is a discrete time transform technique mainly used for analyzing the
stability of a system. The system is stable only if all the poles are inside the unit circle. We can
also find out the region of convergence using the transform.

Program:

%%%%%%%%%%%%%%%%%%%%%%%
% Z-transform
%%%%%%%%%%%%%%%%%%%%%%%
clc
clear all
close all
num=input('Enter the numerator polynomial: '); % coefficient of the
numerator polynomial.
deno=input('Enter the denominator polynomial: '); % coefficient of
the denominator polynomial.
sys_z=tf(num,deno,0.1,'variable','z^-1') % system transfer function
in z-domain
% if deno=[1], then sys_z gives the z-transform of the sequence
defined by the numerator.
% if the transfer function is given, the numerator and denominator
coefficients can be find out using the function:
% [num,deno,Ts]=tfdata(sys)
[z_z,p_z,k_z] = zpkdata(sys_z,'v');
zplane(z_z,p_z)
title('POLE-ZERO MAP');

Output:
Enter the numerator polynomial: [1 2 3 2]
Enter the denominator polynomial: [1 2 3 2 1]

Transfer function:
1 + 2 z^-1 + 3 z^-2 + 2 z^-3
-----------------------------------
1 + 2 z^-1 + 3 z^-2 + 2 z^-3 + z^-4

Sampling time: 0.1
Graph:














-1.5 -1 -0.5 0 0.5 1 1.5
-1
-0.5
0
0.5
1
2
2
Real Part
I
m
a
g
i
n
a
r
y

P
a
r
t
POLE-ZERO MAP










ASSEMBLY LANGUAGE PROGRAMMING

C PROGRAMMING

(DSP starter kit)

Experiment No. 16

FAMILIARIZATION WITH DSP KIT

DSP STARTER KIT

The Code Composer Studio
TM
IDE is a development environment that tightly integrates
the tools needed to create winning DSP applications. It is designed for the Texas Instruments
(TI) high performance TMS320C6000 (C6000) and digital signal processor (DSP) platforms.

The Key components of the Code Composer Studio IDE include:

o Tuning tools for optimizing applications
o C/C++ Compiler, Assembly Optimizer and Linker (Code Generation Tools)
o Real-Time Operating System (DSP/BIOS )
o Ability to dynamically connect and disconnect from targets
o Real-Time Data Exchange between host and target (RTDX )
o Update Advisor
o Instruction Set Simulator
o Advanced Event Triggering
o Data Visualization
The Code Composer Studio IDE Version 3.0 (Tuning Edition) integrates all host and
target tools in a unified environment. It also simplifies DSP system configuration and
application design to help designers get started faster than ever before.

The Code Composer Studio IDE, an integral component of TI.s software strategy,
includes the features necessary to take you through each step of the application development
flow. All of these features are provided in an integrated product allowing developers to focus
their energy on innovation.

Code Composer Studio Setup is a utility that is used to define the target board or
simulator the user will use with the Code Composer Studio IDE. This information is called the
system configuration and consists of a device driver that handles communication with the
target plus other information and files that describe the characteristics of your target, such as
the default memory map. The Code Composer Studio IDE needs this information to establish
communication with your target system and to determine which tools are applicable for the
given target.

As DSP applications become more complex, it is important to structure them in an
efficient, maintainable manner. This requires use of a real-time kernel that enables system
functions to be allocated to different threads. The DSP/BIOS kernel provides an efficient set of
kernel, real-time analysis, and peripheral configuration services, eliminating the need to
develop and maintain custom DSP operating systems. DSP/BIOS is an integral part of the
Code Composer Studio IDE. The kernel object browser displays the state of operating system
objects (such as tasks and semaphores), and provides data on stack usage and stack
overflow/underflow. Thesecapabilities make it easier to debug applications and optimize usage
of OS and systemresources. DSP/BIOS consists of four parts: a real-time kernel, real-time
analysis services, peripheral configuration libraries, and a graphical configuration tool.For each
supported processor, DSP/BIOS includes a set of peripheral management functions and macros
known as the Chip Support Library (CSL). The CSL supports on-chip peripherals for all
TMS320C5000 and TMS320C6000 devices and is fully integrated into the DSP/BIOS
Configuration tool. The CSL supports both graphical and programmatic peripheral
configuration and control, eliminating the need to remember individual register flags settings
or painstakingly calculate bitmaps.

Code Composer Studio IDEs open plug-in architecture (called TMS320 DSP
Algorithm Standard or XDAIS) reduces time-consuming system integration for anyone
trying to include algorithms into their DSP system. XDAIS defines common programming
rules and guidelines with a set of programming interfaces that are used consistently by
algorithms across a wide variety of applications.

Source Code Editor
The Code Composer Studio IDE includes fully integrated code editing environment
tuned for writing C, C++ and DSP assembly code. The editor provides standard editing
features such as: keyword highlighting, printing, cut and paste, drag and drop, etc. The
maximum number of lines per file is 2,147,483,648 and the maximum number of characters
per line is 3500.

The Code Composer Studio compile tools shifts the burden of optimization from hand-coded
assembly to the C Compiler. With these tools it is possible to exploit the high performance of
TIs DSP platforms without ever writing hand-coded assembly.

Debugger
The Code Composer Studio debugger makes it easy to find and fix errors in realtime
embedded applications. For example, debugger commands enable you to control program
execution. Debugger windows and dialogs allow you to view source code and track the values
of program variables in memory and registers. Breakpoints enable you to stop execution at a
specified location and examine the current state of the program.

Real-Time Data Exchange (RTDX)
RTDX allows designers to monitor continuously their systems and gain realtime
insights into running applications. It also allows data to be streamed with ActiveXcompliant
application such as Excel, LabVIEW or MATLAB. When displaying RTDX data, host
applications can read either live or saved data. The IDE also supports RTDX with multiple
processors on either the same or different scan paths.

Application Code Tuning
The Code Composer Studio IDE now offers a series of tools (called Tuning Tools) to
help developers to optimize applications. These tools allow users to set goals and track
progress towards goals by collecting different sets of data. A new Advice Window provides
on-the-fly recommendations about how to make code meet user goals.
The IDE has two Layouts, (tuning layout and standard layout), which can be toggled from the
main toolbar. Standard layout is the default, while tuning layout (represented by a tuning fork
icon on the toolbar) opens advice windows on the left side. The tuning layout focuses attention
on the optimization needs of the user.s program. The advice window walks the user through the
optimization/tuning process specific to the DSP device and a selected goal.

Data Visualization
Code Composer Studio IDE incorporates an advanced signal analysis interface that
enables developers to monitor signal data critically and thoroughly. The new features are
useful in developing applications for communications, wireless, and image processing, as well
as general DSP applications. Time/frequency, Constellation plot, Eye diagram, Image display
etc are the various graphs that can be drawn.

Real-Time Analysis
Real-time analysis tools help developers to see time-related interactions between code
sections. They can reveal subtle real-time problems that otherwise might go undetected. Code
Composer Studio IDE allows developers to probe, trace and monitor a DSP application while it
runs. Even after the program has halted, information already captured through real-time
analysis tools can provide invaluable insight into the sequence of events that led up to the
current point of execution.

General Extension Language (GEL)
The General Extension Language (GEL) is an interpretive language similar to C that
lets you create functions to extend Code Composer Studio IDEs usefulness. After creating
GEL functions using the GEL grammar, you can load them into Code Composer Studio IDE.
With GEL, you can access actual/simulated target memory locations and add options to the
IDEs GEL menu. GEL is particularly useful for automated testing.

CONCLUSION
Code Composer Studio IDE v3.0 represents the evolution of the DSP development
environment. It contains functionality needed by todays larger, distributed, global project
teams. By reducing time spent on repetitive tasks and tool development, the IDE gives the
developer more time to focus on innovation.

SOFTWARE DEVELOPMENT FLOW IN TMS PROCESSORS




Tools Descriptions
The following list describes the tools that are shown in Figure 1-1:
The C/C++ compiler translates C/C++ source code into assembly language source
code. The compiler package includes the library-buildutility, with which you can
build your own runtime libraries.
The assembler translates assembly language source files into machine language COFF
object files. Source files can contain instructions, assembler directives, and macro
directives. You can use assembler directives to control various aspects of the assembly
process, such as the source listing format, data alignment, and section content.The
assembler translates assembly language source files into machine language COFF
object files. The TMS320C54x,55x tools include two assemblers. The mnemonic
assembler accepts mnemonic assembly source files. The algebraic assembler accepts
algebraic assembly source files. Source files can contain instructions, assembler
directives, and macro directives. You can use assembler directives to control various
aspects of the assembly process, such as the source listing format, data alignment, and
section content.
The linker combines relocatable COFF object files (created by the assembler) into a
single executable COFF object module. As it creates the executable module, it binds
symbols to memory locations and resolves all references to those symbols. It also
accepts archiver library members and output modules created by a previous linker run.
Linker directives allow you to combine object file sections, bind sections or symbols to
addresses or within memory ranges, and define or redefine global symbols.
The archiver collects a group of files into a single archive file. For example, you can
collect several macros into a macro library. The assembler searches the library and uses
the members that are called as macros by the source file. You can also use the archiver
to collect a group of object files into an object library. The linker includes in the library
the members that resolve external references during the link.
The mnemonic-to-algebraic assembly translator utility converts an assembly
language source file containing mnemonic instructions to an assembly language source
file containing algebraic instructions.
The library-build utility builds your own customized C/C++ runtime-support library.
Standard runtime-support library functions are provided as source code in rts.src and as
object code in rts.lib.
The TMS320C54x,55x Code Composer Studio debugger accepts COFF files as input,
but most EPROM programmers do not.
The hex conversion utility converts a COFF object file into TI-tagged, Intel, Motorola,
or Tektronixobject format. The converted file can be downloaded to an
EPROMprogrammer.
The absolute lister accepts linked object files as input and creates .abs files as output.
You assemble .abs files to produce a listing that contains absolute rather than relative
addresses. Without the absolute lister, producing such a listing would be tedious and
require many manual operations.
The cross-reference lister uses object files to produce a cross-reference listing
showing symbols, their definitions, and their references in the linked source files.
The COFF disassembler(only in c55x) accepts object files and executable files as input
and produces an assembly listing as output. This listing shows assembly instructions,
their opcodes, and the section program counter values. The disassembly listing is useful
for viewing the:
Assembly instructions and their size
Encoding of assembly instructions
Output of a linked executable file
The object file display utility prints the contents of object files, executable files, and/or
archive libraries in both human readable and XML formats.
The name utility (only in c55x) prints a list of names defined and referenced in a
COFF object or an executable file.
The strip utility removes symbol table and debugging information from object and
executable files.
The purpose of this development process is to produce a module that can be executed in a
C54x target system. You can use one of several debugging tools to refine and correct your code.
Available products include:
An instruction-accurate software simulator
An evaluation module (EVM)
An XDS emulator
These debugging tools are accessed within Code Composer Studio.
TMS 320 DSP PROCESSORS

TMS320DSP family consists of fixed-point, floating-point, and multiprocessor digital
signal processors (DSPs). The TMS320 DSP architecture is designed specifically for real-time
signal processing. The following characteristics make this family the ideal choice for a wide
range of processing applications:
-Very flexible instruction set
-Inherent operational flexibility
-High-speed performance
-Innovative parallel architecture
-Cost-effectiveness
-C-friendly architecture

Today, the TMS320 DSP family consists of three supported DSP platforms:
TMS320C2000, TMS320C5000, and TMS320C6000. Within the C5000 DSP platform
there are three generations, the TMS320C5x, TMS320C54x, and TMS320C55x.

The C54x DSP has a high degree of operational flexibility and speed. It combines an
advanced modified Harvard architecture (with one program memory bus, three data memory
buses, and four address buses), a CPU with application-specific hardware logic, on-chip
memory, on-chip peripherals, and a highly specialized instruction set. Spinoff devices that
combine the C54x CPU with customized on-chip memory and peripheral configurations have
been, and continue to be, developed for specialized areas of the electronics market.

The C54x devices offer these advantages:
Enhanced Harvard architecture built around one program bus, three data buses, and
four address buses for increased performance and versatility
Advanced CPU design with a high degree of parallelism and application specific
hardware logic for increased performance
A highly specialized instruction set for faster algorithms and for optimized high-level
language operation
Modular architecture design for fast development of spinoff devices
Advanced IC processing technology for increased performance and low power
consumption
Low power consumption and increased radiation hardness because of new static design
techniques

1.3 TMS320C54x DSP Key Features
This section lists the key features of the C54x DSPs.
CPU
Advanced multi-bus architecture with one program bus, three databuses, and four
address buses
40-bit arithmetic logic unit (ALU), including a 40-bit barrel shifter and two
independent 40-bit accumulators
17-bit x 17-bit parallel multiplier coupled to a 40-bit dedicated adder for nonpipelined
single-cycle multiply/accumulate (MAC) operation
Compare, select, store unit (CSSU) for the add/compare selection of the Viterbi
operator
Exponent encoder to compute the exponent of a 40-bit accumulator value in a single
cycle
Two address generators, including eight auxiliary registers and two auxiliary register
arithmetic units
Multiple-CPU/core architecture on some devices
Memory
192K words x 16-bit addressable memory space (64K-words program, 64K-words
data, and 64K-words I/O), with extended program memory in the C548, C549, C5402,
C5410, and C5420.
Instruction set
Single-instruction repeat and block repeat operations
Block memory move instructions for better program and data management
Instructions with a 32-bit long operand
Instructions with 2- or 3-operand simultaneous reads
Arithmetic instructions with parallel store and parallel load
Conditional-store instructions
Fast return from interrupt
On-chip peripherals
Software-programmable wait-state generator
Programmable bank-switching logic
On-chip phase-locked loop (PLL) clock generator with internal oscillator or external
clock source. With the external clock source, there are several multiplier values
available from one of the device

Speed: 25/20/15/12.5/10-ns execution time for a single-cycle, fixed-pointb instruction (40
MIPS/50 MIPS/66 MIPS/80 MIPS/100 MIPS):
Power
Power consumption control with IDLE 1, IDLE 2, and IDLE 3 instructions for power-
down modes
Control to disable the CLKOUT signal
Emulation: IEEE Standard 1149.1 boundary scan logic interfaced to on-chip scan-based
emulation logic

Introduction to the TMS320C55x
The TMS320C55x digital signal processor (DSP) represents the latest generation
of C5000 DSPs from Texas Instruments. The C55x is built on the proven legacy of the C54x
and is source code compatible with the C54x, protecting the customers software investment.
Following the trends set by theC54x, the C55x is optimized for power efficiency, low system
cost, and best-in-class performance for tight power budgets. The TMS320C55x is a low-power,
general-purpose signal processing architecture with an instruction set optimized for efficiency,
ease of use, and compactness. Although the C55x instruction set is much more powerful and
flexible than that of previous generations, the architecture is completely compatible with
TMS320C54x instructions. This allows programs developed on the C54x to be re-assembled
and executed on the C55x with bit-exact results. A highly parallel architecture complements
the C55x instruction set
and enables increased code density while reducing the number of cycles required per operation.
The union of an efficient, compact instruction set with a highly parallel architecture provides a
high-performance signal processing engine while minimizing code size and power
consumption.

The key features of TMS320C55x are
A 32 x 16-bit Instruction buffer queue
Two 17-bit x17-bit MAC units
One 40-bit ALU
One 40-bit Barrel Shifter
One 16-bit ALU
Four 40-bit accumulators
Twelve independent buses:
Three data read buses
Two data write buses
Five data address buses
One program read bus
One program address bus
User-configurable IDLE Domains

The TMS320C6000 digital signal processor (DSP) platform is part of the
TMS320 DSP family. The TMS320C62xx DSP generation and the TMS320C64x DSP
generation comprise fixed-point devices in the C6000 DSP platform, and the
TMS320C67x DSP generation comprises floating point devices in the C6000 DSP platform.
The TMS320C62x and TMS320C64x DSPs are code-compatible. The TMS320C62x and
TMS320C67x DSPs are code-compatible. All three use the VelociTI architecture, a high-
performance, advanced VLIW (very long instruction word) architecture, making these DSPs
excellent choices for multichannel and multifunction applications.

1-5 Introduction
The C6000 devices execute up to eight 32-bit instructions per cycle. The C62x/C67x
devices core CPU consists of 32 general-purpose registers of 32-bit word length and eight
functional units. The C64x core CPU consists of 64 general-purpose 32-bit registers and eight
functional units. These eight functional units contain:
Two multipliers
Six ALUs
The C6000 generation has a complete set of optimized development tools, including an
efficient C compiler, an assembly optimizer for simplified assembly language programming
and scheduling, and a Windows based debugger interface for visibility into source code
execution characteristics. A hardware emulation board, compatible with the TI
XDS510 emulator interface, is also available. This tool complies with IEEE Standard 1149.1
1990, IEEEStandardTestAccessPort and Boundary-Scan Architecture.
Features of the C6000 devices include:
Advanced VLIW CPU with eight functional units, including two multipliers and six
arithmetic units
Executes up to eight instructions per cycle for up to ten times the performance of
typical DSPs
Allows designers to develop highly effective RISC-like code for fast development time
Instruction packing
Gives code size equivalence for eight instructions executed serially or in parallel
Reduces code size, program fetches, and power consumption
Conditional execution of all instructions
Reduces costly branching
Increases parallelism for higher sustained performance
Efficient code execution on independent functional units
Industrys most efficient C compiler on DSP benchmark suite
Industrys first assembly optimizer for fast development and improved parallelization
8/16/32-bit data support, providing efficient memory support for a varietyof
applications
40-bit arithmetic options add extra precision for vocoders and other computationally
intensive applications
Features and Options of the TMS320C62x/C64x/C67x
Saturation and normalization provide support for key arithmetic operations
Field manipulation and instruction extract, set, clear, and bit counting support common
operation found in control and data manipulation applications.
The C67x has these additional features:
Hardware support for single-precision (32-bit) and double-precision (64-bit) IEEE
floating-point operations
32 x 32-bit integer multiply with 32- or 64-bit result.
The C64x additional features include:
Each multiplier can perform two 16 x 16-bit or four 8 x 8 bit multiplies every clock
cycle.
Quad 8-bit and dual 16-bit instruction set extensions with data flow support
Support for non-aligned 32-bit (word) and 64-bit (double word) memory accesses
Special communication-specific instructions have been added to addresscommon
operations in error-correcting codes.
Bit count and rotate hardware extends support for bit-level algorithms.









Experiment No. 17

GENERATION OF BASIC SIGNALS

Aim:
To generate impulse, step, ramp and exponential signals.

Equipments Used:
DSK TMS320C6713, CCS version, IDE version.3, Power cord, USB cable

Theory:
A signal can be used to represent any variable of interest as a function of time,
temperature, pressure etc. Signals carry some amount of information in them. One of the
methods to classify signals is on the basis of their time characteristics as
Continuous -time signals: The function is defined continuously in time.
Discrete time signals: they are defined in discrete time instants only.
Both of these signals can have any amplitude(continuous in amplitude).Digital signals have
discrete amplitude levels. A continuous time signal is called periodic if
+ = ()
Here T is called the period of the signal.The signals which do not satisfy the above conditions
are called aperiodic or non-periodic signals.An important classification of aperiodic signals is
the singularity functions. They can be used to represent more complicated signals. Delta, step,
ramp, etc are examples of such functions.

Important Basic Signals
5. I mpulse Function
In discrete domain it is defined as
=
1, = 0
0, 0

6. Step Function
The discrete-time unit step function is defined as
=
1, 0
0, < 0

7. Ramp signal
The ramp signal can be generated from the mathematical expression
= , 0
8. Exponential signal
The exponential signal can be generated from the mathematical expression
=

, 0
0, < 0

;

In MATLAB, these functions can be generated and be displayed using stem function
Algorithm:

Generation of Impulse Waveform
Step 1: reset the registers and files
Step 2: enter the range and instant at which the impulse occur
Step 3: generate the impulse
Step 4: display the figure with suitable labels

Generation of Step function
Step 1: reset the registers and files
Step 2: enter the instant at which the step occurs
Step 3: generate the step appropriately
Step 4: display the figure with suitable labels

Generation of Ramp waveform
Step 1: reset the registers and files
Step 2: enter the range and the time of occurrence of the rectangular pulse
Step 3: generate the pulse appropriately
Step 4: display the figure with suitable labels

Generation of Exponential Waveform
Step 1: reset the registers and files
Step 2: enter the range
Step 3: generate the appropriate signal using rand function in MATLAB
Step 4: display the figure with suitable labels


Program:

# include<stdio.h>
# include<math.h>
int a[100],b[100],c[100],d[100];
void main()
{
int i;
for (i=0;i<=100;i++)
a[i]=1; //Step Signal

for (i=0;i<=100;i++)
b[i]=i; //Ramp Signal

for (i=0;i<=50;i++)
c[i]=0;
c[51]=1;
for (i=52;i<=100;i++)
c[i]=0; //Impulse Signal

for (i=0;i<=50;i++)
d[i]=0;
for (i=51;i<=100;i++)
d[i]=1; //Rectangular Pulse

}

Graphs:
Step Signal



Ramp Signal





Impulse Signal




Rectangular Pulse Signal



















Experiment No. 18

GENERATION OF PERIODIC SIGNALS

Aim:
To generate the following periodic waveforms
Sinusoidal
Square
Triangular
Ramp

Equipments Used:
DSK TMS320C6713, CCS version, IDE version.3, Power cord, USB cable

Theory:

A signal may be periodic or non-periodic. A continuous time signal is called periodic if
+ = ()
Here T is called the period of the signal.
For a discrete time signal,
+ = ()
Here N is called the sampling period.
The general expression for a continuous-time sinusoid is = ( +) where
A is the amplitude, is the frequency in radians/second and is the phase angle in radians.
This signal is always periodic and the period of this signal is defined by =
2

. The square
wave is also periodic and its duty cycle is 50% i.e., it has equal ON and OFF time in one period.
It can be generated by adding the odd harmonics of a sinusoidal signal.
A triangular wave is periodic and in one period it is defined by
=
1 ; || 1
0;


It has even symmetry. A ramp pulse does not have any symmetry. They can have rising slope
or falling slope depending on the definition.
Algorithm:
Generation of Sinusoidal signals
Step 1: reset the registers and files
Step 2: enter the frequency
Step 3: plot the signal using functions available in MATLAB
Step 4: display the figure with suitable labels

Generation of Square waveform
Step 1: reset the registers and files
Step 2: generate an appropriate square wave using function available in MATLAB
Step 3: display the figure with suitable labels
OR
Step 1: reset the registers and files
Step 2: generate a square pulse and repeat it using function available in MATLAB
Step 3: display the figure with suitable labels
OR
Step 1: reset the registers and files
Step 2: enter the frequency of sinusoidal
Step 3: enter the number of harmonics to be added
Step 4: generate the signal and add all the harmonics to the signal.
Step 5: display the figure with suitable labels

Generation of Triangular waveform
Step 1: reset the registers and files
Step 2: generate a triangular pulse using appropriate logic and repeat it using function
available in MATLAB
Step 3: display the figure with suitable labels

Generation of Ramp Waveform
Step 1: reset the registers and files
Step 2: generate a ramp pulse using appropriate logic
Step 3: display the figure with suitable labels




Program:

# include<stdio.h>
# include<math.h>
float a1[1000],a2[1000],c1[1000],d1[1000],c2[1000],d2[1000];
void main()
{
int b=5,i,j;
for(i=0;i<100;i++)
{
a1[i]=sin(2*3.14*i/100);
}
for(i=0;i<=10;i++)
{
for(j=0;j<=50;j++)
{
a2[(50*i)+j]=b;
}
b=b*(-1);
}
for(j=0;j<=10;j++)
{
c1[j]=j-5;
c1[10+j]=5-j;
}
for(i=0;i<=5;i++)
{
for(j=0;j<=20;j++)
d1[(20*i)+j]=c1[j];
}
for(j=0;j<=10;j++)
{
c2[j]=j-5;
}

for(i=0;i<=10;i++)
{
for(j=0;j<=10;j++)
d2[(11*i)+j]=c2[j];
}

}






Graphs:
Sinusoidal Waveform



Square Waveform




Triangular Waveform



Sawtooth Waveform



Experiment No. 19

GENERATION OF COMPLEX SIGNALS

Aim:
To generate the following waveforms
Amplitude Modulation
Frequency Modulation
Pulse Width Modulator

Equipments Used:
DSK TMS320C6713, CCS version, IDE version.3, Power cord, USB cable

Theory:

In modulation, a high frequency carrier signal is used to carry the message signal, also
known as the modulating signal. Amplitude Modulation and frequency modulation are two
important analog modulation systems. Amplitude modulation is the process of changing the
amplitude of the carrier wave in accordance with the amplitude of the modulating signal.
If the modulating signal is

sin


And carrier wave is

sin


Then the AM wave is defined as

(1 +sin

) sin


where, m
a
is the modulation index whose value is between 0 and 1.
Frequency modulation is the process by which the frequency of the carrier wave is altered in
accordance with the instantaneous amplitude of the modulating signal.
The FM wave is defined as

sin(

sin

)
where,

is the modulation index of FM,

is the frequency
deviation given by

.
Pulse Width Modulation (PWM) is also known as pulse duration modulation or pulse
length modulation. The message signal controls the variation of the pulse width. The message
signal may vary the trailing or leading edge of the carrier pulses in order to accommodate the
information

Equipments Used:
DSK 5416, CCS version, IDE version .3, Power cord, USB cable

Algorithm:

Generation of AM
Step 1: reset the registers and files
Step 2: enter the amplitude and frequency of the message signal and carrier signal
Step 3: generate the message and carrier signal
Step 4: generate the amplitude modulated waveform using the equation
Step 5: display the figure with suitable labels

Generation of FM
Step 1: reset the registers and files
Step 2: enter the amplitude and frequency of the message signal and carrier signal
Step 3: generate the message and carrier signal
Step 4: generate the frequency modulated waveform using the equation
Step 5: display the figure with suitable labels

Generation of PWM
Step 1: reset the registers and files
Step 2: generate a triangular waveform as carrier
Step 3: generate a sinusoidal message signal
Step 4: generate PWM waveform by comparing the two signals
Step 5: display the figure with suitable labels

Program:

# include<stdio.h>
# include<math.h>
float am[200],Fm[200],em[100],ec[100],Em,m1,m2;
int Ec,fc,fm,t,z[200],i;
void main()
{
printf(Enter the Carrier Amplitude: );
scanf(%d,&Ec);
printf(Enter the Carrier Frequency: );
scanf(%d,&fc);
printf(Enter the Modulation index of AM: );
scanf(%f,&m1);
printf(Enter the Modulation index of FM: );
scanf(%f,&m2);
printf(Enter the Modulating Frequency: );
scanf(%d,&fm);
Em=m1*Ec;
for (i=0;i<200;i++)
z[i]=0;
for (t=0;t<200;t++)
{
em[t]=Em*sin(2*3.14*fm*t);
ec[t]=Ec*sin(2*3.14*fc*t);
am[t]=Ec*sin(2*3.14*fc*t)*(1+(m1*sin(2*3.14*fm*t)));
Fm[t]=Ec*sin((2*3.14*fc*t)+(m2*sin(2*3.14*fm*t)));
if (em[t]<ec[t])
z[t]=1;
else
z[t]=0;\\PWM
}
}
Output:
Enter the Carrier Amplitude: 5
Enter the Carrier Frequency: 250
Enter the Modulation index of AM: 0.5
Enter the Modulation index of FM: 5
Enter the Modulating Frequency: 25

Graphs:

Carrier Signal


Modulating Signal






Amplitude Modulated Signal


Frequency Modulated Signal





Pulse Width Modulated Signal






















Experiment No. 20

DISCRETE FOURIER TRANSFORM (DFT) AND ITS INVERSE (IDFT)

Aim:
To write a matlab program for finding the DFT of the given sequence

Equipments Used:
DSK TMS320C6713, CCS version, IDE version.3, Power cord, USB cable

Theory:
The direct evaluation of DFT using the formula
= ()
2 /
1
=0

requires N
2
complex multiplications and N(N-1) complex additions .Thus for reasonably large
values of N direct evaluation of DFT requires an inordinate amount of computation. By using
FFT algorithms the number of computations can be reduced. For an N point DFT, the number
of complex multiplications required using FFT is N/2 log N.
The inverse DFT (IDFT) is given by
=
1

()
2 /
1
=0

Using DFT we can analyze the frequency components present in a signal.

Algorithm:

Generation of DFT
Step 1: reset the registers and files
Step 2: enter the sequence and the value of N
Step 3: Implement the equation of DFT
Step 4: display the figure

Generation of IDFT
Step 1: reset the registers and files
Step 2: enter the DFT of the sequence and the value of N
Step 3: Implement the equation of IDFT
Step 4: display the figure


Program:

#include<stdio.h>
#include<math.h>
#define pi 3.14
double a1[10],b1[10],a2[10],b2[10],X[10],y[10];
int x[10],m,i,j;
main()
{
printf("Enter the length of first sequence ");
scanf("%d",&m);

printf("Enter the sequence ");
for(i=0;i<m;i++)
scanf("%d",&x[i]);

for(i=0;i<m;i++)
{
a1[i]=0;
for(j=0;j<m;j++)
a1[i]+=x[j]*cos((2*pi*i*j)/m);
}
for(i=0;i<m;i++)
{
b1[i]=0;
for(j=0;j<m;j++)
b1[i]+=x[j]*-1*sin((2*pi*i*j)/m);
}
for(i=0;i<m;i++)
{
X[i]=sqrt((a1[i]*a1[i])+(b1[i]*b1[i]));
}
printf("The DFT is ");
for(i=0;i<m;i++)
printf("%g\n",X[i]);

for(i=0;i<m;i++)
{
a2[i]=0;
for(j=0;j<m;j++)
a2[i]+=((a1[j]*cos((2*pi*i*j)/m))-
(b1[j]*sin((2*pi*i*j)/m)));
}
for(i=0;i<m;i++)
{
b2[i]=0;
for(j=0;j<m;j++)

b2[i]+=((a1[j]*sin((2*pi*i*j)/m))+(b1[j]*cos((2*pi*i*j)/m)));
}
for(i=0;i<m;i++)
{
y[i]=sqrt((a2[i]*a2[i])+(b2[i]*b2[i]));
}
printf("The IDFT is ");
for(i=0;i<m;i++)
{
//printf("%g\n",a2[i]);
//printf("%g\n",y[i]);
printf("%g\n",y[i]/m);
}

}
Output:
Enter the length of first sequence 4
Enter the sequence 1
2
3
6
The DFT is 12
4.47356
4.00001
4.4679
The IDFT is 1.00645
1.99843
2.99682
6.00001


Graph:

























Experiment No. 21

LINEAR CONVOLUTION
Aim:
To implement linear convolution using its formula

Equipments Used:
DSK TMS320C6713, CCS version, IDE version.3, Power cord, USB cable

Theory:
The operator stands for the linear convolution operation. The convolution between
two signals x[n] and h[n] is represented symbolically as
= () ()
and is defined by
= ( )

=

It can be used to find the response of a system to any input signal. Then () represents the
input and represents the impulse response of the system.
Convolution is commutative, associative and distributive. The identity operator for convolution
is the delta function.

Algorithm:
Step 1: reset the registers and files
Step 2: enter the sequences
Step 3: find the length of the sequence
Step 4: find the length of convolved sequence
Step 5: for the length, find the sequence implementing the formula for convolution
Step 6: display the output sequence

Program:

#include<stdio.h>
int m,n,i,j,x[20],h[20],y[50];
main()
{
printf("Enter the length of first sequence");
scanf("%d",&m);
printf("Enter the length of second sequence");
scanf("%d",&n);

printf("Enter the first sequence");
for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf("Enter the second sequence");
for(j=0;j<n;j++)
scanf("%d",&h[j]);
for(i=m;i<m+n-1;i++) //remaining locations have value 0
x[i]=0;
for(j=n;j<m+n-1;j++)
h[j]=0;

for(i=0;i<m+n-1;i++)
{
y[i]=0;
for (j=0;j<=i;j++)
y[i]+=x[j]*h[i-j];
}
printf("The convolved sequence is");
for(i=0;i<m+n-2;i++)
printf("%d\n",y[i]);
}

Output:

Enter the length of first sequence 4
Enter the length of second sequence 4
Enter the first sequence 1 2 3 1
Enter the second sequence 2 5 5 4
The convolved sequence is 2
9
21
31
28
17
4













Graph:



Experiment No. 22

CIRCULAR CONVOLUTION

Aim:
To implement circular convolution using its formula

Equipments Used:
DSK TMS320C6713, CCS version, IDE version.3, Power cord, USB cable

Theory:

The operator stands for the circular convolution operation. The circular convolution
between two signals x[n] and h[n] is represented symbolically as

and is defined by

It can be used to find the response of a system to any input signal. Then x[n] represents
the input and h[n] represents the impulse response of the system.
Circular convolution is commutative, associative and distributive. The identity operator for
convolution is the delta function.

Algorithm:

Direct Implementation of formula
Step 1: reset the registers and files
Step 2: enter the sequences
Step 3: find the length of the sequence
Step 4: find the length of convolved sequence
Step 5: for the length, find the sequence implementing the formula for circular
convolution
Step 6: display the output sequence

Program:

#include <stdio.h>
int i,j,l,m,n,x[20],y[20],p[20];
main()
{
printf("Enter the length of first sequence");
scanf("%d",&m);
printf("Enter the length of second sequence");
scanf("%d",&n);
printf("Enter the first sequence");
for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf("Enter the second sequence");
for(j=0;j<n;j++)
scanf("%d",&y[j]);
if(m-n!=0)
{
if(m>n)
{
for(j=n;j<m;j++)
y[j]=0;
l=m;
}
else
{
for(i=m;i<n;i++)
x[i]=0;
l=n;
}
}
else
l=m;
for(i=0;i<20;i++)
p[i]=0;
for(i=0;i<l;i++)
{
p[i]=0;
for(j=0;j<l;j++)
{
if(i-j<0)
p[i]+=x[j]*y[l+i-j];
else
p[i]+=x[j]*y[i-j];
}
}
printf("The convolved sequence is");
for(i=0;i<l;i++)
printf("%d\n",p[i]);
}





Output:
Enter the length of first sequence 5
Enter the length of second sequence 5
Enter the first sequence 1
8
5
1
2
Enter the second sequence 4
1
1
2
3
The convolved sequence is 41
52
36
25
33

Graph:




Experiment No. 23

REAL TIME IMPLEMENTATION OF IIR FILTER

Aim:
To implement IIR filters using DSP kit

Equipments Used:
DSK TMS320C6713, CCS version, IDE version.3, Power cord, USB cable

Theory:

I I R FI LTERS:
IIR filters have infinite frequency response and nonlinear phase. The classical IIR
filters are Butterworth, Chebyshev Types I and II, elliptical and Bessel filters.

Butterworth Filter:
The Butterworth filter provides the best Taylor Series approximation to the ideal low-
pass filter response at analog frequencies = 0 and = ; for any order N, the magnitude
squared response has 2N-1 zero derivatives at these locations (maximally flat at = 0 and =
). Response is monotonic overall, decreasing smoothly from = 0 to = .| (j )| =
at =1.

Chebyshev Type1:
The Chebyshev Type I filter minimizes the absolute difference between the ideal and
actual frequency response over the entire pass-band by incorporating an equal ripple of R
p
dB
in the pass-band. Stop-band response is maximally flat. The transition from pass-band to stop-
band is more rapid than for the Butterworth filter. | (j )| = 10
Rp/20
at =1.

Chebyshev Type I I :
The Chebyshev Type II filter minimizes the absolute difference between the ideal and
actual frequency response over the entire stop-band by incorporating an equal ripple of Rs dB
in the stop-band. Pass-band response is maximally flat. The stop-band does not approach zero
as quickly as the type I filter (and does not approach zero at all for even-valued filter order n).
The absence of ripple in the pass-band, however, is often an important advantage. . | (j )| =
10
Rs/20
at =1.

Elliptical Filter:
Elliptical filters are equiripple in both the pass-band and stop-band. They generally
meet filter requirements with the lowest order of any supported filter type. Given a filter order
n, pass-band ripple R
p
in decibels, and stop-band ripple R
s
in decibels, elliptic filters minimize
transition width. | (j )| = 10
Rp/20
at =1.

Design:
The classic IIR filter design technique includes the following steps.
Find an analog low-pass filter with cutoff frequency of 1 and translate this
"prototype" filter to the desired band configuration
Transform the filter to the digital domain.
Discretize the filter.

Procedure:
1. A MATLAB program is written to design an IIR filter with the given specifications:
a. Order
b. Sampling Rate
c. Cut off Frequency
2. Compute the desired Impulse Response.
3. Connect CRO to the Socket Provided for LINE OUT.
4. Connect a Signal Generator to the LINE IN Socket.
5. Switch on the Signal Generator with a sine wave of desired frequency.
6. Now Switch on the DSK and Bring Up Code Composer Studio on the PC.
7. Create a new project with name XXXX.pjt.
8. From the File Menu new DSP/BIOS Configuration select
9. dsk6713.cdb and save it as XXXX.cdb and add it to the current project.
10. Add the given XXXX.c file to the current project which has the main function and
calls all the other necessary routines.
11. View the contents of the generated file XXXXcfg_c.c and copy the include header
file XXXXcfg.h to the XXXX.c file.
12. Add the library file dsk6713bsl.lib from the location
C:\ti\C5400\dsk6713\lib\dsk6713bsl.lib to the current project
13. Compile, Build, Load and Run the program.
14. You can notice the input signal appearing on the CRO verifying the codec
configuration.
15. You can also pass an audio input and hear the output signal through the speakers.
16. You can also vary the sampling frequency using the DSK6713_AIC23_setFreq
Function in the codec.c file and repeat the above steps.
Program:

#include "filtercfg.h"

#include "C:\CCStudio_v3.1\C6000\dsk6713\include\dsk6713.h"
#include "C:\CCStudio_v3.1\C6000\dsk6713\include\dsk6713_aic23.h"

const signed int filter_Coeff[] =
{
//12730,-12730,12730,2767,-18324,21137 /*HP 2500 */
//312,312,312,32767,-27943,24367 /*LP 800 */
//1455,1455,1455,32767,-23140,21735 /*LP 2500 */
//9268,-9268,9268,32767,-7395,18367 /*HP 4000*/
7215,-7215,7215,32767,5039,6171, /*HP 7000*/
} ;

/* Codec configuration settings */
DSK6713_AIC23_Config config = { \
0x0017, /* 0 DSK6713_AIC23_LEFTINVOL Left line input channel
volume */ \
0x0017, /* 1 DSK6713_AIC23_RIGHTINVOL Right line input channel
volume */\
0x00d8, /* 2 DSK6713_AIC23_LEFTHPVOL Left channel headphone
volume */ \
0x00d8, /* 3 DSK6713_AIC23_RIGHTHPVOL Right channel headphone
volume */ \
0x0011, /* 4 DSK6713_AIC23_ANAPATH Analog audio path control
*/ \
0x0000, /* 5 DSK6713_AIC23_DIGPATH Digital audio path control
*/ \
0x0000, /* 6 DSK6713_AIC23_POWERDOWN Power down control */
\
0x0043, /* 7 DSK6713_AIC23_DIGIF Digital audio interface
format */ \
0x0081, /* 8 DSK6713_AIC23_SAMPLERATE Sample rate control */
\
0x0001 /* 9 DSK6713_AIC23_DIGACT Digital interface
activation */ \
};

/*
* main() - Main code routine, initializes BSL and generates tone
*/
void main()
{
DSK6713_AIC23_CodecHandle hCodec;

int l_input, r_input, l_output, r_output;

/* Initialize the board support library, must be called first */
DSK6713_init();

/* Start the codec */
hCodec = DSK6713_AIC23_openCodec(0, &config);

DSK6713_AIC23_setFreq(hCodec, 7);

while(1)
{ /* Read a sample to the left channel */
while (!DSK6713_AIC23_read(hCodec, &l_input));

/* Read a sample to the right channel */
while (!DSK6713_AIC23_read(hCodec, &r_input));

l_output=IIR_FILTER(&filter_Coeff ,l_input);
r_output=l_output;

/* Send a sample to the left channel */
while (!DSK6713_AIC23_write(hCodec, l_output));

/* Send a sample to the right channel */
while (!DSK6713_AIC23_write(hCodec, r_output));
}

/* Close the codec */
DSK6713_AIC23_closeCodec(hCodec);
}

signed int IIR_FILTER(const signed int * h, signed int x1)
{
static signed int x[6] = { 0, 0, 0, 0, 0, 0 }; /* x(n), x(n-1),
x(n-2). Must be static */
static signed int y[6] = { 0, 0, 0, 0, 0, 0 }; /* y(n), y(n-1),
y(n-2). Must be static */
int temp=0;

temp = (short int)x1; /* Copy input to temp */

x[0] = (signed int) temp; /* Copy input to x[stages][0] */

temp = ( (int)h[0] * x[0]) ; /* B0 * x(n) */

temp += ( (int)h[1] * x[1]); /* B1/2 * x(n-1) */
temp += ( (int)h[1] * x[1]); /* B1/2 * x(n-1) */
temp += ( (int)h[2] * x[2]); /* B2 * x(n-2) */

temp -= ( (int)h[4] * y[1]); /* A1/2 * y(n-1) */
temp -= ( (int)h[4] * y[1]); /* A1/2 * y(n-1) */
temp -= ( (int)h[5] * y[2]); /* A2 * y(n-2) */

/* Divide temp by coefficients[A0] */

temp >>= 15;

if ( temp > 32767 )
{
temp = 32767;
}
else if ( temp < -32767)
{
temp = -32767;
}
y[0] = temp ;

/* Shuffle values along one place for next time */

y[2] = y[1]; /* y(n-2) = y(n-1) */
y[1] = y[0]; /* y(n-1) = y(n) */

x[2] = x[1]; /* x(n-2) = x(n-1) */
x[1] = x[0]; /* x(n-1) = x(n) */

/* temp is used as input next time through */

return (temp<<2);
}

Result:
Analyze the input and output on the CRO. Change the input frequency and note down
corresponding variations in the output. Draw the frequency response of the filter.









Experiment No. 24

REAL TIME IMPLEMENTATION OFFIR FILTER

Aim:
To implement FIR filters using DSP kit

Equipments Used:
DSK TMS320C6713, CCS version, IDE version.3, Power cord, USB cable

Theory:

Finite Impulse Response (FIR) filters are of non-recursive type, whereby the present
output sample depends om the present input sample and previous input samples. Digital filters
with finite-duration impulse response (all-zero, or FIR filters) have both advantages and
disadvantages compared to infinite-duration impulse response (IIR) filters.
FIR filters have the following primary advantages:
They can have exactly linear phase.
They are always stable.
The design methods are generally linear.
They can be realized efficiently in hardware.
The filter startup transients have finite duration.

The primary disadvantage of FIR filters is that they often require a much higher filter order
than IIR filters to achieve a given level of performance. Correspondingly, the delay of these
filters is often much greater than for equal performances IIR filter. Different methods for
designing FIR filters are
1) Using windows
2) Using equiripple approximation
3) Using frequency sampling method

Procedure:
1. A MATLAB program is written to design an IIR filter with the given specifications:
a. Order
b. Sampling Rate
c. Cut off Frequency
2. Compute the desired Impulse Response.
3. Connect CRO to the Socket Provided for LINE OUT.
4. Connect a Signal Generator to the LINE IN Socket.
5. Switch on the Signal Generator with a sine wave of desired frequency.
6. Now Switch on the DSK and Bring Up Code Composer Studio on the PC.
7. Create a new project with name XXXX.pjt.
8. From the File Menu new DSP/BIOS Configuration select
9. dsk6713.cdb and save it as XXXX.cdb and add it to the current project.
10. Add the given XXXX.c file to the current project which has the main function and
calls all the other necessary routines.
11. View the contents of the generated file XXXXcfg_c.c and copy the include header
file XXXXcfg.h to the XXXX.c file.
12. Add the library file dsk6713bsl.lib from the location
C:\ti\C5400\dsk6713\lib\dsk6713bsl.lib to the current project
13. Compile, Build, Load and Run the program.
14. You can notice the input signal appearing on the CRO verifying the codec
configuration.
15. You can also pass an audio input and hear the output signal through the speakers.
16. You can also vary the sampling frequency using the DSK6713_AIC23_setFreq
Function in the codec.c file and repeat the above steps.
Program:

#include "filtercfg.h"

#include "C:\CCStudio_v3.1\C6000\dsk6713\include\dsk6713.h"
#include "C:\CCStudio_v3.1\C6000\dsk6713\include\dsk6713_aic23.h"

float filter_Coeff[] = {0.000000,-0.001591,-
0.002423,0.000000,0.005728,0.011139,0.010502,-0.000000,-0.018003,-
0.033416, -
0.031505,0.000000,0.063010,0.144802,0.220534,0.262448,0.220534,0.1448
02,0.063010,0.000000,-0.031505,-0.033416,-0.018003,-
0.000000,0.010502,0.011139,0.005728,0.000000,-0.002423,-
0.001591,0.000000 };

static short in_buffer[100];
DSK6713_AIC23_Config config = {\
0x0017, /* 0 DSK6713_AIC23_LEFTINVOL Leftline input channel
volume */\
0x0017, /* 1 DSK6713_AIC23_RIGHTINVOL Right line input channel
volume*/\
0x00d8, /* 2 DSK6713_AIC23_LEFTHPVOL Left channel headphone
volume */\
0x00d8, /* 3 DSK6713_AIC23_RIGHTHPVOL Right channel headphone
volume */\
0x0011, /* 4 DSK6713_AIC23_ANAPATH Analog audio path control
*/\
0x0000, /* 5 DSK6713_AIC23_DIGPATH Digital audio path control
*/\
0x0000, /* 6 DSK6713_AIC23_POWERDOWN Power down control */\
0x0043, /* 7 DSK6713_AIC23_DIGIF Digital audio interface
format */\
0x0081, /* 8 DSK6713_AIC23_SAMPLERATE Sample rate control */\
0x0001 /* 9 DSK6713_AIC23_DIGACT Digital interface activation
*/ \
};

/*
* main() - Main code routine, initializes BSL and generates tone
*/

void main()
{
DSK6713_AIC23_CodecHandle hCodec;

Uint32 l_input, r_input,l_output, r_output;

/* Initialize the board support library, must be called first */
DSK6713_init();

/* Start the codec */
hCodec = DSK6713_AIC23_openCodec(0, &config);

DSK6713_AIC23_setFreq(hCodec, 7);
while(1)
{ /* Read a sample to the left channel */
while (!DSK6713_AIC23_read(hCodec, &l_input));

/* Read a sample to the right channel */
while (!DSK6713_AIC23_read(hCodec, &r_input));


l_output=(Int16)FIR_FILTER(&filter_Coeff ,l_input);
r_output=l_output;

/* Send a sample to the left channel */
while (!DSK6713_AIC23_write(hCodec, l_output));

/* Send a sample to the right channel */
while (!DSK6713_AIC23_write(hCodec, r_output));
}
/* Close the codec */
DSK6713_AIC23_closeCodec(hCodec);
}
signed int FIR_FILTER(float * h, signed int x)
{
int i=0;
signed long output=0;
in_buffer[0] = x; /* new input at buffer[0] */
for(i=30;i>0;i--)
in_buffer[i] = in_buffer[i-1]; /* shuffle the buffer */
for(i=0;i<32;i++)
output = output + h[i] * in_buffer[i];
return(output);
}

Result:
Analyze the input and output on the CRO. Vary the input frequency and note down
corresponding variations in the output. Draw the frequency response of the filter.
Experiment No. 25

REAL TIME IMPLEMENTATION OFSINE WAVE

Aim:
To generate a sine wave using DSP kit

Procedure:
A MATLAB program is written to design a IIR filter with the given specifications:
Order
Sampling Rate
Cut off Frequency
Compute the desired Impulse Response.

1. Connect CRO to the Socket Provided for LINE OUT.
2. Connect a Signal Generator to the LINE IN Socket.
3. Switch on the Signal Generator with a sine wave of frequency 500 Hz.
4. Now Switch on the DSK and Bring Up Code Composer Studio on the PC.
5. Create a new project with name XXXX.pjt.
6. From the File Menu new DSP/BIOS Configuration select
7. dsk6713.cdb and save it as YYYY.cdb and add it to the current project.
8. Add the generated YYYYcfg.cmd file to the current project.
9. Add the given codec.c file to the current project which has the main function and
calls all the other necessary routines.
10. View the contents of the generated file YYYYcfg_c.c and copy the include header
file YYYYcfg.h to the codec.c file.
11. Add the library file dsk6713bsl.lib from the location
C:\ti\C5400\dsk6713\lib\dsk6713bsl.lib to the current project
12. Build, Load and Run the program.
13. You can notice the input signal of 500 Hz. appearing on the CRO verifying the codec
configuration.
14. You can also pass an audio input and hear the output signal through the speakers.
15. You can also vary the sampling frequency using the DSK6713_AIC23_setFreq
Function in the codec.c file and repeat the above steps.

Program:

#include "sinewavecfg.h"

#include "C:\CCStudio_v3.1\C6000\dsk6713\include\dsk6713.h"
#include "C:\CCStudio_v3.1\C6000\dsk6713\include\dsk6713_aic23.h"

/* #include <stdio.h> */
/* #include <math.h> */
/* #include "dsk6713_aic23.h" */

#define pi 3.1428571
float f;
unsigned int N,n;
unsigned sample=0, data =0, gain =10000;

DSK6713_AIC23_Config config = {
0x0017, // 0 DSK6713_AIC23_LEFTINVOL Left line input channel volume
0x0017, // 1 DSK6713_AIC23_RIGHTINVOL Right line input channel volume
0x00d8, // 2 DSK6713_AIC23_LEFTHPVOL Left channel headphone volume
0x00d8, // 3 DSK6713_AIC23_RIGHTHPVOL Right channel headphone volume
0x0011, // 4 DSK6713_AIC23_ANAPATH Analog audio path control
0x0000, // 5 DSK6713_AIC23_DIGPATH Digital audio path control
0x0000, // 6 DSK6713_AIC23_POWERDOWN Power down control
0x0043, // 7 DSK6713_AIC23_DIGIF Digital audio interface format
0x0001, // 8 DSK6713_AIC23_SAMPLERATE Sample rate control
0x0001 // 9 DSK6713_AIC23_DIGACT Digital interface activation
};
DSK6713_AIC23_CodecHandle hCodec;

void main()
{
DSK6713_init();
hCodec = DSK6713_AIC23_openCodec(0, &config);
printf("Enter the input frequency \n");
scanf("\n %f",&f);
printf("Generating tone of %f frequency\n",f);
N=48000/f;
printf("N value = %d\n",N);
n = 0;
while(1)
{
{
data= gain*sin(2*pi*n/N);
n++;
if(n>=N) n=0;
/* Send a sample to the left channel */
while (!DSK6713_AIC23_write(hCodec, data));
/* Send a sample to the right channel */
while (!DSK6713_AIC23_write(hCodec, data));
return(data)
} }
}

Result:
Observe the generated sine wave in CRO



























VIVA VOCE QUESTIONS

1. Differentiate a microprocessor from a digital signal processor.
2. What are the main factors to be considered while selecting a digital signal processor?
3. Distinguish between Von Neumann architecture and Harvard architecture.
4. What are the key features of TMS320C50 family?
5. TMS320C50 belong to which generation in the TMS320C50 family?
6. What is modified Harvard architecture?
7. Which are the main units in the 16 16 bit parallel multiplier?
8. Explain the data memory and program memory.
9. Explain the interrupts in TMS320C50.
10. What is standalone mode operation of digital signal processor?
11. What is the Q15 format of representation of a number?
12. What are the functions of the instructions LTA and APAC?
13. What is the difference between convolution theorem and correlation theorem?
14. What is the condition when circular convolution becomes equal to linear convolution?
15. What is the energy and power of a random signal?
16. What do you mean by TAP?
17. Advantages of DSP
18. Disadvantages of DSP
19. Architectural features of Digital Signal Processor.
20. Evolution of TMS processors.
21. Which are the fixed point and floating point TMS processors?
22. What is the basic difference between the different processors in same series?
23. What are the important software tools in CCS?
24. What are DSP/BIOS? Where it is used?
25. Can you put break point in DSP code for real time? Then how can you debug such a
program?
26. What is an emulator?
27. What is evaluation module?
28. What is DSK?
29. Which is the most commonly used anti-aliasing filter?
30. What is moving average filter?
31. When a random signal is called white?
32. What is a non-stationary signal? Give examples.
33. How do you find the spectrum of a stationary signal?
34. What is meant by a Circular Buffer?
A special buffer which is "circular" because incrementing at the end causes it to
wrap around to the beginning, or because decrementing from the beginning causes it to
wrap around to the end. Circular buffers are often provided by DSP microprocessors to
implement the "movement" of the samples through the FIR delay-line without having
to literally move the data in memory. When a new sample is added to the buffer, it
automatically replaces the oldest one.
35. What is an Interpolator? Decimator?
36. What is a linear phase filter?
"Linear Phase" refers to the condition where the phase response of the filter is a
linear (straight-line) function of frequency (excluding phase wraps at +/- 180 degrees).
This results in the delay through the filter being the same at all frequencies. Therefore,
the filter does not cause "phase distortion" or "delay distortion". The lack of
phase/delay distortion can be a critical advantage of FIR filters over IIR and analog
filters in certain systems, for example, in digital data modems.
37. Which filter shows linear phase characteristics?
38. What is the disadvantage of FIR filter?
39. Draw the Block diagram of a typical DSP system.
40. What is the condition for linear phase?
41. What is the delay of a linear-phase FIR filter?
42. Differentiate a microprocessor from a digital signal processor.
43. What are the main factors to be considered while selecting a digital signal processor?
44. Distinguish between Von Neumann architecture and Harvard architecture.
45. What are the key features of TMS320C50 family?
46. TMS320C50 belong to which generation in the TMS320C50 family?
47. What is modified Harvard architecture?
48. Which are the main units in the 16 16 bit parallel multiplier?
49. Explain the data memory and program memory.
50. Explain the interrupts in TMS320C50.
51. What is standalone mode operation of digital signal processor?
52. What is the Q15 format of representation of a number?
53. What are the functions of the instructions LTA and APAC?
54. Explain the significance of Matlab.
55. Is there any usage of matlab in digital signal processing?
56. What are built functions used for convolution, fast Fourier transform, inverse Fourier
transform?
57. Mention some important commands of matlab.
58. Is there any difference between stem and plot?
59. Distinguish between plot and subplot with examples.
60. What are the different flow control constructs used?
61. Name the different windows in matlab menu and also specify their significance.
62. What are the different parts of a matlab system?
63. Explain the procedure of running a matlab program.

PREVIOUS YEARSUNIVERSITY EXAM QUESTIONS

1. Design a low pass filter 1 ) f ( H , Hz 100 f 0 an 0 otherwise using hamming
window
2. Implement a MATLAB or C program to obtain circular convolution of two finite length
sequences of length N and M respectively.
3. Design a digital FIR high pass filter with the following specification:
6 . 0 w , 5 . 0 w
p s
, dB 50 A , dB 25 . 0 R
s p
. Plot the frequency response and
impulse response.
4. Design a digital FIR high pass filter with the following specification:
2 . 0 w , 3 . 0 w
p s
, dB 30 A , dB 1 R
s p
.Plot the magnitude and phase response
and pole zero plot.
5. Write a m-file to compute the N point DFT of a sequence .verify that
DFT(DFT(x,N))=Nx.
6. Design a band reject filter and test by giving an input signal using MATLAB
7. Given two arbitrary sequence of unequal length. Use linear convolution to calculate
their circular convolution.
8. Implement a MATLAB or C program to obtain circular convolution of two finite
length sequence of length N and M respectively.
9. Design a Butterworth digital LPF with sampling rate=8000 samples/sec, passband edge
= 1500 Hz, ripple = 3dB, stopband edge = 2000Hz, attenuation = 40 dB. Use the
impulse invariant method with T=1 and T=1/8000 and compare the response log-mag
response and impulse response.
10. Generate the ECG waveform. Replicate it 10 times using the column(:) operator.
Obtain the spectra.
11. Design a low pass Butterworth prototype and impulse invariant method to satisfy the
specification dB 30 A , 3 . 0 , db 0 . 1 R , 2 . 0
s S p p
.Plot the magnitude and
phase response and pole zero positions.
12. Generate a complex sine wave containing two sine wave of amplitude 5V and 2V with
frequency 100Hz and 2000Hz. Design suitable IIR filter to attenuate high frequency
component by 30 dB Apply the complex sine wave to the filter and plot the output.
13. Implement linear convolution using convolution property of DFT.
14. Design a low pass filter
Hz 100 f 0 1
otherwise 0
) f ( H

using hamming window
15. Write a MATLAB program to compare the response of low pass Butterworth and
Chebyshev filters with rest of frequency of 1Khz.
16. Obtain PWM with a carrier waveform of frequency 40 KHz and a random binary
modulating sequence .Display the waveform.
17. Write a MATLAB program to verify the time-shifting property of DTFT.
18. Generate a sine wave of 1KHz using any DSP processors. Verify the output in a CRO.
Modify the program to obtain a 2KHz sine wave.
19. Write a MATLAB or C program using elementary commands to generate a
pseudorandom sequence , each sample of which is distributed uniformly over the
interval[-1, 1]. Obtain an estimate probability density function and show that the
distribution is nearly uniform of large data size.
20. Design a high pass filter meeting the following specifications
dB 4 . 0 R , dB 45 A , 6 . 0 , 3 . 0
p s s p
.Use Kaiser window and verify the design.
21. Calculate the coefficient of a digital bandpass filter with Butterworth characteristics
that meets the following specifications:
Passband=200-300 Hz
Sampling frequency=2000Hz
Filter order=8. Plot the magnitude response and the pole-zero diagrams.
22. Write a modified linear convolution conv_m(x,nx,y,ny) that produces the total result of
linear convolution between two sequences x and y.
23. Design a Butterworth High Pass Filter for the following specifications: Passband ripple
= 0.5, Stopband ripple =50, Passband frequency=1200 Hz, Stopband frequency=2400
Hz, Sampling frequency =10 KHz
24. Design a Chebyshev Type-1 Low Pass Filter for the following specifications: Passband
ripple =0.3, Stopband ripple =50, Passband frequency=1300 Hz, Stopband
frequency=1500Hz, Sampling frequency =10 KHz
25. Design a Butterworth Bandstop Filter for the following specifications: Passband ripple
=0.3, Stopband ripple =45, Passband frequency=1300 Hz, Stopband frequency=1500Hz,
Sampling frequency =10 KHz
26. Determine the output of a system with impulse response given by
27. h(n) = u(n) - u(n-10) and input x(n) = u(n-2) - u(n-7)
28. Generate and plot the following sequence both in MATLAB and C :
29.
)] 20 n ( u ) 10 n ( u )[ n ( 2 . 0 ) n 04 . 0 cos( ) n ( x

where
) n (
is a random number generator with zero mean and unit variance
30. Without using functions, find cross correlation of the sequence using MATLAB x[n] =
[3,11,7,0,7,4,2] and y[n] = x[n-2]. Obtain the plot.
31. Given a causal system y(n) = 0.85 y(n-1) + 2 x(n). Find z-transform and comment on its
stability.
32. Find the output of the follwing LTI system usinf MATLAB h[n] = {1,2,1,1}
33. Write a program in MATLAB which can be used to function as a sinusoidal signal
generator of frequency range 1 Hz to 1 MHz.
34. Design a Butterworth High Pass Filter for the following specifications: Passband ripple
= 0.5, Stopband ripple =50, Passband frequency=1200 Hz, Stopband frequency=2400
Hz, Sampling frequency =10 KHz
35. Design a Chebyshev Type-1 Low Pass Filter for the following specifications: Passband
ripple =0.3, Stopband ripple =50, Passband frequency=1300 Hz, Stopband
frequency=1500Hz, Sampling frequency =10 KHz
36. Design a Butterworth Bandstop Filter for the following specifications: Passband ripple
=0.3, Stopband ripple =45, Passband frequency=1300 Hz, Stopband frequency=1500Hz,
Sampling frequency =10 KHz
37. Determine the output of a system with impulse response given by
38. h(n) = u(n) - u(n-10) and input x(n) = u(n-2) - u(n-7)
39. Generate and plot the following sequence both in MATLAB and C :
40.
)] 20 n ( u ) 10 n ( u )[ n ( 2 . 0 ) n 04 . 0 cos( ) n ( x
where
) n (
is a random number
generator with zero mean and unit variance
41. Without using functions, find cross correlation of the sequence using MATLAB x[n] =
[3,11,7,0,7,4,2] and y[n] = x[n-2]. Obtain the plot.
42. Given a causal system y(n) = 0.85 y(n-1) + 2 x(n). Find z-transform and comment on its
stability.



MODEL QUESTIONS
1. Write a MATLAB program to show that a large number of sinusoids is approximately a
square.
2. Write a MATLAB program to show that a large number of sinusoids is approximately a
triangle.
3. Design a function generator in MATLAB which can generate any of the following
waveforms from frequencies 1Hz to 1MHz.
a. Sine
b. Triangle
c. Square
4. Generate a zero mean unit variance random sequence.
5. Generate a Real and Complex exponential sequence using MATLAB.
6. Write a MATLAB program to generate Sinc function.
7. Generate a PWM waveform in MATLAB without using formula.
8. Write a MATLAB program to generate a DSB-SC AM signal.
9. Write a MATLAB program to generate a SSB AM signal.
10. Generate an FM signal for a carrier frequency of 1 KHz and modulating frequency of 20
Hz. Select appropriate Modulation Index.
11. Write a MATLAB program to implement convolution and correlation of Sin(wt) with itself
and plot it.
12. The impulse response of the system is h(n). Find the output of the system to any given
input using FFT.
13. Find the output of an LTI system characterized by the following difference equation: y(n)
= 5 x(n).
14. Find the step response of: Y(Z) = 3 X(Z) + Z
-1
X(Z).
15. Plot the frequency domain representation of the signal x(t) using MATLAB. x(t) = 5
sin(2*pi*50*t) + 10 sin(2*pi*100*t).
16. Find the output of the following LTI system using MATLAB : h(n) = {1,2,1,1}
17. Find without using conv function the convolution of : x(n) ={1,0,0,1}; h (n) ={1,2,1}
18. Find the output of an LTI system described by y(n) = x(n) + 2x(n-1).
19. Compute system response given
y = [ 6 31 46 6 -41 41 8 -18 1 8 2 ]
x = [ 3 1 1 7 0 1 4 2]
Verify the result using convolution.
20. Write a Matlab programwithout using fft function to calculate the DFT of 6 sampled signals:
f(0) = 0.8415
f(1) = 0.9975
f(2) = 0.9093
f(3) = 0.5985
f(4) = 0.1411
f(5) = -0.3508
and also calculate the inverse DFT to generate the f(x) and plot it.
21. Prove any three properties of convolution using MATLAB.
22. Using MATLAB experimentally find out what happens to convolution sum if one of the
input sequence is time reversed.
23. Using MATLAB experimentally find out what happens to convolution sum if both of the
input sequences are time reversed.
24. Prove using MATLAB Nyquist Sampling Theorem.
25. Show that DFT of circularly convolved sequence is equal to product of the DFT of the
sequences.
26. Prove any three properties of DFT using MATLAB.
27. Find the linear convolution of 2 sequences using FFT functions in MATLAB.
28. Plot the poles and zeroes of the z-transform :
G(z) = 2z
4
+ 16 z
3
+ 44 z
2
+ 56 z + 32
3 z
4
+ 3 z
3
15z
2
+ 18z -12
29. Design a fourth order maximally flat analog low pass filter with 3-dB cutoff frequency at
=1. Plot its pole-zero plot.
30. Design an Analog elliptic BPF with the following specifications: Pass band edge at 4 KHz
and 7 KHz, Stop edges at 3 KHz and 8 KHz with pass band ripple 1 dB and stop band
attenuation 22dB.
31. Design an analog filter with equi-ripple pass band and equi-ripple stop band magnitude
response with the following specifications: Pass band edge angular frequency = 2*pi*1000,
Stop band edge angular frequency = 2*pi*5000, MaximumPass band attenuation = 1 dB
and Stop band attenuation = 40 dB.
32. Design an analog filter with monotonic behavior in pass band and equi-ripple stop band
magnitude response with the following specifications: Pass band edge angular frequency =
2*pi*1000, Stop band edge angular frequency = 2*pi*5000, MaximumPass band
attenuation = 1 dB and Stop band attenuation = 40 dB.
33. Design an analog filter with equi-ripple pass band and monotonic behavior in stop band
magnitude response with the following specifications: Pass band edge angular frequency =
2*pi*1000, Stop band edge angular frequency = 2*pi*5000, MaximumPass band
attenuation = 1 dB and Stop band attenuation = 40 dB.
34. Sketch the magnitude response and phase response of an IIR digital LPF with Pass band
edge frequency = 0.5 KHz and Stop band edge frequency 1.2 KHz. Select suitable pass
band and stop band attenuations.
35. Design a linear phase band pass FIR filter of order 40 with pass band edges
p1
= 0.4 and

p2
= 0.6 . Show the impulse response coefficients and plot the magnitude response.
36. Design a digital filter with equi-ripple pass band and equi-ripple stop band magnitude
response with the following specifications: Pass band edge angular frequency = 2*pi*1000,
Stop band edge angular frequency = 2*pi*5000, MaximumPass band attenuation = 1 dB
and Stop band attenuation = 40 dB.
37. Design a digital filter with monotonic behavior in pass band and equi-ripple stop band
magnitude response with the following specifications: Pass band edge angular frequency =
2*pi*1000, Stop band edge angular frequency = 2*pi*5000, MaximumPass band
attenuation = 1 dB and Stop band attenuation = 40 dB.
38. Design a digital filter with equi-ripple pass band and monotonic behavior in stop band
magnitude response with the following specifications: Pass band edge angular frequency =
2*pi*1000, Stop band edge angular frequency = 2*pi*5000, MaximumPass band
attenuation = 1 dB and Stop band attenuation = 40 dB.
39. Design a Low pass FIR filter Kaiser Window with
p
= 0.3 and
s
= 0.4 and
s
= 50
dB.
40. Design an IIR Butterworth BPF with Pass band edges at 0.45 and 0.65, Stop band edges at
0.3 and 0.75, Maximum Pass band attenuation = 1 dB and Stop band attenuation = 40 dB.
Find the order of the above filter.
41. Design a second order digital notch filter having a notch frequency of 60 Hz and 3db notch
bandwidth of 6Hz. Plot its phase and frequency responses.
42. Perform spectral analysis for the random signal g = 5*sin(0.15*pi*n) + 2*sin(0.35*pi*n) +
randn(size(n))
43. Plot a chirp signal and find its narrow band spectrum.
44. Design an IIR LPF with cutoff frequency 7000 Hz using DSP kit.
45. Design an FIR LPF with cutoff frequency 4000 Hz using DSP kit.
46. Write a C program to show that a large number of sinusoids is approximately a square and
execute it in DSP kit.
47. Find the output of the following LTI system using DSP kit : h(n) = {1,2,1,1}
48. Find the convolution of : x(n) ={1,0,0,1}; h (n) ={1,2,1} using DSP kit.
49. State and Prove convolution theorem using DSP kit.
50. Find magnitude and phase response for the following I/O equation :
y(n) = x(n) + x(n-1) using DSP kit
51. Find frequency response for the following I/O equation: y(n) = x(n) + x(n-1) using DSP kit.
52. Find the Fourier transform of a noisy Sine wave using DSP kit. What are your conclusions?
53. For a periodic signal of length N find the average power of the signal using DSP kit.
54. Generate an AM waveform using DSP kit.
55. Generate an FM waveform using DSP kit.
56. Generate a PWM waveform using DSP kit.
57. Design a Tone Modulator with 75 % and 100% modulation for a signal
m(t)= cos (0.5*pi*20*t)
58. State and Prove Parsevals theorem
59. Show that the magnitude response of a second order low pass Butterworth has a rolloff rate
of 40dB/decade.
60. Design a filter with the following response.

61. Design a filter with the following response.

62. Design a filter with the following response.

63. Design a filter with the following response.