Electrical – Best approach for sharing SPI bus across multiple sensors

multiplexersensorsharedbusspi

I'm designing a few PCBs for a project:

  • Microcontroller PCB (SPI master)
  • Sensor PCB, where each sensor PCB has several SPI slaves on it.

In a full system, there would be 3 sensor PCBs directly plugged into 3 connectors on the microcontroller PCB. In certain scenarios, not all 3 sensor PCBs will be present.

My question is about best practices/approach for sharing a single SPI controller across all 3 sensor PCBs. I'm planning to run the SPI bus at 20 MHz and the longest end-to-end trace length between the microcontroller and SPI slave will be about 8 inches.

Some ideas I had:

  1. Use a 'SPI bus multiplexer' to isolate which Sensor PCB is connected to the SPI bus at any given time, but haven't had much luck turning up results. Was hoping to find something similar to a TCA9544A (I2C multiplexer).
  2. Use 4-bit tri-state buffer on the microcontroller board for each Sensor PCB interface. In this case, I'd have 3 of these on the microcontroller PCB. Using the output enable to connect/disconnect a sensor PCB from the shared SPI bus.

Update:

Here's a diagram of what I'm trying to do:

enter image description here

I suppose I'm more concerned with signal integrity and EMI/reflections. I believe I have an understanding of the functional connection aspects. How should I handle the inter-board connections, given that a sensor board may or may not be attached? Should I use tri-state buffers at the interface?

Best Answer

I believe the best approach would be to use SPI-controlled switches like ADGS1408 to select slave device on sensor PCB. This way same bus will be used for both communication and multiplexing. And you only need 1 additional wire per board - when it is low it selects switch itself, when it is high the inverted low signal is used as multiplexed SS for sensors.

So, to access certain sensor you first pull board SS low, send sensor address to a switch, then pull SS high and communicate with sensor.

On master PCB you can select active board directly from MCU (if you can spare pins) or you can add switch(es) to select between as many boards as you like. In this case you first send board address to local switch, then sensor address to selected board, and then communicate with selected sensor.

Note that if bus capacitance becomes a problem you can use switches to multiplex bus wires too. You only need two dual ADGS1409 to switch three bus wires and board SS.

Related Topic