-
Notifications
You must be signed in to change notification settings - Fork 5
Communication with the RoboRIO
This page needs a bunch of detail, but here are some topics we can fill in
We did this on our 2017 robot (Helios) to allow the RoboRIO to change the Bling colors when the driver set the robot in "reverse" mode (where the controls operated backwards). It helped the driver know which way the robot should be moving by looking at it, and reduced mistakes due to the robot being in the wrong mode.
The technique is to set a special Digital I/O (DIO) pin on the RobotRIO as an output, and connect that to one of the Arduino digital pins as an input. The RoboRIO can set the pin as a high or low output, and the Arduino reads the pin as a 1 or 0 input. It can then choose different paths through the Bling code in response.
This is the easiest way to establish communications between the RoboRIO and the Arduino, but is also the most limited, as it only sends one bit of information (true or false). Multiple DIO pins could be connected to increase the number of "messages", but for anything more than a few "modes" this would become difficult to build and maintain.
When the Arduino is plugged in to the RoboRIO, it should present a "virtual" serial port to the RoboRIO software, so that it can send multi-byte messages to the Arduino. This is the same interface that your desktop computer uses to program the Arduino in the first place.
Since the RoboRIO environment is different than a desktop computer, this solution may not work the same as it does on a desktop. It looks like there are APIs to use the USB device as a "serial port". The good thing about USB is that it will provide power to run the Arduino, in addition to communications. This is a very promising interface method.
Links to useful information:
- http://first.wpi.edu/FRC/roborio/release/docs/java/edu/wpi/first/wpilibj/SerialPort.Port.html
- http://first.wpi.edu/FRC/roborio/release/docs/java/edu/wpi/first/wpilibj/SerialPort.html
- https://github.com/frc-88/2018-TestBot/blob/ab950bf32213690010f2e0aee4f2646cd015f2a4/src/org/usfirst/frc/team88/robot/subsystems/Lights.java
I2C is a serial message bus, which allows bytes of data to be sent in both directions. It uses two signal wires (a clock and a data signal), and requires a common ground connection between the devices. The RoboRIO controls the communications, and sends messages to the Arduino. Likewise, the RoboRIO can ask for responses (which could be useful if the Arduino has any sensors attached to it).
Links to useful information:
RS-232 is an asynchronous, point-to-point serial communication link. That means that the data is sent across the wires serially (like the I2C), but since it is asynchronous it does not require a separate clock line. Each wire carries data in one direction only, so there is one wire for messages from the RoboRIO to the Arduino, and another wire for messages coming back.
The Arduino is not electrically compatible with the RoboRIO RS-232 port, so some adapter hardware is needed in order to reduce the voltages used by the RoboRIO.
Links to useful information:
Most Arduino boards do not have a built-in Ethernet connection, but there are some add-on boards to provide the functionality. This can be a good way of connecting devices together (especially since the RoboRIO already uses Ethernet to communicate to the radio). Adding Ethernet to the Bling Arduino would allow it to be directly controlled from the driver station, which could be another added bonus.
This is probably the most complex way to send messages into a "bling" controller, but someday we should try it out.