LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to interrup as fast as possible a visa reading action in a while loop?

I'm trying to figure out a way to stop / interrupt as fast as possible a while loop containing a VISA read function call.

The visa source is set with a timeout of 1ms, however it seems that it actually takes much longer when the operation is timing out.

 

My loop does not only contain this visa read call, but it's pretty clear that regardless of how badly wired the rest of the loop is, the bottleneck is clearly the read call (replacing it with a wait function of 1ms is definitely faster).

 

The elapsed time can up to 29ms (on my local) configuration when using the read call and about 1-2ms when using a dummy wait.

 

I am aware of the underlying operations, the serial port is leveraged as a file through the OS sometimes it may be suject to locks and can be slower than the timeout indicated in the configuration but seems it's still kinda too much compared to what I get with the wait call.

 

Any idea to improve that?

 

 

Thanks

0 Kudos
Message 1 of 4
(2,836 Views)

Why do you even want to do this?  This seems more like a poor plan of attack than an issue with the VISA Read.

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 2 of 4
(2,811 Views)

You should replace the sequence structure with a simple state machine. That is much easier to interrupt.

 

But...., the key to your question may be in part of the code which you did not include. What is the baud setting? How many bytes are in each message? Does each message contain a termination character? Is the port configured to use the termination character?

 

Lynn

0 Kudos
Message 3 of 4
(2,775 Views)

I'd still like to know why you want this unusual behavior.  Maybe we can suggest something better.

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 4 of 4
(2,769 Views)