DSP Lab Manual New 2018-19

Download as pdf or txt
Download as pdf or txt
You are on page 1of 45

DSP LAB MANUAL

INDEX
Sl.No. Experiment Name Page No.
Following Experiments to be done using MATLAB / SCILAB / OCTAVE or equivalent:

INTRODUCTION TO MATLAB 2-10


PART-A PROGRAMS
1. Verification of sampling theorem 11-12
Linear and circular convolution of two given sequences, Commutative,
2. 13-18
Distributive and associative property of convolution.
3. Auto and cross correlation of two sequences and verification of their properties 19-22

4. Solving a given difference equation. 23


Computation of N point DFT of a given sequence and to plot magnitude and phase
5. 24-25
spectrum (using DFT equation and verify it by built-in routine).
(i) Verification of DFT properties (like Linearity and Parseval’s theorem, etc.) (ii)
6. 26-28
DFT computation of square pulse and Sinc function etc.
Design and implementation of FIR filter to meet given specifications
7. 29-30
(using different window techniques).
8. Design and implementation of IIR filter to meet given specifications. 31-34

Following Experiments To Be Done Using DSP Kit

INTRODUCTION TO CODE COMPOSER STUDIO (CCS) 35-39

PART-B PROGRAMS

9. Linear convolution of two sequences 40

10. Circular convolution of two sequences 41-42

11. N-point DFT of a given sequence 43

12. Impulse response of first order and second order system 44

13. Implementation of FIR filter 45

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 1


DSP LAB MANUAL

INTRODUCTION TO MATLAB
MATLAB® is a high-performance language for technical computing. It integrates computation,
visualization, and programming in an easy-to-use environment where problems and solutions are
expressed in familiar mathematical notation.

Typical uses include

 Math and computation


 Algorithm development
 Data acquisition
 Modeling, simulation, and prototyping
 Data analysis, exploration, and visualization
 Scientific and engineering graphics
 Application development, including graphical user interface building

MATLAB is an interactive system whose basic data element is an array that does not require
dimensioning. This allows you to solve many technical computing problems, especially those
with matrix and vector formulations, in a fraction of the time it would take to write a program in
a scalar noninteractive language such as C or Fortran.

The name MATLAB stands for matrix laboratory. MATLAB was originally written to provide
easy access to matrix software developed by the LINPACK and EISPACK projects. Today,
MATLAB engines incorporate the LAPACK and BLAS libraries, embedding the state of the art
in software for matrix computation.

MATLAB has evolved over a period of years with input from many users. In university
environments, it is the standard instructional tool for introductory and advanced courses in
mathematics, engineering, and science. In industry, MATLAB is the tool of choice for high-
productivity research, development, and analysis.

MATLAB features a family of add-on application-specific solutions called toolboxes. Very


important to most users of MATLAB, toolboxes allow you to learn and apply specialized
technology. Toolboxes are comprehensive collections of MATLAB functions (M-files) that
extend the MATLAB environment to solve particular classes of problems. Areas in which
toolboxes are available include signal processing, control systems, neural networks, fuzzy logic,
wavelets, simulation, and many others.

The MATLAB System

The MATLAB system consists of five main parts:

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 2


DSP LAB MANUAL

Development Environment. This is the set of tools and facilities that help you use MATLAB
functions and files. Many of these tools are graphical user interfaces. It includes the MATLAB
desktop and Command

Command Window, a command history, an editor and debugger, and browsers for viewing help,
the workspace, files, and the search path.

The MATLAB Mathematical Function Library. This is a vast collection of computational


algorithms ranging from elementary functions, like sum, sine, cosine, and complex arithmetic, to
more sophisticated functions like matrix inverse, matrix eigenvalues, Bessel functions, and fast
Fourier transforms.

The MATLAB Language. This is a high-level matrix/array language with control flow
statements, functions, data structures, input/output, and object-oriented programming features. It
allows both "programming in the small" to rapidly create quick and dirty throw-away programs,
and "programming in the large" to create large and complex application programs. Graphics.

MATLAB has extensive facilities for displaying vectors and matrices as graphs, as well as
annotating and printing these graphs. It includes high-level functions for two-dimensional and
three-dimensional data visualization, image processing, animation, and presentation graphics. It
also includes low-level functions that allow you to fully customize the appearance of graphics as
well as to build complete graphical user interfaces on your MATLAB applications.

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

CONV Convolution and polynomial multiplication.


C = CONV (A, B) convolves vectors A and B. The resulting vector is length LENGTH (A)
+LENGTH (B)-1.
If A and B are vectors of polynomial coefficients, convolving them is equivalent to
multiplying the two polynomials.
Class support for inputs A, B:
Float: double, single
DECONV Deconvolution and polynomial division.
[Q, R] = DECONV (B, A) deconvolves vector A out of vector B. The result is returned in
vector Q and the remainder in vector R such that
B = conv (A, Q) + R.
If A and B are vectors of polynomial coefficients, deconvolution is equivalent to polynomial
division. The result of dividing B by A is quotient Q and remainder R.
Class support for inputs B, A:
Float: double, single
IMPZ Impulse response of digital filter

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 3


DSP LAB MANUAL

