PDM mic and audio shield

richcj10

Member
I have a PDM mic (IM69D130V01XTSA1) running with this code.

Code:
#include <Arduino.h>

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioInputPDM            pdm1;           //xy=364,169
AudioFilterStateVariable filter1;        //xy=384.99998474121094,268.0000190734863
AudioAmplifier           amp1;           //xy=515,170
AudioAnalyzeFFT1024      fft1024_1;      //xy=567.9999961853027,241.000018119812
AudioEffectWaveshaper    waveshape1;     //xy=571,289
AudioOutputI2S           i2s1;           //xy=742,291
AudioConnection          patchCord1(pdm1, amp1);
AudioConnection          patchCord2(filter1, 1, fft1024_1, 0);
AudioConnection          patchCord3(filter1, 1, waveshape1, 0);
AudioConnection          patchCord4(amp1, 0, filter1, 0);
AudioConnection          patchCord5(waveshape1, 0, i2s1, 0);
AudioControlSGTL5000     sgtl5000_1;     //xy=383,359
// GUItool: end automatically generated code

// GUItool: end automatically generated code

float WAVESHAPE_INVERT[2] = {
  1.0,
  -1.0
};

void setup() {
  AudioMemory(50);
  filter1.frequency(30); // filter out DC & extremely low frequencies
  amp1.gain(8.5);        // amplify sign to useful range
  waveshape1.shape(WAVESHAPE_INVERT, 2);
}

void loop() {
  if (fft1024_1.available()) {
    // each time new FFT data is available
    // print 20 bins to the Arduino Serial Monitor
    Serial.print("FFT: ");
    for (int i = 0; i < 20; i++) {
      float n = fft1024_1.read(i);
      if (n >= 0.001) {
        Serial.print(n, 3);
        Serial.print(" ");
      } else {
        Serial.print("  --  "); // don't print "0.000"
      }
    }
    Serial.println();
  }
}

Bur this is with the radio shield plugged in. Can I run the PDM mic and the shield at the same time? I need to for a project I am running
 
Are both trying to transmit data to Teensy pin 8?

You probably need to sever the connection between the audio shield and pin 8, so it doesn't conflict with the microphone's data. The audio shield has a place to cut the signal, and pads you can solder bridge if you later want to reconnect it.

pin8.jpg
 
Oh, I probably didn't explain this well. The pin 8 issue is purely a matter of hardware. Or at least I think it is, but I'm going only from the words you wrote. I can't see what you've actually done or how the wires are really connected.

But my assumption is you've connected both this mic as the docs say, and the audio shield with all pins. When running, both the mic and audio shield transmit data to pin 8. Even if you don't use an I2S input in your design, the audio shield will still try to drive pin 8 when it it enabled.

The possible issue is if both are physically wired to pin 8, then both would be trying to drive the same pin. That's not good. It's a hardware matter, that only 1 driven signal should be connected to any specific pin.
 
I have the PDM mic attached to pin 8 (Data) and pin 21 (Clock). Where do I move the data and clock lines from the Audio shield?
Mic.jpgMB.jpg
 
Back
Top