From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Read timing issues

Solved!
Go to solution

I am using an RS232 to control an older model Power Supply (OXFORD PS 120-10).

 

I have successfully written several VI's that all work, the only problem is that VISA Read takes WAY too long. I'm talking 10's of seconds to refresh. I need it have it refreshing in milliseconds or at least tens of seconds for the measurements we need. All of the VI's I have written have the same timing issue. 

 

Attached is the most basic Serial Read/Write VI. Is there any way to improve the Read rate? Or might this just be an instrumentation issue. The strange thing is the Write commands work almost instantaneously (I can seem them on the instruments display).

 

Please help if you can, I've only been working with LabVIEW for a few weeks and am very must still in the learning process. 

 

Thanks!

Download All
0 Kudos
Message 1 of 7
(2,832 Views)

Do you have the communications protocol for the power supply? If you do not have everything right, you will have problems with communications.

 

Tens of seconds is a clue that you may be getting timeout errors because the default timeout is 10 seconds. Try placing an inidicator on the error out wire inside the loop (after Read) to see if an error occurs on any iteration. The way you have the VI set up you only see the error on the last iteration of the loop.

 

You are writing a carriage return to the instrument. If it requires that, it almost certainly sends a carriage return with the response. (This is why I asked about the protocol). If the instrument sends a carriage return (or other termination character), then you should Enable Termination Character on the Configuration VI and set the termination character to the correct value. The default is line feed (hex A or decimal 10). A carriage return is hex D or decimal 13. You must wire the numeric value to the termination character input for any value other than the default. Then change the byte count value (at the Read input) to a number larger than the longest message the instrument will ever send, perhaps 100 or 500. The Read will end as soon as the termination character is received, regardless of the number of characters.

 

I suspect that this is the problem - the instrument sends fewer than 10 characters in most messages but does send a termination character.

 

Lynn

Message 2 of 7
(2,818 Views)

I don't have LabVIEW right now, so I can't look at your code.  But here's what I would look for.

 

10 seconds for a VISA read to happen sounds like you ran into a timeout situation.  Are you getting any errors out of your VISA Read?

 

Does the power supply use a termination character?  If it is using ASCII commands, they usually do.  If it does, make sure you enable the termination character and set the bytes to read to something rediculously high.  The VISA Read will stop when the termination character is found.


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
Message 3 of 7
(2,815 Views)

I placed an error indicator immediately after the Read and it does seem to be a timing issue. The error code I recieve is -1073807339 which states: VISA:  (Hex 0xBFFF0015) Timeout expired before operation completed.

 

I enabled the termination character which according to the manual is Carriage Return. I also tried lowering my timeout rate to 100ms, then 50 ms, and it refreshes according to those times.

 

How does the timeout affect the running of the code, and will this cause issues when I run the instrument in more complicated codes?

 

Thanks again

 

 

0 Kudos
Message 4 of 7
(2,772 Views)
Solution
Accepted by topic author myannell

Try this minor mod

!1-1.png

After power cycling the device resets to "Q0" state.


"Should be" isn't "Is" -Jay
Message 5 of 7
(2,766 Views)
Setting the timeout to a lower value only affects the read rate if you are still getting a timeout error. If the instrument is responding, you can set the timeout value back to the default and the read rate will be totally dependent on the instrument.
Message 6 of 7
(2,765 Views)

Thanks everyone. Jeff- The mod worked wonderfully. I implemented it in several of my other more complecated codes already. And Dennis, the explanation was very helpful for my understanding of how Serial communication works. 

 

Thanks again!

0 Kudos
Message 7 of 7
(2,752 Views)