LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Visa write works intermittently

I have two exes that are reading data over the serial port.  One is a test serial that tests the reading of the string.  They both are identical in the serial com setup but one works and one does not.  the obvious would be to say that they are different but they are identical in the serial write/read respect.  They both first write "?" over the port to the main vi that when it is read in it sets a case to true that then writes the data string to the exe on anther PC.  Both the exes have an indicator of bytes out and sometimes when I run each of them the value is 0.  On one of them it does have the write bytes equal to 1 but on the other it always is zero.  Earlier today that very exe did work for a while then failed to write,  Any idea of this inconsistent visa write?

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

Without posting your code we can only guess. Are you getting any error mesages?

 

My first guess would be it's a time out or serial port setting issue.

 

Post your code

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 13
(3,498 Views)

I just discovered an undefined error;" -1073807339 occurred at Visa Read".   The serial write on the larger code is located in the lower right while in the plot vi the code sketch is on the lower left of the BD.  The serial test code should be self explanatory.

0 Kudos
Message 3 of 13
(3,484 Views)

The other code attached.....

Download All
0 Kudos
Message 4 of 13
(3,476 Views)

 

 

I just discovered an undefined error;" -1073807339

 

That is a Time Out Error

 

(Hex 0xBFFF0015)
Timeout expired before operation completed.

 

-1073807339(dec) = BFFF0015(hex)

 

Omar
0 Kudos
Message 5 of 13
(3,475 Views)

Any idea why it would time out and sometimes work?

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

Here are some tips for serial reads. This method the serial read will read until it reaches the termination character or times out. You of course will have to deal with the timeout errors properly if you don't want the program to stop on error.

 

SerialCapture.PNG

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 13
(3,470 Views)

One reason for the time out seems to be (when running the Test serial exe) that the visa write does not seem to be sending the "?" over to the main vi so that the main vi would send the data sting.  Any idea why this would not work?

0 Kudos
Message 8 of 13
(3,457 Views)

I am getting data now but, it seems to be hit or miss.  Sometimes it sends an empty or partial string and seems to be running slower that 1Hz as set by the delay.  Also, if I did not change the values of the term character or the time out would not be the same as using the defaults? Are they not active as default without wiring a constant to them.

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

@teslac wrote:

I am getting data now but, it seems to be hit or miss.  Sometimes it sends an empty or partial string and seems to be running slower that 1Hz as set by the delay.  Also, if I did not change the values of the term character or the time out would not be the same as using the defaults? Are they not active as default without wiring a constant to them.


The defaults will be used if you do not wire them. Also I forgot to check and see what type of flow control you are using. If you are leaving that terminal unwired it will default to NONE.

 

Wire it to set a reasonable form of flow control. I have found that XON/XOFF is only good up to 9600 baud, anything over that needs a hardware flow control like RTS/CTS to be reliable. Note that hardware flow control requires the hardware lines to be present in your serial cable. Many cheap serial cables only have Rx/Tx and ground.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 10 of 13
(3,437 Views)