LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Proper VISA use

Solved!
Go to solution

I'm still kind of new with LabVIEW, and I came across the VISA open/close functions (they were hidden under the Advanced tab so I never saw them before).

 

My question is if I am supposed to be using those VISA open/close functions when I make gpib drivers for equipment I use.  For example: attached is a simple code that will set up my Keithley 181 and take a measurement (really only for demonstration purposes).  I highlighted the open/close functions, I have never actually used them before, and normally if I wanted to write the same code I would have just skipped them and gone straight to the VISA write (which still works).  I haven't seen any problems with the drivers I have made, even though I have not used these functions in the past, but maybe there is a chance that some unexpected results could occur, I am not really sure.

 

Thanks!

 

 

0 Kudos
Message 1 of 3
(2,090 Views)

Hi Lars,

 

let's compare VISA with simple FileIO:

First you open a file (providing it's filename), then you read/write the file, then you close the file. You do the same with VISA: open the connection, read/write data, close the connection...

 

It's the same when using DAQmx, queues, and many other: open the resource, work with it, and close the resource afterwards!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 3
(2,081 Views)
Solution
Accepted by topic author LarsUlrich

Once upon a time, the use of the VISA Open was required. A session was not created unless you explicitly called it. Then, VISA got a bit smarter and if a VISA function is called, if the session does not already exist, it is automatically created. So, calling the Visa Open is somewhat optional though I still prefer to use it in my code. With the VISA Close, there is a setting (tools>Options>Environment) that will automatically close VISA sessions when you exit the top level VI but, especially with serial, I prefer to have more control.

Message 3 of 3
(2,073 Views)