• I am using a 3-axis LIS2D12H accelerometer interfaced with NRF51832 through the SPI interface.

    1. The sensor has a sampling-rate from 1 Hz to 5.376 KHz which is happening at sensor only.

    2. I am taking sensor data at 400 Hz by setting register values in the sensor.

    3. I am implementing an FFT algorithm in microcontroller over a raw sensor data received by the 3 axes, for vibration analysis.

  • I can have resolution of FFT from 64 to 2048.

Q: My confusion is how should I sample it at microcontroller for FFT? There are FFT functions in ARM cortex which I am using.

  1. Shall I take raw samples in buffer and sample them or shall I take each reading from sensor and sample them individually?

  2. If that is the case how shall I select sampling frequency at microcontroller level and/or at what rate microcontroller shall read data?


1 Answer 1


I understand the sampling process is completely handled by the sensor itself, i.e. it delivers digital data. Then you just collect the desired number of samples from the sensor and calculate its FFT. The frequency range depends only on the sampling rate ($f_{\text{max}}=f_s/2)$, the frequency resolution depends only on the number of samples $N$, in your case $N\in[64,2048]$.

There is no sampling done on the uC, as it already receives sampled data. However, what you will want to do is employ a lowpass filter before calculating the FFT, with a cutoff frequency slightly lower than $f_{\text{max}}$, to get rid of high frequency content, that would otherwise cause aliasing in your spectrum.

  • 2
    $\begingroup$ Any aliasing would have already occurred, so low pass filtering won’t help. Otherwise spot on. $\endgroup$
    – Dan Szabo
    Jul 16, 2019 at 12:30
  • $\begingroup$ You are right of course, the sensor's ADC will should have some kind of filter onboard. $\endgroup$
    – Max
    Jul 16, 2019 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.