Arduino Uno and LabVIEW serial communication

Hi all,

I need to make a serial communication between my Arduino Uno and LabVIEW application running on my PC. The Arduino and PC are connected through USB cable.

Attached please find the Arduino sketch and the LabVIEW code (I changed the extension to “.ino” to be able to attach it. So please change it back to “.vi” to be able to open it in LabVIEW).

The arduino prints numbers from 0 to 9 to serial buffer, and stops the printing.
The LabVIEW application reads the data from the buffer and closes the connection session.

I run the Arduino sketch. It writes the numbers to the buffer.
Then I run the LabVIEW application. It successfully reads the numbers and closes the session.
When I run the LabVIEW app again (note that the arduino already stopped printing the numbers) it reads the numbers again. This process continues whenever I run the LabVIEW app.

The only way to fix this, I thought to clear the buffer content in LabVIEW app (before closing the session). However, it didn’t help.
Then I tried to clear the buffer in Arduino as well, however it didn’t help as well.

Can anyone tell me what am I doing wrong, or is there any other way to clear the serial buffer not to read the same data the second time?

Thanks in advance,

Gevorg

sketch_jun05a.ino (254 Bytes)

main.ino (16.5 KB)

I am not familiar with LabView but your description suggests to me that your LV program is opening the serial port and causing the Arduino to reset each time. You should ensure that LV keeps the serial port open until it is completely finished with the Arduino.

...R

I have written such a VI in LabVIEW, and it is as Robin2 writes - wait after you open the serial port.

I get paid to write LabVIEW software, so I will pass on this opportunity. :)

You can take Reference from this VI

http://embeddedlaboratory.blogspot.in/2016/08/serial-communication-using-labview.html

This might be of some help. https://github.com/GaryCousins/Arduino-Interface I wrote it a few days ago, it's a bit scrappy but does the job I needed. It's probably not quite what you need but has a full Serial Interface and the corresponding Arduino test code so should give you some pointers.

Gary Cousins https://cengarduino.wordpress.com/