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
  1. 2. Wiring
  2. Switch inputs

Port expander

PreviousShift registerNextAnalog

Last updated 9 months ago

Wiring the PCA9555 is fairly straight forward. It has 24 pins. 8 of these are to make the chip work, and the remaining 16 are the input/output pins.

Power

  • First of all, this thing needs power and ground connection, as well as a 100 nF decoupling cap.

  • It can be powered with 2.3 - 5.5 V.

Communication

Next up is connecting it to a microcontroller:

  • The SDA and SCL pins on PCA9555 needs to go to the SDA and SCL pins on the microcontroller. These are not random pins. On many microcontrollers there are dedicated pins for SDA and SCL.

  • Lastly, the INT# pin, which is the interrupt. You can wire this to any digital pin on the microcontroller. Pin 4 is used in the example above. The PCA9555 is constantly checking if any inputs have changed. It if detects a change, the INT# pin will be grounded, and we can read a "0" on this line. The DDC software will only take in new input values from the port expander if there is a "0" here. So unless anything has changed, no processing power is used on reading the port expander.

  • When adding more port expanders, or even other I2C devices, wire them to the same SDA and SCL lines. No additional pullup resistors requred. Every PCA9555 will need its own interrupt pin though.

I2C address

Next up are the A0-A2 pins. These are not Analog pins, they are Address pins. In order for the microcontroller and the port expander to find eachother, the port expander needs a name. This is the I2C address. In a circuit design, devices on the same I2C lines need to have different addresses. There are 128 different addresses a I2C device can have, but they are hardware determined, and usually a I2C device will only give you the option to choose between a few addresses for your chip. I guess the manufacturer talk with eachother, because rarely will you have the issue that you can't have the devices you need for your design because the I2C addresses crash.

The 3 pins A0-A2 offer a way for you to change the address of the port expander. An I2C address is a 7-bit value. For the PCA9555 it is 0100XXX where XXX is A2, A1 and A0. Like this:

This figure is from the PCA9555 datasheet. It says the last 3 bits in the address are "programmable", but in practice it is hardware wired. If course, you could connect these pins to your microcontroller and adjust the address on the fly, but that doesnt make much sense.

The 3 pins, representing 3 bits in the address gives you 8 possible addresses, which means you can connect up to 8 PCA9555, a total of 128 inputs. We typically write these addresses in hexadecimal format; for the PCA9555 these are addreses 0x20 to 0x27, where 0x20 have all 3 pins grounded and 0x27 have all 3 pins connected to VCC.

In the example above, all 3 pins are grounded. The I2C address will be 0x20.

Input pins

On RP2040 you have a lot more freedom, and you also have two sets of SDA/SCL pins to chose from; I2C0 and I2C1. Have a look at a to see which pins can do what.

Both SCL and SDA pins needs to be with a 2.2K resistor. I recommend placing that resistor close to the microcontroller, not close to the port expander.

What we're left with are the 16 input pins. You wire switches to these as you would with or with . Common pins to ground and input pins directly to the port expander pins. The example below shows 3 encoders with pushbutton. Knowing that pins 1-8 and 9-16 are on seperate rows, and knowin the , we should keep encoder pins next to eachother and on the same row.

pico pinout
direct wiring
shift registers
pulled up
switch table rules