|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools |
Rating:
|
Display Modes |
|
#1
|
|||
|
|||
|
Using an Arduino w/ a RoboRIO
Apologies if this is under the wrong section, but I had a question about connecting an Arduino to a RoboRIO.
As of now, my team is using an Arduino (primarily for some timing specific WS2182b LED Strips) that is connected to the RoboRIO via Serial over USB, but we've been having some issues with getting serial communication to work properly between the two devices. The serial libraries in WPILib on the RoboRIO do not seem to send data to the Arduino reliably (even when the flush method is called) and the serial link has (on occasion) held up the entire robot (I believe it was when disabling the robot). Additionally, the serial link sometimes doesn't send data over when the appropriate method is called, but instead sends over everything in a short burst right as the robot is being disabled. I was wondering if any teams have managed to get Serial to work properly on the RoboRIO to communicate with the Arduino. If not, does anyone have any other suggestions as to how to interface the Arduino and the RoboRIO? We choose this method of communication as it's relatively simple to wire (one wire for power and signal), but I know i2C is an option (though I've heard/read mixed reports about i2C on the RoboRIO) and as is a simple one way two or three pin connection to some relay pin. There's also SPI. Thanks in advance. Last edited by rbhl : 31-03-2015 at 12:59. Reason: SPI |
|
#2
|
|||
|
|||
|
Re: Using an Arduino w/ a RoboRIO
You can connect an Arduino to the roboRio's MXP port using devices like this one:
http://www.revrobotics.com/product/rioduino/ That's probably the most straightforward. |
|
#3
|
|||
|
|||
|
Re: Using an Arduino w/ a RoboRIO
I kind of want to avoid using a RIOduino just because of the additional cost (additionally, I'd rather keep the MXP port open in case we need it for other expansions later). Thanks, though.
Does RevRobotics provide any code for communication between their board and the RoboRIO? Their product page mentions that communication can be achieved through i2C and UART (Serial), but they do not elaborate. |
|
#4
|
||||
|
||||
|
Re: Using an Arduino w/ a RoboRIO
We spent quite a while trying to get our arduino to read serial communication, but were unable to do so. In the meantime, we began generating our own PWM pulse from a DIO port on the roboRIO, and reading it from a DI slot on the arduino. This is working well enough for us, but it is a little cumbersome. We will be exploring alternatives (SPI, I2C, etc...) over the offseason.
We use Java, and generate our signal from the roboRIO with the DigitalOutput class from WPILib. Specifically, we use the enablePWM, setPWMRate, and updateDutyCycle methods. We use a 1000Hz rate to get 8-bit output resolution. On the arduino, we simply use the pulseIn() method, and multiply this value by a constant to get our transmitted byte. We don't transmit any information back to the roboRIO from the arduino. This method hasn't given us spectacular resolution, but it has been good enough for our purposes. For example, the arduino reads anything between 231 and 233 when we transmit 232 from roboRIO. If you need to transmit more than 7 bits of information, or read information from the arduino. I do not recommend this method. |
|
#5
|
|||
|
|||
|
Re: Using an Arduino w/ a RoboRIO
Our team experimented with getting the Arduino (driving an LED light string from AdaFruit) talking to the RoboRIO, but did not have enough time during build season to have it installed on the final robot. I wasn't directly involved so I don't know whether we used the RIOduino... I will find out and get back to the thread.
Is TCP/UDP not an option? |
|
#6
|
|||
|
|||
|
Re: Using an Arduino w/ a RoboRIO
What are you trying to use the LEDs for on your robot?
|
|
#7
|
|||
|
|||
|
Re: Using an Arduino w/ a RoboRIO
We, Team 1258, used an Arduino last season to measure the distance from the target to shoot the big ball. It worked very well. It started when we were getting flakey (inaccurate) distance readings from the analog output of the Maxbotix sonar module. We wanted to measure 8 feet ... consistently and accurately for our autonomous and to assist the operator during teleop.
We mounted the Arduino and Maxbotix module in a sturdy polycarb box and powered it from a 12v branch circuit. The box was oriented toward the front of the robot. We gave up on the Maxbotix analog output and, instead, used the serial output. That complicated the Arduino code a bit but we began to get very accurate distance readings. You connect the Maxbotix serial TX output to the Arduino's RX input or pin 0. Then we used softserial for the Arduino. Please understand that other teams claimed to get very accurate Maxbotix distance readings from the analog output. They simply connect it to the analog input of the cRIO or roboRIO and they are good to go. We did not have that experience so we used the serial output instead. When the Arduino/Maxbotix read 8 ft, it would raise the Arduino digital I/O pin ( I choose pin 4) to high. This pin was connected to one of the cRIO's (last season, right?) digital I/O inputs, DIO1. Very important: connect the Arduino ground to the Maxbotix ground then to the DIO ground. I believe the software team created a task in the robot code to keep track of that pin, DIO 1, to "know" when the robot was 8 ft from the target for shooting the ball. We also controlled some lights (old cold cathode lights from ? 2006 target) to light when 8 ft was reached. We used Spikes to control the lights. Note: they are not LEDs. Also note that I am not on the software team. I wrote only the Arduino code. It is very easy to add an Arduino or any other small single board computer to the robot. roboRIO connections would be the same. Be sure that all the grounds are common or connected together. No need to connect them to the 12v bus negative. Just to the roboRIO and any sensors like the Maxbotix. The advantages of this setup are: 1. very simple communication between sensor (Maxbotix sonar) and robot controller, 2. off loads cpu cycles by keeping the Arduino busy rather than the cRIO (or roboRIO), 3. creates a module that can be moved from robot to robot in the coming seasons, 4. cheap parts and easy to purchase from multiple sources, 5. doesn't require the MXP port but our plan is to get acquainted with it for the future and lastly, 6. we won the Innovation in Control award at our first competition. I would be happy to share the Arduino code. Also, I would be interested in similar ideas that you are willing to share. -Larry Team 1258 electrical mentor |
|
#8
|
|||
|
|||
|
Re: Using an Arduino w/ a RoboRIO
RUSH attempted to use an arduino to aggregate sensor data this build season. Unfortunately, the roborio is documented to not support communication over Serial USB to an arduino, although it does support axis cameras. Other means of communication are an option, but it limits you from testing the code on both sides (labview/c++/java and Arduino C) from a computer.
|
|
#9
|
||||
|
||||
|
Re: Using an Arduino w/ a RoboRIO
We had not fully tried this yet, but the path we were taking was to uses the roborio master I2C and talk to the arduino as an I2C slave. That is the off season activity for our programmers.
|
|
#10
|
|||
|
|||
|
Re: Using an Arduino w/ a RoboRIO
Serial between the roboRIO won't be possible because the arduino UNO works on 5v logic and the roboRiO is 3.3v logic from the MXP or 12/-12v logic from the dedicate RS232 port. A logic translator will be needed to convert the 3.3v to 5v. You can find them at adafruit.
Last edited by gvbravo : 01-04-2015 at 20:14. |
|
#11
|
|||
|
|||
|
Re: Using an Arduino w/ a RoboRIO
WildStang has been using I2C for several years now, both with the cRio and the roborio. We use it to communicate with an Arduino (several, actually) that control LEDs and aggregate sensor data. We've found that I2C is very robust and reliable.
|
|
#12
|
|||
|
|||
|
Re: Using an Arduino w/ a RoboRIO
We used a Pololu A-Star 32U4 Micro (essentially an Arduino Leonardo) with our LEDs this year, and fed data to it from the serial port on the MXP without a level shifter (not actually necessary in this case). We only connected TX from the RoboRIO to RX on the Arduino, it was not bidirectional.
I don't know exactly how they coded it on the RoboRIO, but it just spit out a single byte every time it ran through the control loop and never had any of the issues you mentioned. |
|
#13
|
|||
|
|||
|
Re: Using an Arduino w/ a RoboRIO
gvbravo makes a good point about the roboRIO being a 3V3 device that expects a maximum voltage of 3.3 volts to be applied to a DIO or digital I/O pin. In my article above using the Arduino with a Maxbotix sonar, I mentioned that you would connect the Arduino output to the cRIO digital input - ok, no problem or to a roboRIO digital input - NOT ok. Do not directly connect an Arduino output to a roboRIO input.
The Arduino is a 5v device so a digitial output will be close to 5v and may destroy the roboRIO input. As mentioned, you can purchase a level shifter that converts the 5v and 3.3v levels. An alternative that works in this case is to use a voltage divider between the Arduino output pin and the roboRIO input pin. A web search will turn up many examples of this circuit. I used a 100 and 200 ohm resistor in series that divided the 5v by 2/3 = 3.3v. Calculated: 5v x (200/100+200) = 3.3v. Also mentioned above is to connect the Arduino to the roboRIO using I2C. In my example above, this would be overkill because I only wanted to tell the robot controller that the Arduino/Maxbotix "says" the 8 ft distance has been confirmed. However, I2C is an effective solution especially when your Arduino has a lot of data to send and receive from the roboRIO. Again, take care connecting devices to the roboRIO. -Larry |
|
#14
|
|||
|
|||
|
Re: Using an Arduino w/ a RoboRIO
Quote:
https://decibel.ni.com/content/docs/DOC-30419 According to the specifications PDF, the digital I/O is 5V-tolerant and the maximum voltage you can apply to an input is 5.25 volts. |
|
#15
|
|||
|
|||
|
Re: Using an Arduino w/ a RoboRIO
It's probably good practice to design your circuit to respect the nominal voltage levels anyway. Not all boards are going to be as tolerant!
(don't ask me how I know) |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|