|
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
|