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
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
One period spans two poles (2p = 2 mm). Electrical angle error Δθ converts to position error Δx.
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)
| Gap | Fundamental (vs surface) | 3rd harmonic | Electrical angle error | Position error |
|---|---|---|---|---|
| 0.1 mm | 73.0% | 17.8% | 0.179 rad | 56.9 μm |
| 0.2 mm | 53.3% | 9.5% | 0.095 rad | 30.2 μm |
| 0.5 mm | 20.8% | 1.4% | 0.014 rad | 4.6 μm |
| 1.0 mm | 4.3% | 0.06% | 0.0006 rad | 0.2 μm |
Example 2: errors from signal imperfections
| Cause | Position error | Error period |
|---|---|---|
| 1% offset | 3.2 μm | once per period |
| 1% amplitude mismatch | 1.6 μm | twice per period |
| Resolution with ×1000 interpolation | 2 μ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
- Solve the scale field including magnetisation pattern (pole transition width, depth profile).
- Get two field components at the sensor and convert to sin and cos signals.
- Vary gap, tilt and pitch error to see signal changes.
- Apply angle calculation and correction to get position error.
- Add external fields (motors, wiring) to check robustness.
“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
| Mistake | Effect | Fix |
|---|---|---|
| Treating resolution as accuracy | Accuracy overestimated | Build an error budget |
| Assuming sinusoidal field | Harmonic error missed | Solve from magnetisation pattern |
| Fixed gap | Sensitive to mounting | Sweep gap |
| Ignoring external fields | Location-dependent error | Shielding, differential layout |
| One-time calibration only | Error returns with temperature | Temperature-dependent correction |
I'd like to learn related topics.
Related pages include Hall-effect sensor, magnetoresistive sensor, eddy-current sensor, LVDT and fluxgate magnetometer.
Related Topics
Experience the theory firsthand with the interactive simulator for this field
All Simulators