pmueller
Posts: 1
Joined: Mon Mar 14, 2016 7:36 pm

More than 2 SPI slaves

Mon Mar 14, 2016 7:41 pm

Hello,

I like to connect more than two SPI slaves to the Raspberry.
Unfortunately there are only to chip select pins possible (/CS0, /CS1). I can use GPIO pins for all of the SPI slaves, but then I can't use /CS0 and /CS1 anymore.

I looked into the kernel sources and saw that there seems to be the possibility to define not using any chip select. But control the the chip select via port pins in the application. But this seems not to work (at least what I tried).

Has anyone more than 3 SPI devices running that way?

Thanks,
Peter

TheRayTracer
Posts: 51
Joined: Tue Oct 13, 2015 12:23 am
Location: Australia

Re: More than 2 SPI slaves

Tue Mar 15, 2016 4:51 am

You may successfully use more that two SPI style devices. You may simply use any free GPIO pin on the RPi to manually toggle the CS for the slave device. This may not work for all SPI devices, such as those that require the CS to go inactive between each byte of a transmission, but most devices would have no issue with using this method.

User avatar
brekee12
Posts: 334
Joined: Wed Feb 03, 2016 3:36 pm
Location: HU

Re: More than 2 SPI slaves

Tue Mar 15, 2016 5:55 am

There is an additional auxilary SPI on B+ Zero 2B which is located on the header and have three CS. This is additional to the standard SPI, but separate handling by sofware. Study joan's pigpio library which makes the handling. Very usefull option!
Brekee12
on a Raspberry B+ with whezzy, two Zero with Jessie Light

User avatar
adun
Posts: 91
Joined: Fri Mar 20, 2015 9:25 am
Location: Switzerland

Re: More than 2 SPI slaves

Tue Mar 15, 2016 9:45 am

The current spi-bcm2835 driver supports additional GPIO chip-selects. For driver performance the hardware chip-select pins (CE0,CE1) will be automatically converted to GPIO CS's pins.

thomen
Posts: 31
Joined: Mon Sep 01, 2014 3:46 am

Re: More than 2 SPI slaves

Tue Mar 29, 2016 1:07 pm

Just wondering if anyone has done anything with more than 2 slaves using daisy chaining or the like?
I'm looking to wire up around 6 colour oleds using SPI

User avatar
brekee12
Posts: 334
Joined: Wed Feb 03, 2016 3:36 pm
Location: HU

Re: More than 2 SPI slaves

Tue Mar 29, 2016 1:16 pm

As I mentioned auxilary SPI available on B+, 2B, Zero has three CE.
Brekee12
on a Raspberry B+ with whezzy, two Zero with Jessie Light

blushi
Posts: 19
Joined: Tue Jul 14, 2015 3:53 pm

Re: More than 2 SPI slaves

Tue Mar 29, 2016 5:43 pm

thomen wrote:Just wondering if anyone has done anything with more than 2 slaves using daisy chaining or the like?
I'm looking to wire up around 6 colour oleds using SPI
I did actually. See my post: viewtopic.php?p=940975#p940975 (even though I am facing now some issues, you can get the idea ;) ) If you have any further questions, I'd be glad to help.

User avatar
mikronauts
Posts: 2622
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: More than 2 SPI slaves

Tue Mar 29, 2016 7:18 pm

http://www.mikronauts.com/raspberry-pi/ ... and-howto/

Shows you how to generate eight chip selects from one...
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

thomen
Posts: 31
Joined: Mon Sep 01, 2014 3:46 am

Re: More than 2 SPI slaves

Tue Mar 29, 2016 9:21 pm

I was hoping to Daisy chain 6 oled small screens. Do you think that would be possible??

thomen
Posts: 31
Joined: Mon Sep 01, 2014 3:46 am

Re: More than 2 SPI slaves

Tue Mar 29, 2016 9:36 pm

Wow micronaughts I can't even begin to understand half of what you've written! (Being totally green and all) time to Google like crazy and read electronics for dummies ha-ha..

User avatar
mikronauts
Posts: 2622
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: More than 2 SPI slaves

Thu Mar 31, 2016 6:40 pm

Hi.

You can't daisy chain SPI, as each device needs its own chip select.

You can daisy chain i2c.

The circuit in my article basically adds a "one of eight" de-multiplexer, and uses that to generate individual chip selects from a three bit binary number, and one of the chip selects on the GPIO connector.
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

