Digital Inputs/Outputs and Accelerometer WPI Robotics Library

Digital inputs
Digital inputs are generally used for controlling switches. The WPILib DigitalInput object is typically used to get the current state of the corresponding hardware line: 0 or 1. The digital inputs are more complex such as encoders or counters, are handled by using the appropriate classes. Using these other supported device types (encoder, ultrasonic rangefinder, gear tooth sensor, etc.) doesn’t require a digital input object to be created. The lines of digital input are shared from the 14 GPIO lines on each Digital Breakout Board. Creating an example of a DigitalInput object will automatically set the direction of the line to input.

The lines of digital input have pull-up resistors so an unconnected input will naturally be high. If a switch is contacted to the digital input it should connect to ground when closed. The switch open state will be 1 and the closed state will be 0. In Java, digital input values are true and false. So an open switch is true and a closed switch is false.

Digital Outputs
Typically digital outputs are used to run indicators or to interface with other electronics. The digital outputs provide the 14 GPIO lines on each Digital Breakout Board. Creating an example of a DigitalOutput object will automatically set the direction of the GPIO line to output. In C++, digital output values are 0 and 1 representing high (5V) and low (0V) signals. In Java, the digital output values are true (5V) and false (0V).

Accelerometer
The two-axis accelerometer given in the kit of parts is a two-axis accelerometer. This device can offer acceleration data in the X and Y axes relative to the circuit board. In the WPI Robotics Library you treat it as two separate devices, one for the X axis and the other for the Y axis. This provides better performance if your application only needs to use one axis. The accelerometer can be used as a tilt sensor – actually measuring the acceleration of gravity.

No comments:

Post a Comment