Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   I2C bytes to Arduino in LV? (http://www.chiefdelphi.com/forums/showthread.php?t=120173)

jman4747 08-10-2013 14:29

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.

Greg McKaskle 16-10-2013 09:45

Re: I2C bytes to Arduino in LV?
 
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

jman4747 16-10-2013 10:29

Re: I2C bytes to Arduino in LV?
 
Quote:

Originally Posted by Greg McKaskle (Post 1296786)
I suspect most of them focus on reading from sensors, but I didn't look too closely.

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.

trilogy2826 16-10-2013 10:43

Re: I2C bytes to Arduino in LV?
 
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.

Redo91 16-10-2013 14:57

Re: I2C bytes to Arduino in LV?
 
Found these on NI's website.

A short intro to I2C here.

Implementing I2C in LabVIEW here.

jhersh 17-10-2013 01:31

Re: I2C bytes to Arduino in LV?
 
Quote:

Originally Posted by Redo91 (Post 1296834)
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.

jhersh 17-10-2013 01:34

Re: I2C bytes to Arduino in LV?
 
Quote:

Originally Posted by jman4747 (Post 1296801)
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.

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.

jman4747 17-10-2013 10:38

Re: I2C bytes to Arduino in LV?
 
2 Attachment(s)
Quote:

Originally Posted by jhersh (Post 1296917)
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.

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?

Joe Hershberger 17-10-2013 15:04

Re: I2C bytes to Arduino in LV?
 
Quote:

Originally Posted by jman4747 (Post 1296972)
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)?

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.

Quote:

Originally Posted by jman4747 (Post 1296972)
PS Also is the devise address on the I2C Open the address of the receiver?

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


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

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