Agilent Technologies E6640A EXM Manual

Agilent Technologies
Programmer’s Guide
Agilent E6640A EXM
Wireless Test Set
(and X-Series
Instruments)

Notices
© Agilent Technologies, Inc.
2008-2014
No part of this manual may be
reproduced in any form or by any
means (including electronic storage
and retrieval or translation into a
foreign language) without prior
agreement and written consent from
Agilent Technologies, Inc. as
governed by United States and
international copyright laws.
Trademark
Acknowledgements
Microsoft®is a US registered
trademark of Microsoft Corporation.
Windows®, MS Windows®,
Windows Vista®, and Windows 7®
are US registered trademarks of
Microsoft Corporation.
Visual Basic®, Visual Basic.NET®,
Visual Studio®, and MS Excel®are
registered trademarks of Microsoft
Corporation.
Adobe Acrobat®and Reader®are
US registered trademarks of Adobe
Systems Incorporated.
Java™ is a US trademark of Sun
Microsystems, Inc.
MATLAB®is a US registered
trademark of Math Works, Inc.
LabVIEW™ and CVI™ are trademarks
of National Instruments Corporation.
LabWindows is a mark used by
National Instruments Corporation
under a license from Microsoft
Corporation.
Manual Part Number
E6640-90002
Print Date
February 2014
Printed in USA
Agilent Technologies Inc.
1400 Fountaingrove Parkway
Santa Rosa, CA 95403
Warranty
The material contained in this
document is provided “as is,” and is
subject to being changed, without
notice, in future editions. Further, to
the maximum extent permitted by
applicable law, Agilent disclaims all
warranties, either express or
implied, with regard to this manual
and any information contained
herein, including but not limited to
the implied warranties of
merchantability and fitness for a
particular purpose. Agilent shall not
be liable for errors or for incidental
or consequential damages in
connection with the furnishing, use,
or performance of this document or
of any information contained herein.
Should Agilent and the user have a
separate written agreement with
warranty terms covering the material
in this document that conflict with
these terms, the warranty terms in
the separate agreement shall
control.
Technology Licenses
The hardware and/or software
described in this document are
furnished under a license and may
be used or copied only in accordance
with the terms of such license.
Restricted Rights Legend
If software is for use in the
performance of a US Government
prime contract or subcontract,
Software is delivered and licensed
as “Commercial computer software”
as defined in DFAR 252.227-7014
(June 1995), or as a “commercial
item” as defined in FAR 2.101(a) or
as “Restricted computer software”
as defined in FAR 52.227-19 (June
1987) or any equivalent agency
regulation or contract clause. Use,
duplication or disclosure of Software
is subject to Agilent Technologies’
standard commercial license terms,
and non-DOD Departments and
Agencies of the US Government will
receive no greater than Restricted
Rights as defined in FAR
52.227-19(c)(1-2) (June 1987). U.S.
Government users will receive no
greater than Limited Rights as
defined in FAR 52.227-14 (June
1987) or DFAR 252.227-7015 (b)(2)
(November 1995), as applicable in
any technical data.
Safety Notices
CAUTION
A CAUTION notice denotes a hazard.
It calls attention to an operating
procedure, practice, or the like that,
if not correctly performed or adhered
to, could result in damage to the
product or loss of important data. Do
not proceed beyond a CAUTION
notice until the indicated conditions
are fully understood and met.
WARNING
A WARNING notice denotes a
hazard. It calls attention to an
operating procedure, practice, or the
like that, if not correctly performed
or adhered to, could result in
personal injury or death. Do not
proceed beyond a WARNING notice
until the indicated conditions are
fully understood and met.

3
Warranty
This Agilent technologies instrument product is warranted against defects in material and workmanship for a period of
one year from the date of shipment. During the warranty period, Agilent Technologies will, at its option, either repair or
replace products that prove to be defective.
For warranty service or repair, this product must be returned to a service facility designated by Agilent Technologies.
Buyer shall prepay shipping charges to Agilent Technologies, and Agilent Technologies shall pay shipping charges to
return the product to Buyer. For products returned to Agilent Technologies from another country, Buyer shall pay all
shipping charges, duties, and taxes.
Where to Find the Latest Information
Documentation is updated periodically. For the latest information about these products, including instrument software
upgrades, application information, and product information, browse to one of the following URLs, according to the name
of your product:
http://www.agilent.com/find/e6640a
To receive the latest updates by email, subscribe to Agilent Email Updates at the following URL:
http://www.agilent.com/find/emailupdates
Information on preventing instrument damage can be found at:
http://www.agilent.com/find/tips
Is your product software up-to-date?
Periodically, Agilent releases software updates to fix known defects and incorporate product enhancements. To search
for software updates for your product, go to the Agilent Technical Support website at:
http://www.agilent.com/find/techsupport

4

Contents
5
Table of Contents
1 Introduction to Programming X-Series Applications
How to Use this Manual 9
X-Series Programming Options 10
Hardware Connection Formats 11
VISA Driver Options 11
Agilent VEE Pro 13
Programming Documentation Roadmap 14
2 SCPI Programming Fundamentals
SCPI Language Basics 16
Command Keywords, Separators and Syntax 16
Creating Valid Commands 17
Special Characters in Commands 17
Parameters in Commands 19
Variable Parameters 19
Block Program Data 21
Writing Multiple Commands on the Same Line 21
SCPI Termination and Separator Syntax Examples 22
Where to find X-Series SCPI Command Definitions 23
Help System Features for SCPI Programmers 23
Help System Contents Pane 23
Help Topic Content 24
List of SCPI Commands 25
Simple SCPI Communication Methods 27
Connecting to the X-Host Using VISA Connection Strings 27
Left Sub-Instrument Connections 27
Right Sub-Instrument Connections 27
Distinguishing Between the Sub-Instruments 28
Communicating SCPI Using Telnet 28
Determining Instrument IP Address 30
Enabling Telnet in Windows 31
Communicating SCPI using Agilent Connection Expert 31
Techniques for Improving Measurement Performance 34
Turn off Display Updates 34
Use Binary Data Format instead of ASCII 34

6
Contents
Minimize the Number of Bus Transactions 34
Minimize DUT/instrument Setup changes 35
Avoid Unnecessary Use of *RST 35
Use Video or External Triggering for Single Burst Signals 35
To make Power Measurements on Multiple Bursts or Slots use
CALCulate:DATA<n>:COMPress? 36
More Hints & Tips 37
3 Developing and Deploying VISA Projects
Programming in Visual Basic 6 with VISA 39
Location of Header Files 39
Programming in C or C++ with VISA 39
Location of Header Files & Libraries 39
Programming with Microsoft .NET and VISA 40
Location of Header Files 40
Requirements for Deploying a VISA Project 41
Multiple VISA DLL Versions 41
4 Program Samples
Where to find Sample Programs 43
Programing Samples 44
Matrix of Program Sample Functionality and Programming Language 44
Visual Basic 6 45
Transfer Screen Images 45
C, C++ 46
Serial Poll for Operation Complete 46
Trace Detector/Couple Markers 46
C#.NET & Visual Studio 2010 47
Transfer Screen Images 47
Serial Poll for Sweep Complete 47
Agilent VEE Pro 48
Transfer Screen Images 48
LabVIEW 48
Transfer Screen Images 48
Appendix A References
Documents & Web Sites 49
Developer Resources 51

Contents
7
Agilent Developer Network (ADN) 51
Technical Support 51

8
Contents

9
Introduction to Programming X-Series Applications
How to Use this Manual
1 Introduction to Programming
X-Series Applications
How to Use this Manual
This chapter provides overall information regarding remote programming of Agilent X-Series instruments, and
how to use the programming documentation provided with the product.
This chapter includes the following topics:
“X-Series Programming Options” on page 10
“Hardware Connection Formats” on page 11
“VISA Driver Options” on page 11
“Agilent VEE Pro” on page 13
“Programming Documentation Roadmap” on page 14
The second chapter, “SCPI Programming Fundamentals” on page 15, provides an introduction to Standard
Commands for Programmable Instruments (SCPI), which is the most popular and versatile protocol for
programming X-Series instruments.
The chapter “Developing and Deploying VISA Projects” on page 39 provides basic information about X-Series
programming with the Virtual Instrument Software Architecture (VISA), using various popular programming
languages.
The chapter “Program Samples” on page 43 describes all program samples that are included in the
\progexamples folder of the X-Series Documentation DVD, and provides information about how to find
other X-Series program samples.

10
Introduction to Programming X-Series Applications
X-Series Programming Options
X-Series Programming Options
The E6640A EXM Wireless Test Set uses the same applications used in Agilent X-Series analyzers and test
sets. You can program these instruments using a variety of programming tools, languages and Application
Development Environments (ADEs).
There are also several software driver technologies that you can use to program X-Series instruments, which
offer various tradeoffs between programming tool, ADE and driver technology. Table 1-1 explains the relative
advantages of each programming method and driver technology. Figure 1-1 on page 11 shows a conceptual
overview of the hierarchy of drivers that are available for X-Series programming.
Table 1-1 Programming Options & Driver Technologies for X-Series Instruments
Method Description
VISA Drivers Features As shown in Figure 1-1, VISA is a driver technology that
operates at a lower level of abstraction than instrument
drivers. As such, it offers greater flexibility, at the
expense of a longer learning curve.
VISA is a generic, industry-wide standard, unlike
Instrument Drivers, which are instrument-specific.
For more details, see “VISA Driver Options” on page 11.
Acquisition &
Licensing
Free download from Agilent web site.
Requires separate
ADE?
Yes, but depending on your program development
requirements, you may be able to use a free download
such as one of the Microsoft Visual Studio Express
editions.
Driver Support VISA (commands go to the VISA Library Layer), as
shown in Figure 1-1 below.
Agilent VEE Features An integrated, graphically-oriented, standalone ADE,
which supports instruments from Agilent and other
manufacturers.
For more details, see “Agilent VEE Pro” on page 13.
Acquisition &
Licensing
License must be purchased from Agilent.
Requires separate
ADE?
No
Driver Support Supports both Instrument Drivers and VISA.

11
Introduction to Programming X-Series Applications
Hardware Connection Formats
Figure 1-1 E6640A Software Driver Hierarchy
Hardware Connection Formats
E6640A supports the TCPIP connection standard (represented by the "Network Layer" in Figure 1-1 above)
for LAN and HiSLIP instruments.
In general, modern driver technology hides the details of the hardware connection from the programmer, so
your instrument’s actual hardware connection is unlikely to have any significant effect on the optimal choice
of programming tool, language or ADE.
VISA Driver Options
Agilent I/O Libraries Suite is a collection of libraries, Application Programming Interfaces (APIs) and utility
programs. The I/O libraries (SICL, VISA, and VISA COM) enable instrument communication for a variety of
development environments (Agilent VEE Pro, Microsoft Visual Studio, etc.) that are compatible with GPIB,
USB, LAN, RS-232, PXI, AXIe, and VXI test instruments from a variety of manufacturers.
The suite’s utility programs help you quickly and easily connect instruments to a computer.

12
Introduction to Programming X-Series Applications
VISA Driver Options
The Agilent IO Libraries Suite includes the following libraries:
Item Library Name Documentation Location & Notes
1 Agilent Virtual Instrument Software
Architecture (VISA)1
1. Note that using VISA functions and SICL functions in the same I/O application is not supported.
The VISA API is a programming interface originally
developed and standardized by the VXIplug&play
Alliance (now the IVI Foundation) as an industry-wide
standard for communicating with instruments over
various hardware interfaces. The definition includes
the standard visa.h header file for use with C and
C++, which provides declarations for the
visa32.dll library.
Additionally, Agilent has developed the header files
visa32.cs and visa32.bas, to permit the VISA
DLL to be used with C#.NET and Visual Basic.NET
respectively.
For more information, see the VISA Documentation
Help in the Agilent I/O Libraries Suite.
2 VISA for the Common Object Model
(VISA COM)1
The VISA COM I/O API is a programming interface
standardized by the IVI Foundation for
communicating with instruments over various
hardware interfaces.
Agilent Technologies offers an implementation of the
VISA COM I/O standard that is compatible with
Agilent hardware as well as computer standard I/O
interfaces. VISA COM I/O is an update of the older
VISA C API to work in and with Microsoft’s COM
technology.
For more information, see the VISA COM Help in the
Agilent I/O Libraries Suite.
3 Agilent Standard Instrument Control
Library (SICL)1
SICL is compatible only with Agilent interfaces,
whereas VISA is an industry-wide standard.
This library is not described further in this document.
For more information, see the SICL Documentation
Help in the Agilent I/O Libraries Suite.
Note that SICL is supported only for the C and VB6
languages; there is no SICL support for .NET
languages.

