Reputation: 2777
I have to take the FFT of a sin wave of 50 Hz and measure up to the 16 harmonics.
My sampling frequency is as per Nyquist criteria: fs = 16*50*2 = 1600 Hz = 1600 samples/sec
i.e in one period of 50Hz corresponds to 20 msec or 32 samples.
As shown in FIG-1, I will take 32 samples per cycle.
Then as per FIG-2 I will do the 32 point FFT of the ADC sample voltage series x[n]
where n
= 0 to 31
Then FFT algorithm returns the value X[k]
where k
= 0 to 31.
If x[n]
is the sample of voltage.
So my question is in the
output of the FFT algorithm X[k]
, where k = 0 to 31 :
X[0]
= fundamental frequency
X[1]
= 1st harmonic
.
.
.
X[31]
= 31st harmonic
Is it right ?
Also if value of X[1]
= 1 + j, then magnitude of X[1]
= sqrt(2) =
1.4142. So is this value 1.4142 the peak value of the first harmonic ? Now if I have to find RMS value of first harmonic then
will it be Vrms = Vm/sqrt(2) = 1 ?
Also should the 32 samples of the input signal start from zero crossing of the sin wave, or can I start at any time place of the sin wave as shown in figure-3?
Please correct me.
Upvotes: 2
Views: 1840
Reputation: 70733
Both X[1] and X[31] will contain the energy of the any spectrum than correlates to a sinusoid at a frequency of Fs/N, including, not only the fundamental, but any spectrum (up to Fs/2) with frequencies that are not an exact integer multiple of Fs/N. e.g. in your case, including a 49 Hz sine wave.
X[1] and X[31], being complex conjugates, will split the energy between them, and the peak value of your fundamental might be scaled from the magnitude of FFT result X[1] by 0.5 * N, the length of the FFT. The scale factor could also be N or 0.5 or 0.5 * sqrt(N), depending on the implementation of your particular FFT.
Added: Re Point 3: A noise spike can contain wide-band energy, thus the "true" FFT value will include some of their effect. Completely removing 1 sample spikes requires a non-linear approach outside linear filtering or the use of an FFT.
Upvotes: 1
Reputation: 14577
X[0]
= fundamental frequency
X[1]
= 1st harmonic ...
X[31]
= 31st harmonicIs it right ?
Almost but not quite. You should not forget about the constant term (which shifts all your assumed correspondences up), and that any terms above the Nyquist frequency are mirrored from lower frequency components. The correspondence is as follows:
X[0]
is the constant term (also refereed to as DC bias)X[1]
is the fundamental frequencyX[2]
is the first harmonicX[16]
is the 15th harmonicX[17]
to X[31]
are the complex conjugates of X[15]
to X[1]
respectively.Also if value of
X[1] = 1 + j
, then magnitude ofX[1]
is sqrt(2) = 1.4142. So is this value 1.4142 the peak value of the first harmonic ?
Since your signal's frequency is an exact multiple of the FFT frequency bin width, the magnitude of X[1]
does correspond to the peak of the corresponding frequency component. As pointed out earlier X[1]
would correspond to the fundamental frequency, rather than the first harmonic. So the 1.4142 value in your example would be the peak value of the fundamental frequency.
Now if I have to find RMS value of first harmonic then will it be Vrms = Vm/sqrt(2) = 1 ?
That would indeed be the relationship between the RMS of a single harmonic and its peak value. However be careful not to apply this to convert between the RMS and the peak value of a signal with more than a single harmonic since the relationship is not linear.
Also should the 32 samples of the input signal start from zero crossing of the sin wave, or can I start at any time place of the sin wave as shown in figure-3?
You can start at any time offset in the periodic wave, but this will introduce phase offsets in the FFT results. If you are only interested in the magnitude of the frequency components, then it wouldn't matter.
Upvotes: 1