Author Topic: Which rotary switch to use?  (Read 633 times)

0 Members and 1 Guest are viewing this topic.

Offline hertugweileTopic starter

  • Newbie
  • Posts: 6
  • Country: dk
Which rotary switch to use?
« on: October 18, 2024, 07:23:42 pm »
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?
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 13034
  • Country: ch
Re: Which rotary switch to use?
« Reply #1 on: October 18, 2024, 08:05:13 pm »
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.pdf

Focus on U2 and U3 in the schematic.
 
The following users thanked this post: shabaz, hertugweile

Offline shabaz

  • Frequent Contributor
  • **
  • Posts: 547
Re: Which rotary switch to use?
« Reply #2 on: October 18, 2024, 08:16:09 pm »
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.
 

Offline hertugweileTopic starter

  • Newbie
  • Posts: 6
  • Country: dk
Re: Which rotary switch to use?
« Reply #3 on: October 18, 2024, 08:30:23 pm »
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.
 

Offline RJSV

  • Super Contributor
  • ***
  • Posts: 2725
  • Country: us
Re: Which rotary switch to use?
« Reply #4 on: October 18, 2024, 08:56:13 pm »
   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 chA
      Outputs   A1, A2, A3, A4, A5, A6

   Input chB
      Outputs   B1, B2, B3, B4, B5, B6

It's a bit of a larger housing, but approx like a potentiometer.
 

Offline hertugweileTopic starter

  • Newbie
  • Posts: 6
  • Country: dk
Re: Which rotary switch to use?
« Reply #5 on: October 19, 2024, 03:54:36 am »
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.
 

Online MarkF

  • Super Contributor
  • ***
  • Posts: 2746
  • Country: us
Re: Which rotary switch to use?
« Reply #6 on: October 19, 2024, 04:20:14 am »
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.

Are 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.
« Last Edit: October 19, 2024, 04:25:45 am by MarkF »
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 13034
  • Country: ch
Re: Which rotary switch to use?
« Reply #7 on: October 19, 2024, 11:46:44 am »
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.
If 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.

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.

Are 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.
My 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.
 
The following users thanked this post: hertugweile

Offline hertugweileTopic starter

  • Newbie
  • Posts: 6
  • Country: dk
Re: Which rotary switch to use?
« Reply #8 on: October 19, 2024, 11:19:03 pm »
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.
 

Offline coppercone2

  • Super Contributor
  • ***
  • Posts: 11214
  • Country: us
  • $
Re: Which rotary switch to use?
« Reply #9 on: October 19, 2024, 11:21:47 pm »
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
 

Offline hertugweileTopic starter

  • Newbie
  • Posts: 6
  • Country: dk
Re: Which rotary switch to use?
« Reply #10 on: October 19, 2024, 11:32:52 pm »
Quote
If 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.

I 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.
 

Offline hertugweileTopic starter

  • Newbie
  • Posts: 6
  • Country: dk
Re: Which rotary switch to use?
« Reply #11 on: October 19, 2024, 11:41:34 pm »
Quote
two knife switches that cause the icon to move in their respective direction when you pump them.

I 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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf