|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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) |
|
#2
|
||||||
|
||||||
|
Re: Arduino & Roborio cant find each other I2C Issues
Is your arduino configured as a slave?
|
|
#3
|
||||
|
||||
|
Re: Arduino & Roborio cant find each other I2C Issues
Quote:
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() |
|
#4
|
|||
|
|||
|
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?
|
|
#5
|
||||
|
||||
|
Re: Arduino & Roborio cant find each other I2C Issues
Could you post the code you're using (roborio and arduino)?
|
|
#6
|
|||
|
|||
|
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. |
|
#7
|
||||
|
||||
|
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);
}
}
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);
}
}
|
|
#8
|
|||
|
|||
|
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
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|