DATA LOGGING..

hi, what is the min value of data sampling i can get from a arduino mega board e.g how much ms .. and what software should i use to log data direct to my pc ,instead of a sd card by sd card shield.. thanks

:P I am a nooob too, but I think processing from processing would do the job. Not sure if there is a separate program for data-logging.

The serial connection to the PC would probably be the limiting factor for your sampling rate, so it would depend mainly on how many bytes you need to send per sample, and how fast you can get the serial port to run reliably. Obviously if you run it down at 9600 baud it'll be very reliable but you get a very low data rate. I don't know what the practical upper limit is - I've seen comments discussing rates approaching 1Mbps but I don't know how easy it is to achieve that.

OK, but there should be any program that stores the data received from the serial port ,like the com port window show live. :roll_eyes:

The serial connection to the PC would probably be the limiting factor for your sampling rate

Think not, I have run the serial port at 500.000 baud succesfully for some hours, with on the PC side putty.exe to write data to a file. baudrates of 230.400 and 345.600 do also work pretty well.

At 230.400 you can send 23000 bytes per second to the PC that is 10K+ 2 byte(int) analog samples in theory.
In practice you can get max ~5000 analog samples pumped into the PC I think.

Some testcode

void setup()
{
  Serial.begin(345600);  // use putty.exe or other terminal program as this is to fast for the build in IDE
  Serial.println("Start");
  
  unsigned long start = millis();
  for (int i=0; i< 10000; i++)
  {
    Serial.print(analogRead(A0));  // note text mode
  }
  Serial.println();
  Serial.println(millis() - start);
}

void loop()
{
}

output captured with putty.exe
Result: 3148 millisec for 10K samples => 3178 samples per second

// Now binary mode

int val;

void setup()
{
  Serial.begin(345600);
  Serial.println("Start");
  
  unsigned long start = millis();
  for (int i=0; i< 10000; i++)
  {
    val = analogRead(A0);
    Serial.write(byte((val & 0xFF00)>>8));  // write can send a byte at a time...
    Serial.write(byte((val & 0x00FF)));
  }
  Serial.println();
  Serial.println(millis() - start);
}

void loop()
{
}

output captured with putty.exe
Result: 1204 millisec for 10K samples => 8305 samples per second → think this is the upper limit - higher than I thought (see above)

A similar loop just doing 10000 analogRead() => 1120 millisec

Check if the math adds up 1204 - 1120 millisec = 84 millisec for 20.000 bytes => effective baudrate 238K of 345600 = 68% (sounds realistic to me, as the counter i is incemented 10000 times too :slight_smile:

Conclusion:
If you do no math with the samples ~8300 analog samples per second seems to be the limit. Doing some math (e.g. smoothing) will bring this number down.

On the otherhand one can increase the speed of analogRead so I think the 10K samples per second can be reached. - but that is another thread (search for fastAnalogRead or so)

– update –
FasterAnalogRead thread - http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1208715493/all -
Seems to be 6+ times faster

exellent ,great work...thankyou very much..... :open_mouth: