Electronics > Projects, Designs, and Technical Stuff
why The FFT can not compute this second harmonic correctly?
<< < (4/6) > >>
ali_asadzadeh:

--- Quote ---The problem is that even though the cut samples of 32 length still contains the shorter wavelength, it is still a composite signal.  As others mentioned, the cut causes the boundaries of the finite sequence to be non-zero.  This causes lots of undesired output in the fft.  Windowing can be used to force the boundaries to zero.  I changed the start point of the cut to be 1/8 of the way into the 32-sample sequence and applied triangular windows.  Somewhat of trick question, so here is somewhat of a trick answer:   If nothing else, it shows how to do windowing and zero padding.
--- End quote ---
Thanks, Is there away to do it in an arbitrary starting point like the 16:47 points?
ali_asadzadeh:
Also there is some problems with your solution, Because I'm doing the FFT finally in a Cortex M device, with limited resources and limited time, I have reduced the original signal to 32 samples,so the FFT would be faster and needs less ram resources! Doing it in a 4096 sample windows size would be an over kill, because I have under 1ms to do this stuff on several simultaneous channels of data, so any New Ideas?
nick_d:
Yes, there are many ways to separate frequencies without FFT. An IIR filter would be an efficient choice. So would a wavelet transform if you need to process a spectrum (but this is usually unnecessary). May we have details of the application?
cheers, Nick
rstofer:
Here's some MATLAB code I grabbed from the MathWorks site and changed enough to add a couple of harmonics.


--- Code: ---Fs=1000;
T=1/Fs;
NFFT=256;
FFTperiod=256*T;
t=(0:NFFT-1)*T;
str=['FFT period is ',num2str(FFTperiod), ' seconds'];
Freq=10*1/FFTperiod
strFreq =['Frequency is ', num2str(Freq), ' Hz'];
Freqbin =1/FFTperiod
strFreqbin =['FFT frequency bin is ',num2str(1/FFTperiod), ' Hz'];
strFreqNyquist =['FNyquist is ',num2str(1/FFTperiod*256/2), ' Hz'];
disp(str);
disp(strFreq);
disp(strFreqbin);
disp(strFreqNyquist);
x=sin(2*pi*Freq*t)+(sin(6*pi*Freq*t)/3)+(sin(10*pi*Freq*t)/5);
subplot(2,1,1)
plot(t,x);
title('time domain signal')
Y=fft(x,NFFT)/NFFT;
f=Fs/2*linspace(0,1,NFFT/2);
subplot(2,1,2);
plot(f,20*log10(2*abs(Y(1:NFFT/2))))
title('FFT magnitude in dB20')

--- End code ---
ali_asadzadeh:
Thanks rstofer, Because the application should be so fast, I could only do the FFT in 1 full sin cycle, and for the second harmonic also I wanted to be able to calculate it in half the cycle of the full first harmonic cycle.
Navigation
Message Index
Next page
Previous page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod