View Single Post
  #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,059
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.