Interfacing shaft encoders
Use interrupt on GPIO pin
- every interrupt, increment counter
Use timer to set period for counting
- when timer interrupts, read GPIO pin counter
- velocity = counter * distance per click / period
- reset counter
Pulse accumulator function
- common function
- some microcontrollers have this in a single peripheral device