[H, T] = IMPZ (B, A) computes the impulse response of the filter B/A choosing the number of
samples for you, and returns the response in column vector H and a vector of times (or sample
intervals) in T
(T = [0 1 2 ...]').
[H, T] = IMPZ (B, A, N) computes N samples of the impulse response.
If N is a vector of integers, the impulse response is computed only at those integer values (0 is
the origin).
[H, T] = IMPZ (B, A, N, Fs) computes N samples and scales T so that samples are spaced 1/Fs
units apart. Fs is 1 by default.
[H, T] = IMPZ (B, A, [], Fs) chooses the number of samples for you and scales T so that samples
are spaced 1/Fs units apart.
IMPZ with no output arguments plots the impulse response using STEM (T, H) in the current
figure window.
FFT Discrete Fourier transforms.
FFT(X) is the discrete Fourier transform (DFT) of vector X. For matrices, the FFT operation
is applied to each column. For N-D arrays, the FFT operation operates on the first non-singleton
dimension.
FFT(X, N) is the N-point FFT, padded with zeros if X has less than N points and truncated if
it has more.
FFT(X, [], DIM) or FFT(X, N, DIM) applies the FFT operation across the dimension DIM.
For length N input vector x, the DFT is a length N vector X,with elements
N
X(k) = sum x(n)*exp(-j*2*pi*(k-1)*(n-1)/N), 1 <= k <= N.
n=1
The inverse DFT (computed by IFFT) is given by
N
x(n) = (1/N) sum X(k)*exp( j*2*pi*(k-1)*(n-1)/N), 1 <= n <= N.
n=1
IFFT Inverse discrete Fourier transform.
IFFT(X) is the inverse discrete Fourier transform of X.
IFFT(X, N) is the N-point inverse transform.
IFFT(X, [], DIM) or IFFT(X, N, DIM) is the inverse discrete Fourier transform of X across the
dimension DIM.
IFFT (..., 'symmetric') causes IFFT to treat F as conjugate symmetric along the active
dimension. This option is useful when F is not exactly conjugate symmetric merely because of
round-off error.
IFFT (..., 'nonsymmetric') causes IFFT to make no assumptions about the symmetry of F.
FLIPLR Flip matrix in left/right direction.
FLIPLR(X) returns X with row preserved and columns flipped in the left/right direction.
X = 1 2 3 becomes 3 2 1
456 654

XLABEL X-axis label.


XLABEL ('text') adds text beside the X-axis on the current axis.
XLABEL ('text','Property1', PropertyValue1,'Property2', PropertyValue2,) sets the values of
the

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 4


DSP LAB MANUAL

specified properties of the xlabel.


XLABEL (AX,...) adds the xlabel to the specified axes.
H = XLABEL (...) returns the handle to the text object used as the label.
YLABEL Y-axis label.
YLABEL ('text') adds text beside the Y-axis on the current axis.
YLABEL ('text','Property1', PropertyValue1,'Property2', PropertyValue2,...)
Sets the values of the specified properties of the ylabel.
YLABEL (AX,...) adds the ylabel to the specified axes.
H = YLABEL (...) returns the handle to the text object used as the label.
PLOT linear plot.
PLOT(X, Y) plots vector Y versus vector X. If X or Y is a matrix, then the vector is plotted
versus the rows or columns of the matrix, whichever line up. If X is a scalar and Y is a vector,
length(Y) disconnected points are plotted.
PLOT(Y) plots the columns of Y versus their index. If Y is complex, PLOT(Y) is equivalent to
PLOT (real(Y), imag(Y)). In all other uses of PLOT, the imaginary part is ignored.
Various line types, plot symbols and colors may be obtained with
PLOT(X, Y, S) where S is a character string made from one element from any or all the
following 3 columns:
b blue . point - solid
g green o circle : dotted
r red x x-mark -. dashdot
c cyan + plus -- dashed
m magenta * star (none) no line
y yellow s square
k black d diamond
v triangle (down)
^ triangle (up)
< triangle (left)
> triangle (right)
p pentagram
h hexagram
For example, PLOT(X,Y,'c+:') plots a cyan dotted line with a plus at each data point; PLOT(X,
Y, 'bd') plots blue diamond at each data point but does not draw any line.
PLOT(X1, Y1, S1, X2, Y2, S2, X3, Y3, S3,) combines the plots defined by the (X,Y,S) triples,
where the X's and Y's are vectors or matrices and the S's are strings.
For example, PLOT(X,Y,'y-',X,Y,'go') plots the data twice, with a solid yellow line interpolating
green circles at the data points. The PLOT command, if no color is specified, makes automatic
use of the colors specified by the axes Color Order property. The default Color Order is listed in
the table above for color systems where the default is blue for one line, and for multiple lines, to
cycle through the first six colors in the table. For monochrome systems, PLOT cycles over the
axes LineStyleOrder property.
If you do not specify a marker type, PLOT uses no marker. If you do not specify a line style,
PLOT uses a solid line.
PLOT (AX,...) plots into the axes with handle AX.
PLOT returns a column vector of handles to lineseries objects, one handle per plotted line.

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 5


DSP LAB MANUAL

The X, Y pairs, or X, Y, S triples, can be followed by parameter/value pairs to specify


additional properties of the lines. For example, PLOT(X,Y,'LineWidth',2,'Color',[.6 0 0]) will
create a plot with a dark red line width of 2 points.
Backwards compatibility
PLOT ('v6',...) creates line objects instead of lineseries objects for compatibility with
MATLAB 6.5 and earlier.
SUBPLOT Create axes in tiled positions.
H = SUBPLOT(m,n,p), or SUBPLOT(mnp), breaks the Figure window into an m-by-n matrix
of small axes, selects the p-th axes for for the current plot, and returns the axis handle. The axes
are counted along the top row of the Figure window, then the second row, etc. For example,
SUBPLOT (2,1,1), PLOT(income)
SUBPLOT (2,1,2), PLOT(outgo) plots income on the top half of the window and outgo on
the bottom half.
SUBPLOT (m,n,p), if the axis already exists, makes it current.
SUBPLOT (m,n,p,'replace'), if the axis already exists, deletes it and creates a new axis.
SUBPLOT (m,n,p,'align') places the axes so that the plot boxes are aligned instead of
preventing the labels and ticks from overlapping.
SUBPLOT (m,n,P), where P is a vector, specifies an axes position that covers all the subplot
positions listed in P.
SUBPLOT (H), where H is an axis handle, is another way of making an axis current for
subsequent plotting commands.
SUBPLOT ('position',[left bottom width height]) creates an axis at the specified position in
normalized coordinates (in the range from 0.0 to 1.0).
SUBPLOT (m,n,p, PROP1, VALUE1, PROP2, VALUE2, ...) sets the specified property-
value pairs on the subplot axis. To add the subplot to a specific figure pass the figure handle as
the value for the 'Parent' property.
If a SUBPLOT specification causes a new axis to overlap an existing axis, the existing axis is
deleted - unless the position of the new and existing axis is identical. For example, the statement
SUBPLOT(1,2,1) deletes all existing axes overlapping the left side of the Figure window and
creates a new axis on that side - unless there is an axes there with a position that exactly matches
the position of the new axes (and 'replace' was not specified), in which case all other
overlapping axes will be deleted and the matching axes will become the current axes.
SUBPLOT (111) is an exception to the rules above, and is not identical in behavior to
SUBPLOT(1,1,1). For reasons of backwards compatibility, it is a special case of subplot which
does not immediately create an axes, but instead sets up the figure so that the next graphics
command executes CLF RESET in the figure (deleting all children of the figure), and creates a
new axes in the default position. This syntax does not return a handle, so it is an error to
specify a return argument. The delayed CLF RESET is accomplished by setting the figure's
NextPlot to 'replace'.
XCORR Cross-correlation:
Function estimates.
C = XCORR (A,B), where A and B are length M vectors (M>1), returns the length 2*M-1
cross-correlation sequence C. If A and B are of different length, the shortest one is zero-padded.
C will be a row vector if A is a row vector and a column vector if A is a column vector.
XCORR produces an estimate of the correlation between two random (jointly stationary)
sequences:

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 6


DSP LAB MANUAL

C(m) = E[A(n+m)*conj(B(n))] = E[A(n)*conj(B(n-m))]


It is also the deterministic correlation between two deterministic signals. XCORR (A), when A
is a vector, is the auto-correlation sequence. XCORR (A), when A is an M-by-N matrix, is a
large matrix with 2*M-1 rows whose N^2 columns contain the cross-correlation sequences for
all combinations of the columns of A. The zeroth lag of the output correlation is in the middle of
the sequence, at element or row M.
XCORR (..., MAXLAG) computes the (auto/cross) correlation over the range of lags: -
MAXLAG to MAXLAG, i.e., 2*MAXLAG+1 lags. If missing, default is MAXLAG = M-1.

FILTIC:
Make initial conditions for 'filter' function.
Z = filtic( B, A, Y, X ) converts past input X and output Y into initial conditions for the state
variables Z needed in the TRANSPOSED DIRECT FORM II filter structure.
The vectors of past inputs & outputs are stored with more recent values first, i.e.
X = [ x[-1] x[-2] x[-3] ... x[-nb] ... ]
Y = [ y[-1] y[-2] y[-3] ... y[-na] ... ]
Where nb = length (B)-1 and na = length (A)-1. Short input vectors X and Y are zero padded
to length nb and na respectively. If X or Y are longer than nb or na, the values beyond those
lengths are irrelevant to the filter's initial conditions and are ignored.
Z = filtic (B, A, Y) assumes that X = 0 in the past.
INTERP:
Resample data at a higher rate using low pass interpolation.
Y = INTERP(X,R) resample’s the sequence in vector X at R times the original sample rate.
The resulting resampled vector Y is R times longer, LENGTH(Y) = R*LENGTH(X). A
symmetric filter, B, allows the original data to pass through unchanged and interpolates between
so that the mean square error between them and their ideal values is minimized.
Y = INTERP(X, R, L, CUTOFF) allows specification of arguments L and CUTOFF which
otherwise default to 4 and .5 respectively. 2*L is the number of original sample values used to
perform the interpolation. Ideally L should be less than or equal to 10. The length of B is
2*L*R+1. The signal is assumed to be band limited with cutoff frequency 0 < CUTOFF <=
1.0.
[Y, B] = INTERP(X, R, L, CUTOFF) returns the coefficients of the interpolation filter B.
BUTTORD:
Butterworth filter order selection.
[N, Wn] = BUTTORD (Wp, Ws, Rp, Rs) returns the order N of the lowest order digital
Butterworth filter that loses no more than Rp dB in the pass band and has at least Rs dB of
attenuation in the stop band. Wp and Ws are the pass band and stop band edge frequencies,
normalized from 0 to 1 (where 1 corresponds to pi radians/sample). For example,
Lowpass: Wp = .1, Ws = .2
Highpass: Wp = .2, Ws = .1
Band pass: Wp = [.2 .7], Ws = [.1 .8]
Bandstop: Wp = [.1 .8], Ws = [.2 .7]
BUTTORD also returns Wn, the Butterworth natural frequency (or, the "3 dB frequency") to
use with BUTTER to achieve the specifications.

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 7


DSP LAB MANUAL

[N, Wn] = BUTTORD (Wp, Ws, Rp, Rs,’s’) does the computation for an analog filter, in which
case Wp and Ws are in radians/second. When Rp is chosen as 3 dB, the Wn in BUTTER is equal
to Wp in BUTTORD.
CHEB1ORD Chebyshev Type I filter order selection:
[N, Wn] = CHEB1ORD (Wp, Ws, Rp, Rs) returns the order N of the lowest order digital
Chebyshev Type I filter that loses no more than Rp dB in the pass band and has at least Rs dB of
attenuation in the stop band. Wp and Ws are the pass band and stop band edge frequencies,
normalized from 0 to 1 (where 1 corresponds to pi radians/sample). For example,
Lowpass: Wp = .1, Ws = .2
Highpass: Wp = .2, Ws = .1
Band pass: Wp = [.2 .7], Ws = [.1 .8]
Bandstop: Wp = [.1 .8], Ws = [.2 .7]
CHEB1ORD also returns Wn, the Chebyshev natural frequency to use with CHEBY1 to
achieve the specifications.
[N, Wn] = CHEB1ORD (Wp, Ws, Rp, Rs,’s’) does the computation for an analog filter, in which
case Wp and Ws are in radians/second.
CHEBY1 Chebyshev:
Type I digital and analog filters design.
[B, A] = CHEBY1 (N, R, Wn) designs an Nth order low pass digital Chebyshev filter with R
decibels of peak-to-peak ripple in the pass band. CHEBY1 returns the filter coefficients in length
N+1 vectors B (numerator) and A (denominator). The cutoff frequency Wn must be 0.0 < Wn <
1.0, with 1.0 corresponding to half the sample rate. Use R=0.5 as a starting point, if you are
unsure about choosing R. If Wn is a two-element vector, Wn = [W1 W2], CHEBY1 returns an
order 2N band pass filter with pass band W1 < W < W2.
[B, A] = CHEBY1 (N, R, Wn,'high') designs a highpass filter.
[B, A] = CHEBY1 (N, R, Wn,'low') designs a low pass filter.
[B, A] = CHEBY1 (N,R,Wn,'stop') is a bandstop filter if Wn = [W1 W2].
When used with three left-hand arguments, as in [Z, P, K] = CHEBY1 (...), the zeros and
poles are returned in length N column vectors Z and P, and the gain in scalar K. When used with
four left-hand arguments, as in [A, B, C, D] = CHEBY1 (...), state-space matrices are returned.
CHEBY1(N,R,Wn,'s'), CHEBY1(N,R,Wn,'high','s') and CHEBY1(N,R,Wn,'stop','s') design
analog Chebyshev Type I filters. In this case, Wn is in [rad/s] and it can be greater than 1.0.
BILINEAR Bilinear transformation:
with optional frequency prewarping.
[Zd,Pd,Kd] = BILINEAR (Z,P,K,Fs) converts the s-domain transfer function specified by Z, P,
and K to a z-transform discrete equivalent obtained from the bilinear transformation:
H(z) = H(s) || s = 2*Fs*(z-1)/(z+1)
Where column vectors Z and P specify the zeros and poles, scalar K specifies the gain, and Fs
is the sample frequency in Hz.
[NUMd, DENd] = BILINEAR(NUM,DEN,Fs), where NUM and DEN are row vectors
containing numerator and denominator transfer function coefficients, NUM(s)/DEN(s), in
descending powers of s, transforms to z-transform coefficients NUMd(z)/DENd(z).
[Ad,Bd,Cd,Dd] = BILINEAR (A, B, C, D, Fs) is a state-space version. Each of the above three
forms of BILINEAR accepts an optional additional input argument that specifies prewarping.
For example, [Zd,Pd,Kd] = BILINEAR(Z,P,K,Fs,Fp) applies prewarping before the bilinear

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 8


DSP LAB MANUAL

transformation so that the frequency responses before and after mapping match exactly at
frequency point Fp (match point Fp is specified in Hz).
FILTER One-dimensional digital filter.
Y = FILTER(B,A,X) filters the data in vector X with the filter described by vectors A and B to
create the filtered data Y. The filter is a "Direct Form II Transposed" implementation of the
standard difference equation:
a(1)*y(n) = b(1)*x(n) + b(2)*x(n-1) + ... + b(nb+1)*x(n-nb) - a(2)*y(n-1) - ... - a(na+1)*y(n-
na)
If a(1) is not equal to 1, FILTER normalizes the filter coefficients by a(1). FILTER always
operates along the first non-singleton dimension, namely dimension 1 for column vectors and
non-trivial matrices, and dimension 2 for row vectors. [Y,Zf] = FILTER (B,A,X,Zi) gives
access to initial and final conditions, Zi and Zf, of the delays. Zi is a vector of length
MAX(LENGTH(A),LENGTH(B))-1, or an array with the leading dimension of size
MAX(LENGTH(A),LENGTH(B))-1 and with remaining dimensions matching those of X.
FILTER(B,A,X,[],DIM) or FILTER(B,A,X,Zi,DIM) operates along the dimension DIM.
STEM Discrete sequence or "stem" plot.
STEM(Y) plots the data sequence Y as stems from the x axis terminated with circles for the data
value. If Y is a matrix then each column is plotted as a separate series.
STEM(X,Y) plots the data sequence Y at the values specified in X.
STEM (...,'filled') produces a stem plot with filled markers.
STEM (...,'LINESPEC') uses the linetype specified for the stems and markers. See PLOT for
possibilities.
STEM (AX,...) plots into axes with handle AX. Use GCA to get the handle to the current axes or
to create one if none exist.
H = STEM (...) returns a vector of stemseries handles in H, one handle per column of data in
Y.
Backwards compatibility STEM ('v6',...) creates line objects instead of stemseries objects for
compatibility with MATLAB 6.5 and earlier.
IF Conditionally execute statements.
The general form of the IF statement is
IF expression
statements
ELSEIF expression
statements
ELSE
statements
END
The statements are executed if the real part of the expression has all non-zero elements. The
ELSE and ELSEIF parts are optional. Zero or more ELSEIF parts can be used as well as nested
IF's. The expression is usually of the form expr rop expr where rop is ==, <, >, <=, >=, or ~=.
Example
if I == J
A(I,J) = 2;
elseif abs(I-J) == 1
A(I,J) = -1;
else

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 9


DSP LAB MANUAL

A(I,J) = 0;
end
IF Conditionally execute statements.
The general form of the IF statement is
IF expression
statements
ELSEIF expression
statements
ELSE
statements
END
The statements are executed if the real part of the expression has all non-zero elements. The
ELSE and ELSEIF parts are optional. Zero or more ELSEIF parts can be used as well as nested
IF's. The expression is usually of the form expr rop expr where rop is ==, <, >, <=, >=, or ~=.
Example
if I == J
A(I,J) = 2;
elseif abs(I-J) == 1
A(I,J) = -1;
else
A(I,J) = 0;
End
ZEROS Zeros array.
ZEROS (N) is an N-by-N matrix of zeros.
ZEROS (M,N) or ZEROS([M,N]) is an M-by-N matrix of zeros.
ZEROS (M,N,P,...) or ZEROS([M N P ...]) is an M-by-N-by-P-by-... array of zeros.
ZEROS (SIZE(A)) is the same size as A and all zeros.
ZEROS with no arguments is the scalar 0.
ZEROS (M,N,...,CLASSNAME) or ZEROS([M,N,...],CLASSNAME) is an
M-by-N-by-... array of zeros of class CLASSNAME.
Example: x = zeros(2,3,'int8');

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 10


DSP LAB MANUAL

PART-A PROGRAMS
1) VERIFICATION OF SAMPLING THEOREM
clc;
clear all;
close all;
fm=input('Enter the maximum frequency component of the signal: ');
fs=input('Enter sampling frequency: ');
ts=1/fs;
t=0:0.001:0.2;
xt=cos(2*pi*fm*t);
subplot(2,2,1);
plot(t,xt);
xlabel('Time------->');
ylabel('Magnitude-------->');
title('Original Signal');
n=0:ts:0.2;
xn=cos(2*pi*fm*n);
subplot(2,2,2);
stem(n,xn,'g');
xlabel('Time------->');
ylabel('Magnitude-------->');
grid on;
title('Sampled version of original signal');
ni=0:ts:0.2;
xni=interp1(n,xn,ni);
subplot(2,2,3);
stem(n,xn,'r');
hold on;
grid on;
xlabel('Time------->');
ylabel('Magnitude-------->');
title('Sampled + recovered signal');
legend('sampled','recovered' );
plot(ni,xni);
subplot(2,2,4);
plot(t,xt,'b',ni,xni,'r');
grid on;
xlabel('Time------->');
ylabel('Magnitude-------->');
title('Original+Sampled signal');

