DSP Lab Manual New 2018-19
DSP Lab Manual New 2018-19
DSP Lab Manual New 2018-19
INDEX
Sl.No. Experiment Name Page No.
Following Experiments to be done using MATLAB / SCILAB / OCTAVE or equivalent:
PART-B PROGRAMS
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.
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.
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 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.
[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
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.
[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
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
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');
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
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------->
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------->
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------->
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
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------->
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:
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------->
Output:
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:
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
Input Sequence
8
6
Magnitude-------->
0
0 0.5 1 1.5 2 2.5 3
Time------->
100
Magnitude-------->
80
60
40
20
0
-3 -2 -1 0 1 2 3
Time------->
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------->
Output:
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-->
Output:
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------->
6. (i) Verification of DFT properties (like Linearity and Parseval’s theorem, etc.)
(ii) DFT computation of square pulse and Sinc function etc.
output:
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');
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------>
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;
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
-10
-20
-30
-40
-50
-60
-70
-80
-90
-100
0 50 100 150 200 250 300 350 400 450 500
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;
-20
-40
-60
-80
-100
-120
0 200 400 600 800 1000 1200 1400 1600 1800
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
-50
-100
-150
-200
-250
-300
0 200 400 600 800 1000 1200 1400 1600 1800
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
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.
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
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-
audio, medical and diagnostic. Other hardware features of the TMS320C6713 DSK board
include:
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:
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 StartProgramsTexas InstrumentsCode Composer StudioCode Composer Studio
C5416 DSK ToolsC5416 DSK Diagnostic Utilities
The below Screen will appear
Select StartSelect 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
File New Type the code (Save & give file name, Eg: sum.c).
CMD file – Which is common for all non real time programs.
(Path: c:\ti\tutorial\dsk6713\hello1\hello.cmd)
Compile:
Which will create the final .out executable file. (Eg. Vectors.out).
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:
#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];
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
#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:
#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]);
}
}