MAVLINKHUD

Overview

The LOG parameter group configures the DataFlash Logging system. This is the "Black Box" of the autopilot, recording high-frequency internal data (IMU, PIDs, GPS, Battery) for post-flight analysis.

Logs are essential for tuning, diagnosing crashes, and verifying mission performance.

Key Concepts

1. Storage Backend (LOG_BACKEND_TYPE)

Defines where the data is sent.

  • File (1): Records to the SD Card (Standard).
  • MAVLink (2): Streams logs to the Ground Station in real-time.
  • Block (4): Records to on-board SPI Flash memory.

2. Message Filter (LOG_BITMASK)

There are hundreds of data messages available. To save SD card space and CPU, you can choose which ones to log.

  • Standard: Logs basic navigation and attitude data.
  • Fast Attitude: Logs at the PID loop rate (essential for tuning).
  • Raw IMU: Logs every single gyro sample (very heavy, used for FFT analysis).

3. Disarmed Logging (LOG_DISARMED)

If enabled, the autopilot logs data even when the motors are not spinning. This is great for bench testing but consumes space quickly.

Parameter Breakdown

  • LOG_BITMASK: Bitmask of active log categories.
  • LOG_BACKEND_TYPE: Output selection.
  • LOG_FILE_BUFSIZE: RAM buffer size.
  • LOG_MAX_FILES: Number of old logs to keep before overwriting.

Integration Guide

Diagnosing a Problem

  1. Enable Raw Logging: Set LOG_BITMASK to include RawIMU (check Wiki for exact bit for your version).
  2. Replicate: Fly and perform the maneuver that caused the issue.
  3. Download: Use the "DataFlash Logs" tab in Mission Planner to download the .BIN file.
  4. Analyze: Use "Review Log" to graph the data.

Developer Notes

  • Library: libraries/AP_Logger.
  • Speed: On modern boards, logging can consume a significant portion of CPU time. Use LOG_BITMASK judiciously.

LOG_BACKEND_TYPE

Default 1
Range 0 7

AP_Logger Backend Storage type (LOG_BACKEND_TYPE)

Description

LOG_BACKEND_TYPE determines where your flight data is physically stored.

Most flight controllers have an SD card, but some specialized hardware might use internal flash chips (Block) or send the log data live over a telemetry radio (MAVLink).

  • Bit 0 (1): File. Save logs to the SD card (Standard).
  • Bit 1 (2): MAVLink. Send log data live to your Ground Station. (Requires high bandwidth link like WiFi/LTE).
  • Bit 2 (4): Block. Save logs to the internal onboard dataflash chip (if available).

Tuning & Behavior

  • Default Value: Usually 1 (File).
  • Safety: You can enable multiple backends simultaneously (e.g., set to 5 for File + Block).
  • Reboot Required: Yes.

LOG_BITMASK

Default 176126
Range 0 4294967295

Log Bitmask (LOG_BITMASK)

Description

LOG_BITMASK is the "Recording Selector" for your drone's black box.

ArduPilot can log a massive amount of data, but recording everything all the time would fill up your SD card too fast and might overload the CPU. This bitmask allows you to pick exactly what you want to record.

Key Bits

  • Bit 0 (1): ATTITUDE_FAST. Logs attitude at the fastest possible rate. (Heavy CPU).
  • Bit 1 (2): ATTITUDE_MED. Logs attitude at a medium rate. (Standard).
  • Bit 2 (4): GPS. Logs GPS position and satellite health.
  • Bit 3 (8): PM. Processor Monitoring (CPU load and loop times).
  • Bit 7 (128): IMU. Raw accelerometer and gyro data.
  • Bit 9 (512): CURRENT. Battery voltage and amperage.
  • Bit 12 (4096): PID. Motor controller P-I-D gains and errors. (Essential for tuning).
  • Bit 19 (524288): IMU_RAW. Extreme high-speed raw IMU data for vibration analysis.

Tuning & Behavior

  • Default Value: 176126 (Standard set including GPS, ATT_MED, CTUN, NTUN, etc.).
  • Recommendation:
    • Tuning PIDs: Ensure Bit 12 (PID) is enabled.
    • Troubleshooting Vibrations: Enable Bit 19 (IMU_RAW) briefly for one flight, then disable it (it generates huge files).

LOG_BLK_RATEMAX

Hz
Default 0
Range 0 1000

Maximum logging rate for block backend (LOG_BLK_RATEMAX)

Description

LOG_BLK_RATEMAX sets a speed limit for data being written to the onboard flash chip.

Internal flash chips often have limited capacity and write cycles. By setting a rate limit (e.g., 50Hz), you can ensure you capture enough data for tuning while preventing the chip from filling up too quickly during long flights.

  • 0: No limit.

LOG_DARM_RATEMAX

Hz
Default 0
Range 0 1000

Maximum logging rate when disarmed (LOG_DARM_RATEMAX)

Description

LOG_DARM_RATEMAX allows you to save SD card space by recording at a lower fidelity while sitting on the ground.

While you are flying, you need high-speed data (400Hz+) to analyze vibrations and PIDs. On the ground, you usually only need a slow update (e.g. 5Hz) to monitor GPS health or battery status.

  • 0: Use the normal backend rate limits.
  • 10: Force 10Hz logging while disarmed.

LOG_DISARMED

Default 0
Range 0 3

Enable logging while disarmed (LOG_DISARMED)

Description

LOG_DISARMED determines if the "Record" button stays active when the drone is disarmed.

Normally, ArduPilot only logs while you are flying to save SD card space. However, logging on the ground is vital for debugging GPS problems, sensor initialization, or pre-arm failures.

  • 0: Disabled (Default). Only log when armed.
  • 1: Enabled. Log constantly as long as the board has power.
  • 2: Disabled on USB. Log while on battery, but stop when plugged into a computer (to speed up parameter changes).
  • 3: Discard if never armed. Log while disarmed, but delete the file on reboot if the drone didn't actually take off.

Tuning & Behavior

  • Recommendation: Set to 1 if you are troubleshooting a "Pre-Arm: Needs 3D Fix" or other startup issue. Set to 0 for general use to keep your SD card clean.

LOG_FILE_BUFSIZE

kB
Default 200
Range 4 200

Logging File buffer size max (LOG_FILE_BUFSIZE)

Description

LOG_FILE_BUFSIZE helps prevent "Gaps" in your logs.

SD cards are sometimes slow to write. This parameter creates a "Waiting Area" (buffer) in the flight controller's RAM. Data is collected here and then written to the card in one big burst. A larger buffer can handle slower SD cards without losing data.

Tuning & Behavior

  • Default Value: 200 KB (on high-end boards like Cube Orange).
  • Recommendation: If you see "Log: GAP" messages in your log files, increase this value to its maximum (200).

LOG_FILE_DSRMROT

Default 0
Range 0 1

Stop logging to current file on disarm (LOG_FILE_DSRMROT)

Description

LOG_FILE_DSRMROT helps organize your flight logs.

  • 0 (Default): One log file per power cycle. If you land, disarm, and re-arm without unplugging the battery, everything is saved in one big file.
  • 1 (Rotate): Every flight (each Arm/Disarm cycle) gets its own individual .BIN file. This makes it much easier to find the specific flight you are looking for in a long day of testing.

Tuning & Behavior

  • Recommendation: Set to 1 for easier post-flight analysis.
  • Note: If LOG_DISARMED is enabled, setting this to 1 will immediately start a new log the moment you land.

LOG_FILE_MB_FREE

MB
Default 500
Range 10 1000

Min free MB on SD card (LOG_FILE_MB_FREE)

Description

LOG_FILE_MB_FREE is an "Auto-Cleanup" setting.

To prevent the SD card from becoming completely full (which causes write errors and potentially crashes), ArduPilot automatically deletes your oldest log files when the free space drops below this limit.

  • 500 (Default): Maintain at least 500MB of free space.

Tuning & Behavior

  • Recommendation: Set this to be larger than your largest typical flight log (e.g. if you fly 1-hour missions that generate 200MB logs, 500MB is a safe limit).

LOG_FILE_RATEMAX

Hz
Default 0
Range 0 1000

Maximum logging rate for file backend (LOG_FILE_RATEMAX)

Description

LOG_FILE_RATEMAX prevents your SD card from being overwhelmed by too much data.

High-speed logs (like raw IMU or fast attitude) can generate massive amounts of traffic. If your SD card is slow, the drone might experience "I/O Wait" stutters. This parameter sets a limit on the logging frequency.

  • 0 (Default): No limit. Record everything as fast as the system demands.
  • 100: Limit streaming messages to 100 Hz.

Tuning & Behavior

  • Recommendation: Leave at 0 unless you see "Log dropped" errors in your GCS or experience flight performance issues due to slow storage media.

LOG_FILE_TIMEOUT

s
Default 5
Range 1 60

Timeout before giving up on file writes (LOG_FILE_TIMEOUT)

Description

LOG_FILE_TIMEOUT detects failing SD cards.

If your SD card is slow or damaged, it might "hang" during a write operation. If it stays unresponsive for longer than this duration, ArduPilot declares the log as failed and stops recording to protect the main flight control CPU from waiting indefinitely.

Tuning & Behavior

  • Default Value: 5 seconds.
  • Safety: Do not set this too high. An unresponsive SD card can eventually cause "Internal Error 0x800" (Main Loop Slow) if the system spends too much time waiting for it.

LOG_MAV_BUFSIZE

kB
Default 8
Range 1 100

MAVLink Logging Buffer Size (LOG_MAV_BUFSIZE)

Description

This parameter sets the size of the memory buffer (in kilobytes) dedicated to "MAVLink Logging." Unlike standard logging which writes to an SD card, MAVLink logging streams the log data over your telemetry link (WiFi or Radio) directly to the Ground Control Station (GCS).

This is extremely useful for vehicles without SD cards (like some small racing drones) or for real-time analysis of flight data while the aircraft is still in the air. The buffer ensures that brief interruptions in the radio link don't cause gaps in the telemetry log.

The Mathematics

The system allocates a static block of RAM based on this value.

$$ \text{RAM}\_{MAV\_Log} = LOG\_MAV\_BUFSIZE \times 1024 \text{ bytes} $$

Because MAVLink logging is sent in small chunks, the internal code calculates how many "Blocks" can fit into this RAM:
$$ \text{BlockCount} = \frac{\text{RAM}\_{MAV\_Log}}{\text{sizeof}(\text{dm\_block})} $$
(where dm_block is typically 92 bytes).

The Engineer's View

In AP_Logger_MAVLink.cpp, this parameter determines the capacity of the outgoing message queue.

  • Bandwidth Sensitivity: MAVLink logging consumes significant telemetry bandwidth. Even with a large buffer, if your radio link is slow (e.g., a 915MHz SiK radio at 57600 baud), the buffer will fill up quickly and data will be dropped.
  • Recommendation: Only use this feature on high-speed links (WiFi, Ethernet, or high-speed SIYI/Herelink telemetry). On standard slow radios, this feature should typically be disabled or set to a very low rate.

Tuning & Behavior

  • Default Value: 8 kB.
  • Range: 1 to 100 kB.
  • When to Increase: If you are using real-time GCS logging over a fast link and notice "Data Missing" or "Gaps" in your live telemetry charts.
  • When to Decrease: If you are tight on RAM and not using the MAVLink logging feature.
  • Reboot Required: Yes. Memory allocation for the logging backend happens at startup.

LOG_MAV_RATEMAX

Hz
Default 0
Range 0 1000

Maximum logging rate for mavlink backend (LOG_MAV_RATEMAX)

Description

LOG_MAV_RATEMAX prevents live logging from choking your telemetry link.

Live MAVLink logging is very bandwidth intensive. If you are using a 915MHz SiK radio, you should set this to a very low value (e.g. 1Hz) or disable the MAVLink backend entirely. If you are using a high-speed WiFi link, you can set it higher.

Tuning & Behavior

  • Default Value: 0 (Unlimited).
  • Recommendation: Usually left at 0 because the MAVLink backend is disabled by default in LOG_BACKEND_TYPE.

LOG_MAX_FILES

Default 500
Range 2 500

Maximum number of log files (LOG_MAX_FILES)

Description

LOG_MAX_FILES limits the number of files in the /LOGS directory.

  • Default (500): ArduPilot keeps up to 500 flights.
  • Safety: This prevents directory fragmentation and slow boot times caused by having thousands of tiny files on the SD card.

LOG_RATE

Hz
Default 10
Range 1 100

External AHRS Logging Rate (LOG_RATE)

Description

This parameter controls the data recording frequency for "External AHRS" (Attitude and Heading Reference System) devices. When you use a specialized external sensor suite (like a VectorNav or a companion-computer based estimator) to provide attitude data to ArduPilot, this parameter determines how often that external data is saved to your SD card.

Setting an appropriate rate is important for post-flight analysis and digital twin simulations, ensuring you have enough resolution to see fast movements without bloating your log file size.

The Mathematics

The logging interval ($T\_{interval}$) is derived directly from the frequency:

$$ T\_{interval} = \frac{1000}{LOG\_RATE} \text{ milliseconds} $$

The system checks the time elapsed since the last log write ($t\_{now} - t\_{last}$) and only writes a new entry if the elapsed time is greater than or equal to $T\_{interval}$.

The Engineer's View

In AP_ExternalAHRS.cpp, this maps to the log_rate member.

  • Update Logic: Inside the AP_ExternalAHRS::update() function, the code enforces the timing constraint:
    if (log_rate.get() > 0 && now_ms - last_log_ms >= uint32_t(1000U/log_rate.get())) { ... }
  • Data Quality: Note that this logging rate is independent of the internal processing rate of the EKF. Even if you log at 10Hz, the autopilot may still be using the external data at a much higher frequency (e.g., 50Hz or 100Hz) for stabilization.

Tuning & Behavior

  • Default Value: 10 Hz.
  • Range: 1 to 100 Hz.
  • General Use: 10Hz is sufficient for general navigation and flight path review.
  • Acrobatics/Research: Increase to 50Hz if you are performing aggressive maneuvers and need to precisely compare the external AHRS performance against ArduPilot's internal EKF.
  • 0: Disables logging for the external AHRS device.

LOG_RAW

Option
Default 0
Range 0 1

Proximity Raw Logging Enable (LOG_RAW)

Description

This parameter enables the recording of raw, unfiltered distance data from Proximity sensors (like LiDAR or Ultrasound 360-degree scanners) to the autopilot's data log.

Proximity sensors are the "Eyes" of the drone's obstacle avoidance system. Normally, ArduPilot only logs the processed "Object Locations." Enabling LOG_RAW allows you to see every individual distance measurement the sensor reports, which is essential for diagnosing why an avoidance system might be failing, detecting "phantom" obstacles caused by sunlight or dust, and verifying the physical performance of your sensors.

The Mathematics

This is a binary boolean gate ($G\_{log}$):

$$ \text{IF } LOG\_RAW == 1 \rightarrow \text{Execute } Write\_Proximity\_Raw\_Message() $$

When enabled, the system generates high-frequency PRX log packets containing distance and angle pairs for every detection.

The Engineer's View

In AP_Proximity.cpp, this parameter maps to _raw_log_enable.

  • Logging Backend: When enabled, the AP_Proximity::update() loop triggers the message creation in the Log_Write() function.
  • SD Card Load: Warning: Raw proximity data can be very high-volume (hundreds of points per second). Enabling this will significantly increase the size of your .BIN log files and the load on your SD card.
  • Data Integrity: This logs the data before any of ArduPilot's internal filtering or "Persistence" checks are applied, providing a "Truth" view of the sensor output.

Tuning & Behavior

  • Default Value: 0 (Disabled).
  • When to Enable: Specifically during troubleshooting of Obstacle Avoidance or when integrating a new Proximity sensor model.
  • When to Disable: Standard flight operations. Keep disabled to save log space and reduce CPU overhead.
  • Dependencies: Requires PRX_TYPE to be non-zero and a healthy proximity sensor to be connected.

LOG_REPLAY

Default 0
Range 0 1

Enable logging of information needed for Replay (LOG_REPLAY)

Description

LOG_REPLAY is the "Diagnostic Mode" for your EKF.

If you are experiencing "EKF Compass Variance" or "EKF Lane Switch" errors and don't know why, you need to enable this. It records the raw sensor data and internal Kalman filter variables with high precision, allowing developers to "Replay" your actual flight through a simulator to find the bug.

Tuning & Behavior

  • Default Value: 0 (Disabled).
  • Warning: Enabling this generates much larger log files and increases CPU load. Use it only for troubleshooting, not for standard flying.
  • Prerequisite: Requires LOG_DISARMED to be set to 1 or 2 to capture the critical pre-flight calibration data.