1
\$\begingroup\$

I'm trying to connect a model B rev 2 Raspberry Pi to a whole bunch of stuff to create a MIDI foot controller:

  • Adafruit touch screen
  • 20 switches (some foot, some encoder buttons)
  • 8 x SPI LED drivers (TLC5925 chips in 4 groups of 2)
  • MIDI in / out ports
  • 6 quadrature encoders (Each: 2 IO for rotation, 1 IO for button)

The screen just clicks onto the Pi without hassle.. it's already working but it eats quite a number of pins. The current pin-out of the Pi is as follows:

P1:
    01: +3.3V power
    02: +5V power
    03: SDA i2c1: SCREEN
    04: +5V power
    05: SCL i2c1: SCREEN
    06: GND
    07: --free--
    08: UART transmit: MIDI
    09: GND
    10: UART receive: MIDI
    11: --free--
    12: --free--
    13: --free-- (GPIO 23)
    14: GND
    15: --free-- (GPIO 22)
    16: --free-- (GPIO 23)
    17: +3.3v power
    18: GPIO: SCREEN
    19: SPI MOSI: SCREEN
    20: GND
    21: SPI MISO: SCREEN
    22: GPIO: SCREEN
    23: SPI SCLK: SCREEN
    24: SPI SC0: SCREEN?
    25: GND
    26: SPI SC1: SCREEN?

P5:
    01: +5V
    02: +3.3V
    03: i2c0 SDA: LED ring driver (GPIO 28)
    04: i2c0 SCL: LED ring driver (GPIO 29)
    05: --free-- (GPIO 30)
    06: --free-- (GPIO 31)
    07: GND
    08: GND

I already have a lot of code and experience with all of these components individually. But I'm overwhelmed with the quantity of input and output required to make this work.

There is currently 10 free GPIO pins. 2 of which could be used for hardware I2C.

By my estimate I need these GPIO pins:

Inputs:
    12: Encoders x 6 @ 2 channels each
    6: Encoder buttons
    14: Foot switches

Outputs:
    3: common SPI lines
    4: SPI select lines

Or 32 inputs, 7 outputs.

Anyway. I'm assuming there isn't some nice way of addressing all those SPI devices in hardware and I'll probably have to bit bash them in software. I don't like the idea of chaining them all together into one long SPI device (although it's physically possible) because of the chance for errors to propagate down the chain and also the time taken to update all those bits just to change the state of one LED. I much prefer shorter chains where I can address things quickly. Also if there is a hardware fault in one chain it doesn't effect all the others.

Is there a break out board that I can drive via I2C maybe?

Other ideas?

\$\endgroup\$
2
  • \$\begingroup\$ I wonder if 3-4 of these would do the trick? \$\endgroup\$
    – fret
    Aug 5, 2015 at 7:35
  • \$\begingroup\$ Apparently you can use GPIO with the hardware SPI lines. The question would be whether the RPi screen driver can co-operate with manually handled chip selection. Maybe the source could be copied out and modified to my purpose? \$\endgroup\$
    – fret
    Aug 7, 2015 at 5:53

1 Answer 1

0
\$\begingroup\$

This project actually did get finished. The solution that I used was a number of chips connected to the Pi via I2C.

  • 1 x SC18IS602B (I2C to SPI bridge) connected to:
    • 3 x LED rings using TLC5925 SPI LED drivers (although it wasn't straight forward).
  • 2 x MCP23017 (I2C GPIO expanders) connected to:
    • 14 x hardware buttons (14 pins)
    • 6 x encoder quadrature pins (12 pins)
    • 6 x encoder buttons (6 pins)
  • 1 x ads1115 (I2C analog to digital convertor)
  • RPi PWM output connected to:
    • a 3.3v->5v level convertor and then
    • a string of 14 neopixels.
  • RPi UART TX/RX pins connected to:
    • a 3.3v->5v level convertor and then
    • for MIDI output: a 4011 4xNAND gate buffer
    • for MIDI input: a 6N138 optical decoupler

There is an ongoing log of progress on my blog here.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.