Go to Post My robotics team is my love (my ex-wife told me so). - Koko Ed [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Spotlight this post!  
Unread 20-03-2013, 22:13
Mike Bortfeldt Mike Bortfeldt is offline
Registered User
FRC #1126 (& 1511)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Rochester, NY
Posts: 119
Mike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud of
Re: Arduino-cRIO I2C Communication

Quote:
Originally Posted by Bryce Paputa View Post
Has anybody used I2C to talk to an arduino from the crio (Java)? I would like to do it to control some lights on our robot, and I think I know what the crio side of the code should look like, but I don't know how to do the arduino side. Does anybody have any suggestions? Has anyone had a good experience with a different method?
Bryce,

What you are trying to do is definately possible as we've implemented this on our robot this year, both for LED control as well as gyro and field positioning. There are a couple of bugs you have to watch out for, two on the cRIO side, and one on the Arduino, but once you understand what they are, it works reasonably well. I say, reasonably, because we were having some sporatic communication issues that I think is due to the I2C cable length, but as the robot is bagged, I can't test it out. Initial bench testing didn't seem to have this issue. As Branden mentioned, you will want to use the Wire library with the Arduino as the I2C slave. You will need to bit shift the address you use left by 1 for the cRIO as it apparently interprets the LSB (the read/write bit) as part of the address. For example, if you use an address of "2" for the Wire library on the Arduino, you will have to use an address of "4" on the cRIO. Second, there is a bug in the Wire library in the slave "restart" command that will prevent the cRIO from completing a successful write/read transaction with the Arduino. You can get around this by splitting the transaction into two parts, a write only (0 bytes for the read) followed by a read (0 write bytes). Alternately, there is a fix for the Wire library you can find on the net if you search (this is where I found it). Finally, there seems to be a bug in the WPI Library, where if you try to send (write) multiple bytes to the Arduino, it will interpret the individual bytes as "signed integers" and possibly overwrite some bytes with a value of 255 up to the integer 4 byte boundry where it will work again. The easiest way around this is to make sure you never send a value greater than 127 to the Arduino, or ensure that if you do need to do so, it is either the 4th byte or last byte sent. Finally, this brings up the fact that the cRIO limits you to 7 bytes of data communication per transaction each way. If you have any other questions, PM me, and I'll try to help.

Mike
Reply With Quote
 


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 11:35.

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