control and automation

5
Accelerate Instrument Control and Automation Deborah Homan Technical Marketing Engineer Agilent Technologies, Inc Loveland, CO USA [email protected] Abstract— Automating instrument set-up and measurement within a programming environment can be difficult. The instrument commands and programming languages are different, and do not always integrate well. Instruments may have hundreds if not thousands of commands and knowing all of the correct parameters and what is possible for each instrument can be very time consuming and tedious. A new free programming tool from Agilent Technologies (Command Expert) bridges the gap between the computer programming language and the instrument commands accelerating the automation process. This paper will demonstrate the details of creating a sequence of instrument commands that will perform the necessary set-up and measurement and will assure the correct syntax and options for later integration into an automated environment. Instrument commands can be profiled to improve execution time and identify bottlenecks. Different instruments can be substituted, and the software will identify commands that need to be altered or will not work for the new instrument. The command sequence once developed and tuned can easily be used in the following Application Development Environments (ADEs): Visual Studio®, LabVIEW, MATLAB, VEE, SystemVue and Excel®. These and other features help remove many of the barriers that exist today when trying to automate instrument control for validation and test. I. INTRODUCTION Instruments are being controlled by the PC more and more to automate measurements, to analyze measurement data, or both. The process of getting the information from the instrument to the PC requires not just the wired connection, but the ability to have the PC speak the language of the instrument. Instruments use text or ASCII-based commands such as Standard Commands for Programmable Instruments (SCPI) or drivers such as IVI-COM, and the programs may be text-based or graphical but use different syntax and constructs than the instruments. This paper uses the capture of a waveform from channel 1 of an Agilent MSO6032A as an example to demonstrate the steps to simplify and accelerate test development and automation. The example uses the instrument’s SCPI commands. The methodology works in the general case as well. The software can be downloaded from the Agilent.com web site (www.agilent.com/find/commandexpert ), and once installed, the SCPI Command Set for the oscilloscope (InfiniiVision 6000 Series Oscilloscopes / 06.10.0001) can be downloaded by going to File > Manage Command Sets and choosing the SCPI Command Set. The Command Expert user interface (Figure 1) provides the instrument commands and associated documentation, which can be browsed by navigating the command tree or searched to more quickly find the appropriate commands. The form-based interface guides the selection of the correct options and parameters for the instrument commands. Figure 1 Command Expert User Interface II. INSTRUMENT CONNECTION Instruments have USB, LAN, RS-232, PXI and/or GPIB as the interface connection(s) to the PC, and Command Expert works with any of these interfaces using the standard instrument address formats. For this example, the connect step will use the VISA resource address format over USB. This address can be 978-1-4673-0700-0/12/$31.00 ©2012 IEEE

Upload: athul-ks

Post on 30-Nov-2015

66 views

Category:

Documents


2 download

DESCRIPTION

control and automation

TRANSCRIPT

Page 1: control and automation

Accelerate Instrument Control and Automation

Deborah Homan Technical Marketing Engineer

Agilent Technologies, Inc Loveland, CO USA

[email protected]

Abstract— Automating instrument set-up and measurement

within a programming environment can be difficult. The instrument commands and programming languages are different, and do not always integrate well. Instruments may have hundreds if not thousands of commands and knowing all of the correct parameters and what is possible for each instrument can be very time consuming and tedious. A new free programming tool from Agilent Technologies (Command Expert) bridges the gap between the computer programming language and the instrument commands accelerating the automation process.

This paper will demonstrate the details of creating a sequence of instrument commands that will perform the necessary set-up and measurement and will assure the correct syntax and options for later integration into an automated environment. Instrument commands can be profiled to improve execution time and identify bottlenecks. Different instruments can be substituted, and the software will identify commands that need to be altered or will not work for the new instrument. The command sequence once developed and tuned can easily be used in the following Application Development Environments (ADEs): Visual Studio®, LabVIEW, MATLAB, VEE, SystemVue and Excel®. These and other features help remove many of the barriers that exist today when trying to automate instrument control for validation and test.

I. INTRODUCTION Instruments are being controlled by the PC more and more

to automate measurements, to analyze measurement data, or both. The process of getting the information from the instrument to the PC requires not just the wired connection, but the ability to have the PC speak the language of the instrument. Instruments use text or ASCII-based commands such as Standard Commands for Programmable Instruments (SCPI) or drivers such as IVI-COM, and the programs may be text-based or graphical but use different syntax and constructs than the instruments.

This paper uses the capture of a waveform from channel 1 of an Agilent MSO6032A as an example to demonstrate the steps to simplify and accelerate test development and automation. The example uses the instrument’s SCPI commands. The methodology works in the general case as well. The software can be downloaded from the Agilent.com web site (www.agilent.com/find/commandexpert), and once installed, the SCPI Command Set for the oscilloscope (InfiniiVision 6000 Series Oscilloscopes / 06.10.0001) can be

downloaded by going to File > Manage Command Sets and choosing the SCPI Command Set.

The Command Expert user interface (Figure 1) provides the instrument commands and associated documentation, which can be browsed by navigating the command tree or searched to more quickly find the appropriate commands. The form-based interface guides the selection of the correct options and parameters for the instrument commands.

Figure 1 Command Expert User Interface

II. INSTRUMENT CONNECTION Instruments have USB, LAN, RS-232, PXI and/or GPIB as

the interface connection(s) to the PC, and Command Expert works with any of these interfaces using the standard instrument address formats.

For this example, the connect step will use the VISA

resource address format over USB. This address can be

978-1-4673-0700-0/12/$31.00 ©2012 IEEE

Page 2: control and automation

discovered using a utility such as Agilent Connection Expert, part of the IO Libraries Suite.

If hardware is not available, Command Expert can be used by working offline to build the command sequence. This can be a good starting point for learning a new instrument in a more interactive way, in contrast to reading a manual. In this example, the oscilloscope is connected to the PC via USB with VISA address: USB0::0x0957::0x1732::30d3090505::0::INSTR

This VISA address is entered into the Address field of the command pane, and the Connect step is:

Connect "MSO6000 Series",

"USB0::0x0957::0x1732::30d3090505::0::INSTR", "InfiniiVision 6000 Series Oscilloscopes / 06.10.0001"

III. INSTRUMENT COMMANDS The SEARCH feature of Command Expert will return all

commands and documentation related to the search term, ordered by relevance, making it fast and easy to the find the right commands. Then, Command Expert can be used to experiment, to interactively set up and initialize the instrument, and to perform a specific measurement.

In the waveform capture example, after the instrument is connected, the SEARCH tab (Figure 2) can be used to find the right commands to send to the instrument. The terms “digitize” and “waveform” can be entered into the form and appropriate results are returned.

A. Command Sequences When a command is added to a sequence, Command Expert

provides assistance, such as including any other requirements for the command. Command Expert supports controlling multiple instruments within a command sequence.

In the waveform capture example, the command sequence needs to include commands to digitize and then to read back the waveform from channel 1. When the DIGitize command is selected, the documentation points to the need for an ACQuire command to be added.

Figure 2 Command Expert Search

When the SCPI command to read the waveform data is selected, Command Expert provides the formatting commands

required by this particular command and data type, and adds the additional required commands to the sequence. The documentation describes the waveform as having a preamble and waveform component.

The MSO6032A can transmit the data in three different modes: WORD, BYTE, or ASCII. When the digital channel is selected, ASCII and WORD are the only waveform formats allowed. Command Expert handles these requirements as well, and limits the selections in the sequence.

The final sequence for this example (InfiniiVision_6000Series_WaveformDownload) is included when Command Expert is installed, and is shown below.

Figure 3 Final Command Sequence

B. Sequence Optimization Command Expert provides a way to measure the execution

time of sequence steps or of an entire sequence by profiling the steps. The information provided can be used to optimize the sequence execution.

From the menu, select Play > Profile. When profiling is selected, a dialog box provides the option to STOP automatically executing SYST:ERR? queries, which speeds up execution time by turning off error checking. The average, minimum, and maximum times for each step and the entire sequence are displayed in the sequence pane, providing valuable information that can be used to further evaluate and then improve the performance of the sequence.

C. Hardware Interchange Another use of Command Expert is to understand the

potential change to the sequence if different hardware is substituted for the measurement. By selecting a different Command Set, any instrument commands that will not work are identified to quickly understand the impact of changing instruments within a working system.

For example, the Command Set can be changed from an InfiniiVision 6000 Series Oscilloscope to an Infiniium 90000 Series Oscilloscope, and the software identifies a number of commands that will not work with this hardware, such as the WAVeform:UNSigned, DIGitize CHANNEL1, WAVeform:PREamble?, and WAVeform:DATA? commands. These commands are all displayed in red with the statement

(Connect "MSO6000 Series", "USB0::0x0957::0x1732::30d3090505::0::INSTR", "InfiniiVision 6000 Series Oscilloscopes / 06.10.0001") :WAVeform:UNSigned 1 :WAVeform:BYTeorder LSBFirst :WAVeform:FORMat WORD :ACQuire:COMPlete 100 :DIGitize <source1> :WAVeform:SOURce CHANnel1 , , , <count>, , , , , , = :WAVeform:PREamble? <binary_block_data> = :WAVeform:DATA?

Page 3: control and automation

“Unknown command” or “Illegal command” preceding the command itself.

IV. APPLICATION DEVELOPMENT ENVIRONMENT (ADE) INTEGRATION

Command Expert understands the requirements of each supported programming language and will add additional required code to the command sequence. The details of the integration depend on the ADE used, and application notes for many of the environments are available on the Agilent web site.

In all languages, parameters for inputs and outputs to the instrument sequences can be passed to the ADE to enable additional control. Parameters provide the data that affects the running of a command sequence, and retrieve data that results from a sequence.

V. EXCEL Command Expert integration allows Excel to be the home

base for instrument control. Command Expert can be called from a worksheet to create, edit, control, and debug sequences. The Command Expert Excel Add-in is accessed through a new tab in Excel, which is available after Command Expert is installed on the PC. A Command Expert sequence reads its inputs from the workbook, and writes its outputs to the workbook. The Command Expert Ribbon includes execution of the sequence, displays the sequence task pane, and provides options for handling execution errors.

In the example where the waveform on channel 1 of the oscilloscope is captured, Excel is used to graph the waveform using the parameters passed between the instrument and the worksheet. The channel of the oscilloscope would be an input parameter to the sequence, and in Excel is an input entered into the specific cell. The waveform preamble from the scope is an output parameter that defines the vertical and horizontal scaling of the data of the corresponding channel. The waveform data, another sequence output, would be used by the worksheet to draw a graph, or do further analysis.

Command Expert can also export the sequence as a comma-separated value (CSV) file for Excel.

Command Expert includes a number of example programs that demonstrate integration with an Excel worksheet, such as: InfiniiVision_6000Series_WaveformDownload.xlsx

An available application note provides the steps for creating a sequence in Excel using Command Expert. [1]

VI. VISUAL STUDIO Visual Studio programs are widely used for test

automation and instrument control. Command Expert supports the text-based programming languages of Visual Studio through the export function File > Export Sequence. Command Expert includes the necessary commands and syntax required by each environment when the sequence is exported.

Command Expert supports Visual Studio in two ways: code generation for sequences, and hand-writing code that calls a SCPI.NET driver. Both options can accelerate automation by

providing tools and syntax checking previously not available. The options can be used together in a hybrid approach.

An available application note provides additional information about using Command Expert in Visual Studio[2].

a) Code generation

The code generation approach provides improved efficiency by allowing the development and testing of command sequences before the code is incorporated into a Visual Studio project. This can simplify and speed up the automation process.

Once the sequence is created, the options to generate code are found under File > Export Sequence. For SCPI sequences used in Visual Studio programs, the options include:

• C# with calls to SCPI.NET Drivers • VB.NET with calls to SCPI.NET Drivers • C/C++ with calls to VISA formatted I/O

VISA C/C++ calls generated by Command Expert can be used with any version of Visual Studio or with other development tools that support development of C/C++ programs, including LabWindows/CVI.

The Visual Studio files needed to run the example program used in this paper (InfiniiVision_6000Series_WaveformDownload) are installed when Command Expert is installed.

b) SCPI.NET drivers

A SCPI.NET driver is a .NET assembly that provides a strongly-typed interface to a SCPI Command Set. Command Expert generates a SCPI.NET driver when the SCPI Command Set is installed for a SCPI instrument. There are a number of advantages to using SCPI.NET drivers and code generation:

1. SCPI.NET driver methods perform data translation between .NET data types and SCPI commands/responses.

2. SCPI.NET drivers provide a strongly-typed interface to SCPI commands which eliminates most syntax errors.

3. SCPI.NET drivers work with IntelliSense. The IntelliSense for a method includes the synopsis for the corresponding SCPI command.

4. SCPI.NET drivers are generated in both source code (C# and VB.NET) and binary (DLL) forms.

5. SCPI.NET driver source code includes URLs that link from a SCPI.NET method to the documentation for the corresponding SCPI command.

Manually adding instrument commands can be a fast way to modify a program, and can be done with SCPI.NET drivers. Once a SCPI.NET driver is added to the Visual Studio project (as a source file or DLL), code is written to call the methods provided by the SCPI.NET driver.

c) Hybrid approach A hybrid approach provides additional flexibility by

combining Command Expert code generation with writing code manually. Once the required references for the SCPI.NET drivers are added to the Visual Studio project,

Page 4: control and automation

Command Expert code generated with calls to SCPI.NET drivers can be copied into the project. Modifying the sequence by adding, removing or editing steps can now be done directly in Visual Studio.

VII. MATLAB MATLAB integration can be done in two different ways,

each of which provides enhanced instrument control within MATLAB. Instrument command sequences can be run using the MATLAB Add-on, or MATLAB code can be generated using the File>Export Sequence command. Both methods require MATLAB and Instrument Control Toolbox to be installed on the PC.

The MATLAB Add-on is a set of MATLAB functions that run Command Expert sequences.

For example, the function: agRunSequence (‘WaveformDownload’) runs the sequence named WaveformDownload. This is a simple way to use the sequence in a MATLAB program and works with both SCPI and IVI-COM commands.

MATLAB code generation is available for SCPI commands only (not for IVI-COM drivers). Each SCPI command in the sequence is translated into one or more lines of MATLAB code, and each sequence has a corresponding MATLAB function. Code generation can result in more lines of code than the use of the MATLAB Add-on, but an advantage of code generation is, once the existing sequence is integrated into a MATLAB program, Command Expert does not need to be installed on the PC to run the MATLAB program.

An available application note provides additional information about using Command Expert with MATLAB[3].

VIII. AGILENT VEE The Command Expert VEE Add-on provides the features

of Command Expert within the VEE environment to easily create instrument command sequences. It is only available when VEE is installed. When the Command Expert block is selected and opened in the VEE ADE, Command Expert is launched and sequences can be created, edited, and debugged with all of the features and capability of Command Expert. Once developed, these sequences are available in VEE and can be executed from VEE programs.

Command Expert objects are added to VEE programs through the I/O > Command Expert Sequence main menu bar of VEE. The Sequence object can then be selected and placed in the VEE work area. Double-clicking on the Sequence object will launch Command Expert. To connect the Sequence object with the rest of the program, input and output terminals need to be added by including an instrument connection and adding parameterized sequence(s) in the Sequence object. Each input parameter of the sequence generates a corresponding input terminal, and each output parameter of the sequence generates a corresponding output terminal.

The VEE object shown (Figure 4) demonstrates the sequence used in the waveform download example.

Figure 4 VEE Sequence Object

The debugging and editing of the command sequence is done in Command Expert. Now, the debugging of the final VEE program can be done with more of a focus on the logic of the overall system and not the individual pieces. The instrument commands, the setup, and the measurements all have been proven to work. Having the instrument commands integrated into the programming environment accelerates program development.

IX. LABVIEW The Command Expert LabVIEW Add-on is used within

LabVIEW to create command sequences, and is only available when LabVIEW is installed on the PC. The add-on provides a new LabVIEW Express VI called the Sequence block. After starting LabVIEW, a new VI (File > New VI) can be created by right-clicking on a blank area of the VI block diagram. This will display the Functions Palette, where there is an Agilent Functions Palette with a Sequence block Express VI in the sub-palette. The configuration dialog for a Sequence block is Command Expert. When used with LabVIEW, Command Expert has OK and Cancel buttons at the bottom of the window. LabVIEW waits for the Command Expert window to close, and does not respond until OK or Cancel is selected.

To configure a Sequence block, first connect to an instrument in Command Expert. Then, all commands in the Sequence block will be sent to that instrument. Terminals are added by parameterizing steps within the command sequence. An input parameter of the sequence generates a corresponding input terminal, and an output parameter of the sequence generates a corresponding output terminal.

The Sequence block shown (Figure 5) demonstrates the sequence used in the waveform download example.

Page 5: control and automation

Figure 5 LabVIEW Sequence Block

An available application note provides additional information about using Command Expert with LabVIEW[4].

X. AGILENT SYSTEMVUE SystemVue’s Command Expert linkage

(CommandExpertLink) can pre-configure a series of instrument interactions that execute at runtime, directly to and from SystemVue dataflow simulations. In contrast with other instrument linkage parts (e.g. SignalDownloader), SystemVue’s Command Expert linkage can run a sequence of commands to set up, transfer, and reset various instruments, including command sequences such as turning on the bias supplies and signal generators in a certain order, or restoring the state of the instrument after a measurement. With Command Expert integrated inside SystemVue, instrument automation is much easier within the simulation paradigm.

This capability is only available when SystemVue is installed on the PC. The SystemVue brochure outlines the software and various additional features[5].

XI. CONCLUSION Instrument control and automation are significantly

easier with new PC applications such as Agilent’s Command Expert. The form-based interface ensures the accuracy of the instrument commands and accelerates the process of learning the instrument and creating command sequences. Integration with the most common ADEs provides faster time to automate instrument control for validation and test.

ACKNOWLEDGMENTS Many thanks to the Command Expert team for their support

and guidance to make this paper a reality. A special thanks to: Gordon Kotik, Command Expert R&D Project Manager and product expert; Alan Copeland, Command Expert Support Engineer and technical expert; Laura Johnson, Agilent Learning Products and style advisor; Dave Griess, Learning Products and product expert, Bill Coppel and Scott Sample Marketing Managers and editors, as well as many others.

REFERENCES [1] Agilent Technologies, “Using Command Expert with Microsoft Excel”

Application Note, literature number 5990-9639EN [2] Agilent Technologies, “Accelerate Program Development using Agilent

Command Expert with Microsoft Visual Studio” Application Note, literature number 5991-0258EN

[3] Agilent Technologies, “Accelerate Program Development using Agilent Command Expert with MATLAB”, Application Note, literature number 5991-0502EN

[4] Agilent Technologies, “Accelerate Program Development using Agilent Command Expert with LabVIEW”, Application Note, literature number 5991-0693EN

[5] Agilent Technologies, “Agilent Eesof EDA SystemVue 2012”, Technical Overview, literature number 5990-4731EN