Excel is nice…but…
A better solution comes from the open-source tool Octave. Here is the simple code to generate a sampled sine wave and perform an FFT.
myfile = fopen (“dat.txt”, “w”);
fprintf(myfile,”%f %f\n”,0.0,0.0);
Samples = 1024;
OSR = 16;
length = 0;
z=0; v=0; vlp=0; zlp=0;
delt= 1; # delta time for RC calcultion
c=20; # capacitor for RC filter
r=1; # resistor for RC filter
steps = Samples/OSR;
for i= 1:Samples+length
arg(i) = i – mod(i,steps);
arg(i) = 2*pi*arg(i)/Samples;
v(i) = sin(arg(i));
# smoothing function using digital averaging filter
#vlp(i)=0.0;
#if(i>length)
# for j=i-length:i
# vlp(i)=vlp(i)+v(j);
# endfor
# vlp(i) = vlp(i)/(length+1);
# endif
# end of smoothing filter
#RC filter function (Euler integration)
if(i>1)
ir(i)=(v(i)-vlp(i-1))/r;
vlp(i)=(delt*ir(i))/c + vlp(i-1);
endif
#end of RC filter function
# generate PWL data
if(mod(i,steps)==0) #generates an output file for excel as needed
fprintf(myfile,”%fu %f\n”,i-1,v(i-1));
fprintf(myfile,”%fu %f\n”,i,v(i));
endif
endfor
plot(v);
pause(2)
plot(vlp);
pause(2)
y = fft(v);
z = 2*abs(y)/Samples; #magnitude calculation
plot(z);
axis([0 100]);
pause(2)
ylp = fft(vlp);
zlp = 2*abs(ylp)/Samples; #magnitude calculation
pause(2)
plot(zlp);
axis([0 100]);
fclose(myfile);