Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Multiple SPI devices

spi serial

  • Please log in to reply
2 replies to this topic

#1 Casmer

Casmer

    Member

  • Members
  • PipPip
  • 22 posts
  • LocationGrant, FL

Posted 30 August 2013 - 04:58 AM

I get the adafruit max31855 working, next I have about 3 other SPI sensors I want to read from, and finally I want to use an lcd to display some of this information. I am out of pins. can anyone point me in the direction of a device or sample for handling a larger number of spi devices at once?



#2 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 30 August 2013 - 05:45 AM

A single master SPI (e.g. Netduino) can be wired to several slave-SPI devices, in general. However, the actual feasibility is sensible to every device's features.

Let's say you can share (i.e. wire together) the SCK and the MOSI lines. Also you'd need a SS signal for every single slave device, in order to select only one at once.

The troubles could arise if you need to read data (by MISO pin) from more than a single device. Unless any of the involved devices has a kind of "output enable", or is a real pain. The "output enable", as the name suggests, is an input for the device, which activates its serial data output (going to the MISO). Without activation, the serial data out is in "high-Z" state, which is as it is left open.

 

A general approach for solving *any* kind of device SPI management, is by using a bidirectional multiplexer, such the 74HC4052.

Such a chip embeds a couple of 4-to-1 selectors, that simply act as a "short" from a pin and another one. The selection is made by a pair of inputs which map a binary position.

Let's say that using a 74HC4052, you may manage up to 4 SPI slave devices as follows:

  • share the SCK and the MOSI between master and slaves altogether;
  • use one selector for the MISO;
  • use the other selector for the SS;
  • use two more Netduino outputs for the selectors mapping.

I think that's the optimal way to manage such a context, that is just two pins more than a standard single-slave SPI.

 

Of course, you may use more 74HC4052's or even choose a different chip, but the mentioned chip looks as the best compromise for this kind of applications.

 

Finally, here is a concrete realization of a multiplexed slave devices management, with the only difference that the bus is I2C instead of SPI, but the sense is perfectly equivalent.

http://blogs.msdn.co...ing-better.aspx

 

Cheers


Biggest fault of Netduino? It runs by electricity.

#3 Casmer

Casmer

    Member

  • Members
  • PipPip
  • 22 posts
  • LocationGrant, FL

Posted 30 August 2013 - 04:10 PM

Looks like this might work for me thanks. I think I may even to be able to use multiple to get more than 4 devices off of 3 pins, instead I can get use 4 pins and control a few more devices. by adding more of these 74HC4052's together.







Also tagged with one or more of these keywords: spi, serial

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.