|LabWindows/CVI 2010 Help|
|LabWindows/CVI 2012 Help|
|LabWindows/CVI 2013 Help|
|LabWindows/CVI 2015 Help|
|LabWindows/CVI 2017 Help|
|LabWindows/CVI 2019 Help||LabWindows/CVI 2020 Help|
Instrument drivers are high-level function libraries for controlling specific GPIB, VXI, serial instruments, or other devices. With an instrument driver, you can control an instrument without knowing the low-level command syntax or I/O protocol. IVI instrument drivers apply an attribute-based approach to instrument control to deliver better run-time performance and more flexible instrument driver operation.
An IVI instrument driver specifies each readable or writable setting on the instrument, such as the vertical voltage range on an oscilloscope, as an attribute. The IVI Engine works in conjunction with IVI instrument drivers to manage the reading and writing of instrument attributes. The IVI Engine tracks the values of attributes in memory and controls when instrument drivers send and read settings from instruments. By managing instrument attributes and mandating a standard structure for the internal driver implementation, the IVI Engine adds many features to instrument drivers, including the following:
Enable or disable these features by setting special attribute values in the instrument driver. For example, you can set the FL45_ATTR_RANGE_CHECK or FL45_ATTR_ attributes of the Fluke 45 digital multimeter driver to VI_TRUE to enable range checking or simulation. These types of attributes are called inherent IVI attributes because every IVI instrument driver has them and because these attributes control how the instrument driver works rather than representing particular instrument settings.
This section presents a simplified view of how the IVI Engine and driver work together. The actual process involves additional steps that implement other powerful features. The rest of This section discusses the entire process in detail.
The key to the IVI architecture is the manner in which the IVI Engine controls the reading and writing of attributes to and from the instrument. The instrument driver contains callback functions that read and write instrument settings and range tables that specify the valid range for each instrument attribute. The IVI Engine accesses the range tables and invokes the callbacks at the appropriate times. For example, suppose the instrument driver exports an niScope_ConfigureChannel function that configures the vertical subsystem of an oscilloscope. Suppose that you pass 5.0 to the verticalRange parameter of the function. The driver and the IVI Engine work together to execute the following steps:
Notice that steps 1 through 5 repeat for each parameter that you pass to Scope_ConfigureChannel. The following figure illustrates this process.
|Note You must call an Initialize and a Close function for every instrument session to properly allocate and free system resources.|
Each IVI instrument driver presents a set of high-level functions for controlling an instrument. The high-level functions are sufficient for most applications. Although each IVI instrument driver exports SetAttribute and GetAttribute functions, you typically do not use them in high-level application programs. When you call the configuration functions in the instrument driver, you specify configuration settings. The configuration functions pass these settings to SetAttribute function calls. In many cases, it is necessary to send settings to the instrument in a particular order. The high-level configuration functions handle these order dependencies for you.
To use an instrument driver for a particular instrument, you must first initialize an IVI instrument driver session. When you initialize an IVI session, the IVI Engine creates data structures to store all the information for the session. Each IVI instrument driver exports two functions for initializing an IVI session: Prefix_init and Prefix_InitWithOptions, where Prefix is the instrument prefix for the driver. Both functions require that you identify the physical device. The functions give you the option of performing ID query and reset operations on the device. The functions also initialize the device for correct operation of subsequent instrument driver function calls.
The Prefix_InitWithOptions function has a string parameter in which you can set the value of inherent attributes such as IVI_ATTR_RANGE_CHECK, IVI_ATTR_SIMULATE, and IVI_ATTR_QUERY_INSTR_STATUS. Set these attributes through the Prefix_InitWithOptions function so that the settings are in effect during the initialization procedure. It is particularly important to use the Prefix_InitWithOptions function if you want to enable simulation. The initialization procedure usually attempts to interact with the physical instrument. If the instrument is not available, you must enable simulation in the call to Prefix_InitWithOptions to prevent the initialization from failing.
The Prefix_init and Prefix_InitWithOptions functions return an IVI session handle that you pass to subsequent calls to instrument driver functions. If you want to use the same instrument driver for a separate physical device, you must call Prefix_init or Prefix_InitWithOptions again to initialize a different IVI session.
Do not open multiple IVI sessions to the same physical device because two separate cached states may not be identical and one may be out of sync with the instrument. If you want to use the same instrument in different execution threads, you can do so by sharing the same session handle across multiple threads in the same program. IVI instrument drivers functions are multithread safe. In some cases, however, you might have to lock a session around a sequence of calls to an IVI instrument driver. For example, if you call a configuration function and then take a reading in one thread, you must prevent calls to instrument driver functions in other threads from altering the configuration between the two function calls in the first thread. Each IVI instrument driver exports the Prefix_LockSession and Prefix_UnlockSession functions for this purpose.