Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP-DSP: DC-Offset and Nyquist frequency in output? (DSP-146) #93

Open
4 tasks done
ruig25 opened this issue Sep 5, 2024 · 5 comments
Open
4 tasks done

ESP-DSP: DC-Offset and Nyquist frequency in output? (DSP-146) #93

ruig25 opened this issue Sep 5, 2024 · 5 comments

Comments

@ruig25
Copy link

ruig25 commented Sep 5, 2024

Answers checklist.

  • I have read the ESP-DSP documentation and the issue is not addressed there.
  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my ESP-DSP branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

Hi!

I suspect, that fft output contains dc offset at index=0 and Nyquist frequency at index=1 (like in ARM CMSIS DSP library for cortex).

I have accelerometer signal. I feed input signal (hann window applied to real values) interleaved by zeros to dsps_fft2r_fc32.

  1. Bit reverse op applied to output (dsps_bit_rev_fc32).
  2. dsps_cplx2reC_fc32 is also applied.

After calc of magnitude on output sqrtf(real^2 + imag^2) the first bin (index = 1) is always bigger than others.
If I set bin 0 and 1 to zero - I get the results that seems to be near to reality (bin index multiplied by freq resolution... ~ expected fundamental freq of my test vibration).

I am i right about index 0 and 1?

Thanks

@github-actions github-actions bot changed the title ESP-DSP: DC-Offset and Nyquist frequency in output? ESP-DSP: DC-Offset and Nyquist frequency in output? (DSP-146) Sep 5, 2024
@ruig25
Copy link
Author

ruig25 commented Sep 12, 2024

image

@dmitry1945
Copy link
Collaborator

Hi @ruig25
Could you please share here the input data that you are converting? Just 512 samples?
Thank you.

@ruig25
Copy link
Author

ruig25 commented Sep 16, 2024

Hello!

Sure.

1st example
Accelerometer ST lsm6dsl (+/-2g, Fs=1,66kHz, no filters).
FFT_SIZE=512.
Hann Windows size = FFT_SIZE
image

Raw accelerometer 512 samples used to calc magnitude
xl_3d_raw.json

@ruig25
Copy link
Author

ruig25 commented Sep 16, 2024

2nd example

Source: 3D magnet field sensor.
Fs=800Hz
No filters.

The same routine as above but RAW values converted to milli Tesla before calculating magnitude.

In both cases first two FFT bins (0 and 1) contain high values.

b_3d_mt.json

I will try to prepare Octave snippet to verify fft... may my fault somewhere

@dmitry1945
Copy link
Collaborator

Hi @ruig25

You have a positive bin[0] and this bin is bigger then others for tree reasons.

  1. All samples that you have are positive. It means, that they have DC value inside.
  2. Even if you will have negative values, you are using sqrt(AA + BB + C*C) function. It also provide you only positive values, and it means, it has DC value inside.
  3. Bin[1] has high value because you are using window function. Even if you don't have it, the bin[1] will be max -13 dB smaller then bin[0].

Regards,
Dmitry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants