Rotary Encoders

In a real plane cockpit not every rotary knob is an encoder. Often it's a mechanical knob geared with instrument card or needle (which itself can have absolute rotary sensors on the other side). Incremental rotary encoders are used mostly in radio equipment displays and autopilot.

Here are the examples of typical controls for which you can use encoders in your cockpit, including instrument card knobs:

For your home cockpit you can use any cheap mechanical rotary encoders that can be found on AliExpress or Ebay.

Do not hunt for some "special", "branded", expensive encoders, any cheap encoder ($0.3 ... $1 for a piece) works just fine with SimVimCockpit Interface.
There is absolutelly no difference in work between $0.5 encoder and $30 "brand" encoder in your home cockpit!

Depending on usage in your cockpit it can be just a single encoder or dual (coaxial) encoder, or encoder with built-in push-button, so that you can switch modes to control different parameters with a single encoder.

Video - Encoder Demo


How Encoders Work

Rotary encoder has two output terminals (A,B) and one "common" C. Each output is cyclically connecting to the "common" terminal when the shaft is rotated, and the encoder generates a shifted sequence of On/Off signals on its two outputs.


This code sequence can be processed by the controller (or hardware circuit) as direction and velocity. Commonly, in relation to the simulator, we need to get the moment of status change and its direction.

The number of phase changes in 360 degrees of rotation can vary for different encoders. For example, having 20 full phase cycles per rotation, or 20 PPR, the program can detect 80 state changes ( 80 combinations of "On" to "Off" states on A and B outputs).


encoder_wave Usually the encoder shaft has several fixed positions (switch effect) in full 360-deg range, that define the "touch-feel resolution" for you when you rotate the knob.

An encoder may have 8,12,16...20,24,32 detents, and a smaller detent number may give you more sensory control when entering parameters which need fine step-by-step change. On the other hand, large number of small steps (or even complete absence of detents) is mostly usable in consumer electronic as volume regulator, etc.

An encoder phase state in detent position is defined by encoder construction that may have one of the main 3 types, described below.

On the program side, within one physical "click" 1 to 4 phase changes may occur, depending on the detent type. The program should be able to detect all the phase changes between detents to determine the direction correctly, making only one step per detent to avoid excessive value change or step skipping.

Encoder types (signal/detent configuration)

Type 1 - full cycle per detent (very good for SimVim)

Encoder of this type has one full cycle per detent, it differs in that it is always in the same phase state at each detent and when encoder is rotated by one "step", its outputs phase changes 4 times between two fixed positions what allows the program to reliably detect an encoder direction and speed.

All detents are in 00 state - Both A and B outputs are in open state.

All detents are in 11 state - Both A and B outputs are in closed state.

All detents are in 10 state (or 01) - A and B outputs are in opposite state.

Type 2 - 1/2 cycle per detent (good for SimVim)

Encoder of this type has a half cycle per detent, when encoder is rotated by one "step", its outputs change 2 times between two fixed positions.


(detents 10,01) - A and B outputs have an opposite state in one fixed position and inverted state in the next position alternately

(detents 00,11) - Both outputs A and B have a closed state in one fixed position and an open state in the next position alternately

Type 3 - 1/4 cycle per detent ( good only for one-step )

Encoder with detent in each phase position (detents in 00,10,11,01), when encoder is rotated by one "step", its outputs change by one phase state and provide full resolution.

Encoders with 1/4 cycle per detent have full resolution. For example, if an encoder has full 9 cycles per revolution (9 PPR), it can generate 36 state changes, i.e. one per each detent. Some of these encoders may not have detents at all, but they don't have tactile feedback because of it.

Not usable for "accelerated" input, can be used only for one-step data entry.

Common pin location on different encoders:

KY-040 - Breakout boards with encoder

Often, looking for where to buy encoders you can find and buy some of breakout boards with encoder soldered in it, like this KY-040 board. It's useless, this board only increases the price for you.

If you have this board, and you are going to connect it as you have read somewhere about its connection, don't do that, it will not work! The marking (+Vcc, GND, SW, DT and CLK) on this encoder board has no practical meaning in relation to SimVim connections. All you need is "raw" encoder itself.

Just desolder the encoder and throw away the PCB, use encoder as we described. Or, you can make changes as on the picture below:

Note: All encoders we have (a lot of encoders of different types) are cheap and any of them can be perfectly used with SimVim, Here are some examples:

- LINK1 - $0.25 / piece, no button
- LINK2 - (about $0.5/pc, with button)

Encoders substitutes


As an option you can use a simplified way to emulate encoders - use two buttons or two-way switch - this will be working the same way as clicking areas of the screen in a virtual cockpit. I've made it for my transponder knobs, using two-way springed micro switches taken from old CD-ROMs.


Another way that could be useful for such instruments as Radio Altimete is using a potentiometer connected to analog input. It lets you properly emulate the real knob, when the arrow is rotating correspondingly with the rotating knob.

© Copyright 2012-2018 - SimVim