Command Expert C#
Command Expert C#
Command Expert C#
Introduction
Keysight Command Expert for fast and easy
instrument control!
Keysight Technologies, Inc. Command Expert is a FREE software application that
provides fast and easy instrument control in many PC application environments.
Command Expert combines instrument command sets, command sequences,
documentation, syntax checking, and command execution in one simple interface.
Command Expert helps you to:
Find instrument commands
Access command documentation
Verify command syntax
Build instrument command sequences
Execute instrument command sequences
Integrate sequences into the Visual Studio, Excel, LabVIEW, MATLAB,
Keysight VEE, or Keysight SystemVue PC application environment
Generate code for command sequences in Visual C#, VisualBasic.NET,
Visual C/C++, and MATLAB
Proile command execution time
Debug command sequences using breakpoints and single-stepping
Generate SCPI.NET for use in Visual Studio
Instrument command sets are available for instruments that use Standard Commands
for Programmable Instrumentation (SCPI) or IVI-COM drivers.
The Instruments Pane shows your instruments and lets you connect to them.
The Search/Browse Pane shows you the commands for the selected instrument and lets you search for commands.
The Command Pane shows the selected command and its documentation, and lets you execute the command.
The Status Bar shows progress messages as Command Expert performs operations.
The Parameters Pane expands to show sequence parameters and lets you view and edit their names and values.
The Sequence Pane shows the various steps in the Command Expert sequence and lets you edit the sequence and
replay commands. The Sequence Pane has the following features:
Working offline
The absence of a specific instrument address in step 1of the sequence shown above indicates that we are working offline.
To connect to an actual instrument, select step 1 in the Sequence Pane, and enter the instrument address in the address
field in the Command Pane.
Working offline is a simulation mode where you can view and perform commands as usual, but the commands return
default values. This is a good way to explore a command set, view documentation, and prototype sequences without having
to connect to a physical instrument.
Sequence Steps
Selecting a step in the Sequence Pane reveals details about the command and its parameters.
Sequence Debugging
You can debug a sequence by inserting breakpoints. When you run the sequence, execution pauses at the first step with a
breakpoint and Command Expert enters single-step mode. In single-step mode you can single-step the sequence, monitor
parameters and results, replay the sequence, and play selected steps. When you are ready to run the sequence without pausing
at the breakpoint, remove the breakpoint and run the sequence normally.
Substituting an instrument
You can temporarily switch command sets in a sequence to see the effects of switching to a different instrument.
Any commands that arent supported by the new instrument are highlighted in red.
Using IVI-COM
If you prefer, you can use IVI-COM commands instead of SCPI commands. Command Expert has a number of IVI-COM examples
and the operation is very similar to SCPI.
The example below (filename: N67xx_PowerSupply_OutputSetup.xlsx) uses IVI-COM commands:
10
The Visual Studio code generation options for SCPI command sequences are:
C/C++ with calls to VISA Formatted I/O
C# with calls to SCPI.NET Drivers
VB.NET with calls to SCPI.NET Drivers
The code generation options for IVI-COM command sequences are:
C# with calls to IVI-COM Drivers
VB.NET with calls to IVI-COM Drivers
Examples
This application note shows a code generation example for C/C++ with calls to VISA Formatted I/O and for C# with calls to
SCPI.NET Drivers. The code generation process for the other options listed above is similar. Detailed information and tutorials are
located in the Command Expert help.
11
Procedure
1. If not already open, open the N6700_PowerSupply_OutputSetup example from the Welcome Window.
2. The example opens with the SCPI commands listed (default mode). This example sets the output voltage and current of
a Keysight N6700B Power Supply:
12
4. Click Copy to Clipboard followed by Close. The Keysight VISA I/O calls (viOpen, viPrint) are automatically added to the
sequence and copied to the clipboard.
5. You can now paste this code into a Visual Studio console application to create a working program. The following
graphic shows the generated code from the N6700_PowerSupply_OutputSetup example pasted into a Visual Studio C++
console application. Be sure to add the appropriate #include statements (see the Command Expert help for details).
13
The above example is included with Command Expert as a Visual Studio C++ project. A number of examples are included for
Visual Studio. These examples are located in:
C:\Documents and Settings\All Users\Keysight\Command Expert\Examples (for Windows XP)
C:\ProgramData\Keysight\Command Expert\Examples (for Windows 7)
Visual Studio examples are in these subfolders:
\Scpi\Visual Studio (SCPI examples)
\IviCom\Visual Studio (IVI-COM examples)
14
C# SCPI.NET Example
1. If not already open, open the N6700_PowerSupply_OutputSetup example from the Welcome Window.
2. The example opens with the SCPI commands listed (default mode). This example sets the output voltage and current of
a Keysight N6700B Power Supply:
15
4. Click Copy to Clipboard followed by Close. Command Expert automatically adds the C# SCPI.NET calls to the sequence
and copies the sequence to the clipboard.
5. You can now paste this code into a Visual Studio console application to create a working program.
The following graphic shows the generated code from the N6700_PowerSupply_OutputSetup example pasted into a Visual
Studio C# project. Be sure to add the required references (see the SCPI.NET Drivers Tutorial in the online help for details).
16
17
Click Go to Definition from the Visual Studio context menu. Visual Studio displays the source code for the SCPI.NET driver class.
Click the link directly under // Remarks: to view the HTML documentation for the AMPLitude command.
The preceding example is included with Command Expert as a Visual Studio C# project. A number of Visual Studio examples are
included for Visual Studio. Examples are located in:
C:\Documents and Settings\All Users\Keysight\Command Expert\Examples (for Windows XP)
C:\ProgramData\Keysight\Command Expert\Examples (for Windows 7)
Visual Studio examples are in these subfolders:
\Scpi\Visual Studio (SCPI examples)
\IviCom\Visual Studio (IVI-COM examples)
18
Where to Go Next
The easiest way to get started using Command Expert with Visual Studio is to browse through the example folders and select an example that is
similar to your test and measurement application. Examples are provided for Visual Studio 2005, Visual Studio 2008, and Visual Studio 2010.
Command Expert has extensive application documentation containing FAQs, tutorials, examples, and getting started information. You can use one
of these tutorials, available in the Command Expert help, for step-by-step information on how to use Command Expert with Visual Studio:
Tutorial on Using Generated VISA Code
Command Expert for IVI-COM Tutorial
SCPI.NET Drivers Tutorial
19
Be sure to check the Command Expert help for important information on using the various Visual Studio versions. You can find more information
on Command Expert, including links to other application notes,
at www.keysight.com/find/commandexpert.
PC Operating Requirements
Operating System
Disk
Monitor
Browser
You can find the current list of instrument SCPI command sets at: www.keysight.com/find/commandsetlist
LabVIEW
VEE
Excel
MATLAB
Download Command Expert now and experience fast and easy instrument control: www.keysight.com/find/commandexpert
20
21 | Keysight | Accelerate Program Development using Agilent Command Expert with Microsoft Visual Studio - Application Note
myKeysight
www.keysight.com/find/mykeysight
A personalized view into the information most relevant to you.
Keysight Assurance Plans
www.keysight.com/find/AssurancePlans
Up to five years of protection and no budgetary surprises to ensure your
instruments are operating to specification so you can rely on accurate
measurements.
www.keysight.com/quality
Keysight Technologies, Inc.
DEKRA Certified ISO 9001:2008
Quality Management System
Keysight Channel Partners
www.keysight.com/find/channelpartners
Get the best of both worlds: Keysights measurement expertise and product
breadth, combined with channel partner convenience.
www.keysight.com/find/commandexpert
Asia Paciic
Australia
China
Hong Kong
India
Japan
Korea
Malaysia
Singapore
Taiwan
Other AP Countries
United Kingdom
0800 001122
0800 58580
0800 523252
0805 980333
0800 6270999
1800 832700
1 809 343051
800 599100
+32 800 58580
0800 0233200
8800 5009286
0800 000154
0200 882255
0800 805353
Opt. 1 (DE)
Opt. 2 (FR)
Opt. 3 (IT)
0800 0260637