Sie sind auf Seite 1von 105

2.

Objective, Relevance and Outcome


This lab introduces students to DSP design and analysis techniques that are
core knowledge for DSP engineers, and which serve as solid grounding for advanced
level work in DSP. This lab aims at supporting the teaching and research activities in
the area of DSP, which are either currently being.
As such, the lab aims at achieving the following objectives:
1. To emphasize the teaching of key DSP concepts, such as overview of discrete time
signal and systems in time domain, and frequency domain, sampling and
reconstruction of analog signals, signal and systems representation in complex
frequency domain, solution of differential equations using z transform, computation of
Fourier transform and its efficient implementation, Discrete Fourier transform and
Fast Fourier transform, Structure for the implementation of digital filters, FIR Filter
design and IIR Filter Design.
2. 2. To provide an understanding of how to design signal processing systems and
process data in a software simulation like using MATLAB , including how to :Create
and analyze signals Create and analyze filters Apply signal and filter specifications to
real-world designs and to implement the DSP algorithms in software and to familiarize
key DSP Concepts in a practical way with matlab examples and computer
demonstrations and MATLAB ,techniques to analyze z and inverse z transforms,
3.

To give students an introduction to real-time DSP requirements by exposing them to


the use of some educational DSP kits with real time capability, which will help them
get acquainted with the programming of these devices and some typical hardware
and functions found in practical applications such as I/O interface cards (A/D, D/A, I/O
filters), types of DSP processors and their different characteristics, interrupts, etc.

4.

To heighten students' awareness of the vast array of diverse practical DSP


applications by exposing them to some practical DSP demos, hardware and
operations involved in this area and also to provide students with a learning platform
on which to further experiment with DSP through course work, design projects,
theses, etc. and appreciate the inter-disciplinary nature of the field, its vast array of
industrial applications and its growing importance in today's world.

3.Code of conduct

All students must observe the Dress Code while in the laboratory.

Foods, drinks and smoking are NOT allowed.

All bags must be kept at the indicated place.

The lab timetable must be strictly followed.

Be PUNCTUAL for your laboratory session.

Experiment/Program must be completed within the specified time.

Students who turn up late to the labs will in no case be permitted to perform the
experiment scheduled for the day.

After completion of the experiment, certification of the staff in-charge concerned in the
observation book is necessary.

Noise must be kept to a minimum.

Workspace must be kept clean and tidy at all time.

All students are responsible for the damage (caused if any) of equipment/work
benches/computing system.

Students are strictly PROHIBITED from taking out any items from the laboratory.

Students are NOT allowed to work alone in the laboratory without the Lab Supervisor.

Report immediately to the Lab Supervisor if any injury occurred.

Students should be present in the labs for the total scheduled duration.

Students are expected to prepare thoroughly to perform the experiment before coming to
Laboratory.

Before leaving the lab Place the stools/chairs properly.

Turn off the power supply of the work bench or shut down the computing system.

Please check the laboratory notice board regularly for updates regarding lab sessions.

4.Precautions
1.
Select your HDL File before you simulate and synthesize Using Xilinx /any
equivalent tool.
2.
Check JTAG cable connections to down load design to the Target device on
FPGA/CPLD demo board.
3.

Check Your Target Device details to synthesize design.

4.

Check Your Target Device details to write UCF file.

5.

Handle FPGA/CPLD Board carefully.

5.List of Experiments
The programs shall be implemented in software (Using MATLAB / Lab view / C programming/ OCTAVE
Equivalent) and hardware (Using TI / Analog devices / Motorola / Equivalent DSP processors).
1. Generation of Sinusoidal waveform / signal based on recursive difference equations
2. To find DFT / IDFT of given DT signal
3. To find frequency response of a given system given in (Transfer Function/ D.E form).
4. Implementation of FFT of given sequence
5. Determination of Power Spectrum of a given signal(s).
6. Implementation of LP FIR filter for a given sequence
7. Implementation of HP FIR filter for a given sequence
8. Implementation of LP IIR filter for a given sequence
9. Implementation of HP IIR filter for a given sequence
10. Generation of Sinusoidal signal through filtering
11. Generation of DTMF signals
12. Implementation of Decimation Process
13. Implementation of Interpolation Process
14. Implementation of I/D sampling rate converters
15. Audio application such as to plot a time and frequency display of microphone plus a cosine using DSP.
Read a .wav file and match with their respective spectrograms.
16. Noise removal: Add noise above 3 KHz and then remove, interference suppression using 400 Hz tone.
17. Impulse response of first order and second order systems.
Note: Any 12of the above experiments from each part are to be conducted

6.Text books as per theory


Text Books
1. Digital Signal Processing, Principles, Algorithms and Applications by John G.
Proakis, Dimitris G.
Manolakis, Pearson Education/ PHI, 2007.
2.Discrete Time Signal Processing, A.V. Oppenhem and R.W. Schaffer, PHI, 2009.
3. Fundamentals of digital signal processing Loney ludeman, John Wiley, 2009.
Reference Books
1. Digital signal processing Fundamentals and applications Li Tan, Elsevier, 2008.
2. Fundamentals of Digital Signal Processing using Matlab Robert J. Schiling, Sandra
L. Harris, Thomson, 2007.
3. Digital Signal processing S. Salivahanan, A. Vallavaraj and C. Gnanapriya, TMH,
2009.
4. Discrete systems and digital signal processing with MATLAB, Taan S. ElAli, CRC
press, 2009.
5. Digital signal processing A Practical approach, Emmanuel c. Ifeachor and Barrie
W. Jervis, 2nd Edition, Pearson Education, 2009.

7.Session Plan
S. No
1

Week
No.
1

Activity
Generation of Sinusoidal

Remarks
Prerequisite

waveform / signal based on


recursive difference equations

To find DFT / IDFT of given

As per JNTU Syllabus

DT signal

To find frequency response of


a given system given in

As per JNTU
Syllabus(ICA
Subject,Unit 7)

(Transfer Function/ D.E form).

Implementation of FFT of
given sequence .

Determination of Power

As per JNTU
Syllabus(ICA
Subject,Unit 7)
As per JNTU Syllabus

Spectrum of a given signal(s).

Implementation of LP FIR
filter for a given sequence

.
7. Implementation of HP FIR

As per JNTU
Syllabus(STLD
Subject Unit-2)
As per JNTU Syllabus

filter for a given sequence

8. Implementation of LP IIR

As per JNTU Syllabus

filter for a given sequence

9. Implementation of HP IIR

As per JNTU Syllabus

filter for a given sequence

10

10. Generation of Sinusoidal

As per JNTU Syllabus

signal through filtering


11

11. Generation of DTMF


signals

12

12. Implementation of

As per JNTU Syllabus


(STLD Subject Unit5)

As per JNTU Syllabus

Decimation Process

13

13. Implementation of

As per JNTU Syllabus

Interpolation Process

14

10

14. Implementation of I/D

As per JNTU Syllabus

sampling rate converters

15

10

15. Audio application such as

As per JNTU Syllabus

to plot a time and frequency


display of microphone plus a
cosine using DSP. Read a .wav
file and match with their
respective spectrograms.

16

11

16. Noise removal: Add

As per JNTU Syllabus

noise above 3 KHz and


then remove,
interference suppression
17

11

using 400 Hz tone.


Impulse response of first order
and second order systems.

As per JNTU Syllabus

8. EACH EXPERIMENT WRITE UP


1.

Introduction:

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 non interactive language such as C or Fortran. The name MATLAB
stands for matrix laboratory.
Starting MATLAB on Windows platforms, start MATLAB by double-clicking the MATLAB
shortcut icon on your Windows desktop.
Quitting MATLAB: To end your MATLAB session, select File > Exit MATLAB in the desktop,
or type quit in the Command Window. You can run a script file named finish.m each time
MATLAB quits that, for example, executes functions to save the workspace.
MATLAB desktop:
On starting MATLAB the MATLAB desktop appears, containing tools (graphical user interfaces )
for managing files , variables and applications associated with MATLAB. It contains :
(i) Command Window and Command History
Command Window : Use the Command Window to enter variables and to run functions and Mfile scripts. Press the up arrow key to recall a statement previously typed. Edit the statement as
needed and then press Enter to run it.
Command History : Statements entered in the Command Window are logged in the Command
History. From the Command History, previously run statements can be viewed, copied and
executed. M-file can be created from selected statements.

(ii) Current Directory Browser and Search Path : MATLAB file operations use the current
directory and the search path as reference points. Any file required to run must either be in the
current directory or on the search path.

(iii) Workspace Browser and Array Editor :The MATLAB workspace consists of the set of
variables (named arrays) built up during a MATLAB session and stored in memory. The variables
can be added to the workspace by using functions, running M-files, and loading saved
workspaces. To delete variables from the workspace, select the variables and select Edit > Delete.
Array Editor : Double-click a variable in the Workspace browser, or use open var variable name,
to see it in the Array Editor. Use the Array Editor to view and edit a visual representation of
variables in the workspace.
(iv) Editor/Debugger : Editor/Debugger is used to create and debug M-files, which are
programs to run MATLAB functions. The Editor/Debugger provides a graphical
user interface for text editing, as well as for M-file debugging. To create or edit an M-file use File
> New or File > Open, or use the edit function.
The important commands/ functions are as below :

