PGD Home

Project 136: Thermal Imager Project Update 5: 2.2″ Multiple Slaves on SPI Bus

by on Sep.17, 2015, under Inventions, Tutorials

SPI stands for Serial Periphral Interface, and it used with devices like microcontrollers to connect RAM, displays, sensors, etc.

A very useful primer from Sparkfun is located HERE. This link provides a lot of theory on how SPI works, and on the two main ways of connecting multiple devices to the same SPI bus.

SPI uses several “pins” to transmit and receive data.
These pins are:

MISO: Master IN Slave OUT: Data goes from the slave, to the master, eg. a sensor sending back readings to an Arduino.
MOSI: Master OUT slave IN: Data goes from the master, to the slave, eg. an Arduino telling a display what to render.
System Clock(SCK): The clock pulse which synchronises the master and the slaves.
Slave Select(SS): This allows multiple slaves to communicate with the master, by setting the SS line low on only the slave which is currently communicating with the master.

It turns out that connecting multiple slave devices to a master using SPI on Arduino is much easier than I thought it would be.

The first way is to daisy chain the devices together, connecting Slave 1 to slave 2, then slave 2 to slave 3, etc. This is done by connecting the MISO of one slave to the MOSI of the next. This setup uses the least number of pins, since only a single SS line is used. This could be an advantage for a setup where very few pins are available, however, this system strikes me as much more complex (I haven’t actually tried it) and it also involves sending data to ALL devices at once. For example, if the user wants to send data to Slave 3, it must be sent to slave 1 first, then slave 2, then slave 3. The same is true with sending data back to the master (The Arduino) the data must be sent from Slave 3 to slave 2, then to slave 1, then to the microcontroller.

The method which I used was to connect the SCK, MOSI, and MISO lines of both slaves to the arduino, then use a seperate SS line for each slave. Pin 10 on the arduino is the default SS pin, I used this for the ram, and changed the pin for the display to Digital Pin 9.

I also needed to change the LCD’s DC pin and it’s Reset Pin to pin 3 and 2, since I was already using their default pins (9 and 8) for the RAM module. The DC pin is used for sending data to the Arduino. The RST pin is used for resetting the LCD screen, this can actually be plugged into the arduino’s reset pin, which means that both the arduino and the LCD screen will be reset at the same time, saving a pin. It can also be left unconnected, and it seems like the LCD screen still works properly.

The MISO on this display is actually only used for the SD card, so, I could have left that unconnected for the moment too, but since I plan to use the SD card to store images created by the thermal imager, I connected it.

I then also needed to update the CS pin in the Sketch, as well as the DC and RST pins. Then, to my surprise, everything worked! I didn’t need to change any other code, the SPI library (“SPI.h”) took care of everything else for me! This left me with plenty of free pins for the FLIR dev kit and the SD card Chip select pin.

See THIS post for some pics and a video of the project in action.

 

 

Facebooktwitterredditpinterestlinkedinmail

Comments are closed.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!