Magnetic Calibration
Magnetic calibration compensates hard-iron and soft-iron distortions that move rigidly with the module, and is required for accurate 9-axis absolute heading. Skip this chapter if you use 6-axis mode or a model without a magnetometer.
Scope & When to Calibrate
- 9-axis mode is suitable only outdoors in open space, away from rebar, motors, and high-current cables, with the module rigidly mounted and calibrated. Indoors or near motors, the field varies over space and time and cannot be calibrated out — use 6-axis mode instead.
- Calibrate once after final mechanical installation. Recalibrate if you remount the module, change nearby ferromagnetic parts, or see heading errors after a firmware upgrade.
- When mounted on a PCB, metal enclosure, tripod, drone, or vehicle, rotate the entire assembly during calibration. Calibrating a loose module and reinstalling it invalidates the result.
Calibration Steps
CHCenter's Magnetic Calibration window handles steps 3–4 interactively; for Modbus registers, see Magnetic Calibration via Modbus. Using ASCII commands:
- Switch to 9-axis mode: send
CONFIG ATT MODE 1→SAVECONFIG→REBOOT, then confirmPROFILE=1inLOG USRCONFIG(orMAIN_STATUS.MAG_AIDING=1). Follow Configuration Order to clear and redo zeroing (saveRST 0until after heading verification). - Choose a clean site: preferably outdoors (> 5 m from buildings and vehicles), away from magnets, motors, steel fixtures, power cables, metal desks, and rebar.
- Start calibration and rotate:text
CONFIG MCAL START (3D: drones, handhelds, and vehicles that pitch/roll widely) CONFIG MCAL START 2D (2D: cars, AGVs, and turntables moving mostly level; uppercase 2D)- 3D motion: stay in place and rotate smoothly at ~20–100 deg/s for at least 1–2 full turns around each of X, Y, and Z without dwelling in one pose.
- 2D motion: keep level and rotate steadily around the vertical axis for more than one full turn.
- Do not resend
STARTwhile running; if progress stalls, keep rotating through uncovered angles.
- Poll status periodically with
LOG MCAL STAT:text→ LOG MCAL STAT ← STAT=3 ← PROGRESS=100 ← OKSTAT=0idle;1running (PROGRESSis 0–99);3succeeded (applied and saved automatically, noSAVECONFIGneeded);4failed.- Wait for
STAT=3rather than a fixed timeout. A single heading jump on completion is normal alignment.
- Verify heading closure: place the module level, record the initial yaw, rotate slowly through 360° back to the start, and confirm smooth motion (±180° wrap is normal) with closure error ≤ 5°. Power-cycle once and recheck to confirm persistence. Closure checks consistency only; for absolute heading, confirm the nose points near 0° when aimed at magnetic north.
Right after power-up in 9-axis mode, MAIN_STATUS.MAG_DIST may stay 1 briefly. Rotate the module in a clean environment until MAG_DIST clears before trusting yaw.
Calibration Failure & Troubleshooting
If STAT=4 occurs or 360° closure exceeds 5°, check the total magnetic field magnitude mag_b in μT, viewable in HI91 or CHCenter) in order:
| Step | Check | Normal Range | Action If Out of Range |
|---|---|---|---|
| 1 | Stationary | 20–65 μT | <20 μT (shielded) or >65 μT (near magnet): move to a clean site and retry |
| 2 | Rotation coverage | 3D: ≥ 360° per axis; 2D: ≥ 360° level | Cover missing orientations, or switch to 2D if vehicle cannot tilt widely |
| 3 | Spread of | Max − min ≤ 10 μT | >10 μT indicates spatial gradient or motor currents: move away or use 6-axis mode |
| 4 | Rigid mounting & fixed spot | Pure rotation, no translation or flex | Secure the assembly and recalibrate on the spot |
