Using Instrument I/O Assistant to Create LabWindows/CVI Instrument Drivers

Publish Date: Feb 02, 2012 | 5 Ratings | 2.40 out of 5 |  PDF


National Instruments LabWindows/CVI expands your options for communicating with and controlling your instrumentation systems with one of the industry-standard development tools. With the new Instrument I/O Assistant in LabWindows/CVI, you can perform simple instrument I/O tasks or use it as a building block to help create instrument drivers. You can quickly and easily send commands to your instrument and view the responses in real-time. This article describes the Instrument I/O Assistant in LabWindows/CVI and how you can use it as a debugging utility and as a tool to parse complex responses from an instrument.

Table of Contents

  1. How to Use Instrument I/O Assistant
  2. Instrument I/O Assistant and the VISA Interactive Control
  3. Incorporate I/O Assistant Parsing in Your Instrument Drivers
  4. Summary

1. How to Use Instrument I/O Assistant

You can access Instrument I/O Assistant from the toolbar (Figure 1) or from the Tools menu (Figure 2) in LabWindows/CVI 7.0. When you launch Instrument I/O Assistant, the interactive window automatically appears.

Figure 1. Instrument I/O Assistant Toolbar Item

Figure 2. Access Instrument I/O Assistant from the Tools menu.

Once Instrument I/O Assistant appears (Figure 3), select your instrument from the drop-down instrument list and then add steps to communicate with the instrument. The list of instruments is generated automatically by making a find resource call and checking Measurement & Automation Explorer (MAX), an I/O configuration utility, for any existing unique instrument names or aliases. You can search for instruments and assign unique names or aliases for your instruments through MAX. The unique names and aliases automatically populate the Instrument I/O Assistant instrument pull-down menu.

Figure 3. Instrument I/O Assistant

You might want to configure specific parameters on your instrument, such as triggering or coupling, before you read back measurement data. You can write these specific commands with the write step in Instrument I/O Assistant. You also can perform query and parse steps to send commands to the instrument and automatically display the response in the interactive window. After you receive a response from the instrument, Instrument I/O Assistant can parse the response for you, automatically converting the data into a more usable format, such as a numeric data type. Because parsing data is usually the most tedious aspect of instrument programming, Instrument I/O Assistant can save you significant development time in your instrument control applications.

In addition to automatically parsing data, you can manually parse data using Instrument I/O Assistant if you want to look at specific pieces of the data returned. With each piece of data parsed you can assign tokens, or outputs, for the parsed values. The function call shown in Figure 4 outputs the current tokens for this sequence of commands and responses. These tokens appear as outputs from the generated Instrument I/O Assistant code and can then be passed to your user interface (Figure 4) or analysis functions. Moreover, you can apply scaling for your tokens to convert the responses from your instrument into real-world data. Because parsing, formatting, and scaling data can sometimes be a difficult task with instrument communication, Instrument I/O Assistant delivers automatic, interactive parsing and scaling so you can convert your instrument data correctly without extensive debugging.

Figure 4. Use RunIOTask to call the generated code and send to user interface indicators.

Because Instrument I/O Assistant generates native LabWindows/CVI source code, you can modify the generated code and use the modular format (*.c and *.h) to reuse the generated code. Viewing the underlying code also can help you understand the parsing and formatting involved with sending these commands.

Figure 5. Instrument I/O Assistant generates a source, header, and *.mxb file when you create the IO task (the *.mxb file launches the assistant).

Back to Top

2. Instrument I/O Assistant and the VISA Interactive Control

In general, Instrument I/O Assistant is not designed as a replacement for well-written, full-featured instrument drivers. For the majority of your applications, the instrument driver code templates and other documentation available on should serve as the model for your instrument drivers. However, Instrument I/O Assistant does deliver several benefits for both beginning and advanced instrument driver developers.

The main benefit of using Instrument I/O Assistant is as a tool for investigating instrument responses, much like the VISA Interactive Control (VISAIC) utility. With the assistant you can maintain a command history so that retyping or remembering previous commands is not necessary. For experienced instrument driver developers, this can save significant time when trying to debug a piece of code or in figuring out how an instrument responds under a certain set of parameters. Furthermore, Instrument I/O Assistant features a Query step, whereas VISAIC can only read and write commands. However, VISAIC is still a useful tool if you are performing register-based programming as opposed to standard message-based command sets.

With Instrument I/O Assistant you can view parsed code as real data types (e.g., graphed waveforms) instead of just ASCII or binary in VISAIC. This can be helpful in comparing data real-time with what you see on an instruments’ front panel.

Finally, you can check for instrument errors automatically in the interactive window with the assistant, while VISAIC requires you to manually check registers to determine instrument errors.

See Also:
Instrument Driver Network

Back to Top

3. Incorporate I/O Assistant Parsing in Your Instrument Drivers

Instrument I/O Assistant helps you quickly parse complex responses from an instrument for use in their native-code instrument drivers. You would apply your parsing in the interactive window, close the assistant, and open the generated source code. Here, you can copy out the complex parsing routine to use in your instrument driver (See Figure 6). Because parsing can be tricky, using the Instrument I/O Assistant interactive window to parse a set of complex code can save you time in creating your instrument driver.

Figure 6. Easily copy the parsing routines to use in your instrument driver.

Back to Top

4. Summary

In conclusion, Instrument I/O Assistant is a useful tool to communicate with instruments when an instrument driver is not available. Furthermore the assistant can be used to assist instrument driver developers as a good replacement for the VISA Interactive Control and in creating complex parsing routines.

Related Links: 

Back to Top

Bookmark & Share


Rate this document

Answered Your Question?
Yes No