Go to Post Just take a chance. Dream and live. It's not a wild decision, but just ask yourself - if I got my team just a little bit more spending money, where would my team be then? Then, change that dream into a reality. Help your team sustain itself to inspire more kids. - CalTran [more]
Home
Go Back   Chief Delphi > Technical > Control System
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 21-09-2004, 20:10
Paolo's Avatar
Paolo Paolo is offline
Registered User
FRC #1351 (AMHS Robotics)
Team Role: Mechanical
 
Join Date: Sep 2004
Rookie Year: 2004
Location: California
Posts: 4
Paolo is an unknown quantity at this point
Dynamic Input/Output Changing

Has anyone made a bi-direction bus using the I/Os on the Robot Controller? That is, has anybody dynamically changed I/Os from input to output using software control?
  #2   Spotlight this post!  
Unread 21-09-2004, 20:23
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: Dynamic Input/Output Changing

If you mean so that at one point in the code we read in, and then later switch it and put something out, then maybe even later again read in... Nope, I haven't.

It's possible (I think, it's been a while since I've done anything with the FRC, but...).

Was that just a question in general, or are you don't something with it?
__________________

  #3   Spotlight this post!  
Unread 21-09-2004, 20:27
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: Dynamic Input/Output Changing

[quote=Paolo]Has anyone made a bi-direction bus using the I/Os on the Robot Controller? That is, has anybody dynamically changed I/Os from input to output using software control?[/QUOTE
]
I have done this and there are no problems doing it. All you have to do is set the TRIS bit(digital_io_xx flag) to either an input or an output. This presents no special problems and your direction change will take effect immediately.


----------- A short Explanation of the IO pins on a PIC --------
The PIC18F8520 inside the robot controller has 8 groups of I/O lines. The groups are lettered A,B,C,D,E,F,G, and H. Each one of these groups consists of 8 pins. On the robot controller we have access to only 18 of these general purpose I/O pins. They correspond to the digital IO pins on the RC as follow:

[digital input on RC: group and pin number (processor pin name)]
digital I/O 01: group B pin 2 (RB2)
digital I/O 02: group B pin 3 (RB3)
digital I/O 03: group B pin 4 (RB4)
digital I/O 04: group B pin 5 (RB5)
digital I/O 05: group B pin 6 (RB6)
digital I/O 06: group B pin 7 (RB7)

digital I/O 07: group H pin 0 (RH0)
digital I/O 08: group H pin 1 (RH1)
digital I/O 09: group H pin 2 (RH2)
digital I/O 10: group H pin 3 (RH3)

digital I/O 11: group J pin 1 (RJ1)
digital I/O 12: group J pin 2 (RJ2)
digital I/O 13: group J pin 3 (RJ3)

digital I/O 14: group C pin 0 (RC0)

digital I/O 15: group J pin 4 (RJ4)
digital I/O 16: group J pin 5 (RJ5)
digital I/O 17: group J pin 6 (RJ6)
digital I/O 18: group J pin 7 (RJ7)



Each group is controlled by 3 registers, TRISx LATx and PORTx, where x is the group letter. Each bit of these registers modifies one pin in the group. These registers are what are called special function registers(SFRs). There are lots of SFRs that control various aspects of the the processor's operation.

The TRISx register of each group can be used to individually set pins as inputs or outputs. 0 corresponds to output, 1 corresponds to input. IE: if you set bit 0 of the TRISG register to 0, you make digital I/O 1 on the robot controller an output. NOTE: on power up all pins are set as inputs. IFI wanted to make things easier for you so they created the digital_io_xx variables in the default code. If you look at their declaration in ifi_aliases.h you will see that they are actaully just direct aliases for various bits in various TRIS registers.

Ok so now we have a pin that is configured as an output and we want to set its state. This is the job of the LATx registers. They control the output of a pin when it is set as a output. They have no effect when the pin is set as an input. Example: We set bit 0 of LATB to a 1. This sets Digital I/O 1 on the RC to high(+5v). Again to make things easier to remember IFI has provided a set of logically named aliases for you (rc_dig_out01 - rc_dig_out18). Again these are direct aliases and map directly to different bits of different LAT registers.


Lets say we have changed our mind now and we now want to use pin RB2 (Digital I/O 01) as an input. This is where the PORTx registers are used. they are read to determine the state of a pin. The pin must first be set as an input using it's TRIS bit. Yet again IFI has made things easier and provided you with at set of aliases for these registers(rc_dig_in01 - rc_dig_in18). I don't remember what a PORT bit will read if its corresponding pin is set as an output.
__________________
1139 Alumni

Last edited by Rickertsen2 : 21-09-2004 at 21:27.
  #4   Spotlight this post!  
Unread 21-09-2004, 22:04
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Dynamic Input/Output Changing

Quote:
Originally Posted by Paolo
Has anyone made a bi-direction bus using the I/Os on the Robot Controller? That is, has anybody dynamically changed I/Os from input to output using software control?
Yes. We did some experiments with a robot position sensing system using an optical tracking chip watching the floor, and the communication had bidirectional data on one pin (with a clock signal on another).
  #5   Spotlight this post!  
Unread 21-09-2004, 23:52
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Dynamic Input/Output Changing

Quote:
Originally Posted by Paolo
Has anyone made a bi-direction bus using the I/Os on the Robot Controller? That is, has anybody dynamically changed I/Os from input to output using software control?
Yes, this is pretty common function. You might look into using a state-machine to keep track of what direction the pins should be in at any given time.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #6   Spotlight this post!  
Unread 23-09-2004, 18:24
Paolo's Avatar
Paolo Paolo is offline
Registered User
FRC #1351 (AMHS Robotics)
Team Role: Mechanical
 
Join Date: Sep 2004
Rookie Year: 2004
Location: California
Posts: 4
Paolo is an unknown quantity at this point
Re: Dynamic Input/Output Changing

We already knew that it was possible on the PIC. We knew how to do it in assembly. Can anyone tell me how to do it in C?
  #7   Spotlight this post!  
Unread 23-09-2004, 19:09
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: Dynamic Input/Output Changing

Quote:
Originally Posted by Paolo
We already knew that it was possible on the PIC. We knew how to do it in assembly. Can anyone tell me how to do it in C?
I already did:

Quote:
Originally Posted by Rickertsen2
Again to make things easier to remember IFI has provided a set of logically named aliases for you (rc_dig_out01 - rc_dig_out18). Again these are direct aliases and map directly to different bits of different LAT registers.
Just write to these variables to change the direction.
__________________
1139 Alumni
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
Changing 1 joystick code to 2 (rookie team) Brawler006 Programming 5 20-02-2004 17:00
Changing Fields? Steve W Championship Event 8 08-04-2003 19:37
Changing the Elim. Format... Joe Johnson General Forum 46 08-04-2003 12:27
Changing the face of the game.. archiver 2000 19 23-06-2002 22:10
changing my name Travis Covington CD Forum Support 1 09-10-2001 08:37


All times are GMT -5. The time now is 03:58.

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