Pip-Boy 2000 Mk.VI - Input Control Board

- 3 mins read

Hardware

The Pip-Boy 2000 Mk.VI input control board is based around an MCP23017 16-bit I/O expander, three momentary push switches and a rotary encoder with push switch. All on-board switches are connected to bank A of the expander and bank B is exposed as header pins for optional addition I/O.

The rotary encoder used a Bourns PEC11R Series 12 mm Incremental Encoder and the three momentary switches used for navigation are TE Connectivity Alcoswitch tactile switches.

Bill of Materials

PartPart NumberDatasheet
Rotary EncoderPEC11R-4325F-S0012Datasheet
Push Buttons1-1825027-7Datasheet

Schematics

All schematics, and KiCad files can be found in this Gitlab repo https://gitlab.com/robco-industries/pipboy-electronics.

Connectivity

The minimum required connectivity is to supply power (3.3V) via VIN and GND, and then I2C connectivity for operation via SCL and SDL. Interrupts are optional depending on your use case, all bank B GPIO’s are also optional.

PinUsage
GNDGround connection
SCLI2C serial clock
SDAI2C serial data
VINVoltage input, expects 3.3V
INT_ABank A GPIO interrupts
INT_BBank B GPIO interrupts
GPIO_B (0-7)Additional optional GPIO pins from bank B

I2C Addressing

The default I2C address is 0x20, if for any reason this needs to be changed, solder bridges are exposed on the back of the board and can be bridged to shift the address, eg. bridging +1 will shift the address to 0x21.

Software

For detailed descriptions of operating the MCP23017 it is worth consulting the manufacturers data sheets and documentation on their website https://www.microchip.com/en-us/product/mcp23017.

Device Registers

Functionality can be accessed at the following pins.

GPIOUsage
GPA0Rotary encoder push button.
GPA1STAT push button.
GPA2ITEM push button.
GPA3DATA push button
GPA4Rotary encoder pin A.
GPA5Rotary encoder pin B.
GPA6Not connected
GPA7Info LED.
GPB0-9GPIO_B optional extra pins.

Basic Usage

Example usage uses the MCP23017 from PyPi (https://pypi.org/project/mcp23017/).

import time
import smbus2 as smbus
from mcp23017 import *

ADDR = 0x20 # Device I2C address

# Connect to address 20 on bus 11
mcp = MCP23017(ADDR, smbus.SMBus(11))

# Set all pins as inputs
mcp.set_all_input()

# Except the info LED which is an output
mcp.pin_mode(GPA7, OUTPUT)

# Enable the internal pull-up resistors
mcp.i2c.write_to(ADDR, GPPUA, HIGH)

# For the push buttons, set the inverse polarity, so activation reads high
mcp.set_bit_enabled(IPOLA, GPA0, True) # Rotary button press
mcp.set_bit_enabled(IPOLA, GPA1, True) # STAT
mcp.set_bit_enabled(IPOLA, GPA2, True) # ITEM
mcp.set_bit_enabled(IPOLA, GPA3, True) # DATA
mcp.set_bit_enabled(IPOLA, GPA4, True) # Rotary A
mcp.set_bit_enabled(IPOLA, GPA5, True) # Rotary B

while True:
  # Read the status of the ITEM button
  item_pressed = mcp.digital_read(GPA2)

  # Light up the INFO LED when the button is pressed
  mcp.digital_write(GPA7, item_pressed)

  # If the button is pressed, say hello!
  if item_pressed is HIGH:
    print("Hello!")

  time.sleep(0.1)

Usage As HID in Linux

Various example code exists in the Gitlab repository over at https://gitlab.com/robco-industries/hid-driver.

The example in uinput-py/ can be used to register the device in Linux as a user input device and then send keyboard keypresses when physical buttons are pressed.