13
Introduction to Programming X-Series Applications
Agilent VEE Pro
Agilent VEE Pro
Agilent VEE (Visual Engineering Environment) Pro provides a graphical language and integrated development
environment that permits efficient development of measurement and analysis solutions, while requiring
minimal custom programming.
You can select and edit objects from pull-down menus or toolbars and connect them to each other by virtual
wires to specify the program's data flow, mimicking the order of tasks you want to perform.
Agilent VEE Pro can communicate with any instrument from any vendor, using GPIB, LAN, USB, RS-232, VXI
or LXI.
For further details, see the web page for Agilent VEE Pro.
For information about using IVI Instrument Drivers with Agilent VEE, see Agilent Application Note 1595.

14
Introduction to Programming X-Series Applications
Programming Documentation Roadmap
Programming Documentation Roadmap
Most X-Series manuals and publications can be accessed via the Additional Documentation page in the
instrument Help system, and are also included on the Documentation DVD shipped with the instrument.
Exceptions are noted in Ta b l e 1 - 2 below.
All documents can also be found online at the Agilent X-Series Document Library.
Table 1-2 X-Series Documentation Resources
Resource Description
X-Series
Programmer’s
Guide
(This document)
Provides general programming information on the following topics:
•Introduction to Programming X-Series Applications
•SCPI Programming Fundamentals
•Program Samples
Note that SCPI command descriptions for measurement applications are not in this
document, but are in the User’s and Programmer’s Reference manuals for each
measurement application (mode).
User’s and
Programmer’s
Reference
manuals
Describes all SCPI commands for a measurement application (mode). Note that:
• Each measurement application has its own User’s and Programmer’s Reference.
• The content of this manual is duplicated in the instrument’s Help file. That is, the
context-sensitive help content for a key is identical to that in User’s and
Programmer’s Reference manual for the same mode.
Embedded Help in
the instrument
Describes all SCPI commands for a measurement application (mode), organized
according to the front-panel key and softkey hierarchy.
Note that the content that you see in Help when you press a key is identical to that
in the User’s and Programmer’s Reference for the same topic.
Agilent X-Series
Signal Analyzer:
Getting Started
Guide
Provides valuable sections related to programming including:
• Licensing New Measurement Application Software - After Initial Purchase
• Configuring instrument LAN Hostname, IP Address, and Gateway Address
• Using the Windows Remote Desktop to connect to the instrument remotely
This manual is shipped with the instrument as a printed document.
Agilent
Application Notes
Printable PDF versions of pertinent application notes.
Agilent I/O
Libraries Suite
The download package includes documentation describing the Agilent Virtual
Instrument Software Architecture (VISA) library, and showing how to use it to
develop I/O applications and instrument drivers on Windows PCs.
Not included on X-Series Documentation DVD.

15
SCPI Programming Fundamentals
2SCPIProgramming
Fundamentals
This chapter provides overall information on programming X-Series instruments using Standard Commands
for Programmable Instruments (SCPI). Sections include:
•“SCPI Language Basics” on page 16
•“Where to find X-Series SCPI Command Definitions” on page 23
•“Simple SCPI Communication Methods” on page 27
•“Techniques for Improving Measurement Performance” on page 34

