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


For every 360 degrees of rotation the number of full quadrature cycles determines resolution of the encoder. Having 20 full cycles per rotation, or 20 PPR, for example, the encoder generates 80 changes of state ( On to Off, and vice versa).

So, for this encoder, we can register 80 parameter changes per full turn using the appropriate code for that. But whether this full resolution (all state changes) could be used effectively or not, depends on how many mechanical detents this encoder has.

Detents and resolution

encoder_wave In detent position the encoder shaft is fixed between rotation steps (switch effect) and eventually this can limit the "fixed" resolution, because within one "click" 1 to 4 code changes may occur, depending on the number of detents per quadrature cycle - 1, 2 or 4 detents/cycle ( or 1/4, 1/2, 1 cycles or pulses per detent).

If you have an encoder with 1 cycle/detent (or 4 state changes per detent - see encoder type 1 below), and in the code each state change is processed with maximum resolution, we can discover that our controlled parameter increments/decrements for 4 units in one click (e.g. 4 degree course stepping)!

It may be acceptable for such parameters as lighting brightness but unusable for course adjustment. For this type of encoder we need to program it to reading states between detents, for determining direction, but take in account only one change per detent (i.e. the whole cycle). Say, using an encoder with 80 state changes resolution (or 80/4 = 20 PPR), and having 20 detents we can actually control HSI OBS by 20 deg/rev. (not 80).

Encoder types (signal/detent configuration)

Type 1 - full cycle per detent

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.

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

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

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 such encoders may not have detents at all but thus they don't have tactile feedback.

Common pin location on different encoders:

Breakout boards with ky-040 encoder

Often instead of single encoder people are buying some kind of breakout board with attached encoder on it, like this KY-040 board. Firstly, this board only increases the price, 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.

Any encoder itself always has 3 pins - A,B,C. In ArdSimX/SimVim each encoder occupies two adjacent inputs, with the common "C" terminal connected to the common GND bus.

If you have this board, just throw away the PCB on which this encoder is soldered and use encoder as needed. Or, 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