Extension board · Controls and displays

64-pin SPI I/O expander

Sixty-four extra 3.3 V input or output lines on four headers, controlled over SPI with one chip select. Each line has a series resistor against wiring faults. Using it needs your own driver.

Top view of the I/O expander: four expander chips, resistor arrays and four 20-way pin headers, with sockets on the left and right edges.
Top view, drawn from the board’s design files. This is a drawing, not a photograph.
64 lineseach input or output
4 × MCP23S17one chip select
220 Ωin series with every line
10 MHzmaximum SPI clock
< 100 mArecommended total load
110 × 80millimetres, four M3 holes
Every line is 3.3 V only. 12 or 24 V on any line destroys the expander. Do not drive relays, motors or solenoids directly, and do not use these lines for safety inputs.

Tech specs

PurposeMany switches, indicator drivers or logic signals from one SPI port
ExpandersFour Microchip MCP23S17 at hardware addresses 0 to 3, software-enabled input pull-ups
Lines64 at 3.3 V, 220 Ω in series; about 7 mA into a short
InterruptOne shared line on contact 3, 10 kΩ pull-up
Supply3.3 V from the socket; stay under 100 mA of external load
ConnectorsFour 2 × 10 pin headers; two Gadgeteer type S sockets (Samtec SHF-105, 1.27 mm)
Size110 × 80 mm, four M3 holes on a 100 × 70 mm pattern
Works withSmoothieboard V2 Prime header GE electrically; no firmware driver
LicenceOpen hardware, CERN-OHL-S-2.0

Every figure with its basis is in the electrical specifications appendix; hole positions are in the mounting dimensions appendix.

Board tour

The numbers on the drawing match the list below it. The board is shown from the component side.

  1. 1
    Input socket S IN (J1) — Chip select 6, MOSI 7, MISO 8, clock 9, interrupt 3, reset 4.
  2. 2
    Chain socket CHAIN (J2) — SPI data and clock continue.
  3. 3
    Port 1 header (J3) — Lines of expander U1.
  4. 4
    Port 2 header (J4) — Lines of U2.
  5. 5
    Port 3 header (J5) — Lines of U3.
  6. 6
    Port 4 header (J6) — Lines of U4.
  7. 7
    Expanders (U1 to U4) — Hardware addresses 0 to 3.
  8. 8
    Series resistor arrays (RN1 to RN16) — 220 Ω on every line.
  9. 9
    Interrupt resistors (R1 to R4) — Join the four interrupt outputs safely.
  10. 10
    Chain links — Data and clock closed; interrupt, reset and chip select open.
  11. 11
    Mounting hole — One of four M3 holes.
Point at a number, or tap it, to read what the part is; the same text is in the list. On a small screen, scroll the drawing sideways.

Pinout

Check pin 1 of each header against the board printing before wiring.

J3 to J6: port headers (same pattern on each)

PinsSignal
1 to 8Port B, bit 7 down to bit 0
9 to 16Port A, bit 7 down to bit 0
17, 183.3 V
19, 20Ground

J1: input socket (S IN)

ContactSignalUsePrime header GE
13.3 VBoard supply3.3 V
25 VPassed to the chain only5 V
3INTInterruptPE8
4RESETLow resets all expandersPJ7
5Passed throughNot usedPJ8
6CSChip selectPD15
7MOSIData to boardPB5 (SPI1_MOSI)
8MISOData from boardPA6 (SPI1_MISO)
9SCKClockPA5 (SPI1_SCK)
10GNDGroundGND

What you need

An SPI portPrime header GE.
A ten-way cable1.27 mm Gadgeteer ribbon cable.
Header cables2 × 10 way, 2.54 mm.
Your own driverNone is supplied.

Get started

Minimum wiring: contact 1 to contact 1, 3.3 V; PD15, contact 6 to contact 6, chip select; PB5, contact 7 to contact 7, MOSI; PA6, contact 8 to contact 8, MISO; PA5, contact 9 to contact 9, clock; contact 10 to contact 10, ground. Prime header GE (J36) Expander J1 contact 1contact 13.3 V PD15, contact 6contact 6chip select PB5, contact 7contact 7MOSI PA6, contact 8contact 8MISO PA5, contact 9contact 9clock contact 10contact 10ground
Minimum connections. Interrupt and reset are optional.
  1. Mount the board

    Keep I/O wires short and away from motor wiring.

  2. Connect with the power off

    Plug J1 into header GE.

  3. Enable hardware addressing

    Before any read, write the IOCON register with HAEN (together with MIRROR and ODR) to address 0 and also address 4.

    Then devices 0 to 3 answer individually.

  4. Test one line

    Set one line as output and toggle it while measuring the header pin.

    About 0 and 3.3 V.

Configuration

You wantModuleExample
Use the extra linesNoneNo SmoothieV2 module drives this expander; its pins cannot be named in config.ini

There is nothing to add to config.ini.

How it works

One SPI bus and chip select serve four addressed expanders. J1 SPIone chip select U1 to U4addresses 0 to 3 220 ohmper line J3 to J664 lines 4 interruptsopen drain 1 k eachisolate 10 k pull-upshared J1.3to controller
Data path above, interrupt below.

Each SPI transfer starts with a byte containing the device address, so four chips share the chip select once hardware addressing is on. Port B and port A of each chip appear on one header. The interrupt outputs default to push-pull, so each has a 1 kΩ resistor that makes that harmless until software selects open drain.

Solder links

A further SPI device on the chain needs its own chip select; leave JP6 open unless you know why it should share.