16
SCPI Programming Fundamentals
SCPI Language Basics
SCPI Language Basics
This section provides a basic introduction to the SCPI language. For more details about SCPI, see IEEE
Standard 488.2–1992.
Topics covered in this section include:
•“Command Keywords, Separators and Syntax” on page 16
•“Creating Valid Commands” on page 17
•“Special Characters in Commands” on page 17
•“Parameters in Commands” on page 19
•“Writing Multiple Commands on the Same Line” on page 21
Command Keywords, Separators and Syntax
Keywords, Parameters & Separators: A typical SCPI command is made up of keywords separated by colons.
The keywords are followed by parameters that can be followed by optional units. The parameter list is
separated from the command by a space.
Example: :SENSe:FREQuency:STARt 1.5 MHZ
Upper- vs. Lower-Case Usage: The instrument does not distinguish between upper and lower case letters. In
the documentation, upper case letters indicate the short form of the keyword, whereas lower case letters
indicate the long form of the keyword. Either form may be used in the command.
Example:
:Sens:Freq:Star 1.5 mhz
This is the same as
:SENSE:FREQ:start 1.5 MHz
NOTE The command :SENS:FREQU:STAR would not be valid because FREQU is neither
the short, nor the long form of the command. Only the short and long forms of the
keywords are allowed in valid commands.
Multiple SCPI commands on the same line: This is permissible if the commands are separated by a
semicolon. See “Writing Multiple Commands on the Same Line” on page 21.
Initial Colon: In general, SCPI commands start with a colon, as shown above. You may choose to omit the
initial colon, but, if you do so, note that SCPI rules for the interpretation of Compound Headers will be invoked
by the command interpreter. For full discussion and examples of Compound Headers, see Appendix A of IEEE
Standard 488.2–1992. For examples, see “SCPI Termination and Separator Syntax Examples” on page 22.

17
SCPI Programming Fundamentals
SCPI Language Basics
Creating Valid Commands
Commands are not case-sensitive, and there are often many different ways of writing a particular command.
These are examples of valid commands for a given command syntax:
Special Characters in Commands
Command Syntax Sample Valid Commands
:[SENSe:]BANDwidth[:RESolution]
<freq>
The following sample commands are all identical. They
all cause the same result.
•:Sense:Band:Res 1700
•:BANDWIDTH:RESOLUTION 1.7e3
•:sens:band 1.7KHZ
•:SENS:band 1.7E3Hz
•:band 1.7kHz
•:bandwidth:RES 1.7e3Hz
:MEASure:SPECtrum[n]? •:MEAS:SPEC?
•:Meas:spec?
•:meas:spec3?
The number 3 in the last meas example causes it to
return different results than the commands above it.
See the command description for more information.
[:SENSe]:DETector[:FUNCtion]
NEGative|POSitive|SAMPle
•:DET:FUNC neg
•:Detector:Func Pos
:INITiate:CONTinuous ON|OFF|1|0 The sample commands below are identical.
•:INIT:CONT ON
•:init:continuous 1
Special
Character
Meaning Example
| A vertical stroke between parameters
indicates alternative choices. The
effect of the command is different
depending on which parameter is
selected.
Command: TRIGger:SOURce
EXTernal|INTernal|LINE
The choices are external, internal, and line.
Ex: TRIG:SOURCE INT
is one possible command choice.

18
SCPI Programming Fundamentals
SCPI Language Basics
|Averticalstrokebetweenkeywords
indicates identical effects exist for
both keywords. The command
functions the same for either
keyword. Only one of these keywords
is used at a time.
Command:
SENSe:BANDwidth|BWIDth:OFFSet
Two identical commands are:
Ex1: SENSE:BWIDTH:OFFSET
Ex2: SENSE:BAND:OFFSET
[] keywordsinsquare brackets are
optional when composing the
command. These implied keywords
will be executed even if they are
omitted.
Command:
[SENSe:]BANDwidth[:RESolution]:AUT
O
The following commands are all valid and have
identical effects:
Ex1: bandwidth:auto
Ex2: band:resolution:auto
Ex3: sense:bandwidth:auto
< > Angle brackets around a word, or
words, indicates they are not to be
used literally in the command. They
represent the needed item.
Command: SENS:FREQ <freq>
In this command example the word <freq>
should be replaced by an actual frequency.
Ex: SENS:FREQ 9.7MHz.
{ } Parameters in braces can optionally
be used in the command either not at
all, once, or several times.
Command: MEASure:BW <freq>{,level}
A valid command is:
meas:BW 6 MHz, 3dB, 60dB
Special
Character
Meaning Example

