DSP LAB Manual
DSP LAB Manual
Institute Vision
To become an institute of excellence by creating high quality and innovating engineering and
management professionals who would take the world into their stride through sustainable
growth in technology and management.
Institute Mission
To instill moral values and promote technological, intellectual and ethical environment to the
students with an in-depth and exceptional education that makes them employment ready as
per the emerging trends in industry and to invoke the desire of innovation as a process of life-
long learning for a successful career in engineering and management.
Department Vision
To develop a centre of excellence for imparting high quality education in Electronics and
Communication Engineering to produce technically competent, innovative and socially
responsible professionals to meet global challenges.
Department Mission
M1: To impart knowledge in a way that caters to the needs of the present and emerging
technological world.
M2: To turnout competent professionals trained in design and development of hardware and
software based products.
M3: To infuse sense of ethics and social responsibility among the students.
To prepare the students to fit into any industry associated with designing,
PEO1 developing and manufacture of hardware and software products based on
state of art technologies, make them capable of pursuing higher studies in
the field of electronics and communication engineering.
PEO2 To enrich the students with sound mathematical, scientific and engineering
fundamentals required to solve engineering problems and also to pursue
higher studies.
PO NO Program Outcomes
PO12 Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological
change.
0 0 3 1.5 30 70 100
COURSE OBJECTIVES
1. To provide background and fundamentals of MATLAB tool for the analysis and processing
of signals and to generate various continuous and discrete time signals.
2. To study the designs and structures of digital (IIR and FIR) filters from analysis to synthesis
for a given specifications.
3. To familiarize the relationships between continuous-time and discrete-time signals and
systems.
4. To verify the Circular Convolution, Noise removal and DTMF filtering.
5. To analyze the FFT algorithm, multi-rate signal processing techniques.
COURSE OUTCOMES
LIST OF EXPERIMENTS
List of Experiments:
1. Generation of Sinusoidal Waveform / Signal based on Recursive Difference Equations
2. Histogram of White Gaussian Noise and Uniformly Distributed Noise.
3. Impulse Response of First order and Second Order Systems.
4. To find Frequency Response of a given System given in Transfer Function/ Differential
equation form.
5. To find DFT / IDFT of given DT Signal
6. To find circular convolution of given two sequences.
7. Obtain Fourier series coefficients by formula and using FFT and compare for half sine
wave.
8. Implementation of FFT of given Sequence
9. Determination of Power Spectrum of a given Signal(s).
10. Implementation of LP & HP FIR Filter for a given Sequence/Signal.
11. Implementation of LP & HP IIR Filter for a given Sequence/Signal
12. Generation of Narrow Band Signal through Filtering
13. Generation of DTMF Signals
14. Implementation of Decimation Process
15. Implementation of Interpolation Process
16. Implementation of I/D Sampling Rate Converters
INRODUCTION
MATLAB: MATLAB is a software package for high performance numerical computation and
visualization provides an interactive environment with hundreds of built in functions for
technical computation, graphics and animation. The MATLAB name stands for MATrix
Laboratory. At its core ,MATLAB is essentially a set (a “toolbox”) of routines (called “m files”
or “mex files”) that sit on your computer and a window that allows you to create new variables
with names (e.g. voltage and time) and process those variables with any of those routines (e.g.
plot voltage against time, find the largest voltage, etc). It also allows you to put a list of your
processing requests together in a file and save that combined list with a name so that you can
run all of those commands in the same order at some later time. Furthermore, it allows you to
run such lists of commands such that you pass in data and/or get data back out (i.e. the list
of commands is like a function in most programming languages). Once you save a
function, it becomes part of your toolbox (i.e. it now looks to you as if it were part of the basic
toolbox that you started with). For those with computer programming backgrounds:
Note that MATLAB runs as an interpretive language (like the old BASIC). That is, it does
not need to be compiled. It simply reads through each line of the function, executes it, and
then goes on to the next line. (In practice, a form of compilation occurs when you first run a
function, so that it can run faster the next time you run it.)
MATLAB Windows :
MATLAB works with through three basic windows Command Window : This is the main
window .it is characterized by MATLAB command prompt >> when you launch the
application program MATLAB puts you in this window all commands including those for
user-written programs ,are typed in this window at the MATLAB prompt .
Graphics window: the output of all graphics commands typed in the command window are
flushed to the graphics or figure window, a separate gray window with white background color
the user can create as many windows as the system memory will allow
Edit window: This is where you write edit, create and save your own programs in
files called M files.
Input-output: MATLAB supports interactive computation taking the input from the screen
and flushing, the output to the screen. In addition it can read input files and write output files
Data Type: the fundamental data -type in MATLAB is the array. It encompasses several distinct
data objects- integers, real numbers, matrices, charcter strings, structures and cells.There is no
need to declare variables as real or complex, ATLAB automatically sets the variable to be real.
a.*b = [4 10 18]
8 if C= [2 2 2]
b.*C results in [8 10 12]
9. plot (t, x)
If x = [6 7 8 9] t = [1 2 3 4]
10. stem (t,x) :-This instruction will display a figure window.
11. Subplot: This function divides the figure window into rows and columns.
Subplot (2 2 1) divides the figure window into 2 rows and 2 columns 1 represent
number of the figure .
12. Conv
Syntax: w = conv(u,v)
Description: 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.
13.Disp
Syntax: disp(X)
Description: 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.
14.xlabel
Syntax: xlabel('string')
Description: xlabel('string') labels the x-axis of the current axes.
15. ylabel
Syntax : ylabel('string')
Description: ylabel('string') labels the y-axis of the current axes.
16.Title
Syntax : title('string')
Description: title('string') outputs the string at the top and in the center of the
current axes.
17.grid on
Syntax : grid on
Description: grid on adds major grid lines to the current axes.
18.FFT Discrete Fourier transform.
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.
19. ABS Absolute value.
ABS(X) is the absolute value of the elements of X. When X is
complex, ABS(X) is the complex modulus (magnitude) of the
elements of X.
20. ANGLE Phase angle.
ANGLE(H) returns the phase angles, in radians, of a matrix with complex
elements.
AIM: To generate a sinusoidal signal through Signal based on Recursive Difference Equations.
Flow Chart:
PROGRAM:
clc;
close all;
clear all;
b=[1];
a=[1,-1,0.9];
n=[-20:120];
t=0:0.1:2*pi;
x=sin(t);
s=filter(b,a,x);
stem(t,s);
title('sinusoidal response');
xlabel('n');
ylabel('s(n)');
Output Waveform:
RESULT: Hence a sinusoidal signal through Signal based on Recursive Difference Equations is
performed.
VIVA QUESTIONS:
1. Define signal?
2. Differentiate periodic and non-periodic signals?
3. Define period of the signal?
4. Define LTI system.
5. What is filtering?
6. Define sequence?
EXPERIMENT NO-2
Histogram of White Gaussian Noise and Uniformly Distributed
Noise.
AIM: Histogram of white Gaussian Noise and uniformly distributed noise using MATLAB.
THEORY: Since the random variables in the white noise process are statistically uncorrelated, the
covariance function contains values only along the diagonal. The matrix above indicates that only the
autocorrelation function exists for each random variable. The cross-correlation values are zero
(samples/variables are statistically uncorrelated with respect to each other). The diagonal elements are
equal to the variance and all other elements in the matrix are zero. Plot the histogram of the generated
white noise and verify the histogram by plotting against the theoretical pdf of the Gaussian random
variable.
Algorithm: Algorithm:
Procedure:
1. Open MATLAB
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and run the program
6. For the o/p see command window.
Program:
clc;
clear all;
close all;
L=100;
mu=0;
sigma=2;
F1=sigma*randn(L,1)+mu;
figure(1)
plot(F1);
hist(F1)
F2=sigma*rand(L,1)+mu;
figure(3);
plot(F1);
figure(4)
hist(F2);
Output:
RESULT: Hence the Histogram of white Gaussian Noise and uniformly distributed noise
using MATLAB performed.
VIVA QUESTIONS:
1. Define Strictly and weakly defined white noise.
2. What‟s with Covariance Function/Matrix ?
3. Explain Frequency Domain Characteristics
4. Define Wide Sense Stationary Process (WSS).
5. What is a random process?
6. Define Noise?
7. Give applications‟ of Random Processes.
8. Define random variable?
9. What is the other name for Random Processes.
10. Define auto correlation.
EXPERIMENT NO-3
IMPULSE RESPONSE OF FIRST ORDER AND SECOND ORDER
SYSTEMS
AIM: - To Generation of Impulse Response of First Order and Second Order Systems.
APPARATUS REQUIRED:-
1. MATLAB Software.
2. Computer Systems.
THEORY:
The response of an LTI system when an unit impulse sequence is applied at the input of
the system. It is denoted by h(n).
PROGRAM:
clc;
close all;
clear all;
n=0:10;
%impulse response of first order system
b=[2 0 0];
a=[1 -0.9 0];
y=dimpulse(b,a,length(n));
subplot(2,1,1);
stem(n,y);
xlabel('n--->');
ylabel('amplitude');
title('impulse response of first order system');
%impulse response of second order system
b=[1 0 0];
a=[1 0.6 0.8];
y1=dimpulse(b,a,length(n));
subplot(2,1,2);
stem(n,y1);
xlabel('n - >');
ylabel('amplitude');
title('impulse response of second order system');
OUTPUT:-
VIVA QUESTIONS:
1. Define impulse response?
2. Give example for first order difference equation?
3. Give example for second order difference equation?
4. Define LTI system?
5. Define convolution?
6. What are Fourier series and Fourier transform?
7. What is meant by linearity of a system and how it is related to scaling and superposition?
8. How to perform linear convolution using circular convolution?
9. What is the necessity of sectioned convolution in signal processing?
10.What is meant by causality?
EXPERIMENT NO-4
To find Frequency Response of a given System given in Transfer
Function/ Differential equation form.
THEORY: Systems respond differently to inputs of different frequencies. Some systems may
amplify components of certain frequencies, and attenuate components of other frequencies. The
way that the system output is related to the system input for different frequencies is called the
frequency response of the system. Since the frequency response is a complex function, we can
convert it to polar notation in the complex plane. This will give us a magnitude and an angle. We
call the angle the phase.
Amplitude Response: For each frequency, the magnitude represents the system's tendency to
amplify or attenuate the input signal.
Phase Response: The phase represents the system's tendency to modify the phase of the input
sinusoids.
The phase response, or its derivative the group delay, tells us how the system delays the input
signal as a function of frequency.
Procedure:-
1) Open MATLAB
2) Open new M-file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
Algorithm:
Step I : Give numerator coefficients of the given transfer function or difference equation..
Step II : Give denominator coefficients of the given transfer function or difference equation
Step III : Pass these coefficients to matlab command freqz to find frequency response.
Step IV : Find magnitude and phase response using matlab commands abs and angle.
Step V : Plot magnitude and phase response.
Flow Chart:
PROGRAM:
%MATLAB program to plot the frequency response (magnitude and phase response)of agiven
difference equation.
clc;
clear all;
b=input('Enter the numerator coefficients:');
a=input('Enter the denominator coefficients:');
[h,w]=freqz(b,a);
subplot(2,1,1);
plot(w/pi,abs(h));
grid;
xlabel('Normalised Frequency');
ylabel('Magnitude in dB');
title('Magnitude Response');
subplot(2,1,2);
plot(w/pi,angle(h));
grid;
xlabel('Normalised Frequency');
ylabel('phase in radians');
title('Phase Response');
Output:
Enter the numerator coefficients: [1]
Enter the denominator coefficients: [1 -1/6 -1/6]
Output Waveforms:
RESULT: Hence frequency response of a given system determined using differential equation
form.
VIVA QUESTIONS:
1. Define Frequency response?
2. Define magnitude response?
3. Define Phase response?
4. Define transfer function.
5. State the significance of difference equations.
6. What are the classifications of system based on unit sample response?
7. What is zero input response?
8. Define impulse response?
9. Define System.
10. Write mathematical formula to find response of any given system.
EXPERIMENT NO-5
To find DFT / IDFT of given DT Signal
AIM: To find Discrete Fourier Transform and Inverse Discrete Fourier Transform of given
digital signal.
APPARATUS REQUIRED: System with MATLAB
THEORY:
Procedure:-
1) Open MATLAB
2) Open new M-file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
Algorithm:
Step I: Get the input sequence.
Step II: Find the DFT of the input sequence using direct equation of DFT.
Step III: Find the IDFT using the direct equation.
Step IV: Plot DFT and IDFT of the given sequence using matlab command stem.
Step V: Display the above outputs.
Flow chart:
PROGRAM:
clc;
close all;
clear all;
xn=input('Enter the sequence x(n)');
%Get the sequence from user ln=length(xn);
%find the length of the sequence
xk=zeros(1,ln);
%initialize an array of same size as that of input sequence
ixk=zeros(1,ln);
%initialize an array of same size as that of input sequence
%DFT of the sequence
%-----------------------------------------------------
for k=0:ln-1
for n=0:ln-1
xk(k+1)=xk(k+1)+(xn(n+1)*exp((i)*2*pi*k*n/ln));
end
end
%------------------------------------------------------
%Plotting input sequence %-----------------------------------------------------
t=0:ln-1;
subplot(221);
stem(t,xn);
ylabel ('Amplitude');
xlabel ('Time Index');
title('Input Sequence');
%---------------------------------------------------------------
magnitude=abs(xk);
% Find the magnitudes of individual DFT points
% plot the magnitude response
%------------------------------------------------------------
t=0:ln-1;
subplot(222);
stem(t,magnitude);
ylabel ('Amplitude');
xlabel ('K');
title('Magnitude Response');
%------------------------------------------------------------
phase=angle(xk);
% Find the phases of individual DFT points
% plot the magnitude sequence
%------------------------------------------------------------
t=0:ln-1;
subplot(223);
stem(t,phase);
ylabel ('Phase');
xlabel ('K');
title ('Phase Response');
%------------------------------------------------------------
%IDFT of the sequence %------------------------------------------------------------
for n=0:ln-1
for k=0:ln-1
ixk(n+1)=ixk(n+1)+(xk(k+1)*exp(i*2*pi*k*n/ln));
end
end
ixk=ixk./ln;
%------------------------------------------------------------
%code block to plot the input sequence
%------------------------------------------------------------
t=0:ln-1;
subplot(224);
stem(t,ixk);
ylabel ('Amplitude');
xlabel ('Time Index');
title ('IDFT sequence');
%------------------------------------------------------
Output:
Xn=[1 2 3 4 5]
Xk = 15,-2.50+3.44i,-2.50+0.81i,-2.49-0.81i,-2.49-3.44i
Output Waveforms:
RESULT: Thus Discrete Fourier Transform is performed using Matlab.
VIVA QUESTIONS:
1. Define signal, Give Examples for 1-D, 2-D, 3-D signals.
2. Define transform. What is the need for transform?
3. Differentiate Fourier transform and discrete Fourier transform.
4. Differentiate DFT and DTFT
5. Explain mathematical formula for calculation of DFT.
6. Explain mathematical formula for calculation of IDFT.
7. How to calculate FT for 1-D signal?
8. What is meant by magnitude plot, phase plot, power spectrum?
9. Explain the applications of DFT.
10. What are separable transforms?
EXPERIMENT NO-6
To find circular convolution of given two sequences
THEORY: Circular convolution also known as cyclic convolution to two functions which
are aperiodic in nature occurs when one of them is convolved in the normal way with a
periodic summation of other function.
Algorithm:
Step 1: Start.
Procedure:-
1) Open MATLAB
2) Open new M-file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
Program:
clc;
close all;
clear all;
x1=input('Enter the first sequence :
');
x2=input('Enter the second sequence
: ');
N1=length(x1);
N2=length(x2);
N=max(N1,N2);
if(N2>N1)
x4=[x1,zeros(1,N-N1)];
x5=x2;
elseif(N2==N1)
x4=x1;
x5=x2;
else
x4=x1;
x5=[x2,zeros(1,N-N2)];
end
x3=zeros(1,N);
for m=0:N-1
x3(m+1)=0;
for n=0:N-1
j=mod(m-n,N);
x3(m+1)=x3(m+1)+x4(n+1).*x5(j+1);
end
end
subplot(4,1,1)
stem(x1);
title('First Input Sequence');
xlabel('Samples');
ylabel('Amplitude');
subplot(4,1,2)
stem(x2);
title('Second Input Sequence');
xlabel('Samples');
ylabel('Amplitude');
subplot(4,1,3)
stem(x3);
title('Circular Convolution Using
Modulo Operator');
xlabel('Samples');
ylabel('Amplitude');
OUTPUT:
RESULT: Hence the circular convolution of given two sequences is verified using MATLAB.
VIVA QUESTIONS:
1. What is the use of circular convolution?
2. Why do we use circular convolution in DFT?
3. What is the length of circular convolution?
4. What is the difference between convolution and circular convolution?
5. What are the types of circular convolution?
6. What is the symbol for circular convolution?
7. Write the properties of discrete convolution.
8. What is circular convolution DFT method?
9. What is circular convolution Matrices method?
10. What is circular convolution Matrices method?
EXPERIMENT NO-7
Obtain Fourier series coefficients by formula and using FFT and
compare for half sine wave.
AIM: To Obtain Fourier series coefficients by formula and using FFT and compare for half sine
wave.
THEORY: The Fourier series representation of a periodic discrete-time sequence is called discrete Fourier
series (DFS). Consider a discrete-time signal x(n), that is periodic with period N defined by x(n) = x(n +
kN) for any integer value of k. The periodic function x(n) can be synthesized as the sum of sine and cosine
sequences (Trigonometric form of Fourier series) or equivalently as a linear combination of complex
exponentials (Exponential form of Fourier series) whose frequencies are multiples of the fundamental
frequency ὡ0 = 2π/N. This is done by constructing a periodic sequence for which each period is identical
to the finite length sequence.
Procedure:-
1) Open MATLAB
2) Open new M-file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
Algorithm :
Step I : define time vector for signal
Step II : find m value
Step III : find the periodicity of the signal
Sterp IV : find the fourier coefficients of the given signal
Step V : plot the Graph input and fourier coeffdicients.
Program:
RESULT: Hence the Fourier series coefficients by formula and using FFT and compare for half
sine wave verified using MATLAB.
VIVA QUESTIONS:
1. What is Fourier series used for?
2. What are the types of Fourier series?
3. What are the properties of Fourier series?
4. Which Fourier series is the most widely used?
5. What is Fourier series formula?
6. Who is the father of Fourier series?
7. Explain periodic function with examples.
8. State Dirichlet‟s conditions for a function to be expanded as a Fourier series.
9. To what value does the sum of Fourier series of f (x) converge at the point of continuity
10. State the Parseval‟s Identity (or) theorem
EXPERIMENT NO-8
Implementation of FFT of given Sequence
THEORY:
DFT of a sequence
Procedure:-
1) Open MATLAB
2) Open new M-file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
Algorithm:
Flow Chart:
PROGRAM:
clc;
clear all;
close all;
x=input('Enter the sequence : ')
N=length(x)
xK=fft(x,N)
xn=ifft(xK)
n=0:N-1;
subplot (2,2,1);
stem(n,x);
xlabel('n---->');
ylabel('amplitude');
title('input sequence');
subplot (2,2,2);
stem(n,abs(xK));
xlabel('n---->');
ylabel('magnitude');
title('magnitude response');
subplot (2,2,3);
stem(n,angle(xK));
xlabel('n---->');
ylabel('phase');
title('Phase responce');
subplot (2,2,4);
stem(n,xn);
xlabel('n---->');
ylabel('amplitude');
title('IFFT');
Output:
Output Waveform:
RESULT:
VIVA QUESTIONS:
1. Define transform. What is the need for transform?
2. Differentiate Fourier transform and discrete Fourier transform.
3. Differentiate DFT and DTFT.
4. What are the advantages of FFT over DFT?
5. Differentiate DITFFT and DIFFFT algorithms.
6. What is meant by radix?
7. What is meant by twiddle factor and give its properties?
8. How FFT is useful to represent a signal?
9. Compare FFT and DFT with respect to number of calculation required?
10. How the original signal is reconstructed from the FFT of a signal?
EXPERIMENT NO-9
Determination of Power Spectrum of a given Signal(s).
THEORY: The power spectrum describes the distribution of signal power over a frequency
spectrum. The most common way of generating a power spectrum is by using a discrete Fourier
transform, but other techniques such as the maximum entropy method can also be used. The
power spectrum can also be defined as the Fourier transform of auto correlation function.
Procedure:-
1) Open MATLAB
2) Open new M-file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
Algorithm:
Flow Chart:
PROGRAM:
Clc;
clear all;
close all;
N=1024;
fs=8000;
f=input('enter the frequency[1 to 5000]:');
n=0:N-1;
x=sin(2*pi*(f/fs)*n)
pxx=spectrum(x,N);
specplot(pxx,fs);
grid on
xlabel('freq(hz)');
ylabel('magnitude(db)');
title('power spectrum of x(n)');
Output Waveform:
RESULT:
VIVA QUESTIONS:
THEORY:
FIR filters are digital filters with finite impulse response. They are also known as non-recursive
digital filters as they do not have the feedback. An FIR filter has two important advantages over
an IIR design: Firstly, there is no feedback loop in the structure of an FIR filter. Due to not
having a feedback loop, an FIR filter is inherently stable. Meanwhile, for an IIR filter, we need to
check the stability. Secondly, an FIR filter can provide a linear-phase response. As a matter of
fact, a linear-phase response is the main advantage of an FIR filter over an IIR design otherwise,
for the same filtering specifications; an IIR filter will lead to a lower order.
An FIR filter is designed by finding the coefficients and filter order that meet certain
specifications, which can be in the time-domain (e.g. a matched filter) and/or the frequency
domain (most common). Matched filters perform a cross-correlation between the input signal and
a known pulse-shape. The FIR convolution is a cross-correlation between the input signal and a
time-reversed copy of the impulse-response. Therefore, the matched-filter's impulse response is
"designed" by sampling the known pulse-shape and using those samples in reverse order as the
coefficients of the filter. When a particular frequency response is desired, several different design
methods are common:
In the window design method, one first designs an ideal IIR filter and then truncates the infinite
impulse response by multiplying it with a finite length window function. The result is a finite
impulse response filter whose frequency response is modified from that of the IIR filter.
Procedure:-
1) Open MATLAB
2) Open new M-file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
Algorithm:
Step I : Enter the pass band frequency (fp) and stop band frequency (fq).
Step II : Get the sampling frequency (fs), length of window (n).
Step III : Calculate the cut off frequency, fn
Step IV : Use boxcar, hamming, blackman Commands to design window.
Step V : Design filter by using above parameters.
Step VI : Find frequency response of the filter using matlab command freqz.
Step VII : Plot the magnitude response and phase response of the filter.
Flow Chart:
PROGRAM:
clc;
clear all;
close all;
n=20;
fp=200;
fq=300;
fs=1000;
fn=2*fp/fs;
window=blackman(n+1);
b=fir1(n,fn,window);
[H W]=freqz(b,1,128);
subplot(2,1,1);
plot(W/pi,abs(H));
title('magnitude response of lpf');
ylabel('gain in db-------->');
xlabel('normalized frequency------>');
subplot(2,1,2);
plot(W/pi,angle(H));
title('phase response of lpf');
ylabel('angle-------->');
xlabel('normalized frequency------>');
Output Wave forms:
Algorithm:
Step I : Enter the pass band frequency (fp) and stop band frequency (fq).
Step II : Get the sampling frequency (fs), length of window (n).
Step III : Calculate cut off frequency
Step IV : Use boxcar, hamming, Blackman Commands to design window.
Step V : Design filter by using above parameters.
Step VI : Find frequency response of the filter using matlab command freqz.
Step VII : Plot the magnitude response and phase response of the filter.
Flow Chart:
PROGRAM:
clc;
clear all;
close all;
n=20;
fp=300;
fq=200;
fs=1000;
fn=2*fp/fs; window=blackman(n+1);
b=fir1(n,fn,'high',window);
[H W]=freqz(b,1,128);
subplot(2,1,1);
plot(W/pi,abs(H));
title('mag res of lpf');
ylabel('gain in db-------->');
xlabel('normalized frequency------>');
subplot(2,1,2);
plot(W/pi,angle(H));
title('phase res of lpf');
ylabel('angle-------->');
xlabel('normalized frequency------>');
Output Waveforms:
RESULT: Thus FIR LP and HP Filter is designed for windowing techniques using MATLAB.
VIVA QUESTIONS:
1. Define filter.
2. What are the different types of filters?
3. Why are FIR filters generally preferred over IIR filters in multirate (decimating and
interpolating) systems/
4. Difference between IIR and FIR filters?
5. Differentiate ideal filter and practical filter responses.
6. What is the filter specifications required to design the analog filters?
7. What is meant by frequency response of filter?
8. What is meant by magnitude response?
9. What is meant by phase response?
10. Difference between FIR low pass filter and high pass filter.
EXPERIMENT NO-11
Implementation of LP & HP IIR Filter for a given
Sequence/Signal
THEORY: IIR filters are digital filters with infinite impulse response. Unlike FIR filters, they
have the feedback (a recursive part of a filter) and are known as recursive digital filters therefore.
For this reason IIR filters have much better frequency response than FIR filters of the same order.
Unlike FIR filters, their phase characteristic is not linear which can cause a problem to the
systems which need phase linearity. For this reason, it is not preferable to use IIR filters in digital
signal processing when the phase is of the essence. Otherwise, when the linear phase
characteristic is not important, the use of IIR filters is an excellent solution. There is one problem
known as a potential instability that is typical of IIR filters only. FIR filters do not have such a
problem as they do not have the feedback. For this reason, it is always necessary to check after
the design process whether the resulting IIR filter is stable or not. IIR FILTER DESIGN For
the given specifications to Design a digital IIR filter, first we need to design analog filter
(Butterworth or chebyshev). The resultant analog filter is transformed to digital filter by using
either “Bilinear transformation or Impulse Invariant transformation”.
Procedure:-
1) Open MATLAB
2) Open new M-file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
Algorithm:
Step I : Enter the pass band ripple (rp) and stop band ripple (rs).
Step II : Enter the pass band frequency (wp) and stop band frequency (ws).
Step III : Get the sampling frequency (fs).
Step IV : Calculate normalized pass band frequency, and normalized stop band frequency w1 and
w2 respectively. w1 = 2 * wp /fs w2 = 2 * ws /fs
Step V : Make use of the following function to calculate order of filter Butterworth filter order
[n,wn]=buttord(w1,w2,rp,rs ) Chebyshev filter order [n,wn]=cheb1ord(w1,w2,rp,rs)
Step VI : Design an nth order digital low pass Butterworth or Chebyshev filter using the
following statements. Butterworth filter [b, a]=butter (n, wn) Chebyshev filter [b,a]=cheby1 (n,
0.5, wn) Step VII : Find the digital frequency response of the filter by using „freqz( )‟ function
Step VIII : Calculate the magnitude of the frequency response in decibels (dB) mag=20*log10
(abs (H))
Step IX : Plot the magnitude response [magnitude in dB Vs normalized frequency]
Step X : Calculate the phase response using angle (H)
Step XI : Plot the phase response [phase in radians Vs normalized frequency (Hz)].
Flow Chart:
PROGRAM:
clc;
clear all;
close all;
disp('enter the IIR filter design specifications');
rp=input('enter the passband ripple:');
rs=input('enter the stopband ripple:');
wp=input('enter the passband freq:');
ws=input('enter the stopband freq:');
fs=input('enter the sampling freq:');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs,'s');
disp('Frequency response of IIR LPF is:');
[b,a]=butter(n,wn,'low','s');
w=0:.01:pi;
[h,om]=freqs(b,a,w);
m=20*log10(abs(h));
an=angle(h);
figure,
subplot(2,1,1);
plot(om/pi,m);
title('magnitude response of IIR filter is:');
xlabel('(a) Normalized freq. -->');
ylabel('Gain in dB-->');
subplot(2,1,2);
plot(om/pi,an);
title('phase response of IIR filter is:');
xlabel('(b) Normalized freq. -->');
ylabel('Phase in radians-->');
INPUT:
enter the IIR filter design specifications
enter the passband ripple:15
enter the stopband ripple:60
enter the passband freq:1500
enter the stopband freq:3000
enter the sampling freq:7000
Output waveforms:
Algorithm:
Step I : Enter the pass band ripple (rp) and stop band ripple (rs).
Step II : the pass band frequency (wp) and stop band frequency (ws).
Step III : Get the sampling frequency (fs).
Step IV : Calculate normalized pass band frequency, and normalized stop band frequency w1 and
w2 respectively. w1 = 2 * wp /fs w2 = 2 * ws /fs
Step V : Make use of the following function to calculate order of filter Butterworth filter order
[n,wn]=buttord(w1,w2,rp,rs ) Chebyshev filter order [n,wn]=cheb1ord(w1,w2,rp,rs)
Step VI : Design an nth order digital high pass Butterworth or Chebyshev filter using the
following statement. Butterworth filter [b,a]=butter (n, wn,‟high‟) Chebyshev filter [b,a]=cheby1
(n, 0.5, wn,'high')
Step VII : Find the digital frequency response of the filter by using „freqz( )‟ function
Step VIII : Calculate the magnitude of the frequency response in decibels (dB) mag=20*log10
(abs (H))
Step IX : Plot the magnitude response [magnitude in dB Vs normalized frequency]
Step X : Calculate the phase response using angle (H)
Step XI : Plot the phase response [phase in radians Vs normalized frequency (Hz)].
Flow chart:
PROGRAM:
clc;
clear all;
close all;
disp('enter the IIR filter design specifications');
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
wp=input('enter the passband freq');
ws=input('enter the stopband freq');
fs=input('enter the sampling freq');
w1=2*wp/fs;w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs,'s');
disp('Frequency response of IIR HPF is:');
[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,
subplot(2,1,1);
plot(om/pi,m);
title('magnitude response of IIR filter is:');
xlabel('(a) Normalized freq. -->');
ylabel('Gain in dB-->');
subplot(2,1,2);
plot(om/pi,an);
title('phase response of IIR filter is:');
xlabel('(b) Normalized freq. -->');
ylabel('Phase in radians-->');
INPUT:
Output Waveforms:
VIVA QUESTIONS:
APPARATUS REQUIRED:-
1. MATLAB Software.
2. Computer Systems.
THEORY:-
One application of an LTI discrete-time system is to pass certain frequency components
in an input sequence without any distortion and block other frequency components. Such
systems are called digital filters. The key to the filtering process is the inverse Discrete
Fourier transform, which expresses an arbitrary input sequence as a linear weighed sum
of an infinite number of exponential sequences, or equivalently, as a linear weighted sum
of sinusoidal sequences. As a result, by appropriately choosing the values of magnitude
function of the LTI digital filter at frequencies corresponding to the frequencies of the
sinusoidal components of the input, some of these sinusoidal sequences can be selectively
heavily attenuated or filtered with respect to the others.
PROCEDURE:-
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window/ Figure window
PROGRAM:-
close all;
clear all;
clc;
b=[1];
a=[1,-1,0.9];
n=[-20:120];
t=0:0.1:2*pi;
x=sin(t);
s=filter(b,a,x);
stem(t,s);
title('sinusoidal response');
xlabel('n');
ylabel('s(n)');
OUTPUT:-
VIVA QUESTIONS:-
APPARATUS REQUIRED:-
1. MATLAB Software.
2. Computer Systems.
THEORY:
The DTMF stands for “Dual Tone Multi Frequency”, and is a method of
representing digits with tone frequencies, in order to transmit them over an analog
communications network, for example a telephone line. In telephone networks, DTMF
signals are used to encode dial trains and other information.
Dual-tone Multi-Frequency (DTMF) signaling is the basis for voice
communications control and is widely used worldwide in modern telephony to dial
numbers and configure switchboards. It is also used in systems such as in voice mail,
electronic mail and telephone banking.
A DTMF signal consists of the sum of two sinusoids - or tones - with frequencies
taken from two mutually exclusive groups. These frequencies were chosen to prevent any
harmonics from being incorrectly detected by the receiver as some other DTMF
frequency. Each pair of tones contains one frequency of the low group (697 Hz, 770 Hz,
852 Hz, 941 Hz) and one frequency of the high group (1209 Hz, 1336 Hz, 1477Hz) and
represents a unique symbol.
PROCEDURE:-
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window/ Figure window
PROGRAM:
Clc;
Clear all;
Close all;
t = -2:0.05:2;
x=input('enter the input number');
fr1=697;
fr2=770;
fr3=852;
fr4=941;
fc1=1209;
fc2=1336;
fc3=1477;
fc4=1633;
y0 = sin(2*pi*fr4*t) + sin(2*pi*fc2*t); % 0
y1 = sin(2*pi*fr1*t) + sin(2*pi*fc1*t); % 1
y2 = sin(2*pi*fr1*t) + sin(2*pi*fc2*t); % 2
y3 = sin(2*pi*fr1*t) + sin(2*pi*fc3*t); % 3
y4 = sin(2*pi*fr2*t) + sin(2*pi*fc1*t); % 4
y5 = sin(2*pi*fr2*t) + sin(2*pi*fc2*t); % 5
y6 = sin(2*pi*fr2*t) + sin(2*pi*fc3*t); % 6
y7 = sin(2*pi*fr3*t) + sin(2*pi*fc1*t); % 7
y8 = sin(2*pi*fr3*t) + sin(2*pi*fc2*t); % 8
y9 = sin(2*pi*fr3*t) + sin(2*pi*fc3*t); % 9
y_start = sin(2*pi*fr4*t) + sin(2*pi*fc1*t); % *
y_canc = sin(2*pi*fr4*t) + sin(2*pi*fc3*t); % #
if (x==1)
plot(t,y1)
xlabel('time(t)')
ylabel('amplitude')
elseif (x==2)
plot(t,y2)
xlabel('time(t)')
ylabel('amplitude')
elseif (x==3)
plot(t,y3)
xlabel('time(t)')
ylabel('amplitude')
elseif (x==4)
plot(t,y4)
xlabel('time(t)')
ylabel('amplitude')
elseif (x==5)
plot(t,y5)
xlabel('time(t)')
ylabel('amplitude')
elseif (x==6)
plot(t,y6)
xlabel('time(t)')
ylabel('amplitude')
elseif (x==7)
plot(t,y7)
xlabel('time(t)')
ylabel('amplitude')
elseif (x==8)
plot(t,y8)
xlabel('time(t)')
ylabel('amplitude')
elseif (x==9)
plot(t,y9)
xlabel('time(t)')
ylabel('amplitude')
elseif (x==0)
plot(t,y0)
xlabel('time(t)')
ylabel('amplitude')
elseif (x==11)
plot(t,y_start)
xlabel('time(t)')
ylabel('amplitude')
elseif (x==12)
plot(t,y_canc)
xlabel('time(t)')
ylabel('amplitude')
else
disp('enter the correct input')
end
INPUT:-
Enter the input number = 7
OUTPUT:-
1. Expand DTMF?
2. Define frequency groups for all symbols?
3. Define DTMF?
4. Give the applications of DTMF?
5. Define low frequency group and high frequency group?
6. Explain about multi rate digital signal processing.
7. List the Applications of multi rate digital signal processing
8. What is meant anti aliasing?
9. What is the effect of anti imaging filter?
10. What is meant by magnitude response?
EXPERIMENT NO-14
Implementation of Decimation Process
THEORY: “Decimation” is the process of reducing the sampling rate. “Downsampling” is a more
specific term which refers to just the process of throwing away samples, without the lowpass filtering
operation. The most immediate reason to decimate is simply to reduce the sampling rate at the output
of one system so a system operating at a lower sampling rate can input the signal. But a much more
common motivation for decimation is to reduce the cost of processing: the calculation and/or
memory required to implement a DSP system generally is proportional to the sampling rate, so the
use of a lower sampling rate usually results in a cheaper implementation.
Algorithm:
Step I : Define down sampling factor and input frequencies f1 and f2
Step II : Represent input sequence with frequencies f1 and f2
Step III : Perform the decimation on input signal using matlab command decimate.
Step IV : Plot the input and output sequence.
Procedure :
1) Open MATLAB
2) Open new M-file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
PROGRAM:
Clc;
Clear all;
Close all;
D=input('enter the downsampling factor');
L=input('enter the length of the input signal');
f1=input('enter the frequency of first sinusodal');
f2=input('enter the frequency of second sinusodal');
n=0:L-1;
x=sin(2*pi*f1*n)+sin(2*pi*f2*n);
y=decimate(x,D,'fir');
subplot(2,1,1);
stem(n,x(1:L));
title('input sequence');
xlabel('time(n)');
ylabel('amplitude');
subplot(2,1,2)
m=0:(L/D)-1;
stem(m,y(1:L/D));
title('Decimated sequence');
xlabel('time(n)');
ylabel('amplitude');
INPUT:
enter the downsampling factor = 5
enter the length of the input signal = 100
enter the frequency of first sinusoidal = 0.01
enter the frequency of second sinusoidal = 0.03
Output Waveforms:
RESULT: Hence the decimation of given sequence verified using MATLAB.
VIVA QUESTIONS:
1. Explain about multi rate digital signal processing.
2. List the Applications of multi rate digital signal processing.
3. Define interpolation.
4. Define decimation.
5. Define aliasing
6. What are the two basic operations in multi-rate signal processing?
7. How can different sampling rates be obtained?
8. Name the areas in which multi-rate signal processing is used.
9. What are the advantages of multi-rate signal processing?
10. What are single-rate systems?
EXPERIMENT NO-15
Implementation of Interpolation Process
THEORY
“Upsampling” is the process of inserting zero-valued samples between original samples to
increase the sampling rate. (This is called “zero-stuffing”.) “Interpolation”, is the process of
upsampling followed by filtering. The filtering removes the undesired spectral images. The primary
reason to interpolate is simply to increase the sampling rate at the output of one system so that
another system operating at a higher sampling rate can input the signal.
Algorithm:
Flow Chart:
Procedure:-
1) Open MATLAB
2) Open new M-file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
PROGRAM:
Clc;
Clear all;
Close all;
L=input('enter the upsampling factor');
N=input('enter the length of the input signal');
% Length should be greater than 8
f1=input('enter the frequency of first sinusodal');
f2=input('enter the frequency of second sinusodal');
n=0:N-1;
x=sin(2*pi*f1*n)+sin(2*pi*f2*n);
y=interp(x,L);
subplot(2,1,1)
stem(n,x(1:N))
title('input sequence');
xlabel('time(n)');
ylabel('amplitude');
subplot(2,1,2)
m=0:N*L-1;
stem(m,y(1:N*L))
title('output sequence ');
xlabel('time(n)');
ylabel('amplitude');
INPUT:
enter the upsampling factor = 5
enter the length of the input signal = 9
enter the frequency of first sinusoidal = 0.1
enter the frequency of second sinusoidal = 0.3
Output Waveforms:
RESULT: Hence the Interpolation Process of given sequence is verified using MATLAB.
VIVA QUESTIONS:
1. Explain about multi rate digital signal processing.
2. List the Applications of multi rate digital signal processing.
3. Define interpolation.
4. Define decimation.
5. Define aliasing.
6. MATLAB stands for what?
7. What is impulse function?
8. Differentiate between even and odd signals.
9. What is impulse function?
10. State sampling theorem.
EXPERIMENT NO-16
Implementation of I/D Sampling Rate Converters
AIM: program to implement sampling rate conversion.
ALGOTITHAM:
Step I : Define up-sampling factor, down-sampling and inputfrequenciesf1 andf2
Flow Chart:
Procedure:-
1) Open MATLAB
2) Open new M-file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
PROGRAM:
Clc;
Clearall;Clos
eall;
L=input('enter the upsampling factor');
D=input('enter the downsampling factor');
N=input('enter the length of the input signal');
f1=input('enter the frequency of first sinusodal');
f2=input('enterthefrequencyofsecondsinusodal');
n=0:N-1;
x=sin(2*pi*f1*n)+sin(2*pi*f2*n);y=r
esample(x,L,D);
subplot(2,1,1)
stem(n,x(1:N))
title('inputsequence');xlab
el('time(n)');
ylabel('amplitude');subpl
ot(2,1,2)
m=0:N*L/D-1;
stem(m,y(1:N*L/D);
title('outputsequenc');xlab
el('time(n)');
ylabel('amplitude');
INPUT:
enter the up-sampling factor =3
enter the down-sampling factor=2
enter the length of the input signal=40
enter the frequency of first sinusoidal=0.01
enter the frequency of second sinusoidal = 0.03
OUTPUT WAVEFORMS
VIVA QUESTIONS:
1. What is decimation?
2. Define down sampling.
3. How can different sampling rates be obtained?
4. Define up sampling.
5. What is interpolation?
6. What for decimation is used in multi-rate digital signal processing system?
7. What for interpolation is used in multi-rate digital signal processing system?
8. How is decimation achieved?
9. How is interpolation achieved?
10. What is sampling rate conversion?
LIST OF EXPERIMENTS USING DSP PROCESSOR ARCHITECTURE
AND INSTRUCTION SET OF DSPCHIP-TMS320C5515
Introduction to the TMS320C55x: The TMS320C55x digital signal processor (DSP) represents the
latest generation of ‟C5000 DSPs from Texas Instruments. The ‟C55x is built on the proven legacy of
the ‟C54x and is source code compatible with the ‟C54x, protecting the customer‟s software
investment. Following the trends set by the ‟C54x, the ‟C55x is optimized for power efficiency, low
system cost, and best-in-class performance for tight power budgets. With core power dissipation as
low as 0.05 mW/MIPS at 0.9V, and performance up to 800 MIPS (400 MHz), the TMS320C55x
offers a cost-effective solution to the toughest challenges in personal and portable processing
applications as well as digital communications infrastructure with restrictive power budgets.
Compared to a 120-MHz ‟C54x, a 300-MHz ‟C55x will deliver approximately 5X higher
performance and dissipate one-sixth the core power dissipation of the ‟C54x. The ‟C55x core‟s ultra-
low power dissipation of 0.05mW/MIPS is achieved through intense attention to low-power design
and advanced power management techniques. The ‟C55x designers have implemented an
unparalleled level of power-down configurability and granularity coupled with unprecedented power
management that occurs automatically and is transparent to the user. The ‟C55x core delivers twice
the cycle efficiency of the ‟C54x through a dual- MAC (multiply-accumulate) architecture with
parallel instructions, additional accumulators, ALUs, and data registers. An advanced instruction set,
a superset to that of the ‟C54x, combined with expanded busing structure complements the new
hardware execution units. The ‟C55x continues the standard set by the ‟C54x in code density
leadership for lower system cost. The ‟C55x instructions are variable byte lengths ranging in size
from 8 bits to 48 bits. With this scalable instruction word length, the ‟C55x can reduce control code
size per function by up to 40% more than ‟C54x. Reduced control code size means reduced memory
requirements and lower system cost.
Key Features of the ’C55x The ‟C55x incorporates a rich set of features that provide processing
efficiency, low-power dissipation, and ease of use. Some of these features are listed in Table
Overview of the C5515 eZdsp USB Stick
The C5515 eZdsp USB Stick is an evaluation tool for the Texas Instruments TMS320C5515 Digital
Signal Processor (DSP). This USB bus powered tool allows the user to evaluate the following items:
• Micro SD connector
• 32 Mb NOR flash
The block diagram of the C5515 eZdsp USB Stick is shown below.
Code Composer Studio™ (CCS or CCStudio) is the integrated development environment for TI's
DSPs, microcontrollers and application processors. CCStudio includes a suite of tools used to
develop and debug embedded applications. It includes compilers for each of TI's device families,
source code editor, project build environment, debugger, profiler, simulators and many other
features. CCStudio provides a single user interface taking users through each step of the application
development flow. Familiar tools and interfaces allow users to get started faster than ever before and
add functionality to their application thanks to sophisticated productivity tools. CCStudio version 4
(CCSv4) is based on the Eclipse open source software framework. CCSv4 is based on Eclipse
because it offers an excellent software framework for development environments a standard
framework many embedded software vendors. CCSv4 combines the advantages of the Eclipse
software framework with advanced embedded debug capabilities from TI resulting in a compelling
feature rich development environment for embedded developers.
Features Debugger
CCStudio's integrated debugger has several capabilities and advanced breakpoints to simplify
development. Conditional or hardware breakpoints are based on full C expressions, local variables or
registers. The advanced memory window allows you to inspect each level of memory so that you can
debug complex cache coherency issues. CCStudio supports the development of complex systems
with multiple processors or cores. Global breakpoints and synchronous operations provide control
over multiple processors and cores.
Profiling
CCStudio's interactive profiler makes it easy to quickly measure code performance and ensure the
efficient use of the target's resources during debug and development sessions. The profiler allows
developers to easily profile all C/C++ functions in their application for instruction cycles or other
events such as cache misses/hits, pipeline stalls and branches. Profile ranges can be used to
concentrate efforts on high-usage areas of code during optimization, helping developers produce
finely-tuned code. Profiling is available for ranges of assembly, C++ or C code in any combination.
To increase productivity, all profiling facilities are available throughout the development cycle.
Scripting
Some tasks such as testing need to run for hours or days without user interaction. To accomplish such
a task, the IDE should be able to automate common tasks. CCStudio has a complete scripting
environment allowing for the automation of repetitive tasks such as testing and performance
benchmarking. A separate scripting console allows you to type commands or to execute scripts
within the IDE.
Image Analysis and Visualization
CCStudio has many image analysis and graphic visualization. It includes the ability to graphically
view variables and data on displays which can be automatically refreshed. CCStudio can also look at
images and video data in the native format (YUV, RGB) both in the host PC or loaded in the target
board.
Compiler
TI has developed C/C++ compilers specifically tuned to maximize the processor's usage and
performance. TI compilers use a wide range of classical, application-oriented, and sophisticated
device-specific optimizations that are tuned to all the supported architectures.
• Software pipelining
• Strength Reduction
• Instruction predication
• Hardware looping
• Function In-lining
• Vectorization
TI compilers also perform program level optimizations that evaluate code performance at the
application level. With the program level view, the compiler is able to generate code similar to an
assembly program developer who has the full system view. This application level view is leveraged
by the compiler to make trade-offs that significantly increase the processor performance. The TI
ARM and Microcontroller C/C++ compilers are specifically tuned for code size and control code
efficiency. They offer industry leading performance and compatibility.
Simulation
Simulators provide a way for users to begin development prior to having access to a development
board. Simulators also have the benefit of providing enhanced visibility into application performance
and behavior. Several simulator variants are available allowing users to trade off cycle accuracy,
speed and peripheral simulation, with some simulators being ideally suited to algorithm
benchmarking and others for more detailed system simulation. Hardware Debugging (Emulation) TI
devices include advanced hardware debugging capabilities.
These capabilities include:
• Real-time mode which provides for the debugging of code that interacts with interrupts that must
not be disabled. Real-time mode allows you to suspend background code at break events while
continuing to execute time-critical interrupt service routines.
• Multi-core operations such as synchronous run, step, and halt. This includes crosscore triggering,
which provides the ability to have one core trigger other cores to halt. Advanced Event Triggering
(AET) which is available on selected devices, allows a user to halt the CPU or trigger other events
based on complex events or sequences such as invalid data or program memory accesses. It can non-
intrusively measure performance and count system events (for example, cache events).
CCStudio provides Processor Trace on selected devices to help customers find previously
“invisible” complex real-time bugs. Trace can detect the really hard to find bugs – race conditions
between events, intermittent real-time glitches, crashes from stack overflows, runaway code and false
interrupts without stopping the processor. Trace is a completely nonintrusive debug method that
relies on a debug unit inside the processor so it does not interfere or change the application‟s real-
time behavior. Trace can fine tune code performance and cache optimization of complex switch
intensive multi-channel applications. Processor Trace supports the export of program, data, timing
and selected processor and system events/interrupts. Processor Trace can be exported either to an
XDS560 Trace external JTAG emulator, or on selected devices, to an on chip buffer Embedded
Trace Buffer (ETB).
CCSv4 comes with two versions of TI's real time operating system:
• BIOS 6.x is an advanced, extensible real-time operating system that supports ARM926,
ARM Cortex M3, C674x, C64x+, C672x, and 28x-based devices. It offers numerous kernel and
debugging enhancements not available in DSP/BIOS 5.x, including faster, more flexible memory
management, events, and priority-inheritance mutexes.
Note: BIOS 6.x includes a DSP/BIOS 5.x compatibility layer to support easy migration of
application source code.
Step 1: Open the code composer studio (CCSV4) and give a name to workspace and store it
in the default path itself. Note: don‟t assign other than default path unless you are familiar with
eclipse frame work based CCSV4
EQUIPMENTS:
1. Host (PC) with windows (95/98/Me/XP/NT/2000).
2. TMS320C5515 DSP Starter Kit (DSK).
THEORY:
Basic equation to find the DFT of a sequence is given below.
Program
//dft.c N-point DFT of sequence read from lookup table
#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979
#define N 64
#define TESTFREQ 10000.0
#define SAMPLING_FREQ 64000.0
typedef struct
{
float real;
float imag;
} COMPLEX;
float x1[N],y1[N];
COMPLEX samples[N];
void dft(COMPLEX *x)
{
COMPLEX result[N];
int k,n,i;
for (k=0 ; k<N ; k++)
result[k].real=0.0;
result[k].imag = 0.0;
x[k] = result[k];
printf("output");
printf("\n%d = %f",i,x1[i]);
void main()
//main function
int n;
y1[n] = samples[n].real = c
os(2*PI*TESTFREQ*n/SAMPLING_FREQ);
samples[n].imag = 0.0;
printf("\n%d = %f",n,samples[n].real);
printf("\n");
Code Flow:
• Step 2 – Generate a sine wave of frequency „f „ (eg: 10 Hz with a sampling rate = No. of Points of
DFT(eg. 64)) using math library function.
Execution Procedure:
In the Import Window under CCs choose Existing CCS/CCE Eclipse project then next.
Now Connect the DSP Kit to PC and Launch it.(Follow the above given manual procedure from
Step 46 to 51)
Give Right Click on Your Dft.out file under Binaries and select Load program Option.
Result: Hence the N (=4/8/16) point DFT of the given sequence computed.
Input Signal:
Output Signal :
EXPERIMENT NO-2
EQUIPMENTS:
FFT Algorithm The FFT has a fairly easy algorithm to implement, and it is shown step by step in
the list below. This version of the FFT is the Decimation in Time Method
1. Pad input sequence, of N samples, with Zero‟s until the number of samples is the nearest power of
two. e.g. 500 samples are padded to 512 (2^9)
3 = 011 goes to 110 = 6 3. Compute (N / 2) two sample DFT's from the shuffled inputs. See
"Shuffled Inputs"
4. Compute (N / 4) four sample DFT's from the two sample DFT's. See "Shuffled Inputs"
5. Compute (N / 2) eight sample DFT's from the four sample DFT's. See "Shuffled Inputs"
6. Until the all the samples combine into one N-sample DFT
PROGRAM:
Main.c
#include "usbstk5515.h"
#define PI 3.14159265358979
COMPLEX;
void main(void)
for(i=0;i<PTS;i++)
iobuffer[i]=0;
x1[i]=0;
printf("\n input");
printf("\n%d = %f",i,iobuffer[i]);
samples[i].real=0.0; samples[i].imag=0.0;
{
samples[i].real=iobuffer[i]; //buffer with new data
printf("\n output");
printf("\n%d = %f",i,x1[i]);
} //end of main
fft.c
COMPLEX;
do
num_stages +=1;
i = i*2;
while (i!=N);
lower_leg = upper_leg+leg_diff;
(Y[lower_leg]).real = temp2.real*(w[index]).real
-temp2.imag*(w[index]).imag;
(Y[upper_leg]).real = temp1.real;
}
leg_diff = leg_diff/2; step *= 2;
j = 0;
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;
Code Flow:
Execution Procedure:
In the Import Window under CCs choose Existing CCS/CCE Eclipse project then next.
Now Connect the DSP Kit to PC and Launch it.(Follow the above given manual procedure from
Step 46 to 51)
Give Right Click on Your fft.out file under Binaries and select Load program Option.
From Tools select Graph (Dual Time) , give properties and select OK.
Input Signal: