Hi, im trying to do a project where i will be needing a very high sampling rate. I want to use some microphones to detect loud short noises (like claps) - but i have 4 microphones(testing with 2) i want to sample with. I know the Tennsy 3.2 have 2 ADC's and im trying to understand and use Pedvide's ADC library (https://forum.pjrc.com/threads/25532-ADC-library-update-now-with-support-for-Teensy-3-1) but im not sure how to set up the high sampling rate and how to store the values for a bit?
right now i got the following code:
but i have tried to add serial print to see my values and it seemse to be hard to see the diffrence in the level of sound ( seen from this code example https://github.com/pedvide/ADC/blob/master/examples/analogRead/analogRead.ino )
i know there is some background noise, but i should be able to see the claps. Right now im thinking it is because the serial print cannot keep up with the sample rate, so how can i get a fast readout of the ADC that i can see? sound quality doesnt matter, only high speed and peak readouts. also how should i store the values?
TL; DR How do i sample highspeed sound and store the data from 2 (or 4) microphones on the teensy 3.2?
right now i got the following code:
Code:
#include <ADC.h>
const int readPin = A3; // ADC0
const int readPin2 = A2; // ADC1
ADC *adc = new ADC(); // adc object;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("Begin setup");
pinMode(LED_BUILTIN, OUTPUT);
pinMode(readPin, INPUT); //pin 23 single ended
pinMode(readPin2, INPUT); //pin 23 single ended
adc->setSamplingSpeed(ADC_VERY_HIGH_SPEED);
adc->setConversionSpeed(ADC_VERY_HIGH_SPEED);
adc->setAveraging(8, ADC_1); // set number of averages
adc->setResolution(8, ADC_1); // set bits of resolution
adc->setConversionSpeed(ADC_VERY_HIGH_SPEED, ADC_1); // change the conversion speed
adc->setSamplingSpeed(ADC_VERY_HIGH_SPEED, ADC_1); // change the sampling speed
// always call the compare functions after changing the resolution!
adc->enableCompare(1.0/3.3*adc->getMaxValue(ADC_1), 0, ADC_1); // measurement will be ready if value < 1.0V
//adc->enableCompareRange(1.0*adc->getMaxValue(ADC_1)/3.3, 2.0*adc->getMaxValue(ADC_1)/3.3, 0, 1, ADC_1); // ready if value lies out of [1.0,2.0] V
}
int value;
int value2;
void loop() {
// put your main code here, to run repeatedly:
value = adc->analogRead(readPin, ADC_0);
value2 = adc->analogRead(readPin2, ADC_1);
}
but i have tried to add serial print to see my values and it seemse to be hard to see the diffrence in the level of sound ( seen from this code example https://github.com/pedvide/ADC/blob/master/examples/analogRead/analogRead.ino )
i know there is some background noise, but i should be able to see the claps. Right now im thinking it is because the serial print cannot keep up with the sample rate, so how can i get a fast readout of the ADC that i can see? sound quality doesnt matter, only high speed and peak readouts. also how should i store the values?
TL; DR How do i sample highspeed sound and store the data from 2 (or 4) microphones on the teensy 3.2?