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)
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.
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
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.