I'm hoping this is a very easy fix. To start, I'm using Maple IDE 0.0.9 and the maple r5 board. The sketch I have at present attempts to fill an array with both a time stamp of when the data was acquired and the actual analogRead. The problem of the output can been seen below. Despite having a delayMicroseconds(50) there seems to be some sort of variable delay that takes approximately 7-8 microseconds. While livable, it would be nice to have a reproducible time stamp for the analog reads placed into an array--or any process for that matter. I tried introducing the noInterrupt() call but that still produced the same result. Any ideas would be appreciated.
Cheers.
Brian
SerialUSB Output:
####################################
Micros DeltaT AnalogIn
6152400 , , 2370
6152457 , 57 , 2266
6152515 , 58 , 2186
6152573 , 58 , 2129
6152631 , 58 , 2089
6152688 , 57 , 2056
6152746 , 58 , 2033
6152804 , 58 , 2167
6152862 , 58 , 2115
6152920 , 58 , 2076
6152977 , 57 , 2047
6153036 , 59 , 2178
6153093 , 57 , 2120
6153151 , 58 , 2077
6153211 , 60 , 2048
6153268 , 57 , 2027
6153326 , 58 , 2156
6153384 , 58 , 2107
6153442 , 58 , 2074
6153500 , 58 , 2045
6153557 , 57 , 2177
6153615 , 58 , 2119
6153673 , 58 , 2075
6153731 , 58 , 2050
6153788 , 57 , 2029
#################################
int analogPin = 0;
// our array size
int size=25;
uint32 time[25];
uint32 rawdata[25];
void setup() {
pinMode(analogPin, INPUT_ANALOG);
SerialUSB.begin();
}
void loop() {
//noInterrupts();
for (int i=0;i<size;i++) {
time[i]=micros();
rawdata[i]=analogRead(analogPin);
delayMicroseconds(50);
}
for (int i=0;i<size;i++) {
SerialUSB.print(time[i]);
SerialUSB.print(" , ");
if (i > 0) {
SerialUSB.print((time[i]-time[(i-1)]));
SerialUSB.print(" , ");
}
else{
SerialUSB.print(" ");
SerialUSB.print(" , ");
}
SerialUSB.println(rawdata[i]);
}
SerialUSB.println("");
delay(3000);
}