View Single Post
  #3   Spotlight this post!  
Unread 20-02-2009, 12:41
oddjob oddjob is offline
Registered User
no team
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Earth
Posts: 118
oddjob is a splendid one to beholdoddjob is a splendid one to beholdoddjob is a splendid one to beholdoddjob is a splendid one to beholdoddjob is a splendid one to beholdoddjob is a splendid one to beholdoddjob is a splendid one to behold
Re: Using a GPIO pin for both input and output.

Our team used two cRIO pins for a Radio Shack "parallax" ultrasonic sensor. The cRIO output pin is wired through a small signal diode (e.g. 1n4148) to the sensor SIG pin. The diode cathode is oriented towards the SIG pin. Add a 1K resistor between SIG and ground (because there is a weak pull down on the SIG pin and the pull up in the cRIO will otherwise cause the SIG pin to go high when the sensor floats the pin). Wire SIG to a cRIO input pin. The diode serves to "remove" the cRIO output from the circuit when the output goes low and allow the sensor to drive the pin high and low. It a quick and dirty fix rather than adding a true isolation circuit, and the forward voltage drop is not important in this application.

Then write your own ultrasonic code so that it doesn't look for a high going pulse until the outgoing trigger is finished and returns to a low e.g. modify the existing source code like this:

Code:
void Ultrasonic_SIG::Ping() 
{ 
  // TODO: Either assert or disable, not both. 
  wpi_assert(!m_automaticEnabled); 
  SetAutomaticMode(false); // turn off automatic round robin if pinging single sensor 
  m_pingChannel->Pulse(kPingTime); // do the ping to start getting a single range 
  while(m_pingChannel->IsPulsing()) {}; // wait for the pulse to end 
  m_counter->Reset(); // reset the counter to zero (invalid data now) 
}
Or add your own method to the existing ultrasonic.cpp file, or create a new class that inherits the ultrasonic class, or however you prefer to modify the code.

It's a little complicated but we have our Parallax sensors working.
Reply With Quote