Solder links as delivered: JP3 open; JP4 open; JP6 open; JP7 closed; JP8 closed; JP9 closed. JP3 · openchain interrupt JP4 · openchain reset JP6 · openchain chip select JP7 · closedchain MOSI JP8 · closedchain MISO JP9 · closedchain clock
The links as delivered. Close one with a small blob of solder across both pads; open it by removing the solder or cutting the copper between the pads.
LinkWhat it doesAs delivered
JP3Joins the interrupt to the chainOpen
JP4Joins reset to the chainOpen
JP6Joins chip select to the chainOpen
JP7Continues MOSIClosed
JP8Continues MISOClosed
JP9Continues clockClosed

Chaining

SPI data and clock continue to another board with a separate chip select.

The controller's ribbon cable goes to the connector S IN of the I/O expander board. Inside the board each of the ten pins runs through a solder link to the connector CHAIN, where a second ribbon cable continues to the next board. A closed link passes its pin on, an open link stops it. Controller one ten-pin port I/O expander board S IN CHAIN pin 6, select stops here pin 7, MOSI passed on pin 9, clock passed on one solder link per pin Next board sees what is passed on
Chaining: one port of the controller serves two boards. Pin 1 of S IN leads to pin 1 of CHAIN, pin 2 to pin 2, and so on, each through its own solder link. The three lines stand for the ten pins and show the links as delivered. Two boards must never drive the same pin, and a pin that one board uses for a signal is not free for the next. Data and clock continue; chip select stops here.
ContactSignalOn CHAIN
1, 2, 10Power and groundPassed on
3, 4, 6Interrupt, reset, selectStopped by open links
5FreePassed on
7 to 9SPIPassed on through closed links

Troubleshooting

SymptomLikely causeWhat to check
All reads are 0 or 255Wiring, chip select or reset held lowTest points CS and SCK
All four chips answer togetherHAEN not enabledWrite IOCON first
One chip unreachableAddress bitsCheck the Microchip errata for address handling
LED dim on an outputSeries resistor drops voltageUse less current or a driver
Interrupt never clearsA port not readRead the captured port registers

The board has no indicator lights; use the test points.

Still stuck? Read how to ask for help or see the general troubleshooting guide.

Downloads

FileWhat it is
Schematic (PDF)The circuit diagram
Parts list (CSV)Every component with its value, footprint and part number where one is chosen
Board drawing (PNG)The top view used on this page
3D view, top (PNG)Rendered from the design files
3D view, angled (PNG)Rendered from the design files

Appendix: mounting dimensions

For drilling a mounting plate or designing an enclosure. Positions are hole centres, in millimetres, measured from the top-left corner with the board seen from the component side.

Mounting drawing of the I/O expander board, component side: outline 110 by 80 millimetres with 4 mounting holes. Hole positions are listed in the table below. COMPONENT SIDE · millimetres 110 80 0, 0 X Y 1 5.00, 5.00 2 105.00, 5.00 3 5.00, 75.00 4 105.00, 75.00 Numbered rings are mounting holes. Positions are hole centres, X then Y, from the marked corner.
Board outline 110 × 80 mm, corners rounded to a 1 mm radius, board thickness 1.6 mm. Drawn from the design files, component side up, in the same orientation as the board tour.
HoleX (mm)Y (mm)DiameterUse
15.005.003.2 mm, not platedMounting, M3 screw
2105.005.003.2 mm, not platedMounting, M3 screw
35.0075.003.2 mm, not platedMounting, M3 screw
4105.0075.003.2 mm, not platedMounting, M3 screw

Appendix: electrical specifications

Every figure is a design value, a calculated or simulated value, or a manufacturer’s data sheet value, as the last column says. A dash means no figure is given.

ParameterApplies toLowerNominalUpperBasis
Supply and signalsAll lines—3.3 V—Design
SPI clockJ1——10 MHzMicrochip data sheet
Current per lineAny line——25 mAAbsolute maximum
Current into a shorted outputOne line—7.3 mA25 mASimulated
Current with 5 V applied to a lineOne line—4.6 mA25 mASimulated, generic clamp diode
Shared interrupt low levelContact 3—0.40 V0.66 VSimulated
Total external load3.3 V——100 mADesign budget

Component stress limits

PartLimitUse on this board
Line voltage3.3 VResistors are not overvoltage protection
Per expander125 mA in, 150 mA outAdd up all loads
3.3 V rail100 mA budgetExternal loads

Appendix: simulation

Fault and interrupt cases were simulated with ngspice.

Each simulated value (yellow mark) against its allowed range (green band). Shared interrupt low level399 mV Current into the low INT output during misconfigu...1.86 mA Output shorted to ground7.28 mA External 5 V on one line (generic clamp diode)4.59 mA
Simulated value (yellow) against the limit used for it (green). Each bar has its own scale.
ResultSimulated valueLimitOutcome
Shared interrupt low level399 mVat most 660 mVWithin
Current into the low INT output during misconfiguration1.86 mAat most 25 mAWithin
Output shorted to ground7.28 mAat most 25 mAWithin
External 5 V on one line (generic clamp diode)4.59 mAat most 25 mAWithin

Not simulated: the expanders themselves, SPI signal quality and electrostatic discharge.

Appendix: datasheet

The first page of the expander data sheet. Click the page to open the PDF.

First page of the MCP23017 / MCP23S17 16-bit I/O expander datasheet
MCP23017 / MCP23S17 16-bit I/O expander — Microchip, 40 pages.

See all boards on the extension boards page.

This is a wiki! If you'd like to improve this page, you can edit it on GitHub.