logo

Encoder debounce

This always-on function tries to improve the performance of failing rotary encoders.

The rotary selection wheel (rotary encoder), like any mechanical switch, eventually fails. Many of the old TNRs that I am aware from forum posts seem to suffer from a problem in which the behavior of the encoder becomes erratic - either not responding or skipping several entries at once.

This post on modwiggler describes a hardware replacement approach.

The function described here is a firmware modification. If your encoder already works OK, you won’t see any change in behavior. Indeed, if your encoder is failing, these fixes might not make much of a difference, but since I don’t have a unit with a failing encoder (yet), it is difficult to test improvements.

Failure mode

The encoder has 2 output channels - A & B. These are realised internally with spring loaded contacts. This shows the internal operation

The signal output as the encoder is rotated is meant to have the A & B states inverting, but out of phase with each other.

Over time, the contacts can get dirty, leading to poor contact being made between the surfaces, leading to a noisy signal. This can appear to the software similar to the encoder being rotated very quickly.

Fix 1 in release A036

The TNR polls the encoder at 500Hz. The original firmware assumes that if A changes twice (i.e. 0->1->0) without an intervening change in B, this meant that the encoder had rotated +2 click positions. This is not properly enforced quadrature.

Revision A036 implemented proper state management so that a noisy A signal without a change in B could not lead to 2 position changes (and vice versa).

Fix 2 in release A037

Revision A037 implements a shift register based approach to filtering noisy A or B signals - now, in order for A to register as changed, it has to be consistent for 4 consecutive polls. This is effectively an 8ms timer that should help to reject noisy fluctuations happening quicker than this.

Compatibility Issues

None known.

Releases

Quadrature included in A036. 8ms timer included in A037.

Pika Blue avatar
About Pika Blue
Pika Blue is overly obsessed with midi controllers, especially unsupported ones with blinky lights .