DSP Lab Manual Align
DSP Lab Manual Align
To write a MATLAB Script to perform discrete convolution (Linear and Circular) for
the given two sequences.
COMPONENTS REQUIRED:
PC, MATLAB software
ALGORITHM/PROCEDURE:
LINEAR CONVOLUTION:
1. Enter the sequences (Input x[n] and the Impulse response h[n])
2. Perform the linear convolution between x[k] and h[k] and obtain y[n].
3. Find the FFT of x[n] & h[n].Obtain X and H
4. Multiply X and H to obtain Y
5. Find the IFFT of Y to obtain y’[n]
6. Compute error in time domain e=y[n]-y’[n]
7. Plot the Results
CIRCULAR CONVOLUTION
1. Enter the sequences (input x[n] and the impulse response h[n])
2. Make the length of the sequences equal by padding zeros to the smaller length
sequence.
3. Perform the circular convolution between x[k] and h[k]and obtain y[n].
4. Find the FFT of x[n] & h[n].Obtain X and H
5. Multiply X and H to obtain Y
6. Find the IFFT of Y to obtain y’[n]
7. Compute error in time domain e=y[n]-y’[n]
8. Plot the Results
SOURCE CODE 1 – LINEAR CONVOLUTION
clc;
clear all;
close all;
%Program to perform Linear Convolution
f=conv(x1,x2);
disp('The Linear convoluted sequence is');
disp(f);
subplot(3,1,3);
stem(f);
xlabel('Time');
ylabel('Amplitude');
title('Linear Convoluted sequence');
SOURCE CODE 2 – CIRCULAR CONVOLUTION
clc;
clear all;
close all;
%Program to perform Circular Convolution
if l1>l2
l3=l1-l2;
x2=[x2,zeros(1,l3)];
elseif l2>l1
l3=l2-l1;
x1=[x1,zeros(1,l3)];
end
f=cconv(x1,x2);
OUTPUT WAVEFORMS:
LINEAR CONVOLUTION
Output Waveforms
CIRCULAR CONVOLUTION
Columns 6 through 7
16.0000 0.0000
Output Waveforms
RESULT:
The linear and circular convolutions are performed by using MATLAB script and the
program results are verified by manual calculation.
AIM:
To write a MATLAB program to perform the Discrete Fourier Transform/Fast Fourier
Transform for the given sequences.
COMPONENTS REQUIRED:
PC, MATLAB software
ALGORITHM/PROCEDURE:
1. Click on the MATLAB icon on the desktop (or go to Start - All Programs and click on
MATLAB) to get into the Command Window
2. Type ‘edit’ in the MATLAB prompt ‘>>’ that appears in the Command window.
3. Write the program in the ‘Edit’ window and save it as ‘m-file’
4. Run the program
5. Enter the input in the command window
6. The result is displayed in the Command window and the graphical output is displayed
in the Figure Window
Source Code :1
clc;
clear all;
close all;
%Get the sequence from user
disp('The sequence from the user:');
xn=input('Enter the input sequence x(n):');
xlabel('Time Index');
title('X(k)');
iXk=iXk./N;
%code block to plot the FFT of input sequence using inbuilt function
x2=fft(xn);
subplot(3,2,6);
stem(t,x2);
ylabel ('Amplitude');
OUTPUT 1:
Output of Spectrum Analysis with the FFT
Source Code :2
% Spectrum Analysis with the FFT with noise
clc;
clear all;
close all;
fs = 100; % sample frequency (Hz)
t = 0:1/fs:10-1/fs; % 10 second span time vector
x = (1.3)*sin(2*pi*15*t) ... % 15 Hz component
+ (1.7)*sin(2*pi*40*(t-2)) ... % 40 Hz component
+ 2.5*gallery('normaldata',size(t),4); % Gaussian noise;
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')
y0 = fftshift(y); % shift y values
f0 = (-n/2:n/2-1)*(fs/n); % 0-centered frequency range
power0 = abs(y0).^2/n; % 0-centered power
plot(f0,power0)
xlabel('Frequency')
ylabel('Power')
OUTPUT 2:
RESULT:
The program for DFT/FFT calculation was performed. The results were verified by
manual calculation.
AIM:
To write a MATLAB Script to design a low pass FIR filter using Window Method for
the given specifications.
COMPONENTS REQUIRED:
PC, MATLAB software
ALGORITHM/PROCEDURE:
1. Click on the MATLAB icon on the desktop (or go to Start – All Programs and
click on MATLAB) to get into the Command Window.
2. Type ‘edit’ in the MATLAB prompt ‘>>’ that appears in the Command window.
3. Write the program in the ‘Edit’ window and save it in ‘M-file’.
4. Run the program.
5. Enter the input in the Command Window.
6. The result is displayed in the Command window and the graphical output is displayed
in the Figure Window.
SOURCE CODE :1
clc;
clear all;
close all;
h=fir1(N,wc/pi,rectwin(N+1));
freqz(h);
title('FIR Filter - Rectangular Window');
h=fir1(N,wc/pi,triang(N+1));
figure(2)
freqz(h);
title('FIR Filter - Triangular Window');
h=fir1(N,wc/pi,hamming(N+1));
figure(3)
freqz(h);
title('FIR Filter - Hamming Window');
h=fir1(N,wc/pi,hanning(N+1));
figure(4)
freqz(h);
title('FIR Filter - Hanning Window');
h=fir1(N,wc/pi,blackman(N+1));
figure(5)
freqz(h);
title('FIR Filter - Blackman Window');
SOURCE CODE :2
clc;
clear all;
close all;
b=fir1(N,wc/pi,rectwin(N+1));
[H,w]=freqz(b,1,512); %frequency response
plot(w/pi,abs(H),'k');
hold on
b=fir1(N,wc/pi,triang(N+1));
[H,w]=freqz(b,1,512); %frequency response
plot(w/pi,abs(H),'--k');
hold on
b=fir1(N,wc/pi,hamming(N+1));
[H,w]=freqz(b,1,512); %frequency response
plot(w/pi,abs(H),':k');
hold on
b=fir1(N,wc/pi,hanning(N+1));
[H,w]=freqz(b,1,512); %frequency response
plot(w/pi,abs(H),'-.k');
hold on
b=fir1(N,wc/pi,blackman(N+1));
[H,w]=freqz(b,1,512); %frequency response
plot(w/pi,abs(H),'.b');
hold on
xlabel('Normalized Frequency');
ylabel('Magnitude');
legend('Rectangular','Triangular(Barlett)','Hamming','Hanning','Blackman','Location','Best');
title('Gibbs Phenomenon');
allaxes=findall(a,'Type','axes');
alllines=findall(a,'Type','line');
alltext=findall(a,'Type','text');
SOURCE CODE:
%30th order LPF using Frequency Sampling method
clc;
clear all;
close all;
Fs=1000; %sampling frequency
Fn=Fs/2; %Nyquist frequency
f=[ 0 400 400 500]/Fn;
m=[1 1 0 0];
h=fir2(30,f,m);
[H,w]=freqz(h,1,256);
plot(f*Fn,m,'-o')
hold on
plot (Fn*w/pi, abs(H),'k');grid
hold on
legend('Ideal', 'Designed')
xlabel('Frequency (Hz)')
ylabel('Magnitude')
title('FIR filter')
%optional code
M=63; Wp=0.5*pi;%the number of samples and the passband cutoff frequency
m=0:(M+1)/2; Wm=2*pi*m./(M+1);%the sampling points and the stopband cutoff frequency
mtr=floor(Wp*(M+1)/(2*pi))+2;%round to negative part,i.e.floor(3.5)=3;floor(-3.2)=-4
Ad=[Wm<=Wp];Ad(mtr)=0.38;
Hd=Ad.*exp(-j*0.5*M*Wm);%define frequency-domain sampling vector H(k)
Hd=[Hd conj(fliplr(Hd(2:(M+1)/2)))];
%fliplr is to realize the fliplr of matrix and conj
h=real(ifft(Hd));% h(n)=IDFT[H(k)
w=linspace(0,pi,1000);%get 1000 row vectors between 0 and pi
H=freqz(h,[1],w);%the amplitude -frequency characteristic diagram of the filter
figure(1)
plot(w/pi,20*log10(abs(H)));%parameters are respectively the normalized frequency and
amplitude
xlabel('the normailzed frequency');
ylabel('gian/dB');
title('The gain response of lowpass filter');
axis([0 1 -50 0.5]);
f1=100;f2=300;f3=700;
fs=2000;%the frequencies of sines signal that needs filtered and the sample frequency
figure(2);
subplot(211)
t=0:1/fs:0.25;%define the time domain and steplength
s=sin(2*pi*f1*t)+sin(2*pi*f2*t)+sin(2*pi*f3*t);%signal before filtering
plot(t,s);%plot the diagram before filtering
xlabel('time/s');
ylabel('amplitude');
title('Time-domain diagram before filtering');
subplot(212)
Fs=fft(s,512); AFs=abs(Fs);%transform to the frequency domain
f=(0:255)*fs/512;%frequency sampling
plot(f,AFs(1:256));%plot the frequency domain diagram before filtering
xlabel('frequency/Hz');
ylabel('amplitude');
title('Frequency-domain diagram before filtering');
figure(3)
sf=filter(h,1,s);%use function filter
subplot(211)
plot(t,sf)%plot the diagram after filtering
xlabel('time/s');
ylabel('amplitude');
title('Time-domain diagram after filtering');
axis([0.2 0.25 -2 2]);%set the range of image coordinates
subplot(212)
Fsf=fft(sf,512); AFsf=abs(Fsf);%frequency-domain and the amplitude diagram
f=(0:255)*fs/512;%frequency sampling
plot(f,AFsf(1:256))%plot the frequency domain diagram before filtering
xlabel('frequency/Hz');
ylabel('amplitude');
title('Frequency-domain diagram after filtering');
OUTPUT 1:
OUTPUT 2:
RESULT:
For the given specifications low pass filter was designed using Frequency Sampling
To write a MATLAB Script to design Butterworth and Chebyshev low pass filters
using Bilinear Transformation, Impulse Invariant Transformation
COMPONENTS REQUIRED:
PC, MATLAB software
BILINEAR TRANSFORMATION:
DESIGN STEPS:
1. From the given specifications, Find pre-warped analog frequencies using
2
= tan
T 2
2. Using the analog frequencies, find H(s) of the analog filter
2 1 − Z −1
3. Substitute S = in the H(s) of Step:2
T 1 + Z −1
% Calculation of ohmp,ohms,Ap,As
Ap=abs(20*log10(1-Sp));
As=abs(20*log10(Ss));
ohmp=Wp/T;
ohms=Ws/T;
% Butterworth Filter
% Calculation of order and cutoff freq. for the above filter specs.
[n,Wc]=buttord(ohmp,ohms,Ap,As,'s');
% Magnitude Response
Hm=20*log10(abs(H));
subplot(2,1,1);
semilogx(O,Hm);
xlabel('Frequency');
ylabel('Magnitude');
title('Magnitude Response of IIR Filter using Impulse Invariant Method');
% Phase Response
Ha=angle(H);
subplot(2,1,2);
semilogx(O,Ha);
xlabel('Frequency');
ylabel('Phase');
title('Phase Response of IIR Filter using Impulse Invariant Method');
clc;
clear all;
close all;
warning off;
% Design of IIR Filters
%% Filter Specifications
% Input Wp,Ws,Sp,Ss,T
% T=1,both the ripple gains should have band width( .1 to .3)
disp(' Butterworth Lowpass filter using Bilnear transformation method ');
% Calculation of ohmp,ohms,Ap,As
Ap=abs(20*log10(1-Sp));
As=abs(20*log10(Ss));
ohmp=Wp/T;
ohms=Ws/T;
% Butterworth Filter
% Calculation of order and cutoff freq. for the above filter specs.
[n,Wc]=buttord(ohmp,ohms,Ap,As,'s');
% Magnitude Response
Hm=20*log10(abs(H));
subplot(2,1,1);
semilogx(O,Hm);
xlabel('Frequency');
ylabel('Magnitude');
title('Magnitude Response of IIR Filter using Bilinear Transformation Method');
% Phase Response
Ha=angle(H);
subplot(2,1,2);
semilogx(O,Ha);
xlabel('Frequency');
ylabel('Phase');
title('Phase Response of IIR Filter using Bilinear Transformation Method');
clc;
clear all;
close all;
warning off;
% Design of IIR Filters
%% Filter Specifications
% Input Wp,Ws,Sp,Ss,T
% T=1,bothe ripple gains should be b/w .1 to .3
disp(' Chebyshev Lowpass filter using Impulse invariant method ');
% Calculation of ohmp,ohms,Ap,As
Ap=abs(20*log10(1-Sp));
As=abs(20*log10(Ss));
ohmp=Wp/T;
ohms=Ws/T;
% Chebyshev Filter
% Calculation of order and cutoff freq. for the above filter specs.
[n,Wc2]=cheb1ord(ohmp,ohms,Ap,As,'s')
% Magnitude Response
Hm=20*log10(abs(H));
subplot(2,1,1);
semilogx(O,Hm);
xlabel('Frequency');
ylabel('Magnitude');
title('Magnitude Response of IIR Filter using Impulse Invariant Method');
% Phase Response
Ha=angle(H);
subplot(2,1,2);
semilogx(O,Ha);
xlabel('Frequency');
ylabel('Phase');
title('Phase Response of IIR Filter using Impulse Invariant Method');
clc;
clear all;
close all;
warning off;
% Design of IIR Filters
%% Filter Specifications
% Input Wp,Ws,Sp,Ss,T
% T=1,bothe ripple gains should be b/w .1 to .3
disp(' Chebyshev Lowpass filter using Bilnear transformation method ');
% Magnitude Response
Hm=20*log10(abs(H));
subplot(2,1,1);
semilogx(O,Hm);
xlabel('Frequency');
ylabel('Magnitude');
title('Magnitude Response of IIR Filter using Bilinear Transformation Method');
% Phase Response
Ha=angle(H);
subplot(2,1,2);
semilogx(O,Ha);
xlabel('Frequency');
ylabel('Phase');
title('Phase Response of IIR Filter using Bilinear Transformation Method');
Command window:
OUTPUT:
Butterworth Lowpass Bilinear Transformation Method
Command Window :
OUTPUT:
Chebyshev Lowpass Impulse invariant method
Command Window:
OUTPUT:
Chebyshev Lowpass Bilinear Transformation Method
Command Window:
Output:
RESULT:
Butterworth and Chebyshev Lowpass filters were designed using Bilinear and Impulse
Invariant transformations, and manually verified the order, cut off frequency and filter co-
COMPONENTS REQUIRED:
SOURCE CODE:
%To design a lowpass filter FIR filter having 128 coefficients and a cut of frequency of
C = ,
3
% use the same signal except with M=3. First without the prefilter, and then include it to
avoid aliasing.
n = 0:1024;
x = 1/4*sinc(1/4*(n-512)).^2;
xf = filter(h,1,x);
yf = downsample(xf,3);
ynf = downsample(x,3);
X = freqz(x,1,2*pi*f);
Xf = freqz(xf,1,2*pi*f);
Yf = freqz(yf,1,2*pi*f);
Ynf = freqz(ynf,1,2*pi*f);
subplot(411)
plot(f,abs(X))
subplot(412)
plot(f,abs(Ynf))
subplot(413)
plot(f,abs(Xf))
subplot(414)
plot(f,abs(Yf))
print -tiff -depsc multi5.eps
OUTPUT
OUTPUT
RESULT:
The multirate LPF filters (Interpolator and Decimator) are performed by using
MATLAB script and the program results are verified by manual calculation.
AIM:
To write a MATLAB Script to estimate the spectrum using the following non
parametric methods.
a. Periodogram
b. Modified Periodogram
c. Bartlett Method
d. Welch Method
COMPONENTS REQUIRED:
PC, MATLAB software
Periodogram
The periodogram spectral estimator stems from the PSD already defined in equation
Removing the expectation operator and using only a finite data size, the periodogram spectral
estimator is defined as,
Averaged Periodogram
The variance in the periodogram estimator of equation (not decreasing with increasing data
record length) may be due to the removal of the expectation operator, that is, a lack of
averaging. To improve the statistical properties of the the periodogram, the expectation
operator can be approximated by averaging a set of periodograms. Assume that K independent
records of the random process are available for the interval 0 ≤ n ≤ L − 1. Then the averaged
periodogram estimator is defined as,
Bartlett’s Method
Averages several periodograms (rectangular window applied to each) and leads to consistent
estimate of the PSD
Welch method
The Wlech method provides a variation of the averaged periodogram. Recall that the
periodogram is just the average, magnitude squared of the DFT of the signal. The Welch
method differs from the averaged periodogram in two ways. First, the data is windowed and
secondly, data blocks are overlapped. The data window reduces spectral leakage (we see this
later) and by overlapping blocks of data, typically by 50 or 75%, some extra variance
reduction is achieved. The Welch PSD estimator uses the DFT. However, it does it in a clever
way (overlapping samples) such that the PSD estimates, depending on the data set, are often
better than those obtained with the DFT
Multitaper Method
The MTM method uses a bank of optimal bandpass filters to compute the estimate. These
optimal FIRfilters are derived from a set of sequences known as discrete prolate spheroidal
sequences (DPSSs, also known as Slepian sequences). In addition, the MTM method provides
a time-bandwidth parameter with which to balance the variance and resolution. This parameter
is given by the time-bandwidth product, NW and it is directly related to the number of tapers
used to compute the spectrum.
Source Code:
clc;
clear all;
close all;
randn('state',0);
fs = 1000; % Sampling frequency
t = (0:fs/10)./fs; % One-tenth of a second worth of samples
xn = sin(2*pi*150*t) + 2*sin(2*pi*140*t) + 0.1*randn(size(t));
%Periodogram
figure(1)
periodogram(xn,[],1024,fs);
%Modified Periodogram
figure(2)
periodogram(xn,hamming(length(xn)),1024,fs);
%Welch Method
figure(3)
pwelch(xn,hamming(length(xn)),75,512,fs)
%Multitaper Method
figure(4)
pmtm(xn,3/2,1024,fs);
OUTPUT:
RESULT:
Different non-parametric spectral estimation techniques were studied and compared
through matlab script programs
AIM:
To write a MATLAB Script to equalize the digital audio signals
COMPONENTS REQUIRED:
PC, MATLAB software
THEORY:
For an audio application such as the CD player, the digital audio equalizer is used to make the
sound as one desires by changing filter gains for different audio frequency bands. Other
applications include adjusting the sound source to take room acoustics into account, removing
undesired noise, and boosting the desired signal in the specified passband. The simulation is
based on the consumer digital audio processor—such as a CD player—handling the 16-bit
digital samples with a sampling rate of 44.1 kHz and an audio signal bandwidth at 22.05 kHz.
A block diagram of the digital audio equalizer is depicted in this Figure
A seven-band audio equalizer is adopted. The center frequencies are listed in this Table
The 3 dB bandwidth for each bandpass filter is chosen to be 50% of the center frequency. As
shown in Figure, g0 through g6 are the digital gains for each bandpass filter output and can be
adjusted to make sound effects, while y0(n) through y6(n) are the digital amplified bandpass
filter outputs. Finally, the equalized signal is the sum of the amplified bandpass filter outputs
and itself. By changing the digital gains of the equalizer, many sound effects can be produced.
To complete the design and simulation, second-order IIR bandpass Butterworth filters are
chosen for the audio equalizer. The coefficients are achieved using the BLT method, and are
given in this Table
The audio test signal having frequency components of 100 Hz, 200 Hz, 400 Hz, 1,000 Hz,
2,500 Hz, 6,000 Hz, and 15,000 Hz is generated from Equation
After simulation, we notice that the frequency components at 100 Hz, 200 Hz, 6,000 Hz, and
15,000 Hz will be boosted by 20 log10 10 ¼ 20dB.
SOURCE CODE
OUTPUT:
The top plot in this Figure shows the spectrum for the audio test signal, while the bottom plot
depicts the spectrum for the equalized audio test signal. As shown in the plots, before audio
digital equalization, the spectral peaks at all bands are at the same level; after audio digital
equalization, the frequency components at bank 0, bank 1, bank 5, and bank 6 are amplified.
Therefore, as we expected, the operation of the digital equalizer boosts the low frequency
components and the high frequency components.
RESULT:
Thus the Digital audio signals generated were equalized by using MATLAB script program.
AIM
To generate a sinewave form using TMS320C6745 DSP KIT.
COMPONENTS REQUIREMENTS
CCS v4
TMS320C6745 KIT
USB Cable
5V Adapter
ALGORITHM
#include<stdio.h>
#include<math.h>
#define PI 3.14
void main()
{
const float sampf = 1024000.0;// Sampling frquency is fixed
const int inpf = 4000; // change the input frquency from 1khz to
//8khz(1000 to 8000)
float sampt;
double teta;
short value,*sinout;
int i,count,nsamp,value1;
for(i=0;i<400;i++)
*(sinout+i)=0;
for(count=0;count<nsamp;count++)
{
teta = (2 * PI * inpf * sampt * count);
printf("\nteta = %lf",teta);
value1 = value&0x0000FFFF;
*sinout++ = value1;
}
}
OUTPUT
RESULT
Thus, the Sine waveform generation was generated and the sine samples is stored at
memory location(0xc0000000).
AIM
To Generate a Square wave form using TMS320C6745 DSP KIT.
COMPONENTS REQUIREMENTS
CCS v4
TMS320C6745 KIT
USB Cable
5V Adapter
ALGORITHM
1. Create a new project and initialize header file, input, output and variables to the
particular data type.
2. Set the memory address which is used to store the input and output values.
3. The output values (real time) are stored in the DAC Channel 1 memory
address (0xc0000000).
4. The total size of the triangular wave is 4096.The increment order starts from
1024 up to 1024 and decrement order starts from 1024 up to -1024 (totally
4096).
5. The first “for” loop is used for increment order and second “for” loop is used
for decrement order. This is nused for simulation output. The while loop is used
to get real time output.
6. Simulation output is displayed in Graph window & Real time output in the
CRO.
PROCEDURE
The procedures are same as previous experiment.
12. TARGET → RUN.(wait few seconds generate samples)
13. TARGET → HALT.
14. TOOLS → GRAPH → SINGLE TIME
a.Acquirstion buffer size : 1000
b.Index increment : 1
c.Start address : 0xC0000000.
d.Display data size : 1000 → Ok.
SOURCE CODE:
#include <stdio.h>
#include <math.h>
void main()
{
int *Square;
int i;
Square = (int *)0xC0000000;
while(1)
{
for(i=0;i<50;i++)
{
*Square++ = 0x0000FFFF;
}
for(i=0;i<50;i++)
{
*Square++ = 0x0;
}
}
OUTPUT
RESULT
Thus, the Square waveform was generated and samples is stored at memory
location(0xC0000000).
AIM:
To Generate a Triangle wave form using TMS320C6745 DSP KIT.
COMPONENTS REQUIREMENTS
a. CCS v4
b. TMS320C6745 KIT
c. USB Cable
d. 5V Adapter
ALGORITHM
1. Create a new project and initialize header file,input,output and variables to the
particular data type.
2. Set the memory address which is used to store the input and output values.
3. The output values (real time) are stored in the DAC Channel 1 memory
address (0xc0000000).
4. The total size of the triangular wave is 4096.The increment order starts from
1024 up to 1024 and decrement order starts from 1024 up to -1024 (totally
4096).
5. The first “for” loop is used for increment order and second “for” loop is used
for decrement order.This is used for simulation output.The while loop is used to
get real time output.
6. Simulation output is displayed in Graph window & Real time output in the
CRO.
PROCEDURE
SOURCE CODE:
#include <stdio.h>
#include <math.h>
void main()
{
int *Triangle;
int i=0,j=0;
Triangle = (int *)0xC0000000;
while(1)
{
for(i=0;i<50;i++) //set frequency value
{
j=j+1; //set amplitude value
*Triangle++ = j;
}
for(i=50;i>0;i--)
{
j=j-1;
*Triangle++ = j;
}
}
}
OUTPUT:
RESULT:
Thus, the Triangle waveform was generated and samples is stored at memory
location(0xC0000000).
AIM:
To Generate a Sawtooth wave form using TMS320C6745 DSP KIT.
COMPONENTS REQUIREMENTS
a. CCS v4
b. TMS320C6745 KIT
c. USB Cable
d. 5V Adapter
ALGORITHM
1. create a new project and initialize header file,input,output and variables to the
particular data type.
2. Set the memory address which is used to store the input and output values.
3. The output values (real time) are stored in the DAC channel 1 memory
address(0xc0000000).
4. The total size of the sawtooth wave is 4096.The increment order start from -
1024 up to 1024 and decrement order start from 1024 up to -1024 (totally
4096).
5. The first “for” loop is used for increment order and second for loop is used for
decrement order.This is used for simulation output.The while loop used to get
real time output.
6. Simulation output is displayed in Graph window & Real time output in CRO.
PROCEDURE
SOURCE CODE:
#include <stdio.h>
#include <math.h>
void main()
{
int *Sawtooth;
int i=0,j=0;
Sawtooth = (int *)0xC0000000;
while(1)
{
for(i=0;i<100;i++) //set the frequency value
{
j=j+1; //set the amplitude value
*Sawtooth++ = j;
}
j=0;
i=0;
*Sawtooth++ = j;
}
}
OUTPUT:
RESULT:
Thus, the Sawtooth waveform was generated and samples is stored at memory
location(0xC0000000).
AIM:
To perform the Linear Convolution of two given discrete sequence in
TMS320C6745 KIT.
COMPONENTS REQUIREMENTS
a. CCS v4
b. TMS320C6745 KIT
c. USB Cable
d. 5V Adapter
ALGORITHM
1. First declare the two inputs (x&h) and one output memory (y),Declare the
variables (i,k,n,l,m) for loop operation.
2. Declare the two input sequences length(xnlength&hnlength).
3. Give the length of xnlength & hnlength value.
4. Move the input sequence length data into two variables(l,m).
5. Give the input of x& hnvalue.
6. Clear the input,output and sequence length memories.
7. Declare the outer for loop of variables n is initially zero to formulae (l+m-l).
8. Next declare the inner loop of variables k is initially zero to outer loop of
variable n.
9. Finally declare the linear convolution formulae into a loop operation and the
output is stored to the y[n] location.
PROCEDURE:
SOURCE CODE
#include<stdio.h>
void main()
{
int *x,*h,*y,i,n,k,l,m,*xnlength,*hnlength;
xnlength=(int *)0xc0010000;
hnlength=(int *)0xc0100000;
l=*xnlength;
m=*hnlength;
x = (int *)0xc0000000;
h = (int *)0xc0000100;
y = (int *)0xc0001000;
for(i=0;i<(l+m-1);i++)
{
y[i]=0;
x[l+i]=0;
h[m+i]=0;
}
for(n=0;n<(l+m-1);n++)
{
for(k=0;k<=n;k++)
y[n] = (y[n]) + ((x[k])*(h[n-k]));
}
while(1);
}
RESULT
Thus, the Linear Convolution of two given discrete sequence has performed and the
result is stored at memory location(0xc0001000).
AIM
COMPONENTS REQUIREMENTS
CCS v4
TMS320C6745 KIT
USB Cable
5V Adapter
ALGORITHM
1. First declare the two input variables (xn&hn) and one output variables
(y),Declare the variables (i,n,m,n,l,a,b,k) for loop operation.
2. Declare the two input sequences length(xnlength&hnlength).
3. Give the length of xnlength & hnlength value.
4. Give the input of xn & hn value.
5. Next check whether xn length greater or hn length is greater.Take the greater
number that is the length of the circular convolution length(n).
6. Then do memory clear operation.
7. .Next perform convolution operation to two input sequences.For hn[n-k] output
is lesser than 0 means add n (hn[n-k+n],this is perform shifting operation of
second sequences.
8. .The output is stored to the y[n] location.
PROCEDURE
#include<stdio.h>
void main()
{
int *xn,*hn,*y,*xnlength,*hnlength;
int i,n,m,a,b,l,k;
xn = (int *)0xc0000000;
hn = (int *)0xc0000100;
y = (int *)0xc0001000;
xnlength=(int *)0xc0010000;
hnlength=(int *)0xc0100000;
a=*xnlength;
b=*hnlength;
if(a<b)
k=b;
else
k=a;
for(i=0;i<k;i++)
{
y[i]=0;
xn[a+i]=0;
hn[b+i]=0;
}
for(n=0;n<k;n++)
{
for(m=0;m<k;m++)
{
l=n-m;
if(l<0)
l=l+k;
y[n]=y[n]+(xn[m]*hn[l]);
}
}
}
RESULT
Thus, the Circular Convolution of two given discrete sequence has performed
and the result is stored at memory location(0xC0001000).
AIM:
To perform the 8 point FFT using DIT process from a given discrete sequence
in TMS320C6745 KIT.
COMPONENTS REQUIREMENTS
a. CCS v 4
b. TMS320C6745 KIT
c. USB Cable
d. 5V Adapter
ALGORITHM
0xC0001030 – 00000014
0xC0001034 – FFFFFFFB
0xC0001038 – 00000000
0xC000103C – 00000000
0xC0001040 – 00000000
0xC0001044 – 00000000
0xC0001048 – 00000000
0xC000104C – FFFFFFFB
Note: watch window will show exact decimal values, processor memory
location will show a hexadecimal values.
SOURCE CODE
#include <math.h>
#define PI 3.14159
float x[8],t[8],s1[8],s2r[8],s2i[8],Xr[8],Xi[8],Yr[8],Yi[8];
const float W0r = 1,
W0i = 0,
W1r = 0.707,
W1i = -0.707,
W2r = 0,
W2i = -1,
W3r = -0.707,
W3i = -0.707;
void main()
{
int *Input,*Real_out,*Imag_out;
int i=0,j=0;
Input = (int *)0xC0001000;
Real_out = (int *)0xC0001030;
Imag_out = (int *)0xC0001050;
for(i=0;i<8;i++)
{
t[i] = 0;
t[i] = *(Input + i);
}
s2r[1] = s1[1];
s2i[1] = (s1[3] * W2i);
s2r[3] = s1[1];
s2i[3] = - (s1[3] * W2i);
s2r[5] = s1[5];
s2i[5] = (s1[7] * W2i);
s2r[7] = s1[5];
s2i[7] = -(s1[7] * W2i);
// output
// complex multiplication for B * Wn
j=0;
for(i=0;i<4;i++)
{
Xr[i] = s2r[j] + Yr[i];
Xi[i] = s2i[j] + Yi[i];
j++;
}
j=0;
for(i=4;i<8;i++)
{
Xr[i] = s2r[j] - Yr[i];
Xi[i] = s2i[j] - Yi[i];
j++;
}
for(i=0;i<8;i++)
{
*Real_out ++= Xr[i];
*Imag_out ++= Xi[i];
}
for(;;);
}
RESULT
Thus, the 8 point FFT of given discrete sequence has performed and the result
is stored at memory location (0xC0001030 and 0xC0001050).
AIM
To perform the 8 point FFT using DIF process from a given discrete sequence
in TMS320C6745 KIT.
COMPONENTS REQUIREMENTS
a. CCS v 4
b. TMS320C6745 KIT
c. USB Cable
d. 5V Adapter
ALGORITHM
1. First initialize all the inputs and ouputs arrays.
2. Delare the twiddle factor values.
3. Delare the address value of inputs and outputs.(Real value & imaginary).
4. Load the input values to the input array t[8].
5. First stage computation with 2-point dft.
6. second stage computation with 4-point dft.
7. Third stage computation with 8-point dft.
8. Take the bit reversal process.
PROCEDURE
SOURCE CODE
#include <math.h>
#define PI 3.14159
float x[8],tr[8],ti[8],s1r[8],s1i[8],s2r[8],s2i[8],Xr[8],Xi[8],Yr[8],Yi[8];
const float W0r = 1,
W0i = 0,
W1r = 0.707,
W1i = -0.707,
W2r = 0,
W2i = -1,
W3r = -0.707,
W3i = -0.707;
void main()
{
int *Input,*Real_out,*Imag_out;
int i=0;
for(i=0;i<8;i++)
{
x[i] = 0;
x[i] = *(Input + i);
}
// stage one process
s1r[0] = (int)(x[0] + x[4]);
s1i[0] = 0;
s1r[1] = (int)(x[1] + x[5]);
s1i[1] = 0;
s1r[2] = (int)(x[2] + x[6]);
s1i[2] = 0;
s1r[3] = (int)(x[3] + x[7]);
s1i[3] = 0;
s1r[4] = (int)(x[0] - x[4]) * W0r;
s1i[4] = 0;
s1r[5] = (int)(x[1] - x[5]) * W1r;
s1i[5] = (int)(x[1] - x[5]) * W1i;
s1r[6] = 0;
s1i[6] = (int)(x[2] - x[6]) * W2i;
s1r[7] = (int)(x[3] - x[7]) * W3r;
s1i[7] = (int)(x[3] - x[7]) * W3i;
// bit reversal
tr[0] = Xr[0];
ti[0] = Xi[0];
tr[1] = Xr[4];
ti[1] = Xi[4];
tr[2] = Xr[2];
ti[2] = Xi[2];
tr[3] = Xr[6];
ti[3] = Xi[6];
tr[4] = Xr[1];
ti[4] = Xi[1];
tr[5] = Xr[5];
ti[5] = Xi[5];
tr[6] = Xr[3];
ti[6] = Xi[3];
tr[7] = Xr[7];
ti[7] = Xi[7];
// sending output array to memory location
for(i=0;i<8;i++)
{
*Real_out ++= tr[i];
*Imag_out ++= ti[i];
}
for(;;)
}
RESULT
Thus, the 8 point FFT of given discrete sequence has performed and the result
is stored at memory location(0xC0001030 and 0xC0001050).
AIM
To Implement the FIR Low pass filter using TMS320C6745 KIT
COMPONENTS REQUIREMENTS
CCS v4
TMS320C6745 KIT
USB Cable
5V Adapter
Function Generator
DSO
ALGORITHM
1. First include the stdio.h file,math.h file,c6745.h file.spiadc.h file and spidac.h
file.
2. Define the analog to digital converter function.
3. Declare the spi write function.
4. Declare the local variables and global variables.
5. Define the lowpass co-efficent values to the arrays.
6. Initialize the c6745 function,spiadc function,spidac function.
7. set the commands for the read the adc values.
8. Multiply the co-efficent values and adc values and store to the temp variables.
9. Then we add temp plus sum and move to the sum variables.
10. set they delay function (xval[i+1]=xval[i]).
11. Finally adc values sent to spi write function and recover the original signal
from dac.
PROCEDURE
The procedures 1 to 11 steps are same as previous experiment.
12.paste the following header file in the project location.
a.spiadc.h
b.spidac.h
13.Set the sine wave at 3v from function generator.
14.Connect the FG output to ADC connector(jp1).
15. Connect the DSO at DAC connector(j2).
16. TARGET → RUN.
17. Output is displayed at DSO.
18. TARGET → HALT.
FDA tool for low-pass filter co-efficient generation:
Click Matlab ---- Type fdatool
Response type --- Lowpass
Design method --- Fir --- Equiripple
Specify order --- 50
Density factor --- 20
Frequency specifications
Units --- HZ
FS --- 6000
Fpass --- 200
Fstop ---400
Magnitude specification
Wpass --- 1
Wstop --- 1
Generate c Header:
Targets --- Generate c Header
✓ Click Export as
✓ Select single precision floating point
✓ Generate ----- save(any name)
✓ Open the saved folter.
✓ Copy the filter co-efficient and paste (float h[51]) in the program.
SOURCE CODE
#include <stdio.h>
#include <math.h>
#include "c6745.h"
#include "spiadc.h"
#include "spidac.h"
float h[51] = {
0.01060591545, 0.004117832519, 0.004079894163, 0.003353076056,
0.001853102469,
-0.0004065925605,-0.003321184311,-0.006660183426, -0.01010407601, -
0.01322921738,
-0.01557052694, -0.01663137041, -0.01597031951, -0.01320868172,-
0.008123514242,
-0.000646590197, 0.0090885479, 0.02072319016, 0.03375224397,
0.04746999219,
0.06107512116, 0.07372291386, 0.08458722383, 0.09293565154,
0.09818658978,
0.09997936338, 0.09818658978, 0.09293565154, 0.08458722383,
0.07372291386,
0.06107512116, 0.04746999219, 0.03375224397, 0.02072319016,
0.0090885479,
-0.000646590197,-0.008123514242, -0.01320868172, -0.01597031951, -
0.01663137041,
-0.01557052694, -0.01322921738, -0.01010407601,-0.006660183426,-
0.003321184311,
-0.0004065925605, 0.001853102469, 0.003353076056, 0.004079894163,
0.004117832519,
0.01060591545
};
C6745_init();
spiadc_init();
spidac_init();
for(i=0;i<52;i++)
{
xval[i]=0;
}
while(1)
{
spiadcbuf[0] = 0x01; // setup command
spiadcbuf[1] = 0xBF;
spiadcbuf[2] = 0x00;
xval[0] = adc_value;
sum = 0;
for(k=0;k<51;k++)
{
temp = (xval[k])*(h[k]);
sum = sum + temp;
}
SPI_Write(sum);
for(i=50;i>=0;i--)
{
xval[i+1] = xval[i];
}
}
}
/****************************/
/* GLCD SPI Sent Data 8 bit */
/****************************/
void SPI_Write(unsigned short Data)
{
unsigned short receive;
DAC_CS_LOW();
Data = ( 0x3000 | Data );
/* Write 1 byte */
SPI0_SPIDAT1 = Data;
while((SPI0_SPIBUF & 0x20000000)==1);
/* Read 1 byte */
receive = SPI0_SPIBUF;
for(i=0;i<10;i++);
DAC_CS_HIGH();
}
INPUT
OUTPUT
RESULT
Thus, the FIR Low pass filter was Implemented and displayed the results in
console window.
AIM
To Implement the FIR High pass filter using TMS320C6745 KIT
COMPONENTS REQUIREMENTS
a. CCS v4
b. TMS320C6745 KIT
c. USB Cable
d. 5V Adapter
e. Function Generator
f. DSO
ALGORITHM
1. First include the stdio.h file,math.h file,c6745.h file.spiadc.h file and spidac.h
file.
2. Define the analog to digital converter function.
3. Declare the spi write function.
4. Declare the local variables and global variables.
5. Define the highpass co-efficent values to the arrays.
6. Initialize the c6745 function,spiadc function,spidac function.
7. set the commands for the read the adc values.
8. Multiply the co-efficent values and adc values and store to the temp variables.
9. Then we add temp plus sum and move to the sum variables.
10. Then add the DC offset value(1625) with sum variable.
11. .set they delay function (xval[i+1]=xval[i]).
12. .Finally adc values sent to spi write function and recover the original signal
from dac.
PROCEDURE
Frequency specifications
Units ---HZ
FS --- 6000
Fpass --- 400
Fstop --- 200
Magnitude specification
Wpass --- 1
Wstop --- 1
Generate c Header:
Targets --- Generate c Header
✓ Click Export as
✓ Select single precision floating point
✓ Generate ----- save(any name)
✓ Open the saved folter.
✓ Copy the filter co-efficient and paste (float h[51]) in the program.
SOURCE CODE
#include <stdio.h>
#include <math.h>
#include "c6745.h"
#include "spiadc.h"
#include "spidac.h"
float h[51] ={
-0.01060591545,-0.004117832519,-0.004079894163,-0.003353076056,-
0.001853102469,
0.0004065925605, 0.003321184311, 0.006660183426, 0.01010407601,
0.01322921738,
0.01557052694, 0.01663137041, 0.01597031951, 0.01320868172,
0.008123514242,
0.000646590197, -0.0090885479, -0.02072319016, -0.03375224397, -
0.04746999219,
-0.06107512116, -0.07372291386, -0.08458722383, -0.09293565154, -
0.09818658978,
0.900020659, -0.09818658978, -0.09293565154, -0.08458722383, -
0.07372291386,
-0.06107512116, -0.04746999219, -0.03375224397, -0.02072319016, -
0.0090885479,
0.000646590197, 0.008123514242, 0.01320868172, 0.01597031951,
0.01663137041,
0.01557052694, 0.01322921738, 0.01010407601, 0.006660183426,
0.003321184311,
0.0004065925605,-0.001853102469,-0.003353076056,-0.004079894163,-
0.004117832519,
-0.01060591545
};
void main( void )
{
Uint8 spiadcbuf[3];
int i,xval[120],k;
float temp,sum;
C6745_init();
spiadc_init();
spidac_init();
for(i=0;i<52;i++)
{
xval[i]=0;
}
while(1)
{
spiadcbuf[0] = 0x01; // setup command
spiadcbuf[1] = 0xBF;
spiadcbuf[2] = 0x00;
xval[0] = adc_value;
sum = 0;
for(k=0;k<51;k++)
{
temp = (xval[k])*(h[k]);
sum = sum + temp;
}
SPI_Write(sum+1625);
for(i=50;i>=0;i--)
{
xval[i+1] = xval[i];
}
}
}
/****************************/
/* GLCD SPI Sent Data 8 bit */
/****************************/
void SPI_Write(unsigned short Data)
{
unsigned short receive;
DAC_CS_LOW();
Data = ( 0x3000 | Data );
/* Write 1 byte */
SPI0_SPIDAT0 = Data;
while((SPI0_SPIBUF & 0x20000000)==1);
/* Read 1 byte */
receive = SPI0_SPIBUF;
for(i=0;i<10;i++);
DAC_CS_HIGH();
}
INPUT
OUTPUT
RESULT
Thus, the FIR High pass filter was Implemented and displayed the results in
console window.
AIM:
To Implement the IIR Low pass filter using TMS320C6745 KIT
COMPONENTS REQUIREMENTS
CCS v4
TMS320C6745 KIT
USB Cable
5V Adapter
Function Generator
DSO
ALGORITHM
Order --- 2
Frequency :
Response --- select Lowpass
Type the a0,a1,a2 & b0,b1,b2 and Gain value (float &#define GAIN) in your c
code.
SOURCE CODE
#include <stdio.h>
#include <math.h>
#include "c6745.h"
#include "spiadc.h"
#include "spidac.h"
C6745_init();
spiadc_init();
spidac_init();
while(1)
{
spiadcbuf[0] = 0x01; // setup command
spiadcbuf[1] = 0xBF;
spiadcbuf[2] = 0x00;
vout = Chebyshev(adc_value);
SPI_Write(vout);
}
}
/****************************/
/* GLCD SPI Sent Data 8 bit */
/****************************/
void SPI_Write(unsigned short Data)
{
unsigned short receive,j;
DAC_CS_LOW();
Data = ( 0x3000 | Data );
/* Write 1 byte */
SPI0_SPIDAT1 = Data;
while((SPI0_SPIBUF & 0x20000000)==1);
/* Read 1 byte */
receive = SPI0_SPIBUF;
for(j=0;j<10;j++);
DAC_CS_HIGH();
}
INPUT:
OUTPUT:
RESULT
Thus, the IIR Low pass filter was Implemented and displayed the results in dso
window.
AIM
To Implement the IIR High pass filter using TMS320C6745 KIT.
COMPONENTS REQUIREMENTS
CCS v4
TMS320C6745 KIT
USB Cable
5V Adapter
Function Generator
DSO
ALGORITHM
SOURCE CODE
#include <stdio.h>
#include <math.h>
#include "c6745.h"
#include "spiadc.h"
#include "spidac.h"
C6745_init();
spiadc_init();
spidac_init();
while(1)
{
spiadcbuf[0] = 0x01;
// setup command
spiadcbuf[1] = 0xBF;
spiadcbuf[2] = 0x00;
spiadc_cycle(spiadcbuf, 3);
//
Execute spiadc read cycle
adc_value = ((spiadcbuf[1]&0x0f) << 8)| spiadcbuf[2];
vout = Chebyshev(adc_value);
vout = vout + DCOFFSET;
if(vout>4095) vout=4095;
SPI_Write(vout);
}
}
/****************************/
/* GLCD SPI Sent Data 8 bit */
/****************************/
void SPI_Write(unsigned short Data)
{
unsigned short receive,j;
DAC_CS_LOW();
Data = ( 0x3000 | Data );
/* Write 1 byte */
SPI0_SPIDAT1 = Data;
while((SPI0_SPIBUF & 0x20000000)==1);
/* Read 1 byte */
receive = SPI0_SPIBUF;
for(j=0;j<10;j++);
DAC_CS_HIGH();
}
INPUT:
OUTPUT:
RESULT
Thus, the IIR High pass filter was implemented and displayed the results in DSO
window.
AIM
COMPONENTS REQUIREMENTS
CCS v4
TMS320C6745 KIT
USB Cable
5V Adapter
ADDRESSING MODES
The addressing modes in TMS320C6745
1. Register addressing mode
2. Memory mapped addressing mode
3. Linear addressing mode
4. Circular addressing mode
Input Output
12345678 ---- A2 A1(0XC0000000) ---- 99CE4COB
8799F593 ---- A3
Blinking LED:
Linear convolution:
nop 7
stw a2,*a4++ ;clear the a4 memory address location
nop 7
stw a2,*a5++ ;clear the a5 memory address location
nop 7
stw a2,*a6++ ;clear the a6 memory address location
nop 7
sub b2,1h,b2 ;8 times decrement looping operation
nop 2
[b2] b zer ;if(b2>0), go to zer function
nop 6 ;if(b2<0), go to next operation
mvkh 0xC0000100,a1
mvkl 0xC0000300,a3 ; 0xc0000300 address move to a3 Register
mvkh 0xC0000300,a3
ldw *a4++[1],a8 ;Increment the a4 address and a4 value load to a8
nop 6 ;Register
stw a8,*a3 ;Store a8 value to a3 Register address
nop 6
mvkl 4h,b0 ;4h value move to b0 register for looping
mvkh 4h,b0
nop 3
MVKL 00000000H,a7 ;0h value move to a7 Register
MVKh 00000000H,a7
loop1:
ldw *a1++,a5 ;a1 Register value lode to a5 Register and
increment the a1 Register address
nop 6
ldw *a3++,a6 ;a3 Register value lode to a6
Register and
nop 6 ; increment the a3 address
mpy a5,a6,a6 ;Multiply a5*a6 and move to a6 Register
nop 4
add a7,a6,a7 ;Add a7+a6 and move to a7 Register
nop 2
sub b0,1,b0 ;Decrement looping for 4 times
nop 2
[b0] b loop1 ;if(b0>0) , go to loop1
nop 7 ;if(b0<0) , go to next operation
stw a7,*a9++[1] ;Store a7 value in incremented a9 Register
address
nop 6
mvkl 4h,b0 ;4h value move to b0 register for looping
mvkh 4h,b0
mvkl 0xC0000300,b3 ; 0xc0000300 address move to a3 Register
mvkh 0xC0000300,b3
ldw *b3,b4 ;load b3 value into b4 Register
nop 6
loop2:
ldw *+b3(4),b5 ;b3 value load to b5 Register but b3 address not
nop 6 ;incremented
stw b4,*++b3 ;b4 value store to incremented b3 Register
nop 6
mv b5,b4 ;Move b5 Register to b4 Register
nop 2
sub b0,1,b0 ;Decrement looping for 4 times
nop 2
Circular convolution:
Input: Output:
x(n) h(n) y(n)
0XC0000000 --- 1 0XC0000100 --- 1 0XC0000200 --- 18
0XC0000004 --- 2 0XC0000104 --- 2 0XC0000204 --- 19
0XC0000008--- 3 0XC0000108 --- 3 0XC0000208 --- 16
0XC000000C --- 4 0XC000010C --- 3 0XC000020C --- 13
-include_path,-I)) select this add icon and add the following three path by
indivdually
➔ "${Diag}../../common/header"
➔ "${XDAIS_CG_ROOT}/packages/ti/xdais"
➔ "${C6000_CSL_CG_ROOT}/include"
8. FILE → NEW → TARGET CONFIGURATION FILE
a. file name: projectname. ccxml (.ccxml extension is must)
b. Connection: Texas Instrument XDS100 v1 USB Emulator.
c. Device: TMS320C6745. → SAVE → TARTGET CONFIGURATION
→C674X_0 →BROWSE, browse the workspace location, open the gel folder
and select the GEL file. → OPEN →SAVE.
9. In C/C++ Project window, Right click the project →REBUILD PROJECT.
10. Connections :
a. Connect the usb cable, in between PC to KIT.
b. Connect the 5v adapter and Power on the kit.
11. TARGET → DEBUG ACTIVE PROJECT.(Then see out at corresponding
place after run)
12. VIEW → MEMORY
13. In right side, memory window will open. Type the output adrress
0xC0001000
14. TARGET → RUN.
15. TARGET → HALT.
See the Output at Particular location:
0xC0000000 – 99CE4C0B........
RESULT:
The study of various addressing modes of TMS320C6745 DSP processor was
verified.
AIM
To Analysis of finite wordlength effects in floating point systems by using
TMS320C6745 Kit.
COMPONENTS REQUIREMENTS
CCS v4
TMS320C6745 KIT
USB Cable
5V Adapter
ALGORITHM
1. First include the header files and define the order of filter and define PI value.
2. Declare the filter coefficients without finite word length effect (or without
truncated values).
3. Declare the filter coefficients with finite word length effect (or with truncated
values).
4. Declare the input sample to the system.
5. .Declare the local variables in the main function.
6. Clearing the memory location.
7. Then do the convolution of without truncated filter coefficient with input
samples.
8. Then do the convolution of with truncated filter coefficient with input samples.
9. Finally print the output in console window
PROCEDURE
The procedure 1 to 11 steps are same as previous experiment
12. TARGET → RUN.(print the output in console window)
13. TARGET → HALT.
SOURCE CODE
#include<stdio.h>
#include <math.h>
#define N 10 // Order of filter
#define PI 3.14
// Filter Coefficents without finite word length effect (or without truncated values)
float coeff1[10] = {
8.6589421428571428571428571428571,
6.7794628518236352561053631471054,
3.8972346426831024540136532012540,
1.7564427498245744124212425412421,
0.9897547424241245242575225821010,
4.1489257262414010254101210211256,
7.7854962145874965135871587526322,
9.6587900787865645342354687900978,
2.9786543211246679087664433221121,
0.0975313354566778980909887654329,
};
float OSample1[10];
float OSample2[10];
void main()
{
unsigned int i=0,j=0;
unsigned int n=0;
unsigned int k=0;
}
OUTPUT:
RESULT
Thus the finite word length effects output was verified in console window.