Diagnosing Altitude Hold Failures in ArduPilot with BarAlt Logs
ArduPilotdronesaltitude holdtroubleshooting

Diagnosing Altitude Hold Failures in ArduPilot with BarAlt Logs

LogHat AIMarch 24, 20265 min read

Key Takeaway

Diagnosing ArduPilot altitude hold failures can be done by analyzing BarAlt logs.

TL;DR: ArduPilot altitude hold failures stem from barometer drift, vibration, or PID misconfiguration. Check CTUN.BAlt vs CTUN.DAlt divergence and VIBE.VibeX/Y/Z — values above 30 m/s² indicate mechanical issues requiring physical fixes before PID tuning.

What Causes ArduPilot Altitude Hold Failures?

ArduPilot altitude hold failures manifest as oscillation, steady drift, or violent altitude hunting. The barometric altimeter drives altitude control in most flight modes, making CTUN.BAlt your first diagnostic target. When this sensor feeds corrupt data into the position controller, no amount of PID tuning will fix the symptom.

The altitude controller commands vertical velocity (PSC_VELZ_* parameters), which then outputs acceleration targets to the attitude controller. Failures occur when the barometer reading diverges from desired altitude (CTUN.DAlt), triggering aggressive corrections. Three root causes dominate: vibration-induced pressure fluctuations, thermal drift from poor enclosure design, and misconfigured velocity controller gains.

This guide shows you how to read altitude telemetry correctly, identify the failure mode from log signatures, and apply targeted fixes.

How to Read Altitude Data in ArduPilot Logs

CTUN (Control Tune) messages contain the altitude control loop's key inputs and outputs. CTUN.BAlt is raw barometric altitude in meters. CTUN.DAlt is the desired altitude commanded by the flight mode. The difference between these two values drives the vertical position error.

Critically, CTUN.Alt is not the EKF-fused altitude estimate. It is simply the current altitude reference the controller is using — typically barometric altitude unless you've changed EK3_SRC1_POSZ. The actual EKF fusion output lives in XKF1 or XKFD messages under the PD (Position Down) field, reported as negative meters in NED frame.

To diagnose altitude hold problems in Mission Planner, load your .bin file and graph CTUN.BAlt, CTUN.DAlt, and CTUN.Alt together. Steady divergence between barometric and desired altitude indicates drift. Oscillation around the setpoint with a period under 2 seconds suggests overly aggressive velocity or acceleration gains.

Key Takeaway: CTUN.BAlt is your barometer input, CTUN.DAlt is your target altitude. The EKF-fused position down is in XKF1.PD, not CTUN.Alt.

How Does Vibration Affect Barometric Altitude?

Vibrations generate transient pressure spikes inside the flight controller enclosure. The MS5611 and similar MEMS barometers interpret these as rapid altitude changes — often reading 5–15 meter altitude swings when the aircraft hasn't moved. Check VIBE.VibeX, VIBE.VibeY, and VIBE.VibeZ in your log. Values consistently above 30 m/s² correlate with unreliable barometric altitude.

If vibration levels exceed 60 m/s², the risk of severe EKF failure increases. At this level, the EKF may not function correctly, leading to erratic behavior and potential loss of control. Immediate action is required to resolve mechanical issues to ensure safe operation.

Foam-damped flight controller mounts reduce high-frequency transmission but don't address prop wash turbulence around the barometer vent hole. A poorly vented enclosure experiences dynamic pressure variations during maneuvers — forward flight can create measurable pressure differentials that the barometer interprets as altitude change. Ensure your case has a dedicated vent hole covered with breathable foam, positioned away from prop wash.

If vibration levels exceed 30 m/s², fix the mechanical problem before touching PID parameters. Balance propellers, check motor mounts for play, and verify frame rigidity. No software tuning compensates for a mechanically unsound airframe.

Key Takeaway: Vibration above 30 m/s² corrupts barometric readings. Mechanical fixes must precede PID adjustments.

What Are the PID Parameters That Control Vertical Position?