Output:
Enter the maximum frequency component of the signal: 10
Enter sampling frequency: 10

Enter the maximum frequency component of the signal: 10


Enter sampling frequency: 20

Enter the maximum frequency component of the signal: 10


Enter sampling frequency: 500

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 11


DSP LAB MANUAL

Original Signal Sampled version of original signal


1 1
Magnitude-------->

Magnitude-------->
0.5

0 0.5

-0.5

-1 0
0 0.05 0.1 0.15 0.2 0 0.05 0.1 0.15 0.2
Time-------> Time------->
Sampled + recovered signal Original+Sampled signal
1 1
sampled
Magnitude-------->

Magnitude-------->
0.5

0.5 0

-0.5

0 -1
0 0.05 0.1 0.15 0.2 0 0.05 0.1 0.15 0.2
Time-------> Time------->

Original Signal Sampled version of original signal


1 1
Magnitude-------->

Magnitude-------->
0.5 0.5

0 0

-0.5 -0.5

-1 -1
0 0.05 0.1 0.15 0.2 0 0.05 0.1 0.15 0.2
Time-------> Time------->
Sampled + recovered signal Original+Sampled signal
1 1
sampled
Magnitude-------->

Magnitude-------->

0.5 0.5

0 0

-0.5 -0.5

-1 -1
0 0.05 0.1 0.15 0.2 0 0.05 0.1 0.15 0.2
Time-------> Time------->

Original Signal Sampled version of original signal


1 1
Magnitude-------->

Magnitude-------->

0.5 0.5

0 0

-0.5 -0.5

-1 -1
0 0.05 0.1 0.15 0.2 0 0.05 0.1 0.15 0.2
Time-------> Time------->
Sampled + recovered signal Original+Sampled signal
1 1
sampled
Magnitude-------->

Magnitude-------->

0.5 0.5

0 0

-0.5 -0.5

-1 -1
0 0.05 0.1 0.15 0.2 0 0.05 0.1 0.15 0.2
Time-------> Time------->

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 12


DSP LAB MANUAL

2. LINEAR AND CIRCULAR CONVOLUTION OF TWO GIVEN


SEQUENCES, COMMUTATIVE, DISTRIBUTIVE AND ASSOCIATIVE
PROPERTY OF CONVOLUTION.
A. MATLAB CODE TO COMPUTE LINEAR CONVOLUTION OF TWO
GIVEN
SEQUENCES.
clc;
clear all;
close all;
xn=input('Enter the samples of x[n]: ');
hn=input('Enter the samples of h[n]: ');
yn=conv(xn,hn);
disp('The convolution of x[n] and h[n] is:');
disp(yn);
L=length(xn);
M=length(hn);
N=L+M-1;
subplot(3,1,1);
n=0:1:L-1;
stem(n,xn);
grid on;
xlabel('Time------->');
ylabel('Magnitude-------->');
title('Input Sequence')
subplot(3,1,2);
n=0:1:M-1;
stem(n,hn);
grid on;
xlabel('Time------->');
ylabel('Magnitude-------->');
title('Impulse Response')
subplot(3,1,3);
n=0:1:N-1;
stem(n,yn);
grid on;
xlabel('Time------->');
ylabel('Magnitude-------->');
title('The convolution of x[n] and h[n]')