19
SCPI Programming Fundamentals
SCPI Language Basics
Parameters in Commands
There are four basic types of parameters: booleans, keywords, variables and arbitrary block program data.
Variable Parameters
Type Description
OFF|ON|0|1
(Boolean)
This is a two state boolean-type parameter. The numeric value 0 is equivalent to
OFF. Any numeric value other than 0 is equivalent to ON. The numeric values of 0 or
1 are commonly used in the command instead of OFF or ON. Queries of the
parameter always return a numeric value of 0 or 1.
keyword The keywords that are allowed for a particular command are defined in the
command syntax description.
Units Numeric variables may include units. The valid units for a command depend on the
variable type being used. See the following variable descriptions. The indicated
default units will be used if no units are sent. Units can follow the numerical value
with, or without, a space.
Variable A variable can be entered in exponential format as well as standard numeric format.
The appropriate range of the variable and its optional units are defined in the
command description.
The following keywords may also be used in commands, but not all commands
allow keyword variables.
• DEFault - resets the parameter to its default value.
• UP - increments the parameter.
• DOWN - decrements the parameter.
• MINimum - sets the parameter to the smallest possible value.
• MAXimum - sets the parameter to the largest possible value.
The numeric value for the function’s MINimum, MAXimum, or DEFault can be
queried by adding the keyword to the command in its query form. The keyword
must be entered following the question mark.
Example query: SENSE:FREQ:CENTER? MAX
Type Description
<integer> An integer value with no units.
<real> A floating point number with no units.
<freq>
<bandwidth>
A positive rational number followed by optional units. The default unit is Hertz.
Acceptable units include: Hz, kHz, MHz, GHz.

20
SCPI Programming Fundamentals
SCPI Language Basics
<time>
<seconds>
A rational number followed by optional units. The default units are seconds.
Acceptable units include: ks, s, ms, μs, ns.
<voltage> A rational number followed by optional units. The default units are Volts.
Acceptable units include: V, mV, μV, nV
<current> A rational number followed by optional units. The default units are Amperes.
Acceptable units include: A, mA, μA, nA.
<power> A rational number followed by optional units. The default units are W. Acceptable
units include: kW, W, mW, μW, nW, pW.
<ampl> A rational number followed by optional units. The default units are dBm. Acceptable
units include: dBm, dBmV, dBμV.
<rel_power>
<rel_ampl>
A positive rational number followed by optional units. The default units are dB.
Acceptable units include: dB.
<percent> A rational number between 0 and 100. You can either use no units or use PCT.
<angle>
<degrees>
A rational number followed by optional units. The default units are degrees.
Acceptable units include: DEG, RAD.
<string> A series of alpha numeric characters.
<bit_pattern> Specifies a series of bits rather than a numeric value. The bit series is the binary
representation of a numeric value. There are no units.
Bit patterns are most often specified as hexadecimal numbers, though octal, binary
or decimal numbers may also be used. In the SCPI language these numbers are
specified as:
• Hexadecimal, #Hdddd or #hdddd where ‘d’ represents a hexadecimal digit 0 to
9 and ‘a’ to ‘f’. So #h14 can be used instead of the decimal number 20.
• Octal, #Odddddd or #odddddd where ‘d’ represents an octal digit 0 to 7. So
#o24 can be used instead of the decimal number 20.
• Binary, #Bdddddddddddddddd or #bdddddddddddddddd where ‘d’ represents a
1 or 0. So #b10100 can be used instead of the decimal number 20.
Type Description
Table of contents
Other Agilent Technologies Computer Accessories manuals