Ubm1512 DSP Lab Manual

You might also like

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

DIGITAL SIGNAL PROCESSING LAB

(UBM1512)
III YEAR BME (VI SEMESTER)

PREPARED

BY

M.DHANALAKSHMI
ASSISTANT PROFESSOR

DEPARTMENT OF BIO-MEDICAL ENGINEERING


SSN COLLEGE OF ENGINEERING, KALAVAKKAM – 603 110
LIST OF EXPERIMENTS

MATLAB / EQUIVALENT SOFTWARE PACKAGE

1. Generation of elementary Discrete-Time sequences

2. Linear and Circular convolutions

3. Auto correlation and Cross Correlation

4. Frequency Analysis of a signal using DFT

5. Design of FIR filters (LPF/HPF/BPF/BSF) and demonstrates the filtering operation

6. Design of Butterworth and Chebyshev IIR filters (LPF/HPF/BPF/BSF) and

demonstrate the filtering operations

7. Design an appropriate filter to remove artifacts in ECG signal

8. Estimation of EEG signal and analysis of its spectrum

DSP PROCESSOR BASED IMPLEMENTATION

1. Study of architecture of Digital Signal Processor


2. MAC operation using various addressing modes
3. Linear Convolution
4. Circular Convolution
5. Waveform generation
6. IIR and FIR Implementation
7. Implementation of Finite word length effects
MATLAB BASED
EXPERIMENTS
EXPT NO:1
DATE:
GENERATION OF SIGNALS

AIM:

To write a MATLAB program to generate the following signals:


1.Sine wave
2.Cosine wave
3.Rising exponential
4.Decreasing exponential
5.Square wave
6.Sinc wave
7.Unit step
8.Unit ramp
9.Unit impulse

APPARATUS REQUIRED:
MATLAB Software

ALGORITHM:

1. For the discrete signals, like the unit impulse waveform, specify the time scale and plot
the signal
2. For the continuous signals, the frequency, amplitude and the time scale and other
parameters are specified and these waveforms are plotted.
3. For each waveform, add appropriate “title”, and label x-axis as “time” and the y-axis as
“amplitude”.

PROGRAM:

%Generation Of Signals

%Sine wave:
a=10;
f=1000;
t=0:0.000001:0.01;
s=a*sin(2*pi*f*t);
figure;
subplot(331);
plot(t,s);
title(‘sine wave’);
xlabel(‘time’);
ylabel(‘amplitude’);
%Cosine wave:
a=10;
f=1000;
t=0:0.00001:0.01;
u=a*cos(2*pi*f*t);
subplot(332);
plot(t,u);
title(‘cosine wave’);
xlabel(‘time’);
ylabel(‘amplitude’);

%Unit step signal:


n1= -10:10;
y1=[zeros(1,10),ones(1,11)];
subplot(333);
stem(n1,y1);
plot(n1,y1);
title(‘unit step’);
xlabel(‘sample’);
ylabel(‘amplitude’);

%Unit ramp signal:


t3= -1:10:0;
y3=0;
t=0:0.1:0;
y=t;
subplot(334):
plot(t3,y3,t,y);
title(‘unit ramp’);
xlabel(‘time’);
ylabel(‘amplitude’);

%Unit impulse signal


n2= -5:1:5;
y3= [zeros(1,5),ones(1),zeros(1,5)];
subplot(3,3,5);
stem(n2,y3);
title(“unit impulse”);
xlabel (“samples”);
ylabel (“amplitude”);

%Rising Exponential signal


x = -2:0.05:20;
y = exp(x);
plot(y,x);
subplot(3,3,6);
stem (y,x);
title(“rising exponential”);
x label(“time”);
y label (“amplitude”);

%Decaying exponential signal


x= -2:0.05:20;
y=exp(-x);
plot(y,x);
subplot(3,3,7);
stem (y,x);
title(“decaying exponential”);
x label(“time”);
y label (“amplitude”);

%square wave
f=1000;
t=0:0.01:0.1;
a=10;
y=a*square(2*pi*f*t);
subplot(3,3,8);
plot(t,y);
title(“square wave”);
x label(“time”);
y label (“amplitude”);

%Sinc function
t=linspace(-10,10);
y=sinc(t);
subplot(3,3,9);
plot(t,y);
title(“sine wave”);
x label(“time”);
y label (“amplitude”);
OUTPUT:

RESULT:
Thus a MATLAB program was coded to generate the following signals:
1.Sine wave
2.Cosine wave
3.Rising exponential
4.Decreasing exponential
5.Square wave
6.Sinc wave
7.Unit step
8.Unit ramp
9.Unit impulse, and the outputs were verified.
EXPT NO:2
DATE:
LINEAR AND CIRCULAR CONVOLUTION

AIM:
To write a MATLAB program to perform linear and circular convolution.

APPARATUS REQUIRED:
Matlab software.

ALGORITHM :

Linear convolution :
1. Get the first input sequence x(n) using input function and second inpt sequence h(n) using
input function.
2. The length of each sequence is checked and the number of terms in the output sequence is
(N1+N2-1).
3. Zeros are added in a particular sequence to make the 2 sequences equal.
4. The ‘for’ loop is used for folding, shifting and multiplication of 2 sequences.
5. The output sequence is displayed using ‘disp’ function.

Circular convolution:
1. Obtain the 2 input sequences using input function.
2. The length of sequences must be same, or else zero padding is done to sequence whose
length is less, to equalise.
3. The ‘for’ loop is used for keeping one stationary and other sequence is shifted and
multiplied.
4. The output sequence is displayed using ‘disp’ function.

PROGRAM:

%Linear convolution

n1 = input('Enter the number of samples in sequence1 ');


x = input('Enter sequence1 ');
figure;
subplot(331);
stem(x);
title('sequence 1');
xlabel('samples');
ylabel('Amplitude');

n2 = input('Enter the number of samples in sequence2 ');


h = input('Enter sequence2 ');
subplot(332);
stem(h);
title('sequence 2');
xlabel('samples');
ylabel('Amplitude');
%Zero Padding
N = n1 + n2-1;
x1 = [x zeros(1, N-n1)];
subplot(334);
stem(x1);
title('sequence 1 with zero padding');
xlabel('samples');
ylabel('Amplitude');
h1 = [h zeros(1, N-n2)];
subplot(335);
stem(h1);
title('sequence 2 with zero padding');
xlabel('samples');
ylabel('Amplitude');
for i= 1:1:N
y (i) = 0;
for j= 1:1:i
y (i) = y (i) + (x1(j)*h1((i-j) + 1));
end
end
subplot(337);
stem (y);
title ('convolved sequence');
xlabel ('samples');
ylabel ('Amplitude');

COMMAND WINDOW:
OUTPUT:
%Circular Convolution

x=input('Enter the array of x ');


