LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA read timeout

Solved!
Go to solution

I dont know why im getting a timeout error at the VISA read function(error says "timeout expired before operation completed"). I made sure the Labview serial port and my devices serial port are configured exactly the same. I even tested hyperterminal with the same port settings as in labview and it works perfectly but my labview program gives me an error. My device terminates each command it sends with a carriage return so i set up VISA READ to stop reading data when it  encounters the CR character. I also made sure the carriage return was infact being sent by my device. Any thoughts?

 

port_settings.jpg

 

code.jpg

0 Kudos
Message 1 of 27
(28,377 Views)

Are you sure the command you are sending is formatted correctly?

 

I don't usually use a "send termination character on writing" option, preferring to add the termination character manually.  Are you sure the termination character for the sent command is correct and being sent?

0 Kudos
Message 2 of 27
(28,374 Views)

Have you tried increasing the time out period? Your picture shows a 100mS timeout .

 

That seems pretty short to me for a 9600 baud serial com.

========================
=== Engineer Ambiguously ===
========================
Message 3 of 27
(28,369 Views)

You can use 'serial port monitor' to see actual data sending from hyperterminal and then with LabVIEW. See where is the difference. Might help.

 

Message 4 of 27
(28,351 Views)

@RTSLVU wrote:

Have you tried increasing the time out period? Your picture shows a 100mS timeout .

 

That seems pretty short to me for a 9600 baud serial com.


As RTSLVU said, increase the timeout period, reading 1000 bytes at a baud rate of 9600 will take more than 100 ms.

 

Ben64

0 Kudos
Message 5 of 27
(28,341 Views)

I know im sending the correct commands because my controller is doing what the command tells it to. Ive tried increasing the timeout as well and still get the error(Ive tried changing it on the front panel and using property nodes). The only way I got it to work is if I simply dont connect the error wire to the VISA read function. If i do it this way i get no error and Im able to read and write correctly. I dont know if this is good programming practice or if it could cause problems somehow but its the only way it works.

 

 

Working code

 

working_code.JPG

0 Kudos
Message 6 of 27
(28,338 Views)

I think it's not seeing your termination character on the read and/or write.  When I send a string to the serial bus, I always use "Concatenate Strings" to add the appropriate termination character(s) to the end.  Assuming your read termination is CR/LF, I've always had better luck stopping on the LF and stripping the CR with "Trim Whitespace."

 

Also, don't be afraid of making the timeout a second or two.  If everything is going right, it will (normally) give the serial port plenty of time to complete its operation, but if things are going wrong, it will give you time to "notice" something is wrong.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 7 of 27
(28,330 Views)

Also, consider cleaning up the block diagram (straighten wires, place terminals in easy-to-see places, etc.).  Sloppy wiring is like random indenting in text-based code.  It doesn't matter to the compiler, but it makes it hard for a human to read.

 

Besides, your program will run slower because all those bits need to navigate those sharp corners (j/k, of course).  😄

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 27
(28,326 Views)

Im pretty sure its seeing the CR because the "actual bytes read" indicator is showing the correct number of bytes that i expect to read for a particular command. I will manually add the CR just incase.

0 Kudos
Message 9 of 27
(28,319 Views)

Still get the error. I guess i'll just leave the error terminal unwired.

0 Kudos
Message 10 of 27
(28,312 Views)