Difference between revisions of "Data Logger"
Line 1: | Line 1: | ||
[[Image:sd_spi.jpg|thumb| | [[Image:sd_spi.jpg|thumb|micro SD card connected to SPI]] | ||
This describes an external device that can be connected to the Paparazzi autopilot to store telemetry data to a mass storage medium on board the aircraft, e.g. an SD card (only non-SDHC cards). For now this is not done with the autopilot itself as the usage of a file system as well as possible lag you might get with a SD card (erase times) does not fit well with the real time nature of the used software scheduler. | This describes an external device that can be connected to the Paparazzi autopilot to store telemetry data to a mass storage medium on board the aircraft, e.g. an SD card (only non-SDHC cards). For now this is '''not''' done with the autopilot itself as the usage of a file system as well as possible lag you might get with a SD card (erase times) does not fit well with the real time nature of the used software scheduler. You need to use e.g. an additional TWOG. | ||
== Mode of operation == | == Mode of operation == | ||
The logger is connected | The logger is connected between the autopilot and the modem. It stores all telemetry on a micro SD card when power is connected. At the end of the flight a button is pressed just before disconnecting the main battery to stop logging (other ways of stopping are not yet done, e.g. by telemetry message from the gcs or a battery buffered voltage-drop detection). When logging is stopped and the USB is connected the logger acts as USB mass storage device and the micro SD card content can be read with any PC supporting FAT file system. The telemetry data is converted to the standard .data and .log file with a Paparazzi tool. Logging can be started again through a long press of the button if USB was not connected. | ||
== Hardware == | == Hardware == | ||
We decided to use the well known LPC2148 to do the logging | We decided to use the well known LPC2148 to do the logging. That allows to use the Paparazzi configuration/tool chain and have a standard USB connection for read out with any PC. Remember that micro SD cards do have a limited number of insertions and should not be plugged too often. The (micro) SD card is connected to the SPI1 of the TWOG following this scheme: | ||
microSD TinyV2 SPI J3 | microSD TinyV2 SPI J3 | ||
Line 34: | Line 34: | ||
## ## | ## ## | ||
The start/stop button is connected to the BUTTON (P0.7) pin of the USB connector (J9). It is activated by pulling it low. It has to be pressed to close the file and be | The start/stop button is connected to the BUTTON (P0.7) pin of the USB connector (J9). It is activated by pulling it low. It has to be pressed to close the file and be able to read the data! The USB should be connected after the logger is stopped to prevent going into download mode when re-powered. | ||
LED2 on: logging enabled, press button to stop | LED2 on: logging enabled, press button to stop | ||
Line 54: | Line 54: | ||
conf/airframes/logger_sd.xml | conf/airframes/logger_sd.xml | ||
as example. You can enable one or both UARTs and have to set the serial speed | as example. You can enable one or both UARTs for logging and have to set the serial speed | ||
<configure name="UART0_BAUD" value="B9600" /> | |||
<configure name="UART1_BAUD" value="B9600" /> | |||
The message type can be switched between the PPRZ and the XBEE format | The message type can be switched between the PPRZ and the XBEE format | ||
<configure name="LOG_MSG_FMT" value="LOG_PPRZ"/> | |||
''or'' | |||
<configure name="LOG_MSG_FMT" value="LOG_XBEE"/> | |||
The SD card can either be connected to SPI0 or SPI1 | The SD card can either be connected to SPI0 or SPI1 | ||
<configure name="SPI_CHANNEL" value="0" /> | |||
''or'' | |||
<configure name="SPI_CHANNEL" value="1" /> | |||
== Decoding == | == Decoding == |
Revision as of 14:17, 2 March 2012
This describes an external device that can be connected to the Paparazzi autopilot to store telemetry data to a mass storage medium on board the aircraft, e.g. an SD card (only non-SDHC cards). For now this is not done with the autopilot itself as the usage of a file system as well as possible lag you might get with a SD card (erase times) does not fit well with the real time nature of the used software scheduler. You need to use e.g. an additional TWOG.
Mode of operation
The logger is connected between the autopilot and the modem. It stores all telemetry on a micro SD card when power is connected. At the end of the flight a button is pressed just before disconnecting the main battery to stop logging (other ways of stopping are not yet done, e.g. by telemetry message from the gcs or a battery buffered voltage-drop detection). When logging is stopped and the USB is connected the logger acts as USB mass storage device and the micro SD card content can be read with any PC supporting FAT file system. The telemetry data is converted to the standard .data and .log file with a Paparazzi tool. Logging can be started again through a long press of the button if USB was not connected.
Hardware
We decided to use the well known LPC2148 to do the logging. That allows to use the Paparazzi configuration/tool chain and have a standard USB connection for read out with any PC. Remember that micro SD cards do have a limited number of insertions and should not be plugged too often. The (micro) SD card is connected to the SPI1 of the TWOG following this scheme:
microSD TinyV2 SPI J3 8 nc 7 DO 5 MISO 6 GND 1 GND 5 CLK 7 SCK 4 Vcc 2 +3V3 3 DI 4 MOSI 2 CS 3 SSEL 1 nc
Looking onto the gold plated connector side of the microSD card: ############### I 8 I 7 I 6 I 5 I 4 I 3 I 2 I 1 ###### ## \ I \ ## ##
The start/stop button is connected to the BUTTON (P0.7) pin of the USB connector (J9). It is activated by pulling it low. It has to be pressed to close the file and be able to read the data! The USB should be connected after the logger is stopped to prevent going into download mode when re-powered.
LED2 on: logging enabled, press button to stop LED3 flashing: writing message to SD LED2 flashing: logging stopped, connect USB to read out data or press button long to restart logging LED1 on: USB mass storage enabled
UART Connection
The two serial inputs LPC_RXD0 (J7) and RXD1 (J2) are used to receive data. The received data is not forwarded to TX0/1 by software (the UART TX pins are deactivated). If the logger is put in between Tiny and the modem the connection should be done with a wire so that a logger failure does not cause any data link issue.
I2C Connection
tbd
Configuration
The logger is defined just like an aircraft. Take the
conf/airframes/logger_sd.xml
as example. You can enable one or both UARTs for logging and have to set the serial speed
<configure name="UART0_BAUD" value="B9600" /> <configure name="UART1_BAUD" value="B9600" />
The message type can be switched between the PPRZ and the XBEE format
<configure name="LOG_MSG_FMT" value="LOG_PPRZ"/> or <configure name="LOG_MSG_FMT" value="LOG_XBEE"/>
The SD card can either be connected to SPI0 or SPI1
<configure name="SPI_CHANNEL" value="0" /> or <configure name="SPI_CHANNEL" value="1" />
Decoding
The telemetry is written in the Paparazzi .tlm format that adds a timestamp to each message. The logger starts with 00000000.TLM in the main folder of the SD and increases the number with each log session. Already used numbers will not be overwritten. This data can be converted back to the Paparazzi .log and .data format using sd2log
me@home:~/media/usbstick$ ~/paparazzi3/sw/logalizer/sd2log 00000002.TLM Renaming produced file ... 09_08_13__20_55_03_SD.data file produced 09_08_13__20_55_03_SD.log file produced 09_08_13__20_55_03_SD.tlm file saved
It creates timestamps from the .tlm and changes the filename to the take-off time if a GPS message with correct time was available in the file or the current local PC time if no GPS was available. The .log file will be re-created either from the current configuration (if still in existence) or the MD5-labeled files that are stored in var/conf each time you build an aircraft. All resulting files are stored in var/logs with an _SD extension.