Output:
Enter the samples of x[n]: [1 2 5 9]
Enter the samples of h[n]: [7 5 3]
The convolution of x[n] and h[n] is:
7 19 48 94 60 27

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 13


DSP LAB MANUAL

Input Sequence
10
Magnitude-------->

0
0 0.5 1 1.5 2 2.5 3
Time------->
Impulse Response
10
Magnitude-------->

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time------->
The convolution of x[n] and h[n]
100
Magnitude-------->

50

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Time------->

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 14


DSP LAB MANUAL
B. MATLAB CODE TO COMPUTE CIRCULAR CONVOLUTION OF TWO GIVEN SEQUENCES.

clc;
clear all;
close all;
xn=input('Enter the samples of x[n]: ');
hn=input('Enter the samples of h[n]: ');
L=length(xn);
M=length(hn);
N=max(L,M);
yn=cconv(xn,hn,N);
disp('The convolution of x[n] and h[n] is:');
disp(yn);

subplot(3,1,1);
n=0:1:L-1;
stem(n,xn);
grid on;
xlabel('Time------->');
ylabel('Magnitude-------->');
title('Input Sequence')
subplot(3,1,2);
n=0:1:M-1;
stem(n,hn);
grid on;
xlabel('Time------->');
ylabel('Magnitude-------->');
title('Impulse Response')
subplot(3,1,3);
n=0:1:N-1;
stem(n,yn);
grid on;
xlabel('Time------->');
ylabel('Magnitude-------->');
title('The convolution of x[n] and h[n]');

Output:

Enter the samples of x[n]: [1 5 9 3]


Enter the samples of h[n]: [6 5 4]
The convolution of x[n] and h[n] is:
57 47 83 83

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 15


DSP LAB MANUAL

Input Sequence
10
Magnitude-------->

0
0 0.5 1 1.5 2 2.5 3
Time------->
Impulse Response
6
Magnitude-------->

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time------->
The convolution of x[n] and h[n]
100
Magnitude-------->

50

0
0 0.5 1 1.5 2 2.5 3
Time------->

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 16


DSP LAB MANUAL
C. MATLAB CODE TO COMPUTE CIRCULAR CONVOLUTION PROPERTY
clc;
clear all;
close all;
x1=input('Enter the samples of x1=');
x2=input('Enter the samples of x2=');
x3=input('Enter the samples of x3=');
N=input('Enter the value of N:');
y1=cconv(x1,x2,N);
y2=cconv(x2,x1,N);
if(y1==y2)
disp('circular convolution is commutative ');
else
disp('circular convolution is not commutative');
end
x4=x2+x3;
y3=cconv(x1,x4,N);
y4=cconv(x1,x3,N);
y5=y1+y4;
if(y3==y5)
disp('circular convolution is distributive');
else
disp('circular convolution is not distributive');
end
y6=cconv(y1,x3,N);
y7=cconv(x2,x3,N);
y8=cconv(x1,y7,N);
if(y6==y8)
disp('circular convolution is associative');
else
disp('circular convolution is not associative');
end

Output:

Enter the samples of x1=[1 2 3 4]


Enter the samples of x2=[1 4 5 6]
Enter the samples of x3=[1 2 5 8]
Enter the value of N:4
circular convolution is commutative
circular convolution is distributive
circular convolution is associative

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 17


DSP LAB MANUAL
D. MATLAB CODE TO COMPUTE LINEAR CONVOLUTION PROPERTY

clc;
clear all;
close all;
xn=input('Enter the samples of x(n):');
h1=input('Enter the samples of h1(n):');
h2=input('Enter the samples of h2(n):');
y1=conv(xn,h1);
y2=conv(h1,xn);
if(y1==y2)
disp('The linear convolution is commutative');
else
disp('The linear convolution is not commutative');
end
y3=h1+h2;
y4=conv(xn,y3);
y5=conv(xn,h2);
y6=y1+y5;
if(y4==y6)
disp('The linear convolution is distributive');
else
disp('The linear convolution is not distributive');
end
y7=conv(h1,h2);
y8=conv(xn,y7);
y9=conv(xn,h1);
y10=conv(y9,h2);
if(y8==y10)
disp('The linear convolution is Associative');
else
disp('The linear convolution is not Associative');
end

Output:

Enter the samples of x(n):[1 2 3 4]


Enter the samples of h1(n):[1 5 9 6]
Enter the samples of h2(n):[1 2 3 5]
The linear convolution is commutative
The linear convolution is distributive
The linear convolution is Associative

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 18


DSP LAB MANUAL

3. AUTO & CROSS CORRELATION OF GIVEN SEQUENCE AND


VERIFICATION OF ITS PROPERTIES
A.MATLAB CODE TO COMPUTE AUTO CORRELATION OF GIVEN SEQUENCE
clc;
clear all;
close all;
xn=input('Enter the samples of x[n]: ');
L=length(xn);
rxx=xcorr(xn,xn);
disp('The correlation of x[n] with x[n] is:');
disp(rxx);
subplot(2,1,1);
n=0:1:L-1;
stem(n,xn);
grid on;
xlabel('Time------->');
ylabel('Magnitude-------->');
title('Input Sequence')
subplot(2,1,2);
n=-(L-1):1:(L-1);
stem(n,rxx);
grid on;
xlabel('Time------->');
ylabel('Magnitude-------->');
title('The auto correlation of x[n]');

Output:
Enter the samples of x[n]: [4 8 6 2]
The correlation of x[n] with x[n] is:
8 40 92 120 92 40 8

PROPERTIES:
1) Periodicity: Rxx(k0) = Rxx(0) then Rxx(k) is periodic with period k0
2) Symmetric: Autocorrelation function is symmetric. i.e. Rxx(m) = Rxx(-m)
3) Mean square value: autocorrelation function at k=0, is equal to mean square
value of the process. Rxx(0) = E{|x(n)|2}≥0

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 19


DSP LAB MANUAL

Input Sequence
8

6
Magnitude-------->

