Pedvide ADC library with 4 microphones

Status
Not open for further replies.

Tootsie

Member
Hello,

I am using pedvide's ADC library for my project where I am reading in a buffer array from each microphone when one of them receives a signal that is bigger than the background noise threshold. My mic has a reading of Vc/2 and I am using 8 bit depth so thats why I subtract the 127 to make the values at 0 which helps my future cross correlation function.

So I start continuous reading on pins 0 and 2 and read the data. Switch to reading on pins 1 and 3 and then read the data. my collectBufferData() function is set up exactly like below, but reads the numbers into a buffer through a loop from 0 to BUFFER_SIZE.

The problem is only 2 of the four microphones ever get their data recorded. Whenever I use analogReadContinuous() it only reads from pin1 and pin3 regardless of if I put
Code:
adc->adc0->startContinuous(readPin0);
 adc->adc1->startContinuous(readPin2);

I move the if statement around in order to debug which mic is actually the one corresponding to each pin. So when I put the if statement where it is, making a noise by the mic connected to pin0 does not cause the if statement to happen, but making a noise by the mic connected to pin1 does.


I set this up using startSingleRead(readPinX) and singleRead() incase it was the continuous reading that was the issue and found that the same issue applies.

Does anyone know what is going on with this?





Code:
void loop() {
  
      float backgroundNoise = 127;
      int THRESHOLD = 10;
      float adc_val0;
      float adc_val1;
      float adc_val2;
      float adc_val3;

        adc->adc0->startContinuous(readPin0);
        adc->adc1->startContinuous(readPin2);
        adc_val0 = adc->adc0->analogReadContinuous()-backgroundNoise;  
        
        if (adc_val0 > THRESHOLD || adc_val0 < -THRESHOLD ) { 
              pin=0;
              Serial.println("----0-----");
              Serial.println(adc_val0);
              collectBufferData();    
        }

        adc_val2 = adc->adc1->analogReadContinuous()-backgroundNoise; 
        //Serial.println(adc_val2);

        adc->adc0->stopContinuous();
        adc->adc1->stopContinuous();
        adc->adc0->startContinuous(readPin1);
        adc->adc1->startContinuous(readPin3);
        
        adc_val1 = adc->adc0->analogReadContinuous()-backgroundNoise;
        //Serial.println(adc_val1);

        adc_val3 = adc->adc1->analogReadContinuous()-backgroundNoise;
        //Serial.println(adc_val3);
        adc->adc0->stopContinuous();
        adc->adc1->stopContinuous();
}
 
Last edited:
Status
Not open for further replies.
Back
Top