Magnetic Encoder

Category: Electromagnetic Analysis – Sensors | Revised 2026-10-01
CAE visualization for magnetic encoder theory - technical simulation diagram
Magnetic Encoder

Theory: scale field and air gap

Overview

🙋

How does a magnetic encoder differ from an optical one?

🎓

The big difference is tolerance of dirt, oil and vibration. Optical encoders read glass gratings with light, achieving fine pitch and high accuracy, but oil or dust that blocks light stops them. Magnetic encoders read the field of a scale of alternating N and S poles with Hall or magnetoresistive elements, and the field passes through moderate contamination. In exchange the field weakens sharply with distance from the scale and its waveform distorts easily. Magnetic encoder design therefore considers pole pitch, sensor gap, field distortion (harmonics) and signal correction together to estimate achievable accuracy.

Field decay with gap

$$ B_n(z) \propto \frac{1}{n}\,e^{-n\pi z/p}\quad (n = 1, 3, 5, \dots),\qquad h_3(z) = \frac{1}{3}\,e^{-2\pi z/p} $$

p is pole pitch (1 mm) and z distance from the scale surface. For ideal abrupt N–S magnetisation the field contains odd harmonics, and higher orders decay faster. h₃ is the third harmonic relative to the fundamental.

Angle calculation and position error

$$ \hat\theta = \arctan\frac{V_{sin}}{V_{cos}},\qquad \Delta x = \frac{\Delta\theta}{2\pi}\cdot 2p $$

One period spans two poles (2p = 2 mm). Electrical angle error Δθ converts to position error Δx.

Coffee Break Trivia

Recording a voice on steel wire

A magnetic scale is, in effect, a position graduation recorded magnetically. The idea of magnetic recording goes back to Danish engineer Poulsen's 1898 device that recorded voice on steel wire. The technology that grew into tape and hard disks — writing fine, uniform poles and reading them from a distance — also underpins magnetic encoder scales and sensors.

Worked examples

Example 1: gap, signal, harmonic and position error (1 mm pole pitch)

GapFundamental (vs surface)3rd harmonicElectrical angle errorPosition error
0.1 mm73.0%17.8%0.179 rad56.9 μm
0.2 mm53.3%9.5%0.095 rad30.2 μm
0.5 mm20.8%1.4%0.014 rad4.6 μm
1.0 mm4.3%0.06%0.0006 rad0.2 μm

Example 2: errors from signal imperfections

CausePosition errorError period
1% offset3.2 μmonce per period
1% amplitude mismatch1.6 μmtwice per period
Resolution with ×1000 interpolation2 μm—
🙋

At 1.0 mm gap the error is only 0.2 µm. Isn't a bigger gap always better?

🎓

Looking only at harmonics, yes — but the signal falls to 4.3% of its surface value. Sensor noise and stray fields from nearby motors and wiring arrive regardless of signal size, so a smaller signal means relatively more noise and more position jitter. With a large gap, gap variation (mounting error, vibration) also changes signal size strongly; a 0.1 mm change at 0.5 mm gap alters signal about 27%, leaving amplitude mismatch that correction can't fully remove. In practice the gap is chosen where both harmonics and noise are small, and residual harmonics are corrected in signal processing. A larger pole pitch gives stronger signal at the same gap, but a longer period turns the same electrical error into a larger position error. That is why field analysis optimises scale magnetisation pattern, gap and sensor placement together.

Modelling workflow

  1. Solve the scale field including magnetisation pattern (pole transition width, depth profile).
  2. Get two field components at the sensor and convert to sin and cos signals.
  3. Vary gap, tilt and pitch error to see signal changes.
  4. Apply angle calculation and correction to get position error.
  5. Add external fields (motors, wiring) to check robustness.
Coffee Break Trivia

“An encoder that lost accuracy only near the motor”

On a linear stage, magnetic encoder error grew only in the section near the drive motor. Field analysis showed leakage from the motor magnets reaching the sensor and adding an offset to the signal. Because the offset varied with position, a single calibration couldn't remove it. Adding a thin magnetic shield around the sensor and switching to a differential sensor arrangement that cancels uniform external fields eliminated the section-dependent error.

Common mistakes

Mistakes and fixes

MistakeEffectFix
Treating resolution as accuracyAccuracy overestimatedBuild an error budget
Assuming sinusoidal fieldHarmonic error missedSolve from magnetisation pattern
Fixed gapSensitive to mountingSweep gap
Ignoring external fieldsLocation-dependent errorShielding, differential layout
One-time calibration onlyError returns with temperatureTemperature-dependent correction
🙋

I'd like to learn related topics.

Related Simulators

Experience the theory firsthand with the interactive simulator for this field

All Simulators

Related fields

Coupled AnalysisStructural AnalysisThermal Analysis
Rate this article
Thank you for your feedback!
Helpful
More details
Report error
Helpful
0
More details
0
Report error
0