This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

frequency component fron fft output

dear sir,

i have a mixed signal on the input side...by using adc i have sampled it and taken theses samples to calculates its FFT. after applying FFT again i m getting samples output in the form of real+imaginary part. i can calculate the phase and magnitude. my question is how to calculate the frequencies with the help of coding?

  • Hi Kanchan,

    The FFT transforms a time-domain signal into the frequency domain (and visa versa). The FFT operates with a power-of-2 number of bins each representing a range of frequencies. The width of each bin depends on the sampling rate that was used to capture the time-domain signal and the number of FFT bins: each bin width = Sampling rate / number of bins. Take for example a 16-pt FFT of a signal that was sampled with a sampling rate of 1MHz. Each bin of the 16-point FFT is 62.5 kHz wide (1MHz / 16), starting at 0Hz (DC) going all the way to the sampling rate 1Mhz.

    If the signal going into the FFT is real only, then you will observe symmetry about the mid-point of the FFT (the Nyquist frequency) - you can ignore the FFT results above the midpoint or you can exploit this symmetry.

    The FFT output is split between real and imaginary parts. You can recombine these two to get the magnitude response by taking the square root of the sum of the squares of each part.

    Some additional background is provided in the HWAFFT appnote: http://www.ti.com/lit/an/sprabb6b/sprabb6b.pdf and also on various websites if you search for it.

    Hope this helps,
    Mark

  • hello sir,
    so i need to take an array of fft samples ouptut..from that i need to find max magnitude index..and at the index where the magnitude is maximux that multiplied by the bin frequnecy..and that will be the final frequency of the input singal..am i right...thats what i grasp from your reply..plz let me know if my perception is right..
  • plz reply

  • Hi Kanchan,

    You got it.

    To detect which frequencies have the greatest magnitue, you would...
    * make sure you sample the signals with a sampling rate greater than 2x the maximum frequency of interest
    * capture several samples into an array over a short period of time (say 1024 samples)
    * perform the FFT with that block of samples
    * calculate the magnitudes from the real and imaginary outputs of the FFT (at each index calculate the square root of the sum of the squares of the real and imaginary array elements)
    * search the magnitude array for the index with the largest magnitude (if the inputs to the FFT are all real numbers, you can search just the first half of the array - the second half will duplicate the first half)
    * multiply that index with the width of each frequency bin (width in Hz = ADC sampling rate / number of bins or the size of the FFT)
    * And you are left with the frequency (actually a range of frequencies) that has the most energy (magnitude).
    The resolution of this range of frequencies equals the width of each frequency bin. In the example above where sampling rate is 1MHz and FFT length is 16-points, the resolution is 62.5 kHz (1MHz / 16). You cannot narrow down the frequency any more unless you increase the size of the FFT (or reduce the sampling rate, or play tricks like the zoom FFT).

    Further, if the predominant frequency is right on the edge of two frequency bins, then its energy will be split across the two neighboring bins.

    You may also be interested in the Goertzel algorithm, which is a completely different approach to finding if a particular frequency is dominant in a signal. It is the approach used to detect the buttons presed on a Touch-Tone phone (DTMF).

    Hope this helps,
    Mark