LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to run vi continuously when VISA read timeout happens

Solved!
Go to solution

Hello,

 

I am using LabView 2010 to read an Agilent 6000 series Oscilloscope. The Oscilloscope reads data from another experimental machine which fails occasionally due to sample failure. When the machine fails, it stops sending signal to the oscilloscope and leads to the VISA read timeout error and the whole vi is terminated.  Is there a way that I can continuously run the vi when the error happens? For example, when the error happens, it stores the error in the error wire. When the vi read the error code from the wire, it sends a command to stop my experimental machine then stop the vi. 

 

So far, it just simply stops during executing the visa read function. In this case, why do we have error in and out? The vi simply stops when the error happens. 

 

Thanks

 

Lawrence

0 Kudos
Message 1 of 17
(3,338 Views)

Hi Lawrence,

 

All you need to do is to extract out the error code using Unbundle by Name, then check whether the error code matches with the timeout error (You need to find out the timeout error code). Then place the code to shutdown the machine in the TRUE case, as shown below.

 

Code.png



See that button on the left side of this post...

If you feel my post is helpful, all you need is just (at most) 2 seconds to click that button, to show your appreciation. Thank you~~



Message 2 of 17
(3,329 Views)

Thank you for your reply. I have tried this out but it doesn't work. I put similar code right after the VISA read, but I think the program stops at the VISA read and doesn't go further. 

0 Kudos
Message 3 of 17
(3,301 Views)

Hi Lawrence,

 

If possible, just attach your VI so that we can see what went wrong.

I'm sure that your VI will not stop at VISA read, unless you did not pass the any error wire from VISA read to the next VISA function (probably VISA close) and you've enabled the automatic error handling.



See that button on the left side of this post...

If you feel my post is helpful, all you need is just (at most) 2 seconds to click that button, to show your appreciation. Thank you~~



0 Kudos
Message 4 of 17
(3,296 Views)

Could you please explain a little bit more about the VISA close and automatic error handling? What do they do and how do they affect the program? My code is in the computer in the lab which is now running an experiment. I will try to have a screen print when it finishes. 

0 Kudos
Message 5 of 17
(3,288 Views)

I'll start of with automatic error handling. By default, LabVIEW enables the automatic error handling. So consider the case like the one below,

Capture.PNG

If let's say the VISA Read returns an error, but you did you pass the error information to VISA Close, what will happen is that LabVIEW will highlight the VISA Read (since the error comes from that function), pause the execution at the VISA Read and an error dialog box will appear. From the dialog box, it will prompt to either continue (Move on to the VISA Close) or stop (LabVIEW will stop the VI at VISA Read)

 

Now, consider another scenario like this,

Capture2.PNG

By passing the error information from one function to another, let's say if VISA Read returns an error, that error will pass to VISA Close and finally to Simple Error Handler.vi. So Simple Error Handler will generate error dialog box after all the VISA operation is completed. This is called manual error handling (It can be enabled by just wiring the error information from one function to another and terminates at Simple Error Handler).

http://www.ni.com/gettingstarted/labviewbasics/handlingerrors.htm

 

As for VISA Close, here is the information about VISA Close.

http://zone.ni.com/reference/en-XX/help/371361K-01/lvinstio/visa_close/



See that button on the left side of this post...

If you feel my post is helpful, all you need is just (at most) 2 seconds to click that button, to show your appreciation. Thank you~~



Message 6 of 17
(3,271 Views)

Hi, this is my subvi. Could you please have a look?

 

subVI_1.JPG

0 Kudos
Message 7 of 17
(3,249 Views)

If you don't want a particular error to permeate through your code, just place ongeelim's recommended code after whichever VI intermittently gives you the error you want to suppress.  In the true case (the error you didn't want occurred), create a default error terminal (no error) and route that out.  In the false case (either no error occurred or some other unrelated error occurred), just wire the error cluster through the case structure.

-John Sullivan
Problem Solver
0 Kudos
Message 8 of 17
(3,239 Views)

Hi Lawrence,

 

From the diagram, I noticed that there are flaws going on in your program. I'll just point out the important ones.

1. The VISA Close should be placed outside the While Loop normally place, after the Timeout property node.

2. The Simple Error Handler.vi should also be placed outside the While Loop, otherwise the running VI will pause inside the While Loop. (You can use Merge Error function to combine 2 error wires together and return the 1st error/warning detected)

Note: But since you've used Error Out cluster indicator, you do not need Simple Error Handler.vi as the Error Out indicator can also report the error/warning without displaying the error dialog box.

3. The Stop function in the Case Stucture is not necessary. The While Loop will stop eventually if there's a timeout error occurred.

4. You should place a VISA Open function at the start of the VI (before Timeout property nodes on the left side), to open/initialize your VISA resource before accessing the resource.

5. The AG33xxx (I think its for AG33xxx Signal Generator, right? ) function should also have Initialize and Close functions (I believe AG33xxx palette should have these functions as well) placed before and after the While Loop respectively.

 



See that button on the left side of this post...

If you feel my post is helpful, all you need is just (at most) 2 seconds to click that button, to show your appreciation. Thank you~~



0 Kudos
Message 9 of 17
(3,231 Views)
I just realised that my previous uploaded subVI was not quite right, I will upload another one next Monday.
0 Kudos
Message 10 of 17
(3,216 Views)