Work in progress This site is under construction — content, figures and specifications are provisional.
4 — Calibration

Three independent
calibrations.

Each sensor is calibrated on its own — don't confuse them. The magnetometer keeps heading honest, the accelerometer keeps bank true, and a short gyro alignment removes drift at power-up.

Where it actsInjection points.

The three calibrations enter the signal chain at different points — the accelerometer fix is applied to the raw signal before the filters, the gyro alignment happens inside the filter, and the magnetometer fix feeds heading.

Fig.01 — Calibration injection pointssignal chain
ACCEL GYRO MAG 6-FACE CAL offset & scale ALIGN zero-rate bias MAG CAL hard & soft-iron ATTITUDE FILTER CF, Madgwick, ESKF gyro align here ATTITUDE
Accel correction is applied to the raw signal before the filter; the gyro is aligned inside it; the magnetometer fix feeds heading.
Magnetometer§1 — Heading.

Metal and avionics distort the local magnetic field in two ways. Hard-iron comes from permanently magnetised material — speakers, screws, magnets — and adds a fixed offset that shifts the whole field; it moves the centre c. Soft-iron comes from ferromagnetic material that bends and re-scales the field differently with heading; it stretches the sphere of readings into a tilted ellipsoid — the shape W. Calibration maps both and corrects them, so magnetic heading reads true in the installed environment — not just on the bench.

01

Rotate

Turn the unit through many orientations so it samples the field from all directions.

02

Fit

A 3D fit (or 2D when motion is limited) recovers the hard- and soft-iron correction.

03

Apply

The correction is stored and applied continuously to incoming data.

The fit. Hand-held, the raw samples trace an off-centre, squashed sphere. A full ellipsoid fit — linear least-squares (Merayo-style) on the quadric — recovers the hard-iron centre c and a soft-iron 3×3 shape W that maps the ellipsoid back to a sphere. In the aircraft, where you can't tumble the airframe, a 2D ellipse in the horizontal plane is fitted instead. A residual-RMS (root-mean-square) and an axis-ratio check reject a bad fit.

Fig.02 — 3D ellipsoid fitall orientations
RAW off-centre & tilted ellipsoid xyz c mcal = W (m − c) subtract c, reshape by W CALIBRATED centred sphere xyz ‖B‖
Swept through all orientations — by hand or on a non-magnetic calibration platform (a gimbal with no magnetic motors near the sensor) — the readings trace an off-centre, tilted ellipsoid. Hard-iron offsets the centre c; soft-iron tilts and stretches the shape W. The fit recovers both; applying m_{\text{cal}} = W\,(m - c) recentres and reshapes the cloud onto a sphere of radius \lVert B \rVert. The accelerometer uses the same idea (6-face fit), but its ellipsoid is axis-aligned (S diagonal — per-axis offset and scale, no tilt) onto a sphere of radius g.
Fig.03 — In-aircraft 2D fithorizontal plane
RAW off-centre & tilted ellipse xy c mcal = W (m − c) subtract c, reshape by W CALIBRATED centred circle xy ‖B‖
Installed in the aircraft you can't tumble the airframe, so the field is sampled in the horizontal plane only and a 2D ellipse is fitted — the same correction m_{\text{cal}} = W\,(m - c), reduced to the plane. A residual-RMS (root-mean-square) and an axis-ratio check reject a bad fit.
Correction (shared apply path with the accelerometer)
m_{\text{cal}} = W\,(m - c)

Re-run when the environment changes — a new mounting, added avionics or a different airframe all shift the field. Recalibrate to keep the map current.

Keyed by what actually affects it — the 3D calibrations (the accelerometer 6-face fit and the magnetometer sensor fit) characterise the sensor itself, so they are stored per IMU (by its address) and stay valid at any mounting. Only the in-aircraft 2D magnetometer fit depends on the install orientation, so it is stored per IMU and per mounting preset. Swap IMUs or change the mounting and the app loads the matching calibrations automatically — and a 3D calibration is never re-run just because the mounting changed.

Accelerometer§2 — The 6-face fit.

A small per-axis offset or scale error tilts the measured gravity vector and shows up as a bank error growing toward 45°. A classic six-point fit removes it. Hold the unit still on each of its six faces in turn:

+X

Face +X up

Hold steady until captured.

−X

Face −X up

Flip to the opposite face.

+Y

Face +Y up

Rotate to the next axis.

−Y

Face −Y up

Opposite face, hold still.

+Z

Face +Z up

Level, hold still.

−Z

Face −Z up

Inverted, hold still.

Each axis is bracketed by its + and − faces, giving a per-axis offset and scale — an axis-aligned ellipsoid mapped to a sphere of radius g, with no absolute-gravity assumption. The result is applied to the raw accelerometer before the filters, so every estimator benefits.

Per-axis offset & scale, then the shared correction
c_i = \tfrac{a_i^{+} + a_i^{-}}{2} \qquad s_i = \frac{2g}{a_i^{+} - a_i^{-}}
a_{\text{cal}} = S\,(a - c), \quad S = \operatorname{diag}(s_x,\, s_y,\, s_z)
Gyro offset§3 — Drift.

Every gyro has a small zero-rate bias that, uncorrected, would drift heading and attitude. A short static "Align" window at power-up — held still on the ground — measures and removes it automatically.

Whenat power-up, on the ground
Conditionaircraft held still
Windowa few seconds, automatic
Resultzero-rate bias removed