There's more IO needed than the BluePill can handle. The following user IO needs to be controlled :
- 11 LEDs
- 11 buttons
- 1 switch
- 1 rotary encoder
So we need an IO expander. The original setup used a MCP23017 to handle all of this. It turned out to be not such a good idea. See below.
Other options exist:
- Use 2 SX1509 boards
- 1x SX1509 for button inputs + 1x TLC59711 or TLC5940 for LEDs (expensive)
- GPIO for inputs ( 3 rows + 4 columns). 1 TLC59711 for LED output
16 channel SPI LED driver, non-dimmable : TLC5925 | STP16CPC26 | CAT4016 | MAX6969: 16 outputs, integrated current source, Digikey €1/pce. Advantage of using these is that charlieplexing is no longer needed.
- SX1509
- More than just an I²C IO-expander
- Keypad scan engine on Rows : IO0 - IO7, Columns : IO8 - IO15
- PWM dimming engine for GPIOs
- Sparkfun
- pin spacing : 0.6" x 10pin (2x12p DIP socket could be used : Digikey ED3051-5-ND)
- I²C connection could be made through 1x5pin socket strip
- power supply : 1V8, 3V3 (not 5V, but IO is 5V tolerant)
- LED driving capability
- 15mA sinking/pin
- 8mA sourcing/pin
- QFN package, so breakout board needed.
- I²C
- More than just an I²C IO-expander
MCP23017- basic I²C IO-expander, not much extra functionality
- AliExpress module : €0.76
- Used by Adafruit
- 25mA push/pull
- I²C
- 2 IRQ pins
- level triggered interrupts, edge triggered interrupts (no distinction between falling and rising edge interrupts)
- 16bit
- 3V3, 5V compatible
- available in SOIC28
- This device has no internal keypad scanning engine, unlike the SX1509. So you'll have to drive the rows & columns yourself when using a matrix keypad. This causes a lot of I²C interrupts and overhead for the MCU.
- The IO expander also controls the 15 LEDs in this setup using charlieplexing. A charlieplexing library for the MCP23017 has been developed, loosely based on the Chaplex library.
- Key scanning combined with charlie plexing the LEDs, causes flickering on the LEDs. Moreover the intensity of the LEDs can't be controlled.
MCP23S17- SPI version of the MCP23017
PCF8574- 8bit
PCF8575- 16bit
- asymmetrical output driver: 1mA source, 25mA sink
PCB Design
The I²C expansion board can control 8LED/switches. The LED/switch-PCBs have four LED/switches. If the I²C expander would be incorporated on the LED/switch PCB, effectively 50% of the I²C expander would be wasted.
All FFC connectors are the same to reduce BoM-cost and lead time. For the 3V3/I²C-connector, this means that some pins are not really used.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.