thomen
Posts: 31
Joined: Mon Sep 01, 2014 3:46 am

Re: More than 2 SPI slaves

Thu Mar 31, 2016 9:31 pm

Thanks !
I'll give it a try! I wanted to try and run up to 6 oleds with a pi

crishoj
Posts: 5
Joined: Tue Mar 22, 2016 11:26 pm

Re: More than 2 SPI slaves

Sun Apr 24, 2016 7:37 am

Are you certain that daisy-chaining on SPI is not possible?

Daisy-chaining with a single, shared chip-select seems to be a common mode of operation. See e.g. http://www.petervis.com/Raspberry_PI/SP ... Chain.html

User avatar
joan
Posts: 12782
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: More than 2 SPI slaves

Sun Apr 24, 2016 10:01 am

crishoj wrote:Are you certain that daisy-chaining on SPI is not possible?

Daisy-chaining with a single, shared chip-select seems to be a common mode of operation. See e.g. http://www.petervis.com/Raspberry_PI/SP ... Chain.html
That does not make sense. I suggest you contact the author and ask for clarification. He may have a very specialised use with one model of chip in mind.

crishoj
Posts: 5
Joined: Tue Mar 22, 2016 11:26 pm

Re: More than 2 SPI slaves

Sun Apr 24, 2016 10:58 am

Of course, the SPI devices in a chain would have to support daisy-chaining, namely by re-transmitting their input to the next device on the following clock cycle.

See here for a description:
https://en.wikipedia.org/wiki/Serial_Pe ... figuration

Typical wiring, with one chip-select per device:
Image

Daisy-chain wiring, with a single, shared chip-select:
Image

crishoj
Posts: 5
Joined: Tue Mar 22, 2016 11:26 pm

Re: More than 2 SPI slaves

Sun Apr 24, 2016 11:09 am

Here is a specific example of chaining 3 AutoDrivers:
http://www.deathbylogic.com/2015/01/dai ... todrivers/

Data is shifted down the chain:
The way daisy chaining works with multiple devices on a single SPI bus is similar to shift registers, data from the SPI master is shifted out MSB first and shifted into the SPI slave on the falling edge of the SPI clock. At the same time the data in the slave is shifted out to the next device, when there is only a single slave device this would go back to the MISO pin on the master or with multiple slave devices the MOSI pin on the next slave. The number of devices that can be daisy chained together is only limited by length of the SPI bus and delay caused by each of the SPI devices on the SPI bus
Illustration:
Image

And here is a more technical description of the daisy-chaining SPI:
https://www.maximintegrated.com/en/app- ... vp/id/3947

I will be attempting a chained setup with 6 AutoDrivers in the coming weeks, and will be happy to report back how it goes.

User avatar
joan
Posts: 12782
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: More than 2 SPI slaves

Sun Apr 24, 2016 12:08 pm

It's simpler just to use shift registers to implement shift registers.

I don't remember any posts where SPI daisy chaining has actually being used on the Pi.

peter.shea
Posts: 8
Joined: Mon Nov 11, 2013 6:00 pm

Re: More than 2 SPI slaves

Thu Sep 07, 2017 4:13 pm

chrishoj:
I will be attempting a chained setup with 6 AutoDrivers in the coming weeks, and will be happy to report back how it goes.
Did you ever get this working?

User avatar
OutoftheBOTS
Posts: 402
Joined: Tue Aug 01, 2017 10:06 am

Re: More than 2 SPI slaves

Sat Sep 09, 2017 8:49 pm

There is a second SPI bus that has another 3 CS pins see http://terminal28.blogspot.com.au/2016/ ... ero23.html
but also I found that to make room on the broad com chip you need to remove the Bluetooth or the serial console. I removed the serial console to use the SPI bus 1

SteveA
Posts: 26
Joined: Sat Mar 14, 2015 11:18 am
Location: South Yorkshire, England

Re: More than 2 SPI slaves

Wed Nov 15, 2017 1:12 am

Peter, from your original post, would you mind letting me know how you can disable the kernel from toggling CE0 or CE1 when using SPI because if that is what I have been trying to find out,
Thanks in advance
Steve

Return to “Interfacing (DSI, CSI, I2C, etc.)”

Who is online

Users browsing this forum: No registered users and 15 guests