1. clc (Remove items from workspace, freeing up system memory) clears all input and output
from the Command Window display, giving "clean screen." After using clc, the scroll bar cannot
be used to see the history of functions, but still the up arrow can be used to recall statements from
the command history.
2. close (Remove specified figure): close deletes the current figure or the specified figure(s). It
optionally returns the status of the close operation.
3. xlabel, ylabel, zlabel (Label x-, y-, and z-axis) : Each axes graphics object can have one
label for the x-, y-, and z-axis. The label appears beneath its respective axis in a two-dimensional
plot and to the side or beneath the axis in a three-dimensional plot.
xlabel('string') labels the x-axis of the current axes.
ylabel(...) and zlabel(...) label the y-axis and z-axis, respectively, of the current axes.
4.title( Add title to current axes) : Each axes graphics object can have one title. The title is located
at the top and in the center of the axes.
title('string') outputs the string at the top and in the center of the current axes.
5. figure (create figure graphics object) : figure creates figure graphics objects. Figure objects
are the individual windows on the screen in which MATLAB displays graphical output.
6. subplot (Create axes in tiled positions): subplot divides the current figure into rectangular
panes that are numbered row wise. Each pane contains an axes object. Subsequent plots are output
to the current pane.
h = subplot(m,n,p) or subplot(mnp) breaks the figure window into an m-by-n matrix of small
axes, selects the pth axes object for the current plot, and returns the axes 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.
stem (Plot discrete sequence data) : A two-dimensional stem plot displays data as lines
extending from a baseline along the x-axis. A circle (the default) or other marker whose y-position
represents the data value terminates each stem.
stem(Y) Plots the data sequence Y as stems that extend from equally spaced and automatically
generated values along the x-axis. When Y is a matrix, stem plots all elements in a row against the
same x value.
stem(X,Y) 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.
bar(Plot bar graph (vertical and horizontal)) : A bar graph displays the values in a vector or
matrix as horizontal or vertical bars.
bar(Y) draws one bar for each element in Y. If Y is a matrix, bar groups the bars produced by the
elements in each row. The x-axis scale ranges from 1 up to length(Y) when Y is a vector, and 1 to
size(Y,1), which is the number of rows, when Y is a matrix.
barh(...) and h = barh(...) create horizontal bars. Y determines the bar length. The vector x is a
vector defining the y-axis intervals for horizontal bars.
plot ( 2-D line plot) :
plot(Y) Plots the columns of Y versus their index if Y is a real number. If Y is complex, plot(Y)
is equivalent to plot(real(Y),imag(Y)). In all other uses of plot, the imaginary component is
ignored.
plot(X1,Y1,...) Plots all lines defined by Xn versus Yn pairs. If only Xn or Yn is a matrix, the
vector is plotted versus the rows or columns of the matrix,
depending on whether the vector's row or column dimension matches the matrix. If Xn is a scalar
and Yn is a vector, disconnected line objects are created and plotted as discrete points vertically at
Xn.
input (Request user input) : The response to the input prompt can be any MATLAB expression,
which is evaluated using the variables in the current workspace.
user_entry = input('prompt') Displays prompt as a prompt on the screen, waits for input from
the keyboard, and returns the value entered in user_entry. user_entry = input('prompt', 's') returns
the entered string as a text variable rather than as a variable name or numerical value.
zeros (Create array of all zeros) :
B = zeros(n) Returns an n-by-n matrix of zeros. An error message appears if n is not a scalar.

12. ones (Create array of all ones) :


Y = ones(n) Rreturns an n-by-n matrix of 1s. An error message appears if n is not a scalar.
exp (Exponential) :
Y = exp(X) The exp function is an elementary function that operates element-wise on arrays. Its
domain includes complex numbers.
Y = exp(X) returns the exponential for each element of X.
disp (Display text or array) :
disp(X)
Displays an array, without printing the array name. If X contains a text string, the
string is displayed. Another way to display an array on the screen is to type its name, but this
prints a leading "X=," which is not always desirable. Note that disp does not display empty arrays.
conv (Convolution and polynomial multiplication) :
w = conv(u,v) convolves vectors u and v. Algebraically, convolution is the same
operation as multiplying the polynomials whose coefficients are the elements of u and v.
xcorr (Cross-correlation) :
c = xcorr(x,y) returns the cross-correlation sequence in a length 2*N-1 vector, where x
and y are length N vectors (N>1). If x and y are not the same length, the shorter vector is zeropadded to the length of the longer vector.
filter (1-D digital filter) :
y = filter(b,a,X) filters the data in vector X with the filter described by numerator
coefficient vector b and denominator coefficient vector a. If a(1) is not equal to 1, filter
normalizes the filter coefficients by a(1). If a(1) equals 0, filter returns an error.
poly (Polynomial with specified roots) :
r = roots(p)
which returns a column vector whose elements are the roots of the
polynomial specified by the coefficients row vector p. For vectors, roots and poly are inverse
functions of each other, up to ordering, scaling, and round off error.
(Convert unconstrained MPC controller to linear transfer function) :
sys=tf(MPCobj)
The tf function computes the transfer function of the linear
controller ss(MPCobj) as an LTI system in tf form corresponding to the MPC controller when the
constraints are not active. The purpose is to use the linear equivalent control in Control System
Toolbox for sensitivity and other linear analysis.
freqz (Frequency response of filter ) :

[h,w] = freqz(ha) returns the frequency response vector h and the corresponding frequency
vector w for the adaptive filter ha. When ha is a vector of adaptive filters, freqz returns the matrix
h. Each column of h corresponds to one filter in the vector ha.
abs (Absolute value and complex magnitude) :
abs(X) returns an array Y such that each element of Y is the absolute value of the
corresponding element of X.
fft (Discrete Fourier transform) :
Y = fft(X) Y = fft(X) returns the discrete Fourier transform (DFT) of vector X, computed with a
fast Fourier transform (FFT) algorithm.
mod (Modulus after division) :
M = mod(X,Y) returns X - n.*Y where n = floor(X./Y). If Y is not an integer and the
quotient X./Y is within round off error of an integer, then n is that integer. The inputs X and Y
must be real arrays of the same size, or real scalars.
sqrt (Square root) :
B = sqrt(X) returns the square root of each element of the array X. For the elements of
X that are negative or complex, sqrt(X) produces complex results.
ceil (Round toward infinity) :
B = ceil(A) rounds the elements of A to the nearest integers greater than or equal to A. For
complex A, the imaginary and real parts are rounded independently.
fir1(Window-based finite impulse response filter design) :
b = fir1(n,Wn) returns row vector b containing the n+1 coefficients of an order n lowpass
FIR filter. This is a Hamming-window based, linear-phase filter with normalized cutoff frequency
Wn. The output filter coefficients, b, are ordered in descending powers of z.
buttord (Butterworth filter order and cutoff frequency) :
[n,Wn] = buttord(Wp,Ws,Rp,Rs)
returns the lowest order, n, of the digital
Butterworth filter that loses no more than Rp dB in the passband and has at least Rs dB of
attenuation in the stopband. The scalar (or vector) of corresponding cutoff frequencies, Wn, is
also returned. Use the output arguments n and Wn in butter.
fliplr (Flip matrix left to right) :
B = fliplr(A) returns A with columns flipped in the left-right direction, that is, about a
vertical axis.If A is a row vector, then fliplr(A) returns a vector of the same length with the order
of its elements reversed. If A is a column vector, then fliplr(A) simply returns A.

min ( Smallest elements in array) :


C = min(A) returns the smallest elements along different dimensions of an array. If A is a
vector, min(A) returns the smallest element in A.If A is a matrix, min(A) treats the columns of A
as vectors, returning a row vector containing the minimum element from each column. If A is a
multidimensional array, min operates along the first nonsingleton dimension.
max ( Largest elements in array) :
C = max(A) returns the largest elements along different dimensions of an array.If A is a
vector, max(A) returns the largest element in A.If A is a matrix, max(A) treats the columns of A as
vectors, returning a row vector containing the maximum element from each column. If A is a
multidimensional array, max(A) treats the values along the first non-singleton dimension as
vectors, returning the maximum value of each vector.
find (Find indices and values of nonzero elements) :
ind = find(X) locates all nonzero elements of array X, and returns the linear indices of
those elements in vector ind. If X is a row vector, then ind is a row vector; otherwise, ind is a
column vector. If X contains no nonzero elements or is an empty array, then ind is an empty array.
residuez (z-transform partial-fraction expansion ) :
residuez converts a discrete time system, expressed as the ratio of two polynomials, to partial
fraction expansion, or residue, form. It also converts the partial fraction expansion back to the
original polynomial coefficients.
[r,p,k] = residuez(b,a) finds the residues, poles, and direct terms of a partial fraction
expansion of the ratio of two polynomials, b(z) and a(z). Vectors b and a specify the coefficients
of the polynomials of the discrete-time system b(z)/a(z) in descending powers of z.
angle (Phase angle) :
P = angle(Z) returns the phase angles, in radians, for each element of complex array Z.
The angles lie between + and .
log (Natural logarithm ) :
Y = log(X) returns the natural logarithm of the elements of X. For complex or negative
z, where z = x +y*i
, the complex logarithm is returned.
.

Experiment No: 1
Aim: . Generation of Sinusoidal waveform
Apparatus require d: A PC with Mat lab version 2008a.
MATLAB Program :

clc;
clear all;
close all;
t=0:.01:2*pi;
%generation of sine signals%
y1=sin(t);
y2=sin(3*t)/3;
y3=sin(5*t)/5;
y4=sin(7*t)/7;
y5=sin(9*t)/9;
%y = sin(t) + sin(3*t)/3 + sin(5*t)/5 + sin(7*t)/7 + sin(9*t)/9; %
y = y1+y2+y3+y4+y5;
plot (t,y,t,y1,t,y2,t,y3,t,y4,t,y5);
legend ('y','y1','y2','y3','y4','y5');
title ('generation of sum of sinusoidal signals');
grid on;
ylabel ('---> Amplitude');
xlabel ('---> t');
Output:

Res ult:- Thus the MATLAB program for sum of sinusoidal signals was performed and the
output was verified.

Experiment No: 2
Aim: To find DFT / IDFT of given DT signal
Apparatus require d: A PC with Mat lab version 2008a.
MATLAB Program:

DFT :
%prog for computing discrete Fourier Transform
clc;clear all;close all;
x =input('Enter the sequence ');

%x =[0 1 2 3 4 5 6 7]

n = input('Enter the length of Fourier Transform ') %n =8 has to be same as


%the length of sequence
x =fft(x,n);
stem(x);
ylabel('imaginary axis------>');
xlabel('(real axis------>');
title('Exponential sequence');
disp('DFT is');x

IDFT :
% prog for inverse discrete Fourier Transform (IDFT)
clc;clear all;close all;
x =input('Enter length of DFT ');

% for best results in power of 2

t = 0:pi/x:pi;
num =[0.05 0.033 0.008];
den =[0.06 4 1];
trans = tf(num,den);
[freq,w] =freqz(num,den,x); grid on;
subplot(2,1,1);plot(abs(freq),'k');
disp(abs(freq));
ylabel('Magnitude');
xlabel('Frequency index');
title('Magnitude Response');
Output :

DFT :

Enter the sequence [0 1 2 3 4 5 6 7]


Enter the length of Fourier Transform 8
n= 8

DFT is x = 28.0000
-4.0000

-4.0000 + 9.6569i

-4.0000 + 4.0000i

-4.0000 + 1.6569i

-4.0000 - 1.6569i

-4.0000 - 4.0000i

-4.0000 - 9.6569i

IDFT :

Enter length of DFT 4 = 0.0180


0.0166
0.0130
0.0093

DFT

Discrete Fourier Transform

10
8

Im a g in a ry a x is ------>

6
4
2
0
-2
-4
-6
-8
-10

4
5
Real axis------>

IDFT
Magnitude Response

M a g n it u d e

0.02
0.015
0.01
0.005

1.5

2.5
Frequency index

3.5

Result:- Thus Discrete Fourier Transform is Performed using Matlab.

Experiment No: 3

Aim: To find frequency response of a given system given in (Transfer Function/ Differential
equation form).
Apparatus require d: A PC with Mat lab version 2008a.
MATLAB Program:
clc
close all
x=1
num=[10];
dem=[0.01 1.2 1.0];
c=tf(num,dem); %Specify transfer functions
w=0:0.1:10;
H=freqresp(c,w);
for i=1:1:101
p(i)=abs(H(:,:,i))
end
plot(w,p)
grid;
title('frequency response of sencond order system')
xlabel('w')
ylabel('Amplitude')
OUTPUT WAVE FORM:

Result:- Thus the MATLAB program for Frequency Response of Transfer function was
performed and the output was verified.

Experiment No: 4

Aim: Implementation of FFT of given sequence


Apparatus require d: A PC with Mat lab version 2008a.
MATLAB Program:
%To compute the FFT of the impulse sequence and plot magnitude and phase response
clc;
clear all;
close all;
%impulse sequence
t=-2:1:2;
y=[zeros(1,2) 1 zeros(1,2)];
subplot (3,1,1);
stem(t,y);
grid;
input('y=');
disp(y);
title ('Impulse Response');
xlabel ('time -->');
ylabel ('--> Amplitude');
xn=y;
N=input('enter the length of the FFT sequence: ');
xk=fft(xn,N);
magxk=abs(xk);
angxk=angle(xk);
k=0:N-1;
subplot(3,1,2);
stem(k,magxk);
grid;
xlabel('k');
ylabel('|x(k)|');
subplot(3,1,3);
stem(k,angxk);
disp(xk);
grid;
xlabel('k');
ylabel('arg(x(k))');

outputs:
y=

00100
enter the length of the FFT sequence: 10
1.0000 0.3090 - 0.9511i -0.8090 - 0.5878i -0.8090 + 0.5878i 0.3090 + 0.9511i
1.0000 0.3090 - 0.9511i -0.8090 - 0.5878i -0.8090 + 0.5878i 0.3090 + 0.9511i

Result:- Thus Fast Fourier Transform is Performed using Matlab.

Experiment No: 5

Aim: Determination of Power Spectrum of a given signal(s).


Apparatus require d: A PC with Mat lab version 2008a.
MATLAB Program:
clc;
close all;
clear all;
t=0:511;
x1=sin(2*pi*50/1000*t);
figure(1);
%subplot(321);
plot(t,x1);
title('*** Sin Signal 1***');
x2=sin(2*pi*120/1000*t);
figure(2);
%subplot(322);
plot(t,x2);
title('*** Sin Signal 2 ***');
x=x1+x2;
figure(3);
%subplot(323);
plot(x);
title('*** Sum of Two Sinusoidal Signals ***');
y=x+randn(size(t));
N=length(y);
figure(4);
%subplot(324);
plot(y);
title('*** After adding the Noise the Signal ***');
f1=1000*(0:N/2-1)/N;
p=(abs(fft(y))).^2/N;
figure(5);
%subplot(325)
plot(f1,10*log10(p(1:256)));
title('*** Power Spectral Density Calculation Using FFT ***');

RESULT: The Power Spectral Density of given sequence is observed

Experiment No: 6

Aim: Implementation of Low Pass FIR filter for given sequence.


Apparatus require d: A PC with Mat lab version 2008a.
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.

In this equation, x(k) and y(n) represent the input to and output from the filter at time n. h(n-k) is
the transversal filter coefficients at time n. These coefficients are generated by using FDS
(Filter Design Software or Digital filter design package).
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.
PROCEDURE:
1. Enter the passband ripple (rp) and stopband ripple (rs).
2. Enter the passband frequency (fp) and stopband frequency (fs).
3. Enter the sampling frequency (f).
4. Calculate the analog passband edge frequency (wp) and stop band edge frequency (ws)
wp=2*fp/f ws=2*fs/f
5. Calculate the order of the filter using the following formula,

[Use ceil( ) for rounding off the value of n to the nearest integer] if n is an
odd number, then reduce its value by 1.
6. Generate (n+1)th point window coefficients.For example boxcar(n+1) generates a rectangular
window. y=boxcar(n+1)
7. Design an nth order FIR filter using the previously generated (n+1) length window function.
b=fir1(n,wp,y)
8. Find the frequency response of the filter by using freqz( ) function. [h,o]=freqz(b,a,k) This
function returns k-point complex frequency response vector h and k-point frequency vector o
in radians/samples of the filter.

Where a, b are vectors containing the denominator and numerator


coefficients. Here a=1.
9. Calculate the magnitude of the frequency response in decibels (dB). m= 20*log10(abs(h))
10. Plot the magnitude response [magnitude in dB Vs normalized frequency (o/pi)]
11. Give relevant names to x- and y- axes and give an appropriate title for the plot.
MATLAB Program:
clc;
close all;
clear all;
rp=0.05%input('enter the passband ripple');
rs=0.04%input('enter the stopband ripple');
fp=1500%input('enter the passband frequency');
fs=2000%input('enter the stopband frequency');
f=8000%input('enter the sampling freq');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n1=n+1;
if(rem(n,2)~=0)
n1=n;
n=n-1;
end
y=boxcar(n1);
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
an=angle(h);
figure(1)
plot(o/pi,m);
title('******** LOW PASS FIR FILTER RESPONSE ********');
ylabel('GAIN in db--->'); xlabel('Normalised Frequency--->');
figure(2)
plot(o/pi,an);
title('******** LOW PASS FIR FILTER RESPONSE ********');
ylabel('PHASE--->');
xlabel('Normalised Frequency--->');

Input:
rp = 0.05
rs = 0.04
fp = 1500
fs = 2000
f = 8000

RESULT: The implementation of Butterworth Lowpass FIR Filters Completed.


Experiment No: 7
Aim: Implementation of High Pass FIR filter for given sequence.
Apparatus require d: A PC with Mat lab version 2008a.
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.

In this equation, x(k) and y(n) represent the input to and output from the filter at time n. h(n-k) is
the transversal filter coefficients at time n. These coefficients are generated by using FDS
(Filter Design Software or Digital filter design package).
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.
PROCEDURE:
1. Enter the passband ripple (rp) and stopband ripple (rs).
2. Enter the passband frequency (fp) and stopband frequency (fs).
3. Enter the sampling frequency (f).
4. Calculate the analog passband edge frequency (wp) and stop band edge frequency (ws)
wp=2*fp/f ws=2*fs/f
5. Calculate the order of the filter using the following formula,

[Use ceil( ) for rounding off the value of n to the nearest integer] if n is an
odd number, then reduce its value by 1.
6. Generate (n+1)th point window coefficients.For example boxcar(n+1) generates a rectangular
window. y=boxcar(n+1)
7. Design an nth order FIR filter using the previously generated (n+1) length window function.
b=fir1(n,wp,high,y)
8. Find the frequency response of the filter by using freqz( ) function. [h,o]=freqz(b,a,k) This
function returns k-point complex frequency response vector h and k-point frequency vector o

in radians/samples of the filter.


Where a, b are vectors containing the denominator and numerator
coefficients.

Here a=1.
9. Calculate the magnitude of the frequency response in decibels (dB). m= 20*log10(abs(h))
10. Plot the magnitude response [magnitude in dB Vs normalized frequency (o/pi)]
11. Give relevant names to x- and y- axes and give an appropriate title for the plot
MATLAB Program:
clc;
close all;
clear all;
rp=0.05%input('enter the passband ripple');
rs=0.06%input('enter the stopband ripple');
fp=1000%input('enter the passband frequency');
fs=2000%input('enter the stopband frequency');
f=8000%input('enter the sampling freq');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n1=n+1;
if(rem(n,2)~=0)
n1=n;
n=n-1;
end
y=boxcar(n1);
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
an=angle(h);
figure(1)
plot(o/pi,m);
title('******** HIGH PASS FIR FILTER RESPONSE ********');
ylabel('GAIN in db--->');
xlabel('Normalised Frequency--->');
figure(2)
plot(o/pi,an);

title('******** HIGH PASS FIR FILTER RESPONSE ********');


ylabel('PHASE--->');
xlabel('Normalised Frequency--->');
Input:
rp = 0.05
rs = 0.06
fp = 1000
fs = 2000
f = 8000

RESULT: The implementation of Butterworth Highpass FIR Filters Completed

Experiment No: 8

Aim: Implementation of Low Pass IIR filter for given sequence.


Apparatus require d: A PC with Mat lab version 2008a.
Procedure:
1. Enter the pass band ripple (rp) and stop band ripple (rs).
2. Enter the pass band frequency (fp) and stop band frequency (fs).
3. Get the sampling frequency (f).
4. Calculate the analog pass band edge frequencies, w1 and w2.
w1 = 2*fp/f w2 = 2*fs/f
5. Calculate the order and 3dB cutoff frequency of the analog filter. [Make use of the following
function] [n,wn]=buttord(w1,w2,rp,rs,s)
6. Design an nth order analog high pass Butter worth filter using the following statement.
[b,a]=butter(n,wn,s)
7. Find the complex frequency response of the filter by using freqs( )function
[h,om]=freqs(b,a,w)
where, w = 0:0.01:pi
This function returns complex frequency response vector h and frequency

vector om in radians/samples of the filter.


+..a(na)
Where a,b are the vectors containing the denominator and numerator coefficients.
8. Calculate the magnitude of the frequency response in decibels (dB)
m=20*log10(abs(h))
9. Plot the magnitude response [magnitude in dB Vs normalized frequency (om/pi)]
10. Give relevant names to x and y axes and give an appropriate title for the plot.
11. Plot all the responses in a single figure window.[Make use of subplot( )].
MATLAB Program:
clc;
close all;
clear all;
format long
rp=input('enter the passband ripple');
rs=input('enter stopband ripple');
wp=input('enter passband freq');

ws=input('enter stopband freq');


fs=input('enter sampling freq');
w1=2*wp/fs;
w2=2*ws/fs;
%Analog LPF
[n,wn]= buttord(w1,w2,rp,rs);
[b,a]=butter(n,wn,'s');
w=0:.01:pi;
[h,om]=freqs(b,a,w);
m=20*log10(abs(h));
an=angle(h);
figure(3)
plot(om/pi,m); title('**** Analog Output Magnitude *****');
ylabel('gain in db...>');
xlabel('normalised freq..>');
figure(2)
plot(om/pi,an);
title('**** Analog Output Phase ****');
xlabel('normalised freq..>');
ylabel('phase in radians...>');
n
wn
%Digital LPF
[n,wn]= buttord(w1,w2,rp,rs);
[b,a]=butter(n,wn);
w=0:.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
figure(1)
plot(om/pi,m);
title('**** Digital Output Magnitude *****');
ylabel('gain in db...>');
xlabel('normalised freq..>');
figure(4)
plot(om/pi,an);
title('**** Digital Output Phase ****');
xlabel('normalised freq..>');
ylabel('phase in radians...>');
n
wn

Result: Butter worth Digital and analog low pass IIR filters are implemented using
MATLAB.

Experiment No: 9
Aim: Implementation of High Pass IIR filter for given sequence.
Apparatus require d: A PC with Mat lab version 2008a.
MATLAB Program:
clc;
close all;
clear all;
format long
rp=input('enter the passband ripple');
rs=input('enter stopband ripple');
wp=input('enter passband freq');
ws=input('enter stopband freq');
fs=input('enter sampling freq');
w1=2*wp/fs;
w2=2*ws/fs;
%Analog HPF
[n,wn]= buttord(w1,w2,rp,rs);
[b,a]=butter(n,wn,'high','s');
w=0:.01:pi;
[h,om]=freqs(b,a,w);
m=20*log10(abs(h));
an=angle(h); figure(1)
plot(om/pi,m);
title('**** Analog Output Magnitude *****');
ylabel('gain in db...>');
xlabel('normalised freq..>');
figure(2)
plot(om/pi,an);
title('**** Analog Output Phase ****');
xlabel('normalised freq..>');
ylabel('phase in radians...>');
n
wn
%Digital HPF
[n,wn]= buttord(w1,w2,rp,rs);
[b,a]=butter(n,wn,'high');
w=0:.01:pi;
[h,om]=freqz(b,a,w); m=20*log10(abs(h));

an=angle(h);
figure(3)
plot(om/pi,m);
title('**** Digital Output Magnitude *****');
ylabel('gain in db...>');
xlabel('normalised freq..>');
figure(4)
plot(om/pi,an);
title('**** Digital Output Phase ****');
xlabel('normalised freq..>');
ylabel('phase in radians...>');
n
wn
Input:
rp = 0.5000 rs = 100 wp = 1200 ws = 2400 fs = 8000
Output:
n = 13
wn = 0.32870936151976
n = 13
wn = 0.32870936151976

Result: Butter worth Digital and analog low pass IIR filters are implemented using
MATLAB.

. Experiment No: 10
Aim: Generation of DTMF signal.
Apparatus require d: A PC with Mat lab version 2008a.
MATLAB Program:
%Generation of Dual Tone Multi Frequency Signal
%%%%first lets generate the tweive freq program
clc;
symbol={'1','2','3','4','5','6','7','8','9','*','0','#'};
lfg=[697 770 852 941];
hfg=[1209 1336 1477];
f= [];
for r=1:4,
for c=1:3,

f=[ f [lfg(r);hfg(c)] ];
end
end
f'
%next generate and visualize the DTMF tones
fs=8000;
N=800;
t=(0:N-1)/fs;
pit=2*pi*t;
tones=zeros(N,size(f,2));
for tonechoice=1:12
%%generetate tone
a=f(:,tonechoice);
b=a*pit;
sinb=sin(b);
c=sum(sinb);
tones(:,tonechoice)=c';
%%plot tone
subplot(4,3,tonechoice),plot(t*1e3,tones(:,tonechoice));
title(['symbol"',symbol{tonechoice},'":[',num2str(f(1,tonechoice)),',',num2str(f(2,
tonechoice)),']'])
set(gca,'xlim',[0 25]);
ylabel('amplitude')
if tonechoice>9,xlabel('time(ms)');
end
end
OUTPUT:

Result: Hence the operation of DTMF signal is generated.

Experiment No: 11
Aim: Implementation of Decimation Process.
Apparatus require d: A PC with Mat lab version 2008a.
MATLAB Program:
clc;
clear all;
close all;
N=250 ;
n=0:1:N-1;
x=sin(2*pi*n/15);
M=2;
figure(1)
stem(n,x);
grid on;
xlabel('No.of.Samples');
ylabel('Amplitude');

title('Original Sequence');
a=1;
b=fir1(5,0.5,'Low');
y=filter(b,a,x);
figure(2)
stem(n,y);
grid on;
xlabel('No.of.Samples');
ylabel('Amplitude');
title('Filtered Sequence'); x1=y(1:M:N);
n1=1:1:N/M;
figure(3)
stem(n1-1,x1);
grid on;
xlabel('No.of.Samples');
ylabel('Amplitude');
title('Decimated Sequence');

Result: This MATLAB program has been written to perform Decimation on the Given Input
Sequence.

Experiment No: 12
Aim: Implementation of Interpolation Process.
Apparatus require d: A PC with Mat lab version 2008a.
MATLAB Program:
clc;
clear all;
close all;
N=125;
n=0:1:N-1;
x=sin(2*pi*n/15);
L=2;
figure(1)
stem(n,x);
grid on;
xlabel('No.of.Samples');
ylabel('Amplitude');
title('Original Sequence');
x1=[zeros(1,L*N)];
n1=1:1:L*N;
j =1:L:L*N;
x1(j)=x;

figure(2)
stem(n1-1,x1);
grid on;
xlabel('No.of.Samples');
ylabel('Amplitude');
title('Upsampled Sequence');
a=1;
b=fir1(5,0.5,'Low');
y=filter(b,a,x1);
figure(3)
stem(n1-1,y);
grid on;
xlabel('No.of.Samples');
ylabel('Amplitude');
title('Interpolated Sequence');

Result: This MATLAB program has been written to perform interpolation on the Given Input
Sequence.

Experiment No: 13
Aim: To write a MATLAB program to find the impulse response of a LTI system defined by a
difference equation:
y(n) + 0.7y(n-1) 0.45y(n-2) 0.6y(n-3) = 0.8x(n) 0.44x(n-1) + 0.36x(n-2) + 0.2x(n-3)
Apparatus require d: A PC with Mat lab version 2008a.
MATLAB Program:
clc;
clear all;
close all;
N = input ('Enter the required length of impulse response N = ');
n = 0 : N-1;
b = input ('Enter the co-efficients of x(n), b = ');
a = input ('Enter the co=efficients of y(n), a = ');
% Impulse response of the LTI system given by the difference equation
x = [1, zeros(1,N-1)];
y = impz (b,a,N);
subplot (2,1,1);
stem (n,y,r);
xlabel ('time');
ylabel ('amplitude');
title ('IMPULSE RESPONSE');
grid on;
% Pole Zero distribution of the LTI system given by the difference equation
subplot (2,1,2);
zplane (b,a);
xlabel ('Real part');
ylabel ('Imaginary part');
title ('Poles and Zeros of H[z] in Z-plane');
grid on;
Output : Enter the required length of impulse response N = 40
Enter the co-efficients of x(n), b = [0.8 -0.44 0.36 0.02]
Enter the co=efficients of y(n), a = [1 0.7 -0.45 -0.6]

Result:-Thus the MATLAB program for Impulse Response of Difference Equation was
performed and the output was verified

INTRODUCTION TO DSP PROCESSORS


