1
votes

I am using the CMSIS DSP FFT functions to convert a known signal from time to frequency domain. The signal in question is a 1 KHz sine wave of peak-peak amplitude of 1V with a DC offset of 1.25V. I am sampling the input signal at 10 KHz with a 16-bit ADC and then doing the processing on a Cortex M4F MCU in floating point.

When I run a 1024 point FFT the DC value comes up at Bin-0 as ~1.24. When I run the same signal for a 2048 point FFT the DC values is ~2.5. So I ran a 512 point FFT and the value became half or ~0.62. To double check my signal, I did the same in Matlab and for no matter what FFT point I use, Matlab shows Bin-0 or DC as ~1.25.

It seems that the CMSIS DSP library from ARM is somehow doing a scaling function, which I checked in the code execution and is nowhere to be seen/executed. Any idea for debug is welcome.

1
The opposite. That FFT library does not scale, but instead obeys Parseval’s theorem, where a longer sine wave contains more power, thus should have a proportionally larger FFT result. Some other FFT implementations do scale by length to better represent waveform height. Other libraries split the difference and scale by the square root of the length, so the FFT and IFFT have the same scaling.hotpaw2
The relationship between your results look correct. The bin 0 result of your output will be a sum of all of the elements in your vector. Technically (for a DFT) you would have a dot procuct of your input vector with (1.0 + 0i). When you halved your number of points, your results got halved.J. R. Schweitzer

1 Answers

1
votes

Looks like your output is not being scaled. This is most likely done for performance reasons, since not all uses of Fourier transform require scaled output, and CMSIS code is expected to be executed on limited-power embedded devices.

Comments preceding the Fast Real FFT implementation (arm_rfft_fast_f32() function) in the CMSIS library confirm this:

The forward and inverse real FFT functions apply the standard FFT scaling; no scaling on the forward transform and 1/fftLen scaling on the inverse transform.

To solve, apply the scaling coefficient manually.