Record Vikas
-
Upload
elangovan-devaki -
Category
Documents
-
view
234 -
download
1
Transcript of Record Vikas
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 1/77
LINEAR CONVOLUTION
%EXPERIMENT NO 1: LINEAR CONVOLUTION USING FORMULA
%NAME :V.VIKAS
%R.NO : 08H61A04C2
%AIM:To generate ouput y(n) by using linear convolution(using formula) with the help of matlabsoftware.
%APPARATUS: MATLAB 7.5.0,PC
%THEORY:
%Syntax
%w = conv(u,v)Descriptionw = conv(u,v) convolves vectors u and v.
%Algebraically, convolution is the same operation as multiplying the polynomials
%Then w is the vector of length m+n-1 whose k the element is%The sum is over all the values of j which lead to
%legal subscripts for u(j) and v(k+1-j),
%specifically j = max(1,k+1-n): min(k,m).
%When m = n, this
%gives w(1) = u(1)*v(1)
%w(2) = u(1)*v(2)+u(2)*v(1)
%w(3) = u(1)*v(3)+u(2)*v(2)+u(3)*v(1)...%w(n) = u(1)*v(n)+u(2)*v(n-1)+ ... +u(n)*v(1)...
%w(2*n-1) = u(n)*v(n)
SOURCE CODE
clc; %clear the command window
clear all; %clear the previous workspace
close all; %close the figure window
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 2/77
disp('linear convolution program'); %disp(X) displays an array, without printing the arrayname. If X contains a text string, the string is displayed.
X = input('enter input x(n)'); %scanning x(n) and storing in x
m = length(X); % m stores length of x
h = input('enter input h(n)'); %scanning h(n) and storing in h
n = length(h); % n stores length of h
x = [X , zeros(1,m)]; %padding zeros to make unique length
subplot(2,2,1); %subplot divides the current figure into rectangular panes that
are numbered rowwise.
stem(X); %A two-dimensional stem plot displays data as lines extending
from a baseline along the x-axis.
title('input sequences X(n) is:'); %The title is located at the top and in the center of the
axes.
Xlabel('--->n'); %giving label to x axis
Ylabel('--->X(n) is:') %giving label to y axis
grid; %grid sets the XGrid, YGrid, and ZGrid properties of the axes.
h = [h , zeros(1,m)]; %padding zeros to make unique length
subplot(2,2,2); %subplot divides the current figure into rectangular panes that
are numbered rowwise.
stem(h); %A two-dimensional stem plot displays data as lines extending
from a baseline along the h-axis.
title('input sequence h(n) is:'); %The title is located at the top and in the center of the
axes.
Xlabel('--->n'); %giving label to x axis
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 3/77
Ylabel('--->h(n)'); %giving label to y axis
grid; %grid sets the XGrid, YGrid,and ZGrid properties of the axes.
disp('convolution of X(n) & h(n) is y(n):'); %disp(X) displays an array, without printing the
array name. If X contains a text string, the string is displayed.
y = zeros(1 , m+n-1); %padding zeros to make unique length
for i=1:m+n-1 %for loop for i varying from 1 to m+n-1
y(i)=0; %assigning 0 to y(i)
for j=1:m+n-1 %for loop for j varying from 1 to m+n-1
if(j<i+1) %if condition
y(i)=y(i)+x(j)*h(i-j+1); %formula
end %end of if condition
end %end of 2nd for loop
end %end of 1st for loop
subplot(2,2,[3,4]); %subplot divides the current figure into rectangular panes that
are numbered rowwise.
stem(y); %A two-dimensional stem plot displays data as lines extending
from a baseline along the y-axis.
title('convolution of x(n) & h(n) is:'); %The title is located at the top and in the center of the
axes.
Xlabel('--->n'); %giving label to x axis
Ylabel('--->y(n)'); %giving label to y axis
grid; %grid sets the XGrid, YGrid,and ZGrid properties of the axes.
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 4/77
%PROCEDURE
%1.Switch on the system and open matlab application.
%2.create an m-file,write the program with correct syntax and semantics.
%3.save and run the program by using F5 key.
%4.check the command window for errors and debug it.
%5.observe the waveforms.
%RESULT:The sequences [1 2 3 4] is given as input and named as x(n) and
%the sequence [4 3 2 1] is given as another input and named as h(n).the
%convolution of these two sequences is done and the output [4 11 20 30 20
%11 4] is obtained.
1 2 3 40
1
2
3
4input sequences X(n) is:
--->n
- - - > X ( n ) i s :
0 2 4 6 80
1
2
3
4input sequence h(n) is:
--->n
- - - > h ( n )
1 2 3 4 5 6 70
10
20
30convolution of x(n) & h(n) is:
--->n
- - - > y ( n )
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 5/77
CIRCULAR CONVOLUTION
%EXPERIMENT NO 2: CIRCULAR CONVOLUTION USING FORMULA
%NAME :V.VIKAS
%R.NO : 08H61A04C2
%AIM:To generate ouput y(n) by using circular convolution(using formula) with the help of
matlab software.
%APPARATUS: MATLAB 7.5.0,PC
%THEORY:
Circular convolution is used to convolve two discrete Fourier transform (DFT) sequences.
%For very long sequences, circular convolution may be faster than linear convolution.
%c = cconv(a,b,n) circularly convolves vectors a and b. n is the length of the resulting vector.
%If you omit n, it defaults to length(a)+length(B)-1.
%When n = length(a)+length(B)-1.
%You can also use cconv to compute the circular cross-correlation of two sequences
Circular convolution is used to convolve two discrete Fourier transform(DFT) sequences. For very
long sequences, circular convolution may be fasterthan linear convolution.c = cconv(a,b,n)
circularlyconvolves vectors a and b. n isthe length of the resulting vector. If you omit n, it
defaultsto length(a)+length(B)-1. When n = length(a)+length(B)-1,the circular convolution is
equivalent to the linear convolution computedwith conv.
You can also use cconv tocompute the circular cross-correlation of two sequences (see the example
below).ExamplesThe following example calculates a modulo-4 circular convolution. a = [2 1 2 1];
b = [1 2 3 4];
c = cconv(a,b,4)
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 6/77
%SOURCE CODE:
clc; %clear the command window
clear all; %clear the previous workspace
close all; %close the figure window
disp('circular convolution program'); %disp(X) displays an array, without printing the array
name. If X contains a text string, the string is displayed.
x=input('enter input x'); %scanning x(n) and storing in x
Nx=length(x); % Nx stores length of x
h=input('enter input h'); %scanning h(n) and storing in h
Nh=length(h); % Nh stores length of h
subplot(2,2,1); %subplot divides the current figure into rectangular panes that are
numbered rowwise.
stem(x); %A two-dimensional stem plot displays data as lines extending from a
baseline along the x-axis.
title('x(n) sequence'); %The title is located at the top and in the center of the axes.
xlabel('------>n'); %giving label to x axis
ylabel('------->x(n)'); %giving label to y axis
grid; %grid sets the XGrid, YGrid, and ZGrid properties of the axes.
subplot(2,2,2); %subplot divides the current figure into rectangular panes that are
numbered rowwise.
stem(h); %A two-dimensional stem plot displays data as lines extending from a
baseline along the h-axis.
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 7/77
title('h(n) sequence'); %The title is located at the top and in the center of the axes.
xlabel('------->n'); %giving label to x axis
ylabel('------->h(n)'); %giving label to y axis
grid; %grid sets the XGrid, YGrid,and ZGrid properties of the axes.
N=max(Nx,Nh); %returns an array the same size as A and B with the largest
elements taken from A or B. The dimensions of A and B must match, or they may be scalar.
x=[x zeros(1,N-Nx)]; %adding zeros to sequence x if necessary
h=[h zeros(1,N-Nh)]; %adding zeros to sequence h if necessary
m=0:1:N-1; %initialising m
M=mod(-m,N); %if N ~= 0,returns m - n.*N where n = floor(-m./N).If N is not an
integer and the quotient -m./N is within round off error of an integer, then n is that integer.
h=h(M+1); %incrementing the value of the sequence
for n=1:1:N; %initialising the loop
m=n-1; %equating m to n-1
p=0:1:N-1; %intialising p
q=mod(p-m,N); %if N ~= 0,returns m - n.*N where n = floor(p-m./N).If N is not an
integer and the quotient p-m./N is within round off error of an integer, then n is that integer.
hm=h(q+1); %incrementing the value of the sequence within the loop
H(n,:)=hm; %size of detail coefficients(N-i+2) for i = 2, ...N+1 and S(N+2,:) =
size(X).
end %ending the loop
y=x*H' %multiplying x with H'
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 8/77
k=0:N-1; %initialising k
subplot(2,2,3); %subplot divides the current figure into rectangular panes that are
numbered rowwise.
stem(k,y); %plots X versus the columns of Y. X and Y must be vectors or
matrices of the same size.
subplot(2,2,[3,4]); % creates an axes at the position specified by a four-element vector.
left, bottom, width, and height are in normalized coordinates
stem(y); %A two-dimensional stem plot displays data as lines extending from abaseline along the x-axis.
title('convolution of x(n) & h(n)'); %The title is located at the top and in the center of the axes.
xlabel('----->n'); %giving label to x axis
ylabel('----->y(n)'); %giving label to y axis
grid; %grid sets the XGrid, YGrid, and ZGrid properties of the axes.
%PROCEDURE:
%1.Switch on the system and open matlab application.
%2.create an m-file,write the program with correct syntax and semantics.
%3.save and run the program by using F5 key.
%4.check the command window for errors and debug it.
%5.observe the waveforms.
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 9/77
%RESULT:The sequences [1 2 3 2] is given as input and named as x(n) and
%the sequence [1 1 1 ] is given as another input and named as h(n).the
%circular convolution of these two sequences is done and the output [6 5 6 7] is obtained.
1 2 3 40
1
2
3
x(n) sequence
------>n
- - - - - - - > x ( n )
1 1.5 2 2.5 30
0.5
1
h(n) sequence
------->n
- - - - - - - > h ( n )
1 1.5 2 2.5 3 3.5 40
2
4
6
8convolution of x(n) & h(n)
----->n
- - - - - > y ( n )
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 10/77
SUM OF SINUSOIDAL SIGNALS
%EXPERIMENT NO 3:SUM OF SINUSOIDAL SIGNALS
%ROLL NO.:08H61A04C2
%NAME: V.VIKAS
%AIM:To write a program for sum of sinusoidal signals using matlab7.0
%APPARATUS: MATLAB 7.0,PC
%THEORY:
%The general form of sine is sin(x).
%There are to types of sine harmonics.
%They are EVEN HARMONiCS and ODD HARMONICS.
%The general formula for even harmonics is sin((2*n*t)/(2*n)).
%The general formula for odd harmonics is sin((2*n+1)*t/(2*n+1)).
%SOURCE CODE(EVEN HARMONICS)
clc; %Clear Command Window
clear all; %All functions, global variables, and classes are cleared in both the
function workspace and in your base workspace.
close all; %deletes all figures whose handles are not hidden.
t=0:0.01:pi; %initialising t ranging from 0 to pi with interval 0.01
y1=sin(2*t)/2; %defining y1 interms of sine
y2=sin(4*t)/4; %defining y2 interms of sine
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 11/77
y3=sin(6*t)/6; %defining y3 interms of sin.
y4=sin(8*t)/8; %defining y4 interms of sine
y5=sin(10*t)/10; %defining y5 interms of sine
y6=sin(12*t)/12; %defining y6 interms of sine
y=y1+y2+y3+y4+y5+y6; %adding y1,y2,y3,y4,y5,y6 and naming it as y
subplot(2,1,1); %divides the current figure into rectangular panes that are
numbered rowwise
plot(t,y,t,y1,t,y2,t,y3,t,y4,t,y5,t,y6); %plotting graph y,y1,y2,y3,y4,y5,y6 wrt t
title('even harmonics'); %outputs the string at the top and in the center of the current
axes
legend('y','y1','y2','y3','y4','y5','y6'); %displays a legend in the current axes using the specified
strings to label each set of data.
xlabel('amplitude'); %labelling x-axis as amplitude
ylabel('time period'); %labelling y-axis as time period
SOURCE CODE(ODD HARMONICS);
t=0:0.01:pi; %initialising t ranging from 0 to pi with interval 0.01
y1=sin(1*t)/1; %defining y1 interms of sine
y2=sin(3*t)/3; %defining y2 interms of sine
y3=sin(5*t)/5; %defining y3 interms of sine
y4=sin(7*t)/7; %defining y4 interms of sine
y5=sin(9*t)/9; %defining y5 interms of sine
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 12/77
y6=sin(11*t)/11; %defining y6 interms of sine
y=y1+y2+y3+y4+y5+y6; %adding y1,y2,y3,y4,y5,y6 and naming it as y
subplot(2,1,2); %divides the current figure into rectangular panes that are
numbered rowwise
plot(t,y,t,y1,t,y2,t,y3,t,y4,t,y5,t,y6); %plotting graph y,y1,y2,y3,y4,y5,y6 wrt t
title('odd harmonics'); %outputs the string at the top and in the center of the current
axes
legend('y','y1','y2','y3','y4','y5','y6'); %displays a legend in the current axes using the specified
strings to label each set of data.
xlabel('amplitude'); %labelling x-axis as amplitude
ylabel('time period'); %labelling y-axis as time period
%PROCEDURE:
%1)Open the MATLAB7.0
%2)Go to file,open new file and click on M-file.
%3)Write the source code in editing.
%4)Go to file & save the file.
%5)Then go to debug & click on RUN.
%6)Observe the obtain graph.
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 13/77
%RESULT : Hence the even and odd harmonics of the given sine signals is computed.
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 14/77
FAST FOURIER TRANSFORMATION
%EXPERIMENT NO 4: FAST FOURIER TRANSFORMATION
%NAME :V.VIKAS
%R.NO : 08H61A04C2
%Aim:To perform fast fourier transformation of a sequence using MATLAB
%Apparatus:MATLAB7.0,Computer
%Theory:
%The FFT block computes the fast Fourier transform (FFT) of each channel of a P-by-N or
length-P input, u.
%When the Inherit FFT length from input dimensions check box is selected,
%the input length P must be an integer power of two, and the FFT length M is equal to P.
%When the check box is not selected, P can be any length, and the value of
%the FFT length parameter must be a positive integer power of two.
%For user-specified FFT lengths, when M is not equal to P, zero padding or
%modulo-M data wrapping happens before the FFT operation.
%y = fft(u,M).
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 15/77
%SOURCE CODE:
xn=input('enter sequence'); %scanning x(n) and storing in xn
N=input('enter length'); %scanning the length and stores in L
L=length(xn); % L stores length of x
subplot(3,1,1); %subplot divides the current figure into rectangular panes that are
numbered rowwise
stem(xn); %plots the data sequence Y as stems that extend from equally spaced and
automatically generated values along the x-axis.
if(N<L) %initializing if statement
error('N must be >= L'); %displays an error message and returns control to the keyboard
end %ending the if statement
x1=[xn,zeros(1,N-L)]; %defining x1
for k=0:1:N-1 %initialising the loop
for n=0:1:N-1 %initialising the another loop within the main loop
p=exp(-i*2*pi*n*k/N); %defining p
x2(k+1,n+1)=p; %defining x2
end %ending the loop present in the main loop
end %ending the main loop
xk=x1*x2; %defining xk
magxk=abs(xk); %defining magxk
argxk=angle(xk); %definig argxk
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 16/77
k=0:N-1; %k ranges fron 0 to N-1
subplot(3,1,2); %subplot divides the current figure into rectangular panes that are
numbered rowwise
stem(k,magxk); %plots X versus the columns of Y. X and Y must be vectors or matrices
of the same size. Additionally, X can be a row or a column vector and Y a matrix with length(X)
rows.
xlabel('k'); %giving label to x axis
ylabel('|x(k)|'); %giving label to y axis
subplot(3,1,3); %subplot divides the current figure into rectangular panes that are
numbered rowwise
stem(k,argxk); %plots X versus the columns of Y. X and Y must be vectors or matrices
of the same size. Additionally, X can be a row or a column vector and Y a matrix with length(X)
rows.
xlabel('k'); %giving label to x axis
ylabel('argxk'); %giving label to y axis
%PROCEDURE:
%1.Switch on the system and open matlab application.
%2.create an m-file,write the program with correct syntax and semantics.
%3.save and run the program by using F5 key.
%4.check the command window for errors and debug it.
%5.observe the waveforms.
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 17/77
%RESULT:Hence the fast fourier transformation is performed for the sequence
%[1 2 4 8 3 2] and the obtained magnitude response is
%[20 12.32 4 4.014 4 4.014 4 12.32] and the phase response is
%[0 -2.24 1.57 -0.42 -3.14 0.42 -1.57 2.24].
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 18/77
FREQUENCY RESPONE OF THE LOW PASS/HIGH PASS
BUTTERWORTH FILTER
%EXPERIMENT NO 5: FREQUENCY RESPONSE OF THE LOW PASS/HIGH PASS%BUTTERWORTH FILTER
%NAME :V.VIKAS
%R.NO : 08H61A04C2
%Aim:To perform Frequency response of the low pass/High pass Butterworth filter using
%MATLAB
%Apparatus:MATLAB7.0,Computer
%BUTTER WORTH LOW PASS FILTER :
%Butter designs lowpass, bandpass, highpass, and bandstop digital andanalog Butterworth filters.
%Butterworth filters are characterized by a magnitude response that is maximally flatin the
%passband and monotonic overall.
%Digital Domain
%[b,a] = butter(n,Wn)
%designs an order n lowpass digital Butterworth filter with normalized cutoff frequency Wn.It
%returns the filter coefficients in length n+1 row vectors b and a, with coefficients in descending
%powers of z.
%Analog Domain
%[b,a] = butter(n,Wn,'s') designs an order n lowpass analog Butterworth
%filter with angular cutoff frequency Wn rad/s.
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 19/77
SOURCE CODE
rp = input('Enter Passband Ripple'); % Input for passband ripple
rs = input('Enter Stopband ripple'); %scanning input for stopand ripple
wp = input('Enter Passband Frequency'); %scanning input for passband frequency
ws = input('Enter Stop Band Frequency'); %scanning input for stopband frequency
fs = input('sampling frequency'); %Scanning Input for sampling frequency
w1 = 2*wp/fs;
w2 = 2*ws*fs;
[n,wn] = buttord(w1,w2,rp,rs,'s'); %buttord calculates the minimum order of a digital
or analog Butterworth filter required to meet a set of filterdesign specifications.
[b,a] = butter(n,wn,'high','s'); %Butterworth IIR filter design using specification
object
w=0:0.01:pi; %w ranges form 0 to pi
[h,om] = freqs(b,a,w); %Frequency response of analog filters
m = 20*log(abs(h)); %Calculating values of m using absolute value of h
plot(om/pi,m); %Plotting om/pi vs m
ylabel('gain in dB'); % Labelling X - axis
xlabel('Normalized Frequency'); % Labelling y - axis
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 20/77
%PROCEDURE :
% 1. OPEN MATLAB 7.0.
% 2. GO TO FILE MENU AND OPEN A NEW M-FILE.
%3. WRITE THE SOURCE CODE IN EDITING
%4. GO TO FILE AND SAVE THE PROGRAM.
%5. GO TO DEBUG AND RUN THE FIEL.
%6. OBSERVE THE OBTAINED GRAPH.
%RESULT:Hence the frequency response of the low pass/high pass butterworth filter is
conducted.
OBSERVED WAVEFORMS:
Low Pass Butterworth Filter
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-8
-7
-6
-5
-4
-3
-2
-1
0x 10
-11
g a i n
i n
d B
Normalized Frequency
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 21/77
High Pass Butterworth Filter
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-340
-320
-300
-280
-260
-240
g a i n
i n
d B
Normalized Frequency
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 22/77
POWER SPECTRAL DENSITY
%EXPERIMENT NO 6: POWER SPECTRAL DENSITY
%NAME :V.VIKAS
%R.NO : 08H61A04C2
%Aim:To obtain power spectral density of a signal using MATLAB
%Apparatus:MATLAB7.0,Computer
%THEORY:
%The goal of spectral estimation is to describe the
%distribution (over frequency) of the power contained in a signal, based on
%a finite set of data. Estimation of power spectra is useful in a variety of
%applications, including the detection of signals buried in wide-band noise.The power spectral
density (PSD)
%of a stationary random process xn is
%mathematically related to the correlation sequence by the discrete-time
%Fourier transform. In terms of normalized frequency
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 23/77
%SOURCE CODE:
clc; %Clear Command Window
clear all; %Remove items from workspace
close all; %Close the figure window
t=0:0.01:1; %Assign values from 0 to 1
x=(2*sin(2*pi*50*t))+(2*sin(2*pi*100*t));
y=x+800*randn(size(t)); %Adding normally distributed random numbers
subplot(2,2,1); %Create axes in tiled positions
plot(y); %2-D line plot
F=fft(y); %Compute fast Fourier transform
subplot(2,2,2); %Create axes in tiled positions
plot(abs(F)); %2-D line plot
c=xcorr(F); %Correlation
subplot(2,2,3); %Create axes in tiled positions
plot(abs(c)); %2-D line plot
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 24/77
%PROCEDURE:
%Open MATLAB 7.0
%Go to file, click on new M-file to open editor window.
%Write the source code in editor window.
%Save the file with '.m' extension.
%Click on 'run' in debug menu to execute code.
%Check for errors in command window.
%Observe the output in figure window.
%RESULT:
%Observed the power spectral density of the given signal.
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 25/77
FREQUENCY RESPONSE OF FIR LPF UNSIG KAISER WINDOW
%EXPERIMENT NO 7: FREQUENCY RESPONSE OF FIP LPF USING KAISER WINDOW
%NAME :V.VIKAS
%R.NO : 08H61A04C2
%Aim:To obtain frequency response of FIR LPF unsing KAISER Window using MATLAB
%Apparatus:MATLAB7.0,Computer
%THEORY:
%A Finite Impulse Response (FIR) filter is a discrete linear time-invariant system
%whose output is based on the weighted summation of a finite number of past inputs.
%An FIR transversal filter structure can be obtained directly from the equation for
%discrete-time convolution.
%FIR – filter is a finite impulse response filter. Order of the filter should be specified.%Infinite response is truncated to get finite impulse response. placing a window of
%finite length does this. Types of windows available are Rectangular, Barlett,
%Hamming, Hanning, Blackmann window etc. This FIR filter is an all zero filter.
%SOURCE CODE:
clc; %Clear Command Window
clear all; %Remove items from workspace
close all; %Remove items from workspace
n=40; %Number of samples
fp=200; %Passband frequency
fs=1000; %Stopband frequency
fn=2*fp/fs; %Normalised frequency
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 26/77
window=kaiser(n+1); %Triangular window
b=fir1(n,fn,window); %window-based finite impulse response filter design
[H,w]=freqz(b,1,128); %Compute the frequency response of filter
gain=abs(H); %Absolute value and complex magnitude
an=angle(H); %Phase angle
subplot(2,1,1); %Create axes in tiled positions
plot(w/pi,gain); %Linear 2-D plot
title('magnitude response of lpf'); %Add title to current axes
xlabel('gain in dB'); %Label the x-axis
subplot(2,1,2); %Create axes in tiled positions
plot(w/pi,an); %Linear 2-D plot
title('phase response'); %Add title to current axes
%PROCEDURE:
%Open MATLAB 7.0
%Go to file, click on new M-file to open editor window.
%Write the source code in editor window.
%Save the file with '.m' extension.
%Click on 'run' in debug menu to execute code.
%Check for errors in command window.
%Observe the output in figure window.
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 27/77
%RESULT:
%Observed the frequency response of FIR LPF using Kaiser window.
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 28/77
FREQUENCY RESPONSE OF FIP LPF USING RECTANGULAR WINDOW
%EXPERIMENT NO 8: FREQUENCY RESPONSE OF FIP LPF USING RECTANGULAR
%WINDOW
%NAME :V.VIKAS
%R.NO : 08H61A04C2
%Aim:To obtain frequency response of FIR LPF unsing RECTANGULAR Window using
%MATLAB
%Apparatus:MATLAB7.0,Computer
%THEORY:
%A Finite Impulse Response (FIR) filter is a discrete linear time-invariant system
%whose output is based on the weighted summation of a finite number of past inputs.
%An FIR transversal filter structure can be obtained directly from the equation for
%discrete-time convolution.
%FIR – filter is a finite impulse response filter. Order of the filter should be specified.
%Infinite response is truncated to get finite impulse response. placing a window of
%finite length does this. Types of windows available are Rectangular, Barlett,
%Hamming, Hanning, Blackmann window etc. This FIR filter is an all zero filter.
%SOURCE CODE:
clc; %Clear Command Window
clear all; %Remove items from workspace
close all; %Remove items from workspace
n=20; %Number of samples
fp=200; %Passband frequency
fs=1000; %Stopband frequency
fn=2*fp/fs; %Normalised frequency
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 29/77
window=rectwin(n+1); %Rectangular window
b=fir1(n,fn,window); %window-based finite impulse response filter design
[H,w]=freqz(b,1,128); %Compute the frequency response of filter
gain=abs(H); %Absolute value and complex magnitude
an=angle(H); %Phase angle
subplot(2,1,1); %Create axes in tiled positions
plot(w/pi,gain); %Linear 2-D plot
title('magnitude response of lpf'); %Add title to current axes
xlabel('gain in dB'); %Label the x-axis
subplot(2,1,2); %Create axes in tiled positions
plot(w/pi,an); %Linear 2-D plot
title('phase response'); %Add title to current axes
%PROCEDURE:
%Open MATLAB 7.0
%Go to file, click on new M-file to open editor window.
%Write the source code in editor window.
%Save the file with '.m' extension.
%Click on 'run' in debug menu to execute code.
%Check for errors in command window.
%Observe the output in figure window.
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 30/77
%RESULT:
%Observed the frequency response of FIR LPF using Rectangular window.
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 31/77
FREQUENCY RESPONSE OF FIP LPF USING TRIANGULAR WINDOW
%EXPERIMENT NO 9: FREQUENCY RESPONSE OF FIP LPF USING TRIANGULAR
%WINDOW
%NAME :V.VIKAS
%R.NO : 08H61A04C2
%Aim:To obtain frequency response of FIR LPF unsing TRIANGULAR Window using
%MATLAB
%Apparatus:MATLAB7.0,Computer
%THEORY:
%A Finite Impulse Response (FIR) filter is a discrete linear time-invariant system
%whose output is based on the weighted summation of a finite number of past inputs.
%An FIR transversal filter structure can be obtained directly from the equation for
%discrete-time convolution.
%FIR – filter is a finite impulse response filter. Order of the filter should be specified.
%Infinite response is truncated to get finite impulse response. placing a window of
%finite length does this. Types of windows available are Rectangular, Barlett,
%Hamming, Hanning, Blackmann window etc. This FIR filter is an all zero filter.
%SOURCE CODE:
clc; %Clear Command Window
clear all; %Remove items from workspace
close all; %Remove items from workspace
n=20; %Number of samples
fp=200; %Passband frequency
fs=1000; %Stopband frequency
fn=2*fp/fs; %Normalised frequency
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 32/77
window=triang(n+1); %Triangular window
b=fir1(n,fn,window); %window-based finite impulse response filter design
[H,w]=freqz(b,1,128); %Compute the frequency response of filter
gain=abs(H); %Absolute value and complex magnitude
an=angle(H); %Phase angle
subplot(2,1,1); %Create axes in tiled positions
plot(w/pi,gain); %Linear 2-D plot
title('magnitude response of lpf'); %Add title to current axes
xlabel('gain in dB'); %Label the x-axis
subplot(2,1,2); %Create axes in tiled positions
plot(w/pi,an); %Linear 2-D plot
title('phase response'); %Add title to current axes
%PROCEDURE:
%Open MATLAB 7.0
%Go to file, click on new M-file to open editor window.
%Write the source code in editor window.
%Save the file with '.m' extension.
%Click on 'run' in debug menu to execute code.
%Check for errors in command window.
%Observe the output in figure window.
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 33/77
%RESULT:
%Observed the frequency response of FIR LPF using Rectangular window.
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 34/77
TO VERIFY LINEAR CONVOLUTION USING TMS320 C6713 DSP PROCESSOR
EXPERIMENT:TO VERIFY LINEAR CONVOLUTION USING C6713DSP PROCESSOR
NAME :V.VIKAS
R.NO : 08H61A04C2
Aim:To verify linear convolution of any two sequences by using C6713DSP processor.
Apparatus: DSP 6713 Kit ,Computer
THEORY:
Syntax
w = conv(u,v)Descriptionw = conv(u,v) convolves vectors u and v.
Algebraically, convolution is the same operation as multiplying the polynomials
Then w is the vector of length m+n-1 whose k the element is
The sum is over all the values of j which lead to
legal subscripts for u(j) and v(k+1-j),
specifically j = max(1,k+1-n): min(k,m).
When m = n, this
gives w(1) = u(1)*v(1)
w(2) = u(1)*v(2)+u(2)*v(1)
w(3) = u(1)*v(3)+u(2)*v(2)+u(3)*v(1)...
w(n) = u(1)*v(n)+u(2)*v(n-1)+ ... +u(n)*v(1)...
w(2*n-1) = u(n)*v(n)
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 35/77
SOURCE CODE:
/* prg to implement linear convolution */
#include<stdio.h>
#define LENGHT1 6 /*Lenght of i/p samples sequence*/
#define LENGHT2 4 /*Lenght of impulse response Co-efficients */
int x[2*LENGHT1-1]={4,3,2,1}; /*Input Signal Samples*/
int h[2*LENGHT1-1]={1,2,3,4}; /*Impulse Response Coefficients*/
int y[LENGHT1+LENGHT2-1];
main()
{
int i=0,j;
for(i=0;i<(LENGHT1+LENGHT2-1);i++)
{
y[i]=0;
for(j=0;j<=i;j++)
y[i]+=x[j]*h[i-j];
}
for(i=0;i<(LENGHT1+LENGHT2-1);i++)
printf("%d\n",y[i]);
}
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 36/77
PROCEDURE:
Open Code Composer Studio, make sure the DSP kit is turned on.
Start a new project using „Project-new‟ pull down menu, save it in a separate directory
(c:\ti\ myprojects) with name „linc.pjt”.
Add the source files “linc.C” in the project using
„Project->add files to project‟ pull down menu.
Add the linker command file “hello.cmd”.
Add the rts file “rts6700.lib”
Compile the program using the „Project-compile‟ pull down menu or by clicking the shortcut
icon on the left side of program window.
Load the program in program memory of DSP chip using the „File-load program” pull down
menu.
Run the program and observe output using graph utility.
RESULT:The sequences [1 2 3 4] is given as input and named as x(n) and
the sequence [4 3 2 1] is given as another input and named as h(n).the
convolution of these two sequences is done and the output [4 11 20 30 20
11 4] is obtained.
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 37/77
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 38/77
TO VERIFY CIRCULAR CONVOLUTION USING TMS320C6713 DSP PROCESSOR
EXPERIMENT:TO VERIFY CIRCULAR CONVOLUTION USING TMS320C6712 DSP
PROCESSOR
NAME :V.VIKAS
R.NO : 08H61A04C2
AIM:To generate ouput y(n) by using circular convolution(using formula) with the help of
TMS320C6712 DSP processor.
APPARATUS:TMS320C6713 DSP PROCESSOR,PC.
THEORY:
Circular convolution is used to convolve two discrete Fourier transform (DFT) sequences.
For very long sequences, circular convolution may be faster than linear convolution.
c = cconv(a,b,n) circularly convolves vectors a and b. n is the length of the resulting vector.
If you omit n, it defaults to length(a)+length(B)-1.
When n = length(a)+length(B)-1.
You can also use cconv to compute the circular cross-correlation of two sequences
Circular convolution is used to convolve two discrete Fourier transform(DFT) sequences. For very
long sequences, circular convolution may be fasterthan linear convolution.c = cconv(a,b,n)
circularlyconvolves vectors a and b. n isthe length of the resulting vector. If you omit n, it
defaultsto length(a)+length(B)-1. When n = length(a)+length(B)-1,the circular convolution is
equivalent to the linear convolution computedwith conv.
You can also use cconv tocompute the circular cross-correlation of two sequences (see the example
below).ExamplesThe following example calculates a modulo-4 circular convolution. a = [2 1 2 1];
b = [1 2 3 4];
c = cconv(a,b,4)
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 39/77
SOURCE CODE:
#include<stdio.h>
intm,n,x[30],h[30],y[30],i,j,temp[30],k,x2[30],a[30];
void main()
{
printf(“ enter the length of the first sequence \ n”);
scanf(“%d”,&m);
printf(“ enter the length of the second sequence \ n”)
scanf(“%d”,&n);
printf(“ enter the first sequence \ n”);
for(i=0;i<m;i++)
scanf(“%d”,&x[i]);
printf(“ enter the second sequence \ n”);
for(j=0;j<n;j++)
scanf(“%d”,&h[j]);
if(m-n!=0) /&if length of both sequences are not eqal*/
{
If(m>n) /* pad the smaller seqeucne with zero*/
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 40/77
{
for(i=n;i<m;i++)
h[i]=0;
n=m;
}
for(i=m;i<n;i++)
x[i]=0;
m=n;
}
y[0]=0;
a[0]=h[0];
for(j=1;j<n;j++?) /*folding h(n) to h(-n)*/
a[j]=h[n-j];
/*circular convolution*/
for(i=0;i<n;i++)
y[0]+=x[i]*a[i];
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 41/77
for(k=1;k<n;k++)
{
y[k]=0;
/*circular shift*/
for(j=1;j<n;j++)
x2[j]=a[j-1];
x2[0]=a[n-1];
for(i=0;i<n;i++]
{
a[i]=x2[i];
y[k]+=x[i]*x2[i];
}
}
/*displaying the result*/
printf(“ the circular convolution is \ n”);
for(i=0;i<n;i++)
printf(“%d \ t”,y[i]);
}
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 42/77
PROCEDURE:
Open Code Composer Studio, make sure the DSP kit is turned on.
Start a new project using „Project-new‟ pull down menu, save it in a separate directory
(c:\ti\ myprojects) with name “cconv.pjt”.
Add the source files “cconv.c” in the project using
„Project->add files to project‟ pull down menu.
Add the linker command file “hello.cmd”.
Add the rts file “rts6700.lib”
Compile the program using the „Project-compile‟ pull down menu or by clicking the shortcut
icon on the left side of program window.
Load the program in program memory of DSP chip using the „File-load program” pull down
menu.
Run the program and observe output using graph utility.
RESULT:The sequences [1 2 3 2] is given as input and named as x(n) and
the sequence [1 1 1 ] is given as another input and named as h(n).the
circular convolution of these two sequences is done and the output [6 5 6 7] is obtained.
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 43/77
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 44/77
TO VERIFY N-POINT FAST FOURIER TRANSFORM (FFT) ALGORITHM USING
TMS320C6713 DSP PROCESSOR
EXPERIMENT:N-POINT FAST FOURIER TRANSFORMATION
NAME :V.VIKAS
R.NO : 08H61A04C2
Aim:To verify fast fourier transformation of a sequence using TMS320C6713 DSP processor
Apparatus:TMS320C6713 DSP PROCESSOR,Computer
Theory:
The FFT block computes the fast Fourier transform (FFT) of each channel of a P-by-N or length-P
input, u.
When the Inherit FFT length f rom input dimensions check box is selected,
the input length P must be an integer power of two, and the FFT length M is equal to P.
When the check box is not selected, P can be any length, and the value of
the FFT length parameter must be a positive integer power of two.
For user-specified FFT lengths, when M is not equal to P, zero padding or
modulo-M data wrapping happens before the FFT operation.
y = fft(u,M).
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 45/77
SOURCE CODE:
Main.c (fft 256.c):
#include <math.h>
#define PTS 64 //# of points for FFT
#define PI 3.14159265358979
typedefstruct {float real,imag;} COMPLEX;
void FFT(COMPLEX*Y<int n); //FFT prototype
floatiobuffer[PTS]; //as input and output buffer
float x 1[PTS]; //intermediate buffer
short i; //general purpose index variable
shortbuffercount = 0; //number of new samples in iobuffer
short flag = 0; //set to 1 by ISR when iobuffer full
COMPLEX w[PTS]; //twiddle constants stored in w
COMPLEX samples [PTS]; //primary working buffer
main()
{
for (i = 0 ; i<PTS ; i++) // set up twiddle constants in w
{
w[i].real = cos(2*PI*i/(PTS*2.0)); //Re component of twiddle constants
w[i].imag = sin(2*PI*i/(PTS*2.0)); //Im component of twiddle constants
}
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 46/77
for (i = 0 ; i < PTS ; i++) //swap buffers
{
iobuffer[i] = sin?(2*PI*10*i/64.0);/* 10-> freq.
64-> sampling freq*/
samples[i].real=0.0;
samples[i].imag=0.0;
}
for (i = 0 ; i < PTS ; i++) // swap buffers
{
Samples[i].real=iobuffer[i]; //buffer with new data
}
for (i = 0 ; i < PTS ; i++)
samples [i].imag = 0.0; //imag components = 0
FFT (samplex, PTS); //call function FFT.c
for (i = 0 ; i < PTS ; i++) //compute magnitude
{
x1[i] = sqrt(samples[i].real*samples[i].real
+samples[i].imag*samples[i].imag);
}
} //end of main
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 47/77
fft.c:
#define PTS 64 //# of points for FFT
typedefstruct {float real.imag;} COMPLEX;
extern COMPLEX w[PTS]; //twiddle constant stored in w
void FFT(COMPLEX *Y, int N) //input sample array, # of points
{
COMPLEX temp1,temp2; //temporary storage variables
inti,j,k; //loop counter variables
intupper_leg, lower_leg; //index of upper/lower butterfly leg
intleg_diff; //difference between upper/lower leg
intnum_stages = 0; //number of FFT stages (iterations)
int index, step; //index/step through twiddle constant
i = 1; //log(Base2) of N points = # of stages
do
{
num_stages +=1;
i = i*2;
}
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 48/77
while (i!=N);
leg_diff=N/2; //difference between upper and lower legs
step = (PTS*2)/N; //step between values in twiddle.h
for (i=0;i <num_stages; i++) //for N-point FFT
{
index = 0
for (j = 0; j <leg_diff; j++)
for (upper_leg = j; upper_leg< N; upper_leg +=(2*leg_diff))
{
lower_leg = upper_leg+leg_diff;
temp1.real = (Y[upper_leg]).real + (Y[lower_leg]).real;
temp1.imag = (Y[upper_leg]).imag + (Y[lower_leg]).imag;
temp2.imag = (Y[upper_leg]).real - (Y[lower_leg]).real;
temp2.imag = (Y[upper_leg]).imag - (Y[lower_leg]).imag;
(Y[lower_leg).real=temp2.real
(w[index]).real-temp2.imag*
(w[index]).imag;
y[lower_leg].imag=temp2.real*
(w[index].imag+temp2.imag*
(w[index]).real;
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 49/77
(Y[upper_leg]).real = temp1.real;
(Y[upper_leg]).imag = temp1.imag;
}
index + = step;
}
leg_diff = leg_diff/2;
step *=2;
}
j = 0;
for (i =1; i <(N-1) ; i++) //bit reversal for resequencing data
{
k = N/2
while (k <=j)
{
j = j - k;
k = k/2;
}
j=j+k;
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 50/77
if (i<j)
{
temp1.real = (Y[j]).real;
temp1.imag = (Y[j]).imag;
(Y[j]).real = (Y[i]).real;
(Y[j]).imag = (Y[i]).imag;
(Y[i]).real = temp1.real;
(Y[i]).imag = temp1.imag;
}
}
return;
}
PROCEDURE:
Open Code Composer Studio, make sure the DSP kit is turned on.
Start a new project using „Project-new‟ pull down menu, save it in a separate directory
(c:\ti\ myprojects) with name „FFT.pjt”.
Add the source files “FFT256.c” and “FFT.C” in the project using
„Project->add files to project‟ pull down menu.
Add the linker command file “hello.cmd”.
Add the rts file “rts6700.lib”
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 51/77
Compile the program using the „Project-compile‟ pull down menu or by clicking the shortcut
icon on the left side of program window.
Load the program in program memory of DSP chip using the „File-load program” pull down
menu.
Run the program and observe output using graph utility.
RESULT:Hence the fast fourier transformation is performed for the sequence
[1 2 4 8 3 2] and the obtained magnitude response is
[20 12.32 4 4.014 4 4.014 4 12.32] and the phase response is
[0 -2.24 1.57 -0.42 -3.14 0.42 -1.57 2.24].
INPUT WAVEFORM:
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 52/77
OUTPUT WAVEFORM:
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 53/77
TO VERIFY POWER SPECTRAL DENSITY USING TMS320C6713 DSP
PROCESSOR
EXPERIMENT: POWER SPECTRAL DENSITY
NAME :V.VIKAS
R.NO : 08H61A04C2
Aim:To verify power spectral density of a signal using TMS320C6713 DSP processor
Apparatus: TMS320C6713 DSP processor ,Computer
THEORY:
The goal of spectral estimation is to describe the
distribution (over frequency) of the power contained in a signal, based on
a finite set of data. Estimation of power spectra is useful in a variety of
applications, including the detection of signals buried in wide-band noise.The power spectral
density (PSD)
of a stationary random process xn is
mathematically related to the correlation sequence by the discrete-time
Fourier transform. In terms of normalized frequency
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 54/77
SOURCE CODE:
#include <math.h>
#define PTS 128 //# of points for FFT
#define PI 3.14159265358979
typedef struct {float real,imag;} COMPLEX;
void FFT(COMPLEX *Y, int n); //FFT prototype
float iobuffer[PTS]; //as input and output buffer
float x1[PTS],x[PTS]; //intermediate buffer
short i; //general purpose index variable
short buffercount = 0; //number of new samples in iobuffer
short flag = 0; //set to 1 by ISR when iobuffer full
float y[128];
COMPLEX w[PTS]; //twiddle constants stored in w
COMPLEX samples[PTS]; //primary working buffer
main()
{
float j,sum=0.0 ;
int n,k,i,a;
for (i = 0 ; i<PTS ; i++) // set up twiddle constants in w
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 55/77
{
w[i].real = cos(2*PI*i/(PTS*2.0)); //Re component of twiddle constants
w[i].imag =-sin(2*PI*i/(PTS*2.0)); /*Im component of twiddle constants*/
}
/****************Input Signal X(n)
********************************************************/
for(i=0,j=0;i<PTS;i++)
{ x[i] = sin(2*PI*5*i/PTS); // Signal x(Fs)=sin(2*pi*f*i/Fs);
samples[i].real=0.0;
samples[i].imag=0.0;
}
/********************Auto Correlation of X(n)=R(t) *********************************/
for(n=0;n<PTS;n++)
{
sum=0;
for(k=0;k<PTS-n;k++)
{
sum=sum+(x[k]*x[n+k]); // Auto Correlation R(t)
}
iobuffer[n] = sum;
}
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 56/77
/********************** FFT of R(t) *****************************/
for (i = 0 ; i < PTS ; i++) //swap buffers
{
samples[i].real=iobuffer[i]; //buffer with new data
}
for (i = 0 ; i < PTS ; i++)
samples[i].imag = 0.0; //imag components = 0
FFT(samples,PTS); //call function FFT.c
/******************** PSD *******************************************/
for (i = 0 ; i < PTS ; i++) //compute magnitude
{
x1[i] = sqrt(samples[i].real*samples[i].real
+ samples[i].imag*samples[i].imag);
}
} //end of main
/*****FFT******/
#define PTS 128 //# of points for FFT
typedef struct {float real,imag;} COMPLEX;
extern COMPLEX w[PTS]; //twiddle constants stored in w
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 57/77
void FFT(COMPLEX *Y, int N) //input sample array, # of points
{
COMPLEX temp1,temp2; //temporary storage variables
int i,j,k; //loop counter variables
int upper_leg, lower_leg; //index of upper/lower butterfly leg
int leg_diff; //difference between upper/lower leg
int num_stages = 0; //number of FFT stages (iterations)
int index, step; //index/step through twiddle constant
i = 1; //log(base2) of N points= # of stages
do
{
num_stages +=1;
i = i*2;
}while (i!=N);
leg_diff = N/2; //difference between upper&lower legs
step = (PTS*2)/N; //step between values in twiddle.h // 512
for (i = 0;i < num_stages; i++) //for N-point FFT
{
index = 0;
for (j = 0; j < leg_diff; j++)
{
for (upper_leg = j; upper_leg < N; upper_leg += (2*leg_diff))
{
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 58/77
lower_leg = upper_leg+leg_diff;
temp1.real = (Y[upper_leg]).real + (Y[lower_leg]).real;
temp1.imag = (Y[upper_leg]).imag + (Y[lower_leg]).imag;
temp2.real = (Y[upper_leg]).real - (Y[lower_leg]).real;
temp2.imag = (Y[upper_leg]).imag - (Y[lower_leg]).imag;
(Y[lower_leg]).real = temp2.real*(w[index]).real
-temp2.imag*(w[index]).imag;
(Y[lower_leg]).imag = temp2.real*(w[index]).imag
+temp2.imag*(w[index]).real;
(Y[upper_leg]).real = temp1.real;
(Y[upper_leg]).imag = temp1.imag;
}
index += step;
}
leg_diff = leg_diff/2;
step *= 2;
}
j = 0;
for (i = 1; i < (N-1); i++) //bit reversal for resequencing data
{
k = N/2;
while (k <= j)
{
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 59/77
j = j - k;
k = k/2;
}
j = j + k;
if (i<j)
{
temp1.real = (Y[j]).real;
temp1.imag = (Y[j]).imag;
(Y[j]).real = (Y[i]).real;
(Y[j]).imag = (Y[i]).imag;
(Y[i]).real = temp1.real;
(Y[i]).imag = temp1.imag;
}
}
return;
}
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 60/77
PROCEDURE:
Open Code Composer Studio, make sure the DSP kit is turned on.
Start a new project using „Project-new‟ pull down menu, save it in a separate directory
(c:\ti\ myprojects) with name „psd.pjt”.
Add the source files “psd.c” and “FFT.C” in the project using
„Project->add files to project‟ pull down menu.
Add the linker command file “hello.cmd”.
Add the rts file “rts6700.lib”
Compile the program using the „Project-compile‟ pull down menu or by clicking the shortcut icon
on the left side of program window.
Load the program in program memory of DSP chip using the „File-load program” pull down
menu.
Run the program and observe output using graph utility.
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 61/77
RESULT: I verified the power spectral density of a signal using TMS320C6713 DSP processor.
INPUT SIGNAL:
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 62/77
OUTPUT SIGNAL:
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 63/77
TO VERIFY FIR FILTER USING TMS320C6713 DSP PROCESSOR
EXPERIMENT:FIR FILTERS
NAME :V.VIKAS
R.NO : 08H61A04C2
Aim:To verify FIR(finite impulse response) filters using TMS320C6713 DSP processor
Apparatus:TMS320C6713 DSP PROCESSOR,Computer
Theory:
A finite impulse response (FIR) filter is a type of a signal processing filter whose impulseresponse (or response to any finite length input) is of finite duration, because it settles to zero in
finite time. The impulse response of an Nth-order discrete-time FIR filter lasts for N+1 samples,
and then dies to zero.
FIR filters can be discrete-time or continuous-time, and digital or analog.
For a discrete-time FIR filter, the output is a weighted sum of the current and a finite number of previous values of the input. The operation is described by the following equation, which defines
the output sequence y[n] in terms of its input sequence x[n] :
SOURCE CODE:
#include<stdio.h>
#include<math.h>
#define pi 3.1415
int n,N,c;
float wr[64],wt[64];
void main()
{
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 64/77
printf("\n enter no. of samples,N= :");
scanf("%d",&N);
printf("\n enter choice of window function\n 1.rect \n 2. triang \n c= :");
scanf("%d",&c);
printf("\n elements of window function are:");
switch(c)
{
case 1:
for(n=0;n<=N-1;n++)
{
wr[n]=1;
printf(" \n wr[%d]=%f",n,wr[n]);
}
break;
case 2:
for(n=0;n<=N-1;n++)
{
wt[n]=1-(2*(float)n/(N-1));
printf("\n wt[%d]=%f",n,wt[n]);
}
break;
}}
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 65/77
PROCEDURE:
Open Code Composer Studio, make sure the DSP kit is turned on.
Start a new project using „Project-new‟ pull down menu, save it in a separate directory
(c:\ti\ myprojects) with name „firf.pjt”.
Add the source files “firf.c” in the project using
„Project->add files to project‟ pull down menu.
Add the linker command file “hello.cmd”.
Add the rts file “rts6700.lib”
Compile the program using the „Project-compile‟ pull down menu or by clicking the shortcut icon
on the left side of program window.
Load the program in program memory of DSP chip using the „File-load program” pull down
menu.
Run the program and observe output using graph utility.
RESULT: I verified FIR(finite impulse response) filter using TMS320C6713 DSP processor.
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 66/77
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 67/77
TO VERIFY IIR USING TMS320C6713 DSP PROCESSOR
EXPERIMENT: IIR FILTERS
NAME :V.VIKAS
R.NO : 08H61A04C2
Aim:To verify IIR (infinite impulse response) filters using TMS320C6713 DSP processor
Apparatus: TMS320C6713 DSP processor ,Computer
THEORY:
Infinite impulse response (IIR) is a property of signal processing systems. Systems with this
property are known as IIR systems or, when dealing with filter systems, as IIR filters. IIR systems
have an impulse response function that is non-zero over an infinite length of time. This is incontrast to finite impulse response (FIR) filters, which have fixed-duration impulse responses. The
simplest analog IIR filter is an RC filter made up of a single resistor (R) feeding into a node
shared with a single capacitor (C). This filter has an exponential impulse response characterizedby an RC time constant. IIR filters may be implemented as either analog or digital filters. In
digital IIR filters, the output feedback is immediately apparent in the equations defining the
output. Note that unlike FIR filters, in designing IIR filters it is necessary to carefully consider the
"time zero" case in which the outputs of the filter have not yet been clearly defined.
SOURCE CODE:
#include<stdio.h>
#include<math.h>
int i,w,wc,c,N;
float H[100];
float mul(float, int);
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 68/77
void main()
{
printf("\n enter order of filter ");
scanf("%d",&N);
printf("\n enter the cutoff freq ");
scanf("%d",&wc);
printf("\n enter the choice for IIR filter 1. LPF 2.HPF ");
scanf("%d",&c);
switch(c)
{
case 1:
for(w=0;w<100;w++)
{
H[w]=1/sqrt(1+mul((w/(float)wc),2*N));
printf("H[%d]=%f\n",w,H[w]);
}
break;
case 2:
for(w=0;w<=100;w++)
{ H[w]=1/sqrt(1+mul((float)wc/w,2*N));
printf("H[%d]=%f\n",w,H[w]);
}
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 69/77
break;
}}
float mul(float a,int x)
{
PROCEDURE:
Open Code Composer Studio, make sure the DSP kit is turned on.
Start a new project using „Project-new‟ pull down menu, save it in a separate directory
(c:\ti\ myprojects) with name “iirf.pjt”.
Add the source files “iirf.c” in the project using
„Project->add files to project‟ pull down menu.
Add the linker command file “hello.cmd”.
Add the rts file “rts6700.lib”
Compile the program using the „Project-compile‟ pull down menu or by clicking the shortcut
icon on the left side of program window.
Load the program in program memory of DSP chip using the „File-load program” pull down
menu.
Run the program and observe output using graph utility.
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 70/77
RESULT: I verified IIR (infinite impulse response) LPF/HPF filters using TMS320C6713 DSPprocessor.
LPF(low pass filter) OUTPUT:
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 71/77
HPF(high pass filter) OUTPUT:
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 72/77
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 73/77
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 74/77
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 75/77
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 76/77
8/3/2019 Record Vikas
http://slidepdf.com/reader/full/record-vikas 77/77