RobotGuide

Hardware & electrical · topic E4 · 25 hours

Sensors & encoders

A control system can only trust what it measures. Pick or mount a sensor wrong and every downstream algorithm is compensating for a mistake.

Core stage · Intermediate
Algorithm · Aware System software · Hands-on Embedded & controls · Proficient Mechanical · Hands-on

Tools
Tools

What to learn

  • Incremental vs absolute encoders, resolution vs accuracy, multi-turn memory
  • Hall sensors and sensorless schemes
  • IMU bias, temperature drift, axis-misalignment error
  • How mounting eccentricity, play, and coaxiality affect measurements
  • The calibration philosophy gap between tactile and proprioceptive sensors: proprioceptive quantities (angle, angular rate) have physics-defined equations, while tactile quantities (contact location, tangential force) must be inverted from material response — the calibration curve is itself the model (see C9)

The lesson · plain words

Encoders and IMUs are the robot's two proprioceptive eyes: the encoder knows how far a joint turned, the IMU knows how the body moves. Every selection and calibration trap is laid out on this page.

Incremental encoders: cheap, fast, and amnesiac

A/B square waves 90° apart: whoever leads sets the direction, count every edge (after 4× decoding, 1024 lines = 4096 counts per turn). Toggle the animation between forward and reverse and see what «direction sensing» looks like in the waveforms.

The fatal weakness: power off, the zero point is forgotten; power on, you must home (limit switch or Z pulse). Lost counts under vibration go undetected anywhere — lose one count and everything after it is wrong.

Interactive figure · drag it and see

What this figure shows: phase A and phase B square waves 90° apart, with a forward/reverse toggle — A leads B for forward, B leads A for reverse, and every edge is counted (4×), so 1024 lines per turn = 4096 counts. Takeaway: whoever leads sets the direction — the entire principle of incremental encoder sensing, and the price is a lost zero at power-off, which is exactly why absolute encoders exist.

Absolute encoders: why every joint uses them

Single-turn absolute (magnetic encoders like AS5048/MT6701, a few dozen dollars): angle known at power-up, no homing needed. Multi-turn absolute (tracks the turn count): the standard for robot arm joints — expensive but worth it.

Three selection questions: resolution (joints want 14 bits or more), interface (SPI/ABZ/analog), and magnet mounting tolerance (magnetic encoders are eccentricity-sensitive; keep it within 0.5mm). Joint space is tight, so the magnetic encoder is the default answer.

IMUs: doing the 6-axis/16-axis math

Six-axis = 3-axis accelerometer + 3-axis gyroscope; nine-axis adds a magnetometer (heading); sixteen-axis adds barometric pressure. The accelerometer tells you «which way you tilt» but is polluted by motion acceleration; the gyroscope tells you «how fast you turn» but drifts. Fusion (C5) is making them cover for each other.

Calibration matters more than selection: gyro bias (sit still 5 minutes, take the average), accelerometer bias and scale (the six-sides-static method). An uncalibrated IMU produces attitude that is permanently skewed after fusion.

Mounting and acceptance

Couple encoders against eccentricity (flexible coupling); mount the magnetic encoder chip 1–2mm from the magnet. Keep the IMU away from motors (magnetic interference) and vibration sources, and rigid-mount it — no foam padding (foam is a low-pass filter that kills the high-frequency information you want).

Acceptance: one encoder revolution must count exactly the rated value (4096); IMU drift over 10 minutes still must be under 1°. Fail either and everything downstream is wasted effort.

Three questions — do you really get it?

1. After 4× decoding, what is the count per revolution for a 1024-line incremental encoder?

  • A1024
  • B256
  • C4096
Show answer

C. A/B two phases × rising/falling edges = 4 edges per line. 1024×4=4096 counts.

2. Which encoder type is the first choice for robot joints?

  • AIncremental optical encoder
  • BPotentiometer
  • CAbsolute magnetic encoder (single- or multi-turn)
Show answer

C. No position lost at power-off, no homing, dirt-tolerant, compact. Incremental encoders are left for high-speed scenarios like spindles.

3. In IMU calibration, what does the «six-sides-static» method measure?

  • AGyroscope bias
  • BMagnetometer soft-iron error
  • CAccelerometer bias and scale factor
Show answer

C. Each face rests still, and gravity at ±1g along each direction gives the accelerometer six known inputs to solve bias and scale.

Keep going deeper

Links without a marker stay on this site; the rest point to the Chinese edition until its translation batch lands.

How it fails in the field

  • Treating encoder resolution as accuracy, while backlash and mounting error are the real bottleneck
  • Feeding an uncalibrated IMU straight into fusion: the attitude drifts slowly forever and the algorithm gets blamed

You have learned enough when

You can pick an encoder that meets an accuracy requirement and justify it, and run a real measurement of IMU bias and temperature drift.

The Chinese edition carries the full topic page for Sensors & encoders, including the complete outline, depth requirements per career track, and further derivations: robotguide.dev/k/E4/.