0
0 0.5 1 1.5 2 2.5 3
Time------->

The auto correlation of x[n]


120

100
Magnitude-------->

80

60

40

20

0
-3 -2 -1 0 1 2 3
Time------->

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 20


DSP LAB MANUAL
B.MATLAB CODE TO COMPUTE CROSS CORRELATION OF GIVEN SEQUENCE
clc;
clear all;
close all;
xn=input('Enter the samples of x[n]: ');
L=length(xn);
yn=input('Enter the samples of y[n]: ');
M=length(yn);
rxy=xcorr(xn,yn);
N=length(rxy);
disp('The correlation of x[n] with x[n] is:');
disp(rxy);
subplot(3,1,1);
n=0:1:L-1;
stem(n,xn);
grid on;
xlabel('Time------->');
ylabel('Magnitude-------->');
title('Input Sequence');
subplot(3,1,2);
n=0:1:M-1;
stem(n,xn);
grid on;
xlabel('Time------->');
ylabel('Magnitude-------->');
title('Input Sequence');
subplot(3,1,3);
n=-(M-1):1:(L-1);
stem(n,rxy);
grid on;
xlabel('Time------->');
ylabel('Magnitude-------->');
title('The cross correlation of x[n]and y[n]');
Output:
Enter the samples of x[n]: [8 4 2 6]
Enter the samples of y[n]: [7 9 3 1]
The correlation of x[n] with x[n] is:
8.0000 28.0000 86.0000 104.0000 64.0000 68.0000 42.0000
PROPERTIES:
1) Rxy(k) is always a real valued function which may be a positive or negative.
2) Rxy(-k) = Ryx(k)
3) |Rxy(k)|2 ≤ Rxx(0) Ryy(0)
4) |Rxy(-k)| ≤ [1/2] [Rxy(-k) + Rxy(-k)]
5) When Rxy(k) = 0, x(n) and y(n) are said to be uncorrelated or they said to be
statistically independent.
6) Rxy(k) may not be necessarily have a maximum at k=0 nor Rxy(k) an even function

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 21


DSP LAB MANUAL

Input Sequence
Magnitude--------> 10

0
0 0.5 1 1.5 2 2.5 3
Time------->
Input Sequence
10
Magnitude-------->

0
0 0.5 1 1.5 2 2.5 3
Time------->
The cross correlation of x[n]and y[n]
150
Magnitude-------->

100

50

0
-3 -2 -1 0 1 2 3
Time------->

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 22


DSP LAB MANUAL
4. SOLVING A GIVEN DIFFERENCE EQUATION.
clc;
clear all;
close all;
b=input('Enter numerator coefficients: ');
a=input('Enter denominator coefficients: ');
N=input('Enter the length of response: ');
x=[1,zeros(1,N)];
yn=filter(b,a,x);
disp('The response of system is:');
disp(yn);
L=length(yn);
n=0:1:L-1;
stem(n,yn);
grid on;
xlabel('Time------->');
ylabel('Magnitude-------->');
title('The response of the system');

Output:

Enter numerator coefficients: [0.58 0.88 1]


Enter denominator coefficients: [1 -0.7 0.12]
Enter the length of response: [2]
The response of system is:
0.5800 1.2860 1.8306

the response of system


2

1.8

1.6

1.4

1.2
magnitude axis--->

0.8

0.6

0.4

0.2

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
time axis-->

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 23


DSP LAB MANUAL

5. Computation of N point DFT of a given sequence and to plot magnitude and


Phase spectrum (using DFT equation and verify it by built-in routine).
clc;
clear all;
close all;
xn=input('Enter the samples of x[n]: ');
N=input('The number of samples in DFT:');
xk=fft(xn,N);
mag_xk=abs(xk);
pha_xk=angle(xk);
disp('The N-point DFT of x[n] is:');
disp(xk);
L=length(xn);
subplot(3,1,1);
n=0:1:L-1;
stem(n,xn);
grid on;
xlabel('Time------->');
ylabel('Magnitude-------->');
title('Input Sequence')
subplot(3,1,2);
n=0:1:N-1;
stem(n,mag_xk);
grid on;
xlabel('Time------->');
ylabel('Magnitude-------->');
title('Magnitude Response of DFT')
subplot(3,1,3);
n=0:1:N-1;
stem(n,pha_xk);
grid on;
xlabel('Time------->');
ylabel('Angle-------->');
title('The phase of DFT');

Output:

Enter the samples of x[n]: [4 8 6 2 3]


The number of samples in DFT:8
The N-point DFT of x[n] is:
Columns 1 through 4

23.0000 5.2426 -13.0711i 1.0000 - 6.0000i -3.2426 - 1.0711i


Columns 5 through 8

3.0000 -3.2426 + 1.0711i 1.0000 + 6.0000i 5.2426 +13.0711i

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 24


DSP LAB MANUAL

Input Sequence
10
Magnitude-------->

0
0 0.5 1 1.5 2 2.5 3 3.5 4
Time------->
Magnitude Response of DFT
30
Magnitude-------->

20

10

0
0 1 2 3 4 5 6 7
Time------->
The phase of DFT
5
Angle-------->

-5
0 1 2 3 4 5 6 7
Time------->

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 25


DSP LAB MANUAL

6. (i) Verification of DFT properties (like Linearity and Parseval’s theorem, etc.)
(ii) DFT computation of square pulse and Sinc function etc.

i. Matlab code to verify the DFT property.


clc;
clear all;
close all;
x1=input('Enter the samples of x1:');
x2=input('Enter the samples of x2:');
N=input('Enter the samples of N:');
X1=fft(x1,N);
X2=fft(x2,N);
x=5*x1+3*x2;
x=fft(x,N);
Y=5*X1+3*X2;
if(x==Y)
disp('The DFT is linear');
else
disp('The DFT is not linear');
end

output:

Enter the samples of x1:[1 2 3 4]


Enter the samples of x2:[1 4 7 8]
Enter the samples of N:4
The DFT is linear

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 26


DSP LAB MANUAL

ii. DFT computation of square pulse and Sinc function etc.

Matlab code to compute DFT of square function

clc;
clear all;
close all;
x1=[zeros(1,32),ones(1,64),zeros(1,32)];
X1=fft(x1);
X2=fftshift(X1);
subplot(3,1,1);
n=0:1:128;
stem(x1);
xlabel('Time----->');
ylabel('Amplitude------>');
title('squre function');
subplot(3,1,2);
k=0:1:128;
plot(abs(X1));
xlabel('Time----->');
ylabel('Amplitude------>');
title('DFT of squre function');
subplot(3,1,3);
k=0:1:128;
plot(abs(X2));
xlabel('Amplitude------>');
ylabel('Amplitude------>');
title('DFT of squre function of X2');

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 27


DSP LAB MANUAL

squre function
1
Amplitude------>

0.5

0
0 20 40 60 80 100 120 140
Time----->
DFT of squre function
100
Amplitude------>

