Skip to content

RoboRio Ports

li46554 edited this page Mar 18, 2024 · 11 revisions

What is a Roborio port?

The roboRIO is a mess of ports which all accept different voltages and communication standards. More information can be found here: [1]

RoboRIO ports From the NI roboRIO user Manual for FRC

From the NI roboRIO user Manual for FRC:

Digital Input/Output (DIO): Used for certain digital sensors, like limit switches or encoders (more about these later). R2-232 I2C port: Can be used with one of the NAVX gyros CAN (Controller Area Network) port: Used to power/signal TalonSRX's and the pneumatics control module Power connector: Gets wired to the Power Distribution Board USB device port: This port provides one way that the laptop can interface with the roboRIO (for loading code or driving the robot, for example). It is more reliable than the ethernet connection. This port is USBb female. USB Host Retention Mount: used for securing USB devices plugged into the RIO (like a camera, for instance). USB Host ports: used for interfacing the roboRIO with USB devices like a camera or the NAVX gyro Ethernet port: used for communicating with the wireless mesh radio or interfacing with the laptop (through an ethernet cord). Serial peripheral interface (SPI) bus: used for interfacing with certain sensors like the Gyro included in the Kit of Parts. LEDs for status:

The roboRIO’s FPGA supports up to 26 digital inputs. 10 of these are made available through the built-in DIO ports on the RIO itself, while the other 16 are available through the MXP breakout port.

Digital inputs read one of two states - “high” or “low.” By default, the built-in ports on the RIO will read “high” due to internal pull-up resistors (for more information, see Digital Inputs - Hardware). Accordingly, digital inputs are most-commonly used with switches of some sort. Support for this usage is provided through the DigitalInput class (Java, C++).

How to initialize digital input:

// Initializes a DigitalInput on DIO 0
DigitalInput input = new DigitalInput(0);

How to read the value of a digital input:

// Gets the value of the digital input.  Returns true if the circuit is open.
input.get();

How to create a Digital Input from an Analog trigger:

// Initializes an AnalogTrigger on port 0
AnalogTrigger trigger0 = new AnalogTrigger(0);

// Initializes an AnalogInput on port 1 and enables 2-bit oversampling
AnalogInput input = new AnalogInput(1);
input.setAverageBits(2);

// Initializes an AnalogTrigger using the above input
AnalogTrigger trigger1 = new AnalogTrigger(input);

How to set Trigger Points

To convert the analog signal to a digital one, it is necessary to specify at what values the trigger will enable and disable. These values may be different to avoid “dithering” around the transition point:

// Sets the trigger to enable at a raw value of 3500, and disable at a value of 1000
trigger.setLimitsRaw(1000, 3500);

// Sets the trigger to enable at a voltage of 4 volts, and disable at a value of 1.5 volts
trigger.setLimitsVoltage(1.5, 4);

How to limit the motion of a mechanism:

Spark spark = new Spark(0);

// Limit switch on DIO 2
DigitalInput limit = new DigitalInput(2);

public void autonomousPeriodic() {
    // Runs the motor forwards at half speed, unless the limit is pressed
    if(!limit.get()) {
        spark.set(.5);
    } else {
        spark.set(0);
    }
}

Clone this wiki locally