Go to Post Several really good programming and control specialists haunt CD, but a thread titled "motor failure" might not attract their notice soon. - Richard Wallace [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 20-02-2016, 16:39
alambert14's Avatar
alambert14 alambert14 is offline
Student Programmer
AKA: Abby Lambert
FRC #2035 ("Rockin" Bots)
Team Role: Programmer
 
Join Date: Apr 2014
Rookie Year: 2014
Location: Carmel
Posts: 14
alambert14 is an unknown quantity at this point
Lightbulb Arduino Ethernet with roboRIO

2 years back, one of our mentors helped us to use network tables to have the cRIO talk to our Arduino Ethernet for controlling LEDs. We abandoned the project last year due to time, but this year we were hoping to have the same Arduino talk to the roboRIO, but we have not been able to find out how to do it, even after doing extensive research. Our java code can read the serial outputs from the Arduino, but we do not know how to have the Arduino read from our java code (we hope to have different LED patterns for certain situations such as autonomous or which alliance we are on).

If any of you guys have been able to do this with the roboRIO, help would be appreciated! Thanks.
__________________
Reply With Quote
  #2   Spotlight this post!  
Unread 21-02-2016, 09:20
pblankenbaker pblankenbaker is offline
Registered User
FRC #0868
 
Join Date: Feb 2012
Location: Carmel, IN, USA
Posts: 102
pblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of light
Re: Arduino Ethernet with roboRIO

We don't have any experience using a Ethernet interface on an Arduino for command and control. However, we are using a Arduino this year to control LEDs as well. Our implementation is fairly simple. We have 4 separate LED patterns which our Arduino can run. To tell the Arduino which pattern to show, we connected two digital outputs from the roboRIO to digital inputs on the Arduino.

The Arduino just monitors the digital inputs to see which LED pattern to show.

We just use two DigitalOutput objects on the roboRIO side to tell the Arduino which pattern we want it to display.

It's not the most sophisticated system, but it works well and is simple to implement when it's late in the season and you want to get your LEDs lit.

Good Luck.
Reply With Quote
  #3   Spotlight this post!  
Unread 21-02-2016, 22:48
lsato808 lsato808 is offline
Registered User
FRC #1056
 
Join Date: Jan 2016
Location: Hawaii
Posts: 1
lsato808 is an unknown quantity at this point
Re: Arduino Ethernet with roboRIO

Quote:
Originally Posted by pblankenbaker View Post
We don't have any experience using a Ethernet interface on an Arduino for command and control. However, we are using a Arduino this year to control LEDs as well. Our implementation is fairly simple. We have 4 separate LED patterns which our Arduino can run. To tell the Arduino which pattern to show, we connected two digital outputs from the roboRIO to digital inputs on the Arduino.

The Arduino just monitors the digital inputs to see which LED pattern to show.

We just use two DigitalOutput objects on the roboRIO side to tell the Arduino which pattern we want it to display.

It's not the most sophisticated system, but it works well and is simple to implement when it's late in the season and you want to get your LEDs lit.

Good Luck.
How did you code this on the arduino side? Is it some kind of if statement? and if so how did you address it?

Thanks in advance.
Reply With Quote
  #4   Spotlight this post!  
Unread 22-02-2016, 08:53
pblankenbaker pblankenbaker is offline
Registered User
FRC #0868
 
Join Date: Feb 2012
Location: Carmel, IN, USA
Posts: 102
pblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of light
Re: Arduino Ethernet with roboRIO

I didn't actually write the code on the LED side (we have a lot of kids on the team and gave that task to a group of them).

However, I'm pretty sure the following code fragment demonstrates how to detect the current LED mode (4 choices: 0, 1, 2 and 3) and whether the mode has just changed:

Code:
// Change to the I/O pins you used
// to connect your Arduino to your roboRIO
int ledControl0 = 8;
int ledControl1 = 9;

// Current LED operating mode
int curMode = -1;

void setup() {
  // Set up I/O pins for LED control as inputs
  pinMode(ledControl0, INPUT);
  pinMode(ledControl1, INPUT);
}

void loop() {
  // Assume no LED mode change
  int modeChanged = 0;
  // Start with mode 0
  int mode = 0;
  if (digitalRead(ledControl0)) {
    // Control line 0 set, add 1 to mode (set bit 1 in mode)
    mode = mode + 1;
  }
  if (digitalRead(ledControl1)) {
    // Control line 1 set, add 2 to mode (set bit 2 in mode)
    mode = mode + 2;
  }

  // Check to see if mode changed since last check
  if (mode != curMode) {
    curMode = mode;
    modeChanged = 1;
  }

  // At this point, curMode will be a value of 0, 1, 2 or 3
  // and modeChanged will be 1 if the mode has changed from
  // last invocation or 0 if it is the same as last time 

  // Add your code below to set your LED display output
  // accordingly ...

}
Hope that helps.
Reply With Quote
Reply


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 08:20.

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