D

DIY Electronics

— Building circuits, programming microcontrollers, and making things blink
49 members Created Jun 2026

Building a MIDI controller with an Arduino and Hairless MIDI

reddit.com/r/askscience/comments/xyz

Hall Sensor Position Encoder

For a brushless motor controller project I needed rotor position feedback. Hall effect sensors embedded in the motor stator provide six position states per electrical cycle, which is enough for trapezoidal commutation.

The three Hall sensors output a Gray-coded 3-bit value that cycles through six states per electrical revolution. The sequence 5, 4, 6, 2, 3, 1 (or its reverse) indicates direction. Decoding this in firmware: read all three GPIO pins atomically, look up the expected next state in a table, and increment or decrement a counter depending on whether the state matches forward or reverse sequence.

For a DIY BLDC controller driving a 14-pole motor, the electrical cycle repeats 7 times per mechanical revolution. An encoder counter that overflows and wraps is fine — just track direction and count.

1

Report thread

Why are you reporting this thread?

Restore the redacted content?

This will make it visible to everyone again. The clear action is logged in the mod log.