h=input('Enter the array of h ');
n1=length(x);
n2=length(h);
if n1>=n2
L=n1;
else
L=n2;
end
x1=[x zeros(1,(L-n1))];
h1=[h zeros(1,(L-n2))];
for m=1:L
for n=1:L
if n>m
H(m,n)=h1(L+m-n+1);
else
H(m,n)=h1(m-n+1);
end
end
end
disp (H);
y= (H*x1');
disp(y);

COMMAND WINDOW:

RESULT:
Thus linear and circular convolution has been performed for the given sequences and
output has been verified using MATLAB.
EXPT NO:3
DATE:
AUTO CORRELATION AND CROSS CORRELATION

AIM:
To generate the auto correlation and cross correlation of periodic and aperiodic signals.

APPARATUS REQUIRED:
Matlab software.

ALGORITHM :

Auto correlation of periodic and aperiodic signals:


1. Generate the periodic (or) aperiodic signals.
2. Plot the waveform with X and Y axis.
3. Use ‘XCorr’ function to obtain the auto correlation.
4. Plot the output waveform with X and Y labels.

Cross correlation of two periodic signals:


1. Generate the two periodic signals.
2. Plot the waveform with X and Y axis.
3. Use ‘XCorr(x,y)’ function to obtain cross correlation.
4. Plot the output waveform with X and Y labels.

Auto correlation of periodic signal and noise:


1. Generate a periodic signal and plot the waveform.
2. Generate a random noise and plot the waveform.
3. Add the periodic signal and noise and plot the added signal.
4. Use ‘XCorr’ function to obtain auto correlation of added signal.
5. Plot the output waveform with X and Y labels.

PROGRAM:

%Correlation

% auto correlation of periodic signal


a=6;
w=30*pi;
phi=pi/6;
t=0:.01:1;
x=a*sin(w*t+phi);
subplot(441);
plot(x);
axis tight;
title('periodic signal');
xlabel('time');
ylabel('amplitude');

y=xcorr(x);
subplot(442);
plot(y);
axis tight;
title('autocorrelation of periodic signal');
xlabel('time');
ylabel('amplitude');

% auto correlation of aperiodic signal


x=randn(1,100);
subplot(445);
plot(x);
axis tight;
title('aperiodic signal');
xlabel('time');
ylabel('amplitude');

y=xcorr(x);
subplot(446);
plot(y);
axis tight;
title ('autocorrelation of aperiodic signal');
xlabel('time');
ylabel('amplitude');

% auto correlation of periodic signal added with noise


t=0:.01:100;
f=600;
fs=1500;
x=sin(2*pi*(f/fs)*t);
subplot(449);
plot(x);
axis tight;
title('periodic signal');
xlabel('time');
ylabel('amplitude');

y=randn(1,length(x-1));
subplot(4,4,10);
plot(y);
axis tight;
title('noise');
xlabel('time');
ylabel('amplitude');

z=x+y;
subplot(4,4,11);
plot(z);
axis tight;
title('added periodic and noise');
xlabel('time');
ylabel('amplitude');

xz=xcorr(z);
subplot(4,4,12);
plot(xz);
axis tight;
title('autocorrelation of periodic signal with noise');
xlabel('time');
ylabel('amplitude');

% cross correlation of two periodic signal


t=0:.01:100;
f=600;
fs=1500;
x=sin(2*pi*(f/fs)*t);
subplot(4,4,13);
plot(x);
axis tight;
title('periodic signal sine');
xlabel('time');
ylabel('amplitude');

t=0:.01:100;
f=600;
fs=1500;
y=cos(2*pi*(f/fs)*t);
subplot(4,4,14);
plot(y);
axis tight;
title('periodic signal cosine');
xlabel('time');
ylabel('amplitude');

z=xcorr(x,y);
subplot(4,4,15);
plot(z);
axis tight;
title('cross correlation of two periodic signal');
xlabel('time');
ylabel('amplitude');

OUTPUT:
RESULT:

Thus auto-correlation and cross-correlation has been executed and output was verified
using MATLAB.
EXPT NO:4
DATE:
DISCRETE FOURIER TRANSFORM
AIM:
To perform discrete fourier transform and inverse fourier transform using decimation in time and
frequency algorithm.

APPARATUS REQUIRED:
MATLAB software

ALGORITHM:
1. Accept the sequence from the command window.
2. Find the length of the sequence, ‘n’.
3. Zero padding is done if ‘a’ is not equal to ‘n’.
4. Divide the sequence into two sets.
5. Assume weighting factor to be W.
6. Radix butterfly structure is used to obtain the data points.
7. Bit reversal should be done for the given sequence in the case of DIT and it should be
done after the butterfly structure in the case of DIF.
8. The values of WNnk are obtained by initialising ‘for’ loop for the corresponding radix
butterfly structures.

PROGRAM:
%DIT-FFT
x=input('enter the sequence');
N=input('enter the length of the sequence');
a=length(x);
if a<N
X=[x,zeros(1,(N-a))];
else
end
x=bitrevorder(x);
w=1;
div=N/2;
for st=1:3
n=1;
for r=1:div
k=0;
for j=1:w
y(n)=x(n)+(x(n+w)*exp(-((2*pi*i*k)/(N/div))));
k=k+1;
n=n+1;
end
for j=1:w
y(n)=x(n)*exp(-((2*pi*i*k)/(N/div)))+x(n-w);
]k=k+1;
n=n+1;
end
end
x=y;
w=w*2;
div=div/2;
end
disp(x);
subplot(311);
stem(real(x));
title('dft');
z=conj(x);
z=bitrevorder(z);
w=1;
div=N/2;
for st=1:3
n=1;
for r=1:div
k=0;
for j=1:w
a(n)=z(n)+z(n+w)*exp(-((2*pi*i*k)/(N/div)));
k=k+1;
n=n+1;
end
for j=1:w
a(n)=z(n)*exp(-((2*pi*i*k)/(N/div)))+z(n-w);
k=k+1;
n=n+1;
end
end
z=a;
w=w*2;
div=div/2;
end
%a=bitrevorder(z);
disp(z);
subplot(312);
c=abs(z);
stem(c/N);
title('idft');

%mag resp
fs=1000;
for i=1:512
freq(i)=((i/512)*fs/2);
end
y1=fft(x,1024);
y2=abs(y1);
subplot(313);
plot(freq,y2(1:512));
xlabel('freq');
ylabel('mag');
title('spectrum');

COMMAND WINDOW:

OUTPUT:
%DIF-FFT

x=input('enter the sequence');


N=input('enter the length of the sequence');
a=length(x);
if a<N
x=[x zeros(1,(N-a))];
else
end
w=1;
dw=N/2;
for s=1:3
n=1;
for r=1:dw
k=0;
for j=1:w
y(n)=x(n)+(x(n+w)*exp(-((2*pi*i*k)/(N/dw))));
k=k+1;
n=n+1;
end
for j=1:w
y(n)=(x(n)*exp(-((2*pi*i*k)/(N/dw)))) + x(n-w);
k=k+1;
n=n+1;
end
end
x=y;
w=w*2;
dw=dw/2;
end
x=bitrevorder(x);
disp(x);
subplot(311);
stem(real(x));
title('dft');
z=conj(x);
w=1;
dw=N/2;
for st=1:3
n=1;
for r=1:dw
k=0;
for j=1:w
a(n)=z(n)+z(n+w)*exp(-((2*pi*i*k)/(N/dw)));
k=k+1;
n=n+1;
end
for j=1:w
a(n)=z(n)*exp(-((2*pi*i*k)/(N/dw)))+z(n-w);
k=k+1;
n=n+1;
end
end
z=a;
w=w*2;
dw=dw/2;
end
a=bitrevorder(z);
disp(a);
subplot(312);
c=abs(a);
stem(c/N);
title('idft');

%mag resp
fs=1000;
for i=1:512
freq(i)=((i/512)*fs/2);
end
y1=fft(x,1024);
y2=abs(y1);
subplot(313);
plot(freq,y2(1:512));
xlabel('freq');
ylabel('mag');
title('spectrum');
COMMAND WINDOW:

OUTPUT:

RESULT:
The code for DFT and IDFT using DIT and DIF was written and executed for the given
sequence and the output was verified.
EXPT NO.:5
DATE:

FIR FILTER DESIGN


AIM:
To generate a MATLAB code for the finite impulse response (FIR) filter design using
windows and filters.

APPARATUS REQUIRED:
Matlab software.

ALGORITHM:
1. Open MATLAB m- file and type in the source code for the filter design.
2. Get the inputs from the user which includes pass band ,stop band , N values , cut off frequency
and sampling frequency.
3. According to the required filter for example- low pass filter , try using all windows and their
equations.
4. Similarly try designing for high pass filter, band pass filter and band stop filter units with
similar window functions.
5. Display the normal ideal response of each filter and their response for the given input signal
frequencies.

PROGRAM:

%FIR – Low pass filter


clc;
clear all;
f1=1;
f2=10;
t=0:0.01:1;
a=sin(2*pi*f1*t);
subplot(451);
plot(t,a);
xlabel('time');
ylabel('amp');
title('signal1');
b=sin(2*pi*f2*t);
subplot(452);
plot(t,b);
xlabel('time');
ylabel('amp');
title('signal2');
c=a+b;
subplot(453);
plot(c);
xlabel('time');
ylabel('amp');
title('added signal');
c1=abs(fft(c,1024));
for i=1:512
freq(i)=(i/1024)*100;
end
subplot(454);
plot(freq,c1(1:512));
xlabel('freq');
ylabel('amp');
title('fft of added signal');
N=input('Enter the filter order');
a1=(N-1)/2
if rem(N,2)==0
a1=N/2
end
fc=input('Enter the cut off frequency');
Wc=2*pi*fc/100
for n=1:N
if n==a1
hd(n)=Wc/pi
else
hd(n)=(sin(Wc*(n-a1)))/(pi*(n-a1))
end
end

%rectangular
w1=rectwin(N)
hn=hd.*w1'
subplot(455);
plot(hn);
xlabel('samples');
ylabel('amp');
title('periodic convolution');
h=freqz(hn,1,N);
subplot(456);
plot(abs(h));
xlabel('samples');
ylabel('amp');
title('magnitude response of window');
y=conv(c,hn);
subplot(457);
plot(y);
xlabel('samples');
ylabel('amp');
title('output signal');
y1=abs(fft(y,1024));
subplot(458);
plot(freq,y1(1:512));
xlabel('freq');
ylabel('amp');
title('spectrum of output signal');

%hanning
w2=hanning(N)
hn=hd.*w2'
subplot(459);
plot(hn);
xlabel('samples');
ylabel('amp');
title('periodic convolution');
h=freqz(hn,1,N);
subplot(4,5,10);
plot(abs(h));
xlabel('samples');
ylabel('amp');
title('magnitude response of window');
y=conv(c,hn);
subplot(4,5,11);
plot(y);
xlabel('samples');
ylabel('amp');
title('output signal');
y1=abs(fft(y,1024));
subplot(4,5,12);
plot(freq,y1(1:512));
xlabel('freq');
ylabel('amp');
title('spectrum of output signal');
%hamming
w3=hamming(N)
hn=hd.*w3'
subplot(4,5,13);
plot(hn);
xlabel('samples');
ylabel('amp');
title('periodic convolution');
h=freqz(hn,1,N);
subplot(4,5,14);
plot(abs(h));
xlabel('samples');
ylabel('amp');
title('magnitude response of window');
y=conv(c,hn);
subplot(4,5,15);
plot(y);
xlabel('samples');
ylabel('amp');
title('output signal');
y1=abs(fft(y,1024));
subplot(4,5,16);
plot(freq,y1(1:512));
xlabel('freq');
ylabel('amp');
title('spectrum of output signal');
COMMAND WINDOW:
OUTPUT:

PROGRAM:

%FIR – High pass filter


