Go to Post Is it really that bad to ask a team to be able to do more than just drive? It's like asking a student to do more than just show up to class... - Katie_UPS [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 21-01-2017, 19:03
zDrakon zDrakon is offline
Registered User
FRC #3501
 
Join Date: Feb 2015
Location: Sunnyvale
Posts: 12
zDrakon is an unknown quantity at this point
Arduino & Roborio cant find each other I2C Issues

code: http://pastebin.com/9uq4S2dQ

Okay, so I'm trying to scan through all the possible addresses that the arduino could be from both Roborio (our code here) and Arduino (Arduino used I2C scanner code: http://playground.arduino.cc/Main/I2cScanner)

We have verified the wiring of the arduino is correctly wired with A4 and A5 connected to the I2C and ground and power to the I2C port of roborio.

Both devices can't find each other.

Anyone have a solution to make both devices find each other?

(Strangely enough we can have Roborio send data to Arduino and Arduino read it but the Arduino can't successfully send data to the roborio with the Roborio giving a response like a System.out.println() in the DriverStation console)
Reply With Quote
  #2   Spotlight this post!  
Unread 21-01-2017, 22:16
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,590
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Arduino & Roborio cant find each other I2C Issues

Is your arduino configured as a slave?
Reply With Quote
  #3   Spotlight this post!  
Unread 21-01-2017, 22:40
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 377
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Arduino & Roborio cant find each other I2C Issues

Quote:
Originally Posted by zDrakon View Post
(Strangely enough we can have Roborio send data to Arduino and Arduino read it but the Arduino can't successfully send data to the roborio with the Roborio giving a response like a System.out.println() in the DriverStation console)
Congrats, you've correctly set up the Arduino as a slave 🎉
In I2C, slaves can only send data for a transaction, not any time they want. For Arduino, that means you can only write in the onRequest handler function, and only the number of bytes the master expects. On the roboRIO side, you need to call I2C.transaction()
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
Reply With Quote
  #4   Spotlight this post!  
Unread 21-01-2017, 23:56
avayner avayner is offline
Registered User
FRC #3501
 
Join Date: Jan 2017
Location: Sunnyvale, CA
Posts: 4
avayner is an unknown quantity at this point
Re: Arduino & Roborio cant find each other I2C Issues

We've done exactly that, but for some reason onRequest was not being triggered... Any ideas how to troubleshoot this?
Reply With Quote
  #5   Spotlight this post!  
Unread 22-01-2017, 00:47
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 377
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Arduino & Roborio cant find each other I2C Issues

Quote:
Originally Posted by avayner View Post
We've done exactly that, but for some reason onRequest was not being triggered... Any ideas how to troubleshoot this?
Could you post the code you're using (roborio and arduino)?
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
Reply With Quote
  #6   Spotlight this post!  
Unread 22-01-2017, 01:47
zDrakon zDrakon is offline
Registered User
FRC #3501
 
Join Date: Feb 2015
Location: Sunnyvale
Posts: 12
zDrakon is an unknown quantity at this point
Re: Arduino & Roborio cant find each other I2C Issues

Roborio code: http://pastebin.com/TiFcYq6L

Arduino: http://pastebin.com/TDPk9W5i

Do keep in mind we did try using onREquest for arduino and set it up as a slave prior but for some reason it didnt work. My team is confused, even the mentor is having trouble explaining what's happening.
Reply With Quote
  #7   Spotlight this post!  
Unread 22-01-2017, 15:55
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 377
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Arduino & Roborio cant find each other I2C Issues

I see. Try this

roboRIO:
Code:
static I2C arduino = new I2C(Port.kOnboard, 42);

@Override
public void teleopPeriodic() {
    byte[] sendData = "sample text".getBytes();
    byte[] receiveData = new byte[sendData.length];
    boolean failed = arduino.transaction(sendData, sendData.length, receiveData, receiveData.length);
    if(!failed) {
        System.out.println("Got data: " + new String(receiveData, 0, receiveData.length);
    }
}
Arduino:
Code:
#include <Wire.h>

void setup() {
  Wire.begin(42);
  Wire.onRequest(requestEvent);
  Serial.begin(9600);
}

void loop() {
  delay(100);
}

// send back the same data as we receive
void requestEvent() {
  Serial.println("Got request:");
  while (Wire.available()) {
    char c = Wire.read();
    Serial.print(c);
    Wire.write(c);
  }
}
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
Reply With Quote
  #8   Spotlight this post!  
Unread 27-01-2017, 22:52
Harp Harp is offline
Registered User
FRC #3501
 
Join Date: Jan 2017
Location: Sunnyvale
Posts: 1
Harp is an unknown quantity at this point
Re: Arduino & Roborio cant find each other I2C Issues

The Arduino didn't read anything from the roborio using this code. We've since switched to using a raspberry pi
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 13:15.

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