1

I'd like to connect multiple different SPI devices to a Raspberry Pi Zero W (at least 5), with a few specific requirements. The devices would be, if possible:

As I understand, the Pi Zero has one main, and one auxiliary SPI interface, with 2 CS pins on the former and 3 on the latter.

Using device tree, I've attempted to configure and enable the interfaces for this, though it's still not working properly. I've done the following to enable the interfaces, using default pin-outs for the wiring:

dtparam=spi=on
dtoverlay=enc28j60
dtoverlay=spi1-3cs

In /dev/, I can then see spidev0.1, 1.1, 1.1, and 1.2 all visible - 0.0 is not visible but I presume this is being used for Ethernet. I have confirmed that all 5 CE pins are being pulled high by default.

Currently, the Ethernet and MicroSD adapters are on SPI0, with CE0 for ethernet and CE1 for MicroSD. The Ethernet adapter works perfectly, so good start there. I can't see or mount any SD card volume, though, and I've had trouble finding how to do so - does anyone know how to fix this and use the SD as redundant storage?

Additionally, is it even possible to maintain uninterrupted (or at least always contactable) Ethernet connection despite sharing a bus while possibility simultaneously writing to the SD card? Would the OS handle this, or is this a bad idea? The Ethernet adapter's interrupt pin is connected, if that helps.

For the ADCs, I was intending to have them all on SPI1 (or 2 here, and the SD card adapter if I can't share it with Ethernet on SPI0), using CE0, CE1, CE2, and DRDY pins as required by the datasheet. We are able to get these working individually currently using the busio Python library and board to provide an SPI interface handle on a separate Pi, but this does not work with the Ethernet adapter (I assume as board looks for spidev0.0 by default?). Either way, I would rather convert this to work with SPI1, or bit-banged separately if I really need (especially if we need >4 ADCs), either way using the pigpio Python library as I've previously used it to solve I2C issues with great success, and I would like to keep consistency across the platform and stick to one major library where possible to avoid any conflicts. Does this approach sound sensible, or am I making some flawed assumptions that means this cannot work?

Summary of key questions, as there's a fair bit of text:

  • How do I use make the SD card available?
  • Is it possible to share SPI0 with continuous Ethernet and intermittent SD card use?
  • Is my described approach for the 3+ ADCs sound, or likely to cause major issues?

Thanks very much for any advice, it is greatly appreciated!

3
  • Hi #TheFaustie, Welcome and nice to meet you. Ah, let me see. Your question is very good, concise and detailed descriptions on user requirements and progress status, problems encounter so far. I am drafting an answer, with information you provided. Please let me know if I am misunderstanding or missing something. Please feel free to always comment and make counter suggestions. I will wait for your confirmation before I move on, suggesting approaches etc. Have a nice project, Cheers.
    – tlfong01
    Commented Aug 22, 2020 at 1:45
  • 1
    Hi tlfong, thank you very much for putting so much effort into this, it is really appreciated. Yes, I think you've understood the gist of the problems perfectly. I look forward to seeing your answer; I'll be trying quite a lot of possible ideas over the next few days so I will keep this thread updated with any progress I make. Thank you again!
    – TheFaustie
    Commented Aug 22, 2020 at 3:15
  • #TheFaustie, Thank you for your confirmation. So I will be making more suggestions on how to play with (1) Ethernet adapter, (2) SD card adapter, and (3) ADS1248 ADC. I need to google my old posts to refresh my memory. It would be nice if you can also share more of your tests. One suggestion is for you also to write up an answer here, so that our answers can compare and contrast, sort of pair programming or pair development. Nothing urgent. So we might update each other, say every couple of days.
    – tlfong01
    Commented Aug 22, 2020 at 8:06

2 Answers 2

1

Frankly I wouldn't try to use SPI for Ethernet or SD Card.

It is much easier to use USB adapters - the SD Card would then use normal drivers, and is likely to perform significantly faster than SPI.

AFAIK there is no inbuilt support for SPI connected SD Card. You may find the following link useful (I have not tried this).

https://ralimtek.com/raspberry pi/electronics/software/raspberry_pi_secondary_sd_card/

1
  • 1
    Hi Milliways, thanks for the link, I will take a look carefully. We first avoided using USB adapters due to space constraints in our application; SPI devices seemed to give us more freedom to design our own electrical footprint whereas many USB devices are too bulky along the edge of the Pi. With the Ethernet adapter working sufficiently for our speed requirements, that's OK, but I will consider MacGyvering a custom crimped MicroUSB connector so we can mount a small storage device or SD card elsewhere - definitely makes more sense now you've made clear there's no in-built support. Thanks!
    – TheFaustie
    Commented Aug 22, 2020 at 3:18
0

Question

Question in short

How can RpiZW talk to 5 SPI guys, including the following:

  1. 1 x Ethernet adapter
  2. 1 x Micro SD card adapter
  3. 3 x ADS1248, hopefully 3+

Progress and problems encountered so far

  1. Successfully setting up spidev 0.1, 1.0, 1.1, 1.2.
  2. Ethernet card adapter on SPI 0.1 CE0 set up and tested OK, but problem with busIO python, might consider bit banging to workaround.
  3. Micro SD card on SPI 0.1 CE1 setup unsuccessful, of course not yet tested.

Specific requirements

  1. Ethernet adapter preferably working non stop, at least SPI communication non stop.
  2. All 3 ADCs on single bus, hopefully SPI 1, CE0, CE1, CE2, and and GPIO x 1

Potential Problems

  1. ADS1248 module seems discontinued in AliExpress

  2. ADS1248 sps seems very small comparing with AD1256, which is very expensive

  3. Suggest to replace with MCP3008/3208/3201/34xx/35xx

  4. Circuit python might not run smoothly in RpiZW or Rpi3/4, might consider microPython which run much slower in Rpi4B, compared with Thonny python3.7.3


Answer

Short answer

/ to continue, ...


Long answer

/ to continue, ...


References

(1) ENC28J60 SPI Ethernet Controller Data Sheet - Microchip

(2) ENC28J60 Controller Board US$4 - AliEXpress

(3) MicroSD Card Productsheet - Diligent Pmod

(4) MicroSD Card Reference Manual - Diligent Pmod

(5) ADS1248 24-Bit, 2-kSPS, ADC - TI

(6) ADS1248 Technical Documentation - TI

(7) ADS1248 14 Channel ADC Module - AliExpress

(8) [ADS1256] How can Rpi4B python read negative result values of the SPI ADS1256 24 bit ADC? - Rpi SE, 2020feb25

(9) [ADS1256] Reading analog sensor value of 0-10Vdc with 12/16bit resolution - Rpi SE, 2019jun12

(10) [ADS1256] How can Rpi read ADS1256 ADC? - Rpi SE 2019jun07

(11) [ADS1256] How can Rpi read ADS1256's negative values? - Rpi SE

(12) [ADS1256] 24-Bit ADC Datasheet 2003~2013 - TI

(13) [ADS1256] 24-Bit ADC Documentation (App notes, white paper etc) - TI

(14) CircuitPython 5.3.x busio Hardware Accelerated Behaviour - AdaFruit

/ to continue, ...


Appendices

Appendix A - ADS1256 Features

ADS1256 Features


Appendix B - ADS1248 Features


ADS1248 Features


Appendix C - My ADS1256 Test Rig

(10) [ADS1256] How can Rpi read ADS1256 ADC? - Rpi SE 2019jun07

ads1256 test rig

/ to continue, ...


End of answer

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.