50

0
0 20 40 60 80 100 120 140
Time----->
DFT of squre function of X2
100
Amplitude------>

50

0
0 20 40 60 80 100 120 140
Amplitude------>

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 28


DSP LAB MANUAL
7. Design and implementation of FIR filter to meet given specifications
(using different window techniques).

clc;
clear all;
close all
wpa=input('enter the pass-band edge freq:');
wsa=input('enter the stop-band edge freq:');
fs=input('enter the sampling freq:');
wpd=2*pi*wpa/fs;
wsd=2*pi*wsa/fs;
tb=wsd-wpd;
N=ceil(6.6*pi/tb);
wc=(wsd+wpd)/(2*pi);
hw=hamming(N+1);
stem(hw);
title('hamming window');
grid on;
h=fir1(N,wc,hamming(N+1));
figure(2);
[m,w]=freqz(h,1,128);
mag=20*log10(abs(m));
plot(fs*w/(2*pi),mag);
title('freq responce of FIR filter');
grid on;

enter the pass-band edge freq:100


enter the stop-band edge freq:200
enter the sampling freq:1000

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 29


DSP LAB MANUAL

hamming window
1

0.9

0.8

0.7

0.6

0.5

0.4

0.3

0.2

0.1

0
0 5 10 15 20 25 30 35

freq responce of FIR filter


0

-10

-20

-30

-40

-50

-60

-70

-80

-90

-100
0 50 100 150 200 250 300 350 400 450 500

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 30


DSP LAB MANUAL

8. Design and implementation of IIR filter to meet given specifications.

Chebyshev Filter
clc;
clear all;
close all;
ap=input('enter passband attenuation in dB:');
as=input('enter stopband attenuation in dB:');
wp=input('enter passband edge freq in dB:');
ws=input('enter stopband edge freq in dB:');
wsp=input('enter sampling freq in dB:');
op=2*pi*wp/wsp;
os=2*pi*ws/wsp;
pop=2*tan(op/2);
pos=2*tan(os/2);
[N,wc]=cheb1ord(pop,pos, ap,as,'s');
[b,a]=cheby1(N,ap,wc,'s');
fs=1
[num,den]=bilinear(b,a,fs);
[msg,freq1]=freqz(num,den,128);
freq=freq1*wsp/(2*pi);
m=20*log10(abs(msg));
plot(freq,m);
title('freq resp of IIR filter');
grid on;

enter passband attenuation in dB:1


enter stopband attenuation in dB:30
enter passband edge freq in dB:1000
enter stopband edge freq in dB:1500
enter sampling freq in dB:3600

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 31


DSP LAB MANUAL

freq resp of IIR filter


20

-20

-40

-60

-80

-100

-120
0 200 400 600 800 1000 1200 1400 1600 1800

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 32


DSP LAB MANUAL

Butterworth Filter
clc;
clear all;
close all;
ap=input('enter the passband attenuation in DB:');
as=input('enter the stopband attenuation in DB:');
wp=input('enter the passband edge frequency in Hz:');
ws=input('enter the stopband edge frequency in Hz:');
wsp=input('enter the sampling frequency :');
op=2*pi*wp/wsp;
os=2*pi*ws/wsp;
pop=2*tan(op/2);
pos=2*tan(os/2);
[N,wc]=buttord(pop,pos,ap,as,'s');
[b,a]=butter(N,wc,'s');
fs=1;
[num,den]=bilinear(b,a,fs);
[mag,freq1]=freqz(num,den,128);
freq=freq1*wsp/(2*pi);
m=20*log10(abs(mag));
plot(freq,m);
title('frequency responce of IIR filter');
grid on;
enter the passband attenuation in DB:1
enter the stopband attenuation in DB:40
enter the passband edge frequency in Hz:800
enter the stopband edge frequency in Hz:1200
enter the sampling frequency :3600

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 33


DSP LAB MANUAL

frequency responce of IIR filter


50

-50

-100

-150

-200

-250

-300
0 200 400 600 800 1000 1200 1400 1600 1800

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 34


DSP LAB MANUAL

INTRODUCTION TO CODE COMPOSER STUDIO


Code Composer is the DSP industry's first fully integrated development environment (IDE) with
DSP-specific functionality. With a familiar environment liked MS-based C++TM, Code
Composer lets you edit, build, debug, profile and manage projects from a single unified
environment. Other unique features include graphical signal analysis, injection/extraction of data
signals via file I/O, multi-processor debugging, automated testing and customization via a C-
interpretive scripting language and much more.

CODE COMPOSER FEATURES INCLUDE:

 IDE
 Debug IDE
 Advanced watch windows
 Integrated editor
 File I/O, Probe Points, and graphical algorithm scope probes
 Advanced graphical signal analysis
 Interactive profiling
 Automated testing and customization via scripting
 Visual project management system
 Compile in the background while editing and debugging
 Multi-processor debugging
 Help on the target DSP

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 35


DSP LAB MANUAL

The TMS320C6713 DSP Starter Kit (DSK) developed jointly with Spectrum Digital is a low-
cost development platform designed to speed the development of high precision applications
based on TI´s TMS320C6000 floating point DSP generation. The kit uses USB communications
for true plug-and-play functionality. Both experienced and novice designers can get started
immediately with innovative product designs with the DSK´s full featured Code Composer
Studio™ IDE and eXpressDSP™ Software which includes DSP/BIOS and Reference
Frameworks.

The C6713 DSK tools includes the latest fast simulators from TI and access to the Analysis
Toolkit via Update Advisor which features the Cache Analysis tool and Multi-Event Profiler.
Using Cache Analysis developers improve the performance of their application by optimizing
cache usage. By providing a graphical view of the on-chip cache activity over time the user can
quickly determine if their code is using the on-chip cache to get peak performance.

The C6713 DSK allows you to download and step through code quickly and uses Real Time
Data Exchange (RTDX™) for improved Host and Target communications. The DSK includes
the Fast Run Time Support libraries and utilities such as Flashburn to program flash, Update
Advisor to download tools, utilities and software and a power on self test and diagnostic utility to
ensure the DSK is operating correctly.

The full contents of the kit include:

 C6713 DSP Development Board with 512K Flash and 16MB SDRAM
 C6713 DSK Code Composer Studio™ IDE including the Fast Simulators and access to
Analysis Toolkit on Update Advisor
 Quick Start Guide
 Technical Reference
 Customer Support Guide
 USB Cable
 Universal Power Supply
 AC Power Cord(s)
 MATLAB from The Mathworks 30 day free evaluation

Ordering Information: TMDSDSK6713 includes a standard US power cord, TMDSDSK6713-0E


version includes both UK & European power cords

Features

The DSK features the TMS320C6713 DSP, a 225 MHz device delivering up to 1800 million
instructions per second (MIPs) and 1350 MFLOPS. This DSP generation is designed
for applications that require high precision accuracy. The C6713 is based on the TMS320C6000
DSP platform designed to needs of high-performing high-precision applications such as pro-

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 36


