0

FFT/spectrum with Feather M0 & Sph0645
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

FFT/spectrum with Feather M0 & Sph0645

by carlocosta2009 on Tue May 11, 2021 3:47 am

Dear Staff,
I would like to ask for your kind help, as I'm trying to monitor the spectrum frequency from an I2S mems mic with the arduino IDE serial plotter.

In first place, I have few years of experience with arduino and microcontrollers (mainly 32u4 and esp32) and I feel somewhat comfortable in editing existing libraries. However, my knowledge of programming C++ is relatively basic and makers's level, not professional, and faraway from understanding all the code.

I have:
SPH0645LM4H (code 3421)
FEATHER M0 with Wifi (code 3010)
Alternately I also have a Feather ESP32.


Option A)
I followed this tutorial but I'm smashing against the Multiple definition of DMAC_Handler. As far as I read in this forum, no way to overcome it.
https://learn.adafruit.com/adafruit-i2s ... g-and-test
-Kindly, what type of boards are compatible with my I2S mic and the spectrum analyzer of the arduino sound library?


Option B)
I installed the Audio Adafruit library fork, but the FFT sketch does not compile for Feather M0, giving the following output:

C:\Users\......\Documents\Arduino\libraries\Audio_-_Adafruit_Fork/effect_delay.h:44:35: error: division by zero in #if
44 | #define DELAY_QUEUE_SIZE (6144 / AUDIO_BLOCK_SAMPLES)
C:\Users\......\Documents\Arduino\libraries\Audio_-_Adafruit_Fork/effect_delay.h:106:5: note: in expansion of macro 'DELAY_QUEUE_SIZE'
106 | #if DELAY_QUEUE_SIZE * AUDIO_BLOCK_SAMPLES < 65535

I tried to change the instructions in the file effect_Delay.h, but other errors come up.
-Kindly, any idea of how to solve it via software?
-Is this compatible with i2s mic and Feather M0?


Option C)
The third option is the FFT Test sketch of the library Adafruit Zero FFT library, which compiles, but has no interaction with the microphone.


I look forward to your kind reply with suggestions on where to focus my effort and eventually whether you recommend further hardware (mic, board..)

Thank you in advance.
Carlo
Attachments
Inked20210510_205224_LI.jpg
hardware available
Inked20210510_205224_LI.jpg (845.32 KiB) Viewed 333 times

carlocosta2009
 
Posts: 8
Joined: Tue Sep 13, 2016 10:01 am

Re: FFT/spectrum with Feather M0 & Sph0645

by adafruit_support_mike on Tue May 11, 2021 10:38 pm

Option A is the one you want.

Post the exact error messages you get when you try to compile that code (between CODE tags please).

adafruit_support_mike
 
Posts: 62788
Joined: Thu Feb 11, 2010 2:51 pm

Re: FFT/spectrum with Feather M0 & Sph0645

by carlocosta2009 on Wed May 12, 2021 12:22 pm

Mike,

Thank you for your quick reply.

The sketch is the default "SpectrumSerialPlotter" of the Arduino Sound Library, latest version 0.2.1
Arduino IDE version: 1.8.13
Adafruit_ZeroDMA version: 1.08

The compiling error is the following:

Code: Select all | TOGGLE FULL SIZE
 c:/users/carlo/appdata/local/arduino15/packages/adafruit/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: libraries\Adafruit_Zero_DMA_Library\Adafruit_ZeroDMA.cpp.o: in function `DMAC_Handler':
C:\Users\carlo\OneDrive\Documents\Arduino\libraries\Adafruit_Zero_DMA_Library/Adafruit_ZeroDMA.cpp:119: multiple definition of `DMAC_Handler'; libraries\I2S\utility\DMA.cpp.o:C:\Users\carlo\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.6.7\libraries\I2S\src\utility/DMA.cpp:418: first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Errore durante la compilazione per la scheda Adafruit Feather M0.



Grateful in advance for your kind support.
Regards

Carlo

carlocosta2009
 
Posts: 8
Joined: Tue Sep 13, 2016 10:01 am

Re: FFT/spectrum with Feather M0 & Sph0645

by adafruit_support_mike on Wed May 12, 2021 5:34 pm

Try removing the Zero_DMA library, or putting a ‘-‘ at the beginning of the folder name to keep the Arduino IDE from loading that library when it starts up. That should eliminate the conflict.

adafruit_support_mike
 
Posts: 62788
Joined: Thu Feb 11, 2010 2:51 pm

Re: FFT/spectrum with Feather M0 & Sph0645

by carlocosta2009 on Thu May 13, 2021 6:38 am

Hi Mike,

I made a fresh new installation of all, and removed the library Adafruit-zeroDma.
Now the compiling error is the below:


Code: Select all | TOGGLE FULL SIZE
In file included from C:\Program Files (x86)\Arduino\libraries\SD\src\utility\Sd2Card.cpp:31:
C:\Users\user\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.6.8\libraries\SPI/SPI.h:24:10: fatal error: Adafruit_ZeroDMA.h: No such file or directory
   24 | #include <Adafruit_ZeroDMA.h>
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Adafruit Feather M0.



I tried to comment out the referring code-instruction in both the Sd2Card.cpp and/or SPI.h, but this triggers further (many more) compiling errors for nested instructions.
I'm not planning to use neither SD nor SPI on this simple application.

I look forward to further kind suggestions.
Regards
Carlo

carlocosta2009
 
Posts: 8
Joined: Tue Sep 13, 2016 10:01 am

Re: FFT/spectrum with Feather M0 & Sph0645

by adafruit_support_mike on Thu May 13, 2021 10:08 pm

Hmm.. do you have a library named 'I2S' in your 'libraries' folder?

adafruit_support_mike
 
Posts: 62788
Joined: Thu Feb 11, 2010 2:51 pm

Re: FFT/spectrum with Feather M0 & Sph0645

by carlocosta2009 on Fri May 14, 2021 2:30 am

Dear Mike,
Thank you for your kind reply.

I confirm there is the library I2S version 1.0 in the following folder:
AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.6.8\libraries\


Carlo

carlocosta2009
 
Posts: 8
Joined: Tue Sep 13, 2016 10:01 am

Re: FFT/spectrum with Feather M0 & Sph0645

by adafruit_support_mike on Fri May 14, 2021 8:51 pm

Try removing that one and replacing the Zero_DMA library.

The error is telling you that the compiler sees a conflict between the two libraries. You should only need one.

adafruit_support_mike
 
Posts: 62788
Joined: Thu Feb 11, 2010 2:51 pm

Re: FFT/spectrum with Feather M0 & Sph0645

by carlocosta2009 on Mon May 17, 2021 2:17 am

Mike,

Removing the library I2S, the terminal gives:

Code: Select all | TOGGLE FULL SIZE
C:\Users\user\Documents\Arduino\libraries\ArduinoSound\src\AudioInI2S.cpp:19:10: fatal error: I2S.h: No such file or directory
   19 | #include <I2S.h>
      |          ^~~~~~~
compilation terminated.
exit status 1
Error compiling for board Adafruit Feather M0.



I also tried to remove the DMAC definition at the end of the file
AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.6.8\libraries\I2S\src\I2S.cpp
Code: Select all | TOGGLE FULL SIZE
#else
  void DMAC_Handler() {
    DMA.onService();
  }

which gives no compiling error.
I'm going to load the code into the board shortly and then post the feedback.

carlocosta2009
 
Posts: 8
Joined: Tue Sep 13, 2016 10:01 am

Re: FFT/spectrum with Feather M0 & Sph0645

by carlocosta2009 on Tue May 18, 2021 6:40 am

Mike,

I confirm that the sketch compiles and uploads, but the Serial Monitor/Plotter won't output anything at the selected frequency.
It did not work commenting out this from the file AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.6.8\libraries\I2S\src\utility\DMA.cpp.
Code: Select all | TOGGLE FULL SIZE
#else
  void DMAC_Handler() {
    DMA.onService();
  }

Nothing from the serial monitor or plotter.

And neither adding the following to the Adafruit_ZeroDMA.cpp into the DMAC_Handler definition
Code: Select all | TOGGLE FULL SIZE
DMA.onService();

Code: Select all | TOGGLE FULL SIZE
DMAClass DMA;


Thank you in advance for any other comment or advice you could give.
Regards

carlocosta2009
 
Posts: 8
Joined: Tue Sep 13, 2016 10:01 am

Please be positive and constructive with your questions and comments.