Skip to main content
akshay bansod
Associate II
June 20, 2018
Solved

FFT with STM32F4 not giving correct frequency output

  • June 20, 2018
  • 1 reply
  • 2404 views
Posted on June 20, 2018 at 11:57

The original post was too long to process during our migration. Please click on the attachment to read the original post.
    This topic has been closed for replies.
    Best answer by Tilen MAJERLE

    Posted on June 20, 2018 at 12:52

    Hello,

    FFT works on sinus signal. For 25Hz square, you have (theoretically) unlimited number of frequencies with different amplitudes.

    In general, FFT input must be 2^n samples and you will also receive back 2^n samples. These samples are mirrored by center frequency between 0 and sampling frequency, which means that your 'useful' data are only between 0 and Fs / 2. Result of FFT is not frequency number. You have to interpret your result properly to decide where to find your frequency.

    Example:

    Sampling frequency Fs = 45kHz

    Number of samples for FFT calculation FFT_SIZE = 1024

    Calculations:

    Frequency resolution on output = Fs / FFT_SIZE = 45000 / 1024 = ~44Hz. You can detect frequency of [0, 44, 88, etc..., 45000-44] Hz

    Useful data = FFT_SIZE / 2, which means frequency bands from [0, 44, 88, ..., 45000/2 - 44] Hz

    If you are interested in result at 88Hz, you have to check output[2] array value. output[0] is equal to DC value in signal.

    Very fast and very basic. You have to take care now that your ADC sampling is really 45kHz and then interpret FFT result properly.

    Best regards,

    Tilen

    1 reply

    Tilen MAJERLE
    Tilen MAJERLEBest answer
    ST Employee
    June 20, 2018

    Posted on June 20, 2018 at 12:52

    Hello,

    FFT works on sinus signal. For 25Hz square, you have (theoretically) unlimited number of frequencies with different amplitudes.

    In general, FFT input must be 2^n samples and you will also receive back 2^n samples. These samples are mirrored by center frequency between 0 and sampling frequency, which means that your 'useful' data are only between 0 and Fs / 2. Result of FFT is not frequency number. You have to interpret your result properly to decide where to find your frequency.

    Example:

    Sampling frequency Fs = 45kHz

    Number of samples for FFT calculation FFT_SIZE = 1024

    Calculations:

    Frequency resolution on output = Fs / FFT_SIZE = 45000 / 1024 = ~44Hz. You can detect frequency of [0, 44, 88, etc..., 45000-44] Hz

    Useful data = FFT_SIZE / 2, which means frequency bands from [0, 44, 88, ..., 45000/2 - 44] Hz

    If you are interested in result at 88Hz, you have to check output[2] array value. output[0] is equal to DC value in signal.

    Very fast and very basic. You have to take care now that your ADC sampling is really 45kHz and then interpret FFT result properly.

    Best regards,

    Tilen

    akshay bansod
    Associate II
    June 20, 2018
    Posted on June 20, 2018 at 14:23

    Hello

    Majerle.Tilen

    ‌,

    Thank you for the instant help.

    Understood & got the output correctly.

    Tilen MAJERLE
    ST Employee
    June 22, 2018
    Posted on June 22, 2018 at 00:43

    Hello,

    you may want to read post on link below:

    https://community.st.com/0D50X00009bMMAwSAO

     

    Best regards,

    Tilen