[sdiy] Selecting a rotary encoder, transistions per detent?

Brian Willoughby brianw at audiobanshee.com
Mon Feb 10 01:42:39 CET 2020


On Feb 9, 2020, at 2:32 AM, Spiros Makris <spirosmakris92 at gmail.com> wrote:
> Thank you Jay, I have look at that datasheet. Indeed what is shown is how my encoder behaves (rests at either 00 or 11when turned). My confusion stems from the fact that the bourns encoders also have the same waveforms in the datasheet even though they don't work in a similar fashion. 
> Is there any algorithm that can successfully read both types of encoders?

The same algorithm is used to read all types of quadrature encoders. The difference is whether you interpret 2 steps or 4 steps as one value. You basically never interpret a single transition by itself, although you could.

If done properly, you don’t even need to debounce the buttons. Contact bounce will simply alternate between two adjacent states, but if your code waits for 2 or 4 states before changing the output value then the bounce will not be apparent in the output value.

As a side note, the Oberheim Xpander and Matrix-12 used hardware to convert the raw quadrature data into a paired Interrupt and Direction for the processor. This hardware required 4 steps per detent so that it could generate a single interrupt for each detent, along with a direction bit that could be read during the interrupt to know whether to increment or decrement.


> I am looking for a smooth encoder with a very light touch. I'm guessing I need to look for no detents first. What about the "hardness"? I suspect that's specified by the torque, and I'm looking for the lowest one possible? 

The data sheets I’ve seen have multiple values. I suppose that’s because there’s still a torque needed to turn, even without detents. I would not rely on these to make your choice - it seems like you really want no detents, so just select a part number without detents.


My turn for a question to the list:

These data sheets mention the maximum time that the contacts might bounce. It seems like it should be possible to determine the rate that the contacts must be read (and potentially debounced) based on those times. However, what if someone turns the encoder so fast that one contact is still bouncing when the next contact transitions? Seems like the really cheap encoders with lots of contact bounce simply cannot be read reliably, no matter how fast the processor scans.

Any experience here?

I’ll also mention that some processors have Quadrature Encoder Interface peripherals that are supposed to be able to handle this behind the scenes, without the processor being involved. I’ve had some success with these. You program the peripheral with the minimum and maximum values that you want to track, along with settings for whether the value should wrap around or be clipped at the extremes. There are even digital filtering options to help with debounce. I’ve had this peripheral working in one rotation direction and not the other, so I wonder whether I had too cheap of an encoder, or just the wrong RC filtering. I stopped experimenting and just used a pure firmware algorithm that worked.

Has anybody used a dedicated Quadrature peripheral?

Brian





More information about the Synth-diy mailing list