Chief Delphi

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

Roger 02-04-2011 06:54

Arduino and LabVIEW
 
After searching high and low here and on the web, I still can't find a definitive answer: How do I send information (numbers) between the cRIO (using LabVIEW) and an Arduino Uno? And what are the actual hardware connections to be made at both ends? Thanks.

davidthefat 02-04-2011 11:30

Re: Arduino and LabVIEW
 
You can't, I also doubt if the arduino has enough power to run vXWorks either.

EricVanWyk 02-04-2011 12:05

Re: Arduino and LabVIEW
 
I'm not sure what David is talking about...

You can use I2C, SPI, or serial. Or, you could add an ethernet shield to the Arduino and use that.

For I2C and SPI, the cRIO wants to be the master. I'm not sure if the arduino easily supports slaving in these modes, you will have to check it out.

For serial, the Uno consumes its native serial port with its USB connection. Instead, you will have to use the software serial port library.

davidthefat 02-04-2011 14:30

Re: Arduino and LabVIEW
 
Quote:

Originally Posted by EricVanWyk (Post 1048351)
I'm not sure what David is talking about...

You can use I2C, SPI, or serial. Or, you could add an ethernet shield to the Arduino and use that.

For I2C and SPI, the cRIO wants to be the master. I'm not sure if the arduino easily supports slaving in these modes, you will have to check it out.

For serial, the Uno consumes its native serial port with its USB connection. Instead, you will have to use the software serial port library.

My, bad, I read the question wrong... I thought he was asking how he can program the arduino with labview... Disregard my post

Andy A. 02-04-2011 14:42

Re: Arduino and LabVIEW
 
Quote:

Originally Posted by EricVanWyk (Post 1048351)
I'm not sure what David is talking about...

You can use I2C, SPI, or serial. Or, you could add an ethernet shield to the Arduino and use that.

For I2C and SPI, the cRIO wants to be the master. I'm not sure if the arduino easily supports slaving in these modes, you will have to check it out.

For serial, the Uno consumes its native serial port with its USB connection. Instead, you will have to use the software serial port library.

There is also a CAN bus shield available, although I know little about it. It has a DB9 connector, which I guess means it's really intended to interface with automotive diagnostics stuff (complete with a sd card slot for data logging!). Still, I'm sure a clever team could handle the wiring and code required to interface it on a FIRST bot.

There are, of course, legal issues regarding custom circuits being in the CAN bus loop. Without carefully looking I think using the bus just to pass data is ok, as long as it doesn't try to control motors. I'm not sure exactly what practical advantage it would give you over SPI or I2C, but it would be pretty neat.

CAN bus shield on Sparkfun. It might be avalible elsewhere.

WizenedEE 02-04-2011 15:54

Re: Arduino and LabVIEW
 
Custom Circuits are explicatively allowed to be on the CAN bus. They are also explicatively illegal to control any non-decorations (and I'm not sure about the rules on decorations). Unless, of course, you email FIRST and get something as an approved motor controller.

I'd most likely try to communicate using I2C, but if you can get the C-RIO to send out serial commands, that's the arduino's native protocall.

Roger 02-04-2011 15:58

Re: Arduino and LabVIEW
 
Well, we might be :cool: but not all that clever, especially when we're short on time. I'll have to check those possibilities, Eric. Where does the data wire(s) get connected? Right now I'm in the "one step back" mode (computer doesn't want to download to the Arduino), so it'll be a bit.

All I need is to send a single number to the Arduino, and it'll turn on some LEDs. Can I do it through a Digital IO (which sounds the simpliest method)? WPI_PWMSetValue.vi?

Just saw Adam's post: Yeah, it's not quite decorative LEDs, so thats out. Any of the LabVIEW I2C examples are good to look at? Or the serial?

Mark McLeod 02-04-2011 17:57

Re: Arduino and LabVIEW
 
How big a number?

You can simply use the digital outputs on a sidecar to digital inputs on the Arduino to send a binary number.
You don't need a communications protocol to do that.

Maybe use one DIO to signal when the number has changed and should be read by the Arduino.

Roger 02-04-2011 19:12

Re: Arduino and LabVIEW
 
Do you mean (for example) 4 DIOs sending a binary signal for 16 numbers? (And no, I don't have many numbers, but I can think of ways to expand that.) Just using the signal portion of the PWM wire, right? (The Keeper of the Numbers says we have 5 DIOs free for use.) Heh -- I had thought of that too, when we originally thought of using DIOs. It seemed too obvious to be true. Could it really be that simple? Thanks, Mark!

Of course, I spent the day trying to make connections on an older robot to test all this, and now discovered (after connecting all the dots, so to speak) that LabVIEW and the Arduino programming port don't play nice together. I am making a nice collection of laptops around me just to test this.

kamocat 02-04-2011 19:20

Re: Arduino and LabVIEW
 
Quote:

Originally Posted by Roger (Post 1048458)
Do you mean (for example) 4 DIOs sending a binary signal for 16 numbers? (And no, I don't have many numbers, but I can think of ways to expand that.) Just using the signal portion of the PWM wire, right? (The Keeper of the Numbers says we have 5 DIOs free for use.) Heh -- I had thought of that too, when we originally thought of using DIOs. It seemed too obvious to be true. Could it really be that simple? Thanks, Mark!

Of course, I spent the day trying to make connections on an older robot to test all this, and now discovered (after connecting all the dots, so to speak) that LabVIEW and the Arduino programming port don't play nice together. I am making a nice collection of laptops around me just to test this.

Yes, if you're not doing a high volume of data, this is an easy and viable method.

Roger 02-04-2011 19:41

Re: Arduino and LabVIEW
 
Well we are talking about an Arduino. :) But no, just a signal to change lights.

Howsoever, I did see at FLR a team using an Arduino for sonar processing, but I don't know what kind of data they were sending back to the cRIO -- much more than I'm asking for, I'm sure. These little boards are fun to work with.

Roger 02-04-2011 21:55

Re: Arduino and LabVIEW
 
An update -- I have some LabVIEW code that sends a DIO true/false value depending on a button press, recieved by the Arduino on a digital pin, and blinks the light on the Arduino and also prints out the high/low value (simple test), slowed down to 1/2 second cycle. Currently I'm getting a semi-random highs/lows, even without pressing the button, which I'm guessing is LV's issue, not continually sending the true/false signal? Unfortunately, I lost my LV computer so I can't check it -- maybe I can schedule for a 3 am session? :ahh:

WizenedEE 02-04-2011 21:58

Re: Arduino and LabVIEW
 
If you haven't opened the IO port in your code, I think it may leave the signal pin floating. Does it work when you press the button, or does it ignore the button as well?

Roger 02-04-2011 22:27

Re: Arduino and LabVIEW
 
I think it's opened once in the Begin.vi (the computer got grabbed so I can't look at the code at the moment), and just referenced during the button pressing, and not open/send/closed each time.

There was no discernable difference when the button got pressed.

davidthefat 02-04-2011 22:35

Re: Arduino and LabVIEW
 
Consider the fact that a boolean on the PPC is 4 bytes. Also consider the fact that the Arduino uses little endianness. I am not sure about the PPC on the cRio, it might be a big endian, that might bring up some troubles.


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

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