Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Visa Serial Communication via Serial port COM# is unreliable

Hi! Guys,
could you please help me with a recurrent issue?. I think it's very interesting . Well, I'll try to explain it clearly.
I work with a master's project, where I'm using a Arduino Mega Atmega 2560 and Labview to valide a GUI to working with a serial communication via VISA read and write funtions. Using a specific serial port COM. I have found several answers about this issue in the Web. But I do not have yet a clear solve of this. The reccurent issue is the follow: When I run my application do not problems with open sesion serial port, and reading/writing way is correct. but after a time, the communication is not stable because there are slow iterations in moments or iterations frozen, even there are interations with a communication broken finally. I have tried with enable events, termination caracters (line feed and carriage return), Bytes at serial port and etc...
I think all hardware by NI have a excellent performance with the transference of data using GUIs by Labview, but using different hardware is not. I attach the VI's used.

0 Kudos
Message 1 of 13
(3,495 Views)

Surely use end characters and NO Bytes available.

What are the error messages you get? And what is a certain time, minutes,hours or even days?

 

And please, add a few subvi's so we can see what is selected in the port open and eventually yhe other subvi's to clear all doubts in the program..

greetings from the Netherlands
0 Kudos
Message 2 of 13
(3,480 Views)

1. I am not really seeing a point in using the Queued Message Handler (QMH) that you have set up.  Just use a loop with an Event Structure in it to handle your button presses.  Then the serial port read can be all alone in its own loop.

2. Talking with an Arduino, therefore you definitely should be using the termination character as is the default with the VISA Configure Serial Port.  You can use the Bytes At Port to detect when a message has started, but DO NOT use it to tell the VISA Read how many bytes to read.  Just tell it to read more bytes than you ever expect in a message.  You also do not need any of the VISA Events.

3. What are you using for a serial port?  If a USB-RS232 device, you may be running into issues where Windows will turn off your USB hub in order to save power.  You can go into the device manager and turn that off.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 13
(3,477 Views)

Hi Albert Geven, 

 Well, I attach a few subVI's used for the project. now I am working with an Arduino sketch to be always printing the same numer of caractheres from Arduino Serial Port . So, Is that good idea?. To be honest there are not several errors in particular Error - 1073807360 occurred at VISA Write in ProducerConsummerData 2.vi
Possible reason(s)
VISA: (Hex 0xBFFF0000) Unknown system error (miscellaneous error) is not common. When I am continuously using the GUI, data printed from Arduino board arrives with a delay to the GUI.

   

0 Kudos
Message 4 of 13
(3,472 Views)

Thanks for sending, but I believe that the mail from Crossrulz is already ging enough hints to get it right.

This message is for me also a hint that power may be switched off on the USB port.

greetings from the Netherlands
0 Kudos
Message 5 of 13
(3,465 Views)

Hi crossrulz,

1. So, I'm going to develop two while loops, (1) to work with the bottons used to execute some precess of my project, (2) to have an event structure into of it to read / write data printed from Arduino serial port. But I need to read data in parallel with a write block continuosuoly because there are a monitor graph of data printed.

 

2. It is ok. Thanks for your good point

3. It is a USB serial cable uses TTL logic levels connected to Serial port of Arduino Mega board

 

0 Kudos
Message 6 of 13
(3,464 Views)

Ok, I will work with the excellent hints.

 

Thank you so much.

0 Kudos
Message 7 of 13
(3,463 Views)

@MiguelReyes110115 wrote:

1. So, I'm going to develop two while loops, (1) to work with the bottons used to execute some precess of my project, (2) to have an event structure into of it to read / write data printed from Arduino serial port. But I need to read data in parallel with a write block continuosuoly because there are a monitor graph of data printed.


No.  You have loop 1 handle the buttons used to execute some processes.  This loop uses the Event Structure.  The second loop should just be the serial read happening continuously and updating the graph.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 13
(3,420 Views)

Hello everybody!

Okay. Attach a picture from diagram block developed, I have run this VI, and I can see an improvement with the serial communication between Arduino and Labview.
Thanks for your advices

 

Miguel Reyes

0 Kudos
Message 9 of 13
(3,376 Views)

Since you are talking to an Arduino, I will also assume you are using the Serial.PrintLn() to send the data, then DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (still not enough emphasis).

 

The Bytes At Port just causes all kinds of weird race conditions.  If you are using the PrintLn() in the Arduino, then you are telling it to add a Carriage Return (0xD, CR, \r) and a Line Feed (0xA, LF, \n) to the end of the message.  This is called a termination character.  So with your VISA Configure Serial Port, leave those two inputs (on the top) unwired.  This will configure LabVIEW to use the proper termination character.  Then with the read, you just tell the VISA Read to read more bytes than you ever expect in a message.  This way, you know you got the full message and it will save you A LOT of headaches (I know from experience).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 10 of 13
(3,370 Views)