Go Down

Topic: Arduino and Labview Serial Communication (Read 24755 times) previous topic - next topic

mleonov

I am trying to establish a serial communication between Labview 8.6 and Arduino Duemilanova board via USB. I read that USB is the same as RS-232 serial communication just that the USB has a built in USB/RS-232 adapter in it. Please correct me if I am wrong.
I tried to establish the communication using Labview's Basic Serial Write and Read vi example however it was not successful.

In the String to write box on front panel of labview, do I need to specify a string or a command that is used to program the Arduino board via the Arduino software?

Any help will be appreciated. I am new to Labview, so please give as much detail as possible when responding.

Thanks

Grumpy_Mike

Quote
do I need to specify a string or a command that is used to program the Arduino board via the Arduino software?


Yes the Arduino needs software in it first that looks at the serial port and does something with it, so you know it has arrived.

You could get LabView to program the Arduino through the boot loader but that is too complex a project for a beginner.

ale914

Hi, i'm working on connecting labview and arduino via serial interface without big issues.

Just to experiment maybe you can try to upload your arduino with an example coming with its ide "dimmer.pde"
Basically this sketch open the serial port at 9600 bps the wait and read 1 byte at time and use its value in analogwrite function to drive a led in PWM on the specified pin, of course you need a LED to test it

Code: [Select]

* Dimmer
* by David A. Mellis
*
* Demonstrates the sending data from the computer to the Arduino board,
* in this case to control the brightness of an LED.  The data is sent
* in individual bytes, each of which ranges from 0 to 255.  Arduino
* reads these bytes and uses them to set the brightness of the LED.
*
* http://www.arduino.cc/en/Tutorial/Dimmer


from the labview side, you can use the example icluded in labview distribution labview>>help>>find examples | select tab search | type "serial" in keyword field | double clicks on serial founded than in le list on the right choose basic serial write and read.

Ok now, leave the VISA resource parameter as is, its define the port seting and in this case fit with the setting on arduino side, make a left click on "string to write" field the select hex display, this permit you to write directly in hex notation, now togle off the switch "read" we don't need to read nothing back from arduino.
Now try to write FF in the "string to write" field then press RUN button , the white arrow on top left (the single arrow), this should ON at maximum power your led.

Ciao

mgriebel

Have you had any luck talking to your Arduino with LabVIEW?

I wrote a quick sketch that does an analogRead and sends it out the serial port.

And I wrote a LabVIEW vi that reads from the port and displays the result.

I'll try to post some screen captures.
-mark-

mgriebel

Here's the screen captures of my LabVIEW code.

Input = 1KHz 0 to 1V sine wave.

Let me know if there is anything I can help with.
-mark-

Here's the sketch:

void setup()
{
 Serial.begin(115200);
}

void loop()
{
 Serial.println(analogRead(0));
 delay(2);
}

Here's the vi front panel:



Here's the back panel:


stefanog

ciao
I found your post about the serial communication between Arduino and a Labview program. Could you say what board did you use? I would use an Arduino2009 which has USB interface and I'm not sure that the vi that you posted runs correctly.
Thank you for the collaboration.

mgriebel

I used a Duemilanove. PC running Arduino 13 and LabVIEW 8.5.
You need to install the FTDI drivers to get the USB port to act as a serial port.
When I installed the FTDI drivers it setup as com3.
-mark-


stefanog


Theom

#8
Apr 28, 2009, 07:43 am Last Edit: Apr 28, 2009, 08:31 am by Theom Reason: 1
mgriebel,

Thank you for the code. I was able to look at what you had put together and a similar simple code with the only difference being a method of saving the data. However, I find that I am getting about every other sample returned as a zero or some loss of data as seen in the graph below. It is not constant, and it seems that I loose the samples for a period of time and then there is a reconnection. Plotting the data straight from the Arduino-15 serial output with Excell produces a perfect sinusoid from my Function Generator, however looking at my labview plot from the same device, I get an intermittent signal, with no change in hardware.  

Thanks very much for any advice.

d4danger

Hi,
You can use the FTDI VIs see link

http://www.ftdichip.com/Projects/CodeExamples/LabVIEW.htm

The D2XX function library for LabVIEW gives you a great selection of VIs.

So now you can also read the FT232RL unique serial number and read/write to its EEPROM as well as do the normal comms to a programme running in the Arduino that generates serial data.

I have found it works well for me.

Go Up