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
  • Shifts in the matrix
  • Pins
  1. 1: Project planning
  2. Switch inputs

Shift register

PreviousDirectNextPort expander

Last updated 1 year ago

The advantage of using shift registers is that you can use a silly amount of switches with only a few input pins on the microcontroller. DDC supports 8-bit parallel in/serial out shift registers, typically 74HC165/74HC166 or similar. These take 8 switch inputs each, and they can be cascaded, or "daisy chained" together. DDC can handle up to 4 chains, each chain having as many shift register chips as you want. Each chain needs 3 microcontroller pins, and a single chain can give you hundreds of inputs, far more efficient than matrix wiring. The wiring is also a lot more structured. Performance-wise the matrix wired switches will be read a little faster than the shift register wired switches, but not a difference that matters at all.

The downside of using shift registers is the extra hardware required, and that a PCB in some shape or form is a must.

Shifts in the matrix

DDC will dictate how SRs fit in the table, so it is more a matter of moving all the switches that aren't in the shift registers out of the way.

  • Adding shift registers to the project will automatically force column count to 8. You can add more columns, but you can't have less.

  • Shift registers will always start at column 1, where columns 1-8 represents inputs 1-8 on the shift register.

  • Shift registers will always start at row 1, and use as many rows as there are shift register ICs in your project.

    • If you have 1 chain of 4, that will be row 1-4. Row 1 being the first in the chain - the one that is wired to the microcontroller.

    • If you have 1 chain of 3, 1 chain of 2 and 1 chain of 4:

      • Shift register chain #1 -> row 1-3

      • Shift register chain #2 -> row 4-5

      • Shift register chain #3 -> row 6-9

  • In case of a mix of different types of wiring, the matrix wired switches and direct wired switches are placed below the shift registers. Direct wired switches can share columns and rows with shift registers.

In the example above, the matrix wired switches are on row 6-8 and columns 5-8, note that even if the planned matrix is 8 columns wide, the switches in the wired matrix doesn't have to be. You can still shape the matrix to use the least amount of pins. The open slots in the planned matrix are filled with 4 direct wired switches (red).

In theory, the direct wired switches could be placed in the unused matrix adresses for the shift registers (for instance row 5, columns 3 - 6), but it would just look messy and wont save you any processing power or memory.

Pins

As with switches, your switches in shift registers also needs to be in the switch table. So if you haven't already, read

Each chain of SRs will need three pins digital pins from the microcontroller. One for DATA, one for LATCH and one for CLOCK. More on this in the and chapters. Since you can make a chain as long as you want, three pins would be all you need. If you want to split up into several chains, only the DATA pin needs to be unique to each chain. LATCH and CLOCK pin can be shared by all SRs in your project. You can, however, use 3 unique pins for each chain if you want.

direct wired
this part.
wiring
coding
74HC166N