To be able to effectively use cheap - mechanical - rotary encoders, some additional electronics is required. The function of these electronics is:
This circuit acts like two 'normally closed' switches. This is no problem when used in combination with FSbus, but for other purposes 'normally open' switches may be preferred.
To my opinion the circuit can be simplified and improved. In the following chapters some alternatives will be presented.
Reasons to modify the original circuit are:
The figure below shows the modified logic diagram:
Since only half of a 4066 is used per rotary encoder and normally several rotary encoders will be used in a cockpit, it seems obvious to build circuits for pairs of rotary encoders. The wiring diagram below gives an example for 2 rotary encoders. When more than 2 rotary encoders are used, multiples of this circuit could be placed on a single print.
With the application of a microcontroller the debouncing characteristics of the circuit can be improved and at the same time the number of electronic components can be reduced, especially when 4 or more rotary encoders are used. The price of the components of such a circuit might be slightly higher, but the reduction of required (PCB-)space and number of components might be worth more!
It wouldn't be cost effective to use a relatively expensive
microcontroller for a single or two rotary encoders.
Since in most situations with Flight Simulator cockpits at least 4, and not
uncommonly more that 12 rotary encoders are used, a cost effective circuit
has been designed for 4 encoders, based on a MicroChip PIC.
The functional logic is all done in software.
The major functions are explained in the following sections.
Mechanical switches have contact bouncing.
This may result in false signals and a low-pass filter must be used to
remove the effects.
The direction of rotation is determined by the sequence of opening and
closing of (debounced) contacts 'a' and 'b' of the rotary encoder.
When 'a' closes and 'b' is open at that time the rotary is turning
clockwise.
When 'a' closes and 'b' is closed at that time the rotary is turning
counter-clockwise.
The duration of the output 'pulse' (the time an output switch is closed)
is as long as contact 'a' is closed.
This gives approximately a 50% duty cycle: the time 'a' is closed is about
the same time as it is open.
Of course this depends on the behaviour of the rotary encoder.
See its datasheet!
The time that a switch is closed depends on the rotational speed of the
rotary encoder.
When turning the rotary encoder really fast a step may be missed from time
to time, because a contact may not remain closed during 4 consecutive
samples.
This is not considered to be a problem!
The selection of a suitable microcontroller was based on price,
availablity and usable pins per chip.
MicroChip PICs are pretty popular, not expensive and exist in a considerable
variety.
The PIC 16F88 looked the most suitable: by using its internal oscillator 16
of the 18 pins can be used for digital input/output.
Four of these circuits will fit on a single strip-board (Vero-board) of
Eurocard-format, so in total 16 rotary encoders can be serviced with a
single print.
See the pictures below.
The required software for the MicroChip PIC is provided for free!
'Digital' debouncing of a contact is performed by sampling.
When the contact state does not change for a number of consecutive samples
the contact is supposed to have reached a stable state.
Actions are only taken on changes in the stable state.
An efficient method for 8 contacts (4 rotary encoders) is described by
Scott Dattalo.
This method is used here.
Rotary encoders have frequently 24 or more 'steps' (on/off cycles) per
full rotation.
The sample frequency must be high enough to avoid missing steps, but
on the other hand it must be not too high because then debouncing will not
work effectively.
In this case the contacts are sampled about 3000 times per second, and after
4 consecutive 'on' or 'off' states the contact state is considered stable.
Direction of Rotation
Pulse duration
Missing pulses
Circuit for 4 rotary encoders
This resulted in the following wiring diagram.
Although QUADRH4 was originally developed with a MicroChip PIC 16F88,
there are some pin-compatible PICs which may be used in stead.
Alternatives are 16F87, 16F818, 16F819, 16F628A and 16F648A.
The differences between these PICs are of minor influence on the software,
but each requires its own program.
Depending on the chosen PIC you must use the corresponding HEX file to
program it.
See the table below.
| type of MicroChip PIC | .hex file to be used |
|---|---|
| 16F88 | QUADRH4_88.HEX |
| 16F87 | QUADRH4_87.HEX |
| 16F818 | QUADRH4_818.HEX |
| 16F819 | QUADRH4_819.HEX |
| 16F628A | QUADRH4_628A.HEX |
| 16F648A | QUADRH4_648A.HEX |
The hex files can be found in a separate package: QUADRH_104.ZIP.
Some considerations when building a board yourself:
Some other considerations:
Although the circuits can be easily built on experiment/strip-board, with a specially designed PCB the assembly will be easier and even less space will be needed. The figure below shows (part of) a possible double sided Printed Circuit Board. Although the board is double sided, the component side contains very little copper. You might decide to make a single sided board and use discrete connections with wires for the upper (component) layer.
The Sprint Layout file "PCB_RVD_QUADRH_ENCODER.LAY" contains a 10x16 cm PCB with 4 of the designs of the figure above, thus providing support for 16 rotary encoders. The board is designed by Rob van Dijk with the Sprint_Layout program, a commercial but not very expensive program. The picture below shows the PCB with 4 quadrh4 encoders.
The layout file can be found in the package QUADRH_104.ZIP, in which there are also the hex files for PICs. When you want to make the board yourself you need to have a regular copy of the SPRINT-LAYOUT program. To simply view the board you can download a free viewer to display the PCB at the site of Abacom.
With the assembly of the PCB please note:
The PCB provides a 5-pins connector for In-Circuit Serial Programming
for programming of a PIC.
Only one of the 4 circuits has the programming connector, so if you want to
reprogram all the PICs, you'll have to shuffle 'm!
For this reason the use of IC-sockets is recommended!
Only High Voltage Programming (HVP) is possible in this case.
It requires a suitable PIC programmer, for example the
Wisp628 PIC programmer
and XWisp2 program.
The following sources of information may be useful:
| Date | Version | Description |
|---|---|---|
| 21 Aug 2005 | 1.0.0 | |
| 23 Aug 2005 | 1.0.1 | |
| 24 Aug 2005 | 1.0.2 | |
| 3 Sep 2005 | 1.0.3 | |
| 7 Sep 2005 | 1.0.4 |