Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Question about I2C Communication (http://www.chiefdelphi.com/forums/showthread.php?t=133654)

ianespana 29-01-2015 12:34

Question about I2C Communication
 
Hello everyone.
I wanted to see if someone here knows how to set up I2C to connect to an Arduino.
Right now we've been able to write to the Arduino, but we have not found a way to read from it.
If anyone can help us, we'd appreciate it.

Alan Anderson 29-01-2015 13:44

Re: Question about I2C Communication
 
In what way is the I2C Read function failing to work for you?

ianespana 29-01-2015 14:08

RoboRIO can't read from the Arduino.
I tried switching between on-board and the MXP pins, but no luck so far

Alan Anderson 29-01-2015 14:16

Re: Question about I2C Communication
 
To have a good chance of figuring out what might be wrong, we'll need a whole lot more information about your system. Tell us what you're doing, exactly what you expect to happen, and exactly what happens instead. Be as specific and as detailed as possible. Don't summarize or leave out anything you might not think is important. Better to give us too much than too little.

Seeing your code would help. Seeing a picture of your wiring would be good too.

ianespana 29-01-2015 15:39

Question about I2C Communication
 
1 Attachment(s)
Quote:

Originally Posted by Alan Anderson (Post 1435714)
To have a good chance of figuring out what might be wrong, we'll need a whole lot more information about your system. Tell us what you're doing, exactly what you expect to happen, and exactly what happens instead. Be as specific and as detailed as possible. Don't summarize or leave out anything you might not think is important. Better to give us too much than too little.



Seeing your code would help. Seeing a picture of your wiring would be good too.


What we're trying to do is control a LED strip with an Arduino. The RoboRIO will send the Arduino an RGB value which will then be used to control the LED strip. At certain points controlled by us, the RoboRIO will "ask" the Arduino what it current RGB values are. This last bit is what we've been having trouble with, because the Arduino gets the message from the RIO, but when it sends the RGB values back the RIO doesn't read them. This is the receive code inside LabVIEW:
Attachment 18044
Note that we know the current address is 0, that was just for testing purposes.

At the moment I can't take a picture of the wiring.

Richard100 29-01-2015 16:26

Re: Question about I2C Communication
 
Would help to see your Arduino code as well.

ianespana 29-01-2015 18:19

Question about I2C Communication
 
This is our current Arduino code:

Code:


#include



void setup()

{

  Wire.begin(2); // join i2c bus (address optional for master)

}



byte x = 0;



void loop()

{

  Wire.write(x);              // sends one byte 

  x++;

  delay(500);

}


Alan Anderson 29-01-2015 22:55

Re: Question about I2C Communication
 
Where did you get that Arduino code? The examples I have seen for an Arduino I2C "slave" use the Wire.onRequest() method to register an event handler that sends the data.

ianespana 29-01-2015 23:31

Question about I2C Communication
 
Quote:

Originally Posted by Alan Anderson (Post 1435937)
Where did you get that Arduino code? The examples I have seen for an Arduino I2C "slave" use the Wire.onRequest() method to register an event handler that sends the data.


We took a "Master write" example from the
Arduino website and modified it a bit.
I hadn't thought about onRequest(). Maybe that's our mistake?

Alan Anderson 29-01-2015 23:41

Re: Question about I2C Communication
 
Quote:

Originally Posted by ianespana (Post 1435951)
We took a "Master write" example...

The roboRIO is the master. You need to use a "slave" example as your guide.

ianespana 29-01-2015 23:51

Quote:

Originally Posted by Alan Anderson (Post 1435962)
The roboRIO is the master. You need to use a "slave" example as your guide.


Right, I didn't think about that before.... I'll test it tomorrow and see what happens. Thanks for your help

ianespana 31-01-2015 14:03

Quote:

Originally Posted by Alan Anderson (Post 1435962)
The roboRIO is the master. You need to use a "slave" example as your guide.


Thanks for your help, we got I2C working.

prifken 03-04-2015 17:09

Re: Question about I2C Communication
 
Can you share your LabVIEW write I2c code as well?


All times are GMT -5. The time now is 08:46.

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