Kranvonkyln
Member
Hi,
I'm working with an Accelerometer, i use the ADC library but the maximum which i get is 13760-15020 Sapmles per second.
My code:
I don't know what i'm doing wrong but the lines
don't really matter, i run my code without them and i still get 13-15k.
Any ideas how can i increse the speed of reading?
I'm working with an Accelerometer, i use the ADC library but the maximum which i get is 13760-15020 Sapmles per second.
My code:
Code:
#include <ADC.h>
ADC *adc = new ADC();; // adc object
volatile int elapsed;
int readPin = A9; // ADC0
int value = 0;
void setup() {
pinMode(readPin, INPUT);
Serial.begin(1000000);
adc->setAveraging(0); // set number of averages
adc->setResolution(12); // set bits of resolution
adc->setConversionSpeed(ADC_CONVERSION_SPEED::HIGH_SPEED); // , change the conversion speed
adc->setSamplingSpeed(ADC_SAMPLING_SPEED::HIGH_SPEED); // change the sampling speed
adc->startContinuous(readPin);
while(!Serial){};
}
void loop() {
elapsedMicros elapsed;
while (elapsed <= 1000000)
{
value = (uint16_t)adc->analogReadContinuous(ADC_0); // the unsigned is necessary for 16 bits, otherwise values larger than 3.3/2 V are negative!
Serial.println(value, DEC);
}
exit(0);
}
I don't know what i'm doing wrong but the lines
Code:
adc->setConversionSpeed(ADC_CONVERSION_SPEED::HIGH_SPEED);
adc->setSamplingSpeed(ADC_SAMPLING_SPEED::HIGH_SPEED);
Any ideas how can i increse the speed of reading?
Last edited: