Go to Post Most teachers are not in it for the income, But they are definitely in it for the outcome. - Bob Steele [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 03-21-2010, 03:21 AM
ay2b's Avatar
ay2b ay2b is offline
Registered User
AKA: Andy
FRC #2928
Team Role: Mentor
 
Join Date: Mar 2004
Rookie Year: 1994
Location: Seattle, WA
Posts: 210
ay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant future
Swapping digital input/output

I have a sensor which I would like to use which requires swapping a pin between input and output. Basically you set the pin to output/high, charge a capacitor, then set it to an input and time how long until the input reads low. Is there an easy way to do this with WPILib?

Based on my reading of the code, the current objects do not allow swapping the direction of a DIO pin. To change this would require modifying the DigitalModule class, probably cloning the AllocateDIO method to make a SetDIO method which would call m_fpgaDIO->writeOutputEnable to change the direction. Next I'd probably want a wrapper class which combines the DigitalInput and DigitalOutput classes. Finally I'd want a class similar to (or perhaps actually using) the Counter class which would have an interrupt on the falling edge to stop a timer which gets started on direction change.

Does this sound like the right track? Am I missing anything? Is there an easier way to do this? Has anyone else done this already?

Thanks.
__________________

2011 - SD Quarterfinalists (980), LA Quarterfinalists (980)
2010 - LA (2404) Finalists (980), AZ Motorola Quality (980)
2009 - LA Semifinalists (980); Las Vegas Quarterfinalists (980); SD (2404); IRI #1 Seed, Finalist (980)
2008 - SD Quarterfinalists (980), LA Champions (980), LA Rookie Inspiration Award (2404); CalGames Finalists
2007 - So.Cal Finalists (980), SD Quarterfinalists (980); CalGames Finalists
2006 - So.Cal Regional Champion (4), Toronto Judge's Award Day 1 (4)
2005 - SVR Champions, Delphi "Driving Tomorrow's Technology" (980); AZ Xerox Creativity (980); So.Cal Finalists, RadioShack Innovation in Control (980); Championship Archimedes Division Semifinalists; IRI Finalists (980)
2004 - So.Cal Regional Champions, Leadership in Controls (980); AZ GM Industrial Design (980); Championship Galileo Division #2 Seed; IRI Champions
2003 - PNW Semi-finalists (488)
2002 - PNW Finalists (488)
2000 - X-bot / 488 - Mentor / Founder
1994 - Sunny Delight - Driver - champion
Reply With Quote
  #2   Spotlight this post!  
Unread 03-21-2010, 03:52 AM
ay2b's Avatar
ay2b ay2b is offline
Registered User
AKA: Andy
FRC #2928
Team Role: Mentor
 
Join Date: Mar 2004
Rookie Year: 1994
Location: Seattle, WA
Posts: 210
ay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant future
Re: Swapping digital input/output

I just thought of this:

Maybe the Ultrasonic class, two I/O pins and a diode would solve the problem: Charge the cap through a diode from an output pin. This corresponds to the "ping" in the Ultrasonic class. When the output pin goes low, the diode prevents the cap from being discharged by the output pin, and the input pin can be used to measure the discharge rate.

Thoughts?
__________________

2011 - SD Quarterfinalists (980), LA Quarterfinalists (980)
2010 - LA (2404) Finalists (980), AZ Motorola Quality (980)
2009 - LA Semifinalists (980); Las Vegas Quarterfinalists (980); SD (2404); IRI #1 Seed, Finalist (980)
2008 - SD Quarterfinalists (980), LA Champions (980), LA Rookie Inspiration Award (2404); CalGames Finalists
2007 - So.Cal Finalists (980), SD Quarterfinalists (980); CalGames Finalists
2006 - So.Cal Regional Champion (4), Toronto Judge's Award Day 1 (4)
2005 - SVR Champions, Delphi "Driving Tomorrow's Technology" (980); AZ Xerox Creativity (980); So.Cal Finalists, RadioShack Innovation in Control (980); Championship Archimedes Division Semifinalists; IRI Finalists (980)
2004 - So.Cal Regional Champions, Leadership in Controls (980); AZ GM Industrial Design (980); Championship Galileo Division #2 Seed; IRI Champions
2003 - PNW Semi-finalists (488)
2002 - PNW Finalists (488)
2000 - X-bot / 488 - Mentor / Founder
1994 - Sunny Delight - Driver - champion
Reply With Quote
  #3   Spotlight this post!  
Unread 03-21-2010, 02:21 PM
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,547
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: Swapping digital input/output

Quote:
Originally Posted by ay2b View Post
I have a sensor which I would like to use which requires swapping a pin between input and output. Basically you set the pin to output/high, charge a capacitor, then set it to an input and time how long until the input reads low. Is there an easy way to do this with WPILib?
Last year, switching I/O directions caused a delay in all DIO. See http://forums.usfirst.org/showthread.php?t=10460

Not sure if anything changed for this year.
Reply With Quote
  #4   Spotlight this post!  
Unread 03-21-2010, 05:32 PM
EricVanWyk EricVanWyk is offline
Registered User
no team
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Boston
Posts: 1,597
EricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond repute
Send a message via AIM to EricVanWyk
Re: Swapping digital input/output

Quote:
Originally Posted by ay2b View Post
I just thought of this:

Maybe the Ultrasonic class, two I/O pins and a diode would solve the problem: Charge the cap through a diode from an output pin. This corresponds to the "ping" in the Ultrasonic class. When the output pin goes low, the diode prevents the cap from being discharged by the output pin, and the input pin can be used to measure the discharge rate.

Thoughts?
Sounds like you are on the right track to me. Personally, I'd use a FET instead of a diode to eliminate the .6V, but it likely doesn't matter.

Out of curiosity, what sensor are you using? Datasheet link please!
Reply With Quote
Reply


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
DS Digital Input/Output dboisvert C/C++ 11 03-08-2009 05:50 PM
Digital Input? boris C/C++ 1 01-30-2009 02:51 PM
Switch digital input to output during operation? Parallax Ultrasonic wt200999 C/C++ 2 01-28-2009 07:30 PM
live input/output to/from application MarkH Programming 3 04-06-2006 01:43 AM
Dynamic Input/Output Changing Paolo Control System 6 09-23-2004 07:09 PM


All times are GMT -5. The time now is 01:56 AM.

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