LabVIEW roboRIO I2C Master, RIOduino I2C Slave - Help

Hello CD,

Has anyone been able to send and receive data from an Arduino (RIOduino, in my case) via the roboRIO MXP port?

I’ve created a link which describes my setup with pictures:

http://www.evernote.com/l/AI17jLAdOPVGt7RmUy6Baj7EDa6Egje3h-4/

How did you configure the addresses? I’m having trouble on the LabVIEW Write side (timeout error). I am simply incrementing a U8 and sending the result to the first register of the I2C read function in LabVIEW.

I don’t think the roboRIO is seeing the RIOduino at address 4.

Thanks for the help, in advance.

Hey prifken,

Have you taken a look at the example code that Andy Mark posted? It uses I2C to communicate between the roboRIO and the RIOduino to control a touch display.

The example can be found on the “Files & Documents” tab of the RIOduino product page: http://www.andymark.com/product-p/am-2999.htm

At first glance I noticed one thing about your LabVIEW code. I think it is recommended to put the I2C Open code in Begin.vi rather than in Periodic Tasks.vi

On the Arduino side of things it may be better to separate out your I2C receiving and sending operations into two different handlers. It looks like you’re trying to send “hello” out as you’re reading the receive buffer.

I hope the example code will help. Let me know if you have any further questions!

-David

David,

I’ve seen the example, it’s the best I could find that demonstrates how to setup communication between the Master/Slave. It has been very helpful in defining an initial approach.

In the example, the address set by Wire.begin is 84 on the Arduino (I2C slave). The address set by I2C Open on the LabVIEW end is also 84. This leads me to believe that my approach of setting an address of “4” on both the master and slave in my setup is also correct (just to be safe, I’ll change to address 84).

I am using Serial.begin and Serial.print to validate that the RIOduino has received a message from the I2C master (using Tools >> Serial Monitor). I have removed the I2C response of “hello”, as I should first confirm that I can receive a message. Since the I2C write loop times out, my suspicion is that there might be an issue in the physical connection between master and slave.

Can you think of any other troubleshooting steps besides:

  1. Attempt a direct connection of RIOduino to RoboRIO (remove extension cable)

  2. Attempt an I2C connection via the on-board I2C port, instead of the MXP breakout.

I can try executing I2C Open in Begin.VI, though I believe programmatically there is no difference between breaking up the command between Begin and Teleop, or having the I2C Open initialize and loop in Periodic Tasks.

It would be nice to have confirmation that the I2C write approach is valid as well. I am simply writing an unsigned 8-bit integer to the first I2C Register and trying to print that data to the RIOduino COM Serial Monitor.

Appreciate the help again. I’ll definitely consider putting together a guide for new users interested in controlling individually addressable LED strips from LabVIEW via a micro-controller and the I2C protocol.

Best,
Peter

Today I attempted an I2C write using the on-board I2C port (instead of MXP) and it worked!

Question is, why am I failing to communicate via MXP?

As promised, a helpful guide for others posted in a new CD thread: http://www.chiefdelphi.com/forums/showthread.php?t=137196

Since you got it working through the on-board I2C port, the only thing I can think of is that the RIOduino was plugged in off-center.

The connector housing on the bottom of the RIOduino is smaller than what it should be so it is possible to plug the RIOduino into the MXP with it shifted to one side. An easy way to check is to look and see if the mounting holes line up to the roboRIO.

Regardless, thank you for posting such a great write up!

-David