Interfacing an Altimeter that has Serial Output

I have a question, I have no experience with inputing data from hardware. So, in the user manual of the PerfectFlite Stratto Logger Altimeter, under the 'Telemetry output' section:

The StratoLogger has an on-board data connector that is used for real time data output during flight using the telemetry feature

Serial port settings should be configured for 9,600BPS, 8 data bits, no parity, and 1 stop bit. Output data format from the altimeter is ASCII text based, with a and character appended to the end of each line.

When telemetry data is selected to start “OnLaunch”, all data will be AGL (above ground level) altitudes:
198 {all data points are AGL altitude}
248
300
349
398
447
497

So I was hoping that some of you could kinda guide me on the part of getting the data into the altimeter. Specially on the part of 9600BPS and 8 data bits, no party and 1 stop bit. What does this all mean

I also don't quite understand that 'the format of the altimeter is ASCII text based'. According to Arduino Reference - Arduino Reference , ASCII is used to encode text into numerical values, but an altimeter does not measure in letters, it measures in numbers (feet or meters)...

If you are reading this and can help in anything of the above it will be greatly appreciated. Thank you.

Insert
Serial.begin(9600);
in void setup. Default settings are 8 data bits, 1 stop bit, no parity. Check out RS232 at wikipedia.com for an explanation of serial data transfers.

Check out asciitable.com

If you were to look at the data actually transmitted, you would see 5 bytes of hex code for every line above. The 1, 9, 8, , all
have a hex equivelent, your arduino will receive and those and make decisions as to what to do with the data.
198 would come out as 0x31 0x39 0x38 0x0D 0x0A, where 0x signifies hex data.

So you would have your code look for data, something like this

if (Serial.available()>0){ // did at least 6 bytes come in?
incomingByte = Serial.read; // read the first character
   if (incomingByte == 0x0A){  // ignore bytes that aren't end of a block of 5 to get in sync
      while (Serial.available <4){ //saw good LF, wait for 5 bytes to come in
      // 5 bytes are in, read them:
        byte0 = Serial.read();  //read hundreds digit
        byte1 = Serial.read();  // read tens digit
        byte2 = Serial.read(); // read ones digit
        byte3  = Serial.read();  // CR
        byte4 = Serial.read(); // LF
       } // end while
      // do something with the data
    } // end 0x0A check
}  // end serial.available check

CrossRoads' code is a good start, but it won't work. The data isn't a fixed 3 column field; you'll need to be able to deal with varying length numbers.

Here's some code I wrote that reads positive integers.

#define isdigit(X) (((X) >= '0') && ((X) <= '9')

int read_int()
{
  static byte c;
  static int i;

  i = 0;
  while (1)
  {
    while (!Serial.available())
    {;}
 
    c = Serial.read();
    Serial.print(c, BYTE);
  
    if (c == '\r')
    {
      return i;
    }
    if (isdigit(c))
    {
      i = i * 10 + c - '0';
    }
    else
    {
      Serial.print("\r\nERROR: \"");
      Serial.print(c, BYTE);
      Serial.print("\" is not a digit\r\n");
      return -1;
    }
  }
}

Hopefully the stratologger doesn't throw commas in there when you get >10,000'...

-j

Note that the manual also states that it is a 3.3V interface.

I was wondering if anyone ever figured out the code for reading the data from a stratologger device in a way that recognizes it as integers so you can apply some math to the values being transmitted. I've tried a number of things using the great input posted on Aduino Forum but I'm too much of a newbie to figure it out. Any thoughts and I'll keep trying!

9600BPS and 8 data bits, no party and 1 stop bit

The 9600BPS is the speed (baud rate) at which data is sent, i.e. 9,600 bits per second.
Each data character is made up of a number of bits in this case 8 plus a stop bit makes 9, so 9600 means it could send about 1067 characters every second if it sent data continuously.
The stop bit helps tell where one character ends and the next begins.
Parity is a means of helping detect if a character has been corrupted, in this case parity is not being used.

In general you just setup the transmitter and the receiver to use the same settings and you don't need to worry about the bits. Whole characters are written at the transmitter and read at the receiver, the fact that the were sent as bits is normally invisible to you.

Providing the receiver is able to read the characters faster than the transmitter sends them all is well.
Things get more complicated if your receiver is busy doing other things.

Using serial data is relatively slow so you need to think about how fast your altitude will change and that the interface speed will let you take readings fast enough to get the accuracy you want. No problem in a balloon, but worth checking in a rocket.

" 9600 means it could send about 1067 characters every second"
Little bit less, you forgot the start bit too. I think you usually see 1 space bit to0 (1 high space after the stop bit), so effectively 11 bits/character.

Combining the code already supplied gives you this:

int foo; // Useless declaration to molify the IDE
#define isdigit(X) (((X) >= '0') && ((X) <= '9'))

void setup()
{
  Serial.begin(9600);
}

void loop()
{
int AGL=read_int();
// Do math
}


int read_int()
{
static byte c;
static int i;

i = 0;
while (1)
  {
  while (!Serial.available())
    {;}
 
  c = Serial.read();
  
  if (c == '\r')
    {
    return i;
    }
  if (isdigit(c))
    {
    i = i * 10 + c - '0';
    }
  else
    {
    Serial.print("\r\nERROR: \"");
    Serial.print(c);
    Serial.println("\" is not a digit\r\n");
    return -1;
    }
  }
}

Compiled, not tested

The "buffering input" code below on Nick's page below would seem to do what you are looking for (assuming the altimeter values are sent as characters). You could add the atoi function if needed.