A digital signal processor (DSP) is an integrated circuit designed for high- speed data
manipulations, and is used in audio, communications, image manipulation, and other dataacquisition and data-control applications. The microprocessors used in personal computers
are optimized for tasks involving data movement and inequality testing. T he typical
applications requiring such capabilities are word processing, database management, spread
sheets, etc. When it comes to mathematical computations the traditional microprocessor are
deficient particularly where real-time performance
is required.
Digital signal
processors are microprocessors optimized for basic mathematical calculations such as
additions and multiplications.
Fixe d ve rs us Floating
Point :
Digital S ignal Processing can be divided into two categories, fixed po int and floating
point which refer to the format used to store and manipulate numbers within the devices. Fixed
point DSPs usually represent each number with a minimum of 16 bits, although a different
length can be used. There are four common ways that these 216 i,e., 65,536 possible bit
patterns can represent a number. In unsigned integer, the stored number can take on any
integer value from 0 to 65,535, signed integer uses two's complement to include negative
numbers from 32,768 to 32,767. With unsigned fraction notation, the 65,536 levels are spread
uniformly between 0 and 1 and the signed fraction format allows negative numbers,
equally spaced between -1 and 1.
The floating point DSPs typically use a minimum of 32 bits to store each value. This results
in many more bit patterns than for fixed point, 232 i,e., 4,294,967,296 to be exact. All floating
point DSPs can also handle fixed point numbers, a necessity to implement counters, loops,
and signals coming from the ADC and going to the DAC. However, this doesn't mean that
fixed point math will be carried out as quickly as the floating point operations; it
depends on the internal architecture.
C
versus
Assembly:
DSPs are programmed in the same languages as other scientific and engineering
applications, usually assembly or C. Programs written in assembly can execute faster, while
programs written in C are easier to develop and maintain. In traditional applications, such as
programs run on PCs and mainframes, C is almost always the first choice. If assembly is
used at all, it is restricted to short subroutines that must run with the utmost speed.
How
fast
DSPs?

are

The primary reason for using a DSP instead of a traditional microprocessor is speed: the
ability to move samples into the device and carry out the needed mathematical operations,
and output the processed data. The usual way of specifying the fastness of a DSP is: fixed
point systems are often quoted in MIPS (million integer operations per second). Likewise,
floating point devices can be specified in MFLOPS (million floating point operations per
second).

TMS320
Family:
The Texas Instruments TMS320 family o f DSP devices covers a wide range, from a 16-bit
fixed- point device to a single-chip parallel-processor device. In the past, DSPs were
used only in specialized applications. Now they are in many mass- market consumer
products that are continuously entering new market segments. The Texas Instruments
TMS320 family of DSP devices and their typical applications are mentioned below.
C1x, C2x, C2xx, C5x, and C54x: The width of the data bus on these devices is 16 bits. All
have

modified Harvard architectures. They have been used in toys, hard disk drives, modems,
cellular phones, and active car suspensions.
C3x: The width of the data bus in the C3x series is 32 bits. Because of the reasonable cost
and floating-point performance, these are suitable for many applica tions. These include
almost any filters, analyzers, hi- fi systems, voice- mail, imaging, bar-code readers,
motor control, 3D graphics, or scientific processing.
C4x: This range is designed for parallel processing. The C4x devices have a 32 -bit data bus
and

are floating-point. They have an optimized on-chip communication channel, which


enables a number of them to be put together to form a parallel-processing cluster. The C4x
range devices have been used in virtual reality, image recognition, telecom routing, and
parallel-processing systems.
C6x: The C6x devices feature VelociTI , an advanced very long instruction word
(VLIW)

architecture developed by Texas Instruments. Eight functional units, including two


multipliers
and six arithmetic logic units (ALUs), provide 1600 MIPS of cost-effective performance.
The C6x DSPs are optimized for multi-channel, multifunction applications, including
wireless base stations, pooled modems, remote-access servers, digital subscriber loop
systems, cable modems, and multi-channel telephone systems.
Typical Applications for the TMS320 Family
The TMS320 DSPs offer adaptable approaches to traditional signal-processing problems and
support complex applications that often require multiple operations to be performed
simultaneously.

INTRODUCTION TO TMS 320 C6713 DSK


The highperformance board features the TMS320C6713 floating-point DSP. Capable of
performing 1350 million floating point operations per second, the C6713 DSK the most powerful
DSK development board.

The DSK is US B port interfaced platform that allows to efficiently develop and
test applications for the C6713. With extensive host PC and target DSP software support, the
DSK provides ease-of- use and capabilities that are attractive to DSP engineers.

The 6713 DSP S tarter K it (DSK) is a low-cost platform which lets customers evaluate
and develop applications for the Texas Instruments C67X DSP family.
The primary features of the DSK are:
225 MHz TMS320C6713 F loating Point DSP
AIC23 Stereo Codec
Four Position User DIP Switch a nd Four User LEDs
On-board F lash and S DRAM
TIs Code Composer S tudio development tools are bundled with the 6713DSK providing
the user with an industrial-strength integrated development environment for C and
assembly programming.
Code Composer Studio communicates with the DSP using an on-board JTAG emulator through a
USB interface.

The TMS320C6713 DSP is the heart of the system. It is a core member of Texas Instruments

C64X line of fixed point DSPs whose distinguishing features are an extremely high performance
225MHz VLIW DSP core and 256Kbytes of internal memory. O n-chip peripherals include a
32- bit external memory interface (EMIF ) with integrated SDRAM controller, 2 multichannel buffered serial ports (McBSPs), two on-board timers and an enhanced DMA controller
(EDMA). The 6713 represents the high end of TIs C6700 floating point DSP line both in
terms of computational performance and on-chip resources.
The 6713 has a significant amount of internal memory so many applications will have all
codeand data on-chip. External accesses are done through the EMIF which can connect to
both synchronous and asynchronous memories. The EMIF signals are also brought out to
standard TI expansion bus connectors so additional functionality can be added on daughter card
modules.
DSPs are frequently used in audio processing applications so the DSK includes an onboard codec called the AIC23. Codec stands for coder/decoder,the job of the AIC23 is to code
analog input samples into a digital format for the DSP to process, then decode data coming
out of the DSP to generate the processed analog output. Digitial data is sent to and from
the codec on McBSP1.
TMS320C6713 DSK Overview Block Diagram

The DSK has 4 light emitting diodes (LEDs) and 4 DIP switches that allow users to interact
with programs through simple LED displays and user input on the switches. Many of the
included examples make use of these user interfaces Options.

The DSK implements the logic necessary to tie board components together in a
programmable logic device called a CPLD. In addition to random glue logic, the CP
LD implements a set of 4 software programmable registers that can be used to access the onboard LEDs and DIP switches as well as control the daughter card interface.

DSK hardware installation


Shut down and power off the PC
Connect the supplied USB port cable to the board
Connect the other end of the cable to the US B port of PC
Plug the other end of the power cable into a power outlet
Plug the power cable into the board
The user LEDs should flash several times to indicate board is operational
When you connect your DSK through USB for the first time on a Windows loaded PC
the new hardware found wizard will come up. So, Install the drivers (The CCS CD
contains the require drivers for C6713 DSK).
Install the CCS software for C6713 DSK.
Troubleshooting DSK Connectivity
If Code Composer S tudio 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
C6713DSK Tools C6713 DSK Diagnostic UtilitiesThe below Screen will appear
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

If the board still fails to detect G o t o C M O S se t u p Enable the US B Port Option


(The required Device drivers will load along with CCS Installation)
SOFTWAR E INSTALLATION
You must install the hardware before you install the software on your system.
The requirements for the operating platform are;
Insert the installation CD into the CD-ROM drive
An install screen appears; if not, goes to the windows Explorer and
run setup.exe
Choose the option to install Code Composer Studio
If you already have C6000 CC Studio IDE installed on your PC,do not install DSK
software. CC Studio IDE full tools supports the DSK platform
Respond to the dialog boxes as the installation program runs
The Installation program automatically configures CC Studio IDE for operation with your DSK
and creates a CCStudio IDE DSK icon on your desktop. To install, follow these instructions:
INTRODUCTION TO CODE COMPOSER S TUDIO
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

Useful Types of Files


You will be working with a number of files with different extensions. They
include:
1. file.pjt: to create and build a project named file.
2.

file.c: C source program.

3. file.asm: assembly source program created by the user, by the C compiler,or by the linear
optimizer.
4. file.sa: linear assembly source program. The linear optimizer uses file.sa as input to
produce an assembly program file.asm
5. file.h: header support file.
6. file.lib: library file, such as the run-time support library file rts6701.lib.

7. file.cmd: linker command file that maps sections to memory.

8. file.obj: object file created by the assembler.

9. file.out: executable file created by the linker to be loaded and run on the proces s or.
Proce dure to wo rk o n co de compos e r s tudio

1.Click on CCStudio 3.1 on the desktop

Now the target is not connected in order to connect Debugconnect

2. To create project, Project New

3. Give project name and click on finish.

4. C lick on F ile New Source F ile, To write the Source Code

Enter the source code and save the file with . C extension.
5. To add the c program to the project
Project Add files to project <source file>

6. To add rts6700.lib to the project

Project Add files to project rts6700.lib


Path : C :\CCstudio\c6000\lib\rts6700.lib
Note: Select Object & library files (*.o, *.l) in Type of file

7. To add hello.cmd to the project


Project Add files to project hello.cmd
Path: C :\CCstudio \tutorial\dsk6713\hello1 \hello.cmd
Note: Select Linker command file (*.cmd) in Type of file

8. To compile
Project Compile file ( or use icon or ctrl+F7 )
9. To build or link
Project b uild (or use F7 ) (which will create a .out file in project folder)
10. To load the program:
File Load Program <select the .out file in debug folder in project folder> This
will load our program into the board.
11.To run the program
Debug Run
12. Observe the output in output window.
11. To see the Graph go to View and select time/frequency in the Graph, And give the correct
Start address provided in the program, Display data can be taken as per user

EXPERIMENT : 1
Aim:- To generate a sine wave and square wave using C6713 simulator
Equipments: Operating S ystem - Windows XP
Software - CC STUDIO 3
DSK 6713 DSP Trainer kit.
USB Cable
Power supply
Procedure :1. Open Code Composer Setup and select C6713 simulator, click save and quit

2. Start a new project using Project New pull down menu, save it in a separate
directory(C:\My projects) with file name sine wave.pjt3. Create a new source file using F ile
New Source file menu and save it in the project folder(sinewave.c)
4. Add the source file (sinewave.c) to the project
Project Add files to Project Select sinewave.c
5. Add the linker command file hello.cmd
Project Add files to Project
(path: C :\CCstudio \tutorial\dsk6713\hello \hello.cmd)
6. Add the run time support library file rts6700.lib
Project Add files to Project
(path: C\CCStudio\cgtools\lib\rts6700.lib)
7. Compile the program using project Compile menu or by Ctrl+F7
8. Build the program using projec t Build menu or by F7
9. Load the sinewave.out file (from project folder lcconv\Debug) using
File Load Program
10. Run the program using Debug Run or F5
11. To view the output graphically
Select View Graph Time and Frequency
12. Repeat the steps 2 to 11 for square wave.

Program
Sine Wave
#include <stdio.h>
#include <math.h>
float a[500];
void main()
{
int i=0;
for(i=0;i<500;i++)
{

a[i]=sin(2*3.14*10000*i);
}
}
Square wave
#include <stdio.h>
#include <math.h>
int a[1000];
void main()
{
int i,j=0; int b=5;
for(i=0;i<10;i++)
{
for (j=0;j<=50;j++)
{
a[(50*i)+j]=b;
}
b=b*(-1) ;
}}

Output:Sine wav

Square wave:-

Result:- The sine wave and square wave has been obtained.

EXPERIMENT : 2
Aim:- To verify FIR filters using C6713 simulator.
Equipments: Operating S ystem - Windows XP
Software - CC STUDIO 3
DSK 6713 DSP Trainer kit.
USB Cable
Power supply
Procedure :1. Open Code Composer Setup and select C6713 simulator, click save and quit
2. Start a new project using Project New pull down menu, save it in a separate
directory(C:\My projects) with file name sine wave.pjt3. Create a new source file using F ile
New Source file menu and save it in the project folder(sinewave.c)
4. Add the source file (sinewave.c) to the project
Project Add files to Project Select sinewave.c
5. Add the linker command file hello.cmd
Project Add files to Project
(path: C :\CCstudio \tutorial\dsk6713\hello \hello.cmd)
6. Add the run time support library file rts6700.lib
Project Add files to Project
(path: C\CCStudio\cgtools\lib\rts6700.lib)
7. Compile the program using project Compile menu or by Ctrl+F7
8. Build the program using projec t Build menu or by F7
9. Load the sinewave.out file (from project folder lcconv\Debug) using
File Load Program
10. Run the program using Debug Run or F5
11. To view the output graphically
Select View Graph Time and Frequency
12. Repeat the steps 2 to 11 for square wave.

PROGRAM:
// FIR Lowpass Filter program in C language using CC Studio
#include<stdio.h>
#include<math.h>
main()
{
int k,N,n,x,y;
static float h[10],hd[10],w[10];
printf("enter the no of samples N");
scanf("%d",&N);
y=(N-1)/2;
x=-y;
for(n=x;n<=y;n++)
{
if(n!=0)
{
hd[n]=(sin(n*1.57)/3.14*n);
}
else
hd[n]=0.5;
}
printf("select the window: 1.rectangular 2.triangular 3.hanning 4.hamming 5.blackmann");
scanf("%d",&k);
switch(k)
{
case 1:
for(n=x;n<=y;n++)
w[n]=1;
break;
case 2:
for(n=x;n<=y;n++)
w[n]=1-((abs(n)*2)/(N-1));
break;
case 3:
for(n=x;n<=y;n++)
w[n]=0.5+(0.5*cos((6.28*n)/(N-1)));
break;
case 4:
for(n=x;n<=y;n++)
w[n]=0.54+(0.46*cos((6.28*n)/(N-1)));
break;
case 5:
for(n=x;n<=y;n++)
w[n]=0.42+(0.5*cos((6.28*n)/(N-1)))+(0.08*cos((12.56*n)/(N-1)));
break;
default:
printf("wrong choice is entered");

}
for(n=x;n<=y;n++)
{
h[n]=hd[n]*w[n];
printf("output is %f\t",h[n]);
}
}
Result:
enter the no of samples N 5
select the window: 1.rectangular 2.triangular 3.hanning 4.hamming 5.blackmann 1
output is 0.001014 output is 0.318471 output is 0.500000 output is 0.318471 output is 0.001014
FIR Low Pass Filter Rectangular Window Graph:

Result:
enter the no of samples N 5
select the window: 1.rectangular 2.triangular 3.hanning 4.hamming 5.blackmann 2
output is 0.000000 output is 0.318471 output is 0.500000 output is 0.318471 output is 0.000000
FIR Low Pass Filter Triangular Window Graph:

Result:
enter the no of samples N 5
select the window: 1.rectangular 2.triangular 3.hanning 4.hamming 5.blackmann 3
output is 0.000000 output is 0.159362 output is 0.500000 output is 0.159362 output is 0.000000

FIR Low Pass Filter Hanning Window Graph:

Result:
enter the no of samples N 5
select the window: 1.rectangular 2.triangular 3.hanning 4.hamming 5.blackmann 4
output is 0.000081 output is 0.172091 output is 0.500000 output is 0.172091 output is 0.000081

FIR Low Pass Filter Hamming Window Graph:

Result:
enter the no of samples N 5
select the window: 1.rectangular 2.triangular 3.hanning 4.hamming 5.blackmann 5
output is 0.000000 output is 0.108407 output is 0.500000 output is 0.108407 output is 0.000000

FIR Low Pass Filter Blackmann Window Graph:

Program:
// FIR High pass Filter program in C language using CC Studio
#include<stdio.h>
#include<math.h>
static float h[20],hd[20],w[20];
main()
{
int k,n,N,x,y;
printf("Enter the number of samples");
scanf("%d",&N);
y=(N-1)/2;
x=-y;
for(n=x;n<=y;n++)
{
if(n!=0)
{
hd[n]=((sin(n*3.14))-(sin(n*1.57)))/(n*3.14);
}
else

hd[n]=0.5;
}
printf("Select the window");
printf("1.Rectangular Window 2.Triangular window 3.Hanning window 4.Hamming window
5.Blackmann window");
scanf("%d",&k);
switch(k)
{
case 1:
for(n=x;n<=y;n++)
w[n]=1;
break;
case 2:
for(n=x;n<=y;n++)
w[n]=1-((abs(n)*2)/(N-1));
break;
case 3:
for(n=x;n<=y;n++)
w[n]=0.5+(0.5*cos((6.28*n)/(N-1)));
break;
case 4:
for(n=x;n<=y;n++)
w[n]=0.54+(0.46*cos((6.28*n)/(N-1)));
break;
case 5:
for(n=x;n<=y;n++)
w[n]=0.42+(0.5*cos((6.28*n)/(N-1))+(0.08*cos((12.5*n)/(N-1))));
break;
default:
printf("\n Wrong choice is entered,Please Enter the correct choice\n");
break;
}
for(n=x;n<=y;n++)
{
h[n]=hd[n]*w[n];
printf("\n The Output is: %f \t",h[n]);
}
}
Result:
Enter the number of samples 5
Select the window 1.Rectangular Window 2.Triangular window 3.Hanning window 4.Hamming
window 5.Blackmann window 1
The Output is: -0.000761
The Output is: -0.317964
The Output is: 0.500000
The Output is: -0.317964
The Output is: -0.000761

FIR High Pass Filter Rectangular Window Graph:

Result:
Enter the number of samples 5
Select the window 1.Rectangular Window 2.Triangular window 3.Hanning window 4.Hamming
window 5.Blackmann window 2
The Output is: 0.000000
The Output is: -0.317964
The Output is: 0.500000
The Output is: -0.317964
The Output is: 0.000000

FIR High Pass Filter Triangular Window Graph:

Result:
Enter the number of samples 5
Select the window 1.Rectangular Window 2.Triangular window 3.Hanning window 4.Hamming
window 5.Blackmann window 3
The Output is: -0.000000
The Output is: -0.159109
The Output is: 0.500000
The Output is: -0.159109
The Output is: -0.000000

FIR High Pass Filter Hanning Window Graph:

Result:
Enter the number of samples 5
Select the window 1.Rectangular Window 2.Triangular window 3.Hanning window 4.Hamming
window 5.Blackmann window 4
The Output is: -0.000061
The Output is: -0.171817
The Output is: 0.500000
The Output is: -0.171817
The Output is: -0.000061

FIR High Pass Filter Hamming Window Graph:

Result:
Enter the number of samples 5
Select the window 1.Rectangular Window 2.Triangular window 3.Hanning window 4.Hamming
window 5.Blackmann window 5
The Output is: 0.000000
The Output is: -0.108238
The Output is: 0.500000
The Output is: -0.108238
The Output is: 0.000000

FIR High Pass Filter Blackmann Window Graph:

PROGRAM:
// FIR LP/HP Filter program in C language using CC Studio
#include<stdio.h>
#include<math.h>
#define pi 3.1415
int n,N,c;
float wr[64],wt[64];
void main()
{
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;
}
}
Result:
enter no. of samples, N=:64
enter choice of window function
1.rect
2.triang
c=:1
elements of window function are:
wr[0]=1.000000 wr[1]=1.000000 wr[2]=1.000000 wr[3]=1.000000
wr[4]=1.000000 wr[5]=1.000000 wr[6]=1.000000 wr[7]=1.000000
wr[8]=1.000000 wr[9]=1.000000 wr[10]=1.000000 wr[11]=1.000000
wr[12]=1.000000 wr[13]=1.000000 wr[14]=1.000000 wr[15]=1.000000
wr[16]=1.000000 wr[17]=1.000000 wr[18]=1.000000 wr[19]=1.000000
wr[20]=1.000000 wr[21]=1.000000 wr[22]=1.000000 wr[23]=1.000000
wr[24]=1.000000 wr[25]=1.000000 wr[26]=1.000000 wr[27]=1.000000
wr[28]=1.000000 wr[29]=1.000000 wr[30]=1.000000 wr[31]=1.000000
wr[32]=1.000000 wr[33]=1.000000 wr[34]=1.000000 wr[35]=1.000000
wr[36]=1.000000 wr[37]=1.000000 wr[38]=1.000000 wr[39]=1.000000
wr[40]=1.000000 wr[41]=1.000000 wr[42]=1.000000 wr[43]=1.000000
wr[44]=1.000000 wr[45]=1.000000 wr[46]=1.000000 wr[47]=1.000000
wr[48]=1.000000 wr[49]=1.000000 wr[50]=1.000000 wr[51]=1.000000
wr[52]=1.000000 wr[53]=1.000000 wr[54]=1.000000 wr[55]=1.000000
wr[56]=1.000000 wr[57]=1.000000 wr[58]=1.000000 wr[59]=1.000000
wr[60]=1.000000 wr[61]=1.000000 wr[62]=1.000000 wr[63]=1.000000

FIR Low Pass / High Pass Filter Rectangular Window Graph:

Result:
enter no. of samples, N= :64
enter choice of window function
1.rect
2.triang
c=:2
elements of window function are:
wt[0]=1.000000 wt[1]=0.968254 wt[2]=0.936508 wt[3]=0.904762
wt[4]=0.873016 wt[5]=0.841270 wt[6]=0.809524 wt[7]=0.777778
wt[8]=0.746032 wt[9]=0.714286 wt[10]=0.682540 wt[11]=0.650794
wt[12]=0.619048 wt[13]=0.587302 wt[14]=0.555556 wt[15]=0.523810
wt[16]=0.492063 wt[17]=0.460317 wt[18]=0.428571 wt[19]=0.396825
wt[20]=0.365079 wt[21]=0.333333 wt[22]=0.301587 wt[23]=0.269841
wt[24]=0.238095 wt[25]=0.206349 wt[26]=0.174603 wt[27]=0.142857
wt[28]=0.111111 wt[29]=0.079365 wt[30]=0.047619 wt[31]=0.015873
wt[32]=-0.015873 wt[33]=-0.047619 wt[34]=-0.079365 wt[35]=-0.111111
wt[36]=-0.142857 wt[37]=-0.174603 wt[38]=-0.206349 wt[39]=-0.238095
wt[40]=-0.269841 wt[41]=-0.301587 wt[42]=-0.333333 wt[43]=-0.365079
wt[44]=-0.396825 wt[45]=-0.428571 wt[46]=-0.460317 wt[47]=-0.492064
wt[48]=-0.523810 wt[49]=-0.555556 wt[50]=-0.587302 wt[51]=-0.619048
wt[52]=-0.650794 wt[53]=-0.682540 wt[54]=-0.714286 wt[55]=-0.746032
wt[56]=-0.777778 wt[57]=-0.809524 wt[58]=-0.841270 wt[59]=-0.873016
wt[60]=-0.904762 wt[61]=-0.936508 wt[62]=-0.968254 wt[63]=-1.000000

FIR Low Pass / High Pass Filter Triangular Window Graph:

Result: Hence the operation of FIR filters is Obtained.

EXPERIMENT : 3
Aim:- To verify IIR filters using C6713 simulator.
Equipments: Operating S ystem - Windows XP
Software - CC STUDIO 3
DSK 6713 DSP Trainer kit.
USB Cable
Power supply
Procedure :1. Open Code Composer Setup and select C6713 simulator, click save and quit
2. Start a new project using Project New pull down menu, save it in a separate
directory(C:\My projects) with file name sine wave.pjt3. Create a new source file using F ile
New Source file menu and save it in the project folder(sinewave.c)
4. Add the source file (sinewave.c) to the project
Project Add files to Project Select sinewave.c
5. Add the linker command file hello.cmd
Project Add files to Project
(path: C :\CCstudio \tutorial\dsk6713\hello \hello.cmd)
6. Add the run time support library file rts6700.lib
Project Add files to Project
(path: C\CCStudio\cgtools\lib\rts6700.lib)
7. Compile the program using project Compile menu or by Ctrl+F7
8. Build the program using projec t Build menu or by F7
9. Load the sinewave.out file (from project folder lcconv\Debug) using
File Load Program
10. Run the program using Debug Run or F5
11. To view the output graphically
Select View Graph Time and Frequency
12. Repeat the steps 2 to 11 for square wave.

PROGRAM:
// IIR Filter C Program
#include<stdio.h>
#include<math.h>
int i,w,wc,c,N;
float H[100];
float mul(float,int);
void main()
{
printf("\n Enter order of filter");
scanf("%d",&N);
printf("\n Enter the cut off frequency");
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]);
}
break;
}
}
float mul(float a,int x)
{
for(i=0;i<x-1;i++)
a*=a;
return(a);
}
Result:
Enter order of filter 2
Enter the cut off frequency 50
Enter the choice for IIR Filter 1.LPF 2.HPF 2
H[0]=0.000000
H[1]=0.000000
H[2]=0.000003
H[3]=0.000013

H[4]=0.000041
H[5]=0.000100
.
.
.
H[95]=0.997069
H[96]=0.997304
H[97]=0.997517
H[98]=0.997712
H[99]=0.997890
H[100]=0.998053
IIR High Pass Filter Graph:

Enter order of filter 2


Enter the cut off frequency 50
Enter the choice for IIR Filter 1.LPF 2.HPF 1
H[0]=1.000000
H[1]=1.000000
H[2]=1.000000
H[3]=1.000000
H[4]=1.000000
H[5]=1.000000
.
.

H[95]=0.076509
H[96]=0.073388
H[97]=0.070423
H[98]=0.067605
H[99]=0.064926
IIR Low Pass Filter Graph:

Result: Hence the operation of IIR filters is Obtained.

EXPERIMENT : 4
Aim:- To Perform Audio applications such as to plot a time and frequency display of microphone
plus a cosine using DSP. Read a wav file and match with their respective spectrograms. using C6713
simulator.
Equipments: Operating S ystem - Windows XP
Software - CC STUDIO 3
DSK 6713 DSP Trainer kit.
USB Cable
Power supply
Procedure :1. Open Code Composer Setup and select C6713 simulator, click save and quit
2. Start a new project using Project New pull down menu, save it in a separate
directory(C:\My projects) with file name sine wave.pjt3. Create a new source file using F ile
New Source file menu and save it in the project folder(sinewave.c)
4. Add the source file (sinewave.c) to the project
Project Add files to Project Select sinewave.c
5. Add the linker command file hello.cmd
Project Add files to Project
(path: C :\CCstudio \tutorial\dsk6713\hello \hello.cmd)
6. Add the run time support library file rts6700.lib
Project Add files to Project
(path: C\CCStudio\cgtools\lib\rts6700.lib)
7. Compile the program using project Compile menu or by Ctrl+F7
8. Build the program using projec t Build menu or by F7
9. Load the sinewave.out file (from project folder lcconv\Debug) using
File Load Program
10. Run the program using Debug Run or F5

11. To view the output graphically


Select View Graph Time and Frequency
12. Repeat the steps 2 to 11 for square wave.
Theory:
Spectrogram with RTDX using MATLAB This version of project makes use of RTDX with
MATLAB for transferring data from the DSK to the PC host. This section introduces configuration
file(.CDB) file and RTDX with MATLAB. This project uses source program spectrogram_rtdx_mtl.c
that runs on the DSK which computes 256 point FFT and enables an RTDX output channel to
write/send the resulting FFT data to the PC running MATLAB for finding the spectrogram. A total of
N/2 (128 points )are sent. The (.CDB) configuration file is used to set interrupt INT11. From this
configuration file select Input/Output RTDX. Right click on properties and change the RTDX
buffer size to 8200. Within CCS, select tools RTDX Configure to set the host buffer size to
2048(from 1024). An input signal is read in blocks of 256 samples. Each block of data is then
multiplied with a hamming window of length 256 points. The FFT of the windowed data is
calculated and squared. Half of the resulting FFT of each block of 256 points is then transferred to
the PC running MATLAB to find the specrtrogram.
Spectrogram_rtdx_mtl.c Time-Frequency analysis of signals Using RTDX-MATLAB
#include "dsk6713_aic23.h" //codec-DSK support file
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set sampling rate
#include <rtdx.h> //RTDX support file
#include <math.h> #include "hamming.cof" //Hamming window coefficients
#define PTS 256 //# 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],iobuffer1[PTS],a[PTS]; //input and output buffer
float x1[PTS]; //intermediate buffer
short i; //general purpose index variable
int j, k,l, curr_block = 0; //index variables
short buffercount = 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


