Rotary Encoders need Caps?

TonyAme

Well-known member
Hello,

I am using some rotary encoders with the Teensy 4.0 and Audio Board. Should I use caps with the encoders? (In my schem. I haven't wired the 3 encoders on the left).

Thanks for any advice. Appreciated.
TonyAm
 

Attachments

  • TeensyBoard.png
    TeensyBoard.png
    87.8 KB · Views: 79
Are the switches remote or close to the Teensy? If close the internal pullups will be enough, else add external pullups. Capacitors wouldn't help I don't think.
 
Are the switches remote or close to the Teensy? If close the internal pullups will be enough, else add external pullups. Capacitors wouldn't help I don't think.
I'm only using the Rotary part of the encoder (without the push button switch) for 3 of them. The one connected in the schem does use the push button switch. The other 3 are remote (on a separate pcb). Thank you.
 
I've personally never had to worry about bounce on the T4 when using the hardware decoders, they have built-in filtering.
 
If encoder is "mechanical", a small R-C filter helps remove the possible oscillations due to bouncing contacts.
The classic implementation is a pull-up on the contact side, followed by a R-C.
A good explanation I just found: https://www.dream-dimensions.de/2015/10/using-rotary-encoders/
You forget that a slow moving signal to a logic input may make dozens or hundreds of transitions anyway due to the high gain of an input buffer - the simplest way to handle the bouncing is poll the signals at a sensible rate like 1kHz - then high speed noise is ignored. You can use RC filter and then a proper hysteresis input gate to clean it up again, but its overkill really.
 
You forget that a slow moving signal to a logic input may make dozens or hundreds of transitions anyway due to the high gain of an input buffer - the simplest way to handle the bouncing is poll the signals at a sensible rate like 1kHz - then high speed noise is ignored. You can use RC filter and then a proper hysteresis input gate to clean it up again, but its overkill really.
Also using an RC filter places the input voltage in the forbidden region for significant periods which can drain a lot of power on a low power CMOS system. Though the T4 isn't very low power of course.
 
If encoder is "mechanical", a small R-C filter helps remove the possible oscillations due to bouncing contacts.
The classic implementation is a pull-up on the contact side, followed by a R-C.
A good explanation I just found: https://www.dream-dimensions.de/2015/10/using-rotary-encoders/
Thank you. It is mechanical, so I will be trying 10k pullups and 0.1uF caps. Using the implementation described here: https://www.build-electronic-circuits.com/arduino-rotary-encoder/
 
There are 3 separate cases:
1. You do NOT need any caps, if you are using hardware quadrature encoder inside NXP i.MX RT1062, as hardware does de-glitching for you. (RT1062 manual chapter 56)

2. You also do NOT need any caps, if you are using software debouncing in your code (by essentially implementing the same technique as hardware glitch filter - sampling multiple times and waiting for inputs to stabilise before detecting the edge)

3. You can use caps to form RC filter on input, if and only if your inputs are Schmitt trigger inputs, so they have hysteresis. NXP i.MX RT1062 has ability to configure its inputs as Schmitt triggers via PAD registers and HYS bit (see the NXP i.MX RT1062 manual Chapter: 12.4.2 GPIO pad structure, 12.4.2.1.1 Schmitt trigger ) or you could use external part like 74HC14

Inside Teensyduino code, in digital.c (https://github.com/PaulStoffregen/c...d8f615497eca2ee49/teensy4/digital.c#L162-L188 ) HYS bit is NOT set for INPUT mode, it is only set for INPUT_PULLUP and INPUT_PULLDOWN.
 
Last edited:
There are 3 separate cases:
1. You do NOT need any caps, if you are using hardware quadrature encoder inside NXP i.MX RT1062, as hardware does de-glitching for you. (RT1062 manual chapter 56)

2. You also do NOT need any caps, if you are using software debouncing in your code (by essentially implementing the same technique as hardware glitch filter - sampling multiple times and waiting for inputs to stabilise before detecting the edge)

3. You can use caps to form RC filter on input, if and only if your inputs are Schmitt trigger inputs, so they have hysteresis. NXP i.MX RT1062 has ability to configure its inputs as Schmitt triggers via PAD registers and HYS bit (see the NXP i.MX RT1062 manual Chapter: 12.4.2 GPIO pad structure, 12.4.2.1.1 Schmitt trigger ) or you could use external part like 74HC14

Inside Teensyduino code, in digital.c (https://github.com/PaulStoffregen/c...d8f615497eca2ee49/teensy4/digital.c#L162-L188 ) HYS bit is NOT set for INPUT mode, it is only set for INPUT_PULLUP and INPUT_PULLDOWN.
Thank you for this info, I appreciate it very much.
 
3. You can use caps to form RC filter on input, if and only if your inputs are Schmitt trigger inputs, so they have hysteresis. NXP i.MX RT1062 has ability to configure its inputs as Schmitt triggers via PAD registers and HYS bit (see the NXP i.MX RT1062 manual Chapter: 12.4.2 GPIO pad structure, 12.4.2.1.1 Schmitt trigger ) or you could use external part like 74HC14
I'm using the Encoder library, would that automatically set the HYS bit? (Does the library put every encoder pin into INPUT_PULLUP, hysteresis included?)
Thank you.
 
Last edited:
Back
Top