What an IMU Measures
An Inertial Measurement Unit is a cluster of tiny sensors that report how the probe is moving. Two are always present, and a third is optional:
- Gyroscope — measures how fast the probe is rotating about each axis. Add up (integrate) that rate over time and you get how far it has turned. This is accurate moment to moment, but a gyro always has a tiny constant error (bias); integrating that bias makes the orientation estimate slowly wander, and integrating noise adds a random drift on top.
- Accelerometer — measures acceleration. When the probe is still it feels only gravity, which points straight down — an absolute reference for tilt (roll and pitch). Crucially, gravity says nothing about which compass direction you face: you can spin the probe in place and gravity never changes, so the accelerometer carries no heading information.
- Magnetometer — measures the Earth’s magnetic field to give a compass heading. It is the only sensor here that can fix heading absolutely — but it is easily thrown off by nearby ferrous metal, vehicles, tools, and electronics.
How the Madgwick Filter Works
No single sensor is enough: the gyro is smooth but drifts, the accelerometer is stable but only sees tilt. A sensor-fusion filter combines their strengths. NDEVR uses the Madgwick filter, which keeps the orientation as a quaternion (a compact, gimbal-lock-free way to store a 3D rotation) and updates it many times a second from two streams:
- Predict from the gyro. Each tick, the filter rotates its current estimate by the measured spin rate — a smooth, responsive prediction that would, on its own, slowly drift.
- Correct toward gravity. The filter compares where it thinks “down” is to where the accelerometer says “down” is. Madgwick’s contribution is an efficient gradient-descent step: a cheap, analytic nudge of the orientation in the direction that most reduces that error — light enough to run hundreds of times a second on a small sensor chip.
- Blend with the gain β. The new estimate is the gyro prediction minus a β-weighted correction. β (beta) is the one big tuning knob: low β trusts the gyro (smooth, rides through motion, but slow to undo drift); high β trusts the accelerometer (snappy drift correction, but jittery and easily fooled by movement). NDEVR’s default is a deliberately conservative value (about 0.042), which favors a steady estimate over a twitchy one.
Why a gradient step instead of a Kalman filter
Madgwick replaced the heavy matrix math of a Kalman filter with a single analytic gradient step, so it runs fast and cheap at a high, steady update rate. That speed is part of its accuracy — which is also why irregular or low update rates, and motion that changes faster than the filter samples it, hurt the estimate.
Why Heading Drifts Without a Magnetometer
Here is the asymmetry at the heart of this whole topic. The accelerometer’s view of “down” pins roll and pitch: if the filter’s tilt is wrong, gravity reveals it and the correction pulls it back. But rotating about the vertical — changing heading — does not change where down is, so the accelerometer simply cannot see a heading error, and cannot correct one.
So without a magnetometer, heading is held by the gyroscope alone. Any leftover gyro bias integrates into a steadily growing heading error — a slow creep, often degrees per minute, that depends on the sensor and its temperature. NDEVR softens this two ways: a still warm-up that measures and subtracts the gyro bias before you begin (dramatically slowing the drift), and locking your starting heading as the zero reference, so heading is reported relative to where you started — dead-on at first, wandering gently from there.
So why run without a magnetometer at all? Because a compass is only as good as the magnetic field around it, and a probe often works in the worst possible places for one — beside rebar, pipes, vehicles, tools, or motors. There the field is distorted and a magnetometer can be off by tens of degrees, worse than a well-behaved gyro. NDEVR checks the field quality and warns when the magnetometer cannot be trusted (“move to a location with less magnetic interference”). In magnetically dirty environments, a drift-managed IMU is the more reliable choice — which is exactly why good handling technique matters.
Handling the Probe to Preserve Heading
Because heading depends entirely on the gyro and on a clean gravity reference, every good habit comes down to two ideas: start with the cleanest possible bias estimate, and never give the filter motion it cannot trust.
Start still
Hold the probe motionless on a stable surface through the warm-up — about five seconds on NDEVR hardware. This is when the gyro bias is measured and subtracted and your heading baseline is set. Move or rotate during the warm-up and you bake in a bad bias and a wrong starting heading that everything afterward is measured against. If the probe just came in from a cold vehicle, give it a moment to reach temperature first, since gyro bias shifts as the sensor warms.
Move slowly and smoothly — no sharp movements
This is the single most important field habit, and there are two distinct reasons for it:
- It protects the gravity reference. The accelerometer correction assumes the probe feels only gravity. A jerk, tap, or fast swing adds real linear acceleration on top of gravity, so the accelerometer no longer points straight down. The filter then corrects toward that wrong “down,” and the error bleeds into your orientation — including heading.
- It keeps the gyro honest. Fast rotations can outrun the gyro between samples — and can even saturate its range — so the integration that holds your heading loses a little accuracy with every quick flick. Smooth, deliberate motion keeps the accelerometer close to gravity and the gyro well sampled.
Avoid knocks, keep it mounted, finish promptly
- No knocks, taps, or vibration. Impacts are the extreme case of a sharp movement — a big, brief acceleration that can snap the estimate. Don’t set the probe down hard or let it rattle; mount it rigidly, damp vibration, and keep it away from running motors.
- Keep it reasonably level when you can. The tilt correction behaves best near level; extreme attitudes make small errors count for more.
- Work promptly. Heading drifts with time, not distance — the longer a run goes, the more it wanders. Complete a measurement efficiently rather than letting the probe idle mid-task.
- Re-reference for long jobs, and after any abuse. On long sessions, periodically re-establish heading — pause to re-zero against a known bearing, or against a GNSS-derived course. If the probe takes a knock or a fast swing, treat the heading as suspect and re-baseline (hold it still to recalibrate, or restart the warm-up).
Field Checklist
Before you scan
- Let it reach temperature
- Hold dead still for the warm-up (~5 s)
- Don’t move until the baseline is set
- Mount it rigidly, away from motors
While scanning
- Move slowly and smoothly
- No jerks, taps, or knocks
- Keep it roughly level
- Finish the run promptly
If heading looks off
- Pause and re-zero to a known bearing
- Restart the still warm-up
- Re-baseline after any impact
- Distrust a compass near metal
Handle the probe with these habits and an IMU-only setup will hold a faithful heading for the length of a normal measurement — no magnetometer required, and no surprises from the steel around you. For the bigger picture of how directions are defined and measured, see What is North?; for the positioning side of field work, see GNSS Best Practices.