LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why Open VISA Session?

In the driver here, the VISA Open sub-VI states that it "must be called first" when using the device. There is a similar sub-VI for closing the session.

How true is this?

I can open and run a different sub-VI (such as Write Single) with no immediately obvious problems, just by specifying the correct device in the VISA Session field. Are errors or performance hits building up in the background?

My problem is that the KS 3988 will be called on in sub VI's within sub VI's within sub VI's (relative to the main program). I'm not clear on where, exactly, I should be putting that VISA Open panel. This is especially confusing if the "dup VISA session" needs to be wired into every use of the Write Single sub-VI.
0 Kudos
Message 1 of 9
(4,024 Views)
Only open the session once, pass it into the subvi as a control and pass it out of the subvi as an indicator so that you close that visa session when you are done with it.  As for the performance hit, I cannot speak to that.  Perhaps someone with more experience there can help.
Message 2 of 9
(4,012 Views)

When that driver was originally written, it was a requirement that a VISA Open be called once, at the very beginning of a program.  Eventually, NI-VISA was changed so that if the user forgot to do the open, the driver would automatically open a VISA reference. Why no longer required, it is still recomended that you do it.

You would typically have a VISA Resource wired to every subVI anyway so I don't understand your other concern. Leaving it unwired and letting it default is a pretty bad habit to get into.

Message 3 of 9
(4,010 Views)
Here is a picture of the VI which actually calls the KS 3988.



My problem is that this thing is just the sub VI of a VI which is itself the sub VI of a VI that is running in a frame. The top-level VI that contains the frames has four such frames.



Now, those top three VI's all read out of the black Admin sub VI, and the bottom can both read from it and write to it. Currently, all programs use the same KS 3988 via VISA, but that needs to be something we can change on the fly.

So, where does the Open sub VI go? Do I need to include, in the frame-containing VI, something like this?



Message Edited by DJDDA on 07-31-2008 04:10 PM
Download All
0 Kudos
Message 4 of 9
(4,002 Views)
There is really no reason to put the initialize function inside each case/frame. Do it once when the main first start and just pass the reference into each case/frame.
Message 5 of 9
(3,984 Views)
I need to be able to change the reference at whim, though. This is the purpose of the black "admin option" sub VI.

Is it acceptable to open the reference, pass it into "admin option," and modify or distribute it as needed?
0 Kudos
Message 6 of 9
(3,979 Views)
You could open references to all your devices and store them in a cluster, and then unbundle the appropriate reference when it is needed.  This way you just carry your cluster around.  Be sure to close them all at the end.
Message 7 of 9
(3,974 Views)
Of course. I do this all of the time with an event structure and the new reference is wired to a shift register.
Message 8 of 9
(3,973 Views)
Thanks guys!
0 Kudos
Message 9 of 9
(3,941 Views)