Debouncing - Rotary Encoder


Do I need to implement a hardware debouncing circuit for DT and CLK pins when connecting to mcu?
Btw, I'm using the below module with it's pins (DT, CLK & SW) are already pulled-up.


Normally no, as its a quadrature encoder and bounces just jitter back and forth one count.

Normally you'd arrange that the output is divided by 4 before using, as each detent is a full quadrature cycle.

If you still have issues with jitter at the detents you can use hysteresis to condition the raw encoder count.

1 Like

A 0.1uF between each of the encoder outputs and gnd will help also.

Tom.. :smiley: :+1: :coffee: :australia:

No, definitely don't do that, this will cause slow edges which are bad news unless you then fix them with Schmitt-trigger circuits.

1 Like

That's right, but the AVR uC on the basic Arduino has a built-in Schmitt-trigger on every GPIO and has hysteresis, so it may be a problem that is not so obvious in nowadays.

Take a look at the State Table encoder implementation:

The algorithm gives you debouncing for free. No external capacitors or software delays required.

Here's one implementation of that algorithm:

really? is 328p has this? in the datasheet?

Not sure what you mean by that.
In gfvalvo's library the debouncing is done in software and I can confirm that it is working really good. I'm using the same type of rotary-encoder like you have posted with great success in combination with the encoder-library "NewEncoder"

How should a hardware-datasheet cover billions of possible ways how to program = write software of a microcontroller?

best regards Stefan

Well if you check the datasheet for the particular chip you are using, yes you can feel reassured, but quadrature encoding is safe against bounce by its nature, and any low-pass filtering just limits the max speed before corruption of the quadrature relationship between the two signals.

If you have a raw optical encoder (analog outputs) then you do need Schmitt triggers to convert those outputs to logic signals anyway, but for mechanical switch encoders the output is already a logic signal. I suppose if the contacts are dirty/oxidized there might come a point they start to behave more like an analog signal, and Schmitt-triggers would be useful, but no caps are needed.

Yes. See the datasheets page85, figure14-2.

Yeah, I understand it well enough.
It's just a supplement to the existence of internal schmitt-trigger

1 Like