Rotary Encoders

Incremental rotary encoders are used in the simulator interface as rotary knob controls to simulate instruments knobs mechanically geared with dials/needles, or for radio and autopilot data setting knobs, etc.

For your home cockpit you can use any cheap mechanical rotary encoders that can be found on AliExpress or Ebay. Don't look for some "special", "branded", expensive encoders., any cheap encoder ($0.3 ... $1 for a piece) works 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 a single encoder, dual (coaxial) encoder, or encoder with built-in push-button to switch it's modes.


Connection

The connection is simple - to work with SimVimCockpit all encoders should be connected to Arduino pins or multiplexer inputs directly, without using any pull-up/pull-down resistors. The encoder always should occupy two adjacent inputs, and the common "C" terminal of each encoder connected to the common GND bus.

NOTE: you need to know the positioning of the common ("C") terminal in each encoder, because it can be either in the middle or not for different encoders. Read more technical details about encoder types below on this page.

If the encoder has a built-in push-button switch you can use it as any other "standalone" button for any simulator command, not linked with encoder itself, or as push function for encoder mode switching, to control more than one parameter with a single encoder.

Configuration

Assigning the encoders in the configurator is easy and intuitive process - simply find needed parameter in the the appropriate category map, click the parameter and select the first of two inputs (N) for it - either direct pin or multiplexer input (multiplexer should be assigned before this!). You will see the assigned input in the configuration table and the next input (N+1) with the "^" sign.

An encoder type and its acceleration or single-step options can be configured in the plugin input settings menu (see below under the encoder types description). The configurator is only used to assign a parameter to the encoder.


How Encoders Work, detent types

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.

b58img

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 state 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).


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.

Encoder types by detents position

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.

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

Encoder of this type has one full cycle per detent (4 phase changes), 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.

encoder_wave encoder_wave encoder_wave
1) All detents are in 00 state - Both A and B outputs are in the same open state.
2) All detents are in 11 state - Both A and B outputs are in the same closed state.
3) All detents are in 10 state (or 01) - A and B outputs are in opposite states.

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.

encoder_wave encoder_wave

1) - detents 10, 01- A and B outputs have an opposite state in one fixed position and inverted state in the next position alternately
2) - 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 mode )

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.

encoder_wave
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 quite usable for "accelerated" input, can be used for one-step data entry.



Setting the correct encoder type in the plugin

You can use the plugin menu to set the correct type and other options for any specific encoder, testing how it works right away. After connection with the board is established, open the "Input Options" menu in the plugin and rotate the connected (and configured!) encoder.

Options for this encoder will appear. Select the correct encoder type and click "Save/Reconnect". The selected type and acceleration will now be saved in the plugin for this encoder (based on the board pin number).

    Selectable options:
  • 1) encoder type (based on the description from this page), 1,2,3 and type"4" that applies to the use of a pair of buttons instead of encoder - just assign the input as an encoder, but connect two buttons to theinputs and then set its type button pair in the menu
  • 2) Acceleration - either none (useful for all radio frequency knobs) or one o 3 levels/speed options.
  • 3) If you have connected (soldered) your encoder in opposite order, you can use the "inversion" option.




Common ("C") pin location on some encoders, examples


Notes about breakout boards with encoder

Often you can find and buy some sort of breakout board with encoder soldered in it, but it only increases the price for you. If you have bought such board, and you are going to connect it as you have read somewhere about its connection, don't do that, don't connect it to 5V! 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 only 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 I have (a lot of encoders of different types) are cheap and any of them can be perfectly used with SimVimCockpit firmware, Here are some examples:

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

Encoders substitutes

3-position springed switch (ON)-OFF-(ON)

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.






SimVimCockpit 2012 - 202X