wiki/ avionics/ av3-data-protocol

Introduction

For the Summer 2013 launch a provisional data message format has been created for sending flight computer data over WiFi to the ground. Data is sent by UDP over IPv4 with the requirement that no data message be split over two or more UDP packets and that a UDP packet may hold more than one (complete) data message. Additionally the format should be somewhat identifiable from the data itself. This is the format that we came up with.

  1. Introduction
  2. Fields
    1. Field IDs
    2. Example Message (in C)
    3. Message Documentation
      1. ADIS
      2. Roll
      3. MESG
      4. Crescent GPS
  3. Discussion
    1. Requirements

Fields

At the beginning of every UDP packet is a 32 bit uint that is incremented with every packet sent out. This is intended to tell on the ground if a packet was lost.

The beginning of every message has a header in the following format:

  1. ID [4 ASCII bytes]
  2. timestamp [6 bytes, nanoseconds from boot of the FC]
  3. length (in bytes) of data section [2 bytes]
  4. Data [variable]

The timestamp length (6 bytes) in nanoseconds comes out to about three days worth of time, long enough for any of our current and foreseeable future flights. The recommended method for acquiring this value is something like this:

static uint64_t get_timestamp(void)
{
        struct timespec now;
        clock_gettime(CLOCK_MONOTONIC, &now);
        now.tv_sec -= starttime.tv_sec;
        now.tv_nsec -= starttime.tv_nsec;
        return now.tv_nsec + (uint64_t) now.tv_sec * 1000000000;
}

Field IDs

Example Message (in C)

typedef     uint16_t                          adis_reg_data;

struct ADIS16405_burst_data {
    adis_reg_data      adis_supply_out; //  Power supply measurement
    adis_reg_data      adis_xgyro_out;  //  X-axis gyroscope output
    adis_reg_data      adis_ygyro_out;  //  Y-axis gyroscope output
    adis_reg_data      adis_zgyro_out;  //  Z-axis gyroscope output
    adis_reg_data      adis_xaccl_out;  //  X-axis accelerometer output
    adis_reg_data      adis_yaccl_out;  //  Y-axis accelerometer output
    adis_reg_data      adis_zaccl_out;  //  Z-axis accelerometer output
    adis_reg_data      adis_xmagn_out;  //  X-axis magnetometer measurement
    adis_reg_data      adis_ymagn_out;  //  Y-axis magnetometer measurement
    adis_reg_data      adis_zmagn_out;  //  Z-axis magnetometer measurement
    adis_reg_data      adis_temp_out;   //  Temperature output
    adis_reg_data      adis_aux_adc;    //  Auxiliary ADC measurement
} __attribute__((packed));
typedef struct ADIS16405_burst_data ADIS16405_burst_data;

struct ADIS_message {
        char                 ID[4];
        uint8_t              timestamp[6];
        uint16_t             data_length;
        ADIS16405_burst_data data;
} __attribute__((packed));
typedef struct ADIS_message ADIS_message;

Message Documentation

Documentation for the types of messages:

ADIS

The ADIS is an integrated IMU/magnetometer from analog devices.

ID: 'ADIS'

Body:

Field Index Type Size [bytes] Description
0 signed short 2 Power supply measurement
1 signed short 2 X-axis gyroscope output
2 signed short 2 Y-axis gyroscope output
3 signed short 2 Z-axis gyroscope output
4 signed short 2 X-axis accelerometer output
5 signed short 2 Y-axis accelerometer output
6 signed short 2 Z-axis accelerometer output
7 signed short 2 X-axis magnetometer measurement
8 signed short 2 Y-axis magnetometer measurement
9 signed short 2 Z-axis magnetometer measurement
10 signed short 2 Temperature
11 signed short 2 Auxiliary ADC

Example python struct:

struct.Struct("<12h")

Units

The ADIS reports fixed point representation of the onboard instruments. To get floats do the following:

Instrument Fixed to float (multiply by) Units
Power Supply 2.418 mV
Rate Gyro 0.05 °/sec
Accelerometer 3.33 mg
Magnatometer 0.5 mgauss
Temperature 0.14 °C
Aux ADC 806 μV

Roll

Roll computer data

ID: 'ROLL'

Body:

Field Index Type Size [bytes] Description
0 unsigned short 2 Fin position (servo PWM in microseconds)
1 byte 1 Roll Servo Disable (boolean)

Example python struct:

struct.Struct("<HB")

MESG

Free form messages from the FC

ID: 'ROLL'

Body:

Field Index Type Size [bytes] Description
0 string variable A string message

Example could include "ROCKET ARMED", etc.

Crescent GPS

ID: 'GPS_'

The GPS module will report binary data. The definitions of the data are from the Integrator's manual which can be downloaded here:

CrescentIntegratorsManual.pdf

We will be using the BIN messages: (BIN1, BIN2, etc.) reported as GPS1, GPS2, etc.

Discussion

Requirements

We estimate that rocket would be generating no more than 100kb/s of data for the October flight so the wifi connection should be able to handle this easily.