User Tools

Site Tools


roborio_digital_io

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
roborio_digital_io [2018/01/22 16:39] – created tellroborio_digital_io [2018/12/11 22:31] (current) – [Selecting from among more than two alternatives] tell
Line 1: Line 1:
 On this page we'll describe the 10 "DIO" Digital I/O connections on the RoboRIO.   On this page we'll describe the 10 "DIO" Digital I/O connections on the RoboRIO.  
 +{{ :roborio-dio.jpg?nolink&250|}}
  
 ====== Introduction ====== ====== Introduction ======
Line 30: Line 31:
 When configured as an output, the signal pin is driven to 0 volts for a "zero", and 3.3 volts for a "one" More on outputs later. When configured as an output, the signal pin is driven to 0 volts for a "zero", and 3.3 volts for a "one" More on outputs later.
  
-When acting as an input, the RoboRIO interprets any voltage between 0 and 0.8v ad a "zero", and a voltage between 2.0v and 5.5v as a "one."  A voltage in between those ranges +When acting as an input, the RoboRIO interprets the voltage seen on the "Signal" pin as: 
-results in either a zero or a one being delivered to the software program.+  * any voltage between 0 and 0.8v is a "zero" 
 +  * a voltage between 2.0v and 5.5v a "one." 
 +  A voltage in between those ranges results in either a zero or a one being delivered to the software program.  We generally want to avoid this indeterminate region.
  
-There is a "pullup" or "pulldown" resistor internal to the RoboRIO that helps ensure that the voltage on a disconnected DIO does not drift into that "unknown" region.  For the ten basic DIOs on the RoboRIO, it is a pullup, so an unconnected DIO will be read by software as a "one".+There is a "pullup" or "pulldown" resistor internal to the RoboRIO that helps ensure that the voltage on a disconnected DIO does not drift into that "unknown" region.  For the ten basic DIOs on the RoboRIO, the resistor is a pullup, so an unconnected DIO will be read by software as a "one".
  
-To cause a DIO to be read as "zero" by software, all we have to do is connect the signal pin to ground, for example with a switch.+So, to cause a DIO to be read as "zero" by software, all we have to do is connect the signal pin to ground, for example with a switch
 + 
 +{{ :pwm-switch-cable.png?400 |}}
  
-[picture needed] 
  
 ====== Software ====== ====== Software ======
  
 Here's a Java code fragment: Here's a Java code fragment:
-''+<code java>
  package edu.wpi.first.wpilib.templates;  package edu.wpi.first.wpilib.templates;
  
Line 68: Line 72:
   }   }
  }  }
-''+</code> 
 + 
 + 
 +Notice somthing there that is true of most simple test programs:  there's a whole lot more "java stuff" then there is specifics about what we're trying to do.  There are really only two interesting lines.  The first one is: 
 +    mySwitch = new DigitalInput(1); 
 + 
 +This creates an object which represents our DIO pin in software.  The "1" in DigitalInput(1), means that its 
 +associtated with DIO number 1. 
 + 
 +The other interesting line is: 
 +    switch_now = mySwitch.get(); 
 +which reads the current state of the DIO and stores it in a boolean variable called ''switch_now''
 +We can then use switch_now in an ''if()'' or other statements. 
 + 
 + 
 + 
 + 
  
  
Line 77: Line 98:
  
  
 +
 +
 +What if we want to select between more than two choices?   See "fun with switches" on the page [[Switches as Digital IO]]
  
 ====== Conclusion ====== ====== Conclusion ======
 +
  
 This discussion also applies to the 16 additional DIO pins located on the roborio expansion connector. This discussion also applies to the 16 additional DIO pins located on the roborio expansion connector.
  
  
roborio_digital_io.1516657160.txt.gz · Last modified: 2018/01/22 16:39 by tell