clc;
clear all;
f1=1;
f2=10;
t=0:0.01:1;
a=sin(2*pi*f1*t);
subplot(451);
plot(t,a);
xlabel('time');
ylabel('amp');
title('signal1');
b=sin(2*pi*f2*t);
subplot(452);
plot(t,b);
xlabel('time');
ylabel('amp');
title('signal2');
c=a+b;
subplot(453);
plot(c);
xlabel('time');
ylabel('amp');
title('added signal');
c1=abs(fft(c,1024));
for i=1:512
freq(i)=(i/1024)*100;
end
subplot(454);
plot(freq,c1(1:512));
xlabel('freq');
ylabel('amp');
title('fft of added signal');
N=input('Enter the filter order');
a1=(N-1)/2
if rem(N,2)==0
a1=N/2
end
fc=input('Enter the cut off frequency');
Wc=2*pi*fc/100
for n=1:N
if n==a1
hd(n)=1-(Wc/pi)
else
hd(n)=(1/(pi*(n-a1)))*((sin((n-a1)*pi))-(sin((n-a1)*Wc)))
end
end

%rectangular
w1=rectwin(N)
hn=hd.*w1'
subplot(455);
plot(hn);
xlabel('samples');
ylabel('amp');
title('convolved signal');
h=freqz(hn,1,N);
subplot(456);
plot(abs(h));
xlabel('samples');
ylabel('amp');
title('magnitude response of window');
y=conv(c,hn);
subplot(457);
plot(y);
xlabel('samples');
ylabel('amp');
title('output signal');
y1=abs(fft(y,1024));
subplot(458);
plot(freq,y1(1:512));
xlabel('freq');
ylabel('amp');
title('spectrum of output signal');

%hanning
w2=hanning(N)
hn=hd.*w2'
subplot(459);
plot(hn);
xlabel('samples');
ylabel('amp');
title('convolved signal');
h=freqz(hn,1,N);
subplot(4,5,10);
plot(abs(h));
xlabel('samples');
ylabel('amp');
title('magnitude response of window');
y=conv(c,hn);
subplot(4,5,11);
plot(y);
xlabel('samples');
ylabel('amp');
title('output signal');
y1=abs(fft(y,1024));
subplot(4,5,12);
plot(freq,y1(1:512));
xlabel('freq');
ylabel('amp');
title('spectrum of output signal');

%hamming
w3=hamming(N)
hn=hd.*w3'
subplot(4,5,13);
plot(hn);
xlabel('samples');
ylabel('amp');
title('convolved signal');
h=freqz(hn,1,N);
subplot(4,5,14);
plot(abs(h));
xlabel('samples');
ylabel('amp');
title('magnitude response of window');
y=conv(c,hn);
subplot(4,5,15);
plot(y);
xlabel('samples');
ylabel('amp');
title('output signal');
y1=abs(fft(y,1024));
subplot(4,5,16);
plot(freq,y1(1:512));
xlabel('freq');
ylabel('amp');
title('spectrum of output signal');

COMMAND WINDOW:
OUTPUT:

PROGRAM:

%FIR – Band pass filter


clc;
clear all;
f1=1;
f2=10;
t=0:0.01:1;
a=sin(2*pi*f1*t);
subplot(451);
plot(t,a);
xlabel('time');
ylabel('amp');
title('signal1');
b=sin(2*pi*f2*t);
subplot(452);
plot(t,b);
xlabel('time');
ylabel('amp');
title('signal2');
c=a+b;
subplot(453);
plot(c);
xlabel('time');
ylabel('amp');
title('added signal');
c1=abs(fft(c,1024));
for i=1:512
freq(i)=(i/1024)*100;
end
subplot(454);
plot(freq,c1(1:512));
xlabel('freq');
ylabel('amp');
title('fft of added signal');
N=input('Enter the filter order');
a1=(N-1)/2
if rem(N,2)==0
a1=N/2
end
fl=input('Enter the lower cut off frequency');
Wl=2*pi*fl/100
fh=input('Enter the higher cut off frequency');
Wh=2*pi*fh/100
for n=1:N
if n==a1
hd(n)=(Wh-Wl)/pi
else
hd(n)=(1/(pi*(n-a1)))*((sin((n-a1)*Wh))-(sin((n-a1)*Wl)))
end
end

%rectangular
w1=rectwin(N)
hn=hd.*w1'
subplot(455);
plot(hn);
xlabel('samples');
ylabel('amp');
title('convolved signal');
h=freqz(hn,1,N);
subplot(456);
plot(abs(h));
xlabel('samples');
ylabel('amp');
title('magnitude response of window');
y=conv(c,hn);
subplot(457);
plot(y);
xlabel('samples');
ylabel('amp');
title('output signal');
y1=abs(fft(y,1024));
subplot(458);
plot(freq,y1(1:512));
xlabel('freq');
ylabel('amp');
title('spectrum of output signal');

%hanning
w2=hanning(N)
hn=hd.*w2'
subplot(459);
plot(hn);
xlabel('samples');
ylabel('amp');
title('convolved signal');
h=freqz(hn,1,N);
subplot(4,5,10);
plot(abs(h));
xlabel('samples');
ylabel('amp');
title('magnitude response of window');
y=conv(c,hn);
subplot(4,5,11);
plot(y);
xlabel('samples');
ylabel('amp');
title('output signal');
y1=abs(fft(y,1024));
subplot(4,5,12);
plot(freq,y1(1:512));
xlabel('freq');
ylabel('amp');
title('spectrum of output signal');
%hamming
w3=hamming(N)
hn=hd.*w3'
subplot(4,5,13);
plot(hn);
xlabel('samples');
ylabel('amp');
title('convolved signal');
h=freqz(hn,1,N);
subplot(4,5,14);
plot(abs(h));
xlabel('samples');
ylabel('amp');
title('magnitude response of window');
y=conv(c,hn);
subplot(4,5,15);
plot(y);
xlabel('samples');
ylabel('amp');
title('output signal');
y1=abs(fft(y,1024));
subplot(4,5,16);
plot(freq,y1(1:512));
xlabel('freq');
ylabel('amp');
title('spectrum of output signal');

COMMAND WINDOW:
OUTPUT:

PROGRAM:

%FIR – Band stop filter


clc;
clear all;
f1=1;
f2=10;
t=0:0.01:1;
a=sin(2*pi*f1*t);
subplot(451);
plot(t,a);
xlabel('time');
ylabel('amp');
title('signal1');
b=sin(2*pi*f2*t);
subplot(452);
plot(t,b);
xlabel('time');
ylabel('amp');
title('signal2');
c=a+b;
subplot(453);
plot(c);
xlabel('time');
ylabel('amp');
title('added signal');
c1=abs(fft(c,1024));
for i=1:512
freq(i)=(i/1024)*100;
end
subplot(454);
plot(freq,c1(1:512));
xlabel('freq');
ylabel('amp');
title('fft of added signal');
N=input('Enter the filter order');
a1=(N-1)/2
if rem(N,2)==0
a1=N/2
end
fl=input('Enter the lower cut off frequency');
Wl=2*pi*fl/100
fh=input('Enter the higher cut off frequency');
Wh=2*pi*fh/100
for n=1:N
if n==a1
hd(n)=1-((Wh-Wl)/pi)
else
hd(n)=(1/(pi*(n-a1)))*((sin((n-a1)*Wl))-(sin((n-a1)*Wh))+(sin((n-a1)*pi)))
end
end

%rectangular
w1=rectwin(N)
hn=hd.*w1'
subplot(455);
plot(hn);
xlabel('samples');
ylabel('amp');
title('convolved signal');
h=freqz(hn,1,N);
subplot(456);
plot(abs(h));
xlabel('samples');
ylabel('amp');
title('magnitude response of window');
y=conv(c,hn);
subplot(457);
plot(y);
xlabel('samples');
ylabel('amp');
title('output signal');
y1=abs(fft(y,1024));
subplot(458);
plot(freq,y1(1:512));
xlabel('freq');
ylabel('amp');
title('spectrum of output signal');

%hanning
w2=hanning(N)
hn=hd.*w2'
subplot(459);
plot(hn);
xlabel('samples');
ylabel('amp');
title('convolved signal');
h=freqz(hn,1,N);
subplot(4,5,10);
plot(abs(h));
xlabel('samples');
ylabel('amp');
title('magnitude response of window');
y=conv(c,hn);
subplot(4,5,11);
plot(y);
xlabel('samples');
ylabel('amp');
title('output signal');
y1=abs(fft(y,1024));
subplot(4,5,12);
plot(freq,y1(1:512));
xlabel('freq');
ylabel('amp');
title('spectrum of output signal');

%hamming
w3=hamming(N)
hn=hd.*w3'
subplot(4,5,13);
plot(hn);
xlabel('samples');
ylabel('amp');
title('convolved signal');
h=freqz(hn,1,N);
subplot(4,5,14);
plot(abs(h));
xlabel('samples');
ylabel('amp');
title('magnitude response of window');
y=conv(c,hn);
subplot(4,5,15);
plot(y);
xlabel('samples');
ylabel('amp');
title('output signal');
y1=abs(fft(y,1024));
subplot(4,5,16);
plot(freq,y1(1:512));
xlabel('freq');
ylabel('amp');
title('spectrum of output signal');
COMMAND WINDOW:

OUTPUT:
RESULT:
Thus FIR filters were designed using windows for low pass filter, high pass filter, band
pass filter and band stop filter and also the responses of the filters were analysed.
EXPT NO:6
DATE:
IIR FILTER DESIGN

AIM:
To generate a MATLAB code for the infinite impulse response (IIR) filter design using
Butterwoth and Chebyshev filters.

APPARATUS REQUIRED:
Matlab software.

ALGORITHM:
1. Open MATLAB m- file and type in the source code for the filter design.
2. Get the inputs from the user which includes pass band ,stop band , N values , cut off frequency
and sampling frequency.
3. According to the required filter for example-Chebyshev and Butterworth low pass filter.
4. Similarly try designing for high pass filter, band pass filter and band stop filter units with
similar filter designs.
5. Display the normal ideal response of each filter and their response for the given input signal
frequencies.

