Pressure logging with Arduino

I'm going to measure fast pressure changes in a compressed air system. How many samples per second could I get with the following code?

void loop()
{
   val = analogRead(analogPin);
   Serial.println(val);
}

depends on the Serial port speed. I have used up to 500000 baud successfully.

analogRead can do about 8000 samples per second but that leaves no time for serial
in practice you get about 3000 samples per second out with such tight loop.

To increase the performance check this discussion - Experiment - split up analog read in 3 steps - Libraries - Arduino Forum
it mentions a number of tricks to speed up things

So there will be more than enough samples. I think that Arduino might be faster than my pressure sensor.

How fast will the pressure change one measurable unit?
that is the question.

What sensor do you use? can you post a link to the datasheet?

I don't need a very high sample rate. Initially I was hoping to get at least 10 samples per second so probably any sensor is enough for me. I just wanted to make sure there's nothing unexpected with the Arduino.

with that "low"number of samples you might use take e.g. 16 samples and take the average. That would reduce noise. 16 samples would take 2-3 milliseconds.

uint32_t lastTime = 0;
float sum = 0;

void loop()
{
  // 10x per second
  if (millis() - lastTime >= 100)
  {
    lastTime = millis();
    // sample the sensor
    sum = 0;
    for (uint8_t i=0; i<16; i++) sum += analogRead(A0);
    // take the average
    sum = sum * 0.0625;  // ==/16 but faster  including rounding
    Serial.println(sum);
  }
}

Is there any software available to record and plot data from arduino? I could just copy and paste data from serial monitor to Excel, but I wonder if there is a better way.

yes, check - Arduino Playground - GoBetwino

or download PLX-DAQ.xls - Download - Parallax

Am looking for feedback on this software I wrote for Arduino data visualization. Give it a try and tell me what improvements can be made or whether it works well for you.

http://forum.arduino.cc/index.php?topic=312702.0

@ Kestis, just a word of caution on PLX. I understand it only works with older versions of Excel. I use Excel2003, but it might be kosher with 2007. PLX effectively turns Excel into a terminal and has the advantage of thereby giving you live graphs. PLX is so good that, if you use a too-new version of Excel, upgrading to Excel 2003 is worth entertaining.

You cannot copy from the serial monitor but you can record with a proper terminal programme like RealTerm. Realterm is a freebie.

Both programmes also provide timestamping from the PC's clock but, if you require that, you might require something special on-board, at the rate you are going.

robtillaart:
depends on the Serial port speed. I have used up to 500000 baud successfully.

analogRead can do about 8000 samples per second but that leaves no time for serial
in practice you get about 3000 samples per second out with such tight loop.

Serial output is interrupt driven from a buffer, in practice it will mostly run in parallel with
analogRead.