Again my apologies, I'm committing the "forum sin" of assuming the rest of the wold is familiar with the details of what I'm doing.
I'll try to explain better. I tried to post the whole code but I got an error message that it exceeded the maximum length of a forum post. Maybe it will let me do it now that I know how to properly post code, can't try again until tonight after work.
I'm using the "Lowlatencylogger" example in the SdFat library here:
And I'm bashing it together with the MCP3008 library here. This is an 8 channel 10 bit ADC connected by SPI:
The reason for diddling with the pins is that MCP3008 is a SPI connected device, and I'm logging to a spi connected SD card (the adafruit data logging shield). So multiple SPI devices. pins 8 and 10 are the CS pins for the ADC and the SD card respectively.
ADC_DIM is the total number of anolog pins being logged, in this case it happens to be 14
"adc"....is a bit of a mystery to me, it seems to be part of the structure "data"
both of them are appear in the included file as part of lowlatencylogger as below:
#ifndef UserDataType_h
#define UserDataType_h
const uint8_t ADC_DIM = 14;
struct data_t {
unsigned long time;
unsigned short adc[ADC_DIM];
};
#endif // UserDataType_h
With all of that said, I think you managed to identify my problem even with all of my vagueness.
the "adcc.readADC(i) will only work with i values of 0 through 7, not the 6 through 13 that I am asking it to do
I need to change it to something like this, which I will try tonight:
// Acquire a data record.
void acquireData(data_t* data) {
data->time = micros();
for (int i = 0; i < 6; i++) { //Read the 6 anolog input pins on the UNO
data->adc = analogRead(i);
}
digitalWrite(10, HIGH); //Sets the CS pin for the SPI sd card reader high to "disconnect" it
digitalWrite(8, LOW); //Sets the CS pin for the SPI connected external ADC low to "connect it"
for (int i=0; i<8; i++) {
data->adc = adcc.readADC(i); //Read the 8 analog inputs from the MCP3008
}
digitalWrite(8, HIGH); //disconnect MCP3008 ADC
digitalWrite(10, LOW); //re-connect sdcard reader