Ground Embedded KO Subscribe

Notes / Sensors & Signal Processing

Encoders and Hall sensors: measuring rotational position and speed

The A/B phases of an incremental encoder, finding BLDC position with three Hall sensors, timer encoder mode, and ways to calculate speed.

GROUND EMBEDDED · NOTESensors & Signal Processing 06Encoders and Hall sensorsMCUTempI2CIMUSPIHallGPIORangeUARTCurrentADC

Incremental encoder

Phase APhase B
Phases A and B are a quarter cycle apart. A rising first is forward; B rising first is reverse.

Two pulse trains, A and B, come out 90° apart. Which one rises first gives the direction, and the pulse count gives the position. Counting all four edges (×4) quadruples the resolution. The Z phase (index) comes once per revolution and marks the origin.

Timer encoder mode

Put an STM32 timer in encoder mode and CNT counts up and down automatically with the A/B signals. Position is counted with no CPU involvement.

Calculating speed

When fastcount pulses in a fixed timeWhen slowtime between pulses
Two ways to get speed.
Method Principle Suited to
M method Pulses counted in a fixed time High speed
T method Time of one pulse Low speed
M/T method A combination of the two The whole range

At low speed the M method sees 0 or 1 pulses per period, so the value jumps in steps.

3D labRun what you have read so far→

Hall sensors

The three Hall sensors inside a BLDC motor give six combinations (001 to 110) that change every 60 electrical degrees. They tell you roughly which sector the rotor is in, so they are used directly for six-step commutation. The resolution is too low for FOC, which interpolates between Hall signals or uses an encoder or a sensorless estimate.

Absolute encoder

It knows the absolute position the moment power comes on. Magnetic types (AS5600, AS5047) give the angle over SPI/I2C.

3D LABBLDC Six-Step CommutationRun what this note explains and watch it respond.Open the lab →FREE PDFGet the 3 free ebooksIf you want to keep reading this topic as one book: BLDC motor control, serial communication and sensors at book length. PDFs are in Korean.Get them free →