
Detecting and Calibrating Compass Motor Interference in ArduPilot
Key Takeaway
Compass motor interference is current-induced magnetic bias from ESCs and power leads. ArduPilot's CompassMot calibration learns the model and stores coefficients in COMPASS_MOT_X/Y/Z (mGauss/A). COMPASS_MOTCT = 2 uses current (more accurate), = 1 uses throttle. Post-calibration vector magnitude < 60 mGauss is excellent; > 100 mGauss means physical separation is required.
TL;DR: Compass motor interference is current-induced magnetic bias from ESCs and power leads that distorts the magnetometer reading as a function of throttle. ArduPilot’s COMPASSMOT calibration learns the relationship and stores it in COMPASS_MOT_X/Y/Z (mGauss per amp at full throttle) so the EKF can subtract the expected interference. COMPASS_MOTCT selects whether the compensation tracks throttle (1) or current (2, more accurate). After calibration, XKF4.SM versus RCOU output should no longer correlate — if it still does, physical separation between compass and power leads is the next step.
What current does to a magnetometer
A current-carrying wire generates a magnetic field proportional to the current. The field falls off with distance, so a compass mounted close to high-current power leads or ESC outputs sees a bias that changes with throttle. For high-current rigs (heavy multirotors, large agricultural drones) the bias can be tens of mGauss — comparable to the Earth’s magnetic field itself.
The bias is repeatable for a given current draw, so the autopilot can model and subtract it. COMPASSMOT is the calibration that learns the model.
The parameters CompassMot writes
COMPASS_MOTCT— compensation type. 0 = disabled, 1 = throttle-based, 2 = current-based. Current-based is more accurate but requires a current sensor.COMPASS_MOT_X,COMPASS_MOT_Y,COMPASS_MOT_Z— bias coefficients in mGauss per amp at full throttle (current mode) or mGauss at full throttle (throttle mode), per axis. The autopilot multiplies by the current and adds to the raw compass reading.
For a healthy build, the magnitude of the COMPASS_MOT vector after calibration is below 60 mGauss; above 100 mGauss means physical separation between the compass and the power leads is needed before any calibration can help.
The CompassMot calibration procedure
- Remove propellers. The autopilot will spin motors during calibration. Props would cause real motion.
- Secure the drone to a heavy table or sandbag. Motors at high throttle without props still produce torque.
- Disable arming checks for the calibration only. The compass will read wildly during the run — if you don’t disable, the autopilot will refuse to enter the calibration mode.
- Connect to Mission Planner: Setup → Mandatory Hardware → Compass → CompassMot. Choose throttle-based or current-based at the dialog.
- Spool throttle slowly from minimum to maximum over 10 seconds and back. The autopilot samples compass reading against current/throttle at every point and fits a linear coefficient per axis.
- Confirm the saved coefficients. The dialog reports the magnitude. If it’s below 60 mGauss, you’re done. If it’s between 60 and 100, you have residual interference but the calibration will partially compensate. If it’s above 100, physical re-routing of wires or relocation of the compass is required.
- Re-enable arming checks. Forgetting this step is the most common post-calibration mistake.
Reading the result in the log
Plot XKF4.SM (the EKF’s magnetometer test ratio) versus RCOU.C1–C4 sum during a normal flight:
- Before calibration,
XKF4.SMrises during high-throttle segments. - After successful calibration,
XKF4.SMis uncorrelated with throttle — throughout the throttle envelope it stays near 0. - If
XKF4.SMstill tracks throttle after calibration, the calibration is insufficient and physical re-routing is required.
Confirming it in MAVExplorer
MAV> graph XKF4.SM
MAV> graph RCOU.C1 RCOU.C2 RCOU.C3 RCOU.C4
MAV> param show COMPASS_MOTCT COMPASS_MOT_X COMPASS_MOT_Y COMPASS_MOT_Z
The parameter values give you the calibration that was active at flight time. If the values are zero but throttle-correlated interference is visible in XKF4.SM, calibration never happened (or was reset).
Throttle versus current mode — which to use
COMPASS_MOTCT = 1 (throttle-based) is the older method. It assumes total current is proportional to total throttle, which is approximately true in hover but breaks down in aggressive flight. Use this only if you don’t have a current sensor.
COMPASS_MOTCT = 2 (current-based) is the better method when a current sensor is available. It compensates against actual measured current, which tracks reality more closely during transients. Almost every modern build has a current sensor in the power module — use current-based.
Per-motor compensation for difficult builds
On rigs where one motor’s power lead routing is particularly close to the compass, a global compensation model misses the asymmetry. ArduPilot supports per-motor compensation via the COMPASS_PMOT_* parameter family, calibrated similarly but with per-motor coefficients. This is advanced setup; the global model is sufficient for most builds.
When CompassMot isn’t enough
If after a successful calibration XKF4.SM still climbs with throttle, the cause is one of:
- Compass too close to power leads. The simplest fix is mechanical: a 50–100 mm mast separating the compass from the main power harness usually solves this.
- External compass not selected as primary. Check
COMPASS_PRIMARY— an internal compass mounted directly above the FC almost always picks up FC-generated interference. Move to an external GPS+compass module on a mast. - Heavy current-carrying loop near the compass. Twisted-pair power wiring radiates much less than parallel runs. Re-route the main +/− pair to be tightly twisted.
- Soft-iron or hard-iron contamination of the airframe. Steel hardware near the compass can magnetise. Use brass or stainless fasteners within 50 mm of the compass.
When this isn’t actually motor interference
- Stale compass calibration. Compass offsets stored in
COMPASS_OFS_X/Y/Zare independent of the motor compensation. A wrong offset produces variance that doesn’t correlate with throttle — that’s a calibration problem, not interference. See our compass variance post. - External magnetic structures. Flying over rebar, power lines, or vehicles produces position-correlated variance, not throttle-correlated variance.
- Failing magnetometer chip. Random spikes uncorrelated with anything point at hardware degradation.
When LogHat helps — and when it doesn’t
LogHat overlays XKF4.SM against summed RCOU output and reports the correlation coefficient — high correlation means motor interference is still significant after whatever calibration was active. The parameter snapshot shows the COMPASS_MOT_X/Y/Z values in force at takeoff. What we can’t do is run the calibration for you — that’s a bench-top process with the airframe physically secured.
About the author
LogHat Engineering Team
The LogHat engineering team — drone-systems engineers who build and operate the LogHat flight analytics platform. Posts in this byline are written and reviewed by team members working on the parsers, analysis engine, and Vector AI that the post describes.
Tagged
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