Logging acceleration data

I am struggling with what seems should be a simple task. I have a LilyPad Arduino (ATmega 168) and an accelerometer (also LilyPad from Sparkfun). I want to read simple uniaxial (z-axis) vibration at the highest possible sampling rate. Presently, I have the code set for 200Hz–I would prefer as high as 1000Hz. I am using GoBetwino to communicate between the Arduino and the PC–to log into a text file (using Excel doesn’t work, because the number of samples I will need to collect will exceed the available number of rows.

I have run the sample (gobetwinoLogTest.pde) and it works fine. In adapting this, I am attempting to use the following code:

//read the analog input into a variable:
int serInLen = 25;
char serInString[25];
int result;

void setup() 
{ 
  // Setup serial comm.
 Serial.begin(115200); 
 Serial.println("#S|CPTEST|[]#");
 readSerialString(serInString,1000);
} 
void loop() 
{
 //read the analog input into a variable:

 int zpin = 3;

   char buffer[5];
  
    Serial.print("#S|LOGTEST|[");
    Serial.print(analogRead(zpin));  
    Serial.println("]#");
    delay (5);
    readSerialString(serInString,1000);
   // There ought to be a check here for a non 0 return value indicating an error and some error handeling
}
//read a string from the serial and store it in an array
//you must supply the array variable - return if timeOut ms passes before the sting is read
void readSerialString (char *strArray,long timeOut) 
{
   long startTime=millis();
   int i;

   while (!Serial.available()) {
      if (millis()-startTime >= timeOut) {
         return;
      }
   }
   while (Serial.available() && i < serInLen) {
      strArray[i] = Serial.read();
      i++;
   }
}

I seem to get reasonable data when I set the delay at 500 and 50 (2Hz and 20Hz, respectively). At a delay(5), though, I am way off.

Can someone help me with the code and/or suggestions for logging the data as a .txt? I am a complete newbie to Arduino and programming like this. :-[

At a delay(5), though, I am way off.

What does this mean, please?

Have you worked out how much time it takes to print your messages?

I'm not sure GoBetwino can handle 200 logging commands / second.

What actually happens is that the log file is opend / written to / closed for every command. Doing this 200 times a second is probably not possible.

Try to increase the delay in smal steps until you have someting that works.

I would be very glad if you would tell me (os) how fast you can get reliable logging, so i can use it to improve the function in a future version of GoBetwino.