Blackbox Logging - rotorflight/rotorflight GitHub Wiki

:exclamation: This page is outdated

Rotorflight Wiki is replaced by www.rotorflight.org.


Blackbox data can be logged to:

  • An SD card on the FC. This is probably the best way to log: it's fast and storage is only limited by the capacity of the SD card.
  • A flash chip on the FC. Logging is fast, but storage is limited and copying log files can be slow.
  • Or to an external logging device: OpenLog or OpenLager. Both devices use a micro SD card. OpenLog is slow, OpenLager is a lot faster.

A flash chip or an SD card on the FC are nice, but if your FC doesn't have that you can connect an OpenLog or OpenLager logging device.

Connecting OpenLog or OpenLager

OpenLog and OpenLager can be connected to the FC using just three wires: +5V, ground and a TX output pad from a free UART on the FC, which is connected to the RX pad of the logging device. As soon as you power the device on, it will create a new log file on the SD card. Then it'll log everything it receives to that file. Simple but effective. For maximum performance the SD card should be formatted with the SD Association's special formatting tool. A fast SD card is needed, e.g. the Sandisk Extreme 16GB Class 10 UHS microSDHC.

OpenLog

OpenLog is a data logger developed by SparkFun. It can record up to 250kbps, but since it doesn't have a write buffer data can be lost. For better results the original SparkFun firmware should be replaced with Blackbox firmware. You need an FTDI cable/adapter to update the OpenLog board. There are also OpenLog clones for sale that are already equipped with Blackbox firmware. You can check your firmware by inspecting the Config.txt file on the SD card, a file that will be created if it doesn't already exist. If it just states the baud rate (e.g. a line with a number and then a line with the word baud), it's using the Blackbox firmware. The SparkFun firmware specifies more properties in Config.txt: baud, escape, esc#, mode, verb, echo, ignoreRX.

OpenLager

OpenLager is a Blackbox data logger developed by dRonin. It can log a lot faster (up to 2470kbps) and uses a write buffer. It's superior to OpenLog, and unless you're on a very tight budget there's no excuse not to use OpenLager.

Some versions use an open/lock hinge mechanism instead of a 'push to eject' SD card socket, so you can't wrap it in heat shrink tube. You can fix that by carefully flattening the SD card retainer pin a little bit.

Configure Blackbox Logging

After you've connected OpenLog/OpenLager, you should configure your helicopter for logging in Rotorflight Configurator.

  • Ensure that your TX output pad has been assigned a resource with resource SERIAL_TX (see Betaflight Unified Targets Repo).
  • Specify which UART is connected to OpenLog/OpenLager. Go to the Serial Ports tab, then select Blackbox logging under Peripherals for the UART used for logging. For OpenLog, select a baudrate of 250kbps, for OpenLager select 2000kbps. Click Save and Reboot.
  • Now you can assign a transmitter switch for logging under the Modes tab. Find the Blackbox mode and assign a range. You can choose a very broad range in order to log always. Click Save.
  • Configure what to log in the Blackbox tab. Select Serial Port as your Blackbox logging device and a log rate of 500 Hz for OpenLog or 2 kHz for OpenLager. Under Blackbox debug mode you can specify what should be logged. There are a lot of choices, but you can select GYRO_SCALED for PID tuning, GOVERNOR for analyzing the governor or CYCLETIME if you're interested in CPU time. Click Save and Reboot.

When logging mode is active and blackbox_mode is set to NORMAL, logging will start when you arm your helicopter. You can set blackbox_mode to ALWAYS for testing purposes, but be aware that you won't see log files unless the FC is rebooted (using LUA or the Configurator).

The log files can be read with the Rotorflight Blackbox Explorer.