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.

800 spectral lines out of 1024 FFT outputs



We are working with a vibration sensor .(MSP432 and a analog out put vibration sensor)

Our requirement is to obtain 800 spectral lines for vibration anlysis.

For this we have done 2K real FFT using ARM CMSIS DSPLib  on MSP432. (8192 sampling rate, 4k is vibration frequency)

How can we pick 800 spectral lines out of 1024 FFT output values. Suggest on this.

  • The number of spectral lines is always half of the selected FFT size, which in your case is 1024 for a FFT size of 2048. The resolution of each spectral line is equal to the sampling rate divided by the FFT size, or 8192/2048 in your case for 4 Hz. I would suggest using all 1024 spectral lines or only half of them (512), but not 800.

    Regards,
    Ryan
  • To expand on Ryan's reply a 2048-point FFT with 8192 Hz sampling frequency will have a bin resolution of 4 Hz or 1000 result bins in the range of 0 Hz to 4 kHz (your vibration frequency). If your application requires you to instead have 800 result bins with steps of 5 Hz the simplest approach would be to increase your sampling frequency while keeping the FFT size the same. Increasing your sampling rate to 10240 Hz and using the same 2048-point FFT will give a result with 5 Hz resolution and exactly 800 result bins in the range of 0 Hz - 4 kHz.

     

    This is the simplest approach to achieve what you are asking for. There are alternative methods to compute the DFT when the number of points are not a power of two but they are more computationally expensive. One method specifically is Bluestein's algorithm which computes an arbitrary length DFT using zero padding and forward and inverse FFT functions. There is not a native MSP432 function to perform this, you will need to dig into the signal processing theory and implement the code yourself using available functions.

    Regards,
    Brent

     

  • Thanks Brent, we tried your suggestion. It resoves our 800 spectral lines issue.

    we are exploring furthur on FFT , when we have taken only 1600 samples and zero padded to make 2048 (As FFT requires ensemble of power of two).

    we have observed difference in FFT amplitude when we have done with 2048 real samples and 1600+zero padding samples .

    Request to suggest on this.

  • The amplitude of the FFT result is directly correlated to the length of "real" samples (non-zero). In fact the definition of the FFT can be interpreted as the cross-correlation of an input signal with complex sinusoids at each frequency bin. When we have 1600 real samples and pad the remaining samples with zero we are really only multiply-and-accumulating 1600 samples, the zero padded samples add nothing to the result. Doing the same with 2048 real samples will accumulate more samples and have a larger amplitude as a result. If the input signal is perfectly correlated and periodic within the window the amplitude of 1600 samples should be exactly 0.78125 that of the amplitude of 2048 samples (1600 / 2048 = 0.78125).

    In reality the ratio of amplitudes probably won't be exact but should be fairly close and can be used as an approximation. Without even taking into account the accuracy of ADC samples the amplitude will vary depending on how periodic the signal is and windowing used. A signal that may be periodic within 2048 samples probably won't be periodic within 1600 samples and the end "edge" will cause spectral leakage into adjacent frequency bins. A good best practice is to use a simple window function (such as hanning window) that forces the signal to be periodic within the FFT window.

    This isn't so much an MSP question but more of a signal processing theory question that can be answered by understanding the concepts and math behind the FFT. The same problems will be present no matter what platform and precision you are using, whether it's fixed-point on MSP or double precision floating-point in MATLAB. Understanding how the FFT works and why will help you to get the most out of your application and algorithms.

    Regards,

    Brent

  • Hi Brent,

    Thanks for your response. please go through the below details we need help.

    Brief Details of our work:

    • To the MSP ADC14 we fed a (0-0.625volt) peak to peak sine signal. The sine signal is addition of 520 Hz and 530 Hz sine waves.
    • Both the sine signals have a 0-0.625volt peak to peak.
    • The ADC of msp 432 has an external reference of 1.8 volts.
    • Sampling rate of ADC is 10240 samples per second.
    • we are taking 1600 samples which will take 1600*(1/10240) = 0.15625 seconds.
    • cycle time of 520Hz signal is 0.00192 seconds, it is periodic in the 1600 samples window.
    • number of samples taken are 1600.

    Below are the operations we performed:

    1. scale the ADC count with scaling factor 1.8/2^14 (msp432 has 14 bit ADC).
    2. Convert the scaled ADC value to Q15 format.
    3. pad 448 zeros to the converted 1600 samples of Q15 data.
    4. perform a 2048 point  Q15 Real FFT on this data.
    5. calculate magnitude for 1024 samples in FFT output.

    Our observations are the peaks at frequency bins corresponding to  520 Hz bin and 530 Hz in FFT output. magnitude is 974 for both the bins.(1600 sample with padded zeros)

    If we take complete 2048 samples from ADC and perform FFT, the value of the peaks at 520 hz and 530 Hz is 1280.

    1280 * (1600/2048) = 1000 which is close to the peak for 1600 samples i.e. 974.

    But when we perform the same process on a sine signal(0-0.625 volt) which is an adition of 520Hz and 525Hz for 1600 samples.

    we get peak value of 809 at 520 hz bin and 525 hz bin. shouldn't it be 974.

    Please help us to solve this. 

    Our application is vibration analysis.

    Thanks in advance.

**Attention** This is a public forum