A magnetometer calibration can center its readings while leaving orientation dependent error. Removing a three-axis offset does not generally correct unequal scaling and cross-axis distortion. Inspect the geometry of the measured field and choose a correction model that matches the observed problem.

Distinguish the two correction types

The ST LSM6DSM application note distinguishes hard iron correction from a soft iron transformation matrix. In geometric terms, an offset shifts the center of the measurement cloud, while directional scaling and coupling can change its shape.

Document the coordinate convention and units before fitting coefficients. A matrix written for row vectors or another axis order can produce plausible looking but incorrect results when applied differently in the host software.

Collect useful orientation coverage

Record raw magnetometer samples while rotating the complete assembly through varied orientations in a reasonably uniform magnetic environment. Keep the battery, enclosure, fasteners, and normal installed accessories present.

A flat rotation about one axis traces only a limited part of the three-dimensional response. It can support some planar checks but may leave out-of-plane parameters poorly determined. Inspect coverage before accepting the numerical output of a fitting routine.

Fit and inspect the residuals

Apply the selected offset and matrix correction to the recorded vectors and inspect their corrected magnitude and orientation behavior. Check whether a small set of outliers or a narrow orientation range is controlling the fit.

Use a separate validation record that was not used to estimate the coefficients. A model can fit its training motion well while failing at orientations that were poorly represented. Compare the result with an independent orientation reference where the application requires heading accuracy.

Check whether the environment remains valid

Repeat representative orientations with product operating states that change current or mechanical configuration. A fixed correction cannot automatically remove a field that changes when a motor starts, a magnetized accessory moves, or a high current load switches state.

Keep sensor saturation and range limits visible. Once a measurement clips, fitting coefficients cannot reconstruct the missing field information. If the raw data approach a limit, address the range or magnetic environment before attempting another fit.

Save raw and corrected records, orientation coverage, coefficient convention, validation results, and the installed configuration. Specify when recalibration is needed and how an invalid calibration is detected. A successful result improves independent measurements throughout the required orientation range. A centered circle from one flat rotation, or a low fitting residual alone, does not establish complete three-dimensional magnetic calibration of the finished assembly.

Move from reading to a build-ready project

Use the fabrication and assembly checklists to prepare drawings, production files and test requirements.

Open the DFM checklist