Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Using external code in VISA

Hi,
 
I am new to use of labVIEW. I have a function that initialize my device and returns the status.
How can i call that function from VISA\open.
 
Thanks
Jacob
0 Kudos
Message 1 of 7
(3,406 Views)
VISA Open cannot call another function. I don't think you understand how VISA works. I would recomend http://www.vxipnp.org/ for information on the VISA api.
Message 2 of 7
(3,399 Views)

Hello,
VISA Open is typically your first VISA function to call.  You must open a connection to the resource before you use it.  The resource is your instrument.  To send it a command, you can use a VISA Write followed by a VISA Read in order to read the instruments response and then a Close to close out the resource.  You sometimes will need a Wait in between your write and read in case your instrument needs more time to respond.  What Dennis suggested is a great first step.  If you know more about the VISA API, you will be able to program much more easily.  You can also check out the examples that ship with LabVIEW from the Example Finder in the LabVIEW Help Menu (if you are using LabVIEW).  If you are having trouble with anything, please give a little more information about what is happening so we can better assist you.  Best of luck to you and have a great day!

Chris R.
Applications Engineer
National Instruments

Chris R.
Applications Engineer
National Instruments
0 Kudos
Message 3 of 7
(3,365 Views)

I've played around with LabVIEW for a while and studied some instrument
driver documents from the NI web site. We are considering implementing an
instrument driver, however the "instrument" is completely implemented in
software in a DLL (it controls specific external hardware). How can i develope

an Instrument driver for the same device in labVIEW using Call Library Function
instead of using the VISA I/O.

0 Kudos
Message 4 of 7
(3,355 Views)
Hey Device Driver,

it depends on you, your device and the targeted audience what you can do.
NI usually suggests to build a new driver according to their design rules, but this can be quite an effort. If you plan that device just for internal purposes or have just a few customers, you might as well implement just the required functionality. We do this often for small-number series of devices targeted for a dedicated and well-known usage.

If you decide to go this way, you just have to decide which driver functionality you need (for instance 'Init', 'createSignal', 'sendSignal', 'stopSignal' and 'Shutdown'). Create a case for each functionality, that calls the appropriate DLL function. If some or each functionality have common dll-calls or require complicated sequences of calls to the dll, use a state machine architecture instead. In either case your LabVIEW driver is more or less just a wrapper around your dll.

Greetings from Germany!<br>-- <br>Uwe
0 Kudos
Message 5 of 7
(3,349 Views)
Hi
Thanks for reply,
 
Can i create subVIs for each functionality like Initialize, close , data etc. These will not be standard VIs of VISA architecture rather each will contain Call Library function node to call appropriate DLL function to Initialize, close device etc.
0 Kudos
Message 6 of 7
(3,347 Views)
Of course you can, but I would not call this a driver, but more or less some wrapped ddl calls.
There is, however, a potential pittfall, as LabVIEW and its call library node can not provide all data types a dll might require. No problems for scalars, arrays and strings, but complicated structs or clusters might be problematic.
If you create a driver, this might be of this kind of structure (pseudocode):
If not error than
  Case command =
    * 'init' than call DLL(Init) {and other related code}
    * 'Data' than call DLL(Data) {dito}
    ...
  Else  Generate Error('Wrong command')
Else pass error through

Greetings from Germany!<br>-- <br>Uwe
0 Kudos
Message 7 of 7
(3,342 Views)