I want to track the speed and the direction of rotation of a wheel.
I use a rotary optical encoder which outputs 2 signals on phase quadrature. (see the doc).
I have a lot of errors of the direction when the speed is high.
Here's my code to detect the clock-wise and anti-clockwise rotation: