TheTangInitiative
Posts: 1
Joined: Mon May 11, 2015 10:54 pm

SPI Interface

Mon May 11, 2015 11:09 pm

100 % Newbie Here

The short of it is that I'm attempting to design a 16' x 14' self leveling platform with HD linear actuators. I was trying to use an Arduino but was told the Raspberry Pi 2 was a better way to go. In the quick amount of research Ive, that seems to be the case. Anyway, I wanted to use 2-Axis inclinomters in my design and interface them with the raspberry pi 2.

My question is....Does the RP2 interface with an SPI ?

Im a pure mechanical engineer so please forgive me if I am butchering the lingo.

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: SPI Interface

Tue May 12, 2015 12:41 am

TheTangInitiative wrote:Does the RP2 interface with an SPI ?
SPI is the interface... acronym stands for Serial to Parallel Interface. Its basically a way to talk to devices that require 8, 16, 32 or more lines with only four(4) lines from your mcu, the RPi in this case.

The data output to the device(s) is sent out a data line and is 'clocked' into shift registers by the clock line. There is generally a 'chip select' or enable line and ground. SPI is very common and is supported by almost all SoC mcu(s) and of course the single board computers like the RPi. By supported I mean that the software engineering language of choice for the SoC generally has an SPI library that makes it easy to use the SPI without needing to get down into the bits at the lowest level.

On the other hand, depending on the device, some people prefer to drive the SPI interface with their own code at a slightly higher level (a technique referred to around here as bit-banging) where any four of the gpio lines can be chosen and used for the purpose. Read-up on SPI to get a good idea of what is involved, and be sure to read the datasheets for the devices you plan to interface.
marcus
:ugeek:

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: SPI Interface

Tue May 12, 2015 4:24 am

MarkHaysHarris777 wrote:
TheTangInitiative wrote:Does the RP2 interface with an SPI ?
SPI is the interface... acronym stands for Serial to Parallel Interface. Its basically a way to talk to devices that require 8, 16, 32 or more lines with only four(4) lines from your mcu, the RPi in this case.
Good grief! Will you please stop posting misinformation? Your posts are verging on the ridiculous.

SPI does not stand for "Serial to Parallel Interface" and is not basically there for the reasons you suggest.

http://en.wikipedia.org/wiki/Serial_Per ... erface_Bus

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: SPI Interface

Tue May 12, 2015 4:26 am

TheTangInitiative wrote:My question is....Does the RP2 interface with an SPI ?
Yes.

User avatar
rpdom
Posts: 17275
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: SPI Interface

Tue May 12, 2015 4:43 am

MarkHaysHarris777 wrote:a technique referred to around here as bit-banging
"Bit-banging" is a very common expression, referring to the control of signal timing via software instead of hardware. It is used in many places, not just here.

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: SPI Interface

Tue May 12, 2015 5:13 am

ame wrote: SPI does not stand for "Serial to Parallel Interface" and is not basically there for the reasons you suggest.
Your dislike for me has actually made you ridiculous...

http://en.wikipedia.org/wiki/Serial_Per ... erface_Bus

<snap!>


PS good friend, I suppose I'll have to 'stop' using SPI for the purpose I've detailed above, since, well, it can't be used that way... says you... :)

PPS take a look, scroll down to the serial to parallel diagram... a very common use of SPI /

http://www.maximintegrated.com/en/app-n ... vp/id/5139

( I do not use the term Serial Peripheral Interface, because it does not 'describe' what is going on. Especially when talking to someone completely new to the idea. SPI takes a serial data stream and writes that stream into parallel out shift registers. This can be used for many purposes; but one of the most common is multiplexing serial in parallel out--- extending gpio for one thing--- and writing to devices control words or writing to multiple 'slave' devices. )
marcus
:ugeek:

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: SPI Interface

Tue May 12, 2015 9:31 am

MarkHaysHarris777 wrote:
ame wrote: SPI does not stand for "Serial to Parallel Interface" and is not basically there for the reasons you suggest.
PPS take a look, scroll down to the serial to parallel diagram... a very common use of SPI /

http://www.maximintegrated.com/en/app-n ... vp/id/5139

( I do not use the term Serial Peripheral Interface, because it does not 'describe' what is going on. Especially when talking to someone completely new to the idea. SPI takes a serial data stream and writes that stream into parallel out shift registers. This can be used for many purposes; but one of the most common is multiplexing serial in parallel out--- extending gpio for one thing--- and writing to devices control words or writing to multiple 'slave' devices. )
Your linked article refers to SPI as Serial Peripheral Interface. Figure 1 shows a group of Serial to parallel interfaces connected to the SPI bus, these are SPI slave devices not SPI master (the output of them is parallel, the input is serial, an SPI bus has a serial output).
A serial to parallel interface converts a serial input to a parallel output. The SPI bus has a serial output (it may be multiplexed to talk to a number of parallel devices but it talks to each of them separately rather than all of them simultaneously).

Edit: Sorry to join the disagree with Mark camp, but I HAD to post.
Doug.
Building Management Systems Engineer.

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: SPI Interface

Tue May 12, 2015 9:47 am

BMS Doug wrote: Your linked article refers to SPI as Serial Peripheral Interface. Figure 1 shows a group of Serial to parallel interfaces connected to the SPI bus, these are SPI slave devices not SPI master (the output of them is parallel, the input is serial, an SPI bus has a serial output).
A serial to parallel interface converts a serial input to a parallel output. The SPI bus has a serial output (it may be multiplexed to talk to a number of parallel devices but it talks to each of them separately rather than all of them simultaneously).
Yes, I know. And your point is?

If you look carefully at the diagram I referred to the outputs of each slave are parallel... yes, more slaves can be added (chained) to the serial out, but that's not the point. The 'words' written to the slaves (shift registers) are written serially and are available on the parallel outputs of each register (sometimes with latching, sometimes without). I built a driver board that looks just like that diagram (for instance) and I use it to multiplex 64 additional output gpio lines (in parallel) but I write to them with a serial data stream via SPI, then I latch the outputs and write the next set. Its a true serial to parallel interface, and it works great!

Some serial peripheral devices do not give you access to the parallel outputs of the shift registers (like seven segment display bars for instance) but internally they also work just like that diagram. The segments are driven from the parallel outputs but the display bar is written to serially via SPI. Under the covers it really IS a serial to parallel interface; although, the bus is considered a serial bus. Much of this discussion is just semantics; which is not terribly important. I'm currently using SPI to write to my LCD graphics display, my LCD two line display, and my LED seven segment 16 digit display. They all work fine; really well, actually.
marcus
:ugeek:

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

Re: SPI Interface

Tue May 12, 2015 10:11 am

Recent Pis (40 pin expansion header) expose two SPI peripherals. One peripheral has two chip selects (to connect two devices) and the other peripheral has three chip selects (to connect three devices).

The two chip select SPI peripheral has Linux driver support.

The Pi also has an I2C bus and a serial UART.

Return to “Beginners”