How an Inertial Measurement Unit Knows You’ve Moved – from Silicon to Software (≈ 500 words)
1. The Physical Core: MEMS Accelerometers & Gyroscopes
An IMU’s “ears” are micro-electro-mechanical systems (MEMS) etched into silicon wafers.
• Accelerometers exploit Newton’s 2nd law (F = m a). Each axis holds a tiny proof-mass suspended by flexures. When the device accelerates, the mass lags behind, bending the flexures and changing the distance between comb-shaped electrodes. That gap variation alters capacitance, which is measured with a charge-balancing circuit and converted to a voltage proportional to linear acceleration (m s⁻²).
• Gyroscopes rely on conservation of angular momentum. The most common MEMS design is a vibrating-mass (Coriolis) gyro: a micro-structure is driven to oscillate at its resonant frequency. When the substrate rotates, the Coriolis force (FC = 2 m v × ω) pushes the mass sideways, creating a secondary vibration orthogonal to the drive mode. Capacitive pick-off plates sense this minute motion; the amplitude is proportional to angular rate (rad s⁻¹).
• Magnetometers (optional) add a third sensing modality, measuring Earth’s field via the magneto-resistive or Hall effect to correct heading drift.
2. Interface Electronics: From Zeptofarads to Digits
The capacitive changes are tiny—femtofarads to zeptofarads—so on-chip charge amplifiers, demodulators, and ΣΔ (sigma-delta) A/D converters digitize the signals at 16–32 bit depth. Built-in temperature sensors feed real-time compensation tables because MEMS spring constants and bias voltages shift with °C.
3. Discrete Time: Sampling & Quantization
At, say, 1 kHz sample rate, the IMU delivers time-stamped vectors:
araw(t) = [ax, ay, az]ᵀ, ωraw(t) = [p, q, r]ᵀ.
Nyquist considerations dictate anti-alias filters (~250 Hz cut-off). Jitter is mitigated with crystal-controlled clocks (±10 ppm).
4. Calibration: Turning Raw Bits into Physics
Factory calibration establishes scale factors, axis mis-alignments, and bias offsets. Mathematically, the raw vector x is corrected via
xcal = S( M(xraw − b) ),
where S is the diagonal scale matrix, M is a 3×3 mis-alignment matrix, and b is the bias vector. In the field, slow-changing biases are tracked with techniques like Allan variance analysis or real-time adaptive filters.
5. Integration & the Drift Problem
To obtain velocity, orientation, or position, the IMU integrates its own outputs:
v(t) = ∫ [a(t) − g] dt, R(t) = ∫ Ω(ω) R dt.
Because small biases integrate into large errors (drift), raw double integration quickly diverges. Thus the computational magic lies in sensor fusion.
6. Sensor Fusion Algorithms
• Complementary Filter: A lightweight blend of high-frequency gyro data with low-frequency accelerometer/magnetometer cues.
• Extended Kalman Filter (EKF): Maintains a state vector (orientation quaternion, velocity, biases) and propagates uncertainties through linearized dynamics. When accelerometer norms approximate 1 g or magnetometer readings are stable, the EKF performs a correction step, gently pulling the estimate back to reality.
• Madgwick & Mahony: Gradient-descent and non-linear complementary filters that achieve near-Kalman accuracy on Cortex-M MCUs by directly minimizing the quaternion error.
7. Coordinate Frames & Representations
Orientation is expressed with quaternions to avoid gimbal lock and enable efficient multiplication:
q̇ = ½ q ⊗ [0, ω] .
Rotation matrices or Euler angles are generated only when needed for human interpretation.
8. Application Layer
High-level firmware packs data into SPI/I²C frames or streams it over BLE, sometimes with on-chip machine-learning cores (e.g., step detection). Developers subscribe to events (tap, free-fall) instead of raw vectors, offloading real-time math to the IMU itself.
Takeaway
An IMU is a marriage between the laws of classical mechanics and digital signal processing. Tiny vibrating masses capture the forces you feel; cascades of filters, calibrations, and quaternions turn those femtofarads into actionable insights—whether stabilizing a camera gimbal, steering a drone, or counting your daily steps.