MAVLINKHUD

Overview

The SCHED parameter group configures the core Task Scheduler for ArduPilot. The scheduler is the heartbeat of the autopilot, responsible for prioritizing and running hundreds of distinct tasks (IMU sampling, PID loops, MAVLink, Logging) at precise intervals.

ArduPilot uses a cooperative multi-tasking model where each task is expected to run and return within a tiny time budget (e.g., 50 microseconds).

Key Concepts

1. Loop Rate (SCHED_LOOP_RATE)

Defines the main frequency (Hz) of the attitude control loop.

  • Multicopter: Usually 400Hz (2.5ms loop) or 800Hz.
  • Fixed Wing: Usually 50Hz (20ms loop) or 100Hz.
  • Importance: Higher rates provide lower latency for control but require more CPU power.

2. Scheduler Options (SCHED_OPTIONS)

A bitmask for advanced scheduler features.

  • Fast Loop: Toggles the dedicated high-priority rate thread on H7 processors.

3. Debugging (SCHED_DEBUG)

Allows developers to monitor "Slips" (when the scheduler runs late) or "Overruns" (when a task takes too long).

Parameter Breakdown

  • SCHED_LOOP_RATE: The primary control frequency.
  • SCHED_DEBUG: Verbosity of timing diagnostics.

Integration Guide

  • Warning: Do not change SCHED_LOOP_RATE unless instructed by hardware documentation. Setting it too high can overload the CPU, causing "Main Loop Slow" errors and potentially a crash.

Developer Notes

  • Library: libraries/AP_Scheduler.
  • Priority: The scheduler uses a fixed table of tasks with assigned priorities. INS (sensors) always run first.

SCHED_DEBUG

Default 0
Range 0 3

SCHED_DEBUG: Scheduler debug level

Description

Set to non-zero to enable scheduler debug messages.

Values

Value Meaning
0 Disabled
2 Show Slips (Delayed tasks)
3 Show Overruns (Long-running tasks)
  • Default: 0

Description

This parameter is a diagnostic tool for monitoring the real-time performance of the autopilot's operating system (the Scheduler).

  • Function: If the CPU becomes overloaded, the scheduler may have to delay certain tasks ("Slips") or a specific task may take longer than its allocated time budget ("Overruns").
  • Usage: Set to 2 or 3 during troubleshooting to see warning messages in the MAVLink console or Ground Control Station. These messages indicate that the flight controller is struggling to keep up with the workload.
  • Normal Operation: Should be left at 0 to avoid flooding the communication link with debug data.

SCHED_LOOP_RATE

Hz
Default 400
Range 50 400

Scheduling main loop rate (SCHED_LOOP_RATE)

Description

SCHED_LOOP_RATE defines the "Heartbeat" speed of the flight controller. It determines how many times per second the autopilot reads the sensors, runs the PID math, and updates the motor outputs.

  • 400Hz (Default for Copter): The drone updates its state every 2.5 milliseconds. This is required for stable, responsive multicopter flight.
  • 50Hz (Default for Plane/Rover): The vehicle updates its state every 20 milliseconds. Sufficient for slower-moving vehicles like cars or fixed-wing aircraft.

The Engineer's View

Defined in AP_Scheduler.cpp.
This parameter sets the base tick interval for the AP_Scheduler system. All other tasks (GPS reading, Battery monitoring, Logging) are scheduled as multiples of this rate.

Warning: Increasing this above 400Hz is considered experimental. It significantly increases CPU load and may cause "Scheduler Slips," where the drone becomes unstable because it cannot finish the math in time for the next loop.

Tuning & Behavior

  • Default Value: 400 (Copter), 50 (Plane/Rover).
  • Recommendation: Leave at 400 for all modern multicopters. Only reduce it if you are using extremely old hardware (like a Pixhawk 1) and experiencing high LOAD values (>80%).
  • Reboot Required: Yes. This changes the fundamental timing of the processor.

SCHED_OPTIONS

Default 0
Range 0 1

Scheduling options (SCHED_OPTIONS)

Description

SCHED_OPTIONS enables specialized performance tracking within the autopilot's operating system.

  • Bit 0 (1): Enable per-task perf info. If enabled, ArduPilot will track exactly how many microseconds every individual task (like "Baro Update" or "Compass Read") takes to complete. This is vital for developers or users experiencing unexplained twitches or CPU spikes.

The Engineer's View

When Bit 0 is set, the AP::PerfInfo module allocates extra memory to store timing statistics for every item in the scheduler task table. These statistics can be viewed in real-time by downloading the @SYS/tasks.txt file via MAVLink FTP.

Tuning & Behavior

  • Default Value: 0 (Disabled to save memory and CPU).
  • Recommendation: Leave at 0 for normal flight. Enable only if you are diagnosing "Internal Error 0x1000" or high system load.