Go to Post We always have a party on Friday. It's called scouting. - Meredith Novak [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 05-02-2004, 20:03
Greg's Avatar
Greg Greg is offline
Registered User
FRC #1075 (Sinclair Sprockets)
Team Role: College Student
 
Join Date: Nov 2002
Rookie Year: 2003
Location: Whitby, Ontario, Canada
Posts: 108
Greg is on a distinguished road
Send a message via ICQ to Greg Send a message via MSN to Greg
Software SPI Interface

I have been trying to interface a sensor that uses an SPI interface to the RC. I know the actual SPI bus on the PICs is used by IFI - this is how the two PICs communicate. However, C18 has a set of "Software SPI" functions that use digital input pins to emulate SPI (C18 Library Manual, p.121).

I looked at the default values for the SPI pins in the manual. They appear to correspond to digital inputs 1, 2, 5, and 6 on the RC. I connected the sensor to these pins, included the sw_spi.h header in the project, and tried to talk to the sensor.

For some reason I cannot get the data out of the sensor. I either get all 1, or all 0 in a byte No real data.

I am suspecting a conflict with the default FIRST code. The function that initializes the SPI, OpenSWSPI, is supposed to set up the pins correctly. Could it be that the FIRST library is conflicting with this? I tried to remove all lines that referenced the pins I am using from the default code. Didnt help.

Also for some reason if I change the pin assignment in sw_spi.h in the mcc18 folder the program does not build properly. Do I have to recompile something or include any other files in my project?

Did anyone use the software SPI functions? Or the software I2C which should be close to what I am doing?
  #2   Spotlight this post!  
Unread 06-02-2004, 15:09
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Software SPI Interface

I have no idea what SPI is, but I'll try to give you some general pointers passed on your message.

Is there any docs on using SPI and how to connect a SPI sensor?
Is the hardware wired for this?
Did you check for semi-colons and the like? One of my probs
Did you wire the sensor wrong?
Is the sensor bad?
Where is the Actual code for the functions? if it is in a lib, I wouldn't mess with it at this time (get it to work first, then check Editing Main.c for advanced stuff)
Could it be that it's working, but not as you expected?
Are aliens skrewing around with it wile your not looking?
  #3   Spotlight this post!  
Unread 06-02-2004, 15:21
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: Software SPI Interface

Quote:
Originally Posted by Astronouth7303
I have no idea what SPI is.
SPI? I haven't the faintest either. Could you clarify that for both of us?

Quote:
Originally Posted by Astronouth7303
Are aliens skrewing around with it wile your not looking?
Or the gremlins that hide under carpet. They always get us.
__________________

  #4   Spotlight this post!  
Unread 06-02-2004, 15:38
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Software SPI Interface

Quote:
Originally Posted by Texan
SPI? I haven't the faintest either. Could you clarify that for both of us?
Where? Google? What does it stand for?

[edit]I went to Google. You know how many things SPI stands for?!?!?!?!?!?!?[/edit]
[edit]Is SPI a company, or a format? Or both?[/edit]
[edit]Think I have it. http://www.mct.net/faq/spi.html

Quote:
Originally Posted by Texan
Or the gremlins that hide under carpet. They always get us.
Well, it ain't ours! They're under lock and key, I think...

Last edited by Astronouth7303 : 06-02-2004 at 15:47.
  #5   Spotlight this post!  
Unread 06-02-2004, 15:48
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,245
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
Re: Software SPI Interface

serial peripheral interface. Don't know how to interface it though.
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
“Life should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me
  #6   Spotlight this post!  
Unread 06-02-2004, 15:50
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,588
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Software SPI Interface

For those who are wondering what SPI is: http://www.mct.net/faq/spi.html

Sorry, I don't have any experience with SPI on a PIC.
  #7   Spotlight this post!  
Unread 06-02-2004, 15:56
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Software SPI Interface

Thank you for conferming my find. I just read through it, And it sounds pretty nifty. Tell us how you figure it out.
  #8   Spotlight this post!  
Unread 08-02-2004, 13:27
Greg's Avatar
Greg Greg is offline
Registered User
FRC #1075 (Sinclair Sprockets)
Team Role: College Student
 
Join Date: Nov 2002
Rookie Year: 2003
Location: Whitby, Ontario, Canada
Posts: 108
Greg is on a distinguished road
Send a message via ICQ to Greg Send a message via MSN to Greg
Re: Software SPI Interface

I have another question. Which PIC controls the digital IO pins on the robot controller - master or the user PIC? In other words, is it possible to update data on those pins without calling Putdata? Or does it only update the state of the digital outouts when putdata is called?
  #9   Spotlight this post!  
Unread 08-02-2004, 13:39
KevinB's Avatar
KevinB KevinB is offline
Registered User
AKA: Alum
no team
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2001
Location: AL
Posts: 188
KevinB will become famous soon enoughKevinB will become famous soon enough
Send a message via ICQ to KevinB
Re: Software SPI Interface

Quote:
Originally Posted by Greg
I have another question. Which PIC controls the digital IO pins on the robot controller - master or the user PIC? In other words, is it possible to update data on those pins without calling Putdata? Or does it only update the state of the digital outouts when putdata is called?
The Digital I/O pins are all controlled by the User Controller (Putdata() is not required.)
  #10   Spotlight this post!  
Unread 08-02-2004, 17:40
Rickertsen2 Rickertsen2 is offline
Umm Errr...
None #1139 (Chamblee Gear Grinders)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2002
Location: ATL
Posts: 1,421
Rickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant future
Send a message via AIM to Rickertsen2 Send a message via Yahoo to Rickertsen2
Re: Software SPI Interface

If you want some help your going to have to post some code, what sensor your are using and to what pins it is wired.
__________________
1139 Alumni
  #11   Spotlight this post!  
Unread 08-02-2004, 20:27
Kevin Casper Kevin Casper is offline
Registered User
#0171 (Hardcore Engineers)
 
Join Date: Oct 2003
Location: Platteville , WI
Posts: 15
Kevin Casper is an unknown quantity at this point
Re: Software SPI Interface

Quote:
Originally Posted by Greg

Did anyone use the software SPI functions? Or the software I2C which should be close to what I am doing?
I have never used the c compiler SPI functions, but I have done firmware Serial Port Interface in assembly on a pic16 series processor. I used it to connect to a digital pot. Depending on what you are doing, my advice is to simply write the software explicitly. SPI is a very simple protocol. The meat of spi is between clock and data pin. Check whatever you are connecting to, if it reads the data pin when your clock pin equals 1, the rise of the clock or cycle, then set what the next bit is when you toggle the clock to 0. Toggle the clock pin 16 times, 8 toggles to value 0 and 8 to value 1, to transmit a byte.

Make a function to do a byte at a time. It shouldn't take more than a half hour to set this up. Most intermediate programmers can do it in several minutes for simpler SPI interfaces.

There is normally a select pin to indicate when the device is reading. Bring that low, set it to zero, for the duration of the communication. Assuming I didn't forget anything critical, it's been a while, that should all there is to most SPI communications.
__________________
Kevin Casper
  #12   Spotlight this post!  
Unread 08-02-2004, 21:38
Greg's Avatar
Greg Greg is offline
Registered User
FRC #1075 (Sinclair Sprockets)
Team Role: College Student
 
Join Date: Nov 2002
Rookie Year: 2003
Location: Whitby, Ontario, Canada
Posts: 108
Greg is on a distinguished road
Send a message via ICQ to Greg Send a message via MSN to Greg
Re: Software SPI Interface

Thats exactly what I am planning to do now - write my own functions It would have been nice to get the pre-written ones working (they should be doing the same thing anyway), but writing my own should not be hard. I'll give it a try in a couple of days (as soon as I finish some school assignments )and see how it works out.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create custom interface _GP_ Technical Discussion 1 18-01-2004 21:24
which software Ryan Foley 3D Animation and Competition 5 01-03-2003 23:39
Looking for operator interface... Where is it? mike325 General Forum 2 07-01-2003 15:28
Gyro interface to software archiver 2001 1 24-06-2002 02:51
software software software archiver 2001 5 24-06-2002 00:21


All times are GMT -5. The time now is 00:02.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi