Which rotary switch to use? - Page 1
Forum section: electronics / beginners

author: hertugweile
author_rank: Newbie
timestamp: October 18, 2024, 07:23:42 pm
content: Hello all.I'm working on a PCB, where I need a dial in order to be able to highlight some icons on a screen.For this, I plan to use something similar to a rotary switch (SMT-type). If I turn it clockwise, an impulse is sent to a pin for each step. If I turn it counterclockwise, an impulse is sent to another pin for each step.I have looked at rotary encoders like this -https://www.digikey.co.uk/en/products/detail/bourns-inc/PEC11S-929K-N0015/3780162- but it outputs a permanent, 2-bit signal and I would like to avoid this.I don't know the name of a device with the behavior mentioned above. Anyone?

author: tooki
author_rank: Super Contributor
timestamp: October 18, 2024, 08:05:13 pm
content: You want something that mechanically outputs basically “up” pulses on one pin and “down” pulses on another? I don’t think such a beast exists.Why can’t you use a normal quadrature encoder (like the Bourns you linked)? They’re supported by tons of software libraries and some hardware too.If you need a software-free solution, you can make a quadrature decoder out of logic gates. This TI demo design does just that. This one decodes it to a direction signal and clock (which it then sends on to an I2C chip), but those could be easily converted to up/down pulses with a few more gates.https://www.ti.com/lit/ug/tiduaa8/tiduaa8.pdfFocus on U2 and U3 in the schematic.

author: shabaz
author_rank: Frequent Contributor
timestamp: October 18, 2024, 08:16:09 pm
content: I've rarely seen them, they were popular for a while in mobile phones (i.e. pre-smartphone age), where, presumably, it may have been easier to miniaturize a navigation control with the separated up and down signals, rather than a proper quadrature encoder.I think most normal-sized (e.g. 6 mm shaft, etc) encoders will be quadrature, so it's boxing oneself in for no good reason to try to find that niche part (if it still exists) that may behave differently.

author: hertugweile
author_rank: Newbie
timestamp: October 18, 2024, 08:30:23 pm
content: Hello Tooki and Shabaz.Thank you for your answers. I hoped to find a rotary switch, because I was concerned that the circuit would drain the battery if stuck in a position with permanent VCC on one of the input pins on the microprocessor (ESP32) when in sleep mode, which would be mitigated if the switch just supplied impulses. It might not be the case, but it was just to be sure.However, it would fit me perfect if I can use the Bourns, as there are quite an extensive amount of libraries, supporting various encoders.

author: RJSV
author_rank: Super Contributor
timestamp: October 18, 2024, 08:56:13 pm
content: If you want a regular (not surface mount)Six position rotary, I'll get you the part number, for the switches I've ordered.It has two decks, essentially it's TWO separate 2P6T or two-pole, six throw.That sounds like it could supply two different polarities, of output.That could be labeled as;Input chAOutputs A1, A2, A3, A4, A5, A6Input chBOutputs B1, B2, B3, B4, B5, B6It's a bit of a larger housing, but approx like a potentiometer.

author: hertugweile
author_rank: Newbie
timestamp: October 19, 2024, 03:54:36 am
content: Hello RJSV.Thank you for your reply, but just thought of something, regarding the rotary encoder.Instead of supplying it with VCC, I could just draw current from one of the ESP32's GPIOs. This way, I can just turn it on, whenever I need the user to be able to perform an action. When the processor goes to sleep, its GPIO goes to sleep with it without the risk of having the encoder drawing unneccesary power.

author: MarkF
author_rank: Super Contributor
timestamp: October 19, 2024, 04:20:14 am
content: Quote from: hertugweile on October 18, 2024, 07:23:42 pmAre you sure about that?I have used Bourns PEC11 encoders with detents. With pull-up resistors, they only pulse low while turning the shaft. When you stop, both outputs float high. (i.e. both switches on the outputs are open when the shaft is not turning.)Seems like what you're asking for.ACTUALLY, they were the PEC11R version. Don't know the difference between the 'R' version and the non-'R' version.

author: tooki
author_rank: Super Contributor
timestamp: October 19, 2024, 11:46:44 am
content: Quote from: hertugweile on October 18, 2024, 08:30:23 pmIf long battery life is your goal, then I would avoid the ESP32 entirely, if possible. Its true sleep modes lose the MCU state (waking from sleep essentially resets the MCU), so if the state matters, you have to first save the state to nonvolatile memory, then restore it on wake. I love the ESP32, but very low power is not its forte.Quote from: MarkF on October 19, 2024, 04:20:14 amMy understanding is that as long as the number of pulses per revolution is the same as or double the number of detents (e.g. 18 detents and 18 pulses, or 12 detents and 24 pulses), then yes, a detent always rests with both channels open. But in encoders with twice as many detents as pulses (e.g. 24 detents and 12 pulses), then some detents rest with a channel closed. Using these also demands that one decode both rising and falling edges, whereas the first type only requires decoding one or the other.In other words: make your life easy and get the kind where pulses are the same or double as the detents.Of course, if you use an encoder without detents, you never know where the wiper will stop, so you may end up with a channel closed.

author: hertugweile
author_rank: Newbie
timestamp: October 19, 2024, 11:19:03 pm
content: I'm not sure, but I looked at the datasheet, which has a diagram of the output. I'll buy some and test it out.

author: coppercone2
author_rank: Super Contributor
timestamp: October 19, 2024, 11:21:47 pm
content: two knife switches that cause the icon to move in their respective direction when you pump them.I have not seen a lever actuated GUI before

author: hertugweile
author_rank: Newbie
timestamp: October 19, 2024, 11:32:52 pm
content: QuoteI use an ESP32 with a 6" e-ink display, where it only updates once an hour. So far, my prototypes have been running for 4-5 months on a 2100 mAh LiPo - there might be more energy efficient solutions out there, but I find it quite adequate for my project and I'm really not experienced with other, comparable microcontrollers.I don't need to save the state, btw. The wheel is just for navigation, so it's perfectly fine that it highlights the first element, every time the menu is activated. At the moment, I use a 5-way joystick, but I can decrease the form factor by using a rotary dial instead on the side.

author: hertugweile
author_rank: Newbie
timestamp: October 19, 2024, 11:41:34 pm
content: QuoteI used something similar in my first prototype, but it became a tedious proces when navigating through the entire alphabet in order to have the user enter a Wi-Fi code. Then, I used a 5-way joystick, which works fine - but I would like to decrease the size of the unit, so with a rotary encoder and an enter-switch on the side, I can make it about 15-20% smaller.