cancel
Showing results for 
Search instead for 
Did you mean: 

two independent MEMS pdm acquisition

Posted on March 29, 2017 at 12:47

Hello STM!

I am facing a new goal: I want to build my own diferencial beamforming 2 MEMS PDM microphone array to achieve kardioid directivity pattern.

So i need to get data out of two MEMS mics simultaneously ... i mean literally get samples at the same time (because the beamforming depend havily on time that sound travel through space, so i will try not to add any delay between the two mics samples). 

So i am thinking what approach for data aquisition here is the best.

I got two variants at the top of my head. I will mention i am going to use probably some of STM32F4 168 MHz or higher (reason is that i developed so far a lot of my app using single microphone at this mcu and it had suitable performance for all the signal processing needed) 

   1. Variant:

Aquire both PDM via one I2S data line using the 'trick' with double PDM clk frequency from I2S routed to a timer (to divide the clk by 2) so i can aquire both of mems mics with only slight delay of tdelay =  1/2  *  1/Fs [s]. Thats fine, it result in sound travel distance difference of 66 um.

Another thing to consider is that i need to demux the signal via firmware routine that takes cpu time ... and i need to figure out how properly setup the PDM filter (i guess 2 input channels, 2 output channels?). 

Questions

Here i am not sure: If i demux bit interleaved pdm to Byte interleaved, this Byte format is suitable for PDM library right? 

My thoughts:

I dont like that this varian employ an additional timer. Even more i dislike that i will need to make an outside cpu rout with pdm clk that will be something like 2,5 MHz! 

   2. Variant:

Use a separate I2S peripherrals for each MEMS microphone.

Questions

Is it possible to synchronize both peribherrals so they start at exact same time? 

Does this option means more cpu load then the variant 1? here will be no need for demuxing the signals, but will be necesarry to call PDM toPCM function separately ... 

My thoughts:

I would like that variant because its easier to implement, and doesnt require to employ another Timer and rout high frequency (twice higher) outside mcu chip to timer input ... 

What do you think dear community? 

Thanks for your kind answers

reagards  Jan 

#pdm-stereo-mems-mic-libpdmfilter #mems-microphones #i2s #beamforming
11 REPLIES 11
raptorhal2
Lead
Posted on March 29, 2017 at 17:05

I vote for number 2.

Set up two peripheral interfaces, but wire the clock, select and enable signals from one interface to both MEMs. Receive data on both interfaces.

Cheers, Hal

Posted on March 30, 2017 at 01:09

+1 i.e. use one I2S as master receiver and one as slave receiver.

You can either use two SPIs for this and connect clocks externally, or use a 'fullduplex' I2S which is the same with the clocks linked internally between SPI/I2S and the respective crippled-down I2Sext unit.

JW

Posted on March 30, 2017 at 09:05

Thanks for your answers!

So far, i have used only single I2S in 'half duplex master'. 

You suggest setup one I2S as half dplx master and other one I2S as half duplex slave? It will be then possible to start them both at the exact same time and they will have same clock input, so they will be synchronized? 

So i will connect it like this:

Master I2S will provide clk for both microphones and also for slave I2S (clk will be routed externally from master to slave? or can i connect clk from master to slave internally somehow?). Master will read data from one mic and slave from another one. Is that correct? 
Posted on March 30, 2017 at 10:01

You suggest setup one I2S as half dplx master and other one I2S as half duplex slave?

Yes, one maste receiver and one slave receiver, an both CK and WS connected externally.

Or, use the 'fullduplex' SPI/I2S + I2Sext couple, the clocks are connected there internally and the I2Sext can be slave only, so that would be the slave receiver and the SPI/I2S the master receiver.

It will be then possible to start them both at the exact same time

'Exact' is not necessary, simply start slave first. Make sure WS is in inactive state before you start it, see errata.

JW

Posted on March 30, 2017 at 16:35

Oh, then you don't need to be bothered by I2S at all... Use just SPI.

JW

PS.

Have you seen AN4041?

And are you aware of the DFSDM units in newer STM32?

And what is STM32F42?

Posted on March 30, 2017 at 16:05

Just for clarification: I am using MEMS microphones without WS. It has only DOUT and CLK pins ... no WS. 

See picture, is this gonna work as mentioned before? 

0690X00000606a5QAA.png
Posted on March 31, 2017 at 09:18

Ok so if i would use SPI, i would configure two of them as receive only slaves and i would generate clk for both of them with timer? I have looked at SPI baudrate configuration possibilities and it seems really not much - only one prescaller resulting in hudge frequency (baudrate) steps. I would prefer I2S's smooth frequency settings or maybe i will go for two SPI slaves clocked by timer PWM.

Yes i have heard about DFSDM, but i cant find suitable fast enough mcu within F4 line. 

Tthere is a bug in my picture ofcourse, it should have been STM32F427.
Posted on March 31, 2017 at 13:19

I would prefer I2S's smooth frequency settings

Yes why not but then you need to connect WS too.

I repeat, using the 'fullduplex' I2S couples removes the need for external connecting the clocks.

JW

Mohamed Jallouli_2
Associate II
Posted on July 18, 2017 at 13:44

Hello,

   Have you concidered using two synchronous SAI sub-blocks? This allows you to interface two microphones separately    without needing a timer. You just have to configure one sub-block as Master and the other one as a Synchrounous    Slave. The SAI also allows you to have a fine tuned audio clock.

Regards,

MJ