Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Arduino with LabVIEW (http://www.chiefdelphi.com/forums/showthread.php?t=125128)

bjackson2016 23-01-2014 20:07

Arduino with LabVIEW
 
Our team has decided to use an Arduino with a gyroscope to navigate in autonomous. We need to be able to recieve data so we wrote hello world code in arduino and tried to read it in labview using DIO, Serial, and I2C. Does anyone know read values from an arduino in labview. Thanks

Joe Ross 23-01-2014 20:21

Re: Arduino with LabVIEW
 
There are LabVIEW VIs for DIO, Serial, and I2C included in the FRC Library. If you couldn't get any of them to work, it would be helpful to post your Arduino code and your LabVIEW code. Note that the cRIO only supports being an I2C master, so you would have to make the Arduino an I2C slave.

bjackson2016 23-01-2014 20:24

Re: Arduino with LabVIEW
 
We have the following for the Arduino and are setting it up as a Slave Sender:
#include <Wire.h>

void setup()
{
Wire.begin(2); // join i2c bus with address #2
Wire.onRequest(requestEvent); // register event
}

void loop()
{
delay(100);
}

// function that executes whenever data is requested by master
// this function is registered as an event, see setup()
void requestEvent()
{
Wire.write("hello "); // respond with message of 6 bytes
// as expected by master
}

At this point we are not sure what we need to do in LabView....any assistance will be greatly appreciated.

Alan Anderson 23-01-2014 22:52

Re: Arduino with LabVIEW
 
The I2C functions are in the Communications function subpalette (found in the WPI Robotics Library). Each one has reasonably good built-in help. Press CTRL-H to toggle the "hover help" window on and off.

Quote:

Originally Posted by bjackson2016 (Post 1331450)
Our team has decided to use an Arduino with a gyroscope to navigate in autonomous.

What kind of gyroscope? Why not connect it directly the cRIO without involving a coprocessor?

Invictus3593 23-01-2014 22:53

Re: Arduino with LabVIEW
 
Now, in Labview, go to WPI Robotics Library > Communications > I2C and use what you need! :D

randantor 23-01-2014 22:58

Re: Arduino with LabVIEW
 
You can find the I2C VIs under the "communications" section of the WPILib palette.

Using I2C between an arduino and LabVIEW is ...odd to say the least. It's pretty poorly documented and there are pitfalls that can cost you a lot of time just trying to get it to work. The library is set up for i2c sensors, so it has this concept of "registers".

Basically when writing to a device, you give it a "register address", which is actually just a byte that is sent before the rest of the data. For example if you told LabVIEW to send the bytes 0xFF 0xFF to register 0x01, the data that would actually be sent would be [0x01, 0xFF, 0xFF]. If you are writing to an arduino, you can treat the register as just a slot for the first byte. Additionally, you can only send 8 bytes (the register byte and 7 data bytes) at a time. Any extra bytes passed to the write VI are silently discarded.

When reading from a slave, there is again a "register". This time it is a byte array that is sent to the i2c slave right before reading from it. I believe you can simply pass it a 0-length array if you don't want to send any data before reading, though I haven't tried it.

A major thing to be aware of is the fact that an i2c address set on an arduino needs to be shifted one bit to the left when set on the cRIO. For example, in your arduino code, you have the address set to 2; you will need to set it to 4 on the cRIO code if you want them to actually communicate.

When writing to an arduino slave, you should set "CompatibilityMode" to true.

I noticed your adruino code also sent 6 bytes to the cRIO. It seems the cRIO is only capable of reading 4 bytes at a time, so you should be aware of that.

bjackson2016 24-01-2014 18:21

Re: Arduino with LabVIEW
 
Quote:

Originally Posted by Invictus3593 (Post 1331527)
Now, in Labview, go to WPI Robotics Library > Communications > I2C and use what you need! :D

We are trying to figure out how to use those blocks, we know where they are but not how to use them to get data from an arduino.

bjackson2016 24-01-2014 18:59

Re: Arduino with LabVIEW
 
Quote:

Originally Posted by Joe Ross (Post 1331458)
If you couldn't get any of them to work, it would be helpful to post your Arduino code and your LabVIEW code.

We tried all of them and could not get any to work. We want to use I2C because it looked closest to working.

bjackson2016 24-01-2014 20:05

Re: Arduino with LabVIEW
 
Quote:

Originally Posted by Alan Anderson (Post 1331526)
What kind of gyroscope? Why not connect it directly the cRIO without involving a coprocessor?

It is a 2013 Pololu with 5 pins. I do not know what any of the other text means... imu02a OJ7211.


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

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