Digital Signal Processing Lab Guide
Digital Signal Processing Lab Guide
DEPARTMENT
OF
LABORATORY OBSERVATION
Student Name :
Register No. :
Branch : ECE
Year / Semester : II / IV
Regulation : R-2021
EC3492 DIGITAL SIGNAL PROCESSING LABORATORY R 2021
LABORATORY RECORD
REGISTER NO:
SYLLABUS
COURSE OUTCOMES
At the end of the course, the student will be able to
CO1: Apply DFT for the analysis of digital signals and systems
CO2: Design IIR and FIR filters
CO3: Characterize the effects of finite precision representation on digital filters
CO4: Design multirate filters
CO5: Apply adaptive filters appropriately in communication systems
EC3492 DIGITAL SIGNAL PROCESSING LABORATORY R 2021
EC3492 DIGITAL SIGNAL PROCESSING LABORATORY
LIST OF EXPERIMENTS:
1
INDEX
2
MATLAB / EQUIVALENT SOFTWARE
PACKAGE
3
4
[Link].:1 GENERATION OF ELEMENTARY DISCRETE-TIME
SEQUENCES
Date:
AIM:
To generate discrete-time impulse signal, step signal, ramp signal, ex[ponential, sine and
cosine signals using MATLAB
OBJECTIVE:
MATHEMATICAL REPRESENTATION:
ALGORITHM:
Generation of Sequences
5
OUTPUT:
Generation of Sequences
6
PROGRAM:
Generation of Sequences
clc;
clear all;
%. Generation of Sequences
%Program
n=[-4:4];
a=[-6:6];
x=(n==0);
a=input('enter the value of x');
subplot(2,3,1);
stem(n,x);
title('Impulse Response');
xlabel('n');
ylabel('amplitude');
n=[-4:4];
y=(n>=0);
subplot(2,3,2);
stem(n,y);
title('Step Response');
xlabel('n');
ylabel('amplitude');
n=[0:4];
z=(n>=0);
z=[0.9*n];
subplot(2,3,3);
stem(n,z);
title('ramp Response');
xlabel('n');
ylabel('amplitude');
n=[0:4];
b=(a.^n);
subplot(2,3,4);
stem(n,b);
title('Exponential');
xlabel('n');
ylabel('amplitude');
n=[-2:2];
a=0:0.1:pi;
y=sin(2*pi*a);
subplot(2,3,5);
plot(a,sin(2*pi*a));
title('Sine');
xlabel('n');
ylabel('amplitude');
7
n=[-2:2];
a=0:0.1:pi;
y=cos(2*pi*a);
subplot(2,3,6);
plot(a,y);
title('cosine');
xlabel('n');
ylabel('amplitude');
RESULT:
Thus the generation of sequence signals (impulse, step, ramp, exponential, sine and cosine)
are performed using MATLAB and output waveforms are plotted.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
APPLICATIONS:
1. Used to generate training signals in communication systems
2. Used to scramble and descramble data in communication systems
3. Used to generate additive dither in data converters
VIVA QUESTIONS:
1. List the classification of signal.
2. Define analog signal, discrete-time signal and digital signal.
3. What is random signal?
4. Define the unit step signal.
5. What is the use of Random signal?
6. Give the relation between unit step and unit ramp signal.
7. Differentiate CT and DT signal.
8. Express the difference between CT and DT signal.
8
REFERENCES:
1. Sanjit K. Mitra, “Digital Signal Processing – A Computer Based Approach”, Tata Mc
Graw Hill, 2007.
2. [Link] Babu, “Digital Signal Processing”, Scitech Publications [Link], 2010.
3. Poorna Chandra S, Sasikala. B ,Digital Signal Processing, Vijay Nicole/TMH,2013.
9
10
[Link].:2
LINEAR CONVOLUTION AND CIRCULAR
Date: CONVOLUTION
AIM:
1. To perform linear convolution of two sequences using MATLAB.
2. To perform circular convolution of two sequences using MATLAB.
OBJECTIVE:
To illustrate the students about circular and linear convolutions.
ALGORITHM:
Linear Convolution
Circular Convolution
1. Enter the input sequences x1(n) and x2(n).
2. Give the length of the maximum length sequence.
3. Determine the DFT values of both the sequences. {i.e., X1(k) and X2(k)}
4. Multiply the DFT values X1(k) and X2(k). The result is X3(k).
5. Find the IDFT value of X3(k). {i.e., x3(m)}
6. Plot the sequences x1(n), x2(n) and x3(m).
PROGRAM:
Linear Convolution:
clc;
clear all;
%Linear convolution
x=input('Enter the input sequence: ');
h=input('Enter the impulse response: ');
y=conv(x,h);
subplot(3,1,1);
stem(x);
display(x);
title('INPUT SEQUENCE');
xlabel('n-time');
ylabel('amplitude x[n]');
grid;
11
Linear Convolution output
12
subplot(3,1,2);
stem(h);
display(h);
title('IMPULSE RESPONSE');
xlabel('n-time');
ylabel('amplitude h[n]');
grid;
subplot(3,1,3);
stem(y);
disp(y);
title('CONVOLUTION SUM OUTPUT');
xlabel('n-time');
ylabel('amplitude y[n]');
grid;
2. Circular Convolution
clc;
clear all;
%circular convolution
%Program
x1=input('Enter the first input sequence:');
x2=input('Enter the second input sequence:');
X1=fft(x1);
X2=fft(x2);
X3=X1*X2;
x3=ifft(X3);
subplot(3,1,1);
stem(x1);
title('FIRST SEQUENCE x1[n]');
xlabel('Time-n');
ylabel('Amplitude x1[n]');
grid;
display(x1);
subplot(3,1,2);
stem(x2);
title('SECOND SEQUENCE x2[n]');
xlabel('Time-n');
ylabel('Amplitude x2[n]');
grid;
display(x2);
subplot(3,1,3);
stem(abs(x3));
13
Circular Convolution output
x1(n) = 3 9 4 2
x2(n) = 1 5 5 1
x3(n) = 42 38 66 70
14
title('OUTPUT SEQUENCE x3[n]');
xlabel('Time-n');
ylabel('Amplitude x3[n]');
grid;
display(x3);
RESULT:
Thus the linear and circular convolution of two sequences is performed and plotted using
MATLAB.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
APPLICATIONS:
1. Digital image processing
2. Digital data processing
3. Acoustics
4. Radiotherapy treatment planning systems
VIVA QUESTIONS:
1. What is sampling theorem?
2. What is an LTI system?
3. What is convolution?
4. Define circular convolution.
5. What is meant by linear convolution or discrete convolution?
6. What are the properties of convolution?
7. How the circular convolution is obtained?
8. What is the difference between linear and circular convolution?
9. What is the difference between convolution and filter?
10. Write the difference between built in function, plot and stem.
REFERENCES:
1. Sanjit K. Mitra, “Digital Signal Processing – A Computer Based Approach”, Tata Mc
Graw Hill, 2007.
2. [Link] Babu, “Digital Signal Processing”, Scitech Publications [Link], 2010.
3. Poorna Chandra S, Sasikala. B ,Digital Signal Processing, Vijay Nicole/TMH,2013.
15
16
[Link].:3
AUTO CORRELATION AND CROSS CORRELATION
Date:
AIM:
1. To plot the autocorrelation sequence of a sine wave with frequency 1 Hz, sampling
frequency of 200 Hz.
2. To plot crosscorrelation of the following signal:
x(n) = sin (2πf1t) with f1 = 1Hz, y(n) = x(n) + w(n), where w(n) is a zero mean, unit
variance of Gaussian random process.
OBJECTIVE:
To familiarize the students about the difference between autocorrelation and cross-
correlation.
ALGORITHM:
Autocorrelation
1. Initialize the no of samples.
2. Generate the signal, x(n)
3. Plot the signals by creating subplots.
4. Give the title, x axis label and y axis label for the plotted signal.
Crosscorrelation
1. Initialize the no of samples.
2. Generate the signal, x(n)
3. Plot the signals by creating subplots.
4. Give the title, x axis label and y axis label for the plotted signal
PROGRAM:
Autocorrelation:
clc;
clear all;
%Autocorrelation
%Program
N=1024;
f1=1;
Fs=200;
n=0:N-1;
x=sin(2*pi*f1*n/Fs);
t=[1:N]*(1/Fs);
subplot(2,1,1);
plot(t,x);
title('Sinwave of frequency 1Hz [Fs=200Hz]');
17
Autocorrelation Output
18
xlabel('time,[s]');
ylabel('amplitude');
grid;
Rxx=xcorr(x);
subplot(2,1,2);
plot(Rxx);
grid;
title('Autocorrelation function of the sinewave');
xlabel('lags');
ylabel('Autocorrelation');
Crosscorrelation
clc;
clear all;
%crosscorrelation
%Program
N=1024;
f1=1;
FS=200;
n=0:N-1;
x=sin(2*pi*f1*n/FS);
y=x+10*randn(1,N);
subplot(3,1,1);
plot(x);
title('x(n),Pure Sinewave');
xlabel(‘time,[s]’);
ylabel(‘amplitude’);
grid;
subplot(3,1,2);
plot(y);
title('y(n),pure sinewave+noise');
xlabel(‘time,[s]’);
ylabel(‘amplitude’);
grid;
Rxy=xcorr(x,y);
subplot(3,1,3);
plot(Rxy);
title('cross correlation Rxy');
xlabel(‘lags’);
ylabel(‘Crosscorrelation’)
19
Crosscorrelation Output
20
INFERENCE AND DISCUSSIONS:
RESULT:
Thus the autocorrelation and crosscorrelation of a given signal is performed and plotted.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
APPLICATIONS:
1. Radar and sonar systems
2. Matched filtering
3. Signal detector
VIVA QUESTIONS:
REFERENCES:
1. Sanjit K. Mitra, “Digital Signal Processing – A Computer Based Approach”, Tata Mc
Graw Hill, 2007.
2. [Link] Babu, “Digital Signal Processing”, Scitech Publications [Link], 2010.
3. J.G. Proakis and D.G. Manolakis, ‘Digital Signal Processing Principles, Algorithms and
Applications’, Pearson Education, New Delhi, PHI. 2003.
21
22
[Link].:4
FREQUENCY ANALYSIS USING DFT
Date:
AIM:
To compute Discrete Fourier Transform(DFT) of a given sequence and to reconstruct the
original sequence MATLAB.
OBJECTIVE:
To enable the students to compute DFT & IDFT of a given sequence.
ALGORITHM:
1. Fix the length of DFT.
2. Enter the values of input signal x(n) .
3. Find the DFT X (k) of the given sequence using ‘FFT’ function.
4. Determine the magnitude and phase values of X(k) using ‘abs’ and ‘angle’ functions.
5. The IDFT of the sequence X(k) is determined by ‘IFFT’ function.
6. Plot the input sequence x(n), magnitude spectrum |X(k)|, phase spectrum and IDFT of
X(k).
PROGRAM:
Computation of DFT and IDFT
clc;
clear all;
% DFT computation
%Program
n=4;
x=input('enter the input sequence:');
y=fft(x);
subplot(2,2,1);
stem(x);
display(x);
title('INPUT SEQUENCE x[n]');
xlabel('n-time');
ylabel('amplitude x[n]');
grid;
subplot(2,2,2);
stem(abs(y));
display(abs(y));
title(‘Magnitude spectrum of DFT’);
xlabel('n-time');
ylabel('amplitude');
grid;
23
DFT and IDFT output
Magnitude response:
y(n) = 30.0000 8.4853 6.0000 8.4853
Phase response:
y(n) = 0 2.3562 3.1416 -2.3562
Original sequence:
z(n) = 3 6 9 12
24
subplot(2,2,3);
stem(angle(y));
display(angle(y));
title(' Phase spectrum of DFT');
xlabel('n-time');
ylabel('rad angle ');
grid;
z=ifft(y);
subplot(2,2,4);
stem(abs(z));
display(abs(z)’);
title(original sequence,IDFT');
xlabel('n-time');
ylabel('amplitude,z[n]');
grid;
RESULT:
Thus the DFT and IDFT of the given sequence are determined using MATLAB.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
APPLICATIONS:
1. Spectral analysis of signals
2. Frequency Response of systems
3. Convolution via the frequency domain
VIVA QUESTIONS:
1. How to calculate output of DFT using MATLAB?
2. Where DFT is used?
3. When the DFT X(k) of a sequence x(n) is imaginary?
4. When the DFT X(k) of a sequence x(n) is real?
5. What is zero padding? What are its uses?
6. What is the difference between DFT and DTFT?
7. Distinguish between Fourier series and Fourier transform.
8. What do you mean by phase spectrum and magnitude spectrum?
25
REFERENCES:
1. Sanjit K. Mitra, “Digital Signal Processing – A Computer Based Approach”, Tata Mc
Graw Hill, 2007.
2. [Link] Babu, “Digital Signal Processing”, Scitech Publications [Link], 2010
3. J.G. Proakis and D.G. Manolakis, ‘Digital Signal Processing Principles, Algorithms and
Applications’, Pearson Education, New Delhi, PHI. 2003.
26
[Link].:5
DESIGN OF FIR FILTERS (LPF/HPF/BPF/BSF) AND
DEMONSTRATE THE FILTERING OPERATION
Date:
AIM:
To design a Finite Impulse Response (FIR) filter (LPF/HPF/BPF/BSF) and demonstrate
the filtering operation by various windowing technique using MATLAB.
OBJECTIVE:
To enable the students design a Finite Impulse Response (FIR) filter using various
windowing technique.
ALGORITHM:
1. Calculate the cut-off frequency.
2. Enter the length of an FIR filter.
3. Calculate the phase delay.
4. Determine the range of values for ‘n’
5. Determine the infinite impulse response using phase delay and ‘n’ values
5. Display the order and analog filter coefficients.
6. Convert the analog filter into a digital filter using ‘bilinear’ function.
7. Display the coefficients of digital filter.
8. Find the frequency response using ‘freqz’ function.
9. Plot the magnitude and phase response using ‘abs’ and ‘angle’ functions.
PROGRAM:
FIR Filter Using Windowing Technique
clc;
clear all;
%fir filter using windows
%program
rp=input('enter the pass band ripple=');
rs=input('enter the stop band ripple=');
fp=input('enter the pass band frequency=');
fs=input('enter the stop band frequency=');
F=input('sampling frequency=');
wp=2*fp/F;
ws=2*fs/F;
num=20*log(sqrt(rp*rs))-13;
den=14.6*(fs-fp)/F;
n=ceil(num/den);
n1=n+1;
if(rem(n,2)~=0)
27
FIR Filter output
28
n1=n;
n=n-1;
end;
y=hamming(n1);
%y=hanning(n1);
%y=bartlett(n1);
%y=boxcar(n1);
%y=blackman(n1);
%y=rectwin(n1);
B=fir1(n,wp,y);
[h,a]=freqz(B,1,256);
M=20*log(abs(h));
subplot(2,2,1);
plot(M);
title('low pass filter');
xlabel('normalized frquency');
ylabel('gain in db');
B=fir1(n,wp,'high',y);
[h,a]=freqz(B,1,256);
M=20*log(abs(h));
subplot(2,2,2);
plot(M);
title('high pass filter');
xlabel('normalized frquency');
ylabel('gain in db');
wn=[wp,ws];
B=fir1(n,wn,y);
[h,a]=freqz(B,1,256);
M=20*log(abs(h));
subplot(2,2,3);
plot(M);
title('band pass filter');
xlabel('normalized frquency');
ylabel('gain in db');
B=fir1(n,wn,'stop',y);
[h,a]=freqz(B,1,256);
M=20*log(abs(h));
subplot(2,2,4);
plot(M);
title('band stop filter');
xlabel('normalized frquency');
ylabel('gain in db');
29
FIR Filter using Bartlett window:
30
FIR Filter using Blackman window:
31
INFERENCE AND DISCUSSIONS:
RESULT:
Thus FIR filter is designed using various windowing techniques and the frequency
response is plotted using MATLAB program.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
APPLICATIONS:
1. Radar system
2. Used in Digital communication
3. Speech processing
4. Image processing
VIVA QUESTIONS:
1. What are the different types of filters based on impulse response?
2. What are the different types of filters based on frequency response?
3. What are FIR filters?
4. What are the techniques of designing FIR filters?
5. What are the advantages of FIR Filters
6. Why is the impulse response "finite"?
7. What are the disadvantages of FIR Filters?
8. What is the reason that FIR filter is always stable?
9. List the properties of FIR filter.
10. What is the basis for Fourier series method of design? Why truncation is necessary?
REFERENCES:
1. Sanjit K. Mitra, “Digital Signal Processing – A Computer Based Approach”, Tata Mc
Graw Hill, 2007.
2. [Link] Babu, “Digital Signal Processing”, Scitech Publications [Link], 2010
3. J.G. Proakis and D.G. Manolakis, ‘Digital Signal Processing Principles, Algorithms and
Applications’, Pearson Education, New Delhi, PHI. 2003.
32
[Link].:6 DESIGN OF BUTTERWORTH AND CHEBYSHEV IIR
FILTERS (LPF/HPF/BPF/BSF) AND DEMONSTRATE THE
Date: FILTERING OPERATIONS
AIM:
To design an analog and digital Chebyshev & Butterworth IIR filter (LPF/HPF/BPF/BSF)
and demonstrate the filtering operation using MATLAB.
OBJECTIVE:
To make the students to design both analog and digital Chebyshev & Butterworth IIR
filter using MATLAB.
ALGORITHM:
Analog Chebyshev IIR filter
33
Analog Chebyshev IIR filter output
34
PROGRAM:
Analog Chebyshev IIR filter
clc;
clear all;
close all;
%Analog Chebychev IIR filter
rp=input('passband ripple=');
rs=input('stopband ripple=');
wp=input('passband cutoff freq.=');
ws=input('stop band cuttoff freq.=');
fs=1;
[N,wn]=cheb1ord(wp,ws,rp,rs,'s');
display(N);
[B,A]=cheby1(N,rp,wp,'low','s');
display(A);
display(B);
h=freqs(B,A);
M =20.*log10(abs(h));
An=angle(h);
subplot(4,2,1);
plot(M);
title('low pass filter-magnitude response');
xlabel('normalised frequency');
ylabel('gain in db');
grid;
subplot(4,2,2);
plot(An);
title('low pass filter-phase response');
xlabel('normalized frequency');
ylabel('phase in radian');
grid;
[B,A]=cheby1(N,rp,wp,'high','s');
display(A);
display(B);
h=freqs(B,A);
M =20.*log10(abs(h));
An=angle(h);
subplot(4,2,3);
plot(M);
title('high pass filter-magnitude response')
xlabel('normalized frequency');
ylabel('gain in db');
grid;
subplot(4,2,4);
plot(An);
title('High pass filter-phase response');
xlabel('normalized frequency');
ylabel('phase in radian');
grid;
wn=[wp,ws];
[B,A]=cheby1(N,rp,wn,'bandpass');
35
display(A);
display(B);
h=freqs(B,A);
M =20.*log10(abs(h));
An=angle(h);
subplot(4,2,5);
plot(M);
title('band pass filter-magnitude response')
xlabel('normalized frequency');
ylabel('gain in db');
grid;
subplot(4,2,6);
plot(An);
title('band pass filter-phase response');
xlabel('normalized frequency');
ylabel('phase in radian');
grid;
wn=[wp,ws];
[B,A]=cheby1(N,rp,wn,'stop');
display(A);
display(B);
h=freqs(B,A);
M =20.*log10(abs(h));
An=angle(h);
subplot(4,2,7);
plot(M);
title('band stop filter-magnitude response')
xlabel('normalized frequency');
ylabel('gain in db');
grid;
subplot(4,2,8);
plot(An);
title('band pass filter-phase response');
xlabel('normalized frequency');
ylabel('phase in radian');
grid;
36
PROGRAM:
Analog Butterworth IIR filter
clc;
clear all;
close all;
%Design of Analog Butterworth filter
Rp=input('Enter the pass band attenutation:');
Rs=input('Enter the stop band attenutation:');
wp=input('Enter the pass band cutoff frequency:');
ws=input('Enter the stop band cutoff frequency:');
[N,wn]=buttord(wp, ws, Rp, Rs, 's');
display(N);
[B,A]=butter(N,wn,'low',’s’);
display(A);
display(B);
H=freqs(B,A);
M=20*log(abs(H));
An=angle(H);
subplot(4,2,1);
plot(M);
title('low pass filter-magnitude response');
xlabel('normalized frequency');
ylabel('gain in db');
grid;
subplot(4,2,2);
plot(An);
title('low pass filter-phase response');
xlabel('normalized frequency');
ylabel('phase in radian');
grid;
[B,A]=butter(N,wn,'high',’s’);
display(A);
display(B);
H=freqs(B,A);
M=20*log(abs(H));
An=angle(H);
subplot(4,2,3);
plot(M);
title('high pass filter-magnitude response');
xlabel('normalized frequency');
ylabel('gain in db');
grid;
subplot(4,2,4);
plot(An);
title('high pass filter-phase response');
37
Analog Butterworth IIR filter output
38
xlabel('normalized frequency');
ylabel('phase in radian');
grid;
wn=[wp,ws]
[B,A]=butter(N,wn,'bandpass',’s’);
display(A);
display(B);
H=freqs(B,A);
M=20*log(abs(H));
An=angle(H);
subplot(4,2,5);
plot(M);
title('band pass filter-magnitude response');
xlabel('normalized frequency');
ylabel('gain in db');
subplot(4,2,6);
plot(An);
title('band pass filter-phase response');
xlabel('normalized frequency');
ylabel('phase in radian');
grid;
[B,A]=butter(N,wn,'stop',’s’);
display(A);
display(B);
H=freqs(B,A);
M=20*log(abs(H));
An=angle(H);
subplot(4,2,7);
plot(M);
title('band stop filter-magnitude response');
xlabel('normalized frequency');
ylabel('gain in db');
grid;
subplot(4,2,8);
plot(An);
title('band stop filter-phase response');
xlabel('normalized frequency');
ylabel('phase in radian');
grid;
39
Digital Chebyshev IIR filter using Impulse Invariant Technique output
40
ALGORITHM:
Digital Chebyshev IIR filter
PROGRAM:
Digital Chebyshev IIR filter using Bilinear and Impulse Invariant Transforms method
clc;
close all;
%digital chebychev IIR filter
%Program
rp=input('passband ripple=');
rs=input('stopband ripple=');
wp=input('passband cutoff freq.=');
ws=input('stop band cuttoff freq.=');
fs=1;
[N,wn]=cheb1ord(wp,ws,rp,rs,'s');
display(N);
[B,A]=cheby1(N,rp,wp,'low');
41
Digital Chebyshev IIR filter using Bilinear Transformation method output
42
display(A);
display(B);
%converting analog to digital filter using bilinear and impulse invariant transforms method
[Bt,At]=bilinear(B,A,fs);
%[Bt,At]=impinvar(B,A,fs);
h=freqz(Bt,At);
M =20*log10(abs(h));
An=angle(h);
subplot(4,2,1);
plot(M);
title('low pass filter-magnitude response');
xlabel('normalised frequency');
ylabel('gain in db');
grid;
subplot(4,2,2);
plot(An);
title('low pass filter-phase response');
xlabel('normalized frequency');
ylabel('phase in radian');
grid;
[B,A]=cheby1(N,rp,wp,'high');
display(A);
display(B);
%converting analog to digital filter using bilinear and impulse invariant transforms method
%[Bt,At]=bilinear(B,A,fs);
[Bt,At]=impinvar(B,A,fs);
h=freqz(Bt,At);
M =20*log10(abs(h));
An=angle(h);
subplot(4,2,3);
plot(M);
title('high pass filter-magnitude response')
xlabel('normalized frequency');
ylabel('gain in db');
grid;
subplot(4,2,4);
plot(An);
title('High pass filter-phase response');
xlabel('normalized frequency');
ylabel('phase in radian');
grid;
wn=[wp,ws];
[B,A]=cheby1(N,rp,wn,'bandpass','s');
display(A);
display(B);
43
Digital Butterworth IIR filter using Bilinear Transformation method output
44
%converting analog to digital filter using bilinear and impulse invariant transforms method
%[Bt,At]=bilinear(B,A,fs);
[Bt,At]=impinvar(B,A,fs);
h=freqz(Bt,At);
M =20*log10(abs(h));
An=angle(h);
subplot(4,2,5);
plot(M);
title('band pass filter-magnitude response')
xlabel('normalized frequency');
ylabel('gain in db');
grid;
subplot(4,2,6);
plot(An);
title('band pass filter-phase response');
xlabel('normalized frequency');
ylabel('phase in radian');
grid;
[B,A]=cheby1(N,rp,wn,'bandstop','s');
display(A);
display(B);
%converting analog to digital filter using bilinear and impulse invariant transforms method
%[Bt,At]=bilinear(B,A,fs);
[Bt,At]=impinvar(B,A,fs);
h=freqz(Bt,At);
M =20*log10(abs(h));
An=angle(h);
subplot(4,2,7);
plot(M);
title('band stop filter-magnitude response')
xlabel('normalized frequency');
ylabel('gain in db');
grid;
subplot(4,2,8);
plot(An);
title('band pass filter-phase response');
xlabel('normalized frequency');
ylabel('phase in radian');
grid;
45
Digital Butterworth IIR filter using Impulse Invariant Transformation method output
46
INFERENCE AND DISCUSSIONS:
RESULT:
Thus the analog and digital Chebyshev & Butterworth IIR filters (LPF/HPF/BPF/BSF) are
designed and the frequency response is plotted using MATLAB program.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
APPLICATIONS:
1. Medical applications
2. Speech processing
3. Image processing
V IVA QUESTIONS:
1. How can one design digital filters from analog filters?
2. What are low-pass and band-pass filters and what is the difference between these two?
3. Differentiate IIR filters and FIR filters.
4. Difference between chebyshev and butterworth filters.
5. What are the applications of MATLAB?
6. What are the properties of chebyshev filter?
7. What are the parameters that can be obtained from the chebyshev filter specification?
8. Give any two properties of butterworth filters?
9. Mention any two procedures for digitizing the transfer function of an analog filter.
10. What is bilinear transformation?
11. What are the properties that are maintained same in the transfer of analog filter into a
digital filter?
12. What are the properties of bilinear transformation?
13. What are the advantages and disadvantages of bilinear transformation?
14. How one can design digital filters from analog filters?
15. What is warping effect?
16. What is meant by impulse invariant method of designing IIR filter?
17. What is the advantage of cascade realization?
18. What is the main disadvantage of direct-form realization?
47
REFERENCES:
1. Sanjit K. Mitra, “Digital Signal Processing – A Computer Based Approach”, Tata Mc
Graw Hill, 2007.
2. [Link] Babu, “Digital Signal Processing”, Scitech Publications [Link], 2010
3. Poorna Chandra S, Sasikala. B ,Digital Signal Processing, Vijay Nicole/TMH,2013.
48
DSP PROCESSOR BASED
IMPLEMENTATION
49
50
[Link].:7
STUDY OF ARCHITECTURE OF DIGITAL SIGNAL
PROCESSOR
Date:
AIM:
To study the architecture of Digital Signal Processor Trainer kit TMS320C5416.
The 5416 DSP Trainer Kit (DSK) is a low-cost platform, which lets enables customers to
evaluate and develop applications for the TI C54X DSP family. The primary features of the DSK
are:
1. 160 MHz TMS320VC5416 DSP
2. PCM3002 Stereo Codec
3. Four Position User DIP Switch and Four User LEDs
4. On-board Flash and SRA
APPLICATIONS:
1. Machine Vision
2. Avionics & Defense
3. High Performance Computing (HPC)
VIVA QUESTIONS:
1. What is CCS? Explain in detail to execute a program using CCS?
2. Why do we need of CCS?
3. What are the factors that influence the selection of DSPs?
4. List the difference between microprocessor and DSP processor?
5. What are the advantages and disadvantages of VLIW architecture?
6. What are the different buses of TMS 320C5x processor? And list their functions.
7. List the on-chip peripherals of C5X processor.
REFERENCES:
1. Sanjit K. Mitra, “Digital Signal Processing – A Computer Based Approach”, Tata Mc
Graw Hill, 2007.
2. [Link] Babu, “Digital Signal Processing”, Scitech Publications [Link], 2010
53
[Link].:8
MAC OPERATION USING VARIOUS ADDRESSING
MODES
Date:
AIM:
To do MAC operation using various addressing modes using TMS320C5416 DSP
Trainer kit.
OBJECTIVE:
To understand the concepts of MAC operation for various addressing modes.
APPARATUS REQUIRED:
1. TMS320C5416 Trainer Kit
2. Personal computer
3. Cable
PROCEDURE
1. Open Code Composer Studio.
2. Connection Texas instruments XDS100V2USB emulator and board or device -5416.
3. Target user defined save the file.
4. The again in target configurations click file name launch.
5. CCS debug connect target.
6. CCS edit project new CCS project Type the program and save with .c extension.
CCS debug project explorer click the file name add command file to project.
7. Project Build all
8. RUN Load Load program Select the .OUT file and download it to the kit.
9. Execute the program by RUN Resume.
10. Execution is stopped by RUN suspend.
PROGRAM:
LED TOGGLE PROGRAM
RESULT:
Thus the MAC operation for various addressing modes is performed using TMS320C5416
DSP Trainer kit.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
APPLICATIONS:
1. Machine Vision
2. Avionics & Defense
3. High Performance Computing (HPC)
4. Video Encoding/Decoding
5. Biometrics
VIVA QUESTIONS:
1. What is CCS? Explain in detail to execute a program using CCS?
2. Why do we need of CCS?
3. Explain the entire CCS program in step by step of execution.
4. What are the factors that influence the selection of DSPs?
5. What are the advantages and disadvantages of VLIW architecture?
55
6. What is pipelining?
7. What are the stages of pipelining?
8. What are the different buses of TMS 320C5x processor? And list their functions.
9. What are the shift instructions in TMS 320 C5X?
10. List the on-chip peripherals of C5X processor.
REFERENCES:
1. Sanjit K. Mitra, “Digital Signal Processing – A Computer Based Approach”, Tata Mc
Graw Hill, 2007.
2. [Link] Babu, “Digital Signal Processing”, Scitech Publications [Link], 2010
3. Sen [Link], woonseng…[Link], “Digital Signal Processors, Architecture, Implementations
& Applications, Pearson,2013
56
[Link].:9
WAVEFORM GENERATION
Date:
AIM:
To generate various waveforms using TMS320C5416 DSP Starter kit.
OBJECTIVE:
1. To generate various types of discrete time signals.
2. To understand the characteristics of the signal.
APPARATUS REQUIRED:
1. TMS320C5416 trainer Kit
2. Personal computer
3. Cable
PROCEDURE:
1. Open Code Composer Studio.
2. Connection Texas instruments XDS100V2USB emulator and board or device -5416.
3. Target user defined save the file.
4. The again in target configurations click file name launch.
5. CCS debug connect target.
6. CCS edit project new CCS project Type the program and save with .c extension.
CCS debug project explorer click the file name add command file to project.
7. Project Build all
8. RUN Load Load program Select the .OUT file and download it to the kit.
9. Execute the program by RUN Resume.
10. Execution is stopped by RUN suspend.
PROGRAM:
SINE WAVE GENERATION
#include <stdio.h>
#include <csl.h>
#include <csl_mcbsp.h>
#include <csl_irq.h>
ioport int port4;
static MCBSP_Config MyConfig_DataRxTx = {
0x1022, /* SPCR1 */ //0x00A3,
0x02e2, /* SPCR2 *///0x02e3
0x0040, /* RCR1 *///same
0x8045, /* RCR2 *///same
0x0040, /* XCR1 *///same
0x8045, /* XCR2 *///same
0x0f01, /* SRGR1 *///0x0F1F
0x201f, /* SRGR2 *///0x301F
0x0000, /* MCR1 */
57
0x0000, /* MCR1 */
0x0F09, /* PCR */ //0x0f00
0x0000, /* RCERA */
0x0000, /* RCERB */
0x0000, /* XCERA */
0x0000, /* XCERB */
};
void taskFunc(void);
void main()
{
short Count,sine[100] = {2048 ,2177, 2307 ,2435, 2562, 2686 ,2808 ,2928 ,3043,
3154, 3261, 3364, 3460, 3552, 3637, 3715, 3787, 3852, 3910, 3960 ,4003,
4037, 4064, 4082, 4093, 4095, 4089, 4074, 4052, 4021, 3982, 3936, 3882,
3821, 3752, 3677, 3595, 3507, 3413, 3313, 3209, 3099, 2986, 2868, 2748,
2624, 2499, 2371, 2242, 2112, 1983, 1853, 1724, 1596, 1471, 1347, 1227,
1109, 996, 886, 782, 682, 588, 500, 418, 343, 274, 213, 159,
113, 74, 43, 21, 6, 0, 2, 13, 31, 58, 92, 135,
185 ,243 ,308 ,380, 458, 543, 635 ,731, 834 ,941, 1052 ,1167
,1287, 1409, 1533, 1660, 1788, 1918, 2047};
short Val;
MCBSP_Handle mhMcbsp;
port4 = 0x1122;
CSL_init();
mhMcbsp = MCBSP_open(MCBSP_PORT0, MCBSP_OPEN_RESET);
MCBSP_config(mhMcbsp, &MyConfig_DataRxTx);
MCBSP_start(mhMcbsp, MCBSP_RCV_START | MCBSP_XMIT_START, 0 );
MCBSP_start(mhMcbsp, MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC,0x200 );
while(1)
{
for(Count = 0; Count < 100; Count++)
{
Val = sine[Count] | 0x1000 ;
while (!MCBSP_xrdy(mhMcbsp));
MCBSP_write16(mhMcbsp,Val);
}
}
}
#include <stdio.h>
#include <csl.h>
#include <csl_mcbsp.h>
#include <csl_irq.h>
ioport int port4;
static MCBSP_Config MyConfig_DataRxTx = {
0x1022, /* SPCR1 */ //0x00A3,
0x02e2, /* SPCR2 *///0x02e3
0x0040, /* RCR1 *///same
0x8045, /* RCR2 *///same
0x0040, /* XCR1 *///same
0x8045, /* XCR2 *///same
0x0f04, /* SRGR1 *///0x0F1F
58
0x201f, /* SRGR2 *///0x301F
0x0000, /* MCR1 */
0x0000, /* MCR1 */
0x0F09, /* PCR */ //0x0f00
0x0000, /* RCERA */
0x0000, /* RCERB */
0x0000, /* XCERA */
0x0000, /* XCERB */
};
void taskFunc(void);
void main()
{
MCBSP_Handle mhMcbsp;
short Count,Out,Val;
short *TriangularOut;
TriangularOut = (short *)0x8500;
Out = 0;
for (Count = -1024; Count < 1024; Count++)
{
*(TriangularOut + Out) = Count;
Out++;
}
Out = 2048;
for (Count = 1023; Count >= -1024; Count--)
{
*(TriangularOut + Out) = Count;
Out++;
}
port4 = 0x1122;
CSL_init();
mhMcbsp = MCBSP_open(MCBSP_PORT0, MCBSP_OPEN_RESET); //port 0 for DAC
MCBSP_config(mhMcbsp, &MyConfig_DataRxTx);
MCBSP_start(mhMcbsp, MCBSP_RCV_START | MCBSP_XMIT_START, 0 );
MCBSP_start(mhMcbsp, MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC,16);
while(1)
{
for(Count = 0; Count <= 4096; Count++)
{
Val = *(TriangularOut + Count) + 2048 ;
while (!MCBSP_xrdy(mhMcbsp));
MCBSP_write16(mhMcbsp,Val | 0x1000);
}
}
SQUARE WAVE GENERATION
#include <stdio.h>
#include <csl.h>
#include <csl_mcbsp.h>
#include <csl_irq.h>
ioport int port4;
static MCBSP_Config MyConfig_DataRxTx = {
0x1022, /* SPCR1 */ //0x00A3,
0x02e2, /* SPCR2 *///0x02e3
59
0x0040, /* RCR1 *///same
0x8045, /* RCR2 *///same
0x0040, /* XCR1 *///same
0x8045, /* XCR2 *///same
0x0f03, /* SRGR1 *///0x0F1F
0x201f, /* SRGR2 *///0x301F
0x0000, /* MCR1 */
0x0000, /* MCR1 */
0x0F09, /* PCR */ //0x0f00
0x0000, /* RCERA */
0x0000, /* RCERB */
0x0000, /* XCERA */
0x0000, /* XCERB */
};
void taskFunc(void);
void main()
{
short i;
MCBSP_Handle mhMcbsp;
port4 = 0x1122;
CSL_init();
mhMcbsp = MCBSP_open(MCBSP_PORT0, MCBSP_OPEN_RESET); //port 0 for DAC
MCBSP_config(mhMcbsp, &MyConfig_DataRxTx);
MCBSP_start(mhMcbsp, MCBSP_RCV_START | MCBSP_XMIT_START, 0 );
MCBSP_start(mhMcbsp, MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC,16);
while(1)
{
while (!MCBSP_xrdy(mhMcbsp));
MCBSP_write16(mhMcbsp,0x0fff | 0x5000);
for(i=0;i<500;i++);
while (!MCBSP_xrdy(mhMcbsp));
MCBSP_write16(mhMcbsp,0x0000 | 0x5000);
for(i=0;i<500;i++);
}
}
RESULT:
Thus the waveforms are generated using TMS320C5416 DSP trainer kit.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
60
APPLICATIONS:
1. Used to generate training signals in communication systems
2. Used to scramble and descramble data in communication systems
3. Used to generate additive dither in data converters
VIVA QUESTIONS:
1. What is CCS?
2. Why do we need of CCS?
3. Explain the procedures to execute a program using CCS?
4. Define analog signal, discrete-time signal and digital signal.
5. Define unit-step signal.
6. List the classification of signal.
7. What is the use of Random signal?
8. What do you mean by aliasing in digital signal processing? How it can be avoided?
9. Give the applications of ramp signal.
REFERENCES:
1. Sanjit K. Mitra, “Digital Signal Processing – A Computer Based Approach”, Tata
Mc Graw Hill, 2007.
2. [Link] Babu, “Digital Signal Processing”, Scitech Publications [Link], 2010.
61
[Link].:10
FIR IMPLEMENTATION
Date:
AIM:
To implement a finite impulse response (FIR) filters using TMS320C5416 DSP Trainer kit
OBJECTIVE:
To design a finite impulse response (FIR) filters.
APPARATUS REQUIRED:
1. TMS320C5416 trainer Kit
2. Personal computer
3. Cable
PROCEDURE:
1. Open Code Composer Studio (CCS Studio) Setup.
2. Select family C67xx and platform XDS100 USB Emulator 6747 XDS100USB &
Endianness Select little.
3. Select 6747 Add save & quit click yes.
4. Then CCS window will open without workspace.
5. Click file load program gel browse option.
6. Debug connect wait until new window open.
7. Project new project save click finish. Now project will be added in CCS work
space.
8. Select file new source file untitled will open save it with .c extension.
9. Again file name source right click add file click file.c
10. Again file name source right click add file cmd file.
11. Write a program in editor window and save.
12. Again file name source right click add file click file.c
13. Again file name source right click add file click file.c
14. Again file name source right click add file click file.c
15. Project Build option Target version 64x+(mv6400-) click ok.
16. Project build program.
17. File load program .out file.
18. Debug RUN. To stop, click debug halt.
PROGRAM:
FIR LOW PASS FILTER
#include <stdio.h>
#include <csl.h>
#include <csl_mcbsp.h>
#include <csl_irq.h>
62
ioport int port4;
static MCBSP_Config MyConfig_DataRxTx = {
0x1822, /* SPCR1 */ //0x00A3,
0x02e3, /* SPCR2 *///0x02e3
0x0040, /* RCR1 *///same
0x8045, /* RCR2 *///same
0x0040, /* XCR1 *///same
0x8045, /* XCR2 *///same
0x0f04, /* SRGR1 *///0x0F1F
0x201f, /* SRGR2 *///0x301F
0x0000, /* MCR1 */
0x0000, /* MCR1 */
0x0F09, /* PCR */ //0x0f00
0x0000, /* RCERA */
0x0000, /* RCERB */
0x0000, /* XCERA */
0x0000, /* XCERB */
};
void main()
{
short data,i;
MCBSP_Handle dac_data,adc_data,codec;
// variable declaration for the filtering action
int imp[20],*inp,*oup,*temp,*loc1,*adc;
int a,b,*k,index,j;
long sum,*loc,*coll;
// address assignmenat for the variables
inp = (int *)0x1000;
loc=(long *)0x1040;
loc1=(int*)0x1080;
adc = (int *)0x1500;
temp = (int *)0x8600;
oup=(int *)0x8500;
coll = (long *)0x1520;
k = (int *)0x1510;
// coefficient for fir high pass filter with the sampling frequency of 12.5Khz
// cutoff frequency of 1Khz
// filter order 16
imp[0] = 0x0FCCF;
imp[1] = 0x0FF37;
imp[2] = 0x02BA;
imp[3] = 0x06FA;
imp[4] = 0x0B6F;
imp[5] = 0x0F80;
imp[6] = 0x01298;
imp[7] = 0x01444;
imp[8] = 0x01444;
imp[9] = 0x01298;
imp[10] = 0x0F80;
imp[11] = 0x0B6F;
imp[12] = 0x06FA;
imp[13] = 0x02BA;
63
imp[14] = 0x0FF37;
imp[15] = 0x0FCCF;
// index variable for circular buffer action
index = 0;
// initialise the input array to zero
for(i=0;i<20;i++)
*(inp+i)=0;
port4 = 0x1122;
// infinite loop for the filter starts here
CSL_init();
dac_data = MCBSP_open(MCBSP_PORT0, MCBSP_OPEN_RESET); // port 0 for dac
MCBSP_config(dac_data, &MyConfig_DataRxTx);
MCBSP_start(dac_data, MCBSP_RCV_START | MCBSP_XMIT_START, 0 );
MCBSP_start(dac_data, MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC,8);
adc_data = MCBSP_open(MCBSP_PORT1, MCBSP_OPEN_RESET); //port 1 for adc
MCBSP_config(adc_data, &MyConfig_DataRxTx);
MCBSP_start(adc_data, MCBSP_RCV_START | MCBSP_XMIT_START, 0 );
MCBSP_start(adc_data, MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC,8);
codec= MCBSP_open(MCBSP_PORT2, MCBSP_OPEN_RESET);
MCBSP_config(codec, &MyConfig_DataRxTx);
MCBSP_start(codec, MCBSP_RCV_START | MCBSP_XMIT_START, 0 );
MCBSP_start(codec, MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC,8);
while(1)
{
while (!MCBSP_xrdy(adc_data));
MCBSP_write16(adc_data,0x0000); //adc1-0x0000,adc2-0x0800,adc3-0x3000,adc4-
0x1800
while (!MCBSP_rrdy(adc_data));
*temp = MCBSP_read16(adc_data);
inp[(index & 0xf)] = *temp;
index = (index +1) & 0xf;
sum = 0;
for (j = 0; j < 16; j++)
{
sum += (long) inp[(index + j) & 0xf] * imp[j];
}
// calculated output is getting output variable & added with offset of 0x800
*oup= (int) (sum >>15) ;
// send to dac
while (!MCBSP_xrdy(dac_data));
MCBSP_write16(dac_data, *oup | 0x1000);
}
}
#include <stdio.h>
#include <csl.h>
#include <csl_mcbsp.h>
#include <csl_irq.h>
ioport int port4;
static MCBSP_Config MyConfig_DataRxTx = {
64
0x1822, /* SPCR1 */ //0x00A3,
0x02e3, /* SPCR2 *///0x02e3
0x0040, /* RCR1 *///same
0x8045, /* RCR2 *///same
0x0040, /* XCR1 *///same
0x8045, /* XCR2 *///same
0x0f04, /* SRGR1 *///0x0F1F
0x201f, /* SRGR2 *///0x301F
0x0000, /* MCR1 */
0x0000, /* MCR1 */
0x0F09, /* PCR */ //0x0f00
0x0000, /* RCERA */
0x0000, /* RCERB */
0x0000, /* XCERA */
0x0000, /* XCERB */
};
void main()
{
short data,i;
MCBSP_Handle dac_data,adc_data,codec;
// variable declaration for the filtering action
int imp[20],*inp,*oup,*temp;
int index,j;
long sum;
// address assignmenat for the variables
inp = (int *)0x1000;
//loc=(long *)0x1040;
//loc1=(int*)0x1080;
//adc = (int *)0x1500;
temp = (int *)0x1501;
oup=(int *)0x1503;
//coll = (long *)0x1506;
//k = (int *)0x1508;
// coefficient for fir high pass filter with the sampling frequency of 12.5Khz
// cutoff frequency of 1Khz
// filter order 16
imp[0] = 0x0FDC3;
imp[1] = 0x070E;
imp[2] = 0x0F5DE;
imp[3] = 0x0214;
imp[4] = 0x0E8ED;
imp[5] = 0x0CC;
imp[6] = 0x0D23F;
imp[7] = 0x03D38;
imp[8] = 0x03D38;
imp[9] = 0x0D23F;
imp[10] = 0x0CC;
imp[11] = 0x0E8ED;
imp[12] = 0x0214;
imp[13] = 0x0F5DE;
imp[14] = 0x070E;
imp[15] = 0x0FDC3;
65
// index variable for circular buffer action
index = 0;
// initialise the input array to zero
port4 = 0x1122;
for(i=0;i<20;i++)
*(inp+i)=0;
// infinite loop for the filter starts here
CSL_init();
//codec= MCBSP_open(MCBSP_PORT2, MCBSP_OPEN_RESET);
//MCBSP_config(dac_data, &MyConfig_DataRxTx);
adc_data = MCBSP_open(MCBSP_PORT1, MCBSP_OPEN_RESET);
MCBSP_config(adc_data, &MyConfig_DataRxTx);
MCBSP_start(adc_data, MCBSP_RCV_START | MCBSP_XMIT_START, 0 );
MCBSP_start(adc_data, MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC,8);
dac_data = MCBSP_open(MCBSP_PORT0, MCBSP_OPEN_RESET);
MCBSP_config(dac_data, &MyConfig_DataRxTx);
MCBSP_start(dac_data, MCBSP_RCV_START | MCBSP_XMIT_START, 0 );
MCBSP_start(dac_data, MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC,8);
codec= MCBSP_open(MCBSP_PORT2, MCBSP_OPEN_RESET);
MCBSP_config(codec, &MyConfig_DataRxTx);
MCBSP_start(codec, MCBSP_RCV_START | MCBSP_XMIT_START, 0 );
MCBSP_start(codec, MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC,8);
while(1)
{
while (!MCBSP_xrdy(adc_data));
MCBSP_write16(adc_data,0x0000); //adc1-0x0000,adc2-0x0800,adc3-0x3000,adc4-
0x1800
while (!MCBSP_rrdy(adc_data));
*temp = MCBSP_read16(adc_data);
inp[(index & 0xf)] = *temp;
index = (index +1) & 0xf;
sum = 0;
for (j = 0; j < 16; j++)
{
sum += (long) inp[(index + j) & 0xf] * imp[j];
}
// calculated output is getting output variable & added with offset of 0x800
*oup= (int) (sum >>15) + 0x800 ;
// send to dac
while (!MCBSP_xrdy(dac_data));
MCBSP_write16(dac_data, *oup | 0x1000);
}
}
FIR BANDPASS FILTER
#include <stdio.h>
#include <csl.h>
#include <csl_mcbsp.h>
#include <csl_irq.h>
ioport int port4;
static MCBSP_Config MyConfig_DataRxTx = {
0x1822, /* SPCR1 */ //0x00A3,
0x02e3, /* SPCR2 *///0x02e3
0x0040, /* RCR1 *///same
66
0x8045, /* RCR2 *///same
0x0040, /* XCR1 *///same
0x8045, /* XCR2 *///same
0x0f04, /* SRGR1 *///0x0F1F
0x201f, /* SRGR2 *///0x301F
0x0000, /* MCR1 */
0x0000, /* MCR1 */
0x0F09, /* PCR */ //0x0f00
0x0000, /* RCERA */
0x0000, /* RCERB */
0x0000, /* XCERA */
0x0000, /* XCERB */
};
void main()
{
short i;
MCBSP_Handle dac_data,adc_data,codec;
// variable declaration for the filtering action
int imp[20],*inp,*oup,*temp;
int index,j;
long sum;
// address assignmenat for the variables
inp = (int *)0x1000;
temp = (int *)0x1501;
oup=(int *)0x1503;
// coefficient for fir high pass filter with the sampling frequency of 12.5Khz
// cutoff frequency of 1Khz
// filter order 16
imp[0] = 0x00;
imp[1] = 0x0FB4E;
imp[2] = 0x0F3A7;
imp[3] = 0x0EEEA;
imp[4] = 0x0F2BF;
imp[5] = 0x00;
imp[6] = 0x0111C;
imp[7] = 0x01D0B;
imp[8] = 0x01D0B;
imp[9] = 0x0111C;
imp[10] = 0x00;
imp[11] = 0x0F2BF;
imp[12] = 0x0EEEA;
imp[13] = 0x0F3A7;
imp[14] = 0x0FB4E;
imp[15] = 0x00;
// index variable for circular buffer action
index = 0;
// initialise the input array to zero
for(i=0;i<20;i++)
*(inp+i)=0;
port4 = 0x1122;
// infinite loop for the filter starts here
CSL_init();
67
codec= MCBSP_open(MCBSP_PORT2, MCBSP_OPEN_RESET); // codec port close
MCBSP_config(dac_data, &MyConfig_DataRxTx);
MCBSP_start(dac_data, MCBSP_RCV_START | MCBSP_XMIT_START, 0 );
MCBSP_start(dac_data, MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC,8);
dac_data = MCBSP_open(MCBSP_PORT0, MCBSP_OPEN_RESET); // port 0 for dac
MCBSP_config(dac_data, &MyConfig_DataRxTx);
MCBSP_start(dac_data, MCBSP_RCV_START | MCBSP_XMIT_START, 0 );
MCBSP_start(dac_data, MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC,8);
adc_data = MCBSP_open(MCBSP_PORT1, MCBSP_OPEN_RESET); //port 1 for adc
MCBSP_config(adc_data, &MyConfig_DataRxTx);
MCBSP_start(adc_data, MCBSP_RCV_START | MCBSP_XMIT_START, 0 );
MCBSP_start(adc_data, MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC,8);
codec= MCBSP_open(MCBSP_PORT2, MCBSP_OPEN_RESET);
MCBSP_config(codec, &MyConfig_DataRxTx);
MCBSP_start(codec, MCBSP_RCV_START | MCBSP_XMIT_START, 0 );
MCBSP_start(codec, MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC,8);
while(1)
{
while (!MCBSP_xrdy(adc_data));
MCBSP_write16(adc_data,0x0000); //adc1-0x0000,adc2-0x0800,adc3-0x3000,adc4-
0x1800
while (!MCBSP_rrdy(adc_data));
*temp = MCBSP_read16(adc_data);
inp[(index & 0xf)] = *temp;
index = (index +1) & 0xf;
sum = 0;
for (j = 0; j < 16; j++)
{
sum += (long) inp[(index + j) & 0xf] * imp[j];
}
// calculated output is getting output variable & added with offset of 0x800
*oup= (int) (sum >>15) + 0x0800 ;
// send to dac
while (!MCBSP_xrdy(dac_data));
MCBSP_write16(dac_data, *oup | 0x1000);
}
}
FIR BAND REJECT FILTER
#include <stdio.h>
#include <csl.h>
#include <csl_mcbsp.h>
#include <csl_irq.h>
ioport int port4;
69
dac_data = MCBSP_open(MCBSP_PORT0, MCBSP_OPEN_RESET); // port 0 for dac
MCBSP_config(dac_data, &MyConfig_DataRxTx);
MCBSP_start(dac_data, MCBSP_RCV_START | MCBSP_XMIT_START, 0 );
MCBSP_start(dac_data, MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC,8);
adc_data = MCBSP_open(MCBSP_PORT1, MCBSP_OPEN_RESET); //port 1 for adc
MCBSP_config(adc_data, &MyConfig_DataRxTx);
MCBSP_start(adc_data, MCBSP_RCV_START | MCBSP_XMIT_START, 0 );
MCBSP_start(adc_data, MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC,8);
codec= MCBSP_open(MCBSP_PORT2, MCBSP_OPEN_RESET);
MCBSP_config(codec, &MyConfig_DataRxTx);
MCBSP_start(codec, MCBSP_RCV_START | MCBSP_XMIT_START, 0 );
MCBSP_start(codec, MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC,8);
while(1)
{
while (!MCBSP_xrdy(adc_data));
MCBSP_write16(adc_data,0x0000); //adc1-0x0000,adc2-0x0800,adc3-0x3000,adc4-
0x1800
while (!MCBSP_rrdy(adc_data));
*temp = MCBSP_read16(adc_data);
inp[(index & 0xf)] = *temp;
index = (index +1) & 0xf;
sum = 0;
for (j = 0; j < 16; j++)
{
sum += (long) inp[(index + j) & 0xf] * imp[j];
}
// calculated output is getting output variable & added with offset of 0x800
*oup= (int) (sum >>15) ;
// send to dac
while (!MCBSP_xrdy(dac_data));
MCBSP_write16(dac_data, *oup | 0x1000);
}
}
RESULT:
Thus the FIR filter and IIR filter are implemented using TMS320C5416 DSP trainer kit.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
70
APPLICATIONS:
1. Radar system
2. Used in Digital communication
3. Speech processing
4. Image processing
VIVA QUESTIONS:
1. Why do we need of CCS?
2. Explain the procedures to execute a program using CCS?
3. What are the different types of filters based on impulse response?
4. What are the different types of filters based on frequency response?
5. What are FIR filters?
6. What are the techniques of designing FIR filters?
7. Why is the impulse response "finite"?
8. Differentiate IIR filters and FIR filters.
9. What is the reason that FIR filter is always stable?
REFERENCES:
71
[Link].:11
IIR IMPLEMENTATION
Date:
AIM:
To implement a infinite impulse response filters using TMS320C6747 DSP Trainer kit
OBJECTIVE:
1. To design a infinite impulse response (IIR) filters.
2. To understand the concepts of a IIR filter.
APPARATUS REQUIED:
1. TMS320C5416 trainer Kit
2. Personal computer
3. Cable
PROCEDURE:
1. Open Code Composer Studio (CCS Studio) Setup.
2. Select family C67xx and platform XDS100 USB Emulator 6747 XDS100USB &
Endianness Select little.
3. Select 6747 Add save & quit click yes.
4. Then CCS window will open without workspace.
5. Click file load program gel browse option.
6. Debug connect wait until new window open.
7. Project new project save click finish. Now project will be added in CCS work
space.
8. Select file new source file untitled will open save it with .c extension.
9. Again file name source right click add file click file.c
10. Again file name source right click add file cmd file.
11. Write a program in editor window and save.
12. Again file name source right click add file click file.c
13. Again file name source right click add file click file.c
14. Again file name source right click add file click file.c
15. Project Build option Target version 64x+(mv6400-) click ok.
16. Project build program.
17. File load program .out file.
18. Debug RUN. To stop, click debug halt.
PROGRAM:
//void Vi_DSKC6747_init( );
72
typedef unsigned int Uint32;
typedef int Int32;
typedef short Int16;
int main(void)
{
Uint32 *socValue;
Uint32 *adcValue;
Uint32 *dacValue;
Int16 adcOut;
Int16 i;
Int16 scaledValue;
Int16 inStage;
Int16 outStage;
Int16 numProduct;
Int16 denProduct;
Int16 numAdded;
Int16 denAdded;
Int16 denStore;
Int16 *memDat;
Int16 memDatInd;
Int16 numInd;
Int16 denInd;
socValue = (Uint32 *)0x60000558;
adcValue = (Uint32 *)0x60000554;
dacValue = (Uint32 *)0x60000554;
memDat = (Int16 *)0xc0010000;
//Vi_DSKC6747_init( );
for(i = 0; i < 50; i++)
memDat[i] = 0;
while(1)
{
*socValue = 0x00;
for(i = 0; i < 100 ; i++);
adcOut = *adcValue;
scaledValue = ((adcOut * gain[0]) >> 14);
inStage = scaledValue;
for(i = 0; i < 10; i++)
{
memDatInd = 2 * i;
numInd = 3 * i;
denInd = 2 * i;
denAdded = inStage;
denProduct = (Int16)((den[denInd] * memDat[memDatInd]) >> 14);
denAdded = (Int16)(denAdded - denProduct);
denProduct = (Int16)((den[denInd + 1] * memDat[memDatInd + 1]) >> 14);
denAdded = (Int16)(denAdded - denProduct);
denStore = denAdded;
numProduct = (Int16)((num[numInd] * denStore) >> 13);
numAdded = numProduct;
numProduct = (Int16)((num[numInd + 1] * memDat[memDatInd]) >> 13);
numAdded = (Int16)(numAdded + numProduct);
numProduct = (Int16)((num[numInd + 2] * memDat[memDatInd + 1]) >> 13);
numAdded = (Int16)(numAdded + numProduct);
73
outStage = numAdded;
scaledValue = (Int16)((outStage * gain[i + 1]) >> 14);
inStage = scaledValue;
memDat[memDatInd + 1] = memDat[memDatInd];
memDat[memDatInd] = denStore;
}
scaledValue = (Int16)((outStage * gain[10]) >> 14);
*dacValue = scaledValue | 0x1000;
//*dacValue = adcOut;
//*led = 0xaa;
for(i = 0; i < 300; i++);
}
}
#include "coefHp.h"
#include <stdio.h>
//void Vi_DSKC6747_init( );
typedef unsigned int Uint32;
typedef int Int32;
typedef short Int16;
int main(void)
{
int32 *socValue;
Uint32 *adcValue;
Uint32 *dacValue;
Int16 adcOut;
Int16 i;
Int16 scaledValue;
Int16 inStage;
Int16 outStage;
Int16 numProduct;
Int16 denProduct;
Int16 numAdded;
Int16 denAdded;
Int16 denStore;
Int16 *memDat;
Int16 memDatInd;
Int16 numInd;
Int16 denInd;
socValue = (Uint32 *)0x60000558;
adcValue = (Uint32 *)0x60000554;
dacValue = (Uint32 *)0x60000554;
memDat = (Int16 *)0xc0010000;
//Vi_DSKC6747_init( );
for(i = 0; i < 50; i++)
memDat[i] = 0;
while(1)
{
*socValue = 0x00;
adcOut = *adcValue;
scaledValue = ((adcOut * gain[0]) >> 13);
74
inStage = scaledValue;
for(i = 0; i < 10; i++)
{
memDatInd = 2 * i;
numInd = 3 * i;
denInd = 2 * i;
denAdded = inStage;
denProduct = (Int16)((den[denInd] * memDat[memDatInd]) >> 14);
denAdded = (Int16)(denAdded - denProduct);
denProduct = (Int16)((den[denInd + 1] * memDat[memDatInd + 1]) >> 14);
denAdded = (Int16)(denAdded - denProduct);
denStore = denAdded;
numProduct = (Int16)((num[numInd] * denStore) >> 14);
numAdded = numProduct;
numProduct = (Int16)((num[numInd + 1] * memDat[memDatInd]) >> 14);
numAdded = (Int16)(numAdded + numProduct);
numProduct = (Int16)((num[numInd + 2] * memDat[memDatInd + 1]) >> 14);
numAdded = (Int16)(numAdded + numProduct);
outStage = numAdded;
scaledValue = (Int16)((outStage * gain[i + 1]) >> 13);
inStage = scaledValue;
memDat[memDatInd + 1] = memDat[memDatInd];
memDat[memDatInd] = denStore;
}
scaledValue = (Int16)((outStage * gain[10]) >> 13);
scaledValue += 0x800;
*dacValue = scaledValue | 0x1000;
for(i = 0; i < 250; i++);
}
}
IIR BAND PASS FILTER
#include "coefBp.h"
#include <stdio.h>
//void Vi_DSKC6747_init( );
typedef unsigned int Uint32;
typedef int Int32;
typedef short Int16;
int main(void)
{
Uint32 *socValue;
Uint32 *adcValue;
Uint32 *dacValue;
Int16 adcOut;
Int16 i;
Int16 scaledValue;
Int16 inStage;
Int16 outStage;
Int16 numProduct;
Int16 denProduct;
Int16 numAdded;
Int16 denAdded;
Int16 denStore;
75
Int16 *memDat;
Int16 memDatInd;
Int16 numInd;
Int16 denInd;
socValue = (Uint32 *)0x60000558;
adcValue = (Uint32 *)0x60000554;
dacValue = (Uint32 *)0x60000554;
memDat = (Int16 *)0xc0010000;
// Vi_DSKC6747_init( );
for(i = 0; i < 50; i++)
memDat[i] = 0;
while(1)
{
*socValue = 0x00;
for(i = 0; i < 100; i++)
adcOut = *adcValue;
scaledValue = ((adcOut * gain[0]) >> 14);
inStage = scaledValue;
for(i = 0; i < 10; i++)
{
memDatInd = 2 * i;
numInd = 3 * i;
denInd = 2 * i;
denAdded = inStage;
denProduct = (Int16)((den[denInd] * memDat[memDatInd]) >> 14);
denAdded = (Int16)(denAdded - denProduct);
denProduct = (Int16)((den[denInd + 1] * memDat[memDatInd + 1]) >> 14);
denAdded = (Int16)(denAdded - denProduct);
denStore = denAdded;
numProduct = (Int16)((num[numInd] * denStore) >> 14);
numAdded = numProduct;
numProduct = (Int16)((num[numInd + 1] * memDat[memDatInd]) >> 14);
numAdded = (Int16)(numAdded + numProduct);
numProduct = (Int16)((num[numInd + 2] * memDat[memDatInd + 1]) >> 14);
numAdded = (Int16)(numAdded + numProduct);
outStage = numAdded;
scaledValue = (Int16)((outStage * gain[i + 1]) >> 14);
inStage = scaledValue;
memDat[memDatInd + 1] = memDat[memDatInd];
memDat[memDatInd] = denStore;
}
scaledValue = (Int16)((outStage * gain[10]) >> 14);
scaledValue += 0x800;
*dacValue = scaledValue | 0x1000;
for(i = 0; i < 250; i++);
}
}
INFERENCE AND DISCUSSIONS:
76
RESULT:
Thus the IIR filter is implemented using TMS320C6747 DSP trainer kit.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
APPLICATIONS:
1. Radar system
2. Used in Digital communication
3. Speech processing
4. Image processing
VIVA QUESTIONS:
1. Why do we need of CCS?
2. Explain the procedures to execute a program using CCS?
3. What are the different types of filters based on impulse response?
4. What are the different types of filters based on frequency response?
5. What are IIR filters?
6. What are the techniques of designing IIR filters?
7. Why is the impulse response "infinite"?
8. Differentiate IIR filters and FIR filters.
REFERENCES:
1. Sanjit K. Mitra, “Digital Signal Processing – A Computer Based Approach”, Tata
Mc Graw Hill, 2007.
2. [Link] Babu, “Digital Signal Processing”, Scitech Publications [Link], 2010.
77
[Link].:12
UP-SAMPLING AND DOWN-SAMPLING
Date:
AIM:
To implement a infinite impulse response filters using TMS320C6747 DSP Trainer kit
OBJECTIVE:
To make the students to design a Up-sampler and Down-sampler using TMS320C6747
DSP Trainer kit.
APPARATUS REQUIRED:
1. TMS320C6747 trainer Kit
2. Personal computer
3. Cable
PROCEDURE:
1. Open Code Composer Studio (CCS Studio) Setup.
2. Select family C67xx and platform XDS100 USB Emulator 6747 XDS100USB &
Endianness Select little.
3. Select 6747 Add save & quit click yes.
4. Then CCS window will open without workspace.
5. Click file load program gel browse option.
6. Debug connect wait until new window open.
7. Project new project save click finish. Now project will be added in CCS work
space.
8. Select file new source file untitled will open save it with .c extension.
9. Again file name source right click add file click file.c
10. Again file name source right click add file cmd file.
11. Write a program in editor window and save.
12. Again file name source right click add file click file.c
13. Again file name source right click add file click file.c
14. Again file name source right click add file click file.c
15. Project Build option Target version 64x+(mv6400-) click ok.
16. Project build program.
17. File load program .out file.
18. Debug RUN. To stop, click debug halt.
PROGRAM:
UP-SAMPLING AND DOWN-SAMPLING
#include "deci3.h"
#include "deci4.h"
#include <stdio.h>
78
/* Specifications for the filters used: fs = 8 KHz, fp1 = fp2 = 700 Hz, fs1 = 3000 Hz, fs2 = 1000
Hz, dp1 = dp2 = 0.005, ds1 = ds2 = 0.001, N1 = 8, N2 = 37, M1 = M2 = L2 = L1 = 2.
For every 4 samples read from the adc the following approximate times apply without using any
additional delays:
samples 1 and 3: 16 us, sample 2: 28 us, sample 4: 0.1 ms
sample 1 = indexSamp 1
sample 2 = indexSamp 2
sample 3 = indexSamp 3
sample 4 = indexSamp 0
This means that without using additional delays the samples are not read at the 8 Khz rate.
Therefore appropriate delays are added for samples 1, 2, 3 and 4 so that each sample would be
read at a rate close to 8 KHz (0.125 ms).
*/
typedef unsigned int Uint32;
typedef int Int32;
typedef short Int16;
typedef unsigned short Uint16;
typedef unsigned char Uchar;
Uint32 *inDeciM1;
Uint32 *inDeciM2;
Uint32 *inInterpL2;
Uint32 *inInterpL1;
Uint32 *storeL1;
Uint32 *outL1;
Int16 *fInterpL2;
Int16 *fInterpL1;
Uint16 adcOut;
Uint32 valueL1;
Int32 outValue;
Int32 filtCount;
Uchar indexL2;
Uchar indexL1;
Uchar indexInit;
Uchar indexSamp;
int deciM1(void);
int deciM2(void);
int interpL2(void);
int interpL1(void);
int main(void)
{
Uint16 *socValue;
Uint16 *adcValue;
Uint16 *dacValue;
//Uint32 socRead;
//Uchar *led;
Int32 tCount;
Uint32 countM1;
Uint32 countM2;
Uint32 countL1;
Uint32 countL2;
Uint32 *inTest;
socValue = (Uint16 *)0x60000558;//0x9004000c;
adcValue = (Uint16 *)0x60000554;//0x90040008;
79
dacValue = (Uint16 *)0x60000554;//0x90040008;
fInterpL2 = (Int16 *)0xc0001000;//0x0000a000;
fInterpL1 = (Int16 *)0xc0001100;//0x0000b000;
inDeciM1 = (Uint32 *)0xc0001200;//0x00011000;
inDeciM2 = (Uint32 *)0xc0001300;//0x00012000;
inInterpL2 = (Uint32 *)0xc0001400;//0x00013000;
inInterpL1 = (Uint32 *)0xc0001500;//0x00014000;
storeL1= (Uint32 *)0xc0001600;//0x00016000;
outL1 = (Uint32 *)0xc0001700;//0x00017000;
//led = (Uchar *)0x90040016;
inTest = (Uint32 *)0xc0001800;//0x00015000;
for(filtCount = 0; filtCount < 50; filtCount++)
*(inTest + filtCount) = filtCount + 0x300;
for(filtCount = 0; filtCount < 37; filtCount++)
*(fInterpL2 + filtCount) = *(fDeciM2 + filtCount) * 2;
for(filtCount = 0; filtCount < 8; filtCount++)
*(fInterpL1 + filtCount) = *(fDeciM1 + filtCount) * 2;
for(filtCount = 0; filtCount < 200; filtCount++)
{
*(inDeciM1 + filtCount) = 0;
*(inDeciM2 + filtCount) = 0;
*(inInterpL2 + filtCount) = 0;
*(inInterpL1 + filtCount) = 0;
}
indexL2 = 1;
indexL1 = 1;
countM1 = 1;
countM2 = 0;
countL2 = 0;
countL1 = 0;
indexSamp = 1;
while(1)
{
if(indexSamp == 0)
for(tCount = 0; tCount < 200; tCount++);
else if ((indexSamp == 1) || (indexSamp == 3))
for(tCount = 0; tCount < 900; tCount++);
else if (indexSamp == 2)
for(tCount = 0; tCount < 700; tCount++);
//socRead = *socValue;
*socValue = 0x00;
adcOut = *adcValue;
// adcOut &= 0x0fff;
// adcOut ^= 0x0800;
*inDeciM1 = adcOut;
if(countM1 == 2)
{
deciM1();
countM1 = 0;
countM2++;
}
if(countM2 == 2)
80
{
deciM2();
countM2 = 0;
}
if((countM1 == 0) && (countM2 == 0))
{
while(countL2 < 2)
{
interpL2();
for(filtCount = 36; filtCount >= 0; filtCount--)
*(inInterpL2 + filtCount + 1) = *(inInterpL2 + filtCount);
indexInit = 1;
countL2++;
}
}
storeL1= (Uint32 *)0xc0001600;//0x00016000;
if((countM1 == 0) && (countM2 == 0) && (countL2 == 2))
{
while(countL1 < 4)
{
if(countL1 == 0)
{
valueL1 = *storeL1;
*inInterpL1 = valueL1;
}
else if(countL1 == 2)
{
valueL1 = *(storeL1 + 1);
*inInterpL1 = valueL1;
}
interpL1();
for(filtCount = 7; filtCount >= 0; filtCount--)
*(inInterpL1 + filtCount + 1) = *(inInterpL1 + filtCount);
countL1++;
}
}
outL1 = (Uint32 *)0xc0001700;//0x00017000;
if(indexInit == 0)
outValue = 0x800;
else
outValue = *(outL1 + indexSamp);
outValue = outValue >> 1;
*dacValue = outValue | 0x1000;
indexSamp++;
countL1 = 0;
countL2 = 0;
for(filtCount = 7; filtCount >= 0; filtCount--)
*(inDeciM1 + filtCount + 1) = *(inDeciM1 + filtCount);
countM1++;
if(indexSamp == 4)
indexSamp = 0;
}
return 0;
81
}
int deciM1(void)
{
for(filtCount = 36; filtCount >= 0; filtCount--)
*(inDeciM2 + filtCount + 1) = *(inDeciM2 + filtCount);
outValue = 0;
for(filtCount = 0; filtCount < 8; filtCount++)
outValue += *(inDeciM1 + filtCount) * *(fDeciM1 + filtCount);
RESULT:
Thus the upsampling and downsampling operation is implemented using TMS320C6747
DSP trainer kit.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
APPLICATIONS:
1. Radar system
2. Used in Digital communication
3. Speech processing
4. Image processing
VIVA QUESTIONS:
1. Why do we need CCS?
2. Explain the procedures to execute a program using CCS?
3. What are the different types of filters based on impulse response?
4. What are the different types of filters based on frequency response?
5. What are IIR filters?
6. What are the techniques of designing IIR filters?
7. Why is the impulse response "infinite"?
8. Differentiate IIR filters and FIR filters.
REFERENCES:
1. Sanjit K. Mitra, “Digital Signal Processing – A Computer Based Approach”, Tata
Mc Graw Hill, 2007.
2. [Link] Babu, “Digital Signal Processing”, Scitech Publications [Link], 2010.
3. Poorna Chandra S, Sasikala. B ,Digital Signal Processing, Vijay Nicole/TMH,2013.
83