Updated DSP Manual 15ECL57 PDF
Updated DSP Manual 15ECL57 PDF
Updated DSP Manual 15ECL57 PDF
LABORATORY MANUAL
V Semester B.E.
(Academic Year: 2019-20)
NAME
USN
BATCH
SECTION
STAFF DETAILS
EVALUATION
WEEKLY
EVALUATION*
LAB CIE
TOTAL
*OBE Sheet Evaluation
I. INTRODUCTION TO OCTAVE
GNU Octave is a high-level interpreted language, primarily intended or numerical
computations. It provides capabilities for the numerical solution of linear and nonlinear
problems, and for performing other numerical experiments. It also provides extensive graphics
capabilities for data visualization and manipulation. Octave is normally used through its
interactive command line interface, but it can also be used to write non- interactive programs. The
Octave language is quite similar to OCTAVE so that most programs are easily portable.
Octave has extensive tools for solving common numerical linear algebra problems,
finding the roots of nonlinear equations, integrating ordinary functions, manipulating polynomials,
and integrating ordinary differential and differential-algebraic equations. It is easily extensible and
customizable via user-defined functions written in Octave's own language, or using dynamically
GNU Octave is also freely redistributable software. You may redistribute it and/or modify
it under the terms of the GNU General Public License (GPL) as published by the Free Software
Foundation.
Octave was written by John W. Eaton and many others. Because Octave is free software
you are encouraged to help make Octave more useful by writing and contributing additional
functions for it, and by reporting any problems you may have.
QTOCTAVE
QTOCTAVE is a front-end user interface for the Octave. It simplifies the use
of Octave for user who are not familiar with the original, command line based version of
Octave.
Where denotes the position n = 0 in octave we can write the program as follows
x=[1 5 6 2 3 5 4 2]
n=[-3 -2 -1 0 1 2 3 4]
to view the waveform :
stem (n,x) : (the x coordinate variable first and y coordinate variable second), the output will
be as shown in the figure.
In the above example if we do not explicitly use n eg : stem (x) , the result will be as shown
below . Please note that the time index starts from n = 1,2,3, …....
PART I
EXPERIMENTS USING OCTAVE
1.1 Objective:
To verify the sampling theorem using octave software.
1.2 Software Required:
Octave software
1.3 Pre-Requisite:
Sampling theorem.
1.4 Introduction:
• Sampling is a process of converting a continuous time signal (analog signal)
x(t) into a discrete time signal x[n], which is represented as a sequence of numbers. (A/D
converter)
•Converting back x[n] into analog (resulting in reconstruction. (D/A converter)
• Some techniques for reconstruction-
o ZOH (zero order hold) interpolation results in a staircase waveform, is
implemented by OCTAVE plotting function stairs(n,x),
o FOH (first order hold) where the adjacent samples are joined by straight lines is
implemented by OCTAVE plotting function plot(n,x),
• For x(t ) to be exactly the same as x(t), sampling theorem in the generation of x(n) from
x(t) is used. The sampling frequency fs determine the spacing between samples.
•Aliasing-A high frequency signal is converted to a lower frequency, results due to under
sampling. Though it is undesirable in ADCs, it finds practical applications in stroboscope
and sampling oscilloscopes.-
1.5 Procedure:
1. Turn on PC
2. Open the octave software already installed in a PC
3. In octave open the new script file.
4. Save the file as any name with .m extension.
5. Type the program and save it. And compile the program using run option or F5.
6. After compilation give the input and observe the output, Graph.
1.6 Program:
tfinal=0.05;
t=0:0.00005:tfinal;
fd=input('Enter analog frequency');
%define analog signal for comparison
xt=cos(2*pi*fd*t);
%simulate condition for under sampling i.e., fs1<2*fd
fs1=1.3*fd;
%define the time vector
n1=0:1/fs1:tfinal;
%Generate the under sampled signal
xn=cos(2*pi*n1*fd);
%plot the analog & sampled signals
subplot(3,1,1);
plot(t,xt,'b',n1,xn,'r*-');
title('under sampling plot');
%condition for Nyquist plot
fs2=2*fd;
n2=0:1/fs2:tfinal;
xn=cos(2*pi*fd*n2);
subplot(3,1,2);
plot(t,xt,'b',n2,xn,'r*-');
title('Nyquist plot');
%condition for oversampling
fs3=5*fd;
n3=0:1/fs3:tfinal;
xn=cos(2*pi*fd*n3);
subplot(3,1,3);
plot(t,xt,'b',n3,xn,'r*-');
title('Oversampling plot');
xlabel('time');
ylabel('amplitude');
legend('analog','discrete');
1.7 Results :
Enter analog frequency 200
1.8 Discussions:
1. From the under sampling plot observe the aliasing effect. The analog signal is of 200Hz
(T=0.005s). The reconstructed (from under sampled plot) is of a lower frequency. The alias
frequency is computed as
fd - fs1 = 200-1.3*200 = 200-260= -60Hz
This is verified from the plot. The minus sign results in a 180˚ phase shift.
(For example: 3kHz & 6kHz sampled at 5kHz result in aliases of -2kHz (3k-5k) & 1kHz
(6k-5k) respectively)
2. Sampling at the Nyquist rate results in samples sin(πn) which are identically zero, i.e., we
are sampling at the zero crossing points and hence the signal component is completely
missed. This can be avoided by adding a small phase shift to the sinusoid. The above
problem is not seen in cosine waveforms (except cos(90n)). A simple remedy is to sample
the analog signal at a rate higher than the Nyquist rate.
3. The over sampled plot shows a reconstructed signal almost similar to that of the analog
signal. Using low pass filtering the wave form can be further smoothened.
2.1 Objective:
To verify the properties of DFT.
2.2 Software Required:
Octave software
2.3 Pre-Requisite:
Linear Convolution and circular convolution
2.4 Introduction:
a) Linear convolution
The output y[n] of a LTI (linear time invariant) system can be obtained by
convolving the input x[n] with the system’s impulse response h[n].
Where the index <n-k>N implies circular shifting operation and <-k>N implies folding the
sequence circularly
Steps for circular convolution are the same as the usual convolution, except all index
calculations are done "mod N" = "on the wheel".
Plot f [m] and h [−m] as shown in Fig. 2.2. (use f(m) instead of x(k))
o Multiply the two sequences
o Add to get y[m]
o "Spin" h[−m] n times Anti Clock Wise (counter-clockwise) to get h[n-m].
x[n] and h[n] can be both finite or infinite duration sequences. If infinite
sequences, they should be periodic, and the N is chosen to be at least equal to the
period. If they are finite sequences N is chosen as >= to max(xlength, hlength).
Whereas in linear convolution N>= xlength+hlength-1.
The linear convolution is the convolution process for the discrete time systems. The
convolution of discrete time (DT) signals possesses the following properties:
Commutative Property: x(n)*h(n) = h(n)*x(n).
Associative Property: x(n)*[h1(n) *h2(n)] = [x(n)*h1(n)] *h2(n) Distributive Property:
x(n)*[h1(n) + h2(n)] = x(n)*h1(n) + x(n)*h2(n)
The definitions and interpretations of these properties are summarized below.
Commutative Property :
The commutative property states that the order in which two sequences are convolved is
not important. Mathematically, the commutative property is x(n)*h(n) = h(n)*x(n).From a
systems point of view, this property states that a system with a unit sample response h(n)
and input x(n) behaves in exactly the same way as a system with unit sample response x(n)
and an input h(n).
Associative Property :
2.5 Procedure:
1. Turn on PC.
2. Open the octave software already installed in a PC.
3. In octave open the new script file.
4. Save the file as any name with .m extension.
5. Type the program and save it. And compile the program using run option or F5.
6. After compilation give the input and observe the output, Graph.
2.6 Program :
a) Linear convolution of two given sequences:
x1=input('Enter first sequence')
x2=input('Enter second sequence')
y=conv(x1,x2);
disp('linear con of x1 & x2 is y=');
disp(y);
%graphical display part
subplot (2,1,1);
stem(y);
xlabel('time index n');
ylabel('amplitude ');
title('convolution output');
subplot(2,2,3);
stem(x1);
xlabel('time index n');
ylabel('amplitude ');
title('plot of x1');
subplot(2,2,4); stem(x2);
xlabel('time index n');
ylabel('amplitude ');
title('plot of x2');
b). Circular convolution of two given sequences
x=[1 2 3 4];
h=[1 2 3 4];
N=length(x);
%Compute the output
for n=0:N-1
y(n+1)=0; for
k=0:N-1
i=mod((n-k),N);
if i<0 i=i+N;
end
y(n+1)=y(n+1)+h(k+1)*x(i+1);
end
end
disp('circular convolution of x & h is y=');
disp(y);
%plot
n1=0:N-1;
stem(n1,y);
title('Circular convolution output y(n)');
2.7 Results :
a) Linear convolution of two given sequences:
2.8 Discussion:
Calculations:-
3.1 Objective:
To verify Auto and cross correlation of two given sequences and their properties using octave
software.
The parameter ‘l’ called ‘lag’ indicates the time shift between the pair.
Autocorrelation sequence of x[n] is given by
At zero lag, i.e., at l=0, the sample value of the autocorrelation sequence has its
maximum value (equal to the total energy of the signal x)
This is verified in Fig. 5.1, where the autocorrelation of the rectangular pulse (square)
has a maximum value at l=0. All other samples are of lower value. Also the maximum
value = 11 = energy of the pulse [1 2+12+12..]
A time shift of a signal does not change its autocorrelation sequence. For example, let
y[n]=x[n-k]; then ryy[l] = rxx[l] i.e., the autocorrelation of x[n] and y[n] are the same
regardless of the value of the time shift k. This can be verified with a sin e and cosine
sequences of same amplitude and frequency will have identical autocorrelation functions.
For power signal the autocorrelation sequence is given by
The ordering of the subscripts xy specifies that x[n] is the reference sequence that
remains fixed in time, whereas the sequence y[n] is shifted w.r.t x[n]. If y[n] is the reference
sequence then
3.5 Procedure:
1. Turn on PC
2. Open the octave software already installed in a PC
3. In octave open the new script file.
4. Save the file as any name with .m extension.
5. Type the program and save it. And compile the program using run option or F5.
6. After compilation give the input and observe the output, Graph.
3.6 Program:
Auto correlation:
n = -5:5;
N=10;
%Generate the square sequence
x = ones(1,11);
%Compute the correlation sequence
r = conv(x,fliplr(x));
disp('autocorrelation sequence r=');
disp(r);
%plot the sequences
subplot(2,1,1);
stem(n,x);
title('square sequence');
subplot(2,1,2);
k = -N:N;
stem(k, r);
title('autocorrelation output');
xlabel('Lag index');
ylabel('Amplitude');
disp('auto-correlation r=');
disp(r);
% to calculate the Energy of the input signal
e=sum(x.^2);
disp('Maximum value of energy =');
disp(e);
disp('Maximum value of energy is at the zero lag index');
disp('The auto-correlated sequence is an even sequence');
Cross correlation :
3.7 Results
Auto correlation:
Cross correlation :
Type the reference sequence = [1 -2 6 1]
Type the second sequence = [1 2 3 4]
Cross correlation output is =
4 -5 20 19 13 8 1
3.8 Discussions:
Calculations:-
4.1 Objective:
To obtain the impulse response/step response/steady state response/response to an arbitrary
input of a system described by the given difference equation
o With x[n]= δ[n], an impulse, the computed output y[n] is the impulse response.
o If x[n]=u[n], a step response is obtained.
o If x[n] = cos(wn) is a sinusoidal sequence, a steady state response is obtained
(wherein y[n] is of the same frequency as x[n], with only an amplitude gain and
phase shift-refer Fig.7.3).
o Similarly for any arbitrary sequence of x[n], the corresponding output response
y[n] is computed.
The difference equation containing past samples of output, i.e., y[n-1], y[n-2], etc leads to a
recursive system, whose impulse response is of infinite duration (IIR). For such systems the
impulse response is computed for a large value of n, say n=100 (to approximate n=∞). The
OCTAVE function filter is used to compute the impulse response/ step response/
response to any given x[n]. Note: The filter function evaluates the convolution of an
infinite sequence (IIR) and x[n], which is not possible with conv function (remember conv
requires both the sequences to be finite).
The difference equation having only y[n] and present and past samples of input (x[n],
x[n-k]), represents a system whose impulse response is of finite duration (FIR). The
response of FIR systems can be obtained by both the ‘conv’ and ‘filter’ functions. The
filter function results in a response whose length is equal to that of the input x[n],
whereas the output sequence from conv function is of a longer length
(xlength + hlength-1).
4.5 Procedure:
1. Turn on PC
2. Open the octave software already installed in a PC
3. In octave open the new script file.
4. Save the file as any name with .m extension.
5. Type the program and save it. And compile the program using run option or F5.
6. After compilation give the input and observe the output, graph.
4.6 Program:
N=input('Length of response required=');
b=[2]; %x[n] coefficient
a=[1,0.5]; %y coefficients
%impulse input
x=[1,zeros(1,N-1)];
%time vector for plotting
n=0:1:N-1;
%impulse response
h=filter(b,a,x);
%plot the waveforms
subplot(2,1,1);
stem(n,x);
title('impulse input');
xlabel('n');
ylabel('δ(n)');
subplot(2,1,2);
stem(n,h);
title('impulse response');
xlabel('n');
ylabel('h(n)');
4.7 Results :
Length of response required=8
4.8 Discussions:
Calculations:-
5.1 Objective:
To compute N point DFT of a given sequence and to plot magnitude and phase spectrum.
5.3 Pre-Requisite:
Fundamentals of time domain and frequency domain signals.
5.4 Introduction:
Discrete Fourier Transform is a powerful computation tool which allows us to evaluate
the Fourier Transform X(ejw) on a digital computer or specially designed digital hardware.
Since X(ejw) is continuous and periodic, the DFT is obtained by sampling one period of the
Fourier Transform at a finite number of frequency points. Apart from determining the
frequency content of a signal, DFT is used to perform linear filtering operations in the
frequency domain.
5.5 Procedure:
1. Turn on PC
2. Open the octave software already installed in a PC
3. In octave open the new script file.
4. Save the file as any name with .m extension.
5. Type the program and save it. And compile the program using run option or F5.
6. After compilation give the input and observe the output, Graph.
5.6 Program:
clc;
clear all;
xn=input('enter the sequence x(n)');
N=input('enter the number of points of computation ');
y=fft(xn,N);
disp(y);
mag=abs(y);
phase=angle(y);
subplot(2,2,1);
stem(xn);
title('Input Sequence x(n)');
subplot(2,2,2)
stem(mag);
xlabel('K');
ylabel('MAGNITUDE');
title('magnitude plot');
subplot(2,2,3);
stem(phase);
xlabel('K');
ylabel('phase');
title('phase plot');
z=ifft(y,N);
mag1=real(z);
subplot(2,2,4);
stem(mag1);
title('signal sequence constituted from spectrum');
5.7 Results
enter the sequence x(n) [1 1 1 1 0 0 0 0]
Columns 1 through 6
Columns 7 through 8
0 1.0000 + 2.4142
5.8Discussions:
Calculations:-
6.1 Objective:
To verify following properties of DFT
(i) Linearity
(ii) Parseval’s Theorem
(iii) Convolution Property
6.3 Pre-Requisite:
Properties of DFT
6.4 Introduction:
By multiplying two N-point DFTs in the frequency domain, we get the circular
convolution in the time domain.
N DFT
y[n] x[n] h[n] Y (k ) X (k ) H (k )
6.5 Procedure:
1. Turn on PC
2. Open the octave software already installed in a PC
3. In octave open the new script file.
4. Save the file as any name with .m extension.
5. Type the program and save it. And compile the program using run option or F5.
6. After compilation give the input and observe the output, Graph.
6.6 Program:
(i) Linearity and Parsevals theorem:
Linearity:
clc;
clear all;
close all;
% a1*x1(n) + a2*x2(n)<-->a1*X1(K) + a2*X2(K).
x1=[1,2,3,4];
x2=[1,1,1,1];
a1=1;
a2=1;
term1= a1.*x1 + a2.*x2;
LHS=fft(term1);
term2= fft(a1.*x1);
term3 = fft(a2.*x2);
RHS = term2 + term3;
if (LHS==RHS)
disp('Linearity property proved');
disp('LHS=');
disp(LHS);
disp('RHS=');
disp(RHS);
else
disp ('DFTs are not linear');
end
Parsevals :
clc;
clear all;
close all;
% Parseval's theorem
x=[1,2,3,4];
XK =fft (x);
en1 = sum(x.^2);
en2= (1/4)* sum(abs(XK).^2);
if (en1==en2)
clc;
clear all;
close all;
% generating square pulse
x1=[zeros(1,32),ones(1,64),zeros(1,32)];
X1K= fft(x1);
x2= fftshift(X1K);
subplot(2,1,1);
stem(x1);
title('time domain');
subplot(2,1,2);
plot(abs(x2));
title('frequency domain');
Sinc function :
6.7 Results
(i) Linearity and Parsevals theorem:
Linearity :
Linearity property proved
LHS=
14.0000 + 0.0000i -2.0000 + 2.0000i -2.0000 + 0.0000i -2.0000 - 2.0000i
RHS=
14.0000 + 0.0000i -2.0000 + 2.0000i -2.0000 + 0.0000i -2.0000 - 2.0000i
Parsevals theorem:
6.8 Discussions:
Calculation:-
7.1 Objective:
To design and implement a FIR filter for given specifications.
7.2 Software Required:
Octave software
7.3 Pre-Requisite:
Design of FIR filter
7.4 Introduction:
There are two types of systems – Digital filters (perform signal filtering in time domain)
and spectrum analyzers (provide signal representation in the frequency domain). The design of
a digital filter is carried out in 3 steps- specifications, approximations and implementation.
Note: In theory we would have calculated h[n]=hd[n]×w[n], where hd[n] is the desired
impulse response (low pass/ high pass,etc given by the sinc function) and w[n] is the
window coefficients. We can also plot the window shape as stem(boxcar(N)).
Plot the frequency response of the designed filter h(n) using the freqz function and o
Method 2: Given the pass band (wp in radians) and Stop band edge (ws in radians)
frequencies, Pass band ripple Rp and stopband attenuation As.
7.5 Procedure:
1. Turn on PC
2. Open the octave software already installed in a PC
3. In octave open the new script file.
4. Save the file as any name with .m extension.
5. Type the program and save it. And compile the program using run option or F5.
6. After compilation give the input and observe the output, Graph.
7.6 Program:
RECTANGULAR WINDOW :
HAMMING WINDOW
BARTLETT WINDOW
HANNING WINDOW
b=fir1(n,wp,y); b=fir1(n,wn,'stop',y);
[h,o]= freqz(b,1,256); [h,o]=freqz(b,1,256);
m=20*log10(abs(h)); m=20*log10(abs(h));
subplot(2,2,1); plot(o/pi,m) subplot(2,2,4);
ylabel('gain in db'); plot(o/pi,m)
xlabel('(a)normalised freq'); ylabel('gain in db');
grid on; xlabel('(d)normalised freq');
grid on;
7.7 Results :
Rectangular window :
enter the passband ripple:0.05
enter the stopband ripple:0.04
enter the passband frequency:1500
enter the stopband frequency:2000
enter the sampling frequency:9000
Graph:
Graph:
Bartlett window :
enter the passband ripple:0.05
enter the stopband ripple:0.04
enter the passband frequency:1500
enter the stopband frequency:2000
enter the sampling frequency:9000
Graph:
Hanning window :
enter the passband ripple:0.03
enter the stopband ripple:0.01
enter the passband
frequency:1400
enter the stopband
frequency:2000
enter the sampling frequency:8000
Graph:
7.8 Discussions:
Calculations:-
8.1 Objective:
To design and implement an IIR filter for given specifications.
8.2 Software Required:
Octave software
8.3 Pre-Requisite:
Design of IIR filter
8.4 Introduction:
There are two methods of stating the specifications as illustrated in previous program. In
the first program, the given specifications are directly converted to digital form and the designed
filter is also implemented. In the last two programs the butterworth and chebyshev filters are
designed using bilinear transformation (for theory verification).
Method I: Given the order N, cutoff frequency fc, sampling frequency fs and the IIR
filter type (butterworth, cheby1, cheby2).
Step 1: Compute the digital cut-off frequency Wc (in the range -π < Wc < π, with π
corresponding to fs/2) for fc and fs in Hz. For example let fc=400Hz, fs=8000Hz
Wc = 2*π* fc / fs = 2* π * 400/8000 = 0.1* π radians. For OCTAVE the Normalized
cut-off frequency is in the range 0 and 1, where 1 corresponds to fs/2 (i.e.,fmax)).
Hence to use the OCTAVE commands wc = fc / (fs/2) =400/(8000/2) = 0.1
Note: if the cut off frequency is in radians then normalized frequency is computed as wc
= Wc / π
Step 2: Compute the Impulse Response [b,a] coefficients of the required IIR filter and
the response type (lowpass, bandpass, etc) using the appropriate butter, cheby1,
cheby2 command. For example given a butterworth filter, order N=2, and a high pass
response, the coefficients [b,a] of the filter are computed using the OCTAVE inbuilt
command ‘butter’ as [b,a] =butter(N, wc , 'high');
Method 2: Given the pass band (Wp in radians) and Stop band edge (Ws in radians)
frequencies, Pass band ripple Rp and stopband attenuation As.
Step 1: Since the frequencies are in radians divide by π to obtain normalized frequencies
to get wp=Wp/pi and ws=Ws/pi. If the frequencies are in Hz (note: in this case the
8.5 Procedure:
1. Turn on PC
2. Open the octave software already installed in a PC
3. In octave open the new script file.
4. Save the file as any name with .m extension.
5. Type the program and save it. And compile the program using run option or F5.
6. After compilation give the input and observe the output, Graph.
8.6 Program :
(i) Chebyshev Filter :
Chebyshev LPF
clc;
close all; clear all;
format long
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
wp=input('enter the passband frequency');
ws=input('enter the stopband frequency');
fs=input('enter the sampling frequency');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=cheb1ord(w1,w2,rp,rs);
[b,a]=cheby1(n,rp,wn);
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);
plot(om/pi,m);
ylabel('gain in db-->');
plot(om/pi,an);
CHEBYSHEV HPF
clc;
close all;
clear all;
format long
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
wp=input('enter the passband frequency');
ws=input('enter the stopband frequency');
fs=input('enter the sampling frequency');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=cheb1ord(w1,w2,rp,rs);
[b,a]=cheby1(n,rp,wn,'high');
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);
plot(om/pi,m);
ylabel('gain in db-->');
xlabel('(a) normalised frequency-->');
subplot(2,1,2);
plot(om/pi,an);
xlabel('(b) normalised frequency-->');
ylabel('phase in radians-->');
CHEBYSHEV BPF
clc;
clear all; close all;
format long
lp=input('Enter the passband attenuation:');
ls=input('Enter the stopband attenuation:');
wp=input('Enter the passband frequency:');
ws=input('Enter the stopband frequency:');
fs=input('Enter the sampling frequency:');
w1=2*wp/fs;
w2=2*ws/fs;
[n]=cheb1ord(w1,w2,lp,ls); wn=[w1 w2]
[b,a]=cheby1(n,lp,wn,'bandpass');
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h); figure(1);
subplot(2,1,1);
title('Butterworth Low Pass Filter');
plot(om/pi,m);
grid on;
ylabel('Gain in db-->');
xlabel('(a)Normalised frequency-->');
subplot(2,1,2);
plot(om/pi,an);
xlabel('(b)Normalised frequency-->');
ylabel('Phase in radians-->');
grid on
CHEBYSHEV BSF
clc;
clear all;
close all;
format long
lp=input('Enter the passband attenuation:');
ls=input('Enter the stopband attenuation:');
wp=input('Enter the passband frequency:');
ws=input('Enter the stopband frequency:');
fs=input('Enter the sampling frequency:');
w1=2*wp/fs;
w2=2*ws/fs;
[n]=cheb1ord(w1,w2,lp,ls);
wn=[w1 w2]
[b,a]=cheby1(n,lp,wn,'stop');
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
figure(1);
subplot(2,1,1);
title('Chebyshev bandstop Filter');
plot(om/pi,m);
grid on;
ylabel('Gain in db-->');
xlabel('(a)Normalised frequency-->');
subplot(2,1,2);
plot(om/pi,an);
xlabel('(b)Normalised frequency-->');
ylabel('Phase in radians-->');
grid on;
Butterworth LPF :
Clc;
close all;
format long
lp=input('Enter the passband attenuation:');
ls=input('Enter the stopband attenuation:');
wp=input('Enter the passband frequency:');
ws=input('Enter the stopband frequency:');
fs=input('Enter the sampling frequency:');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,lp,ls);
[b,a]=butter(n,wn);
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
figure(1);
subplot(2,1,1);
title('Butterworth Low Pass Filter');
plot(om/pi,m);
grid on;
ylabel('Gain in db-->');
xlabel('(a)Normalised frequency-->');
subplot(2,1,2);
plot(om/pi,an);
xlabel('(b)Normalised frequency-->');
ylabel('Phase in radians-->');
grid on;
Butterworth HPF :
clc;
clear all; close all;
format long
lp=input('Enter the passband attenuation:');
ls=input('Enter the stopband attenuation:');
wp=input('Enter the passband frequency:');
ws=input('Enter the stopband frequency:');
fs=input('Enter the sampling frequency:');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,lp,ls);
[b,a]=butter(n,wn,'high');
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
figure(1);
subplot(2,1,1);
title('Butterworth Low Pass Filter');
plot(om/pi,m);
grid on;
ylabel('Gain in db-->');
xlabel('(a)Normalised frequency-->');
subplot(2,1,2);
plot(om/pi,an);
xlabel('(b)Normalised frequency-->');
ylabel('Phase in radians-->');
grid on
plot(om/pi,an);
8.7 Results
CHEBYSHEV HPF
Graph:
CHEBYSHEV HPF
enter the passband ripple0.3
enter the stopband ripple60
enter the passband frequency1500
enter the stopband frequency2000
enter the sampling frequency9000
Graph:
CHEBYSHEV BPF
Enter the passband attenuation:0.4
Enter the stopband attenuation:35
Enter the passband frequency:2000
Enter the stopband frequency:2500
Enter the sampling frequency:10000
wn = 0.40000000000000 0.50000000000000
Graph:
CHEBYSHEV BSF
Enter the passband attenuation:0.4
Enter the stopband attenuation:46
Enter the passband frequency:1100
Enter the stopband frequency:2200
Enter the sampling frequency:6000
wn = 0.36666666666667 0.73333333333333
Graph:
Butterworth LPF
Enter the stopband attenuation: 50
Enter the passband frequency: 1200
Enter the stopband frequency: 2400
Enter the sampling frequency: 10000
Graph:
Butterworth HPF
Enter the stopband attenuation: 50
Enter the passband frequency: 1200
Enter the stopband frequency: 2400
Enter the sampling frequency: 10000
Graph:
Butterworth BPF
Graph :
Butterworth BSF
Graph :
8.8 Discussions:
Calculations:-
Part B
EXPERIMENTS USING DSP PROCESSOR
LCDK FEATURES
1) TI TMS320C6748 DSP or OMAP-L138 Application Processor 456-MHz C674
Fixed/Floating point DSP
2) 456-MHz ARM926EJ RISC CPU(OMAP-L138 only) On-chip RTC
Memory :
3) 128 MByte DDR2 running at 150 MHz
4) 128 MByte 16-bit wide NAND FLASH
5) 1 Micro SD/MMC Slot
Interfaces :
One mini-USB Serial Port(on-board serial to USB) .One Fast Ethernet Port(10/100 Mbps)
with status LEDs . One USB Host port(USB1.1) . One mini-USB OTG port (USB 2.0) .
One SATA Port (3Gbps). One VGA Port (15 pin D-SUB). One Composite Video Input
(RCA Jack) . One Leopard Imaging Camera Sensor Input (36-pin ZIP connector) . Three
AUDIO Ports (1 LINE IN & 1 LINE OUT & 1 MIC IN)
9.1 Objective:
To perform linear convolution of given two sequences
9.2 Apparatus Required:
Code composer studio 6.1.2 LCDKC6748 development kit mini USB,5v power adapter
9.3 Pre-Requisite:
Linear Convolution of two sequence
9.4 Introduction:
The output y[n] of a LTI (linear time invariant) system can be obtained by
convolving the input x[n] with the system’s impulse response h[n].
The output y[n] of a LTI (linear time invariant) system can be obtained by
convolving the input x[n] with the system’s impulse response h[n].
9.5 Procedure:
1. Open the Code Composer Studio by double-clicking on the Code Composer Studio 6.1.2
icon on the desktop.
2. Make sure the DSP kit is turned on
3. If you are launching the 6.1.2 for the first time, a WELCOME window will appear, the
user has to click on the CCS box to launch the project explorer window.
4. Click on the “Project” at the MENU bar & select New ccs project.
5. Target type LCDKC6748 AND also select LCDK and from the options select
LCDKC6748.
6. In the Connection, select Texas Instruments XDS100v3 USB Emulator.
7. Give project name. and select empty project (with main.c).
8. Wright the program on the main.c window.
9. Build the program using the Build icon
10. Compile the program using the ‘Project-compile’ icon.
11. Run the program using resume icon.
9.6 Program:
#include<stdio.h>
main ()
{
int x[20],h[20],y[40],i=0,j=0,len1=0,len2=0,len=0;
printf(“ENTER THE LENGTH OF INPUT SAMPLES \n”);
scanf(“%d”,&len1);
printf(“ENTER THE LENGTH OF h SAMPLES\n”);
scanf(“%d”,&len2);
9.7 Results:
ENTER THE LENGTH OF INPUT SAMPLES
4
ENTER THE LENGTH OF h SAMPLES
4
ENTER THE FIRST SEQUENCE
1
2
3
4
ENTER THE SECOND SEQUENCE
1
2
3
4
9.8 Discussions:
Calculations:-
10.1 Objective:
To perform circular convolution of given two sequences
10.2 Apparatus Required:
Code composer studio 6.1.2 LCDKC6748 development kit mini USB,5v power adapter
10.3 Pre-Requisite:
Circular convolution of two sequences
10.4 Introduction:
As seen in the last experiment, the output y[n] of a LTI (linear time invariant)
system can be obtained by convolving the input x[n] with the system’s impulse response
h[n].
The Circular Convolution is used to study the interaction of two signals that are periodic.
The circular convolution sum is
Where the index <n-k>N implies circular shifting operation and <-k>N implies folding the
sequence circularly
x[n] and h[n] can be both finite or infinite duration sequences. If infinite
sequences, they should be periodic, and the N is chosen to be at least equal to the
period. If they are finite sequences N is chosen as >= to max(xlength, hlength).
Whereas in linear convolution N>= xlength+hlength-1.
10.5 Procedure:
1. Open the Code Composer Studio by double-clicking on the Code Composer Studio 6.1.2
icon on the desktop.
2. Make sure the DSP kit is turned on
3. If you are launching the 6.1.2 for the first time, a WELCOME window will appear, the
user has to click on the CCS box to launch the project explorer window.
4. Click on the “Project” at the MENU bar & select New ccs project.
5. Target type LCDKC6748 AND also select LCDK and from the options select
LCDKC6748.
6. In the Connection, select Texas Instruments XDS100v3 USB Emulator.
7. Give project name. and select empty project (with main.c).
8. Wright the program on the main.c window.
9. Build the program using the Build icon
10. Compile the program using the ‘Project-compile’ icon.
11. Run the program using resume icon.
10.6 Programs:-
#include<stdio.h>
#include<math.h>
int y[20];
main()
{
int N=6;
int p;
intn,m;
int x[15]={1,1,1,1};
int h[15]={1,2,3,4};
for(m=0;m<N;m++)
{ y[m]=0;
for(n=0;n<N;n++)
{
if(-n+m<0)
{
p=-n+m+N;
}
else
p=-n+m;
y[m]+=x[n]*h[p];
}
printf("circular convolution");
printf("%d\n",y[m]);
}
}
10.7 Results :
CIRCULAR CONVOLUTION OUTPUT IS :
35 35 30 20 30
10.8 Discussions:
Calculations:-
11.1 Objective:
To compute the N (=4/8/16) point DFT of the given sequence
11.5 Procedure:
1. Open the Code Composer Studio by double-clicking on the Code Composer Studio 6.1.2
icon on the desktop.
2. Make sure the DSP kit is turned on
3. If you are launching the 6.1.2 for the first time, a WELCOME window will appear, the
user has to click on the CCS box to launch the project explorer window.
4. Click on the “Project” at the MENU bar & select New ccs project.
5. Target type LCDKC6748 AND also select LCDK and from the options select
LCDKC6748.
6. In the Connection, select Texas Instruments XDS100v3 USB Emulator.
7. Give project name. and select empty project (with main.c).
8. Wright the program on the main.c window.
11.6 Program:
#include<stdio.h>
#include<math.h>
#define pi 3.14
main()
{
float XR[10],XI[10],x[10],sum1,sum2;
inti,N,n,k;
printf(“enter the length of the sequence\n”);
scanf(“%d”,&N);
printf(“enter the sequence\n”);
for(i=0;i<N;i++)
scanf(“%f”,&x[i]);
for(k=0;k<N;k++)
{
sum1=0;
sum2=0;
for(n=0;n<N;n++)
{
sum1+= x[n]*cos((2*pi*k*n)/N);
sum2+=x[n]*sin((2*pi*k*n)/N);
}
XR[k]=sum1;
X1[k]=sum2;
}
for(i=0;i<N;i++)
printf(“%f+i %f \n”,XR[i],XI[i]);
}
11.7 Results :
Enter the length of the sequence
8
Enter the sequence
1 2 3 0 4 -2 5 7
Answer :
20.000000+i0.000000
4.758184+i4.132094
-3.045350+i-6.983950
-10.780513+i-0.050660
6.000050+i-0.017520
-10.773189+i0.238967
-2.863469+i7.046662
4.917140+i4.044250
11.8 Discussions:
Calculations:-
12.1 Objective:
To find the Impulse response of the given first order / second order system
12.5 Procedure:
1. Open the Code Composer Studio by double-clicking on the Code Composer Studio 6.1.2
icon on the desktop.
2. Make sure the DSP kit is turned on
3. If you are launching the 6.1.2 for the first time, a WELCOME window will appear, the
user has to click on the CCS box to launch the project explorer window.
4. Click on the “Project” at the MENU bar & select New ccs project.
5. Target type LCDKC6748 AND also select LCDK and from the options select
LCDKC6748.
6. In the Connection, select Texas Instruments XDS100v3 USB Emulator.
7. Give project name. and select empty project (with main.c).
8. Wright the program on the main.c window.
9. Build the program using the Build icon
10. Compile the program using the ‘Project-compile’ icon.
11. Run the program using resume icon.
12.6 Program:
#include<stdio.h>
main()
{
intn,k,i,order,len;
float a[20],b[20];
float h[20],sum;
printf(“enter the order :\n”);
scanf(“%d”, &order);
printf(“enter the length of sequence:\n”);
scanf(“%d”,&len);
printf(“enter the a coefficients of y(n):\n”);
for(i=0;i<(order+1);i++)
scanf(“%f”,&a[i]);
printf(“enter the a coefficicients x(n):\n”);
for(i=0;i<(order+1);i++)
scanf(“%f”,&b[i]);
for(n=0;n<len;n++)
{ sum=0;
for(k=l;k<=order;k++)
if((n-k)>=0)
sum+=a[k]*h[n-k];
if((n-k)>=0)
sum+=a[k]*h[n-k];
if(n<=order)
h[n]=b[n]-sum;
else
h[n]=-sum;
printf(“\nh[%d]=%f”,n,h[n]);
}
}
12.7 Results :
Enter the order :
2
0.1311
0.2622
0.1311
h[0]=0.131100
h[1]=0.360237
h[2]=0.364799
h[3]=0.174741
h[4]=0.031373
h[5]=-0.024104
h[6]=-0.026565
h[7]=-0.013304
h[8]=-0.002718
h[9]=0.001589
12.7 Discussions:
Calculation:-
13.1 Objective:
Realization of an FIR filter (any type ) to meet given specifications. The input can be a
signal from function generator / speech signal.
13.4 Introduction:
In signal processing, a finite impulse response (FIR) filter is a filter whose impulse
response (or response to any finite length input) is of finite duration, because it settles to zero
in finite time. This is in contrast to infinite impulse response (IIR) filters, which may have
internal feedback and may continue to respond indefinitely (usually decaying).
The impulse response (that is, the output in response to a Kronecker delta input) of an Nth-
order discrete-time FIR filter lasts exactly N + 1 samples (from first nonzero element through
last nonzero element) before it then settles to zero.
13.5 Procedure:
1. Open the Code Composer Studio by double-clicking on the Code Composer Studio 6.1.2
icon on the desktop.
2. Make sure the DSP kit is turned on
3. If you are launching the 6.1.2 for the first time, a WELCOME window will appear, the
user has to click on the CCS box to launch the project explorer window.
4. Click on the “Project” at the MENU bar & select Edit the New Project Launcher as in family
c6000.
13.6 Program:
#include "FIRcfg.h"
#include "dsk6713.h"
#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.144802,0.063010,0.000000,-0.031505,-0.033416,
-0.018003, 0 ,0.010502, 0.011139,0.005728,0.000000, -0.002423,-0.001591, 0.0};
static short in_buffer[100];
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;Uint32 l_input, r_input,l_output,
r_output;
13.7 Results :
The output plot is observed on the CRO. This behaves as a highpass filter.
See the effect of filtering by giving a sinusoidal input to DSP kit and slowly varying its
frequency in the range from 0 to 3.5 kHz. What is the cutoff frequency of the filter?
Change the filter co-efficients for different types of window & Cut-off frequencies
13.8 Discussions:
Calculations:-
14.1 Objectives:
To generate the waveform for the following signals using OCTAVE.
1) Sine Wave signal
2) Cosine Wave signal
3) Saw Tooth Wave signal
4) Square Wave signal
14.2 Software Required:
Octave software
14.3 Pre-Requisite:
Basics of signal processing.
14.4 Introduction:
In electronics, acoustics, and related fields, the waveform of a signal is the shape of
its graph as a function of time, independent of its time and magnitude scales and of any
displacement in time.
14.5 Procedure:
1. Turn on PC
2. Open the octave software already installed in a PC
3. In octave open the new script file.
4. Save the file as any name with .m extension.
5. Type the program and save it. And compile the program using run option or F5.
6. After compilation give the input and observe the output, Graph.
14.6 Program:
1) To generate a sinusoidal signal
clear all;
close all;clc;
N = input('enter the number of cycles....');
t = 0:0.05:N;
x = sin(2*pi*t);
subplot(121);
plot(t,x);
xlabel('---> time'); ylabel('--->
amplitude'); title('analog
sinusoidal signal');
subplot(122);
stem(t,x);
xlabel('---> time'); ylabel('--->
amplitude'); title('discrete
sinusoidal signal');
2) To generate a Cosine Wave signal
clear all;
close all;
clc;
N = input('enter the number of cycles....');
t = 0:0.05:N;
x = cos(2*pi*t);
subplot (1,2,1);
plot(t,x);
xlabel('---> time'); ylabel('--
-> amplitude'); title('analog
cosine signal');
subplot(122);
stem(t,x);
xlabel('---> time'); ylabel('---
> amplitude'); title('discrete
cosine signal');
end;
subplot(2,1,1);
plot(t); grid on;
xlabel('---> time');
ylabel('---> amplitude');
title('analog saw tooth signal');
subplot(2,1,2);
stem(t);
grid on;
xlabel('---> time'); ylabel('--->
amplitude'); title('discrete saw
tooth signal');
14.7 Results :
To generate a sinusoidal signal
14.8 Discussions:
Calculations:-
CO-PO-PSO Mapping
POs
1 2 3 4 5 6 7 8 9 10 11 12 PSO1 PSO2
COs
C313.1 3 2 3 2 1 3 1 3
C313.2 3 2 3 2 1 3 1 3
C313.3 3 2 1 3 2 1 3 1 3
C313.4 3 2 1 3 2 1 3 1 3
C313.5 3 2 1 3 2 1 3 1 3