Go to Post Glad to see the CIMulators aren't vaporware after all. - thefro526 [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
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 29-01-2015, 12:34
ianespana ianespana is offline
Registered User
no team
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Mexico
Posts: 11
ianespana is an unknown quantity at this point
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.

Last edited by ianespana : 29-01-2015 at 12:37.
Reply With Quote
  #2   Spotlight this post!  
Unread 29-01-2015, 13:44
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Question about I2C Communication

In what way is the I2C Read function failing to work for you?
Reply With Quote
  #3   Spotlight this post!  
Unread 29-01-2015, 14:08
ianespana ianespana is offline
Registered User
no team
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Mexico
Posts: 11
ianespana is an unknown quantity at this point
RoboRIO can't read from the Arduino.
I tried switching between on-board and the MXP pins, but no luck so far
Reply With Quote
  #4   Spotlight this post!  
Unread 29-01-2015, 14:16
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
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.
Reply With Quote
  #5   Spotlight this post!  
Unread 29-01-2015, 15:39
ianespana ianespana is offline
Registered User
no team
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Mexico
Posts: 11
ianespana is an unknown quantity at this point
Question about I2C Communication

Quote:
Originally Posted by Alan Anderson View Post
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:
Click image for larger version

Name:	ImageUploadedByTapatalk1422564178.563284.jpg
Views:	47
Size:	88.5 KB
ID:	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.

Last edited by ianespana : 29-01-2015 at 15:42.
Reply With Quote
  #6   Spotlight this post!  
Unread 29-01-2015, 16:26
Richard100 Richard100 is offline
Registered User
FRC #0836 (RoboBees)
Team Role: Mentor
 
Join Date: Nov 2009
Rookie Year: 2008
Location: Southern Maryland
Posts: 79
Richard100 is a splendid one to beholdRichard100 is a splendid one to beholdRichard100 is a splendid one to beholdRichard100 is a splendid one to beholdRichard100 is a splendid one to beholdRichard100 is a splendid one to behold
Re: Question about I2C Communication

Would help to see your Arduino code as well.
Reply With Quote
  #7   Spotlight this post!  
Unread 29-01-2015, 18:19
ianespana ianespana is offline
Registered User
no team
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Mexico
Posts: 11
ianespana is an unknown quantity at this point
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);

}

Last edited by ianespana : 29-01-2015 at 20:01.
Reply With Quote
  #8   Spotlight this post!  
Unread 29-01-2015, 22:55
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
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.
Reply With Quote
  #9   Spotlight this post!  
Unread 29-01-2015, 23:31
ianespana ianespana is offline
Registered User
no team
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Mexico
Posts: 11
ianespana is an unknown quantity at this point
Question about I2C Communication

Quote:
Originally Posted by Alan Anderson View Post
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?
Reply With Quote
  #10   Spotlight this post!  
Unread 29-01-2015, 23:41
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Question about I2C Communication

Quote:
Originally Posted by ianespana View Post
We took a "Master write" example...
The roboRIO is the master. You need to use a "slave" example as your guide.
Reply With Quote
  #11   Spotlight this post!  
Unread 29-01-2015, 23:51
ianespana ianespana is offline
Registered User
no team
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Mexico
Posts: 11
ianespana is an unknown quantity at this point
Quote:
Originally Posted by Alan Anderson View Post
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
Reply With Quote
  #12   Spotlight this post!  
Unread 31-01-2015, 14:03
ianespana ianespana is offline
Registered User
no team
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Mexico
Posts: 11
ianespana is an unknown quantity at this point
Quote:
Originally Posted by Alan Anderson View Post
The roboRIO is the master. You need to use a "slave" example as your guide.

Thanks for your help, we got I2C working.
Reply With Quote
  #13   Spotlight this post!  
Unread 03-04-2015, 17:09
prifken prifken is offline
Registered User
FRC #3958 (Schrodinger's Cat)
Team Role: Mentor
 
Join Date: Oct 2013
Rookie Year: 2013
Location: Boston, MA
Posts: 17
prifken is an unknown quantity at this point
Re: Question about I2C Communication

Can you share your LabVIEW write I2c code as well?
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 20:07.

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