From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

Possible Timeout in VISA Read/Write in While Loop

Solved!
Go to solution

As the title says, I have a while loop that is constantly writing then reading using VISA read/write.  I am waiting for the buffer to match a certain one, which when true would end the loop.  In this loop, I have an indicator showing how often it runs. All of this is being repeated in another while loop.

 

My issue comes that the counter gets to 10, then stops at the write command.  Not sure why.  I tried increasing the instruments timeout, but nothing changed.  I added a 10ms delay in the loop, which also did not change anything.

 

For reference, I am using a tektronix MDO 3000 series scope, and checking for its trigger state.

0 Kudos
Message 1 of 10
(4,711 Views)

It is very difficult to help someone debug a paragraph.  Please attach you VI so we can see what it is you are describing.

0 Kudos
Message 2 of 10
(4,708 Views)

Can you trace back where the True value is coming from that's stopping the loop? (Use probes.)

If you can trace it back to the string buffer as getting a match, have you probed the string(s) to see if it does indeed match up? Do you have an error cluster that could be stopping the loop?

You say it stops at the Write command... what does this mean? Are you force stopping your application?

 

There's not much we can help you with without seeing your code. Really, your best bet is to use probes and conditional stop probes to debug and figure out what's stopping the loop.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 3 of 10
(4,707 Views)
Stops at the write command means loop terminates or hangs during write?
----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 4 of 10
(4,696 Views)

VI attached.  It just chills at the read.

 

And it is the Inner Loop that stops at 10.

0 Kudos
Message 5 of 10
(4,675 Views)

Put an indicator on the string wire so you can see what the data looks like coming in from the VISA read.  It looks like it will stop whenever you get "SAV\n" coming in.  Are you getting that?

 

I recommend getting rid of the shift register on the error wires.  If you ever get an error such as a timeout, that error will propagate forever and none of those functions will work until you stop your VI and restart it.

 

What does "it chills at the read" actually mean?  If nothing is coming in, then the VISA read will probably wait 10 seconds (default timeout, unless you changed it to something else somewhere else).  Then you'll get a timeout error and that inner loop will keep running as fast as it can because none of those functions will execute with an incoming error.  The only way the inner while loop stops at 10 is if it gets "SAV\n" on that 10th iteration  (maybe 11th depending on how you count.)  And that  would not mean "chill at the read" to me.

0 Kudos
Message 6 of 10
(4,661 Views)

So I did the indicator, it is stopped when Loop=1, Inner Loop=11, and the indicator reads REA, not SAV.  Also got rid of shift registers, probed the errors and saw nothing.

 

What I mean when I say it is "chillin" there is that when I run it with "HighLight Execution" on, it goes through until the loop is 11, and then the dot/execution goes into the Write and does not come out of it, so it chills at the write.

 

Also, I wait for several minutes and do not get a timeout error.

 

 

0 Kudos
Message 7 of 10
(4,648 Views)
Solution
Accepted by topic author jmaslek

You had said chill at the read earlier!

 

But it doesn't make sense for it to hold at the write either.  As an experiment, go to all the VISA nodes, right click and pick Synchronous I/O Mode.  Make it synchronous instead of asynchronous.  The watch symbol will disappear from the upper right corner.  See if that changes anything.

 

What kind of serial port are you using?  Is it one built into the PC?  A USB to serial port adapter?  Who makes the chips on it , Prolific or FTDI?  Can you try with a different serial port or brand of adapter?  Many people have had problems with prolific chips.  And I've also heard of people having problems using adapters that had counterfeit chips in them.

 

 

Message 8 of 10
(4,639 Views)

Ha.  The synchronous I/Oget fixed that issue!

 

We are just using a USB output from the Scope to the computer.

0 Kudos
Message 9 of 10
(4,608 Views)

I don't fully understand the synchronous vs. asynchronous setting.  I've never had to mess with it myself.  But since it seemed like it was some sort of timing issue and possibly locking up the driver, I figured it was worth a shot.  I'm glad it's working for you now.  I don't know if you can fully trust it yet, so keep an eye on it.  But if it keeps working without further issues, that's great.

 

Good luck!

0 Kudos
Message 10 of 10
(4,579 Views)