cancel
Showing results for 
Search instead for 
Did you mean: 

MEMS Microphone to STM32H7 for acoustic analysis device: SPI / I2S, SAI or DFSDM ?

SWood.8
Associate III

I am developing a device which needs to continuously monitor noise (buffer / page to memory) and either Once or 8 Times per second analyse the acquired data to provide the following:

  • FFT
  • CPB (single or 1/3rd octave band analysis)
  • Various over-all and band-pass filtered metrics familiar to the Sound Level Meter user including LAeq, Leq, LFeq, SPL (Slow and Fast)

The math behind these is not my problem yet, I am stuck on which interfacing method may be the most efficient, the least problematic and potentially the one which would be easiest to adapt away from should I wish to option in an Analogue Microphone > OpAmp > ADC > DMA instead of MEMS > SPI/I2S/SAI/DFSDM > DMA

Would be interested in the thoughts of anyone who has been down this path...

4 REPLIES 4
Eleon BORLINI
ST Employee

​hi stewart, it mostly depends on your target application, because an STM32H7 can support both analog and digital microphone. Both microphone families in ST portfolio are well performing: both around 65dB(A), -38dBV or -41dBFS, AOP above 130dBSPL, FR flat.

For an IoT target, consider that an analog microphone (both single ended or differential) takes around 250uA, but should be supplied @ 2.5V for a best performance. A 16-bit ADC is ok for the overall dynamic of the microphone, and the sampling frequency of STM32H7 allows you to acquire up to the ultrasound part of the spectrum. The offset of a single ended analog microphone however has to be taken into account in the amplification/acquisition chain. On the other side, a digital microphone best working point is 1.8V (or 3V), 2.4MHz, has an higher AOP point (e.g. 135dBSPL for MP23DB01HP), it's easier to acquire (it's PDM and only needs clock and data lines), but takes around 700uA consumption and you are mostly limited to 20kHz-25kHz as maximum acquired frequency. However, if you are not interested in the higher part of the audio band, you can work in Low Power @ 768kHz reducing a lot the power consumption.

It's usually easier to acquire a digital than an analog mic, both in terms of signal integrity and computation, if you consider that an analog signal is more difficult to condition, and for STM32 the DSP HAL that directly acquire and compute PDM are available.

SWood.8
Associate III

Thanks Eleon, that makes sense. The application is industrial and runs on 24V DC so no power issues. I am liking the digital microphones for their ease of use and dynamic range. Would be nice to have them packaged in a conventional 1/2" cartridge* so a 94dB acoustic calibrator could be supplied to verify the measurement chain back to the DCS (will be adding a 4-20mA output). I may have to get an engineered housing to accommodate the MEMS microphone. Only need acoustic frequencies so 20Hz to 10kHz is perfectly adequate and the ~30dB Noise Floor is not a problem as the equipment being monitored operates around 95dB(A)0690X000006DOIaQAO.png * example of conventional 1/2 inch condenser microphone pre-amp and 94dB (1Pa @ 1kHz) acoustic calibrator

On the topic of what protocol to use, I am edging towards I2S for no other reason than it seems quite well documented. Now I just need to find some good working examples of the following quasi-code:

T=125 or 1000 Milliseconds

Power-Up > Initialise >

Read Loop 1: Start reading WaveForm into DMA Buffer 'A'> Has T milliseconds expired ? > Yes > Raise Interrupt Event > Start Loop 2

Read Loop 2: Start reading WaveForm into DMA Buffer 'B'> Has T milliseconds expired ? > Yes > Raise Interrupt Event > Start Loop 1

Interrupt Event ? > Yes > Perform analysis of sound bite from Buffer A or B:

  • FFT calculations t
  • Band Pass Filtering
  • A-Weighting
  • RMS and Peak calculations on both Band Passed, A Weighted and Unfiltered Values

As you can see I need the signal to be continuous (no nasty phase mismatch on signal hence constant write to one of two buffers) and I need the analysis to be complete within the 125 millisecond minimum. Hence my choice of a high speed core. This is due to me wanting to demonstrate compliance to Sound Level Meter international standards and the testing involves injecting various crest factor signals and monitoring the accuracy of the peak detector.

The code in bold is my first problem and one I am now actively investigating (or will once my Digilent Analog 2 Logic Analyser arrives !) If you know of any good demo projects that capture this concept I'd be most grateful.

James_Luo
Associate

Hi, I'm interested with your project, especially the algorithm you mentioned: FFT,CPB,SPL, and so on.

Could you share it with me? My email is lpxj@qq.com. Thanks a lot. Do you have a GitHub?

I'm studying STM32H7, too. How to communication ADC or MEMS microphone using I2S with DMA is a big problem. I'm confused, too.

Eleon BORLINI
ST Employee

Hi @SWood.8​ , @罗 �?​ , I can suggest you some firmware packages that interface via DMA the audio stream but for other than H7 HW platforms.

  • X-CUBE-MEMSMIC1 (F7 platform), digital microphone
    • Streaming audio (I2S via DMA) and FFT,
  • AudioLoop Example of the BlueCoin FP application (FP-AUD-SMARTMIC1)
    • Sends audio signals acquired by the microphone to an onboard DAC via I2S interface. In this way the user can play the recorded sound on loudspeakers or headphones. The same Audio signal is also sent via USB (USB Audio Class)
  • Acoustic analysis on FP-IND-PREDMNT1
    • This is based on analog microphone but contains the FFT processing code

Regards