using arduino uno as DAQ

Dear all, I have recently bought an Arduino UNO board. Now i am trying to use it as DAQ in order to sample the gy-61 acceleration sensor i connected to it. For the last three days I try to struggle it by myself and now I come to you and asking for help. Basically, my program should log the sensor data for 60 seconds at a sample rate of 500-100 Hertz. I am getting a rate of 100 at the most. I already try to use timer0 interrupts and code from https://sites.google.com/site/measuringstuff/the-arduino but with no success. Can you guide me to code that will help me achieve my goal? best regards

Post what you have so far.

this is the code i use right now:
#include <SD.h>

//Add the SdFat Libraries

#include <ctype.h>

//Define Pins
int pot1Pin = 0;
int pot2Pin = 1;int pot3Pin = 2;
int start;
unsigned long n = 0;

//Create the variables to be used by SdFat Library
Sd2Card card;
SdVolume volume;
SdFile root;
SdFile file;

char name = “log.csv”; //Array that contains name of file.
char contents[50]; //Data buffer for writing contents to the file.

#define FASTADC 1 //CODE TO INCREASE ANALOGREAD SPEED BY CHANGING PRESCALER

// defines for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif

void setup()
{
Serial.begin(115200);
card.init(SPI_HALF_SPEED, 8); //Initialize the SD card and configure the I/O pins.
pinMode(10,OUTPUT);
volume.init(card); //Initialize a volume on the SD card.
root.openRoot(volume); //Open the root directory in the volume.

#if FASTADC
// set prescale to 16
sbi(ADCSRA,ADPS2) ;
cbi(ADCSRA,ADPS1) ;
cbi(ADCSRA,ADPS0) ;
#endif

//Create header

file.open(root, name, O_CREAT | O_APPEND | O_WRITE); //Open or create the file ‘name’ in ‘root’ for writing to the end of the file.
sprintf(contents, “, , \nPOT1, POT2”);
file.println(contents); //Write the ‘contents’ array to the end of the file.

}

void loop(){
file.open(root, name, O_CREAT | O_APPEND | O_WRITE); //Open or create the file ‘name’ in ‘root’ for writing to the end of the file.

start = millis();
n=0;
while (millis()-start <= 1000){
n++;
sprintf(contents, “%d, %d ,%d,%lu ,%lu”, analogRead(pot1Pin), analogRead(pot2Pin), analogRead(pot3Pin),millis(),n);;
file.println(contents);
Serial.println(contents);
}
file.println(n);
file.close();
}

Not sure it will help, but does removing the serial print improve matters?

If you want to sample data uniformly and very rapidly, you cannot do any output in the sampling loop. That includes serial.print as wildbill suggested, but also file.println. Your only option is to store the data in an array and do something with the array after collecting the data. Then, a major limitation will be memory.