DSP LAB MANUAL

audio, medical and diagnostic. Other hardware features of the TMS320C6713 DSK board
include:

 Embedded JTAG support via USB


 High-quality 24-bit stereo codec
 Four 3.5mm audio jacks for microphone, line in, speaker and line out
 512K words of Flash and 16 MB SDRAM
 Expansion port connector for plug-in modules
 On-board standard IEEE JTAG interface
 +5V universal power supply

Software - Designers can readily target the TMS32C6713 DSP through TI´s robust and
comprehensive Code Composer Studio™ DSK development platform. The tools, which run on
Windows© 98, Windows 2000 and Windows XP, allow developers to seamlessly manage
projects of any complexity. Code Composer Studio features for the TMS320C6713 DSK
include:

 A complete Integrated Development Environment (IDE), an efficient optimizing C/C++


compiler assembler, linker, debugger, an a advanced editor with Code Maestro™
technology for faster code creation, data visualization, a profiler and a flexible project
manager
 DSP/BIOS™ real-time kernel
 Target error recovery software
 DSK diagnostic tool
 "Plug-in" ability for third-party software for additional functionality

Troubleshooting DSK Connectivity

If Code Composer Studio IDE fails to configure your port correctly, perform the following steps:

 Test the USB port by running DSK Port test from the start menu
Use StartProgramsTexas InstrumentsCode Composer StudioCode Composer Studio
C5416 DSK ToolsC5416 DSK Diagnostic Utilities
 The below Screen will appear
 Select StartSelect 6713 DSK Diagnostic Utility Icon from Desktop
 The Screen Look like as below
 Select Start Option
 Utility Program will test the board
 After testing Diagnostic Status you will get PASS

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 37


DSP LAB MANUAL

If the board still fails to detect

Go to CMOS setup Enable the USB Port Option


(The required Device drivers will load along with CCS Installation)

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 38


DSP LAB MANUAL

Procedure to work on Code Composer Studio

To create the New Project

Project  New (File Name. pjt , Eg: Vectors.pjt)

To Create a Source file

File  New  Type the code (Save & give file name, Eg: sum.c).

To Add Source files to Project

Project  Add files to Project  sum.c

To Add rts.lib file & Hello.cmd:

Project  Add files to Project rts6700.lib

Library files: rts6700.lib(Path: c:\ti\c6000\cgtools\lib\rts6700.lib)

Note: Select Object & Library in(*.o,*.l) in Type of files

Project  Add files to Project hello.cmd

CMD file – Which is common for all non real time programs.

(Path: c:\ti\tutorial\dsk6713\hello1\hello.cmd)

Note: Select Linker Command file (*.cmd) in Type of files

Compile:

To Compile: Project  Compile

To Rebuild: Project  rebuild,

Which will create the final .out executable file. (Eg. Vectors.out).

Procedure to Load and Run program:

Load the program to DSK: File  Load program  Vectors. out

To Execute project: Debug  Run.

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 39


DSP LAB MANUAL

PART-B PROGRAMS
9. Linear convolution of two sequences

#include<stdio.h>
main()
{
int m=4;
int n=4;
int i=0,j;
int x[10]={1,2,3,1,0,0,0,0};
int h[10]={1,1,2,2,0,0,0,0};
int *y;
y=(int*)0x0000100;
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 Linear Convolution is\n");

for(i=0;i<m+n-1;i++)
printf("y[%d]=%d\n",i,y[i]);
}

output:

The Linear Convolution is


y[0]=1
y[1]=3
y[2]=7
y[3]=10
y[4]=11
y[5]=8
y[6]=2

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 40


DSP LAB MANUAL

10. Circular convolution of two sequences

#include<stdio.h>
int m,i,j,n,k,l;
int x[30]={1,2,3,4,5};
int h[30]={1,5,3};
int y[30]={0};
int temp[30],x2[30],a[30];
void main()
{
int *y;
y=(int*)0x0000100;
printf("enter the length of x(n):\n");
scanf("%d",&l);
printf("enter the length of h(n):\n");
scanf("%d",&m);
{
if(m>1)
{
for (i=l;i<m;i++)
x[i]=0;
n=m;
}
if(l>m)
{
for(i=m;i<l;i++)
{
h[i]=0;
n=l;
}
}
}
y[0]=0;
a[0]=h[0];
for(j=1;j<n;j++)
a[j]=h[n-j];
for(i=0;i<n;i++)
y[0]=y[0]+x[i]*a[i];
for(k=1;k<n;k++)
{
y[k]=0;
for(j=1;j<n;j++)
x2[j]=a[j-1];

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 41


DSP LAB MANUAL

x2[0]=a[n-1];
for(i=0;i<n;i++)
{
a[i]=x2[i];
y[k]=y[k]+x[i]*x2[i];
}
}
printf("the circular convolution is\n");
for(i=0;i<n;i++)
{
printf("y[%d]=%d\n",i,y[i]);
}
}
Output :
Enter the length of x(n):
5
Enter the length of h(n):
3
The circular convolution
y[0]=38
y[1]=22
y[2]=16
y[3]=25
y[4]=34

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 42


DSP LAB MANUAL

11. N-point DFT of a given sequence

#include<stdio.h>
#include<math.h>
void main(void)
{
float y[16];
float x[4]={1,2,1,0};
float w;
int n,k,k1,N=4,xlen=4;
printf("The N Point DFT is\n");
for (k=0;k<2*N;k=k+2)
{
y[k]=0;
y[k+1]=0;
k1=k/2;
for(n=0;n<xlen;n++)
{
w=-2*3.14*k1*n/N;
y[k]=y[k]+x[n]*cos(w);
y[k+1]=y[k+1]+x[n]*sin(w);
}
printf("%f+j%f\n",y[k],y[k+1]);
}
}

Output:

The N Point DFT is


4.000000+j0.000000
0.001594+j-2.001592
-0.000003+j-0.000000
-0.004766+j1.995216

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 43


DSP LAB MANUAL

12. Impulse response of first order and second order system

#include<stdio.h>
float x[60],y[60];
void main()
{
float a1,a2,b0,b1,b2;
int i,j,N=20;
a1=-1.1430;
a2=0.4128;
b0=0.0675;
b1=0.7349;
b2=0.0675;
x[0]=1;
for(i=1;i<N;i++)
x[i]=0;
for(j=1;j<N;j++)
{
y[j]=b0*x[j];
if(j>0)
y[j]=y[j]+b1*x[j-1]-a1*y[j-1];
if(j-1>0)
y[i]=y[j]+b2*x[j-2]-a2*y[j-2];
printf("%f\t",y[j]);
}
}

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 44


DSP LAB MANUAL

13. Implementation of FIR Filter

ECE DEPT., KLE COLLEGE OF ENGG. & TECH., CHIKODI Page 45

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy