T3.5 Quad I2S Microphones to RecordQueues not working

Status
Not open for further replies.
Hi,

I am doing a project at work involving I2S microphone capture and analysis with the Teensy 3.5. I have been having success with two microphones, the SPH0645LM4H (https://www.adafruit.com/product/3421), but now want to expand that to four. Unfortunately when I switch my code from AudioInputI2S to AudioInputI2SQuad, the output I get from all four AudioRecordQueue buffers is 0 on the "right" channels, and -32768 on the "left" channels. I have confirmed that all four microphones work in stereo mode, so am at a loss as to what the problem is.

As I am not using Audio Shields, so unable to verify with the PassThroughQuad sketch, here is an example with record queues to usb serial that illustrates the problem:
Code:
#include <Audio.h>

#define USE_QUAD
#ifdef USE_QUAD
  AudioInputI2SQuad      i2s1;  //This doesn't work
#else
  AudioInputI2S          i2s1;  //This works
#endif

AudioRecordQueue         queue1;
AudioRecordQueue         queue2;
AudioConnection          patchCord1(i2s1, 0, queue1, 0);
AudioConnection          patchCord2(i2s1, 1, queue2, 0);

#ifdef USE_QUAD
  AudioRecordQueue         queue3;
  AudioRecordQueue         queue4;
  AudioConnection          patchCord3(i2s1, 2, queue3, 0);
  AudioConnection          patchCord4(i2s1, 3, queue4, 0);
#endif


void setup()
{
  AudioMemory(120);

  Serial.begin(115200);
  delay(2000);

  queue1.begin();
  queue2.begin();

#ifdef USE_QUAD
  queue3.begin();
  queue4.begin();
#endif
}

void loop()
{
#ifdef USE_QUAD
  if(queue1.available() >= 1 && queue2.available() >= 1 && queue3.available() >= 1 && queue4.available() >= 1)
#else
  if(queue1.available() >= 1 && queue2.available() >= 1)
#endif
  {
    byte bufferA[256];
    byte bufferB[256];
    memcpy(bufferA, queue1.readBuffer(), 256);
    memcpy(bufferB, queue2.readBuffer(), 256);
    queue1.freeBuffer();
    queue2.freeBuffer();

  #ifdef USE_QUAD
    byte bufferC[256];
    byte bufferD[256];
    memcpy(bufferC, queue3.readBuffer(), 256);
    memcpy(bufferD, queue4.readBuffer(), 256);
    queue3.freeBuffer();
    queue4.freeBuffer();
  #endif

    for(int i = 0; i < 256; i+= 2)
    {
      int32_t aVal = (int16_t)bufferA[i] + (int16_t)(((int32_t)bufferA[i + 1]) << 8);
      int32_t bVal = (int16_t)bufferB[i] + (int16_t)(((int32_t)bufferB[i + 1]) << 8);
      Serial.print(aVal);
      Serial.print(",");
      Serial.print(bVal);
      Serial.print(",");

    #ifdef USE_QUAD
      int32_t cVal = (int16_t)bufferC[i] + (int16_t)(((int32_t)bufferC[i + 1]) << 8);
      int32_t dVal = (int16_t)bufferD[i] + (int16_t)(((int32_t)bufferD[i + 1]) << 8);
      Serial.print(cVal);
      Serial.print(",");
      Serial.print(dVal);
    #endif

      Serial.println(",4095,-4095"); //Added to force Arduino plotter to keep a fixed scale
    }
  }
}

Stereo serial monitor output
StereoI2SInput.PNG
(mics seem to have a DC offset but are capturing correctly)

Quad serial monitor output
QuadI2SInput.PNG
(no mics capture correctly)

I am using Arduino 1.8.10 with Teensyduino 1.48, on Windows 10. Also attached pictures of my circuit in case I'm doing anything silly there.

Any help with this issue would be greatly appreciated!
 

Attachments

  • TeensyQuadI2SCircuit1.jpg
    TeensyQuadI2SCircuit1.jpg
    96.4 KB · Views: 99
  • TeensyQuadI2SCircuit2.jpg
    TeensyQuadI2SCircuit2.jpg
    84.7 KB · Views: 79
How did you connect these boards?
On the Adafruit page I don't see any indication that they support this mode.
Havn't looked at the mic-datasheet, though.
 
could not find any issue yet, but for clarity (AFAIK) the channel sequence is L1,L2, R1,R2 and not L1,R1,L2,R2.
So your data say mic 1 is -32768 on both channels and mic2 is zero on both channels.
 
How did you connect these boards?
On the Adafruit page I don't see any indication that they support this mode.
Havn't looked at the mic-datasheet, though.
Ah, I see..
my fault. The Quad mode uses two RX-Pins.
Indeed. I believe pin 38 is RX1 so unless that is wrong I don't know what the issue is.

could not find any issue yet, but for clarity (AFAIK) the channel sequence is L1,L2, R1,R2 and not L1,R1,L2,R2.
So your data say mic 1 is -32768 on both channels and mic2 is zero on both channels.
Ah thanks. That explains the value discrepancy but not why neither pair no longer work. I would have thought L1 and R1 would have still output something
 
Only to be sure, I would put the SEL pin to GND AND to 3.3V respectively, so that all Mics have well defined SEL.
at the moment you have only connection to 3.3V
 
Only to be sure, I would put the SEL pin to GND AND to 3.3V respectively, so that all Mics have well defined SEL.
at the moment you have only connection to 3.3V
Thanks, I have added GND connections as you suggest but sadly no effect. I think the mic breakouts have pull-downs for SEL anyway. Has anyone got other thoughts I may try?
 
Quad I2S doesn't work with most I2S mics, because it uses a BCLK / LRCLK ratio of 32. Most I2S chips are flexible on this ratio, but most of those mics require a fixed ratio of 64.

Years ago the stereo I2S was change to have a ratio of 64, so these mics could work. But the quad I2S has remained a ratio of 32, because changing it is rather difficult...
 
Thanks for the explanation Paul! Glad to know I wasn't doing anything silly with my wiring or code.

Since this mic does not work with the 32 ratio, are there any others (preferably with breakout boards) that you can recommend I get in to test?
 
Status
Not open for further replies.
Back
Top