Professional Documents
Culture Documents
COLLEGE
(AUTONOMOUS)
Sree Sainath Nagar, A. Rangampet, Tirupathi - 517102.
IV B. Tech.(ECE) I Sem.
Lab Record
Name:
Roll No.:
1
Name of the Lab (Course Code): Digital Signal Processing Lab (14BT70421)
Class: IV B. Tech (ECE) I Sem.
TABLE OF CONTENTS
EXP.NO DATE NAME OF THE EXPERIMENT PAGE.NO. SIGNATURE
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
2
DATE: EXPERIMENT No.:
Source code:
clc;
clear all;
A=input('Enter (1-4) 1.Low pass 2.High pass 3.Band pass 4.Band stop ');
switch (A)
case 1
rp=input('pass band ripples ');
rs=input('stop band ripples ');
fp=input('pass band freq ');
fs=input('stop band freq ');
f=input('Sampling freq ');
wp=fp/f;
ws=fs/f;
[n,wn]=buttord(wp,ws,rp,rs,'s');
[b,a]=butter(n,wn,'s');
3
case 2
rp=input('pass band ripples');
rs=input('stop band ripples');
fp=input('pass band freq');
fs=input('stop band freq');
f=input('Sampling freq');
wp=fp/f;
ws=fs/f;
[n,wn]=buttord(wp,ws,rp,rs,'s');
[b,a]=butter(n,wn,'high','s');
case 3
rp=input('pass band ripples');
rs=input('stop band ripples');
fs1=input('stop band freq-1');
fp1=input('pass band freq-1');
fp2=input('pass band freq-2');
fs2=input('stop band freq-2');
f=input('Sampling freq');
wp1=fp1/f;
ws1=fs1/f;
wp2=fp2/f;
ws2=fs2/f;
wp=[wp1 wp2];
ws=[ws1 ws2];
[n,wn]=buttord(wp,ws,rp,rs,'s');
[b,a]=butter(n,wn,'bandpass','s');
case 4
rp=input('pass band ripples');
rs=input('stop band ripples');
fp1=input('pass band freq-1');
fs1=input('stop band freq-1');
fs2=input('stop band freq-2');
fp2=input('pass band freq-2');
f=input('Sampling freq');
wp1=fp1/f;
ws1=fs1/f;
wp2=fp2/f;
ws2=fs2/f;
wp=[wp1 wp2];
ws=[ws1 ws2];
[n,wn]=buttord(wp,ws,rp,rs,'s');
[b,a]=butter(n,wn,'stop','s');
end
4
w=0:0.01:pi;
[h,wm]=freqs(b,a,w);
m=20*log10(abs(h));
a=angle(h);
subplot(2,1,1);
plot(wm/pi,m);
ylabel('Gain in dB');
xlabel('Norm.freq');
title('MAGNITUDE RESPONSE');
grid on;
subplot(2,1,2);
plot(wm/pi,a);
ylabel('Phase in radians');
xlabel('Norm.freq');
title('PHASE RESPONSE');
grid on;
Command window:
Enter (1-4) 1.Low pass 2.High pass 3.Band pass 4.Band stop 1
pass band ripples 3
stop band ripples 15
pass band freq 1200
stop band freq 1800
Sampling freq 4000
5
Butterworth filter:
Low pass: High pass:
6
Result:
Analog Butterworth Filters were modelled using MATLAB functions and their
frequency response for defined specifications was plotted.
7
DATE: EXPERIMENT No.:
1. Type-1 Chebyshev filter: These filters are all pole filters. In the passband, these
filters show equi-ripple behaviour and they have monotonic characteristics in
the stopband.
2. Type-2 Chebyshev filter: This Filter Contains zeros as well as poles.
8
Source code:
clc;
clear all;
A=input('Enter (1-4) 1.Low pass 2.High pass 3.Band pass 4.Band stop ');
switch (A)
case 1
rp=input('pass band ripples ');
rs=input('stop band ripples ');
fp=input('pass band freq ');
fs=input('stop band freq ');
f=input('Sampling freq ');
wp=fp/f;
ws=fs/f;
[n,wn]=cheb1ord(wp,ws,rp,rs,'s');
[b,a]=cheby1(n,rp,wn,'s');
case 2
rp=input('pass band ripples');
rs=input('stop band ripples');
fp=input('pass band freq');
fs=input('stop band freq');
f=input('Sampling freq');
wp=fp/f;
ws=fs/f;
[n,wn]=cheb1ord(wp,ws,rp,rs,'s');
[b,a]=cheby1(n,rp,wn,'high','s');
case 3
rp=input('pass band ripples');
rs=input('stop band ripples');
fs1=input('stop band freq-1');
fp1=input('pass band freq-1');
fp2=input('pass band freq-2');
fs2=input('stop band freq-2');
f=input('Sampling freq');
wp1=fp1/f;
ws1=fs1/f;
wp2=fp2/f;
ws2=fs2/f;
wp=[wp1 wp2];
ws=[ws1 ws2];
[n,wn]=cheb1ord(wp,ws,rp,rs,'s');
[b,a]=cheby1(n,rp,wn,'bandpass','s');
case 4
rp=input('pass band ripples');
9
rs=input('stop band ripples');
fp1=input('pass band freq-1');
fs1=input('stop band freq-1');
fs2=input('stop band freq-2');
fp2=input('pass band freq-2');
f=input('Sampling freq');
wp1=fp1/f;
ws1=fs1/f;
wp2=fp2/f;
ws2=fs2/f;
wp=[wp1 wp2];
ws=[ws1 ws2];
[n,wn]=cheb1ord(wp,ws,rp,rs,'s');
[b,a]=cheby1(n,rp,wn,'stop','s');
end
w=0:0.01:pi;
[h,wm]=freqs(b,a,w);
m=20*log10(abs(h));
a=angle(h);
subplot(2,1,1);
plot(wm/pi,m);
ylabel('Gain in dB');
xlabel('Norm.freq');
title('MAGNITUDE RESPONSE');
grid on;
subplot(2,1,2);
plot(wm/pi,a);
ylabel('Phase in radians');
xlabel('Norm.freq');
title('PHASE RESPONSE');
grid on;
Command Window:
Enter (1-4) 1.Low pass 2.High pass 3.Band pass 4.Band stop 2
pass band ripples 3
stop band ripples 15
pass band freq 1800
stop band freq 1200
Sampling freq 4000
10
Chebyshev filter:
Low pass: High pass:
11
Result:
Analog Chebyshev (Type-1) Filters were modelled using MATLAB functions
and their frequency response for defined specifications was plotted.
12
DATE: EXPERIMENT No.:
The frequency-sampling method for FIR filter design is illustrated in the context
of the window method for FIR filter design, to which we now turn.
Source code:
clc;
clear all;
fs=10000;
ts=1/fs;
ns=512;
t=[0:ts:ts*(ns-1)];
f1=1000;
f2=1500;
f3=2500;
f4=4000;
f5=4500
x1=sin(2*pi*f1*t);
x2=sin(2*pi*f2*t);
x3=sin(2*pi*f3*t);
x4=sin(2*pi*f4*t);
x5=sin(2*pi*f5*t);
13
x=x1+x2+x3+x4+x5;
N=16;
w=[0.4 0.6];
w1=0.4;
c=input('Enter choice 1.LPF 2.HPF 3.BPF 4.BSF-');
if(c==1)
w=0.4;
B=fir1(N,w);
end
if(c==2)
w=0.4;
B=fir1(N,w,'high');
end
if(c==3)
w=[0.4 0.6];
B=fir1(N,w,'DC-0');
end
if(c==4)
w=[0.4 0.6];
B=fir1(N,w,'DC-1');
end
disp(B)
A=1;
freqz(B,A);
figure;
subplot(2,1,1);
Npts=200;
plot(t(1:Npts),x(1:Npts));
title('Input signal');
xlabel('time');
ylabel('Amplitude');
y=filter(B,A,x);
subplot(2,1,2);
plot(t(1:Npts),y(1:Npts));
title('Filtered signal');
xlabel('time');
ylabel('Amplitude');
figure;
subplot(2,1,1);
xfftmag=abs(fft(x,ns));
xfftmagh=xfftmag(1:length(xfftmag)/2);
f=[1:1:length(xfftmagh)]*fs/ns;
plot(f,xfftmagh);
14
title('Input spectrum');
xlabel('frequency');
ylabel('Amplitude');
subplot(2,1,2);
yfftmag=abs(fft(y,ns));
yfftmagh=yfftmag(1:length(yfftmag)/2);
f=[1:1:length(yfftmagh)]*fs/ns;
plot(f,yfftmagh);
title('Filtered spectrum');
xlabel('frequency');
ylabel('Amplitude');
15
Low pass:
16
High pass:
17
Band pass:
18
Band stop:
19
Result:
FIR Filters were modelled using MATLAB functions and their frequency
response, Input and output spectrum for defined specifications were plotted.
20
DATE: EXPERIMENT No.:
y(n) x(k)h(n k) 0 n N 1
k 0
In this equation, x(k) and y(n) represent the input to and output from the filter
at time n. h(n-k) is the transversal filter coefficients at time n. These
coefficients are generated by using FDS (Filter Design Software or Digital
filter design package).
FIR filter is a finite impulse response filter. Order of the filter should be
specified. Infinite response is truncated to get finite impulse response. Placing
a window of finite length does this. Types of windows available are
Rectangular, Bartlett, Hamming, Hanning, Blackmann window etc., This FIR
filter is an all zero filter.
Source code:
clc;
close all;
clear all;
fp=input('Enter the pass band frequency-');
fs=input('Enter the stop band frequency-');
rp=input('Enter the pass band attenuation-');
21
rs=input('Enter the stop band attenuation-');
f=input('Enter the sampling frequency-');
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=abs(ceil(num/dem));
wp=fp/f;
ws=fs/f;
if(rem(n,2)==0)
m=n+1;
else
m=n;
n=n-1;
end
c=input('Enter req. window 1.Rectangular 2.Triangular 3.Hamming 4.Hanning
5.Blackmann 6.Kaiser');
if(c==1)
w=rectwin(m);
end
if(c==2)
w=triang(m);
end
if(c==3)
w=hamming(m);
end
if(c==4)
w=hann(m);
end
if(c==5)
w=blackman(m);
end
if(c==6)
b=input('Enter beta value');
w=kaiser(m,b);
end
fil=input('Enter req filter 1.LPF 2.HPF 3.BPF 4.BSF-');
if(fil==1)
B=fir1(n,wp,'low',w);
[h,o]=freqz(B,1,256);
end
if(fil==2)
B=fir1(n,wp,'high',w);
[h,o]=freqz(B,1,256);
end
22
if(fil==3)
wn=[wp ws];
B=fir1(n,wn,'band',w);
[h,o]=freqz(B,1,256);
end
if(fil==4)
wn=[wp ws];
B=fir1(n,wn,'stop',w);
[h,o]=freqz(B,1,256);
end
mag=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);
plot(o/pi,mag);
title('Magnitude response');
xlabel('Normalized frequency');
ylabel('Gain in dB');
subplot(2,1,2);
plot(o/pi,an);
title('Phase response');
xlabel('Normalized frequency');
ylabel('Gain in dB');
grid on;
COMMAND WINDOW:
Enter the pass band frequency-2000
Enter the stop band frequency-4000
Enter the pass band attenuation-3
Enter the stop band attenuation-15
Enter the sampling frequency-8000
Enter req. window 1.Rectangular 2.Triangular 3.Hamming 4.Hanning
5.Blackmann 6.Kaiser6
Enter beta value 0.5
Enter req filter 1.LPF 2.HPF 3.BPF 4.BSF-2
23
Rectangular window:
Low pass: High pass:
24
Triangular window
Low pass: High pass:
25
Hamming window:
Low pass: High pass:
26
Hanning window:
Low pass: High pass:
27
Blackmann window
Low pass: High pass:
28
Kaiser window:
Low pass: High pass:
29
Result:
FIR Filters were modelled using windowing techniques and their frequency
response for defined specifications were plotted.
30
DATE: EXPERIMENT No.:
case 3
rp=input('pass band ripples');
rs=input('stop band ripples');
fs1=input('stop band freq-1');
fp1=input('pass band freq-1');
fp2=input('pass band freq-2');
fs2=input('stop band freq-2');
f=input('Sampling freq');
wp1=fp1/f;
ws1=fs1/f;
wp2=fp2/f;
ws2=fs2/f;
wp3=[wp1 wp2];
ws3=[ws1 ws2];
wp=2*f*tan(wp3/2);
ws=2*f*tan(ws3/2);
[n,wn]=buttord(wp,ws,rp,rs,'s');
[num,den]=butter(n,wn,'bandpass','s');
32
case 4
rp=input('pass band ripples');
rs=input('stop band ripples');
fp1=input('pass band freq-1');
fs1=input('stop band freq-1');
fs2=input('stop band freq-2');
fp2=input('pass band freq-2');
f=input('Sampling freq');
wp1=fp1/f;
ws1=fs1/f;
wp2=fp2/f;
ws2=fs2/f;
wp3=[wp1 wp2];
ws3=[ws1 ws2];
wp=2*f*tan(wp3/2);
ws=2*f*tan(ws3/2);
[n,wn]=buttord(wp,ws,rp,rs,'s');
[num,den]=butter(n,wn,'stop','s');
end
[b,a]=bilinear(num,den,f);
w=0:0.01:pi;
[h,wm]=freqz(b,a,w);
m=20*log(abs(h));
an=angle(h);
subplot(2,1,1);
plot(wm/pi,m);
grid on;
xlabel('Norm freq');
ylabel('Gain in db');
title('Magnitude response');
subplot(2,1,2);
plot(wm/pi,an);
grid on;
ylabel('Phase in radians');
xlabel('Norm freq');
title('Phase response');
33
Command window:
Enter (1-4) 1.Low pass 2.High pass 3.Band pass 4.Band stop 3
pass band ripples 3
stop band ripples 15
stop band freq-1 500
pass band freq-1 1000
pass band freq-2 2000
stop band freq-2 2500 Sampling freq 6000
34
Band pass: Band stop:
RESULT:
IIR filters were modelled from Analog Butterworth filters using Bilinear
Transformation and its frequency response were plotted for pre-wrapped
specifications.
35
DATE: EXPERIMENT No.:
36
feature, with identical gain and phase shift, in the frequency response of the
digital filter.
Source code:
clc;
clear all;
close all;A=input('Enter (1-4) 1.Low pass 2.High pass 3.Band pass 4.Band stop
');
switch (A)
case 1
rp=input('pass band ripples ');
rs=input('stop band ripples ');
fp=input('pass band freq ');
fs=input('stop band freq ');
f=input('Sampling freq ');
wp1=fp/f;
ws1=fs/f;
wp=2*f*tan(wp1/2);
ws=2*f*tan(ws1/2);
[n,wn]=cheb1ord(wp,ws,rp,rs,'s');
[num,den]=cheby1(n,rp,wn,'s');
case 2
rp=input('pass band ripples');
rs=input('stop band ripples');
fp=input('pass band freq');
fs=input('stop band freq');
f=input('Sampling freq');
wp1=fp/f;
ws1=fs/f;
wp=2*f*tan(wp1/2);
ws=2*f*tan(ws1/2);
[n,wn]=cheb1ord(wp,ws,rp,rs,'s');
[num,den]=cheby1(n,rp,wn,'high','s');
case 3
rp=input('pass band ripples');
rs=input('stop band ripples');
fs1=input('stop band freq-1');
fp1=input('pass band freq-1');
fp2=input('pass band freq-2');
fs2=input('stop band freq-2');
f=input('Sampling freq');
wp1=fp1/f;
ws1=fs1/f;
37
wp2=fp2/f;
ws2=fs2/f;
wp3=[wp1 wp2];
ws3=[ws1 ws2];
wp=2*f*tan(wp3/2);
ws=2*f*tan(ws3/2);
[n,wn]=cheb1ord(wp,ws,rp,rs,'s');
[num,den]=cheby1(n,rp,wn,'bandpass','s');
case 4
rp=input('pass band ripples');
rs=input('stop band ripples');
fp1=input('pass band freq-1');
fs1=input('stop band freq-1');
fs2=input('stop band freq-2');
fp2=input('pass band freq-2');
f=input('Sampling freq');
wp1=fp1/f;
ws1=fs1/f;
wp2=fp2/f;
ws2=fs2/f;
wp3=[wp1 wp2];
ws3=[ws1 ws2];
wp=2*f*tan(wp3/2);
ws=2*f*tan(ws3/2);
[n,wn]=cheb1ord(wp,ws,rp,rs,'s');
[num,den]=cheby1(n,rp,wn,'stop','s');
end
[b,a]=bilinear(num,den,f);
w=0:0.01:pi;
[h,wm]=freqz(b,a,w);
m=20*log(abs(h));
an=angle(h);
subplot(2,1,1);
plot(wm/pi,m);
grid on;
xlabel('Norm freq');
ylabel('Gain in db');
title('Magnitude response');
subplot(2,1,2);
plot(wm/pi,an);
grid on;
ylabel('Phase in radians');
xlabel('Norm freq');
38
title('Phase response');
Command window:
Enter (1-4) 1.Low pass 2.High pass 3.Band pass 4.Band stop 2
pass band ripples 3
stop band ripples 15
pass band freq1 800
stop band freq1 200
Sampling freq 4000
39
Band pass: Band stop:
RESULT:
IIR filters were modelled from Analog Chebyshev Type-1 filters using Bilinear
Transformation and its frequency response were plotted for prewrapped
specifications.
40
FAMILIARIZATION WITH CODE COMPOSER STUDIO
Step T1:
Launch the CCS v4 icon from the Desktop or goto All Programs ->Texas Instruments ->CCSv4
Step T2:
Choose the location for the workspace, where your project will be saved.
Step T3:
Click the CCS icon from the welcome page to go the workbench, it is marked in the below picture.
Step T4:
From the Target menu select New target Configuration
Target -> New target Configuration.
41
It will open a window like given below.
Specify any arbitrary target name. For Eg., 6748config.ccxml (Extension should be .ccxml).
Location will set one default folder in current user account. Its also allowed to change the location.
Click Finish it will open a configuration window for the created target.
Step T5:
Select the Connection: Texas instruments XDS100v1 USB Emulator
Select the Device: TMS320C6748.
*To make the search easy type 6748 in the space provided.
42
Next goto Advanced tab give the suitable gel file path as shown below.
Step T6:
Go to view option and select the Target Configuration:
View->Target Configuration.
A wizard will open in the workspace expand the User Defined folder and you can find your target,
Right click on 6748config.ccxml and select the Launch Selected Configuration.
Step T7:
Connect the target
Target -> Connect Target
In future we no need to repeat these steps. If we are working with the same hardware we can just open
the already configured target and launch the selected configuration and connect it.
43
Procedure to create New Project
Program 1:
Procedure to create a simple non-real time project Hello world
Step P1:
Change the Perspective Debug to C/C++ from the right corner of the CCS
Step P2:
Go to File New CCS Project.
Step P3:
Specify the name of the project in the space provided
Eg., Project Name: Hello World
Click Next
44
Select the project type
Click Next
*However our target is based on C6000 family, Based on the family we need to select the Project
Type.
45
.
Click finish
Specify the arbitrary source file name. It should be in the source folder(current project name.).
Note:
Step P5:
Go to
If your code doesnt have any errors and warnings, a message will be printed in the console window
that
47
Step P6:
After successful Build, Debug your code in to the hardware by selecting the option
48
Now press reset button in 6748 hardware then click on retry.
Once you click on retry ccs eill load program on to processor and then ccs will guide us to debug
mode, if it is not done automatically.
Change the Perspective C/C++ to Debug from the right corner of the CCS.
Step P7:
Now you can run the code, by selecting the option run from the dialog box else you can
Go to Target Run
49
Once you run the program the output will be printed in the Console Window.
50
DATE: EXPERIMENT No.:
Theory:
Convolution is a formal mathematical operation, just as multiplication, addition,
and integration. Addition takes two numbers and produces a third number, while
convolution takes two signals and produces a third signal. Convolution is used in
the mathematics of many fields, such as probability and statistics. In linear
systems, convolution is used to describe the relationship between three signals of
interest: the input signal, the impulse response, and the output signal.
Mathematical formulae:
The linear convolution of two continuous time signals x(t) and h(t) is defined by
Where x(n) is the input signal and h(n) is the impulse response of the system.
51
Source code:
#include<stdio.h>
int x[15],y[15],h[15];
void main()
{
int i,j,m,n;
printf("Enter the values for m= \n");
scanf("%d",&m);
printf("Enter value of n= \n");
scanf("%d",&n);
printf("Enter values of input x[m]\n");
for(i=0;i<m;i++)
{
scanf("%d",&x[i]);
}
printf("Enter values for h[n]\n");
for(i=0;i<n;i++)
{
scanf("%d",&h[i]);
}
for(i=0;i<m+n-1;i++)
{
y[i]=0;
for(j=0;j<=i;j++)
{
y[i]=y[i]+(x[j]*h[i-j]);
}
}
for(i=0;i<m+n-1;i++)
printf("output is y[%d]=%d\n",i,y[i]);
}
52
OBSERVATIONS FROM CONSOLE:
Enter the values for m= 4
Enter the values for n= 4
Enter values of input x[m]
1234
Enter values of input h[n]
5678
Output is
Y[0]=5
Y[1]=16
Y[2]=34
Y[3]=60
Y[4]=61
Y[5]=52
Y[6]=32
53
Graph:
54
Result:
Convolution of two finite sequences was demonstrated using CCS v4.0 IDE and
the results were verified with theoretical calculations.
55
DATE: EXPERIMENT No.:
57
for(i=0;i<n;i++)
{
a[i]=x2[i];
y[k]+=x[i]*x2[i];
}
}
printf(" Convolved output is\n");
for(i=0;i<n;i++)
printf("%d \t",y[i]);
}
58
Graph:
59
Result:
Convolution of two periodic sequences were demonstrated using CCS v4.0 IDE
and the results were verified with theoretical calculations.
60
DATE: EXPERIMENT No.:
Source code:
#include<stdio.h>
61
#include<math.h>
#define pi 3.14
main()
{
int n,k,N;
float x[100],xreal[100],ximg[100],X[100];
printf("Enter length of sequnece:");
scanf("%d",&N);
printf("\nEnter the sequence\n");
for(n=0;n<N;n++)
{
scanf("%f",&x[n]);
}
for(k=0;k<N;k++)
{
xreal[k]=ximg[k]=0.0;
for(n=0;n<N;n++)
{
xreal[k]=xreal[k]+x[n]*cos((2*pi*k*n)/N);
ximg[k]=ximg[k]+x[n]*sin((2*pi*k*n)/N);
}
ximg[k]=ximg[k]*(-1.0);
}
printf("\n%d-Point DFT of given seq. is\n",N);
printf("\nReal x[k]\tImaginary x[k]");
for(k=0;k<N;k++)
{
printf("\nX[%d]=%f\t+i%f",k,xreal[k],ximg[k]);
}
62
for(n=0;n<N;n++)
{
x[n]=0;
for(k=0;k<N;k++)
{
x[n]=x[n]+xreal[k]*cos((2*pi*k*n)/N)-
ximg[k]*sin((2*pi*k*n)/N);
}
x[n]=x[n]/N;
}
printf("\nThe %d-point IDFT is :",N);
for(n=0;n<N;n++)
{
printf("\nx[%d]=%f",n,x[n]);
}
}
OBSERVATIONS FROM CONSOLE:
Enter length of sequnece:4
Enter the sequence
4 3 2 1
4-Point DFT of given seq. is
Real x[k] Imaginary x[k]
X[0]=10.000000 +i-0.000000
X[1]=2.000003 +i-2.003187
X[2]=2.000005 +i-0.003185
X[3]=2.000023 +i1.990461
The 4-point IDFT is :
x[0]=4.000008
x[1]=2.997615
63
x[2]=1.998416
x[3]=1.003999
Result:
N-Point DFT and IDFT of a finite sequences were demonstrated using CCS
v4.0 IDE and the results were verified with theoretical calculations.
64
DATE: EXPERIMENT No.:
Source code:
#include<stdio.h>
#include<math.h>
int i,j,k,n,m,n1,n2;
65
double x[20],y[20],a,s,e,c,t1,t2;
float q[20]={0,0},p[20]={0,0};
void main()
{
n=8;
m=3;
printf("enter the real values\n");
for(i=0;i<n;i++)
scanf("%f",&x[i]);
printf("enter the imaginary values\n");
for(i=0;i<n;i++)
scanf("%f",&y[i]);
j=0;
n2=n/2;
for(i=1;i<n-1;i++)
{
n1=n2;
while(j>=n1)
{
j=j-n1;
n1=n1/2;
}
j=j+n1;
if (i<j)
{
t1=x[i];
66
x[i]=x[j];
x[i]=t1;
t1=y[i];
y[i]=y[j];
y[j]=t1;
}
}
n1=0;
n2=1;
for(i=0;j<n1;i++)
{
n1=n2;
n2=n2+n2;
e=-6.28316/n2;
a=0;
for(j=0;j<n1;j++)
{
c=cos(a);
s=sin(a);
a=a+e;
for(k=j;k<n;k)
{
t1=c*x[k+n1]-s*y[k+n1];
t2=s*x[k+n1]+c*y[k+n1];
x[k+n1]=x[k]-t1;
y[k+n1]=y[k]-t2;
67
x[k]=x[k]+t1;
y[k]=y[k]+t2;
}
}
}
for(i=0;i<n;i++)
{
printf("\n fft sequence is %f+j%f",x[i],y[i]);
p[i]=sqrt(x[i]*x[i]+y[i]*y[i]);
printf("\n magnitude is %f \n ",p[i]);
q[i]=atan(y[i]/x[i]);
printf("\n phase is %f \n ",q[i]);
}
}
68
RESULT:
N-Point FFT of a finite sequence was demonstrated using CCS v4.0 IDE and
the results were verified with theoretical calculations.
69
70