Go to Post Our team has one goal: be ourselves. - PayneTrain [more]
Home
Go Back   Chief Delphi > Technical > Electrical
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 31-03-2015, 12:54
rbhl rbhl is offline
Registered User
no team
 
Join Date: Mar 2015
Location: Home.
Posts: 2
rbhl is an unknown quantity at this point
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   Spotlight this post!  
Unread 31-03-2015, 13:00
GreyingJay GreyingJay is offline
Robonut
AKA: Mr. Lam
FRC #2706 (Merge Robotics)
Team Role: Mentor
 
Join Date: Mar 2015
Rookie Year: 2015
Location: Ottawa, Canada
Posts: 778
GreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond repute
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   Spotlight this post!  
Unread 31-03-2015, 13:16
rbhl rbhl is offline
Registered User
no team
 
Join Date: Mar 2015
Location: Home.
Posts: 2
rbhl is an unknown quantity at this point
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   Spotlight this post!  
Unread 31-03-2015, 13:19
Caleb Sykes's Avatar
Caleb Sykes Caleb Sykes is offline
Registered User
FRC #4536 (MinuteBots)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2009
Location: St. Paul, Minnesota
Posts: 1,054
Caleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond repute
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   Spotlight this post!  
Unread 31-03-2015, 14:08
GreyingJay GreyingJay is offline
Robonut
AKA: Mr. Lam
FRC #2706 (Merge Robotics)
Team Role: Mentor
 
Join Date: Mar 2015
Rookie Year: 2015
Location: Ottawa, Canada
Posts: 778
GreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond repute
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   Spotlight this post!  
Unread 31-03-2015, 16:34
Skooks Skooks is offline
Registered User
FRC #4388
 
Join Date: Mar 2015
Location: Fort Collins Colorado
Posts: 2
Skooks is an unknown quantity at this point
Re: Using an Arduino w/ a RoboRIO

What are you trying to use the LEDs for on your robot?
  #7   Spotlight this post!  
Unread 31-03-2015, 19:05
Larry R Larry R is offline
Registered User
FRC #1258
Team Role: Electrical
 
Join Date: Jan 2008
Rookie Year: 2005
Location: Kirkland, WA
Posts: 23
Larry R is on a distinguished road
Send a message via MSN to Larry R
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   Spotlight this post!  
Unread 31-03-2015, 19:22
jlmcmchl jlmcmchl is offline
FF - The Breakfast Company
AKA: Jordan McMichael
FRC #0027 (Team RUSH 27)
Team Role: Alumni
 
Join Date: Feb 2012
Rookie Year: 2011
Location: Clarkston,MI
Posts: 327
jlmcmchl has much to be proud ofjlmcmchl has much to be proud ofjlmcmchl has much to be proud ofjlmcmchl has much to be proud ofjlmcmchl has much to be proud ofjlmcmchl has much to be proud ofjlmcmchl has much to be proud ofjlmcmchl has much to be proud of
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.
__________________


Field reset: Kettering Kickoff ('13, '14), Kettering ('14, '15), Bedford ('14), Woodhaven ('16), Carver ('16), Einstein! ('16)
Referee: Bedford ('15), MARC ('15, '16), Kettering Kickoff ('15, '16), Kettering District (#1&2: '16), Troy ('16)
  #9   Spotlight this post!  
Unread 01-04-2015, 16:19
steinra's Avatar
steinra steinra is offline
(KG7KEO)
AKA: Randy Steiner
FRC #5461 (V.E.R.N.)
Team Role: Coach
 
Join Date: Nov 2008
Rookie Year: 2007
Location: Meridian, Idaho
Posts: 56
steinra is on a distinguished road
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.
__________________
Randy Steiner
2014-2015 FIRST Team 5461 - Coach
2011-2014 FIRST Team 4106 - Head Mentor
2007-2011 FIRST Team 1891 - Mentor
  #10   Spotlight this post!  
Unread 01-04-2015, 20:09
gvbravo gvbravo is offline
Registered User
FRC #5089
 
Join Date: Jan 2014
Location: Los Angeles
Posts: 2
gvbravo is an unknown quantity at this point
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   Spotlight this post!  
Unread 01-04-2015, 20:52
nathanwalters nathanwalters is offline
Registered User
FRC #0111 (WildStang)
Team Role: Alumni
 
Join Date: Dec 2011
Rookie Year: 2011
Location: United States
Posts: 75
nathanwalters has much to be proud ofnathanwalters has much to be proud ofnathanwalters has much to be proud ofnathanwalters has much to be proud ofnathanwalters has much to be proud ofnathanwalters has much to be proud ofnathanwalters has much to be proud ofnathanwalters has much to be proud of
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   Spotlight this post!  
Unread 02-04-2015, 13:25
CronusWorks CronusWorks is offline
Electronics Mentor
AKA: Chris
FRC #1076 (Pi Hi Samurai)
Team Role: Mentor
 
Join Date: Oct 2014
Rookie Year: 2014
Location: Michigan
Posts: 3
CronusWorks is just really niceCronusWorks is just really niceCronusWorks is just really niceCronusWorks is just really niceCronusWorks is just really nice
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   Spotlight this post!  
Unread 02-04-2015, 13:52
Larry R Larry R is offline
Registered User
FRC #1258
Team Role: Electrical
 
Join Date: Jan 2008
Rookie Year: 2005
Location: Kirkland, WA
Posts: 23
Larry R is on a distinguished road
Send a message via MSN to Larry R
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   Spotlight this post!  
Unread 02-04-2015, 14:10
CronusWorks CronusWorks is offline
Electronics Mentor
AKA: Chris
FRC #1076 (Pi Hi Samurai)
Team Role: Mentor
 
Join Date: Oct 2014
Rookie Year: 2014
Location: Michigan
Posts: 3
CronusWorks is just really niceCronusWorks is just really niceCronusWorks is just really niceCronusWorks is just really niceCronusWorks is just really nice
Re: Using an Arduino w/ a RoboRIO

Quote:
Originally Posted by Larry R View Post
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
This is definitely best practice, but according to the documentation, not actually necessary.
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   Spotlight this post!  
Unread 02-04-2015, 15:18
GreyingJay GreyingJay is offline
Robonut
AKA: Mr. Lam
FRC #2706 (Merge Robotics)
Team Role: Mentor
 
Join Date: Mar 2015
Rookie Year: 2015
Location: Ottawa, Canada
Posts: 778
GreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond repute
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)
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:33.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi