DDC
  • Welcome
    • Introduction
    • Supported hardware
  • 1: Project planning
    • Switch inputs
      • Switch table
      • Direct
      • Shift register
      • Port expander
    • Analog inputs
      • External ADC
    • RGB LED
    • Digital outputs
    • PWM / Circuit control
    • EEPROM
    • Processing and memory
  • 2. Wiring
    • Switch inputs
      • Matrix
      • Direct
      • Shift register
      • Port expander
    • Analog
      • Analog switches
      • External ADC
    • RGB LED
    • Digital outputs
    • PWM / Circuit control
    • EEPROM
  • 3. Coding
    • Essentials
      • 02_Board.ino
      • 08_Joystick
      • 10_TableAndAnalog.ino
        • Switch table
        • Analog channels
      • 30_Switches.ino
    • Peripherals
      • RGB LED
        • Firmware control
          • LED functions
          • Color
          • Brightness
          • Presets
        • SimHub control
      • Digital outputs
        • Setup
        • SimHub control
        • Firmware control
      • PWM / Circuit control
        • Setup
        • Calibrate
        • Switch control
        • Trigger control
      • Shift register
      • I2C devices
        • ADS1115
        • PCA9555
        • CAT24C512
    • Advanced
      • Analog inject
      • Conditional coding
        • Triggers
        • Editors
      • Field placement
      • Presets
        • 31_RunningPresets.ino
        • 32_Presets.ino
        • Example
    • Upload
    • Naming the controller
  • 4. Connect to SimHub
    • LED control
    • Controller settings and properties
      • How to connect?
      • How does it work?
      • How to control it?
      • Property list
  • Switch library
    • Pushbutton
    • Function switches
    • Toggle switches
    • Hat switches
    • Car control functions
      • QuickSwitch
      • BrakeMagic
      • ThrottleHold
      • Handbrake
    • Pedals & paddles
      • Brake/throttle
      • Clutch
      • Bite point & launch
      • Filtered curves
      • Shifter
    • Funky switch
      • Directional
      • Center push
    • Encoders
      • rotary2Bit
      • rotary4Bit
      • funkyRotary
      • wildEncoder
      • E18
      • rotaryPulse
      • PEC11
    • Rotary switches
      • rotaryAnalog
      • quickRotary
      • SW1
      • Editing functions
    • Multiswitch complexes
      • Hybrid rotary
      • Multifunction rotary
      • Modded encoder
      • Stacked encoder
    • Preset
    • DDS
    • RGB LED control
    • PWM / Circuit control
    • Utility
  • Fast DDC
    • Buttons and LED
    • 4 encoders, buttons and LED
    • Dual clutches, 4 encoders, buttons and LED
    • Dual clutches, 6 encoders, button matrix and LED
  • CB1
    • Ordering
      • Order together
      • Order yourself
        • 1. Open in EasyEDA
        • 2. Export files
        • 3. Edit Pick&Place
        • 4. Pin headers and jumper
        • 5. Order from JLCPCB
    • Wiring
    • Code
      • Essentials
      • Complete project
      • Settings
    • Circuit
    • Shields
      • Robin
  • Collaboration
Powered by GitBook
On this page
  • Categories
  • rotary2Bit
  • funkyRotary
  • E18
  • wildEncoder
  • PEC11
  • rotaryPulse
  • rotary4Bit
  1. Switch library

Encoders

PreviousCenter pushNextrotary2Bit

Last updated 2 months ago

There are thousands of encoders out there. DDC supports most of them. So far in my tests I've identified and added support for 5 categories of encoders, that have different mechanical properties and thus need different algorithms to determine the direction of rotation. These categories should cover MOST encoders. You'll have to figure out which category your encoder belongs to, and use the switch functions for that encoder. If none of the categories work for you, contact me and we'll find a way to add support.

Common to almost all encoders is that the switch has 2 or more paths to a common.

You can measure the continuity between A->C and B->C and get the following outcomes:

As you rotate the switch, it will scroll through these states: 00, 10, 11, 01, 00, 10, 11, 01, 00, and so on. Rotating the other way and the order will be different: 00, 01, 11, 10, 00, etc. That way we can tell CW from CCW rotation.

Categories

rotary2Bit

These functions are for encoders that move one step on each detent. You can test the encoder and see that it moves through 00, 10, 11, 01 as you turn it.

Encoders:

  • CTS288

  • CTS 12CE/11CE

funkyRotary

These functions are for encoders that move 2 steps on each detent. They stop at 00 and 11. The 01 and 10 are in between the detents, and you'll need to wire up the encoder and use a serial monitor to find these states. Named after the funky switch, Alps RKJXT1F42001.

Encoders:

  • Alps RKJXT1F42001

  • Alps EC11

  • TT Electronics EN11 (20 pulse)

  • Bourns PEC11R

  • Elma E33

E18

Named after Elma E18, these functions are for encoders that move 2 steps on each detent, just like funkyRotary. Infact, the switch is mechanically very similar, but for the E18 in particular, the encoder is just way too bouncy to work with the funkyRotary algorithm. This algorithm is much stricter, and ensures 0 bouncing - but is also bit heavier on memory and processing power.

  • Elma E18 (16 detent)

wildEncoder

These functions are for encoders with an atypical signal output pattern, which is why I chose the name "wild". Depending on how you wired the A and B pins, it either never outputs 10 or never outputs 01. It will behave much like a funkyRotary or E18, which rests on a 11 or 00 output state, and going from 11 to 00 is via 10. However, going from 00 to 11 is a direct switch without ever outputting 01. This requires a completely different algorithm to make it work, and the switch is sensitive to swapping A and B pins. That is why the algorithm also has a software pin swap included.

  • Elma E18 (20 detent)

PEC11

These functions are for encoders that move 4 steps on each detent. They stop at 00. The 01, 11 and 10 are all in between the detents, and you'll need to wire up the encoder and use a serial monitor to find these states. Named after the first switch I tested that works like this: Bourns PEC11H.

Encoders:

  • Bourns PEC11H

  • TT Electronics EN11 (15 pulse)

  • Alps EC16

rotaryPulse

These functions are for encoders that mechanically works the way that the software usually tries to make an encoder work. Rotating CW will briefly close A->C and rotating CCW will briefly close B ->C. The switch is steady at 00 and can never be 11 since you can't turn it CW and CCW at the same time. It would actually work to code this switch as two pushbuttons. The switch very bounce-proof and only needs a lightweight algorithm to work.

Encoders:

  • Alps SRBM

rotary4Bit

These functions are for 4-bit encoders. The way they work are identical to the rotary2Bit encoders, but they have 4 paths to a common. So they will typically scroll through 0000 -> 0001 -> 0011 -> 0010 -> 0110 -> etc. In total 16 different configurations for 16 switch positions. These are absolute encoders, meaning each position of the switch has a different signal output, and the actual physical position of the switch can be determined by reading the signal.

All rotary4Bit() functions are for 16-position switches, but can be modified for 4-bit switches that have 8, 10 and 12 positions. With less than 16 positions, some of the 4-bit combinations are simply skipped. To go from 16 to 12 positions, the switch might skip 0100, 0010, 1110 and 0111, as an example.

The main advantage of these switches is that they are absolute, so you can label the switch on your controller. In addition, they generally have a heavier detent feel to them. The disadvantage is the space they take in the matrix; 4 blocks.

Encoders:

  • Bourns PAC18R

  • Grayhill 26 series

  • Panasonic EVQV9