Go Down

Topic: SPI and Chip select (Read 1 time) previous topic - next topic

book_woorm

Hi, I am running out of pins and a thought occoured to me that it should be possible to combine the required CS pins from multiple SPI interface requirements with a logic chip. The new Ethernet Shield uses 10 and 4 for ethernet and sd card respectively and I will be needing some more SPI's without losing all the available digital lines to do other things.

The idea is to use three digital pins as a  binary number, which it should be possible to decode with a TTL chip to 8 lines. (now perhaps you don't want to use 000 so you can have an all off) I know this would mean a circuit board between the Uno and the shields but that would also allow A0 and A1 to be recovered for analog input with out cutting the pins off the back of the ethernet shield. Also there would need to be a routine to switch the SPI between whatever you wanted to talk to rather than just switching individual pins ( high ; do something; low). You probably have to go through the 000 state in each transition to make sure that no chip is listening before activating the next one.

Can anybody see anything wrong with this basic idea? or are switch on switch off functions already buried so deeply into the libaries that they would be dificult to doctor?

johnwasser

The basic idea of I/O expansion is sound but if you use it for SPI devices you will need to edit the library for each SPI-based device to change the way it sets Slave Select.

Perhaps some of your other pin usage would work better with I/O expansion based on a shift register and shiftIn() or shiftOut().

You have 20 pins to work with (13 if you use 0 and 1 for serial I/O and 5 for the Ethernet+SD Shield).  What are you using them for?
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Graynomad

Quote
The idea is to use three digital pins as a  binary number, which it should be possible to decode with a TTL chip to 8 lines.
Using a 74xx138 decoder.

I don't know exactly what the SPI lib does with SS but you could either just ignore it or use it to enable the '138.

Alternatively look at using an IO expander as John suggests.

_______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

johnwasser


I don't know exactly what the SPI lib does with SS but you could either just ignore it or use it to enable the '138.


The SPI library doesn't touch SS, but the Ethernet, SD, etc. device libraries all have to deal with their individual SS lines.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

fkeel

It should work.

I plan on testing a very similar setup as soon as I get around to it. Once I do I will post what I find out. If you could also share how it works out for you, that would be valuable for me.

Thanks

p.
http://embodimentlabs.tumblr.com/
http://paulstrohmeier.info/

book_woorm

I Thought that the idea would lead to hacking the Ethernet,SD libaries if I can avoid that then I will 'nonstandard' is always trouble. I'm trying to build an enviromental controller that uses PT1000 temperature sensors (for compatable with other things on site and eventually cut down the variety of spares needed) so I need all 6 analog inputs!!   Hence the idea of separating the ethernet shield and uno with a custom board. Plus a local LED display is out the window unless I can get one with a SPI rather than a I2C interface. Trouble is I need all the uno's digital lines to drive relays for interfacing to the dreaded 240V.
To be fault tolerant I don't want to multiplex the relay drives, if something dies then they all need to failsafe.
I do'nt know how long this is going to take now. All other ideas welcome.

johnwasser

Have you thought of using DS18B20 temperature sensors?  You can hook a whole series of them to a single data pin.  That will leave A4 and A5 free for a I2C LCD display.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

CrossRoads

local display with SPI interface like one of these?
http://www.newhavendisplay.com/serial-displays-c-253.html
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Graynomad

#8
Jun 15, 2012, 12:38 am Last Edit: Jun 15, 2012, 12:42 am by Graynomad Reason: 1
Quote
display with SPI interface

Or these

http://www.sparkfun.com/products/9764

Quote
I need all the uno's digital lines to drive relays for interfacing to the dreaded 240V.

Use an IO expander or just a plane shift register.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

fkeel

sounds like you could solve most of your problems by using a mega instead of an uno.

*

btw. I ended up just multiplexing the CS of the SPI
http://embodimentlabs.tumblr.com/
http://paulstrohmeier.info/

book_woorm

Thanks for the info folks. I've managed to keep all the analog inputs and put a 4 to decoder on the outputs using the strobe function to give me the fail safe.

My next problem is the HTML interface and a couple of methods that work when the code is embedded in the main code but dont work as methods. Thats another subject!!!

Go Up