LabVIEW as Arduino input and output

Hi all!
I'm working on building a quadcopter using Arduino.
One of my goals is to have a LabVIEW based interface, so the user can both get data from the quad (position, motors speeds etc.) and send commands to the quad (target position, takeoff/land commands etc.), using a second arduino which is connected to the PC and acts as a transceiver.
The thing is I don't have any idea how to send data back and forth between the arduino and a LabVIEW VI. I tried looking online but all I found was how to use LV to program an Arduino, so any help would be greatly appreciated. (If anyone could show me how to build something simple, like a VI that gets the value of a potentiometer and has a slider to set the brightness of an LED I'm pretty sure I'll be able to take it from there)

Thanks a lot!!

Ok, I spent the day reading and I found out how to do it, so for any future readers:

On the Arduino side, communication with anything on the PC is handled with Serial.read and Serial.print.
once you know how to read and write from the serial port on the arduino side you move on to the LabVIEW side.

On the LabVIEW side serial communication is handled with NI VISA which you'll have to download from NI's website. After downloading and installing VISA you can open LabVIEW and go to tools>measurement & automation explorer, then expand "devices and interfaces" to make sure LabVIEW recognizes your arduino.

To demonstrare how it works I wrote a skatch that will get a string and then send it back, then made a VI that can both send a custom string with a click of a button and receive a string from the serial port.

void setup() {
  Serial.begin(9600);
  while(!Serial){}
}

int bytesToRead=0;
char msg[64];
  
void loop() {

  if(Serial.available())
  {
    getMessage();
    Serial.println(msg);
  }
  
delay(100);
}

void getMessage()
{
  int i;
    
  bytesToRead=Serial.available();

  for(i=0;i<bytesToRead;i++)
  {
    msg[i]=Serial.read(); 
  }
  msg[i]='\0'; //end the string with a null character
}

The VI is attached as an image because I have no idea how to attach files in this forum.

hope it'll help someone someday :slight_smile:

I am trying to make program for Robotic arm.In this project I'm use labview for controlling my digital I/O pin.I saw some example of interfacing Arduino and labview and make one program but i'm getting erron like this

'Arduino: 1.6.8 (Windows 8.1), Board: "Arduino Nano, ATmega328"

sketch\Roboarm.ino.cpp.o: In function `setup':

C:\Users\Desktop\GTU PROJECT\Roboprogram\ROboprogram with labview\Roboarm/Roboarm.ino:18: undefined reference to `syncLV()

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino Nano.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

pls any body help me

pls any body help me

Without seeing your code? No.

Where IS the syncLV() function you are trying to call defined?

shayelk:
The VI is attached as an image because I have no idea how to attach files in this forum.

Actually, you don't need to attach the vi file.

If you select your code in labview, then "Create vi snippet from selection" it will save a .png file of the wiring.

You can then post that image in a forum like this.

Anyone can take that .png file and drag or paste it into a blank vi and it will recreate the code like magic.

I believe it has the be an image created from that LabView dialog. A screen capture won't work.

Also, it won't capture things like custom sub-vi's or cases that aren't visible. You need to capture them individually.

I've been using LabView for years and didn't know this until recently...

I've been sending commands from a RoboRIO to an Arduino over I2C recently.

I think you will have to connect read and write in same flow line from Visa serial name to the end on Serial close side.

But if all you do is sending strings you can use Arduino Serial window for that.
And if you need binary data sending, you can use more advanced RS232 terminal program such as docklight.
With it you can even set automatic answer from PC side triggered on specific keyword from Arduino.

Here it is:

AlGritzmacher:
Actually, you don't need to attach the vi file.

If you select your code in labview, then "Create vi snippet from selection" it will save a .png file of the wiring.

You can then post that image in a forum like this.

Anyone can take that .png file and drag or paste it into a blank vi and it will recreate the code like magic.

I believe it has the be an image created from that LabView dialog. A screen capture won't work.

Also, it won't capture things like custom sub-vi's or cases that aren't visible. You need to capture them individually.

I've been using LabView for years and didn't know this until recently...

I've been sending commands from a RoboRIO to an Arduino over I2C recently.

That's really cool to know! thanks!