PROGRAM:

%Lowpass filter
clc;
clear all;
close all;
f1=input('Enter the input frequency for the first signal =');
f2=input('Enter the input frequency for the second signal =');
fs=input('Enter the sampling frequency =');
fc=input('Enter the cutoff frequency =');
t=0:300;
c1=sin(2*pi*t*(f1/fs));
c2=sin(2*pi*t*(f2/fs));
c=c1+c2;
subplot(221);
plot(t,c);
xlabel('time');
ylabel('amplitude');
title('input signal');
f=abs(fft(c,1024));
for i=1:512
freq(i)=(i/1024)*fs;
end
subplot(222);
plot(freq,f(1:512));
xlabel('freq');
ylabel('amplitude');
title('fft of input signal');

%lpf butterworth
w=0:.001:pi;
[Bl1,Al1]=butter(5,((2*fc)/fs));
p3=freqz(Bl1,Al1,w);
figure;
subplot(221);
plot((w/pi),abs(p3));
title('butterworth lpf magnitude response');
xlabel('normalized freq');
ylabel('amplitude');
subplot(222);
plot((w/pi),phase(p3));
title('butterworth lpf phase response');
xlabel('normalized freq');
ylabel('phase');

l=filter(Bl1,Al1,c);
l1=abs(fft(l,1024));
subplot(223);
plot(freq,l1(1:512));
xlabel('freq');
ylabel('amplitude');
title('fft of lpf output through butterworth');

% lpf chebyshev type 1


w=0:.001:pi;
[BL,AL]=cheby1(5,5,(fc/fs));
p3=freqz(BL,AL,w);
figure;
subplot(221);
plot((w/pi),abs(p3));
title('chebyshev type 1 lpf magnitude response');
xlabel('normalized freq');
ylabel('amplitude');
subplot(222);
plot((w/pi),phase(p3));
title('chebyshev type 1 lpf phase response');
xlabel('normalized freq');
ylabel('phase');

a=filter(BL,AL,c);
a1=abs(fft(a,1024));
subplot(223);
plot(freq,a1(1:512));
xlabel('freq');
ylabel('amplitude');
title('fft of lpf output through chebyshev type 1');

% lpf chebyshev type 2


w=0:.001:pi;
[BL2,AL2]=cheby2(5,15,(fc/fs));
p5=freqz(BL2,AL2,w);
figure;
subplot(221);
plot((w/pi),abs(p5));
title('chebyshev type 2 lpf magnitude response');
xlabel('normalized freq');
ylabel('amplitude');
subplot(222);
plot((w/pi),phase(p5));
title('chebyshev type 2 lpf phase response');
xlabel('normalized freq');
ylabel('phase');

b=filter(BL2,AL2,c);
b1=abs(fft(b,1024));
subplot(223);
plot(freq,b1(1:512));
xlabel('freq');
ylabel('amplitude');
title('fft of lpf output through chebyshev type 2');

OUTPUT:

Input data:
Input:

Butterworth filter:
Chebyshev filter – type 1:

Chebyshev filter – type 2:


PROGRAM

%High pass filter


clc;
clear all;
close all;
f1=input('Enter the input frequency for the first signal =');
f2=input('Enter the input frequency for the second signal =');
fs=input('Enter the sampling frequency =');
fc=input('Enter the cutoff frequency =');
t=0:300;
c1=sin(2*pi*t*(f1/fs));
c2=sin(2*pi*t*(f2/fs));
c=c1+c2;
subplot(221);
plot(t,c);
xlabel('time');
ylabel('amplitude');
title('input signal');
f=abs(fft(c,1024));
for i=1:512
freq(i)=(i/1024)*fs;
end
subplot(222);
plot(freq,f(1:512));
xlabel('freq');
ylabel('amplitude');
title('fft of input signal');

%hpf butterworth
w=0:.001:pi;
[Bl1,Al1]=butter(5,((2*fc)/fs),'high');
p3=freqz(Bl1,Al1,w);
figure;
subplot(221);
plot((w/pi),abs(p3));
title('butterworth hpf magnitude response');
xlabel('normalized freq');
ylabel('amplitude');
subplot(222);
plot((w/pi),phase(p3));
title('butterworth hpf phase response');
xlabel('normalized freq');
ylabel('phase');

l=filter(Bl1,Al1,c);
l1=abs(fft(l,1024));
subplot(223);
plot(freq,l1(1:512));
xlabel('freq');
ylabel('amplitude');
title('fft of hpf output through butterworth');

% hpf chebyshev type 1


w=0:.001:pi;
[BL,AL]=cheby1(5,.5,(fc/fs),'high');
p3=freqz(BL,AL,w);
figure;
subplot(221);
plot((w/pi),abs(p3));
title('chebyshev type 1 hpf magnitude response');
xlabel('normalized freq');
ylabel('amplitude');
subplot(222);
plot((w/pi),phase(p3));
title('chebyshev type 1 hpf phase response');
xlabel('normalized freq');
ylabel('phase');

a=filter(BL,AL,c);
a1=abs(fft(a,1024));
subplot(223);
plot(freq,a1(1:512));
xlabel('freq');
ylabel('amplitude');
title('fft of hpf output through chebyshev type 1');

% hpf chebyshev type 2


w=0:.001:pi;
[BL2,AL2]=cheby2(5,15,(fc/fs),'high');
p5=freqz(BL2,AL2,w);
figure;
subplot(221);
plot((w/pi),abs(p5));
title('chebyshev type 2 hpf magnitude response');
xlabel('normalized freq');
ylabel('amplitude');
subplot(222);
plot((w/pi),phase(p5));
title('chebyshev type 2 hpf phase response');
xlabel('normalized freq');
ylabel('phase');
b=filter(BL2,AL2,c);
b1=abs(fft(b,1024));
subplot(223);
plot(freq,b1(1:512));
xlabel('freq');
ylabel('amplitude');
title('fft of hpf output through chebyshev type 2');

OUTPUT:

Input data:

Input:
Butterworth filter:

Chebyshev – type 1:
Chebyshev – type 2:

PROGRAM:

%Bandpass filter:

clc;
clear all;
close all;
fp1=3000;
fs1=2000;
fp2=4000;
fs2=5000;
fsamp=11000;
rp=3;
rs=45;
wp1=2*fp1/fsamp;
wp2=2*fp2/fsamp;
ws1=2*fs1/fsamp;
ws2=2*fs2/fsamp;
wp=[wp1 wp2];
ws=[ws1 ws2];
t=0:1/fsamp:0.01;
x=sin(2*pi*1000*t)+sin(2*pi*3000*t)+sin(2*pi*5000*t);

%butterworth
[n,wn]=buttord(wp,ws,rp,rs);
[b,a]=butter(n,wn);
h=freqz(b,a,512);
ha=20*log10(abs(h(1:512)));
hp=20*log10(phase(h(1:512)));
y=filter(b,a,x);

figure;
subplot(211);
plot(t,x);
xlabel('time');
ylabel('amplitude');
title('input signal');
for i=1:1024
freq(i)=(i/1024)*fsamp;
end
xf=(fft(x,1024));
subplot(212);
plot(freq(1:512),abs(xf(1:512)));
xlabel('freq');
ylabel('amplitude');
title('fft of input signal');

figure;
subplot(221);
plot(freq(1:512),ha(1:512));
title('butterworth bpf magnitude response');
xlabel('normalized freq');
ylabel('amplitude');
subplot(222);
plot(freq(1:512),hp(1:512));
title('butterworth bpf phase response');
xlabel('normalized freq');
ylabel('phase');
yf=(fft(y,1024));
subplot(223);
plot(freq(1:512),abs(yf(1:512)));
xlabel('freq');
ylabel('amplitude');
title('fft of bpf output through butterworth');

%cheby1
[n1,wn1]=cheb1ord(wp,ws,rp,rs);
[b1,a1]=cheby1(n1,rp,wn1);
h1=freqz(b1,a1,512);
ha1=20*log10(abs(h1(1:512)));
hp1=20*log10(phase(h1(1:512)));
y1=filter(b1,a1,x);
for i=1:512
freq(i)=(i/1024)*fsamp;
end

figure;
subplot(221);
plot(freq(1:512),ha1(1:512));
title('chebyshev type 1 bpf magnitude response');
xlabel('normalized freq');
ylabel('amplitude');
subplot(222);
plot(freq(1:512),hp1(1:512));
title('chebyshev type 1 bpf phase response');
xlabel('normalized freq');
ylabel('phase');
yf1=(fft(y1,1024));
subplot(223);
plot(freq(1:512),abs(yf1(1:512)));
xlabel('freq');
ylabel('amplitude');
title('fft of bpf output through chebyshev type 1');

%cheby2
[n2,wn2]=cheb2ord(wp,ws,rp,rs);
[b2,a2]=cheby2(n2,rp,wn2);
h2=freqz(b2,a2,512);
ha2=20*log10(abs(h2(1:512)));
hp2=20*log10(phase(h2(1:512)));
y2=filter(b2,a2,x);
for i=1:512
freq(i)=(i/1024)*fsamp;
end

figure;
subplot(221);
plot(freq(1:512),ha2(1:512));
title('chebyshev type 2 bpf magnitude response');
xlabel('normalized freq');
ylabel('amplitude');
subplot(222);
plot(freq(1:512),hp2(1:512));
title('chebyshev type 2 bpf phase response');
xlabel('normalized freq');
ylabel('phase');
yf1=(fft(y2,1024));
subplot(223);
plot(freq(1:512),abs(yf1(1:512)));
xlabel('freq');
ylabel('amplitude');
title('fft of bpf output through chebyshev type 2');

