I2C bytes to Arduino in LV?

We want to send data to an Arduino via I2C in LabVIEW. We have the Arduino side worked out. We don’t know how to send the bits and bytes to the Arduino in LabVIEW. We want to send three bytes or registers (if that is the correct terminology) that:

Register 1 - select The LED group number (1-12).

Register 2 - A function code. Here’s a list: DIM, FLASH, MODULATE, FLASHMOD

Register 3 - data, For the functions (how fast to dim, how quick to flash etc.).

I was hoping to find an example of someone talking to an Arduino (or similar board) via the FRC breakout I2C. And yes we could just use the I/O on the breakout for the LEDs but we want to learn I2C for the future.

It may help to look at the examples that cover I2C. You can get there by choosing the Help menu then Find Examples, or from the Getting Started window/Support.

I suspect most of them focus on reading from sensors, but I didn’t look too closely.

Greg McKaskle

Hence the issue. I think if I do figure it out I might put up a white paper or something on how to use I2C in LV since there doesn’t seem to be any tutorial for sending. If that’s something people would want to see.

Go to www.bitbuilttech.com. On the bottom is a link to the LV software package that we use to communicate with the Insight LT display over I2C. You should be able to easily dissect the VI and see how we send text via the protocol. As long as you know the message structure the Arduino expects, it should be straightforward.

Found these on NI’s website.

A short intro to I2C here.

Implementing I2C in LabVIEW here.

I’m afraid these examples quoted here do not apply to FRC.

It should be as simple as using the I2C open in Begin and then the I2C write in teleop or wherever you want to send the data.

The “register” control on the write VI simply refers to the first byte to send. The data array is any additional bytes you wish to send.

I assume you have already found the I2C palette in WPILib.

If you have a specific problem I’ll be glad to help.

So if I only want to send one byte at a time I only define the register? Or do you mean the first byte I send in my code period is that register, and any following bytes need to be under data to send (Witch screen shot would be correct)?

PS Also is the devise address on the I2C Open the address of the receiver?

I2C 1.JPG
I2C 2.JPG


I2C 1.JPG
I2C 2.JPG

If you want to send only one byte in the transaction to your Arduino, you would used the second example you posted. It would send either 2 or 0.

In the first example it looks like you would send either [1,1] or [1], so two bytes or one byte in each transaction.

Yes. The Device address is the 7-bit address of your Arduino device on the I2C bus.

I would also recommend that you try it out and print out what you get on the Arduino side to help you better grasp how the API works. You can also just open up the VIs to see what they do to some extent.

Cheers,
-Joe