LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Read Timeout Error

Hello, I'm attempting to communicate with a serial device via VISA and have been stuck for a while trying to figure out why my program hangs at the VISA Read VI (it hangs until it times out). Increasing the VISA session timeout value hasn't helped - it merely causes the program to hang for longer before it times out.

 

I'll attempt to provide as much information as I can, so below I'm posting screenshots of my front panel and block diagram and below that an explanation of the operation of the program:

 

http://i.imgur.com/IdHnl6K.jpg

http://i.imgur.com/2RSK2vX.jpg

 

This program is intended to trigger a case structure based upon the iteration value of the while loop that encases it for as many times as the value "number of steps" inputted on the front panel. Within each case of the case structure are a series of "serial device command" string concatenations which are tunelled out and passed to the VISA Write VI. From there the program is meant to read back the serial response (a string represenation of a floating point number ie. 2.0000) which is converted to numeric form and added to an array to store the response value from each iteration of the encasing while loop.

 

All the commands written execute just fine as evidenced by the operation of the serial device to which I'm writing and each "error out" is "OK" (including the Visa Write error out) until the Visa Read error out. When running the program and highlighting execution, the program simply hangs after reaching Visa Read (all the wires coming out of it are gray) until the VISA session timeout is reached at which point it [i]actually passes out the value[/i] it was supposed to read (ie. 2.0000), which gets stored into the array as desired, while putting out the error:

 


 

Error -1073807339 occurred at VISA Read in LabVIEW Delay Stage.vi

 

Possible reason(s):

VISA: (Hex 0xBFFF0015) Timeout expired before operation completed.


 

and consequently ending the program (the while loop is not executed again).

 

 

 

Any advice would be very much appreciated. I must admit that I'm a relative rookie when it comes to both Labview and serial communication, so I encourage you to treat me like a 5 year old. If you require any further information I'll be happy to try my best to provide it.

 

Note: I'm aware I probably don't need the execution structures within the case structures, but they're working so I've decided not to tamper with it for now.

0 Kudos
Message 1 of 7
(8,282 Views)

First of all, you should initialize your VISA session and serial port once before the loop.  You should also only close it after the while loop.

 

Secondly, is the device sending a termination character?  Usually an End Of Line character.  I noticed you turned it off.  But if the device is sending one, you should setup the serial port to use the termination character.

Why are you telling the VISA Read to read the number of bytes you wrote?  You should be putting in the number of bytes you expect to get back from your device.

 

There are more things, but we'll worry about those after you get your VISA communications working.


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 2 of 7
(8,274 Views)
The fact that you don't get an error on a write is pretty meaningless. You can usually disconnect an instrument completely and not get an error. Check with another terminal emulation program, verify the com settings, verify the type of serial cable (null-modem or straight through), the correct command, and the termination character. A timeout, in my experience, is usually caused by a bad write and a bad write can be caused by any of the above.
0 Kudos
Message 3 of 7
(8,272 Views)

Okay, I've moved the serial port VI, Visa Resource, and Visa Close VI out of the loop now such that it looks like this now (I added a black separation line in the middle of this image - it's not part of the block diagram).

 

http://i.imgur.com/gv4dXgb.jpg

 

 

In response to your second point, I don't believe the device is sending a termination character. Other people who have communicated with this device in the past have also turned the termination character off.

In regard to why I'm telling the VISA Read the number of bytes I wrote, I suppose I don't have a good answer for that except that it gave me semi-functionality... there's likely a better setup. I just recreated the way I had it originally set up which is with a "Bytes at port" property node: 

 

http://i.imgur.com/0b8FhLQ.jpg

 

however, this was and is giving me a consistent "return count" of 0 as well as the Visa Read VI not returning any value. However, it should really be noted that having just put that property node back in has now eliminated the Visa Read error leading me to suspect this is where the problem lies.

 

Edit: Using a different write command I'm now getting the proper return count and value - I'm gonna tinker with this for a bit and update this post.

0 Kudos
Message 4 of 7
(8,265 Views)

Well, it seems that's solved the main problem that this thread was about (I have no idea why that property node didn't work earlier). My only issue right now is getting the Visa Read return value to be added to a new index of the array for each repetition of the overall while loop, but I think that's something I can solve myself.

 

I notice, crossrulz, that you said there were some other things wrong too. I've changed the loop condition from stop to repeat, but if there's anything else that you'd like to point out I'd be very thankful.

 

Besides that, thanks for the help!

0 Kudos
Message 5 of 7
(8,251 Views)
  1. You don't need the VISA Open
  2. You don't need the property node to set the timeout.  That is an input setting in the Configure Serial Port.
  3. You should't need the VISA Clear either.

The other things I was referring to were how you were building the data array, but you seem to already be aware of that.


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 6 of 7
(8,241 Views)

One reason the Bytes at Port is not giving you the count of the complete return message is that you do not give it enough time.  At 19200 baud you get about 2 characters per millisecond. The Bytes at Port probably executes a few microseconds after the VISA Write. Thus, the remote device has not had time to send any characters at the time Bytes at Port executes.  You can try adding a delay between Write and Bytes at Port. That is a somewhat brute force approach but will tell you whether the communications is working.

 

Lynn

0 Kudos
Message 7 of 7
(8,224 Views)