Professional Documents
Culture Documents
Kec 553a Lab Manual DSP 20-21
Kec 553a Lab Manual DSP 20-21
Contents
SYLLABUS & COURSE OUTCOMES ........................................................................................... 3
STUDY & EVALUATION SCHEME................................................................................. ..............4
EXPERIMENT - 1 Introduction to MATLAB and or Open Source Software, Scilab (Using Spoken
Tutorial MOOCs). ......................................................................................................................... 5
EXPERIMENT - 2Write a Program for the generation of basic signals such as unit impulse, unit step,
ramp, exponential, sinusoidal and cosine. ........................................................................................ .9
EXPERIMENT - 3 Implement IIR Butterworth analog Low Pass for a 4 KHz cut off frequency.
…………………………………………… 13
Experiment -1 Generate Frequency Modulation having carrier frequency 1KHz and modulating
frequency 200 Hz with the modulating index of 0.7. ......................................................................54
Experiment -2 Generate a FSK wave form for transmitting the digital data of the given bit
sequence......................................................................................................................................... .57
Experiment -3 Generate a PSK wave form for transmitting the digital data of the given bit sequence.
..........................................................................................................................................................59
Course Outcomes
After studying this course the students would be able to-
Course Outcomes: At the end of this course students will demonstrate the ability to:
C03558.4. Design IIR, and FIR filters for band pass, band stop, low pass and high pass filters.
ESE Sessional
EXPERIMENT - 1
Objective:-
Introduction to MATLAB:-
This is very important tool used for making long complicated calculations and plotting graphs
of different functions depending upon our requirement. Using MATLAB an m-file created in
which the basic operations are performed which the basic operations are performed which leads
to simple short and simple computations of very complicated problems in no or very short time.
Important functions performed by MATLAB are Matrix computations, Vector Analysis,
Differential equations computations, Integration is possible, Computer language programming
Simulations, Graph 2D and 3D plotting.
LIBRARY FUNCTIONS:
clc
Clear Command Window : clc clears all input and output from the Command Window display,
giving you a "clean screen."
Close all
Remove specified figure, closes deletes the current figure or the specified figure(s). It
optionally returns the status of the close operation.
clear all
• clear removes all variables from the workspace, releasing them from system memory.
• clear name removes just the M-file or MEX-file function or variable name from your
base workspace. If called from a function, clear name removes name from both the
function workspace and in your base workspace.
ones
• Y = ones(n) returns an n-by-n matrix of 1s. An error message appears if n is not a scalar.
zeros
plot
• plot(Y) plots the columns of Y versus the index of each value when Y is a real number.
For complex Y, plot(Y) is equivalent to plot(real(Y),imag(Y)).
subplot
• subplot divides the current figure into rectangular panes that are numbered rowwise.
Each pane contains an axes object which you can manipulate using Axes Properties.
Subsequent plots are output to the current pane.
• 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.
title
• 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.
Digital Signal Processing Lab- KEC-553A Page 6
Department Of Electronics and Communication
• title(fname) evaluates the function that returns a string and displays the string at the top
and in the center of the current axes.
stem
• 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.
Result:
The study of basics of MATLAB been accomplished.
Viva Questions:
• MATLAB Language
• MATLAB working environment
• Handle Graphics
• MATLAB function library
• MATLAB Application Program Interface (API)
Ans : MatLab API is a library that enables you to write Fortran and C programs that interact
with MatLab. It contains the facilities for calling routines from MatLab, for reading and writing
Mat files and calling Matlab as a computational engine.
• While Loop
• For Loop
• Nested Loops
EXPERIMENT- 2
Objective:-
Write a Program for the generation of basic signals such as unit impulse, unit step, ramp,
exponential, sinusoidal and cosine.
Apparatus Required:-
Hardware: Personal Computer
Software : MATLAB
Procedure:-
1. Start the MATLAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.
Program:-
(Generation of Discrete Time Signals)
%Program for unit step sequence
clc;
N=input('Enter the length of unit step sequence(N)= ');
n=0:1:N-1;
y=ones(1,N);
subplot(3,2,1);
stem(n,y,'k');
xlabel('Time')
ylabel('Amplitude')
title('Unit step sequence');
Output Waveform:
Result: -
Thus the MATLAB programs for discrete time signal sequences were written using
using MATLAB function and results were plotted.
Viva Questions :
Ans:- The MATLAB plot is in dB, whereas C-program plot is linear. Hence, the difference is
there. But window coefficient of both the programs are same.
Ans:- 1. Long duration sequences are filtered using overlap save method and overlap add
method.
2. DFT is implemented using FFT algorithms, which is computationally efficient.
EXPERIMENT- 3
Objective: -
Apparatus Required:-
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.
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”.
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:');
Input: -
enter the IIR filter design specifications
Output Waveform:-
Result:-
IIR filter is designed according to the given specifications and output waveforms are observed.
Viva Questions:-
1:- Which of the filter can be realized in both recursive and non recursive structure?
Ans:- [d ]
2:- Which filter is free of Limit cycle oscillations when implemented on a finite word length
digital system
Ans:-[d]
3:- In which filter the memory requirement and execution time are very high.
Ans:- [d ]
4:- Which of the following window is used instead of Hanning window for the same main lobe
width
Ans:- [c ]
Ans:- [c ]
EXPERIMENT -4
Verify Blackman and Hamming windowing techniques.
Apparatus Required:-
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
Procedure:-
1. Start the MATLAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.
Program:-
clc;
clear all;
rp = input('Enter the passband ripple = ');
rs = input('Enter the stopband ripple = ');
fp = input('Enter the passband frequency = ');
fs = input('Enter the stopband frequency = ');
f = input('Enter the sampling frequency = ');
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)==50)
n1 = n;
n = n-1;
end
y = hamming(n1);
% low-pass filter
b = fir1(n,wp,y);
[h,o] = freqz(b,1,256);
m = 20*log10(abs(h));
subplot(2,2,1);
plot(o/pi,m);
title('Magnitude Response of LPF');
ylabel('Gain in dB ---->');
xlabel('Normalised Frequency ---->');
grid on;
Digital Signal Processing Lab- KEC-553A Page 18
Department Of Electronics and Communication
% high-pass filter
b = fir1(n,wp,'high',y);
[h,o] = freqz(b,1,256);
m = 20*log10(abs(h));
subplot(2,2,2);
plot(o/pi,m);
title('Magnitude Response of HPF');
ylabel('Gain in dB ---->');
xlabel('Normalised Frequency ---->');
grid on;
% band pass filter
wn = [wp ws];
b = fir1(n,wn,y);
[h,o] = freqz(b,1,256);
m = 20*log10(abs(h));
subplot(2,2,3);
plot(o/pi,m);
title('Magnitude Response of BPF');
ylabel('Gain in dB ---->');
xlabel('Normalised Frequency ---->');
grid on;
% band stop filter
b = fir1(n,wn,'stop',y);
[h,o] = freqz(b,1,256);
m = 20*log10(abs(h));
subplot(2,2,4);
plot(o/pi,m);
ylabel('Gain in dB ---->');
Digital Signal Processing Lab- KEC-553A Page 19
Department Of Electronics and Communication
grid on;
Expected Output :
Program:-
clc;
clear all;
rp = input('Enter the passband ripple = ');
rs = input('Enter the stopband ripple = ');
fp = input('Enter the passband frequency = ');
fs = input('Enter the stopband frequency = ');
f = input('Enter the sampling frequency = ');
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)==50)
n1 = n;
n = n-1;
end
y = blackman(n1);
% low-pass filter
b = fir1(n,wp,y);
[h,o] = freqz(b,1,256);
m = 20*log10(abs(h));
subplot(2,2,1);
plot(o/pi,m);
title('Magnitude Response of LPF');
ylabel('Gain in dB ---->');
xlabel('Normalised Frequency ---->');
grid on;
% high-pass filter
b = fir1(n,wp,'high',y);
[h,o] = freqz(b,1,256);
m = 20*log10(abs(h));
subplot(2,2,2);
plot(o/pi,m);
title('Magnitude Response of HPF');
ylabel('Gain in dB ---->');
grid on;
Expected Output :-
Result:-
The hamming and Blackman window functions have been verified for various filters.
Viva Questions:-
1.Define filter.
3. Why are FIR filters generally preferred over IIR filters in multirate (decimating and
interpolating) systems/
10. Difference between FIR low pass filter and high pass filter.
EXPERIMENT-5
Objective:-
To find Discrete Fourier Transform and Inverse Discrete Fourier Transform of given digital signal.
Apparatus Required:-
Hardware: Personal Computer
Software : MATLAB
Theory:-
Algorithm:
Step I: Get the input sequence.
Step II: Find the DFT of the input sequence using direct equation of DFT.
Step IV: Plot DFT and IDFT of the given sequence using matlab command stem.
Procedure:-
1. Start the MATLAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.
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);
Digital Signal Processing Lab- KEC-553A Page 25
Department Of Electronics and Communication
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: -
X(n)=[1 2 3 4 5]
X(k) = 15,-2.50+3.44i,-2.50+0.81i,-2.49-0.81i,-2.49-3.44i
Output Waveform:-
Result :
DFT and IDFT of given sequence is implemented and waveforms are plotted.
Digital Signal Processing Lab- KEC-553A Page 26
Department Of Electronics and Communication
Viva Questions:-
1:- What is the advantage of calculating circular convolution using DFT and IDFT
Ans:- 1. DFT and IDFT can be efficiently calculated using FFT algorithms.
2. Frequency domain analysis of the signal can also be performed simultaneously.
Ans:- 1. Long duration sequences are filtered using overlap save method and overlap add
method.
2. DFT is implemented using FFT algorithms, which is computationally efficient.
EXPERIMENT-6
Objective:-
Verify Linear Convolution using code composer studio
Apparatus Required:-
HARDWARE : Personal Computer & TMS320C6713 kit
SOFTWARE : Code Composer Studio
Theory :-
Linear convoluted sequence y(n) between x(n) with duration N1and h(n) with duration N2 is
defined as
DFT does not support linear convolution, because of x(n) and h(n) are of different durations.
That’s why we can go for circular convolution.
Procedure:
1. Open Code Composer Studio.
2. To create the New Project
File->New->CCS Project
3. To create a Source file
a) A new project dialog box will appear. Fill in the following settings:
i) Target: TMS320C6713
5. Repeat Step 4 for the Release configuration by selecting the combo box at the top and
changing it from Debug to Release
6. TargetConfigs>TMS320C6713.ccxml>TMS320671X>initialization script> Add gel
file(DSK6713.gel)
Compile:-
Program:-
#define CHIP_6713
#include<stdio.h>
#include"dsk6713.h"
#include"dsk6713_led.h"
#include<math.h>
int m=4;
int n=4;
int i=0,j;
int x[10]={1,2,3,4};
int h[10]={1,2,3,4};
int y[20];
main()
{
int i;
for(i=0;i<m+n-1;i++)
{
y[i]=0;
for(j=0;j<=i;j++)
y[i]+=x[j]*h[i-j];
}
for(i=0;i<m+n-1;i++)
printf(“%d\n”,y[i]);
}
OUTPUT:
1.0 4.000000 10.000000 20.000000 25.000000 24.000000 16.000000
Result :-
Linear convolution of the sequence is found and the code is implemented on
the DSP processor to verify the results.
Viva Questions:
EXPERIMENT-7
Objective:-
Verify Circular Convolution using code composer studio
Apparatus Required:-
HARDWARE : Personal Computer & TMS320C6713 kit
SOFTWARE : Code Composer Studio
Theory:-
Convolution is a special operation, operated between two signals and which includes
the following operations.
1. Folding.
2. Shifting.
3. Multiplication.
4. Addition
Convolution sum is useful to obtain the response of discrete LTI system with input
x(n) and impulse response h(n).
Procedure:
1. Open Code Composer Studio.
2. To create the New Project
File->New->CCS Project
3. To create a Source file
a) A new project dialog box will appear. Fill in the following settings:
i) Target: TMS320C6713
5. Repeat Step 4 for the Release configuration by selecting the combo box at the top and
changing it from Debug to Release
6. TargetConfigs>TMS320C6713.ccxml>TMS320671X>initialization script> Add gel
file(DSK6713.gel)
Compile:-
1. To Compile: Project_ Compile
2. To Rebuild: project _ rebuild,
Which will create the final .out executable file. ( Eg. vvit.out).
3. Procedure to Load and Run program:
Load the Program to DSK: File_ Load program _vvit.out
To Execute project: Debug _ Run
Program :
#define CHIP_6713
#include<stdio.h>
#include"dsk6713.h"
#include"dsk6713_led.h"
int m,n,x[30],h[30],y[30],i,j,temp[30],k,x2[30],a[30];
void main()
{
printf("enter the length of the 1st sequence\n");
scanf("%d",&m);
printf("enter the length of the second sequence\n");
scanf("%d",&n);
printf("enter the 1st sequence\n");
for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf("enter the second sequence\n");
for(j=0;j<n;j++)
scanf("%d",&h[j]);
if(m-n!=0)
{
if(m>n)
{
for(i=n;i<m;i++)
h[i]=0;
n=m;
}
for(i=m;i<n;i++)
x[i]=0;
m=n;
}
y[0]=0;
a[0]=h[0];
for(j=1;j<n;j++)
a[j]=h[n-j];
for(i=0;i<n;i++)
y[0]+=x[i]*a[i];
for(k=1;k<n;k++)
{
y[k]=0;
for(j=1;j<n;j++)
x2[j]=a[j-1];
x2[0]=a[n-1];
for(i=0;i<n;i++)
{
a[i]=x2[i];
y[k]+=x[i]*x2[i];
}
}
printf("the circular convolution is\n");
for(i=0;i<n;i++)
printf("%d\t",y[i]);
Input:
(Circular Convolution)
Enter the length of the 1st sequence 5
Enter the length of the second sequence 5
Enter the 1st sequence 1 2 3 4 5
Enter the second sequence 1 2 3 4 5
Output:
Result:
Thus the C- Program for Circular convolution was written and the output was
verified.
Viva Questions :
Ans: In circular convolution if value of N < L+M-1 then last M-1 values of y[n] wraps
around gets added with first M-1 values of y[n]. This is called aliasing.
Ans: In periodic convolution input signals are originally periodic with common value of
period. In circular convolution, if input signals are not periodic then they are assumed to be
periodic with period = N where N = max (L, M) where L is the length of first signal and M is
length of second signal.
when DFT techniques are employed, the results of linear convolution are obtained only via
circular convolution.
EXPERIMENT-8
Objective: -
To verify FFT as sample interpolator.
Apparatus Required:-
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.
Procedure:-
1. Start the MATLAB program.
2. Open new M-file
3. Type the program
4. .Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.
Program: -
clc; clear all;
close all;
dx=3*pi/30; x=0:dx:3*pi;
f=sin(x).^2.*cos(x);
subplot(2,1,1) plot(x,f,'o')
title('input function');
xlabel('time(n)');
ylabel('Amplitude');
N=300;
y=interpft(f,N);
dy=dx*length(x)/N;
x2=0:dy:3*pi;
y=y(1:length(x2));
subplot(2,1,2)
plot(x2,y,'*');
ylabel('Amplitude');
Expected Output :-
Result:
FFT has been verified as sample interpolator,
EXPERIMENT-9
Objective: -
To implement Tone Generation./ Generation of DTMF Signal
Apparatus Required:-
Hardware: Personal Computer
Software : MATLAB
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:-
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.
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:
Result :
DTMF generation is completed and output is observed.
Viva Questions: -
1. Expand DTMF?
3. Define DTMF?
EXPERIMENT-10
Objective: -
To implement floating point arithmetic
Apparatus Required:-
HARDWARE : Personal Computer & TMS320C6713 kit
SOFTWARE : Code Composer Studio
Theory:
The term floating point refers to the fact that a number's radix point (decimal point, or,
more commonly in computers, binary point) can "float"; that is, it can be placed anywhere
relative to the significant digits of the number. This position is indicated as the exponent
component, and thus the floating-point representation can be thought of as a kind
of scientific notation.
We will implement the code for floating point multiplication of two numbers.
Procedure:
1. Open Code Composer Studio.
2. To create the New Project
File->New->CCS Project
3. To create a Source file
a) A new project dialog box will appear. Fill in the following settings:
i) Target: TMS320C6713
5. Repeat Step 4 for the Release configuration by selecting the combo box at the top and
changing it from Debug to Release
6. TargetConfigs>TMS320C6713.ccxml>TMS320671X>initialization script> Add gel
file(DSK6713.gel)
Compile:-
Program:-
#include<stdio.h>
#include"dsk6713.h"
#include"dsk6713_led.h"
int main()
{
float A, B, product = 0.0f;
return 0;
}
Output:
EXPERIMENT - 11
Objective:-
Introduction:
The hardware experiments in the DSP lab are carried out on the Texas Instruments
TMS320C6713 DSP Starter Kit (DSK), based on the TMS320C6713 floating point DSP
running at 225MHz. The basic clock cycle instruction time is 1/(225 MHz)= 4.44
nanoseconds. During each clock cycle, up to eight instructions can be carried out in
parallel, achieving up to 8×225 = 1800 million instructions per second (MIPS). The DSK
board includes a 16MB SDRAM memory and a 512KB Flash ROM. It has an on-board
16-bit audio stereo codec (the Texas Instruments AIC23B) that serves both as an A/D and
a D/A converter. There are four 3.5 mm audio jacks for microphone and stereo line input,
and speaker and headphone outputs. The AIC23 codec can be programmed to sample
audio inputs at the following sampling rates: fs = 8, 16, 24, 32, 44.1, 48, 96 kHz.
The ADC part of the codec is implemented as a multi-bit third-order noise-shaping delta-
sigma converter) that allows a variety of oversampling ratios that can realize the above
choices of fs. The corresponding oversampling decimation filters act as anti-aliasing
prefilters that limit the spectrum of the input analog signals effectively to the Nyquist
interval [−fs/2,fs/2]. The DAC part is similarly implemented as a multi-bit second-order
noiseshaping delta-sigma converter whose oversampling interpolation filters act as almost
ideal reconstruction filters with the Nyquist interval as their pass band.
The DSK also has four user-programmable DIP switches and four LEDs that can be used
to control and monitor programs running on the DSP. All features of the DSK are managed
by the Code Composer Studio (CCS). The CCS is a complete integrated development
environment (IDE) that includes an optimizing C/C++ compiler, assembler, linker,
debugger, and program loader. The CCS communicates with the DSK via a USB
connection to a PC. In addition to facilitating all programming aspects of the C6713 DSP,
the CCS can also read signals stored on the DSP‟s memory, or the SDRAM, and plot them
in the time or frequency domains. The following block diagram depicts the overall
operations involved in all of the hardware experiments in the DSP lab. Processing is
interrupt-driven at the sampling rate fs, as explained below.
Architecture:-
The 67XX DSPs use an advanced, modified Harvard architecture that maximizes
processing power by maintaining one program memory bus and three data memory buses.
These processors also provide an arithmetic logic unit (ALU) that has a high degree of
parallelism, application-specific hardware logic, on-chip memory, and additional on-chip
peripherals. These DSP families also provide a highly specialized instruction set, which is
the basis of the operational flexibility and speed of these DSPs. Separate program and data
spaces allow simultaneous access to program instructions and data, providing the high
degree of parallelism. Two reads and one write operation can be performed in a single
cycle. Instructions with parallel store and application-specific instructions can fully utilize
this architecture. In addition, data can be transferred between data and program spaces.
Such parallelism supports a powerful set of arithmetic, logic, and bit-manipulation
operations that can all be performed in a single machine cycle. Also included are the
control mechanisms to manage interrupts, repeated operations, and function calls.
1. Central Processing Unit (CPU): The CPU of the ‟67XX devices contains:
• A 17 -bit multiplier/adder
3. Accumulators: The accumulators, ACCA and ACCB, store the output from the ALU or
the multiplier / adder block; the accumulators can also provide a second input to the ALU
or the multiplier / adder. The bits in each accumulator are grouped as: Guard bits (bits 32–
39) , A high-order word (bits 16–31) , A low-order word (bits 0–15) .
4. Barrel Shifter: The ‟67XX‟s barrel shifter has a 40-bit input connected to the
accumulator or data memory (CB, DB) and a 40-bit output connected to the ALU or data
memory (EB). The barrel shifter produces a left shift of 0 to 31 bits and a right shift of 0 to
16 bits on the input data. The shift requirements are defined in the shift-count field (ASM)
of ST1 or defined in the temporary register (TREG), which is designated as a shift-count
register. This shifter and the exponent detector normalize the values in an accumulator in a
single cycle. The least significant bits (LSBs) of the output are filled with 0s and the most
significant bits (MSBs) can be either zero-filled or sign extended, depending on the state of
the sign-extended mode bit (SXM) of ST1.
6. Compare, Select, and Store Unit (CSSU) The compare, select, and store unit (CSSU)
performs maximum comparisons between the accumulator’s high and low words, allows
the test/control (TC) flag bit of status register 0 (ST0) and the transition (TRN) register to
keep their transition histories, and selects the larger word in the accumulator to be stored in
data memory. The CSSU also accelerates Viterbi-type butterfly computation with
optimized on-chip hardware.
8. Status Registers (ST0, ST1): The status registers, ST0 and ST1, contain the status of the
various conditions and modes for the ‟67XX devices. ST0 contains the flags (OV, C, and
TC) produced by arithmetic operations and bit manipulations in addition to the data page
pointer (DP) and the auxiliary register pointer (ARP) fields. ST1 contains the various
modes and instructions that the processor operates on and executes.
9. Auxiliary Registers (AR0–AR7): The eight 16-bit auxiliary registers (AR0–AR7) can be
accessed by the central arithmetic logic unit (CALU) and modified by the auxiliary register
arithmetic units (ARAUs). The primary function of the auxiliary registers is generating 16-
bit addresses for data space. However, these registers also can act as general-purpose
registers or counters.
10. Temporary Register (TREG): The TREG is used to hold one of the multiplicands for
multiply and multiply/accumulate instructions. It can hold a dynamic (execution-time
programmable) shift count for instructions with a shift operation such as ADD, LD, and
SUB. It also can hold a dynamic bit address for the BITT instruction. The EXP instruction
stores the exponent value computed into the TREG, while the NORM instruction uses the
TREG value to normalize the number. For ACS operation of Viterbi decoding, TREG
holds branch metrics used by the DADST and DSADT instructions.
11. Transition Register (TRN): The TRN is a 16-bit register that is used to hold the
transition decision for the path to new metrics to perform the Viterbi algorithm. The CMPS
(compare, select, max, and store) instruction updates the contents of the TRN based on the
comparison between the accumulator high word and the accumulator low word.
12. Stack-Pointer Register (SP): The SP is a 16-bit register that contains the address at the
top of the system stack. The SP always points to the last element pushed onto the stack.
The stack is manipulated by interrupts, traps, calls, returns, and the PUSHD, PSHM,
POPD, and POPM instructions. Pushes and pops of the stack pre decrement and post
increment, respectively, all 16 bits of the SP.
13. Circular-Buffer-Size Register (BK): The 16-bit BK is used by the ARAUs in circular
addressing to specify the data block size.
14. Block-Repeat Registers (BRC, RSA, REA): The block-repeat counter (BRC) is a 16-
bit register used to specify the number of times a block of code is to be repeated when
performing a block repeat. The block repeat start address (RSA) is a 16-bit register
containing the starting address of the block of program memory to be repeated when
operating in the repeat mode. The 16- bit block-repeat end address (REA) contains the
ending address if the block of program memory is to be repeated when operating in the
repeat mode.
15. Interrupt Registers: (IMR, IFR) The interrupt-mask register (IMR) is used to mask off
specific interrupts individually at required times. The interrupt-flag register (IFR) indicates
the current status of the interrupts.
16. Processor-Mode Status Register (PMST): The processor-mode status registers (PMST)
controls memory configurations of the 67XX devices.
17. Power-Down Modes There are three power-down modes, activated by the IDLE1,
IDLE2, and IDLE3 instructions. In these modes, the ‟67XX devices enter a dormant state
and dissipate considerably less power than in normal operation. The IDLE1instruction is
used to shut down the CPU. The IDLE2 instruction is used to shut down the CPU and on-
chip peripherals. The IDLE3 instruction is used to shut down the ‟67XX processor
completely. This instruction stops the PLL circuitry as well as the CPU and peripherals.
Result:
Thus the study of architecture TMS320VC6713 and its functionalities has been identified.
Viva Questions:
Ans : The 16-bit BK is used by the ARAUs in circular addressing to specify the data
block size.
Ans: : The status registers, ST0 and ST1, contain the status of the various conditions
and modes for the ‟67XX device.
EXPERIMENTS BEYOND
SYLLABUS
EXPERIMENT- 1
Objective-
Generate Frequency Modulation having carrier frequency 1Khz and modulating frequency
200 Hz with the modulating index of 0.7.
Apparatus Required:-
Hardware: Personal Computer
Software : MATLAB
Program:-
clc;
clear all;
close all;
fm=input('Message Frequency=');
fc=input('Carrier Frequency=');
mi=input('Modulation Index=');
t=0:0.0001:0.1;
m=sin(2*pi*fm*t);
subplot(3,1,1);
plot(t,m);
xlabel('Time');
ylabel('Amplitude');
title('Message Signal');
grid on;
c=sin(2*pi*fc*t);
subplot(3,1,2);
Digital Signal Processing Lab- KEC-553A Page 54
Department Of Electronics and Communication
plot(t,c);
xlabel('Time');
ylabel('Amplitude');
title('Carrier Signal');
grid on;
subplot(3,1,3);
plot(t,y);
xlabel('Time');
ylabel('Amplitude');
title('FM Signal');
grid on;
Output Waveform:
Result:
Frequency modulated wave has been generated, waveform is observed.
EXPERIMENT- 2
Objective :-
Generate a FSK wave form for transmitting the digital data of the given bit sequence.
Apparatus Required:-
Hardware: Personal Computer
Software : MATLAB
Program:-
clear all;
close all;
fc1=40;
fc2=20;
g=[1 1 0 0 1 1 1 0 1 0 0 0 1];%modulante
n=1;
while n<=length(g)
if g(n)==0
tx=((n-1)*0.1:.1/100:n*.1);
p=(1)*sin(2*pi*fc2*tx);
plot(tx,p);
hold on;
else
tx=((n-1)*0.1:.1/100:n*.1);
p=(1)*sin(2*pi*fc1*tx);
plot(tx,p);
hold on;
end
n=n+1;
end
Output Waveform:-
Result:
FSK wave has been generated, waveform is observed.
EXPERIMENT- 3
Objective :-
Generate a PSK wave form for transmitting the digital data of the given bit sequence.
Apparatus Required:-
Hardware: Personal Computer
Software : MATLAB
Program:-
clear all;
close all;
clc;
fc1=40;
g=[1 1 0 0 1 0]
n=1;
while n<=length(g)
if g(n)==0
tx=((n-1)*.1:.1/100:n*.1)
p=sin(pi+2*pi*fc1*tx)
plot(tx,p);
hold on;
else
tx=((n-1)*.1:.1/100:n*.1);
p=sin(2*pi*fc1*tx)
plot(tx,p)
hold on;
end
n=n+1;
end
Output Waveform:-
PSK Waveform
Result:
PSK wave has been generated, waveform is observed.
EXPERIMENT- 4
OBJECTIVE
Blinking of On Board LED (TMS320C6713)
Apparatus Required:-
HARDWARE : Personal Computer & TMS320C6713 kit
SOFTWARE : Code Composer Studio
Procedure:
1. Open Code Composer Studio.
2. To create the New Project
File->New->CCS Project
3. To create a Source file
a) A new project dialog box will appear. Fill in the following settings:
i) Target: TMS320C6713
5. Repeat Step 4 for the Release configuration by selecting the combo box at the top and
changing it from Debug to Release
6. TargetConfigs>TMS320C6713.ccxml>TMS320671X>initialization script> Add gel
file(DSK6713.gel)
Compile:-
Program:-
#define CHIP_6713
#include "dsk6713.h"
#include "dsk6713_led.h"
Void main(void)
{
DSk6713_init();
DSK6713_LED_init();
While(1)
{
DSK6713_LED_toggle(1);
DSK6713_waitusec(1000000);
}
}
Result:
Blinking of LED observed.