Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 9 of 9

Thread: T3.5 Quad I2S Microphones to RecordQueues not working

  1. #1

    T3.5 Quad I2S Microphones to RecordQueues not working

    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
    Click image for larger version. 

Name:	StereoI2SInput.PNG 
Views:	2 
Size:	7.0 KB 
ID:	18683
    (mics seem to have a DC offset but are capturing correctly)

    Quad serial monitor output
    Click image for larger version. 

Name:	QuadI2SInput.PNG 
Views:	3 
Size:	7.5 KB 
ID:	18684
    (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!
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	TeensyQuadI2SCircuit1.jpg 
Views:	9 
Size:	96.4 KB 
ID:	18681   Click image for larger version. 

Name:	TeensyQuadI2SCircuit2.jpg 
Views:	5 
Size:	84.7 KB 
ID:	18682  


  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,205
    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.

  3. #3
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,205
    Quote Originally Posted by Frank B View Post
    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.

  4. #4
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,522
    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.

  5. #5
    Quote Originally Posted by Frank B View Post
    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.
    Quote Originally Posted by Frank B View Post
    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.

    Quote Originally Posted by WMXZ View Post
    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

  6. #6
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,522
    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

  7. #7
    Quote Originally Posted by WMXZ View Post
    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?

  8. #8
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,319
    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...

  9. #9
    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •