Denouncing rotary encoder to simulate push buttons - Page 1
Forum section: electronics / beginners

author: Mp3
author_rank: Frequent Contributor
timestamp: September 24, 2020, 04:00:56 am
content: I built a battery powered device into a small premade Hammond box.My plan was to have two buttons (momentary switches) One for the up direction and one for the down direction in order to scroll through a menu.Turns out I don’t have room to install them both, so I decided to see if I could use a rotary encoder instead.The PCB I’m controlling has solder pads for the up and down buttons and has a third solder pad for the battery negative which is to be used as a ground for the buttons.I have a ky040 type rotary encoder with the 5v breakout board. Unfortunately this type seems to be a “double step” type so it seems like some hacking will be needed so that I don’t need to turn it two clicks to simulate one button press.I have seen an example with resistors, a flip flop and NAND gates but this seems overly complex to me. Is there a simpler way to denounce the rotations? I don’t have the luxury of tons of space for additional circuitry, so if I can shove it in point to point wired or break off a very small piece of proto board it should work.

author: ledtester
author_rank: Super Contributor
timestamp: September 24, 2020, 04:23:09 am
content: Hmm... what do you mean by "double-step"? Are you using the rotary encoder in a conventional fashion -- i.e. rotate one way means "scroll up" and rotate the other way means "scroll down"?Do you have a microcontroller in your project? Debouncing is often done in software.If space is an issue perhaps consider using microswitches:

author: newbrain
author_rank: Super Contributor
timestamp: September 24, 2020, 07:42:24 am
content: From the descriptions I can find online it would seem that the encoder has half the pulses per revolution with respect to the number of detents, see the attached picture.This one of the two most common patterns for this kind of encoder.Some resistors and capacitors will be enough for an HW debounce, but the SW must take into account the characteristics of the encoder, and (as with any encoder) it's no direct replacement for a couple of buttons.If you cannot modify the SW, there no (simple) way to emulate two separate buttons.As you are using a breakout board, check the bottom to see whether some debouncing circuit is already included.If not, it's easy to use SMD components to build it directly across the encoder's terminals.Disclaimer: I don't know where the attached schematic comes from. It looks correct, though, with resistors to avoid short-circuiting the capacitors across encoder contacts.

author: Kjelt
author_rank: Super Contributor
timestamp: September 24, 2020, 08:32:18 am
content: Another option would be to use a momentary two way toggle switch that vears back to the central position.

author: MarkF
author_rank: Super Contributor
timestamp: September 24, 2020, 08:34:11 am
content: Quote from: Mp3 on September 24, 2020, 04:00:56 amIs the example you saw like this?Basically, just three chips.

author: Ian.M
author_rank: Super Contributor
timestamp: September 24, 2020, 08:55:39 am
content: Personally I'd program a PIC12 or ATtiny MCU with a software QEI state machine, handling the debouncing (assuming the encoder has more than one edge between detents) and outputting one up or down pulse per transition between detents, as a pair of faked open drain signals (rest state: Hi-Z input, active state: Output Low). You could cut a few tracks and wire a SOIC-8 package MCU + a 100nF decoupling cap, 'dead bug' on the back of the encoder breakout board and it would take negligible extra space, and output on the breakout's original header pins.

author: macboy
author_rank: Super Contributor
timestamp: September 24, 2020, 01:07:20 pm
content: You can buy "smart" rotary encoders with up and down (orCW/CCW) pulse outputs, one pulse per indent in the corresponding direction.