2

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.

  1. 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 ?

  2. 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?

    1. Also one more thing before feeding the 32 samples of the 50 Hz Signal to the FFT algorithm do I have to do some digital filtering on these samples .. why I am asking this question because suppose while taking 20 th & 16th sample if some noise spike comes then in that case it will not be the true value. If yes then which digital filtering method will be best ?

Please correct me.

enter image description here

Katoch
  • 2,709
  • 9
  • 51
  • 84

2 Answers2

1

X[0] = fundamental frequency
X[1] = 1st harmonic ...
X[31] = 31st harmonic

Is 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 frequency
  • X[2] is the first harmonic
  • X[16] is the 15th harmonic
  • X[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 of X[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.

SleuthEye
  • 14,379
  • 2
  • 32
  • 61
  • Thanks for your reply "Since your signal's frequency is an exact multiple of the FFT frequency bin width" what exactly you mean here ? I have done simple calculation fs= 2*50*16 .. so what is FFT frequency here ? are there cases where FFT frequency is not exact multiple ? Can you give example ? – Katoch May 25 '17 at 13:29
  • You said "this will introduce phase offsets in the FFT results " what adverse effects it will have. Also how to correct this in final FFT output ? Should I detect zero cross in my Microcontroller & then take 32 samples & then perform FFT , to avoid this ? Please suggest. – Katoch May 25 '17 at 13:33
  • 2
    1) For the frequency, FFT frequency bin width is `fs/N` for N-point FFT so in your example it is `2*50*16 / 32` or 50Hz. If you were trying to analyse a 49Hz signal sampled at the same 1600Hz sample sampling rate, with 32-point FFT then it wouldn't be an exact multiple. – SleuthEye May 25 '17 at 15:57
  • 1
    2) For the phase offset, it isn't an adverse effect but just something to keep in mind that the FFT output's real & imaginary components would not be identical if you were to numerically compare the FFT's output for different initial time. It isn't something you necessarily need to compensate for. The phase offset just tells you the periodic wave is time shifted with respect to a reference cosine function. – SleuthEye May 25 '17 at 15:57
  • "If you were trying to analyse a 49Hz signal sampled at the same 1600Hz sample sampling rate, with 32-point FFT then it wouldn't be an exact multiple." For 49 Hz I will take how many point FFT so that I get the 1,2,3,4 harmonics peak amplitude .. any expect comment from your side.. it will be helpful for me. – Katoch May 25 '17 at 16:05
  • Can you suggest on point 3 .. I have edited the original post. – Katoch May 25 '17 at 17:53
  • You said .."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 harmonic X[17] to X[31] are the complex conjugates of X[15] to X[1]respectively" can you suggest what is literature behind this .. what term to search on net to Learn in details which index contains complex conjugate of harmonic frequency. – Katoch May 28 '17 at 17:54
1

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.

hotpaw2
  • 70,107
  • 14
  • 90
  • 153
  • "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." .. what I know us X[1] & X[31] are complex conjugate of fundamental frequency 50 hz..so here you want to say X[1] & X[31] represent fundamental frequency 50 Hz & also 49 Hz Signal. got confused with your wording..? – Katoch May 25 '17 at 16:51
  • 1
    Yes, all FFT result bins are complex Sinc shaped bandpass filters, with non-zero bandwidths. – hotpaw2 May 25 '17 at 17:02
  • How to extract 49 Hz Signal information from X[1] & X[31].. also what is the advantage to extract 49 Hz information from X[1] & X[31] (which represent 50 Hz Signal complex conjugate) .. so in this case X[1] & X[31] also contains information about 48, 47, 46 45... Hz Signal ?? – Katoch May 25 '17 at 17:17
  • 1
    You can Sinc interpolate between FFT result bins to see if spectral peaks are to be found there. – hotpaw2 May 25 '17 at 17:24
  • Two things where in practical application this concept is used ?.. can you guide me to right term to google so that I can Lear more about this Concept ? – Katoch May 25 '17 at 17:46
  • ""Completely removing 1 sample spikes requires a non-linear approach outside linear filtering or the use of an FFT.".. which nonlinear method to use for this ? – Katoch May 26 '17 at 01:17