OUTPUT:

Input:
Butterworth filter:

Chebyshev type – 1 filter:


Chebyshev type – 2 filter:

PROGRAM:

%Bandstop filter
clc;
clear all;
close all;
fp1=2000;
fs1=3000;
fp2=5000;
fs2=4000;
fsamp=11000;
rp=3;
rs=45;
wp1=2*fp1/fsamp;
wp2=2*fp2/fsamp;
ws1=2*fs1/fsamp;
ws2=2*fs2/fsamp;
wp=[wp1 wp2];
ws=[ws1 ws2];
t=0:1/fsamp:0.01;
x=sin(2*pi*1000*t)+sin(2*pi*3000*t)+sin(2*pi*5000*t);
%butterworth
[n,wn]=buttord(wp,ws,rp,rs);
[b,a]=butter(n,wn,'stop');
h=freqz(b,a,512);
ha=20*log10(abs(h(1:512)));
hp=20*log10(phase(h(1:512)));
y=filter(b,a,x);

figure;
subplot(211);
plot(t,x);
xlabel('time');
ylabel('amplitude');
title('input signal');
for i=1:1024
freq(i)=(i/1024)*fsamp;
end
xf=(fft(x,1024));
subplot(212);
plot(freq(1:512),abs(xf(1:512)));
xlabel('freq');
ylabel('amplitude');
title('fft of input signal');

figure;
subplot(221);
plot(freq(1:512),ha(1:512));
title('butterworth bsf magnitude response');
xlabel('normalized freq');
ylabel('amplitude');
subplot(222);
plot(freq(1:512),hp(1:512));
title('butterworth bsf phase response');
xlabel('normalized freq');
ylabel('phase');
yf=(fft(y,1024));
subplot(223);
plot(freq(1:512),abs(yf(1:512)));
xlabel('freq');
ylabel('amplitude');
title('fft of bsf output through butterworth');

%cheby1
[n1,wn1]=cheb1ord(wp,ws,rp,rs);
[b1,a1]=cheby1(n1,rp,wn1,'stop');
h1=freqz(b1,a1,512);
ha1=20*log10(abs(h1(1:512)));
hp1=20*log10(phase(h1(1:512)));
y1=filter(b1,a1,x);
for i=1:512
freq(i)=(i/1024)*fsamp;
end

figure;
subplot(221);
plot(freq(1:512),ha1(1:512));
title('chebyshev type 1 bsf magnitude response');
xlabel('normalized freq');
ylabel('amplitude');
subplot(222);
plot(freq(1:512),hp1(1:512));
title('chebyshev type 1 bsf phase response');
xlabel('normalized freq');
ylabel('phase');
yf1=(fft(y1,1024));
subplot(223);
plot(freq(1:512),abs(yf1(1:512)));
xlabel('freq');
ylabel('amplitude');
title('fft of bsf output through chebyshev type 1');

%cheby2
[n2,wn2]=cheb2ord(wp,ws,rp,rs);
[b2,a2]=cheby2(n2,rp,wn2,'stop');
h2=freqz(b2,a2,512);
ha2=20*log10(abs(h2(1:512)));
hp2=20*log10(phase(h2(1:512)));
y2=filter(b2,a2,x);
for i=1:512
freq(i)=(i/1024)*fsamp;
end

figure;
subplot(221);
plot(freq(1:512),ha2(1:512));
title('chebyshev type 2 bsf magnitude response');
xlabel('normalized freq');
ylabel('amplitude');
subplot(222);
plot(freq(1:512),hp2(1:512));
title('chebyshev type 2 bsf phase response');
xlabel('normalized freq');
ylabel('phase');
yf1=(fft(y2,1024));
subplot(223);
plot(freq(1:512),abs(yf1(1:512)));
xlabel('freq');
ylabel('amplitude');
title('fft of bsf output through chebyshev type 2');

OUTPUT:

Input:
Butterworth filter:

Chebyshev filter – type 1:

Chebyshev filter – type 2:


RESULT:
Thus IIR filters were designed for low pass filter, high pass filter, band pass filter and band stop
filter, using butterworth and Chebyshev filters and the response each of the filters were analyzed.
EXPT NO: 7
DATE:

ECG SIGNAL ANALYSIS


AIM:
To write a MATLAB program to Design an appropriate filter to remove artifacts in
ECG signal

APPARATUS REQUIRED:
Matlab software.

ALGORITHM:
1. Open MATLAB m- file and type in the source code for ECG generation.
2. Import the required data from the data file and run the code.
3. ECG signal will be generated and the outputs will be displayed in a separate window.

PROGRAM CODE:

close all;clear;clc;
sig=load('ecg_60hz_200.dat');
N=length(sig);
fs=200;
t=[0:N-1]/fs;
figure(1);subplot(4,2,1);plot(sig)
title('Original Signal')
%%
% Low Pass Filter

b=1/32*[1 0 0 0 0 0 -2 0 0 0 0 0 1];
a=[1 -2 1];
sigL=filter(b,a,sig);
subplot(4,2,3);plot(sigL)
title('Low Pass Filter')
subplot(4,2,4);zplane(b,a)
%%
% High Pass Filter

b=[-1/32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1/32];
a=[1 -1];
sigH=filter(b,a,sigL);
subplot(4,2,5);plot(sigH)
title('High Pass Filter')
subplot(4,2,6);zplane(b,a)
%%
% Derivative Base Filter

b=[1/4 1/8 0 -1/8 -1/4];


a=[1];
sigD=filter(b,a,sigH);
subplot(4,2,7);plot(sigD)
title('Derivative Base Filter')
subplot(4,2,8);zplane(b,a)
%%
% be tavane 2 miresanim
sigD2=sigD.^2;
%%
% normalization
signorm=sigD2/max(abs(sigD2));
%%
h=ones(1,31)/31;
sigAV=conv(signorm,h);
sigAV=sigAV(15+[1:N]);
sigAV=sigAV/max(abs(sigAV));
figure(2);plot(sigAV)
title('Moving Average filter')
%%
treshold=mean(sigAV);
P_G= (sigAV>0.01);
figure(3);plot(P_G)
title('treshold Signal')
figure;plot(sigL)
%%
difsig=diff(P_G);
left=find(difsig==1);
raight=find(difsig==-1);
%%
% run cancel delay
% 6 sample delay because of LowPass filtering
% 16 sample delay because of HighPass filtering
left=left-(6+16);
raight=raight-(6+16);
%%
% P-QRS-t
for i=1:length(left);
[R_A(i) R_t(i)]=max(sigL(left(i):raight(i)));
R_t(i)=R_t(i)-1+left(i) %add offset
[Q_A(i) Q_t(i)]=min(sigL(left(i):R_t(i)));
Q_t(i)=Q_t(i)-1+left(i)
[S_A(i) S_t(i)]=min(sigL(left(i):raight(i)));
S_t(i)=S_t(i)-1+left(i)
[P_A(i) P_t(i)]=max(sigL(left(i):Q_t(i)));
P_t(i)=P_t(i)-1+left(i)
[T_A(i) T_t(i)]=max(sigL(S_t(i):raight(i)));
T_t(i)=T_t(i)-1+left(i)+47
end
%%
figure;plot(t,sigL,t(Q_t),Q_A,'*g',t(S_t),S_A,'^k',t(R_t),R_A,'ob',t(P_t),P_A,'+b',t(T_t),T_A,
'+r');
for i=1:((length(P_t))-1)
HRV=P_t(i+1)-P_t(i)
end

OUTPUT:
RESULT:

Thus MATLAB program to Design an appropriate filter to remove artifacts


in ECG signal has been designed and the outputs have been displayed.
Exp No:8
Date:

EEG SIGNAL ANALYSIS


AIM:
To write a MATLAB program for estimation of EEG signal and analysis of its spectrum

APPARATUS REQUIRED:
Matlab software.

ALGORITHM:
4. Open MATLAB m- file and type in the source code for EEG generation.
5. Import the required data from the data file and run the code.
6. ECG signal will be generated and the outputs will be displayed in a separate window.

PROGRAM CODE:

clc;

clear;

clear all;

%%start by generating an eeg signal (EEG 2D data)

fs = 512;

T = 1/fs;

EEGsig= load ('EEGdata_01_Double.txt');

ls = size(EEGsig); N = length(EEGsig);

t = [0:N-1]/fs;

fx = fs*(0:N-2)/N;

x=EEGsig;
y = fft(x);

n = length(x); % number of samples

f = (0:n-1)*(fs/n); % frequency range

power = abs(y).^2/n; % power of the DFT

plot(f,power)

xlabel('Frequency')

ylabel('Power')

figure();

grid on;

hold on;

plot(EEGsig);

ylabel('Amplitude (microvolt)');

xlabel('Time (s)');

title('EEG Signal');

OUTPUT:
RESULT:

Thus a MATLAB program forestimation of EEG signal and analysis of its


spectrum has been designed and the outputs have been displayed.
PROCESSOR BASED
EXPERIMENTS
EXPT NO:1
DATE:

STUDY OF ARCHITECTURE OF DIGITAL SIGNAL PROCESSOR


TMS320C6713 FLOATING POINT DSP
INTRODUCTION:
The TMS320C6x are the first processors to use velociTI Harvard architecture, having
implemented the VLIW architecture. The TMS320C62x is a 16-bit fixed point processor and the
‘67x is a floating point processor, with 32-bit integer support. The architecture and peripherals
associated with this processor are also discussed.
The C6713 DSK is a low-cost standalone development platform that enables users to evaluate
and develop applications for the TIC67xx DSP family. The DSK also serves as a hardware
reference design for the TMS320C6713 DSP. Schematics, logic equations and application notes
are available to ease hardware development and reduce time to market.

CHARACTERISTICS OF C6713 DSP PROCESSOR:


1) Highest-performance floating-point DSP
2) Advanced very long instruction word TMS320C6713 DSP CORE
3) Eight independent functional units:
- Two ALUs (Fixed Point)
- Four ALUs (Floating and Fixed Point)
- Two Multipliers (Floating and Fixed Point)
4) Load-Store architecture with 32 32-bit General-Purpose registers
5) Instruction set features:
- Native instructions for IEEE 754
- Single- and Double- precision
- Byte-addressable(8-, 16-, 32-bit Data)
- 8-bit overflow protection
6) L1/L2 memory architecture
7) Device configuration:
- Boot Mode: HP1, 8-, 16-, 32-bit ROM Boot
- Endianness: Little Endian, Big Endian
8) 32-bit external memory interface(EMIF)
9) Enhanced direct-memory-access controller (16 independent channels)
10) Two 32-bit general-purpose timers
11) 3.3-V I/OS, 1.2-V+ INTERNAL
TMS320C6713 DSP KIT:

BLOCK DIAGRAM OF TMS320C6713 DSP:


FUNCTIONAL DESCRIPTION:
The DSP on the 6713 DSK interfaces to on-board peripherals through a 32-bit wide
EMIF(External Memory interface). The SDRAM, Flash and CPLD are all connected to the bus.
EMIF signals are also connected daughter card expansion connectors which are used for third
party add-in boards.
The DSP interfaces to analog audio signals through an on-board AIC23 codec and four 3.5mm
audio jacks(microphone input, line input, line output and headphone output). The codec can
select the microphone or the line input as the active input. The analog output is driven to both the
line out(fixed gain) and headphone (adjustable gain) connectors. McBSP0 is used to send
commands to the codec control interface while McBSP1 is used for digital audio data. McBSP0
and McBSP1 can be re-routed to the expansion connectors in software.
A programmable logic device called a CPLD is used to implement glue logic that ties the board
components together. The CPLD has a register based user interface that lets the user configure
the board by reading and writing to its registers.
The DSK includes 4 LEDS and a 4 position DIP switch as a simple way to provide the user with
interactive feedback. Both are accessed by reading and writing to the CPLD registers.
An included 5V external power supply is used to power the board. On-board switching voltage
regulators provide the +1.26VDSP core voltage and +3.3V I/O supplies. The board is held in
reset until rate supplies are within operating specifications.
Code Composer communicates with the DSK through an embedded JTAG emulator with a USB
host interface. The DSK can also be used with an external emulator through the external JTAG
connector.

ARCHITECTURE:

The processor consists of three main parts:


- CPU
- Peripherals
- Memory

CENTRAL PROCESSING UNIT:


The CPU contains program fetch unit, instruction dispatch unit, instruction decode unit. The
CPU fetches advanced very-long instructions (VLIW)(256 bits wide) to supply up to 32-bit
instructions to the eight functional units during every clock cycle. The VLIW architecture
features controls by which all eight units do not have to be supplied with instructions if they are
not ready to execute. The first bit of every 32-bit instruction determines if the next instruction
belongs to the same execute packet as the previous information, or whether it should be executed
in the following clock as a part of the next execute packet.
Fetch packets are always 256 bits wide; however, the execute packets can vary in size. The
variable-length execute packets are a key memory-saving feature, distinguishing the C67xCPU
from other VLIW architectures. The CPU also contains two data paths (containing registers A
and B respectively) in which the processing takes place. Each data path has four functional units
(.D, .M, .L and .S). The functional units execute logic, multiply, shifting and data address
operation.

TMS 320C67XX DATA PATH:


All instructions except loads and stores operate on the register. All data transfers between the
register files and memory take place only through two data-addressing units (.D1 and .D2). The
CPU also has various control registers, control logic and test, emulation and logic. Access to
control registers s provided from data path B.

GENERAL PURPOSE REGISTER FILES:


The CPU contains two general purpose registers files A and B. These can be used for data or as
data address pointers. Each file contains sixteen 32-bit registers (A0-A15 for file A and B0-B15
for file B). The registers A1, A2, B0, B1, B2 can also be used as condition registers. The
registers A4-A7 and B4-B7 can be used for circular addressing. These registers provide 32-bit
and 40-bit fixed-point data. The 32-bit data can be stored in any register. For 40-bit data,
processor stores least significant 32 bits in an even register and remaining 8 bits in upper (odd)
register.

FUNCTIONAL UNIT:

FUNCTIONAL UNIT DESCRIPTION


.L unit (.L1, .L2) 32/40-bit arithmetic and compare operations
Left most 1.0. bit counting for 32 bits
Normalization count for 32 and 40 bits
32 bit logical operations
32/64-bit IEEE floating-point arithmetic
Floating-point/ Fixed-point conversions
.S unit (.S1, .S2) 32-bit arithmetic operations
32/40 bit shifts and 32-bit field operations
32 bit logical operations
Branching
Constant generation
Register transfers to/from the control register
file
32/64-bit IEEE floating-point compare
operations
32/64-bit IEEE floating-point reciprocal and
square root reciprocal approximation
.M unit (.M1, .M2) 16x16 bit multiplies
32x32 bit multiplies
Single-precision(32-bit) floating-point IEEE
multiplies
Double-precision(64-bit) floating-point IEEE
multiplies
.D unit(.D1, .D2) 32-bit add, subtract, linear and circular
address calculation

MEMORY SYSTEM:
The memory system of the TMS320C671x series processor implements a modified Harvard
architecture, providing separate address spaces for instruction and data memory. The processor
uses a two-level cache-based architecture and has a powerful and diverse set of peripherals. The
Level 1 program cache (L1P) is a 4K-byte direct-mapped cache and Level 1 data cache (L1D) is
a 4K-byte 2-way set-associative cache. The Level 2 memory/cache (L2) consists of a 256K-byte
memory space that is shared between program and data space. 64K bytes of the 256K bytes in L2
memory can be configured as mapped memory, cache or combinations of the two. The remaining
192K bytes in L2 serve as mapped SRAM.

FEATURES OF DSP KIT:


The DSK comes with a full complement of on-board devices that suit a wide variety of
application environments. Key features include:
1) A Texas Instruments TMS320C6713 DSP operating at 225 Mhz.
2) An AI23 stereo codec
3) 16 Mbytes of synchronous DRAM
4) 512 Kbytes of non-volatile Flash memory (256Kbytes usable in default configuration)
5) 4 user accessible LEDs and DIP switches
6) Software board configuration through registers implemented in CPLD
7) Configurable boot options
8) Standard expansion connectors for daughter card use
9) JTAG emulation through on-board JTAG emulator with USB host interface or external
emulator
10) Single voltage power supply (+5V)
APPLICATIONS:
It is used in Telecommunications, Voice/Speech, Automotive, Control systems, Military (for
remote sensing), Medical applications like MRI, Instrumentation like spectral analysis, Image
processing applications.

CONCLUSION:
There are many applications for which Digital Signal Processor becomes an ideal choice as they
provide the best possible combination of performance, power and cost. Most of the DSP
applications can be simplified into multiplications and additions, so the MAC formed is a main
functional unit in early DSP processors. The designers later incorporated more features like
pipelining, SIMD, VLIW etc, in the processors to deliver improved performance.
Power issues are gaining importance as DSP processors are incorporated in to handheld, mobile
and portable devices. This leads to development of an important class of DSP processors namely
fixed-point processors.
Based on the current trends seen in the DSP processor development we may predict that the
manufacturers will follow the path of general purpose processors. With new IC manufacturing
technologies available we may expect to see more on-chip peripherals and memory; and in fact
the system on chip may not be too far away.

CODE COMPOSER STUDIO

BASIC STEPS FOR PROGRAM IMPLEMENTATIONS

SIMULATION MODE:
Step 1: Click on the CC Studio icon to open it.
Step 2: On the left part of the window, free the existing system configurations if any by selecting
Remove All.
Step 3: On the top part of the window, select the following
Family: C67XX
Platform: Simulator
Endian: Little
Step 4: From the list, select C67XX CPU cycle. Accurate simulate and give ‘ADD’.
Step 5: Select the icon of the simulator in the left window and click on save and exit.
Step 6: In the pop-up showing “Start CC Studio on exit” click ‘YES’.

Step 7: In the window that opens up, go to options → customize.


Step 8:
i. Under debug properties, uncheck ‘Open the Disassembly window automatically’ and
check ‘Perform Go Main automatically’ [Program Load]
ii. Under Program/Project/CXO,
 Check ‘Perform verification during Program Load’, ‘Load Program after build’,
‘Disable all breakpoints when loading new programs’.
 Check ‘Open Dependent Projects when loading projects’ and open Project
window on startup.
iii. Under control window display,
 Select ‘Board Name’, ‘Processor Name’ and ‘Current Project’ [title bar displays]
 Check ‘Display full path’ [Source file names]
 Check ‘Close all windows on Project close’ [Project Close]

Step 9: Go to Project → New.


Step 10: Create a folder for CCS projects in a desired location.

Step 11:
I. Give the folder path under ‘Location’.
II. Give the ‘Project Name’.
III. Under ‘target’, select TMS 320C67CC.
Step 12: Three files are to be created:
Configuration, Linker Command and source files
Step 13: Creating configuration file:

a) Go to File → New → DSP/Bios configuration. Select TI platforms, sim 67XX and


give OK.
b) In the pop-up, right click on the title ‘System’→ Global settings → Click on
Properties.
 Give board name as C6713.
 Give DSP speed in MHz: 300
 Give OK.
c) Under MEM → right click properties and check ‘No dynamic Memory Heaps’.
d) In the pop-up under input/output, select RTDX and right click to get properties,
set RTDX mode as simulator.
e) Save the configuration file [File → Save] in the Project folder.
Step 14: Add the created Configuration file to the project folder by right clicking on the project
name in the left window. Two files are automatically generated [in generated files]
Step 15:
I. Right click on the project name again and give add files to project.
II. Change the file type to linker command file.
III. Add the found file in the project folder.
Step 16:
I. To create Source file, go to File → New source file [ C source/ C++ source]
II. Type the codes.
III. Add the source file to the project similar to Step 15.

Step 17: Go to Project → Build options.


I. Complier 7ab: Basic: Give target version: C671X – (- mv6710)
Advanced: Endianness: little endian
Feedback: inter listing: C and ASM
Filter: Copy obj. directory onto ASM directory
II. Linker 7ab: output filename: Remove ‘*\ Debug’ and paste the obj.directory copied
earlier.
Copy the same under map filename.
III. Click OK.

Step 18: Go to Project → Rebuild All.

Step 19: Upon compilation, go to debug → Run.


Step 20: To view the graph output,

Go to view → graph → time-frequency.


Step 21: If the values of a variable have to be checked, right click on it and add to watch
window.
Step 22: Change graph properties according to the specifications.
EXPT NO:2
DATE:

MAC OPERATION

AIM:
To perform MAC operation using Code Composer Studio.

APPARATUS REQUIRED:
 VMWare software
 CC Studio.

THEORY :
Multiple-Accumulate (MAC) operation is the most often used operation in DSP. The processor
has specialised hardware to perform single cycle multiplication. An accumulator register is
included in DSP architecture. DSP processor instruction set includes an explicit MAC
instruction. Mac instruction distinguishes early DSP processor and general purpose processor(
GPP).

ALGORITHM:
1. Perform initial steps of CCS.
2. Type in the MAC program.
3. Rebuild all program.
4. Files to be added:
i. C: CCS → tutorial → dsk6713 → hello1 → hello → cmd
ii. C: C6750 → cgtools → lib → rts6750.lib
5. Run the program.
6. Give necessary inputs.

PROGRAM:

% mac operation
//dotpfunc.c Optimized dot product function
intdotpfunc(const short *a, const short *b, intncount)
{
int sum = 0;
inti;
_nassert((int)(a)%4 == 0);
_nassert((int)(b)%4 == 0);
_nassert((int)(ncount)%4 == 0);
for ( i = 0; i<ncount; i++)
{
sum += (a[i] * b[i]); //sum of products
}
return (sum); //return sum as result
}

//dotpopt.c Optimized dot product of two arrays


#include <stdio.h>
#include "dotp4.h"
#define count 4
short x[count] = {x_array}; //declare 1st array
short y[count] = {y_array}; //declare 2nd array
volatileint result = 0; //result
main()
{
result = dotpfunc(x,y,count); //call optimized function
printf("result = %d decimal \n", result); //print result
}

// header file:
/*#define x_array
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35
,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,
67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,
98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120
,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,
143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,1
65,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,18
7,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209
,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,
232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,2
54,255,256
/*#define y_array
256,255,254,253,252,251,250,249,248,247,246,245,244,243,242,241,240,239,238,237,236,235,2
34,233,232,231,230,229,228,227,226,225,224,223,222,221,220,219,218,217,216,215,214,213,21
2,211,210,209,208,207,206,205,204,203,202,201,200,199,198,197,196,195,194,193,192,191,190
,189,188,187,186,185,184,183,182,181,180,179,178,177,176,175,174,173,172,171,170,169,168,
167,166,165,164,163,162,161,160,159,158,157,156,155,154,153,152,151,150,149,148,147,146,1
45,144,143,142,141,140,139,138,137,136,135,134,133,132,131,130,129,128,127,126,125,124,12
3,122,121,120,119,118,117,116,115,114,113,112,111,110,109,108,107,106,105,104,103,102,101
,100,99,98,97,96,95,94,93,92,91,90,89,88,87,86,85,84,83,82,81,80,79,78,77,76,75,74,73,72,71,7
0,69,68,67,66,65,64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,3
9,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7
,6,5,4,3,2,1*/
#define x_array 1,2,3,4
#define y_array 1,2,3,4

OUTPUT:

RESULT:

Thus the MAC operation has been performed using CC Studio and outputs have been
verified.
EXPT NO:3
DATE:
GENERATION OF SIGNALS
AIM:

To generate the following signals using CC Studio:


1. Sine wave
2. Ramp wave
3. Square wave
4. Traingular wave

APPARATUS REQUIRED:
 VMWare software
 CC Studio.

ALGORITHM:
1. Perform initial steps of CCS.
2. Type in the sine wave generation program.
3. Rebuild all program.
4. Files to be added:
i. C: CCS → tutorial → dsk6713 → hello1 → hello → cmd
ii. C: C6750 → cgtools → lib → rts6750.lib
5. Compile, build and run the program.
6. Repeat the above process for ramp wave , square wave, triangular wave as well.
7. Record the output waves.

PROGRAM:

%Waveform generation

#include<stdio.h>
#include<math.h>
float a[500];
float b[500];
float c[500];
float d[500];
void main()
{
int i=0,j=0;

//sine wave
for(i=0;i<500;i++)
a[i]=sin(2*3.14*10000*i);

//square wave
for(i=0;i<500;){
for(j=0;j<10;j++) {
b[j]=1;
b[i]=b[j];
i++;
}
for(j=10;j<20;j++){
b[j]=-1;
b[i]=b[j];
i++;}
}

//ramp wave
for(i=0;i<200;){
for(j=0;j<10;j++){
c[j]=((2*j)-10);
c[i]=c[j];
i++;
}
}

//triangular wave
for(i=0;i<200;)
{
for(j=0;j<10;j++)
{
d[i]=((2*j)-10);
d[i]=d[j];
i++;
}
for(j=10;j<20;j++)
{
d[j]=(30-(2*j));
d[i]=d[j];
i++;
}
}
}

OUTPUT:
i) Triangular Wave:

ii) Square wave:


iii) Ramp wave:

iv) Sine wave:


RESULT:
Thus the sine wave, ramp wave, square wave, and triangular wave were generated using
CC studio and the output waveforms recorded.
EXPT NO:4
DATE:

LINEAR AND CIRCULAR CONVOLUTION

AIM:
To perform linear and circular convolution using Code Composer Studio.

APPARATUS REQUIRED:
 VMWare software
 CC Studio.

ALGORITHM:
1. Perform initial steps of CCS.
2. Type in the convolution program.
3. Rebuild all program.
4. Files to be added:
i. C: CCS → tutorial → dsk6713 → hello1 → hello → cmd
ii. C: C6750 → cgtools → lib → rts6750.lib
5. Compile, build and run the program.
6. Give necessary sequences for circular convolution.
7. Go to view → Graph; type in the necessary values in the time/frequency graph
properties to view the graph.

PROGRAM:

%Linear convolution
#include<stdio.h>
int m=4;
int n=4;
inti=0,j;
int x[10]={1,2,3,4,0,0,0,0};
int h[10]={1,2,3,4,0,0,0,0};
int y[10];
main()
{
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:

PROGRAM:

% circular convolution
#include<stdio.h>
intm,n,x[30],h[30],y[30],i,j, k,x2[30],a[30];
void main(){
printf(" enter the length of the first sequence\n");
scanf("%d",&m);
printf(" enter the length of the second sequence\n"
scanf("%d",&n);
printf(" enter the first 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];

//Circular convolution
for(i=0;i<n;i++)
y[0]+=x[i]*a[i];
for(k=1;k<n;k++)
{
y[k]=0;

//circular shift
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];
}
}

//Displaying output
printf(" the circular convolution is\n");
for(i=0;i<n;i++)
printf("%d \t",y[i]);
}
OUTPUT:

RESULT:

Thus the linear and circular convolution is performed using Code Composer Studio for
the given sequences and the output has been verified.
EXPT NO:5
DATE:

IIR FILTER DESIGN USING CC STUDIO


AIM:
To design an IIR Filter: Chebyshev and Butterworth, using DSK TMS320C6713
processor.

APPARATUS REQUIRED:

1. VMWare software

2. CC Studio

THEORY:
The infinite impulse response of the IIR Filter is of an infinite duration.

Where,
y(n) – Impulse response of filter
x(n) – Input to the filter
akand bkare filter coefficients
The digital signal kit features the TMS320C6713 DSP, a 225 Mhz device delivering 1800 MIPS
and 1350 M flops.

PROCEDURE:
1. Start a new project. Create a new source file.
2. Go to new DSP/BIOS DSK6713 system MEMS and set no dynamic
heaps for memory.
3. Save the configuration.
4. Add files to project C6000 DSK6713 include dsk.aie23 and dsk6713 and
in lib dsk6713.
5. Go to add files to project and add the source file to the ‘ new project’ created under
‘my projects’.

6. Compile ,build and run the program.

PROGRAM:

%IIR filter
#include "Configuration1cfg.h"
#include "dsk6713.h"
#include "dsk6713_aic23.h"

/*float filter_Coeff[]={-0.0157524150924022,-0.0238685132826490,-
0.0181758635681563,1.02306744372008e-17, .0214805660350939, 0.0334159185957086
0.0262540251540036, -1.02306744372008e-17, -0.0337551751980046, -0.0556931976595143,
-0.0472572452772064, 1.02306744372008e-17, 0.0787620754620107, 0.167079592978543,
0.236286226386032, 0.262448010933082, 0.236286226386032, 0.167079592978543,
0.0787620754620107, 1.02306744372008e-17, -0.0472572452772064, -0.0556931976595143,
-0.0337551751980046, -1.02306744372008e-17, 0.0262540251540036, 0.0334159185957086,
0.0214805660350939, 1.02306744372008e-17, -0.0181758635681563,-0.0238685132826490,-
0.0157524150924022};*/
const signed intfilter_Coeff[]=
{
//12730,-12730,12730,2767,-18324,21137 /*HP 2500 */
//312,312,312,32767,-27943,24367 /*LP 800 */
1455,1455,1455,32767,-23140,21735 /* LP 2500 */
//9268,-9268,9268,32767,-7395,18367 /*HP 4000 */
//7215,-7215,7215,32767,5039,6171, /* HP 7000 */
};

DSK6713_AIC23_Config config={
0x0017,
0x0017,
0x00d8,
0x00d8,
0x0011,
0x0000,
0x0000,
0x0043,
0x0081,
0x0001
};

void main()
{
DSK6713_AIC23_CodecHandle hCodec;
intl_input, r_input, l_output, r_output;
DSK6713_init();
hCodec = DSK6713_AIC23_openCodec(0,&config);
DSK6713_AIC23_setFreq(hCodec,3);
while(1) {
while (!DSK6713_AIC23_read(hCodec,&l_input));
while (!DSK6713_AIC23_read(hCodec,&r_input));
l_output = IIR_FILTER(&filter_Coeff,l_input);
r_output = l_output;
while(!DSK6713_AIC23_write(hCodec,l_output));
while(!DSK6713_AIC23_write(hCodec,r_output));
}
DSK6713_AIC23_closeCodec(hCodec);
}
signedint IIR_FILTER(const signed int *h,signedint x1)
{
static signed int x[6]={0,0,0,0,0,0};
static signed int y[6]= {0,0,0,0,0,0};
int temp=0;
temp =(short int)x1;
x[0]=(signed int) temp;
temp = ( (int)h[0]*x[0]);
temp += ( (int)h[1]*x[1]);
temp += ( (int)h[1]*x[1]);
temp += ( (int)h[2]*x[2]);
temp -= ( (int)h[4]*y[1]);
temp -= ( (int)h[4]*y[1]);
temp -= ( (int)h[5]*y[2]);

temp>>=15;

if(temp>32767){
temp=32767;
}
else if (temp<-32767){
temp = -32767;
}
y[0]=temp;
y[2]=y[1];
y[1]=y[0];
x[2]=x[1];
x[1]=x[0];
return (temp<<2);
}

TABULATION:

i) Low pass filter:

Frequency (Hz) Voltage (V)

ii) High pass filter:

Frequency (Hz) Voltage(V)


iii) Band pass filter:

Frequency (Hz) Voltage(V)

iv) Band stop filter:

Frequency (Hz) Voltage(V)


RESULT:
Thus IIR Filter has been designed and the response of lowpass filter, highpass filter,
bandpass filter and bandstop filter has been recorded and tabulated, for butterworth, Chebyshev
types of filters.
EXPT NO:6
DATE :
FIR IMPLEMENTATION USING CCS

AIM:
To perform and design FIR lowpass ,highpass ,bandpass and bandstop filters using
TMS320C6713 DSP processor.

APPARATUS REQUIRED:

1. VMWare software

2. CC Studio

THEORY:
FIR have linear phase response. The transfer function is given by

It is a non feedback ,non recursive and a stable filter and can be realized with recursive and non
recursive structures.It is free of oscillations .

PROCEDURE:
7. Start a new project. Create a new source file.
8. Go to new DSP/BIOS DSK6713 system MEMS and set no dynamic
heaps for memory.
9. Save the configuration.
10. Add files to project C6000 DSK6713 include dsk.aie23 and dsk6713 and
in lib dsk6713.
11. Go to add files to project and add the source file to the ‘ new project’ created under
‘my projects’.

12. Compile ,build and run the program.


PROGRAM:
%FIR Filter
#include "Configuration1cfg.h"
#include "dsk6713.h"
#include"dsk6713_aic23.h"
/*float b[]={-0.0157524150924022,-0.0238685132826490,-
0.0181758635681563,1.02306744372008e-17, .0214805660350939, 0.0334159185957086,
0.0262540251540036, -1.02306744372008e-17, -0.0337551751980046, -
0.0556931976595143, -0.0472572452772064, 1.02306744372008e-
17,0.0787620754620107, 0.167079592978543, 0.236286226386032, 0.262448010933082,
0.236286226386032, 0.167079592978543, 0.0787620754620107, 1.02306744372008e-
17, -0.0472572452772064, -0.0556931976595143, -0.0337551751980046, -
1.02306744372008e-17, 0.0262540251540036, 0.0334159185957086,
0.0214805660350939, 1.02306744372008e-17, -0.0181758635681563,-
0.0238685132826490,-0.0157524150924022};*/\

float b[]={-0.0089819,-0.017782,-0.02502,-0.029339,-0.029569,-0.024895,-0.01497,5.3894e-
018,0.019247,0.041491,0.065053,0.088016,0.10842,0.12447,0.13473,0.13825,0.13473,0.12447,
0.10842,0.088016,0.065053,0.041491,0.019247,5.3894e-018,-0.01497,-0.024895,-0.029569,-
0.029339,-0.02502,-0.017782,-0.0089819};

/*float b[]={.0219418373499807, 0.0131942631153908, -4.27515006108374e-17,


-0.0169640525769310, -0.0365697289166346, -0.0573367841256520, -
0.0775761099093182, -0.0955613068760867, -0.109709186749904, -
0.118748368038517, 0.852993879448159, -0.118748368038517, -0.109709186749904, -
0.0955613068760867, -0.0775761099093182, -0.0573367841256520, -
0.0365697289166346, -0.0169640525769310, -4.27515006108374e-
17,0.0131942631153908, 0.0219418373499807};*/\
static short in_buffer[100];

DSK6713_AIC23_Config config={\

0x0017, /* 0 DSK6713_AIC23_LEFTINVOL Leftline input channel volume*/\


0x0017, /* 1 DSK6713_AIC23_RIGHTINVOL Rightline input channel volume*/\
0x00d8, /* 2 DSK6713_AIC23_LEFTHPVOL LEFT CHANNEL HEADPHONE volume*/\
0x00d8, /* 3 DSK6713_AIC23_RIGHTHPVOL Right Channel Headphone Volume*/\
0x0011, /*4 DSK6713_AIC23_ANAPATH Analog audio path control*/\
0x0000, /*5 DSK6713_AIC23_DIGPATH Digital audio path control*/\
0x0000, /*6 DSK6713_AIC23_POWERDOWN Powerdowncontrol*/\
0x0043, /*7 DSK6713_AIC23_DIGIF digital audio interface format*/\
0x0081, /*8 DSK6713_AIC23_SAMPLERATE sampleratecontrol*/\
0x0001 /* 9DSK6713_AIC23_DIGACT Digital Interface Activation*/\};

void main(){
DSK6713_AIC23_CodecHandle hCodec;
Uint32 l_input,r_input,l_output,r_output;
DSK6713_init();
hCodec=DSK6713_AIC23_openCodec(0,&config);
DSK6713_AIC23_setFreq(hCodec,1);
while(1){
while(!DSK6713_AIC23_read(hCodec,&l_input));
while(!DSK6713_AIC23_read(hCodec,&r_input));
l_output = (Int16)FIR_FILTER(&b,l_input);
r_output = l_output;
while(!DSK6713_AIC23_write(hCodec,l_output));
while(!DSK6713_AIC23_write(hCodec,r_output));
}
DSK6713_AIC23_closeCodec(hCodec);
}
signedint FIR_FILTER(float *h,signedint x)
{
inti=0;
signed long output =0;
in_buffer[0] = x;
for(i=30;i>0;i--)
in_buffer[i] = in_buffer[i-1];
for(i=0;i<32;i++)
output = output+ h[i]*in_buffer[i];
return(output);
}
TABULATION:

i) Low pass filter:

Frequency (Hz) Voltage (V)

ii) High pass filter:

Frequency (Hz) Voltage(V)


iii) Band pass filter:

Frequency (Hz) Voltage(V)

iv) Band stop filter:

Frequency (Hz) Voltage(V)


RESULT:
Thus FIR Filter has been designed and the response of lowpass filter, highpass filter,
bandpass filter and bandstop filter has been recorded and tabulated.
EXPT NO:7
DATE:

IMPLEMENTATION OF FINITE WORD LENGTH EFFECTS

AIM:

To perform rounding off using code composer studio using simulation method.

APPARATUS REQUIRED:

1. VMWare software

2. CC Studio

ALGORITHM:

1. Open CCS setup and follow general setup procedure.


2. Create source file after creating new project file.
3. Add the source file and linker file(hello.cmd).
4. Load the program and run it.
5. Type a decimal number and the rounded off number is obtained.

PROGRAM:

%Finite word length


#include<stdio.h>
int main()
{
float x;
int n;
printf("enter a real number");
fflush(stdout);
scanf("%f",&x);
n=(int)(x+0.5);
printf("%f rounded==%d\n",x,n);
return 0;
}
OUTPUT:

RESULT:

Thus, rounding off of a floating arithmetic was performed using code composer studio and
output was recorded.

You might also like