Saturday, September 25, 2010

Using Instrument Driver VIs

Summary: In this lesson, you will learn how to use instrument driver VIs.
Instrument drivers are developed with a specific instrument in mind and eliminate the need for the user to know the exact IEEE 488.2 commands that the instrument is expecting.

Components of an Instrument Driver

All instrument drivers in the library have the same basic VI hierarchy. The hierarchy, sequence of VIs, and error handling are the same as those used in other areas of I/O in LabVIEW, such as file I/O, DAQ, TCP/IP, and so on. Refer to the File I/O VIs and Functions section of the Strings and File I/O lesson, for more information about error handling.
Figure 1 shows the hierarchy of an instrument driver.
Figure 1
Figure 1 (instdrivercomp.png)
The high-level functions are built from the low-level functions. For the most control over the instrument, use the low-level functions. The high-level functions are easy to use and have soft front panels that resemble the instrument. Instrument drivers have VIs in the following categories:
  • Initialize: Initializes the communication channel to the instrument. This VI also can perform an identification query and reset operation, and it can perform any necessary actions to place the instrument in its default power-on state or other specified state.
  • Configuration: Configures the instrument to perform operations, such as setting up the trigger rate.
  • Action/Status: Contains two types of VIs. Action VIs cause the instrument to initiate or terminate test and measurement operations. Status VIs obtain the current status of the instrument or the status of pending operations. An example of an action VI is Acquire Single Shot. An example of a status VI is Query Transfer Pending.
  • Data: Transfers data to or from the instrument, such as reading a measured waveform from the instrument or downloading a waveform to the instrument.
  • Utility: Performs a wide variety of functions, such as reset, self-test, error query, and revision query.
  • Close: Terminates the communication channel to the instrument and deallocates the resources for that instrument.
All National Instruments instrument drivers are required to implement the following functions: initializecloseresetself-testrevision queryerror query, anderror message.

Application Examples

LabVIEW also includes application example VIs that show how to use the component VIs to perform common tasks. Typically, this includes configuring, triggering, and returning measurements from an instrument. An application example VI does not initialize or close the instrument driver. These VIs are not intended to be a soft front panel for the instrument but rather to demonstrate some instrument driver capabilities and guide you in developing your own VI.

Inputs and Outputs of Instrument Driver VIs

Just as all instrument drivers share a common VI hierarchy, they also share common inputs and outputs.

Resource Name or Instrument Descriptor

When you initialize the communication channel to an instrument, you must know the resource name or instrument descriptor. A resource is an instrument or interface, and the instrument descriptor is the exact name and location of a resource in the following format:

     Interface Type[board index]::Address::INSTR
   
Optional parameters are shown in square brackets [ ]. For example, GPIB::2::INSTR is the instrument descriptor for a GPIB instrument at address 2.
The VISA resource name control located on the Controls>>All Controls>>I/O palette is similar to the DAQ channel name control, but it is specifically used for instrument control. Refer to the VISA section for more information about VISA.
You can use MAX to determine what resources and instrument addresses are available, as you did in GPIB Configuration with MAX when you assigned a VISA alias of devsim to the NI Instrument Simulator. The alias makes it easier to communicate with instruments because you no longer need to memorize which interface and address each instrument uses. You can use the alias in the VISA resource name control instead of the instrument descriptor. For example, you can type devsim instead of GPIB::2::INSTR.

VISA Sessions

After you initialize an instrument, the Initialize VI returns a VISA session number. The VISA session is a connection or link to a resource, such as the instrument. You do not need to display this value. However, each time you communicate with that device, you must wire the VISA session input on the instrument driver VIs. After you finish communicating with the instrument, you use the Close VI to close all references or resources for the instrument.

EXAMPLE 1: Example Instrument Driver Application

The block diagram in Figure 2 initializes the instrument with the devsim alias, uses a configuration VI to select a waveform, uses two data VIs to read the waveform and the waveform scaling information, closes the instrument, and checks the error status. Every application that uses an instrument driver has a similar sequence of events.
Figure 2
Figure 2 (instdrvex.png)

Content actions

GIVE FEEDBACK:

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Popular Projects

My Blog List

Give support

Give support
Encourage Me through Comments & Followers

Followers