The altitude controller is a cascaded loop. The outer position controller (PSC_POSZ_P) converts altitude error into a velocity target. The velocity controller (PSC_VELZ_P, PSC_ACCZ_I, PSC_ACCZ_D) converts velocity error into acceleration commands. The attitude controller translates acceleration into motor throttle adjustments.

High PSC_VELZ_P causes rapid throttle corrections, creating oscillation around the setpoint. Insufficient PSC_ACCZ_I allows steady-state errors — the aircraft hovers 2 meters low and never corrects. Start by reducing PSC_VELZ_P by 20% if you see sub-2-second oscillations. If the aircraft drifts slowly downward despite correct altitude readings, increase PSC_ACCZ_I by 50%.

ArduPilot's Autotune mode adjusts attitude controller PIDs (roll, pitch, yaw rate) but does not tune position or velocity parameters. Some users employ experimental System Identification tools or manual methods documented on forums, but no official Autotune exists for PSC_VELZ or PSC_ACCZ parameters. You must tune these manually based on observed behavior in logs.

Key Takeaway: PSC_VELZ_P controls velocity response speed, PSC_ACCZ_I eliminates steady-state altitude error. Autotune does not adjust these parameters.

When Does EKF Source Selection Matter?

EK3_SRC1_POSZ determines which sensor the EKF uses for vertical position. The default value of 1 selects barometric altitude. Setting it to 2 uses GPS altitude, which drifts vertically by 5–10 meters in typical civilian GPS receivers. Setting it to 3 enables rangefinder fusion if you have a downward-facing lidar or sonar.

If your barometer is fundamentally unreliable due to environmental exposure (e.g., racing quad with no enclosure), switching to GPS altitude prevents wild altitude swings but sacrifices precision. GPS altitude has slower update rates and higher noise than a properly installed barometer. Rangefinder fusion provides centimeter-level precision below 10 meters but requires a clear downward view and fails over water or vegetation.

Check EK3_SRC1_POSZ in your parameter file if altitude hold behaves differently between flight locations. A mismatch between your intended altitude source and the configured parameter explains mysterious site-specific failures. For detailed EKF configuration guidance, see the LogHat docs section on multi-sensor fusion.

Key Takeaway: EK3_SRC1_POSZ selects baro (1), GPS (2), or rangefinder (3) as vertical position source. Baro is best when properly shielded; GPS trades precision for vibration immunity.

What Is the Physical Barometer Installation Checklist?

Foam over the barometer vent hole filters prop wash pressure pulses but must allow air exchange for altitude changes. Use open-cell acoustic foam, not closed-cell weather sealing. The vent should face downward or sideways — never directly into the prop wash. Check that the barometer is securely mounted to minimize vibration transmission.

Ensure that the barometer is not exposed to excessive heat or cold, which can cause thermal drift and pressure inaccuracies. This is especially critical in environments with rapid temperature changes. A well-ventilated enclosure can help mitigate these effects.

Lastly, periodically inspect the barometer and surrounding components for signs of damage or wear. Regular maintenance can prevent altitude hold issues and ensure reliable performance during flights.

FAQ

What should I do if my altitude hold is oscillating?

Check the VIBE values and ensure they are below 30 m/s². If they are high, address the mechanical issues first. After that, adjust the PSC_VELZ_P parameter to reduce oscillation.

How do I know if my barometer is working correctly?

Compare CTUN.BAlt and CTUN.DAlt. If there is a steady divergence, your barometer may be drifting. Ensure proper installation and check for any potential sources of interference.

Can I use GPS altitude instead of barometric altitude?

Yes, but be aware that GPS altitude may have slower update rates and higher noise levels. It's recommended to use EK3_SRC1_POSZ to switch to GPS only if the barometer is unreliable.

Tagged

ArduPilotdronesaltitude holdtroubleshooting

Try LogHat

Analyze your flight logs in seconds

Upload a .bin, .tlog, .log, or .ulg file. Get AI crash analysis, 3D replay, and forensic PDF reports instantly.

Try LogHat Free