RTDX_CreateOutputChannel(ochan); //create output channel C6x->PC
main()
{
for (i = 0 ; i<PTS ; i++) //set up twiddle constants in w
{
w[i].real = cos(2*PI*i/512.0); //Re component of twiddle constants
w[i].imag =-sin(2*PI*i/512.0); //Im component of twiddle constants
}
comm_intr(); //init DSK, codec, McBSP
while(!RTDX_isOutputEnabled(&ochan)) //wait for PC to enable RTDX
puts("\n\n Waiting . . . "); //while waiting
for(l=0;l<256;l++)
a[l]=cos(2*3.14*1500*l/8000);
for(k=0;k<5000;k++) //infinite loop
{
while (flag == 0) ; //wait until iobuffer is full
flag = 0; //reset flag
for (i = 0 ; i < PTS ; i++) //swap buffers
{
iobuffer1[i]=iobuffer[i]+a[i];
samples[i].real=h[i]*iobuffer1[i]; //multiply by Hamming window coeffs
iobuffer1[i] = x1[i]; //process frame to iobuffer
}
for (i = 0 ; i < PTS ; i++)
samples[i].imag = 0.0; //imag components = 0
FFT(samples,PTS); //call C-coded FFT function
for (i = 0 ; i < PTS ; i++) //compute square of FFT magnitude
{
x1[i] = (samples[i].real*samples[i].real + samples[i].imag*samples[i].imag)/16; //FFT data scaling
}
RTDX_write(&ochan, x1, sizeof(x1)/2); //send 128 samples to PC
} //end of infinite loop
} //end of main
interrupt void c_int11() //ISR
{
output_sample((short)(iobuffer[buffercount])); //out from iobuffer iobuffer[buffercount++]=(short)
(input_sample()); //input to iobuffer
if (buffercount >= PTS) //if iobuffer full
{
buffercount = 0; /reinit buffercount flag = 1; //reset flag
}
}

FFT.c C callable FFT function in C


#define PTS 256 //
# of points for FFT
typedef struct {float real,imag;}
COMPLEX;
extern COMPLEX w[PTS]; //twiddle constants stored in w
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 = 512/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.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)

{
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;
}
Spectrogram_RTDX.m For spectrogram plot using RTDX with MATLAB
clc;
ccsboardinfo %board info
cc=ccsdsp('boardnum',0); %set up CCS object
reset(cc); %reset board
visible(cc,1); %for CCS window enable(cc.rtdx); %
enable RTDX
if ~isenabled(cc.rtdx);
error('RTDX is not enabled')
end
cc.rtdx.set('timeout',50); %set 50sec timeout for RTDX open(cc,'spectrogram1.pjt'); %
open CCS project
load(cc,'./debug/spectrogram1.out'); %load executable file
run(cc); %run program
configure(cc.rtdx,2048,1); %configure one RTDX channel
open(cc.rtdx,'ochan','r');%open output channel
pause(3) %wait for RTDX channel to open
enable(cc.rtdx,'ochan'); %enable channel from DSK
isenabled(cc.rtdx,'ochan');
M = 256; %window size
N = round(M/2);
B = 128; %No. of blocks (128)
fs = 8000; %sampling rate
t=(1:B)*(M/fs); %spectrogram axes generation

f=((0:(M-1)/2)/(M-1))*fs; set(gcf,'DoubleBuffer','on'); y = ones(N,B); column = 1;


set(gca,'NextPlot','add');
axes_handle = get(gcf,'CurrentAxes'); set(get(axes_handle,'XLabel'),'String','Time (s)');
set(get(axes_handle,'YLabel'),'String','Frequency (Hz)');
set(get(axes_handle,'Title'),'String','\fontname{times}\bf Real-Time Spectrogram');
set(gca,'XLim', [0 4.096]);
set(gca,'YLim', [0 4000]);
set(gca,'XLimMode','manual');
set(gca,'YLimMode','manual');
for
i = 1:32768
w=readmsg(cc.rtdx,'ochan','single'); %read FFT data from DSK
w=double(w(1:N));
y(:, column) = w';
imagesc(t,f,dB(y)); %plot spectrogram
column = mod(column, B) + 1;
end halt(cc); %halt processor
close(cc.rtdx,'ochan'); %close channel
clear cc %clear object

EXPERIMENT : 5
Aim:- To
1) Add noise above 3kHz and then remove (using adaptive filters)
2) Interference suppression using 400 Hz tone

Equipments: Operating S ystem - Windows XP


Software - CC STUDIO 3
DSK 6713 DSP Trainer kit.
USB Cable
Power supply
Procedure :1. Open Code Composer Setup and select C6713 simulator, click save and quit
2. Start a new project using Project New pull down menu, save it in a separate
directory(C:\My projects) with file name sine wave.pjt3. Create a new source file using F ile
New Source file menu and save it in the project folder(sinewave.c)
4. Add the source file (sinewave.c) to the project
Project Add files to Project Select sinewave.c
5. Add the linker command file hello.cmd
Project Add files to Project
(path: C :\CCstudio \tutorial\dsk6713\hello \hello.cmd)
6. Add the run time support library file rts6700.lib
Project Add files to Project
(path: C\CCStudio\cgtools\lib\rts6700.lib)
7. Compile the program using project Compile menu or by Ctrl+F7
8. Build the program using projec t Build menu or by F7
9. Load the sinewave.out file (from project folder lcconv\Debug) using
File Load Program

10. Run the program using Debug Run or F5


11. To view the output graphically
Select View Graph Time and Frequency
12. Repeat the steps 2 to 11 for square wave.
Program:#include "NCcfg.h"
#include "dsk6713.h"
#include "dsk6713_aic23.h"
#define beta 1E-13 //rate of convergence
#define N 30 //adaptive FIR filter length-vary this parameter & observe
float delay[N];
float w[N];
DSK6713_AIC23_Config config = { \
0x0017, /* 0 DSK6713_AIC23_LEFTINVOL Left line input channel volume */ \
0x0017, /* 1 DSK6713_AIC23_RIGHTINVOL Right line input channel volume */\
0x00d8, /* 2 DSK6713_AIC23_LEFTHPVOL Left channel headphone volume */ \
0x00d8, /* 3 DSK6713_AIC23_RIGHTHPVOL Right channel headphone volume */ \
0x0011, /* 4 DSK6713_AIC23_ANAPATH Analog audio path control */ \
0x0000, /* 5 DSK6713_AIC23_DIGPATH Digital audio path control */ \
0x0000, /* 6 DSK6713_AIC23_POWERDOWN Power down control */ \
0x0043, /* 7 DSK6713_AIC23_DIGIF Digital audio interface format */ \
0x0081, /* 8 DSK6713_AIC23_SAMPLERATE Sample rate control */ \
0x0001 /* 9 DSK6713_AIC23_DIGACT Digital interface activation */ \
};
/* main() - Main code routine, initializes BSL and generates tone*/
void main()
{

DSK6713_AIC23_CodecHandle hCodec;
int l_input, r_input,l_output, r_output,T; /* Initialize the board support library, must be called first */
DSK6713_init();
hCodec = DSK6713_AIC23_openCodec(0, &config); /* Start the codec */
DSK6713_AIC23_setFreq(hCodec, 1);

for (T = 0; T < 30; T++) //Initialize the adaptive FIR coeffs=0


{
w[T] = 0; //init buffer for weights
delay[T] = 0; //init buffer for delay samples
}
while(1)
{
/* Read a sample to the left channel */
while (!DSK6713_AIC23_read(hCodec,&l_input));
/* Read a sample to the right channel */
while (!DSK6713_AIC23_read(hCodec, &r_input));
l_output=(short int)adaptive_filter(l_input,r_input);
r_output=l_output;
while (!DSK6713_AIC23_write(hCodec, l_output));
/* Send o/p to the left channel */
while (!DSK6713_AIC23_write(hCodec, r_output));
/* Send o/p to the right channel*/
}
DSK6713_AIC23_closeCodec(hCodec); /* Close the codec */
}
signed int adaptive_filter(int l_input,int r_input) //ISR
{
short i,output; float yn=0, E=0, dplusn=0,desired,noise;
desired = l_input; noise = r_input;
dplusn = (short)(desired + noise); //desired+noise
delay[0] = noise; //noise as input to adapt FIR

for (i = 0; i < N; i++) //to calculate out of adapt FIR


yn += (w[i] * delay[i]); //output of adaptive filter
E = (desired + noise) - yn; //"error" signal=(d+n)-yn
for (i = N-1; i >= 0; i--) //to update weights and delays
{
w[i] = w[i] + beta*E*delay[i]; //update weights
delay[i] = delay[i-1]; //update delay samples
}
//output=((short)E);
//error signal as overall output
output=((short)dplusn); //output (desired+noise) /
/overall output result return(output);
}

EXPERIMENT : 6
Aim:- Implementation of FFT using C6713 simulator.
Equipments: Operating S ystem - Windows XP
Software - CC STUDIO 3
DSK 6713 DSP Trainer kit.
USB Cable
Power supply
Procedure :1. Open Code Composer Setup and select C6713 simulator, click save and quit
2. Start a new project using Project New pull down menu, save it in a separate
directory(C:\My projects) with file name sine wave.pjt3. Create a new source file using F ile
New Source file menu and save it in the project folder(sinewave.c)
4. Add the source file (sinewave.c) to the project
Project Add files to Project Select sinewave.c
5. Add the linker command file hello.cmd
Project Add files to Project
(path: C :\CCstudio \tutorial\dsk6713\hello \hello.cmd)
6. Add the run time support library file rts6700.lib
Project Add files to Project
(path: C\CCStudio\cgtools\lib\rts6700.lib)
7. Compile the program using project Compile menu or by Ctrl+F7
8. Build the program using projec t Build menu or by F7
9. Load the sinewave.out file (from project folder lcconv\Debug) using
File Load Program
10. Run the program using Debug Run or F5

11. To view the output graphically


Select View Graph Time and Frequency
12. Repeat the steps 2 to 11 for square wave.
PROGRAM: #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
{
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*/
} /****************InputSignalX(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;
}
/********************** 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
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))
{
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)
{
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;
}
OUTPUT:

DFT or FFT spectrum of sinusoidal signal f= 10 Hz

Das könnte Ihnen auch gefallen