Welcome to Cockpitbuilders.com. Please login or sign up.

August 04, 2021, 11:42:27 PM

Login with username, password and session length


Fly Elise-ng
17 Guests, 0 Users
  • Total Members: 4042
  • Latest: Doon1
  • Total Posts: 57342
  • Total Topics: 7630
  • Online Today: 35
  • Online Ever: 582
  • (January 22, 2020, 08:44:01 AM)
Users Online
Users: 0
Guests: 17
Total: 17



Will Depart in...



"New" switch design

Started by ame, July 01, 2021, 01:55:21 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


Hello everyone,

I may have stumbled upon a new design that should work well for rotary switches in cockpits. It may also be useful for a replacement for cockpit panel potentiometers. One advantage is that it is entirely digital. Using 5 switches, 30 positions in a rotation can be resolved.

It's not a new idea, but I haven't found any similar applications.

I was searching for rotary encoder stuff because although rotary encoders are easy to deal with they do require 'attentive' programming, either fast sampling, or interrupts. I wanted to bridge the gap between 'just a bunch of switches' and a rotary encoder being 'just two switches' that needed special handling.

I can't recall the serendipitous chain of events to this patent:

When I saw it I immediately thought of replacing the optical sensors with physical switches and making a compact rotary encoder. In a very literal sense, the encoder not only tells you if you have changed state (you have moved one 'click' in one or the other direction, but it also tells you *where you are*.

The PDF describes several combinations of sensors and slots, and I built the one in figure 4 with six subminiature roller-lever microswitches and a 3D-printed actuator with two 'lobes' 75 degrees wide, 75 degrees apart. It can resolve 24 unique positions over one rotation. This is adequate to replace a rotary encoder, which typically has 20 detents.

Since then I found this article:

This describes a sensor using five (optical) switches and can resolve 30 positions, which is clearly better, so I will build that next. That's a 12 degree resolution, again, a great replacement for a rotary encoder.

If you 'compress' the 360 degree range of a freely rotating switch to the 300 degree range of a potentiometer you can get 10 degrees per 'click', which might be sufficient for a flight-sim input. It's a bit granular, but may be sufficient for some controls (panel light brightness, for example).

The benefit of this design is that simple pushbutton inputs are all that is required. The higher-level software can look at the current position and previous position and detect which way the control is rotated, *and how far*. Usually sampling will be fast enough (on a human scale) that no intermediate positions will be lost, however, if the human turns the knob *really fast* or the computer is busy and misses something, it will catch up on the next read.

There are two other advantages. First, switch bounce is irrelevant. Because it's a Gray code only one bit changes state between switch positions. This means that switch bounce will only appear to move between two adjacent positions (until it settles) but never between two positions very far apart, which you would get with a naive binary code. Secondly, for the same reason, any time you look at the group of switches, if you "miss" the moment that the rotation happens between two states you will either get the position before, or the position after, which will be self-consistent because only one bit changes between positions.

Why do I think this is so cool? Well, connecting switches in a cockpit is easy. Connecting 5 switches is also easy. But, rotary encoders always seem to be hard. They really aren't, but anything that makes things easier is a bonus.

My prototype uses 6 switches, has a resolution of 24 positions (15 degrees) and is about 44mm in diameter. I can probably make it smaller, but there is often a lot of space behind switch panels.

Comments welcome, especially if you've seen this technique before!


Some pictures to convey more meaning. There is a circular plate which holds the microswitches in position evenly spaced around the edge. The rollers are concentrated towards the centre. Because it's symmetrical the plate can be printed twice and used for the top and bottom of the assembly. There are printed bosses to keep both sides apart, but they are unnecessary as the switch bodies do that. In the centre is the actuator with the lobes in the same shape as the light-blocking blades on the original (optical) encoder. The difference in radius between the inside and outside of the lobes is about 2.5mm, which is enough to reliably actuate the microswitches. The rollers on the switch levers allow the actuator to rotate freely and to track the edge of the lobes.

I have built this and it correctly reports 24 different Gray codes over one revolution. This would be satisfactory for a rotary encoder, but I'd like to make the 5-switch 30-position version next.

I am hoping this will work well with the HT16K33 keyboard matrix decoder which I have been working on. The HT16K33 can not sample a regular rotary encoder fast enough, and my attempts to get around this have as yet been unsuccessful.


Just a little more information. This guy has made a program that will find single track Gray codes (STGC) for various numbers of sensors. Note that for any given number of sensors, evenly spaced, there may be several solutions.


The Yoctopuce windvane has five sensors and uses the solution 3rd from bottom:

I think I will use the solution third from top:

The reason being (based on no scientific rigour whatsoever) is that it avoids having the shortest sections (xx or --) and therefore might be more tolerant of mechanical inaccuracies.

I'll build this next and see how it behaves. I'll also have to design some kind of detent mechanism.


Ok, the five switch version works, and gives me a resolution of 30 clicks (12 degrees) per revolution.

It's not super precise, due to the hysteresis in the switch on and off positions and where they change state. In fact, I had to file off a small part of the actuator because it wasn't allowing the switches to return to the rest position at certain points, which was due in part to the diameter of the roller on the switch arm.

There may be better solutions, and certainly an optical solution would be more precise and perhaps easier to assemble, however I need switches because of the hardware I want to interface to.

Attached is a render of the 3D model (which I printed and tested). It's still quite large, and probably it would work better if it were larger, then the relative sizes of the actuator and the roller diameter would have less of an effect.

Next I'll make a slightly more accurate pointer and dial and measure actuator angle vs reported switch position.

In case anyone is wondering, yes, you could hook this up to 5 pushbutton inputs on whatever interface you are using (PoKeys or some button board, for example) and get a rotary encoder with decent resolution for relative movements, or an accurate absolute position. This could take the place of a potentiometer (albeit with only 5 bits of resolution) or a multi-position selector switch (for example, a 12-position switch using only 5 inputs).


July 22, 2021, 02:29:20 PM #4 Last Edit: July 22, 2021, 02:38:14 PM by Doon1
To make it smaller you could use tactile switches. use 3 micro bearings on the wiper arm. Or better yet, a chamfered lead in on the faces of the wiper with a calcium sulfonate lube to prevent wear. The diameter of the entire switch could be cut by 50-70%. The tactile switches have a much tighter tolerance that those micro switches as well.
Here's a pic of my hat switch. It's 15mm square and has four 6x6x4.3mm tactile switches. I also have on that has a 5th switch in the bottom for a push button.


Quote from: Doon1 on July 22, 2021, 02:29:20 PMTo make it smaller you could use tactile switches. use 3 micro bearings on the wiper arm. Or better yet, a chamfered lead in on the faces of the wiper with a calcium sulfonate lube to prevent wear. The diameter of the entire switch could be cut by 50-70%. The tactile switches have a much tighter tolerance that those micro switches as well. 

Thanks. If you try any of those suggestions please let me know if they work.

Joe Lavery

Not sure if this has any bearing on your new design, but have you seen the Pulse Switch from Alpha, it seems to be similar to the function you are working on.
Of course you are the best judge of that.

Just thought it might be a solution.

Life isn't about waiting for the storm to pass, it's about learning to dance in the rain

Journalist - writer for  PC Pilot Magazine


Hi Joe,

Yes, I have seen those, thanks, and I have a bag of them to play with. They are actually very clever, and I thought they'd be a solution to my problem. Unfortunately, the switch closure, although very positive, is very short. Thus it is often missed if you are using a polling solution.

I'm hoping that the fact that the "new" switch design uses a Gray code it won't matter if I don't poll very often (and in fact I don't get to choose the polling period because it's set by the keyswitch matrix scanner I am using). Between positions only one bit changes, so the other bits don't. This means that I don't need to worry about capturing brief transitions, which is a problem with a conventional rotary encoder and the pulse switch. All I have to do is sample all the switches at the same time. Even if I sample the switches at different, but closely-spaced times, only one switch will be changing state as the actuator is rotated, and the others will remain the same. So, I will catch it before it changes, or after it changes. Either way, my result will be the current position or an immediately adjacent position.

I have a bit of work to do before I hook this up to my keyboard scanner, but the first step was to show it actually works. You'd expect it to, since it's just a bunch of switches, and it does.


Like the Website ?
Support Cockpitbuilders.com and Click Below to Donate