This guide applies to the following signal generator models:
N5181A/82A MXG RF Signal GeneratorsN5183A MXG Microwave Analog Signal Generator
E4428C/38C ESG RF Signal GeneratorsE8663B RF Analog Signal Generator
E8257D/67D PSG Microwave Signal Generators
Due to our continuing efforts to improve our products through firmware and hardware revisions, signal generator design
and operation may vary from descriptions in this guide. We recommend that you use the latest revision of this guide to
ensure you have up-to-date product information. Compare the print date of this guide (see bottom of page) with the latest
revision, which can be downloaded from the following websites:
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 to any of the Agilent products to which it
pertains, 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 any of the Agilent products
to which it pertains. Should Agilent have a written contract with the User and should any of the
contract terms conflict with these terms, the contract terms shall control.
Trademarks
Throughout this book, trademarked names are used. Rather than put a trademark symbol in every
occurrence of a trademarked name, we state that we are using the names in an editorial fashion only
and to the benefit of the trademark owner with no intention of infringement of the trademark.
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guideviii
Documentation Overview
Installation Guide
User’s Guide
Programming Guide
SCPI Reference
• Safety Information
• Receiving the Instrument
• Environmental & Electrical Requirements
• Basic Setup
• Accessories
• Operation Verification
• Regulatory Information
• Instrument Overview
• Front Panel Operation
• Security
• Basic Troubleshooting
• Remote Operation
• Status Registers
• Creating & Downloading Files
• SCPI Basics
• Command Descriptions
• Programming Command Compatibility
Service Guide
• Troubleshooting
• Replaceable Parts
• Assembly Replacement
• Post- Repair Procedures and Performance Verification
• Safety and Regulatory Information
Key H elp
a
• Key function description
• Related SCPI commands
a.Press the Help hardkey, and then the key for which you wish help.
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guideix
xAgilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
1Getting Started with Remote Operation
• “Programming and Software/Hardware Layers” on page 2
• “Interfaces” on page 3
• “IO Libraries and Programming Languages” on page 5
• “Using the Web Browser” on page 10
• “Preferences” on page 16
• “Error Messages” on page 19
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide1
Getting Started with Remote Operation
Programming and Software/Hardware Layers
Programming and Software/Hardware Layers
Agilent MXG, ESG, PSG, and E8663B signal generators support the following
interfaces:
InstrumentInterfaces Supported
Agilent MXGGPIB, LAN, and USB 2.0
Agilent E8663B
a
GPIB, LAN
connection
, and ANSI/EIA232 (RS-232) serial
Agilent ESG
GPIB, LAN, and
ANSI/EIA232 (RS- 232) serial
connection
a
Agilent PSG
GPIB, LAN, and ANSI/EIA232 (RS- 232) serial
connection
a.The PSG and E8663B’s AUXILIARY INTERFACE connector is compatible with ANSI/EIA232
(RS-232) serial connection but GPIB and LAN are recommended for making faster measurements
and when downloading files. Refer to “Using RS-232 (ESG, PSG, and E8663B Only)” on page 45
and the User’s Guide.
Use these interfaces, in combination with IO libraries and programming languages, to remotely
control a signal generator. Figure 1-1 uses GPIB as an example of the relationships between the
interface, IO libraries, programming language, and signal generator.
2Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Figure 1-1 Software/Hardware Layers
Getting Started with Remote Operation
Interfaces
Interfaces
GPIBGPIB is used extensively when a dedicated computer is available for remote control of
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide3
each instrument or system. Data transfer is fast because GPIB handles information in
bytes with data transfer rates of up to 8 MBps. GPIB is physically restricted by the
location and distance between the instrument/system and the computer; cables are
limited to an average length of two meters per device with a total length of 20 meters.
For more information on configuring the signal generator to communicate over the
GPIB, refer to “Using GPIB” on page 22.
Getting Started with Remote Operation
Interfaces
LANData transfer using the LAN is fast as the LAN handles packets of data. The single
cable distance between a computer and the signal generator is limited to 100 meters
(100Base- T and 10Base- T).
The Agilent MXG is capable of 100Base- T LAN communication. The ESG, PSG and
E8663B are designed to connect with a 10Base- T LAN. Where auto- negotiation is
present, the ESG, PSG, and E8663B can connect to a 100Base-T LAN, but communicate
at 10Base- T speeds. For more information on LAN communication refer to
http://www.ieee.org.
The following protocols can be used to communicate with the signal generator over the
LAN:
• VXI- 11 (recommended)
• Sockets
• TELNET
• FTP
The Agilent MXG is LXI Class C compliant. For more information on the LXI standards,
refer to http://www.lxistandard.org/home.
For more information on configuring the signal generator to communicate over the LAN,
refer to “Using LAN” on page 28.
a
RS- 232
(ESG/PSG/E8663B
Only)
RS- 232 is an older method used to communicate with a single instrument; its primary
use is to control printers and external disk drives, and connect to a modem.
Communication over RS-232 is much slower than with GPIB, USB, or LAN because data
is sent and received one bit at a time. It also requires that certain parameters, such as
baud rate, be matched on both the computer and signal generator.
For more information on configuring the signal generator to communicate over the
RS- 232, refer to “Using RS- 232 (ESG, PSG, and E8663B Only)” on page 45.
USB
(Agilent MXG
Only)
a.The ESG, PSG, and E8663B’s AUXILIARY INTERFACE connector is compatible with ANSI/EIA232 (RS-232) serial connection but GPIB and
LAN are recommended for making faster measurements and when downloading files. Refer to “Using RS-232 (ESG, PSG, and E8663B Only)”
on page 45 and the User’s Guide.
4Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
• The rear panel Mini-B 5 pin connector is a device USB and can be used to connect
a controller for remote operation.
• The Type- A front panel connector is a host USB and can be used to connect a
mouse, a keyboard, or a USB 1.1/2.0 flash drive.
USB 2.0’s 64 MBps communication speed is faster than GPIB (for data transfers, >1 KB)
or RS- 232. (For additional information, refer to the Agilent SICL or VISA User’s Guide.)
But, the latency for small transfers is longer.
For more information on connecting the signal generator to the USB, refer to the
“Agilent IO Libraries Suite” on page 5 and the Agilent Connection Expert in the Agilent
IO Libraries Help.
For more information on configuring the signal generator to communicate over the USB,
refer to “Using USB (Agilent MXG)” on page 53.
Getting Started with Remote Operation
IO Libraries and Programming Languages
IO Libraries and Programming Languages
The IO libraries is a collection of functions used by a programming language to send instrument
commands and receive instrument data. Before you can communicate and control the signal
generator, you must have an IO library installed on your computer. The Agilent IO libraries are
included on an Automation-Ready CD with your signal generator and Agilent GPIB interface board,
or they can be downloaded from the Agilent website: http://www.agilent.com.
NOTETo learn about using IO libraries with Windows XP or newer operating systems, refer to the
Agilent IO Libraries Suite’s help located on the Automation-Ready CD that ships with your
signal generator. Other sources of this information, can be found with the Agilent GPIB
interface board’s CD, or downloaded from the Agilent website: http://www.agilent.com.
To better understand setting up Windows XP operating systems and newer, using PC LAN
port settings, refer to Chapter 2.
Agilent IO Libraries Suite
The Agilent IO Libraries Suite replaces earlier versions of the Agilent IO Libraries. Agilent IO
Libraries Suite does not support Windows NT. If you are using the Windows NT platform, you must
use Agilent IO Libraries version M or earlier.
Windows 98 and Windows ME are not supported in the Agilent IO Libraries Suite version 14.1 and
higher.
CAUTIONThe Agilent MXG’s USB interface requires Agilent IO Libraries Suite 14.1 or newer. For
NOTEThe signal generator ships with an Automation- Ready CD that contains the Agilent IO
more information on connecting instruments to the USB, refer to the Agilent Connection
Expert in the Agilent IO Libraries Help.
Libraries Suite 14.0 for users who use Windows 98 and Windows ME. These older systems
are no longer supported.
Once the libraries are loaded, you can use the Agilent Connection Expert, Interactive IO, or VISA
Assistant to configure and communicate with the signal generator over different IO interfaces. Follow
instructions in the setup wizard to install the libraries.
Windows NT and XP are registered trademarks of Microsoft Corporation.
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide5
Getting Started with Remote Operation
IO Libraries and Programming Languages
NOTEBefore setting the LAN interface, the signal generator must be configured for VXI- 11 SCPI.
Refer to “Configuring the VXI- 11 for LAN (Agilent MXG)” on page 29 or “Configuring the
VXI- 11 for LAN (ESG/PSG/E8663B)” on page 30.
Refer to the Agilent IO Libraries Suite Help documentation for details about this software.
Windows NT and Agilent IO Libraries M (and Earlier)
NOTEWindows NT is not supported on Agilent IO Libraries 14.0 and newer.
The following sections are specific to Agilent IO Libraries versions M and earlier and apply
only to the Windows NT platform.
For additional information on older versions of Agilent IO libraries, refer to the Agilent
Connection Expert in the Agilent IO Libraries Help. The Agilent IO libraries are included
with your signal generator or Agilent GPIB interface board, or they can be downloaded from
the Agilent website: http://www.agilent.com.
Using IO Config for Computer-to-Instrument Communication with VISA (Automatic or Manually)
After installing the Agilent IO Libraries version M or earlier, you can configure the interfaces
available on your computer by using the IO Config program. This program can setup the interfaces
that you want to use to control the signal generator. The following steps set up the interfaces.
1. Install GPIB interface boards before running IO Config.
NOTEYou can also connect GPIB instruments using the Agilent 82357A USB/GPIB Interface
Converter, which eliminates the need for a GPIB card. For more information, go to
http://www.agilent.com/find/gpib.
2. Run the IO Config program. The program automatically identifies available interfaces.
3. Click on the interface type you want to configure, such as GPIB, in the Available Interface Types
text box.
4. Click the Configure button. Set the Default Protocol to AUTO.
5. Click OK to use the default settings.
6. Click OK to exit the IO Config program.
VISA Assistant
VISA is an industry standard IO library API. It allows the user to send SCPI commands to
instruments and to read instrument data in a variety of formats. You can use the VISA Assistant,
6Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Getting Started with Remote Operation
IO Libraries and Programming Languages
available with the Agilent IO Libraries versions M and earlier, to send commands to the signal
generator. If the interface you want to use does not appear in the VISA Assistant then you must
manually configure the interface. See the Manual VISA Configuration section below. Refer to the VISA
Assistant Help menu and the Agilent VISA User’s Manual (available on Agilent’s website) for more
information.
VISA Configuration (Automatic)
1. Run the VISA Assistant program.
2. Click on the interface you want to use for sending commands to the signal generator.
3. Click the Formatted I/O tab.
4. Select SCPI in the Instr. Lang. section.
You can enter SCPI commands in the text box and send the command using the viPrintf button.
VISA Configuration (Manual)
Perform the following steps to use IO Config and VISA to manually configure an interface.
1. Run the IO Config Program.
2. Click on GPIB in the Available Interface Types text box.
3. Click the Configure button. Set the Default Protocol to AUTO and then click OK to use the default
settings.
4. Click on GPIB0 in the Configured Interfaces text box.
5. Click Edit...
6. Click the Edit VISA Config... button.
7. Cli c k the Add device button.
8. Enter the GPIB address of the signal generator.
9. Click the OK button in this form and all other forms to exit the IO Config program.
Selecting IO Libraries for GPIB
The IO libraries are included with the GPIB interface card, and can be downloaded from the National
Instruments website or the Agilent website. See also, “IO Libraries and Programming Languages” on
page 5 for information on IO libraries. The following is a discussion on these libraries.
CAUTIONBecause of the potential for portability problems, running Agilent SICL without the
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide7
VISA overlay is not recommended by Agilent Technologies.
Getting Started with Remote Operation
IO Libraries and Programming Languages
VISA VISA is an IO library used to develop IO applications and instrument drivers that
comply with industry standards. It is recommended that the VISA library be used
for programming the signal generator. The NI- VISA and Agilent VISA libraries are
similar implementations of VISA and have the same commands, syntax, and
functions. The differences are in the lower level IO libraries; NI- 488.2 and SICL
respectively. It is best to use the Agilent VISA library with the Agilent GPIB
interface card or NI-VISA with the NI PCI-GPIB interface card.
SICL Agilent SICL can be used without the VISA overlay. The SICL functions can be
called from a program. However, if this method is used, executable programs will
not be portable to other hardware platforms. For example, a program using SICL
functions will not run on a computer with NI libraries (PCI- GPIB interface card).
NI- 488.2 NI- 488.2 can be used without the VISA overlay. The NI- 488.2 functions can be
called from a program. However, if this method is used, executable programs will
not be portable to other hardware platforms. For example, a program using
NI- 488.2 functions will not run on a computer with Agilent SICL (Agilent GPIB
interface card).
Selecting IO Libraries for LAN
The TELNET and FTP protocols do not require IO libraries to be installed on your computer.
However, to write programs to control your signal generator, an IO library must be installed on your
computer and the computer configured for instrument control using the LAN interface.
The Agilent IO libraries Suite is available on the Automation- Ready CD, which was shipped with your
signal generator. The libraries can also be downloaded from the Agilent website. The following is a
discussion on these libraries.
Agilent VISA VISA is an IO library used to develop IO applications and instrument drivers that
SICL Agilent SICL is a lower level library that is installed along with Agilent VISA.
comply with industry standards. Use the Agilent VISA library for programming the
signal generator over the LAN interface.
NI- VISA is a registered trademark of National Instruments Corporation.
8Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Getting Started with Remote Operation
IO Libraries and Programming Languages
Programming Languages
Along with Standard Commands for Programming Instructions (SCPI) and IO library functions, you
use a programming language to remotely control the signal generator. Common programming
languages include:
•C/C++
•C#
•MATLAB
•HP Basic
•LabView
• Java (Java is a U.S. trademark of Sun Microsystems, Inc.)
•Visual Basic
•PERL
•Agilent VEE
For examples, using some of these languages, refer to Chapter 3.
®
(MATLAB is a registered trademark of The MathWorks.)
®
(Visual Basic is a registered trademark of Microsoft Corporation.)
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide9
Getting Started with Remote Operation
To operate the signal generator, click the keys.
The Agilent MXG is LXI Class C compliant.
For more information on the
LXI standards, refer to http://www.lxistandard.org/home.
Note: If y ou do not see this window, check to see if the window is hidden
behind your browser window or your web browser settings are set to block
pop-ups. To use this feature, you need to set your web browser to allow
pop-ups for your instrument’s IP address.
Using the Web Browser
Using the Web Browser
The instrument can be accessed through a
standard web browser, when it is
connected to the LAN. To access through
the web browser, enter the instrument IP
address as the URL in your browser.
The signal generator web page, shown at
right and page 13, provides general
information on the signal generator, FTP
access to files stored on the signal
generator, and a means to control the
instrument using either a remote
front- panel interface or SCPI commands.
The web page also has links to Agilent’s
products, support, manuals, and website.
For additional information on memory
catalog access (file storing), and FTP, refer
to the User’s Guide and “Waveform
Memory” on page 198 and for FTP, see
“Using FTP” on page 43 and “FTP
Procedures” on page 210.
newer) web browser and operating systems
Windows 2000, Windows XP, and newer.
For more information on using the Web
Server, refer to “Enabling the Signal
Generator Web Server” on page 11.
Microsoft is a registered trademark of Microsoft.
10Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Getting Started with Remote Operation
If necessary toggle Web Server to
On.
For details on each key, use the key help.
Refer to “Getting Help (Agilent MXG)” on
page 18 and the User’s Guide. For additional
SCPI command information, refer to the SCPI
Command Reference.
If necessary toggle Web Server On
Off to On.
For details on each key, use the Key and Data Field Reference. For additional SCPI command information,
refer to the SCPI Command Reference.
Using the Web Browser
Enabling the Signal Generator Web Server
NOTEJavascript or Active Scripts must be enabled to use the web front panel controls.
1. Turn on the Web server as shown below.
Agilent MXG Web Server On
ESG/PSG/E8663B Web Server On
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide11
Getting Started with Remote Operation
Using the Web Browser
2. Launch the PC or workstation web browser.
3. In the web browser address field, enter the signal generator’s IP address. For example,
http://101.101.101.101 (where 101.101.101.101 is the signal generator’s IP address).
The IP (internet protocol) address can change depending on the LAN configuration (see “Using
LAN” on page 28).
4. On the computer’s keyboard, press Enter. The web browser displays the signal generator’s
homepage.
5. Click the Signal Generator Web Control menu button on the left of the page. The front panel web
page displays.
NOTE If you are experiencing problems with opening the signal generator’s remote front panel
web page, verify that the pop- up blocker is turned off on your web browser.
In some cases the Web- Enabled front panel may appear behind the main browser
window, so you must move the browser window to see the Web- Enabled front panel.
To control the signal generator, either click the front panel keys or enter SCPI commands.
12Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
FTP enables the transfer of files between
The FTP access softkey opens to show the folders containing the
signal generator’s memory catalog files.
Use the FTP window to drag and drop files from the FTP page to your
computer.
the instrument and a computer. The FTP
access button provides drag-and- drop file
capability.
Getting Started with Remote Operation
Using the Web Browser
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide13
Getting Started with Remote Operation
Using the Web Browser
LAN Configuration System Defaults (Agilent MXG)
NOTEThe instrument’s LAN configuration system information can be found on the signal
generator’s homepage and on the signal generator. Refer to “Enabling the Signal Generator
Web Server” o n pag e 11 and to “Displaying the LAN Configuration Summary (Agilent MXG)”
on page 15.
If the instrument has been restored to the factory defaults from the LAN Setup menu the signal
generator will revert to the values displayed in Table 1- 1 on page 14. Refer to “Displaying the LAN
Configuration Summary (Agilent MXG)” on page 15.
To reset the instrument LXI password to “agilent” and the LAN settings to their factory default
values, press the following key sequence on the signal generator:
Utility > I/O Config > LAN Setup > Advanced Settings > Restore LAN Settings to Default Values >
Restore LAN Settings to Default Values
NOTEThere are no SCPI commands associated with this LXI password factory reset.
For more information, refer to the signal generator’s Web Server Interface Help.
14Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Table 1-1 LAN Configuration Summary Values
For details on each key, use the key help (described in the User’s Guide).
Confirm Restore Settings to Factory Defaults: Confirming this action configures the
signal generator to its original factory default settings. For information regarding
those default settings, refer to Ta ble 1-1 on page 14.
a.The Domain Name defaults to a null field.
b.This information is part of the “Advanced Information about this Web-Enabled <signal generator model number>”
Displaying the LAN Configuration Summary (Agilent MXG)
Getting Started with Remote Operation
Using the Web Browser
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide15
Getting Started with Remote Operation
Preferences
Preferences
The following commonly- used manual command sections are included here:
“Configuring the Display for Remote Command Setups (Agilent MXG)” on page 17
“Configuring the Display for Remote Command Setups (ESG/PSG/E8663B)” on page 17
“Getting Help (Agilent MXG)” on page 18
“Setting the Help Mode (ESG/PSG/E8663B)” on page 18
“Setting the Help Mode (ESG/PSG/E8663B)” on page 18
16Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Getting Started with Remote Operation
For details on each key, use the key help (described in User’s Guide).
Select Update in Remote until On is
highlighted.
SCPI commands:
:DISPlay:REMote ON|OFF|1|0
:DISPlay:REMote?
For details on each key, use the Key and Data Field Reference. For additional SCPI command information, refer to the SCPI Command
Reference.
Select Update in Remote until On is highlighted.
SCPI commands:
:DISPlay:REMote ON|OFF|1|0
:DISPlay:REMote?
Using the Update in Remote sof tkey up dates t he displ a y but not the
softkeys on each SCPI command.
In general, the softkeys are not updated until the SCPI command
SYST:DISP:GTL is sent.
Configuring the Display for Remote Command Setups (Agilent MXG)
Configuring the Display for Remote Command Setups (ESG/PSG/E8663B)
Preferences
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide17
Getting Started with Remote Operation
For details on each key, use the key help (described in User’s Guide).
When you press Help:
Help displays for the next key you press. Use the cursor keys, Page Up, Page
Down, and the RPG knob to scroll the help text. Then press Cancel to close the
help window or press any other key to close the help window and execute that key.
For details on each key, use the key help (described in User’s Guide).
When you press Help:
Help displays for the next key you press or you see help for the next key or for
every key, depending on the Help mode.
HELP
For details on each key, use the Key and Data Field Reference. For additional SCPI command information, refer to the SCPI Command Reference.
When you press Help:
Single: Help displays only for the next key you press.
Cont: Help displays for each key you press and that key’s function activates.
18Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Getting Started with Remote Operation
Error Messages
Error Messages
If an error condition occurs in the signal generator, it is reported to both the SCPI (remote interface)
error queue and the front panel display error queue. These two queues are viewed and managed
separately; for information on the front panel display error queue, refer to the User’s Guide.
NOTEFor additional general information on troubleshooting problems with your connections, refer
to the Help in the Agilent IO Libraries and documentation.
When accessing error messages using the SCPI (remote interface) error queue, the error numbers and
the <error_description> portions of the error query response are displayed on the host terminal.
CharacteristicSCPI Remote Interface Error Queue
Capacity (#errors)30
Overflow Handling
Viewing Entries
Clearing the Queue
Unresolved Errors
No Errors
a
a.On the Agilent MXG, using this SCPI command to read out the error messages clears the display of the ERR annunciator and the error
message at the bottom of the screen.
b.On the Agilent MXG, executing the SCPI command *CLS clears the display of the ERR annunciator and the error message at the bottom
of the screen.
c.Errors that still exist after clearing the error queue. For example, unlock.
When the queue is empty (every error in the queue has been read, or the queue is cleared), the
following message appears in the queue:
+0, "No error"
Error Message File
A complete list of error messages is provided in the file errormessages.pdf, on the CD-ROM supplied
with your instrument. In the error message list, an explanation is generally included with each error
to further clarify its meaning. The error messages are listed numerically. In cases where there are
multiple listings for the same error number, the messages are in alphabetical order.
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide19
Getting Started with Remote Operation
Error Messages
Error Message Types
Events generate only one type of error. For example, an event that generates a query error will not
generate a device- specific, execution, or command error.
Query Errors (–499 to –400) indicate that the instrument’s output queue control has detected a
problem with the message exchange protocol described in IEEE 488.2, Chapter 6. Errors in this class
set the query error bit (bit 2) in the event status register (IEEE 488.2, section 11.5.1). These errors
correspond to message exchange protocol errors described in IEEE 488.2, 6.5. In this case:
• Either an attempt is being made to read data from the output queue when no output is either
present or pending, or
• data in the output queue has been lost.
Device Specific Errors (–399 to –300, 201 to 703, and 800 to 810) indicate that a device operation
did not properly complete, possibly due to an abnormal hardware or firmware condition. These codes
are also used for self- test response errors. Errors in this class set the device- specific error bit (bit 3)
in the event status register (IEEE 488.2, section 11.5.1).
The <error_message> string for a positive error is not defined by SCPI. A positive error indicates that
the instrument detected an error within the GPIB system, within the instrument’s firmware or
hardware, during the transfer of block data, or during calibration.
Execution Errors (–299 to –200) indicate that an error has been detected by the instrument’s
execution control block. Errors in this class set the execution error bit (bit 4) in the event status
register (IEEE 488.2, section 11.5.1). In this case:
• Either a <PROGRAM DATA> element following a header was evaluated by the device as outside of
its legal input range or is otherwise inconsistent with the device’s capabilities, or
• a valid program message could not be properly executed due to some device condition.
Execution errors are reported after rounding and expression evaluation operations are completed.
Rounding a numeric data element, for example, is not reported as an execution error.
Command Errors (–199 to –100) indicate that the instrument’s parser detected an IEEE 488.2
syntax error. Errors in this class set the command error bit (bit 5) in the event status register (IEEE
488.2, section 11.5.1). In this case:
• Either an IEEE 488.2 syntax error has been detected by the parser (a control- to- device message
was received that is in violation of the IEEE 488.2 standard. Possible violations include a data
element that violates device listening formats or whose type is unacceptable to the device.), or
• an unrecognized header was received. These include incorrect device-specific headers and
incorrect or unimplemented IEEE 488.2 common commands.
20Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
2Using IO Interfaces
Using the programming examples with GPIB, LAN, RS- 232, and USB interfaces:
• “Using GPIB” on page 22
• “Using LAN” on page 28
• “Using RS-232 (ESG, PSG, and E8663B Only)” on page 45
• “Using USB (Agilent MXG)” on page 53
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide21
Using IO Interfaces
Using GPIB
Using GPIB
GPIB enables instruments to be connected together and controlled by a computer. GPIB and its
associated interface operations are defined in the ANSI/IEEE Standard 488.1- 1987 and ANSI/IEEE
Standard 488.2- 1992. See the IEEE website, http://www.ieee.org, for details on these standards.
The following sections contain information for installing a GPIB interface card or NI- GPIB interface
card for your PC or UNIX-based system.
• “Installing the GPIB Interface” on page 22
• “Set Up the GPIB Interface” on page 24
• “Verify GPIB Functionality” on page 25
Installing the GPIB Interface
NOTEYou can also connect GPIB instruments to a PC USB port using the Agilent 82357A
USB/GPIB Interface Converter, which eliminates the need for a GPIB card. For more
information, refer to table on page 22 or go to http://www.agilent.com/find/gpib.
A GPIB interface card can be installed in a computer. Two common GPIB interface cards are the
Agilent GPIB interface card and the National Instruments (NI) PCI–GPIB card. Follow the interface
card instructions for installing and configuring the card. The following table provide lists on some of
the available interface cards. Also, see the Agilent website, http://www.agilent.com for details on
GPIB interface cards.
Interface
Type
Agilent USB/GPIB Interface Converter for PC- Based Systems
Agilent 82357A
Converter
Agilent GPIB Interface Card for PC- Based Systems
Agilent 82341C
for ISA bus
computers
Agilent 82341D
Plug&Play for
PC
Agilent 82350A
for PCI bus
computers
Operating
System
a
Windows
98(SE)/ME/
2000®/XP
b
Windows
95/98/NT
®
/2000
Windows
95
Windows
95/98/NT
/2000
IO LibraryLanguagesBackplane/
VISA / SICLC/C++, Visual
VISA / SICLC/C++, Visual
VISA / SICLC/C++, Visual
VISA / SICLC/C++, Visual
Basic, Agilent
VEE, HP Basic for
Windows, NI
Labview
Basic, Agilent
VEE, HP Basic for
Windows
Basic, Agilent
VEE, HP Basic for
Windows
Basic, Agilent
VEE, HP Basic for
Windows
BUS
USB 2.0
(1.1 compatible)
ISA/EISA,
16 bit
ISA/EISA,
16 bit
PCI 32 bit750Built- in
Max IO
(kB/sec)
850Built- in
750Built- in
750Built- in
Buffering
22Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Using IO Interfaces
Using GPIB
Interface
Type
Agilent USB/GPIB Interface Converter for PC- Based Systems
Agilent 82350B
for PCI bus
computers
NI- GPIB Interface Card for PC- Based Systems
National
Instruments
PCI- GPIB
National
Instruments
PCI- GPIB+
Agilent- GPIB Interface Card for HP- UX Workstations
Agilent E2071CHP- UX 9.x,
Agilent E2071DHP-UX 10.20VISA/SICLANSI C,
Agilent E2078AHP-UX 10.20VISA/SICLANSI C,
Operating
System
Windows
98(SE)/ME/2000
/XP
Windows
95/98/2000/
ME/NT
Windows
NT
HP- UX 10.01
IO LibraryLanguagesBackplane/
VISA / SICLC/C++, Visual
VISA
NI- 488.2™
VISA
NI- 488.2
VISA/SICLANSI C,
Basic, Agilent
VEE, HP Basic for
Windows
C/C++,
c
Visual BASIC,
LabView
C/C++,
Visual BASIC,
LabView
Agilent VEE,
Agilent BASIC,
HP- UX
Agilent VEE,
Agilent BASIC,
HP- UX
Agilent VEE,
Agilent BASIC,
HP- UX
BUS
PCI 32 bit> 900Built- in
PCI 32 bit1.5 MBps Built- in
PCI 32 bit1.5 MBpsBuilt- in
EISA750Built- in
EISA750Built- in
PCI750Built- in
Max IO
(kB/sec)
Buffering
a.Windows 95, 98(SE), NT, 2000, and XP are registered trademarks of Microsoft Corporation.
b.Windows 98 and ME are registered trademarks of Microsoft Corporation.
c.NI-488.2 is a trademark of National Instruments Corporation.
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide23
Using IO Interfaces
For details on each key, use the key help. Refer to “Getting Help (Agilent MXG)” on page 18 and the User’s Guide. For additional SCPI
command information, refer to the SCPI Command Reference.
To verify GPIB functionality, use the VISA Assistant, available with the Agilent IO Library or the
Getting Started Wizard available with the National Instrument IO Library. These utility programs
enable you to communicate with the signal generator and verify its operation over GPIB. For
information and instructions on running these programs, refer to the Help menu available in each
utility.
If You Have Problems
1. Verify that the signal generator’s address matches the address declared in the program (example
programs in Chapter 2 use address 19).
2. Remove all other instruments connected via GPIB and rerun the program.
3. Verify that the GPIB card’s name or id number matches the GPIB name or id number configured
for your PC.
GPIB Interface Terms
An instrument that is part of a GPIB network is categorized as a listener, talker, or controller,
depending on its current function in the network.
listener A listener is a device capable of receiving data or commands from other
talker A talker is a device capable of transmitting data. To avoid confusion, a GPIB
controller A controller, typically a computer, can specify the talker and listeners (including
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide25
instruments. Several instruments in the GPIB network can be listeners
simultaneously.
system allows only one device at a time to be an active talker.
itself) for an information transfer. Only one device at a time can be an active
controller.
Using IO Interfaces
GPIB Programming Interface Examples
GPIB Programming Interface Examples
NOTEThe portions of the programming examples discussed in this section are taken from the full
text of these programs that can be found in Chapter 3, “Programming Examples.”
• “Interface Check using HP Basic and GPIB” on page 26
• “Interface Check Using NI- 488.2 and C++” on page 26
Before Using the GPIB Examples
If the Agilent GPIB interface card is used, the Agilent VISA library should be installed along with
Agilent SICL. If the National Instruments PCI- GPIB interface card is used, the NI- VISA library along
with the NI- 488.2 library should be installed. Refer to “Selecting IO Libraries for GPIB” on page 7
and the documentation for your GPIB interface card for details.
HP Basic addresses the signal generator at 719. The GPIB card is addressed at 7 and the signal
generator at 19. The GPIB address designator for other libraries is typically GPIB0 or GPIB1.
The following sections contain HP Basic and C++ lines of programming removed from the
programming interface examples in Chapter 3, “Programming Examples.” these portions of
programming demonstrate the important features to consider when developing programming for use
with the GPIB interface.
Interface Check using HP Basic and GPIB
This portion of the example program “Interface Check using HP Basic and GPIB” on page 26, causes
the signal generator to perform an instrument reset. The SCPI command *RST places the signal
generator into a pre- defined state and the remote annunciator (R) appears on the front panel display.
The following program example is available on the signal generator Documentation CD- ROM as
basicex1.txt. For the full text of this program, refer to “Interface Check using HP Basic and GPIB” on
page 66 or to the signal generator’s documentation CD-ROM.
160 Sig_gen=719 ! Declares a variable to hold the signal generator's address
170 LOCAL Sig_gen ! Places the signal generator into Local mode
180 CLEAR Sig_gen ! Clears any pending data I/O and resets the parser
190 REMOTE 719 ! Puts the signal generator into remote mode
200 CLEAR SCREEN ! Clears the controllers display
210 REMOTE 719
220 OUTPUT Sig_gen;"*RST" ! Places the signal generator into a defined state
Interface Check Using NI-488.2 and C++
This portion of the example program “Interface Check Using NI- 488.2 and C++” on page 26, uses the
NI- 488.2 library to verify that the GPIB connections and interface are functional.
The following program example is available on the signal generator Documentation CD- ROM as
niex1.cpp. For the full text of this program, refer to “Interface Check Using NI- 488.2 and C++” on
page 67 or to the signal generator’s documentation CD-ROM.
26Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
GPIB Programming Interface Examples
#include "stdafx.h"
#include <iostream>
#include "windows.h"
#include "Decl-32.h"
using namespace std;
int GPIB0= 0; // Board handle
Addr4882_t Address[31]; // Declares an array of type Addr4882_t
int main(void)
{
int sig; // Declares a device descriptor variable
sig = ibdev(0, 19, 0, 13, 1, 0); // Aquires a device descriptor
ibclr(sig); // Sends device clear message to signal generator
ibwrt(sig, "*RST", 4); // Places the signal generator into a defined state
Using IO Interfaces
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide27
Using IO Interfaces
Using LAN
Using LAN
The Agilent MXG is capable of 100Base- T LAN communication. The ESG, PSG, and E8663B are
designed to connect with a 10Base- T LAN. Where auto- negotiation is present, the ESG, PSG, and
E8663B can connect to a 100Base- T LAN, but communicate at 10Base- T speeds. For more
information refer to http://www.ieee.org.
The signal generator can be remotely programmed via a 100Base- T LAN interface or 10Base- T LAN
interface and LAN- connected computer using one of several LAN interface protocols. The LAN allows
instruments to be connected together and controlled by a LAN- based computer. LAN and its
associated interface operations are defined in the IEEE 802.2 standard. For more information refer to
http://www.ieee.org.
NOTEFor more information on configuring your signal generator for LAN, refer to the User’s Guide
The signal generator supports the following LAN interface protocols:
• VXI- 11 (See page 37)
• Sockets LAN (See page 39)
• Telephone Network (TELNET) (See page 39)
• File Transfer Protocol (FTP) (See page 43)
VXI- 11 and sockets LAN are used for general programming using the LAN interface, TELNET is used
for interactive, one command at a time instrument control, and FTP is for file transfer.
The Agilent MXG is LXI Class C compliant. For more information on the LXI standards, refer to
http://www.lxistandard.org/home.
NOTEFor more information on configuring the signal generator to communicate over the LAN,
The following sections contain information on selecting and connecting IO libraries and LAN interface
hardware that are required to remotely program the signal generator via LAN to a LAN- based
computer and combining those choices with one of several possible LAN interface protocols.
• “Setting Up the LAN Interface” on page 29
• “Verifying LAN Functionality” on page 34
for your signal generator. Also, for the Agilent MXG, refer to www.agilent.com and search on
the FAQs: Hardware Configurations and Installation.
refer to “Using VXI- 11” on page 37.
28Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Using IO Interfaces
NOTE
T o communicate with the signal generator over the LAN, you must enable the VXI-11 SCPI service. Select VXI-11
until On is highlighted. (Default condition is On.)
For optimum performance, use a 100Base-T LAN cable to connect the signal generator to the LAN.
For details on each key, use the key help. For information describing the key help, refer to “Getting Help (Agilent MXG)” on page 18 and
the User’s Guide. For additional SCPI command information, refer to the SCPI Command Reference.
Utility > IO Config
Using LAN
Setting Up the LAN Interface
For LAN operation, the signal generator must be connected to the LAN, and an IP address must be
assigned to the signal generator either manually or by using DHCP client service. Your system
administrator can tell you which method to use. (Most modern LAN networks use DHCP.)
NOTEVerify that the signal generator is connected to the LAN using a 100Base-T LAN or 10Base-T
LAN cable.
Configuring the VXI-11 for LAN (Agilent MXG)
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide29
Using IO Interfaces
NOTE
To communicate with the signal generator over the LAN, you must enable the VXI-11 SCPI service. Select VXI-11 until On is highlighted.
(Default condition is On.)
Use a 10Base-T LAN cable to connect the signal generator to the LAN.Where auto-negotiation is present, the ESG, PSG, or E8663B can
connect to 100Base-T LAN, but will communicate at 10Base-T speeds. For more information refer to http://www.ieee.org.
For details on each key, use the Key and Data Field Reference. For additional SCPI comma nd
information, refer to the SCPI Command Reference.
Utility > GPIB/RS-232
LAN
Using LAN
Configuring the VXI-11 for LAN (ESG/PSG/E8663B)
Manual Configuration
The Hostname softkey is only available when LAN Config Manual DHCP is set to Manual.
To remotely access the signal generator from a different LAN subnet, you must also enter the subnet
mask and default gateway. See your system administrator for more information.
For more information on the manual configuration, refer to “Manually Configuring the Agilent MXG
LAN” on page 31 or to “Manually Configuring the ESG/PSG/E8663B LAN” on page 31.
30Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Manually Configuring the Agilent MXG LAN
For details on each key, use the key help (described in User’s Guide). For additional SCPI command information, refer to the SCPI
Command Reference.
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide31
Using IO Interfaces
Using LAN
DHCP Configuration
If the DHCP server uses dynamic DNS to link the hostname with the assigned IP address, the
hostname may be used in place of the IP address. Otherwise, the hostname is not usable.
For more information on the DHCP configuration, refer to “Configuring the DHCP LAN (Agilent
MXG)” on page 33 or “Configuring the DHCP LAN (ESG/PSG/E8663B)” on page 33.
AUTO (DHCP/Auto-IP) Configuration (Agilent MXG)
DHCP and Auto-IP are used together to make automatic (AUTO) mode for IP configuration.
Automatic mode attempts DHCP first and then if that fails Auto- IP is used to detect a private
network. If neither is found, Manual is the final choice.
If the DHCP server uses dynamic DNS to link the hostname with the assigned IP address, the
hostname may be used in place of the IP address. Otherwise, the hostname is not usable.
Auto- IP provides automatic TCP/IP set- up for instruments on any manually configured networks.
For more information on the AUTO (DHCP/Auto-IP) configuration, refer to “Configuring the DHCP
LAN (Agilent MXG)” on page 33.
32Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Configuring the DHCP LAN (Agilent MXG)
For details on each key, use the key help (described in User’s Guide). For additional SCPI command information, refer to the SCPI
Command Reference.
AUTO (DHCP/Auto-IP): Request a new IP address in the following sequence: 1) from the DHCP (server-based
LAN), 2) Auto-IP (private network without a network administrator) or if neither is available, 3) Manual setting is
selected.
DHCP: Request a new IP address from the DHCP server each power cycle.
Confirming this action configures the signal generator as a DHCP client. In DHCP mode, the signal generator
will request a new IP address from the DHCP server upon rebooting to determine the assigned IP address.
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide33
Using IO Interfaces
Using LAN
Setting up Private LAN
You can connect the Agilent MXG, ESG, PSG or E8663B directly to a PC using a crossover cable. To
do this, you should either choose to set IP addresses of the PC and signal generator to differ only in
the last digit (example: PC’s IP: 1.1.1.1 and Signal generator’s IP: 1.1.1.2); or you can use the DHCP
feature or Auto- IP feature if your PC supports them. For more information go to www.agilent.com,
and search on the Connectivity Guide (E2094- 90009) or use the Agilent Connection Expert’s Help to
see the Connection Guide.
Verifying LAN Functionality
Verify the communications link between the computer and the signal generator remote file server
using the ping utility. Compare your ping response to those described in Table 2- 1 on page 35.
NOTEFor additional information on troubleshooting your LAN connection, refer to “If You Have
Problems” on page 25 and to the Help in the Agilent IO Libraries and documentation for
LAN connections and problems.
From a UNIX
®
workstation, type (UNIX is a registered trademark of the Open Group):
ping <hostname or IP address> 64 10
where <hostname or IP address> is your instrument’s name or IP address, 64 is the packet size,
and 10 is the number of packets transmitted. Type man ping at the UNIX prompt for details on the
ping command.
®
From the MS- DOS
Command Prompt or Windows environment, type:
ping -n 10 <hostname or IP address>
where <hostname or IP address> is your instrument’s name or IP address and 10 is the number of
echo requests. Type ping at the command prompt for details on the ping command.
NOTEIn DHCP mode, if the DHCP server uses dynamic DNS to link the hostname with the
assigned IP address, the hostname may be used in place of the IP address. Otherwise, the
hostname is not usable and you must use the IP address to communicate with the signal
generator over the LAN.
If You Have Problems
If you are experiencing problems with the LAN connection on the signal generator, verify the rear
panel LAN connector green LED is on.
MS- DOS, and Visual Basic are registered trademarks of Microsoft.
34Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Using IO Interfaces
Using LAN
For additional information on troubleshooting your LAN connection, refer to the Help in the Agilent
IO Libraries and documentation for LAN connections and problems.
Table 2-1 Ping Responses
Normal Response for UNIXA normal response to the ping command will be a total of 9 or 10 packets received with a
Normal Response for DOS or
Windows
Error MessagesIf error messages appear, then check the command syntax before continuing with
No Response If there is no response from a ping, no packets were received. Check that the typed address
minimal average round-trip time. The minimal average will be different from network to
network. LAN traffic will cause the round-trip time to vary widely.
A normal response to the ping command will be a total of 9 or 10 packets received if 10 echo
requests were specified.
troubleshooting. If the syntax is correct, resolve the error messages using your network
documentation or by consulting your network administrator.
If an unknown host error message appears, try using the IP address instead of the hostname.
Also, verify that the host name and IP address for the signal generator have been registered
by your IT administrator.
Check that the hostname and IP address are correctly entered in the node names database. To
do this, enter the nslookup <hostname> command from the command prompt.
or hostname matches the IP address or hostname assigned to the signal generator in the
System LAN Setup menu. For more information, refer to “Configuring the DHCP LAN (Agilent
MXG)” on page 33 or “Configuring the DHCP LAN (ESG/PSG/E8663B)” on page 33.
Ping each node along the route between your workstation and the signal generator, starting
with your workstation. If a node doesn’t respond, contact your IT administrator.
If the signal generator still does not respond to ping, you should suspect a hardware problem.
• Check the signal generator LAN connector lights
• Verify the hostname is not being used with DHCP addressing
Intermittent ResponseIf you received 1 to 8 packets back, there maybe a problem with the network. In networks
with switches and bridges, the first few pings may be lost until these devices ‘learn’ the
location of hosts. Also, because the number of packets received depends on your network
traffic and integrity, the number might be different for your network. Problems of this nature
are best resolved by your IT department.
Using Interactive IO
Use the VISA Assistant utility available in the Agilent IO Libraries Suite to verify instrument
communication over the LAN interface. Refer to the section on the “IO Libraries and Programming
Languages” on page 5 for more information.
The Agilent IO Libraries Suite is supported on all platforms except Windows NT. If you are using
Windows NT, refer to section below on using the VISA Assistant to verify LAN communication. See
the section on “Windows NT and Agilent IO Libraries M (and Earlier)” on page 6 for more
information.
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide35
Using IO Interfaces
Using LAN
NOTEThe following sections are specific to Agilent IO Libraries versions M and earlier and apply
only to the Windows NT platform.
Using VISA Assistant
Use the VISA Assistant, available with the Agilent IO Library versions M and earlier, to communicate
with the signal generator over the LAN interface. However, you must manually configure the VISA
LAN client. Refer to the Help menu for instructions on configuring and running the VISA Assistant
program.
1. Run the IO Config program.
2. Click on TCPIP0 in the Available Interface Types text box.
3. Click the Configure button. Then Click OK to use the default settings.
4. Click on TCPIP0 in the Configured Interfaces text box.
5. Click Edit...
6. Click the Edit VISA Config... button.
7. Cli c k the Add device button.
8. Enter the TCPIP address of the signal generator. Leave the Device text box empty.
9. Click the OK button in this form and all subsequent forms to exit the IO Config program.
If You Have Problems
1. Verify the signal generator’s IP address is valid and that no other instrument is using the IP
address.
2. Switch between manual LAN configuration and DHCP using the front- panel LAN Config softkey and
run the ping program using the different IP addresses.
NOTEFor Agilent IO Libraries versions M and earlier, you must manually configure the VISA LAN
client in the IO Config program if you want to use the VISA Assistant to verify LAN
configuration. Refer to the IO Libraries Installation Guide for information on configuring IO
interfaces. The IO Config program interface is shown in Figure 2- 4 on page 38.
36Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Using IO Interfaces
Using LAN
Figure 2-3 IO Config Form (Windows NT)
Check to see that the Default Protocol is set to Automatic.
1. Run the IO Config program
2. Click on TCPIP in the Configured Interfaces text box. If there is no TCPIP0 in the box, follow the
steps shown in the section “Using VISA Assistant” on page 36
3. Click the Edit button.
4. Click the radio button for AUTO (automatically detect protocol).
5. Click OK, OK to end the IO Config program.
Using VXI-11
The signal generator supports the LAN interface protocol described in the VXI- 11 standard. VXI- 11 is
an instrument control protocol based on Open Network Computing/Remote Procedure Call (ONC/RPC)
interfaces running over TCP/IP. It is intended to provide GBIB capabilities such as SRQ (Service
Request), status byte reading, and DCAS (Device Clear State) over a LAN interface. This protocol is a
good choice for migrating from GPIB to LAN as it has full Agilent VISA/SICL support.
NOTEIt is recommended that the VXI-11 protocol be used for instrument communication over the
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide37
LAN interface.
Using IO Interfaces
Using LAN
Configuring for VXI-11
The Agilent IO library has a program, IO Config, that is used to setup the computer/signal generator
interface for the VXI- 11 protocol. Download the latest version of the Agilent IO library from the
Agilent website. Refer to the Agilent IO library user manual, documentation, and Help menu for
information on running the IO Config program and configuring the VXI- 11 interface.
Use the IO Config program to configure the LAN client. Once the computer is configured for a LAN
client, you can use the VXI-11 protocol and the VISA library to send SCPI commands to the signal
generator over the LAN interface. Example programs for this protocol are included in “LAN
Programming Interface Examples” on page 101 of this programming guide.
NOTETo communicate with the signal generator over the LAN interface you must enable the
VXI- 11 SCPI service. For more information, refer to “Configuring the DHCP LAN (Agilent
MXG)” on page 33 and “Configuring the DHCP LAN (ESG/PSG/E8663B)” on page 33.
If you are using the Windows NT platform, refer to “Windows NT and Agilent IO Libraries M
(and Earlier)” on page 6 for information on using Agilent IO Libraries versions M or earlier
to configure the interface.
For Agilent IO library version J.01.0100, the “Identify devices at run- time” check box must be
unchecked. Refer to Figure 2- 4.
Figure 2-4 Show Devices Form (Agilent IO Library version J.01.0100)
38Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Using IO Interfaces
Using LAN
Using Sockets LAN
NOTEUsers with Windows XP operating systems and newer can use this section to better
understand how to use the signal generator with port settings. For more information, refer to
the help software of the IO libraries being used.
Sockets LAN is a method used to communicate with the signal generator over the LAN interface
using the Transmission Control Protocol/Internet Protocol (TCP/IP). A socket is a fundamental
technology used for computer networking and allows applications to communicate using standard
mechanisms built into network hardware and operating systems. The method accesses a port on the
signal generator from which bidirectional communication with a network computer can be
established.
Sockets LAN can be described as an internet address that combines Internet Protocol (IP) with a
device port number and represents a single connection between two pieces of software. The socket
can be accessed using code libraries packaged with the computer operating system. Two common
versions of socket libraries are the Berkeley Sockets Library for UNIX systems and Winsock for
Microsoft operating systems.
Your signal generator implements a sockets Applications Programming Interface (API) that is
compatible with Berkeley socket for UNIX systems, and Winsock for Microsoft systems. The signal
generator is also compatible with other standard sockets APIs. The signal generator can be controlled
using SCPI commands that are output to a socket connection established in your program.
Before you can use sockets LAN, you must select the signal generator’s sockets port number to use:
• Standard mode. Available on port 5025. Use this port for simple programming.
• TELNET mode. The telnet SCPI service is available on port 5023.
NOTEFor backward compatibility, on the E8663B, ESG, and PSG, the signal generator also accepts
An example using sockets LAN is given in “LAN Programming Interface Examples” on page 101 of
this programming guide.
references to the Telnet SCPI service at port 7777 and sockets SCPI service at port 7778.
Ports 7777 and 7778 are disabled on the Agilent MXG.
Using Telnet LAN
Telnet provides a means of communicating with the signal generator over the LAN. The Telnet client,
run on a LAN connected computer, will create a login session on the signal generator. A connection,
established between computer and signal generator, generates a user interface display screen with
SCPI> prompts on the command line.
Using the Telnet protocol to send commands to the signal generator is similar to communicating with
the signal generator over GPIB. You establish a connection with the signal generator and then send
or receive information using SCPI commands. Communication is interactive: one command at a time.
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide39
Using IO Interfaces
Using LAN
NOTEThe Windows 2000 operating systems use a command prompt style interface for the Telnet
client. Refer to the Figure 2- 7 on page 42 for an example of this interface.
Windows XP operating systems and newer can use this section to better understand how to
use the signal generator with port settings. For more information, refer to the help software
of the IO libraries being used.
The following telnet LAN connections are discussed:
• “Using Telnet and MS-DOS Command Prompt” on page 40
• “Using Telnet On a PC With a Host/Port Setting Menu GUI” on page 41
• “Using Telnet On Windows 2000” on page 41
• “The Standard UNIX Telnet Command” on page 42
A Telnet example is provided in “Unix Telnet Example” on page 42.
Using Telnet and MS-DOS Command Prompt
1. On your PC, click Start > Programs > Command Prompt.
2. At the command prompt, type in telnet.
3. Press the Enter key. The Telnet display screen will be displayed.
4. Click on the Connect menu then select Remote System. A connection form (Figure 2-5) is displayed.
Figure 2-5 Connect Form (Agilent IO Library version J.01.0100)
5. Enter the hostname, port number, and Te r m Typ e then click Connect.
•Host Name−IP address or hostname
•Port−5023
•Term Type−vt100
6. At the SCPI> prompt, enter SCPI commands. Refer to Figure 2-6 on page 41.
7. To signal device clear, press Ctrl-C on your keyboard.
8. Select Exit from the Connect menu and type exit at the command prompt to end the Telnet
session.
40Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Using IO Interfaces
Using LAN
Using Telnet On a PC With a Host/Port Setting Menu GUI
1. On your PC, click Start > Run.
2. Type telnet then click the OK button. The Telnet connection screen will be displayed.
3. Click on the Connect menu then select Remote System. A connection form is displayed. See Figure
2- 5.
4. Enter the hostname, port number, and Te r m Typ e then click Connect.
•Host Name−signal generator’s IP address or hostname
•Port−5023
•Term Type−vt100
5. At the SCPI> prompt, enter SCPI commands. Refer to Figure 2-6 on page 41.
6. To signal device clear, press Ctrl-C.
7. Sel ect Exit from the Connect menu to end the Telnet session.
Figure 2-6 Telnet Window (Windows 2000)
Using Telnet On Windows 2000
1. On your PC, click Start > Run.
2. Type telnet in the run text box, then click the OK button. The Telnet connection screen will be
displayed. See Figure 2- 7 on page 42 (Windows 2000).
3. Type open at the prompt and then press the Enter key. The prompt will change to (to).
4. At the (to) prompt, enter the signal generator’s IP address followed by a space and 5023, which
is the Telnet port associated with the signal generator.
5. At the SCPI> prompt, enter SCPI commands. Refer to commands shown in Figure 2- 6 on
page 41.
6. To escape from the SCPI> session type Ctrl-].
7. T ype quit at the prompt to end the Telnet session.
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide41
Using IO Interfaces
Using LAN
Figure 2-7 Telnet 2000 Window
The Standard UNIX Telnet Command
Synopsis
telnet [host [port]]
Description
This command is used to communicate with another host using the Telnet protocol. When the
command telnet is invoked with host or port arguments, a connection is opened to the host, and
input is sent from the user to the host.
Options and Parameters
The command telnet operates in character-at- a- time or line- by-line mode. In line- by-line mode,
typed text is echoed to the screen. When the line is completed (by pressing the Enter key), the text
line is sent to host. In character- at- a- time mode, text is echoed to the screen and sent to host as it
is typed. At the UNIX prompt, type man telnet to view the options and parameters available with
the telnet command.
NOTEIf your Telnet connection is in line-by- line mode, there is no local echo. This means you
cannot see the characters you are typing until you press the Enter key. To remedy this,
change your Telnet connection to character- by- character mode. Escape out of Telnet, and at
the telnet> prompt, type mode char. If this does not work, consult your Telnet program's
documentation.
Unix Telnet Example
To connect to the instrument with host name myInstrument and port number 5023, enter the
following command on the command line: telnet myInstrument 5023.
42Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Using IO Interfaces
Using LAN
When you connect to the signal generator, the UNIX window will display a welcome message and a
SCPI command prompt. The instrument is now ready to accept your SCPI commands. As you type
SCPI commands, query results appear on the next line. When you are done, break the Telnet
connection using an escape character. For example, Ctrl-],where the control key and the ] are
pressed at the same time. The following example shows Telnet commands:
$ telnet myinstrument 5023
Trying....
Connected to signal generator
Escape character is ‘^]’.
Agilent Technologies, E44xx SN-US00000001
Firmware:
Hostname: your instrument
IP :xxx.xx.xxx.xxx
SCPI>
Using FTP
FTP allows users to transfer files between the signal generator and any computer connected to the
LAN. For example, you can use FTP to download instrument screen images to a computer. When
logged onto the signal generator with the FTP command, the signal generator’s file structure can be
accessed. Figure 2-8 shows the FTP interface and lists the directories in the signal generator’s user
level directory.
NOTEFile access is limited to the signal generator’s /user directory.
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide43
Using IO Interfaces
Using LAN
Figure 2-8 FTP Screen
The following steps outline a sample FTP session from the MS-DOS Command Prompt:
1. On the PC click Start > Programs > Command Prompt.
2. At the command prompt enter:
ftp < IP address > or < hostname >
3. At the user name prompt, press enter.
4. At the password prompt, press enter.
You are now in the signal generator’s user directory. Typing help at the command prompt will
show you the FTP commands that are available on your system.
5. Type quit or bye to end your FTP session.
6. Type exit to end the command prompt session.
44Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Using RS-232 (ESG, PSG, and E8663B Only)
Using IO Interfaces
Using RS-232 (ESG, PSG, and E8663B Only)
NOTEThe RS- 232 serial interface is available on the ESG signal generators.
The PSG and E8663B’s AUXILIARY INTERFACE connector is compatible with ANSI/EIA232
(RS- 232) serial connection but GPIB and LAN are recommended for making faster
measurements and when downloading files. Refer to the User’s Guide.
The RS- 232 serial interface can be used to communicate with the signal generator. The RS-232
connection was once standard on most PCs but has now been replaced by USB. RS-232 can be
connected to the signal generator’s rear- panel connector using the cable described in Table 2- 2 on
page 47. Many functions provided by GPIB, with the exception of indefinite blocks, parallel polling,
serial polling, GET, non-SCPI remote languages, SRQ, and remote mode are available using the
RS- 232 interface.
The serial port sends and receives data one bit at a time, therefore RS- 232 communication is slow.
The data transmitted and received is usually in ASCII format with SCPI commands being sent to the
signal generator and ASCII data returned.
The following sections contain information on selecting and connecting IO libraries and RS- 232
interface hardware on the signal generator to a computer’s RS- 232 connector.
• “Selecting IO Libraries for RS- 232” on page 45
• “Setting Up the RS- 232 Interface” on page 46
• “Verifying RS-232 Functionality” on page 48
Selecting IO Libraries for RS-232
The IO libraries can be downloaded from the National Instrument website, http://www.ni.com, or
Agilent’s website, http://www.agilent.com. The following is a discussion on these libraries.
CAUTIONBecause of the potential for portability problems, running Agilent SICL without the
VISA overlay is not recommended by Agilent Technologies.
HP Basic The HP Basic language has an extensive IO library that can be used to control the
VISA VISA is an IO library used to develop IO applications and instrument drivers that
NI- 488.2 NI- 488.2 IO libraries can be used to develop applications for the RS- 232 interface.
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide45
signal generator over the RS- 232 interface. This library has many low level
functions that can be used in BASIC applications to control the signal generator
over the RS- 232 interface.
comply with industry standards. It is recommended that the VISA library be used
for programming the signal generator. The NI-VISA and Agilent VISA libraries are
similar implementations of VISA and have the same commands, syntax, and
functions. The differences are in the lower level IO libraries used to communicate
over the RS- 232; NI- 488.2 and SICL respectively.
See National Instrument’s website for information on NI- 488.2.
Using IO Interfaces
For details on each key, use the key help (described in User’s Guide). For additional SCPI command information, refer to the SCPI
Command Reference.
SICL Agilent SICL can be used to develop applications for the RS- 232 interface. See
Agilent’s website for information on SICL.
Setting Up the RS-232 Interface
1. Setting the RS- 232 Interface Baud Rate (ESG/PSG/E8663B)
NOTEConfigure your computer to use baud rates 57600 or lower only. Select the signal generator’s
baud rate to match the baud rate of your computer or UNIX workstation or adjust the baud
rate settings on your computer to match the baud rate setting of the signal generator.
The default baud rate for VISA is 9600. This baud rate can be changed with the
“VI_ATTR_ASRL_BAUD” VISA attribute.
46Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Using RS-232 (ESG, PSG, and E8663B Only)
For details on each key, use the key help (described in User’s Guide). For additional SCPI command information, refer to the SCPI
Command Reference.
Toggle RS-232 Echo Off On until Off is
highlighted. Selecting On echo es or retu rn s
characters sent to the signal generator and
prints them to the display.
3. Connect an RS- 232 cable from the computer’s serial connector to the ESG signal generator’s
RS-232 connector or the PSG or E8663B’s AUXILIARY INTERFACE connector. Refer to Table 2- 2 for
RS- 232 cable information.
NOTEAny 9 pin (male) to 9 pin (female) straight- through cable that directly wires pins 2, 3, 5, 7,
and 8 may be used.
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide47
Using IO Interfaces
Using RS-232 (ESG, PSG, and E8663B Only)
Verifying RS-232 Functionality
You can use the HyperTerminal program available on your computer to verify the RS- 232 interface
functionality. To run the HyperTerminal program, connect the RS- 232 cable between the computer
and the signal generator and perform the following steps:
1. On the PC click Start > Programs > Accessories > Communications > HyperTerminal.
2. Select HyperTerminal.
3. Enter a name for the session in the text box and select an icon.
4. Select COM1 (COM2 can be used if COM1 is unavailable).
5. In the COM1 (or COM2, if selected) properties, set the following parameters:
• Bits per second: 9600 must match signal generator’s baud rate; for more information, refer to
“Setting Up the RS- 232 Interface” on page 46.
• Data bits: 8
• Parity: None
• Stop bits: 1
• Flow Control: None
NOTE Flow control, via the RTS line, is driven by the signal generator. For the purposes of this
verification, the controller (PC) can ignore this if flow control is set to None. However, to
control the signal generator programmatically or download files to the signal generator,
you must enable RTS- CTS (hardware) flow control on the controller. Note that only the
RTS line is currently used.
Software Flow Control using XON and XOFF is not supported. Only RTS- CTS hardware
flow is supported.
6. Go to the HyperTerminal window and select File > Properties.
7. Go t o Settings > Emulation and select VT100.
8. Leave the Backscroll buffer lines set to the default value.
9. Go to Settings > ASCII Setup.
10. Check the first two boxes and leave the other boxes as default values.
Once the connection is established, enter the SCPI command *IDN? followed by <Ctrl j> in the
HyperTerminal window. The <Ctrl j> is the new line character (on the keyboard press the Cntrl key
and the j key simultaneously).
The signal generator should return a string similar to the following, depending on model:
Agilent Technologies<instrument model name and number>, US40000001,C.02.00
48Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Using RS-232 (ESG, PSG, and E8663B Only)
Using IO Interfaces
Character Format Parameters
The signal generator uses the following character format parameters when communicating via RS- 232:
• Character Length: Eight data bits are used for each character, excluding start, stop, and parity
bits.
• Parity Enable: Parity is disabled (absent) for each character.
• Stop Bits: One stop bit is included with each character.
If You Have Problems
1. Verify that the baud rate, parity, and stop bits are the same for the computer and signal
generator.
2. Verify that the RS- 232 cable is identical to the cable specified in Table 2- 2.
3. Verify that the application is using the correct computer COM port and that the RS- 232 cable is
properly connected to that port.
4. Verify that the controller’s flow control is set to RTS- CTS.
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide49
Using IO Interfaces
RS-232 Programming Interface Examples
RS-232 Programming Interface Examples
NOTEThe portions of the programming examples discussed in this section are taken from the full
text of these programs that can be found in Chapter 3, “Programming Examples.”
• “Interface Check Using HP BASIC” on page 50
• “Interface Check Using VISA and C” on page 51
• “Queries Using HP Basic and RS- 232” on page 51
• “Queries for RS-232 Using VISA and C” on page 52
Before Using the Examples
Before using the examples: On the signal generator select the following settings:
• Baud Rate - 9600 must match computer’s baud rate
• RS- 232 Echo - Off
The following sections contain HP Basic and C lines of programming removed from the programming
interface examples in Chapter 3, Programming Examples,, these portions of programming demonstrate
the important features to consider when developing programming for use with the RS- 232 interface.
This portion of the example program “Interface Check Using HP BASIC” on page 50, causes the signal
generator to perform an instrument reset. The SCPI command *RST will place the signal generator
into a pre- defined state.
The serial interface address for the signal generator in this example is 9. The serial port used is
COM1 (Serial A on some computers). Refer to “Using RS-232 (ESG, PSG, and E8663B Only)” on
page 45 for more information.
The following program example is available on the signal generator’s Documentation CD- ROM as
rs232ex1.txt. For the full text of this program, refer to “Interface Check Using HP BASIC” on
page 131 or to the signal generator’s documentation CD-ROM.
170 CONTROL 9,0;1 ! Resets the RS-232 interface
180 CONTROL 9,3;9600 ! Sets the baud rate to match the sig gen
190 STATUS 9,4;Stat ! Reads the value of register 4
200 Num=BINAND(Stat,7) ! Gets the AND value
210 CONTROL 9,4;Num ! Sets parity to NONE
220 OUTPUT 9;"*RST" ! Outputs reset to the sig gen
50Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
RS-232 Programming Interface Examples
Using IO Interfaces
Interface Check Using VISA and C
This portion of the example program “Interface Check Using VISA and C” on page 51, uses VISA
library functions to communicate with the signal generator. The program verifies that the RS- 232
connections and interface are functional. In this example the COM2 port is used. The serial port is
referred to in the VISA library as ‘ASRL1’ or ‘ASRL2’ depending on the computer serial port you are
using.
The following program example is available on the signal generator Documentation CD- ROM as
rs232ex1.cpp. For the full text of this program, refer to “Interface Check Using VISA and C” on
page 132 or to the signal generator’s documentation CD-ROM.
int baud=9600;// Set baud rate to 9600
ViSession defaultRM, vi;// Declares a variable of type ViSession
// for instrument communication on COM 2 port
ViStatus viStatus = 0;
// Opens session to RS-232 device at serial port 2
This portion of the example program “Queries Using HP Basic and RS- 232” on page 51, example
program demonstrates signal generator query commands over RS- 232. Query commands are of the
type *IDN? and are identified by the question mark that follows the mnemonic.
Start HP Basic, type in the following commands, and then RUN the program:
The following program example is available on the signal generator Documentation CD- ROM as
rs232ex2.txt. For the full text of this program, refer to “Queries Using HP Basic and RS- 232” on
page 134 or to the signal generator’s documentation CD-ROM.
190 OUTPUT 9;"*IDN?" ! Querys the sig gen ID
200 ENTER 9;Str$ ! Reads the ID
210 WAIT 2 ! Waits 2 seconds
220 PRINT "ID =",Str$ ! Prints ID to the screen
230 OUTPUT 9;"POW:AMPL -5 dbm" ! Sets the the power level to -5 dbm
240 OUTPUT 9;"POW?" ! Querys the power level of the sig gen
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide51
Using IO Interfaces
RS-232 Programming Interface Examples
Queries for RS-232 Using VISA and C
This portion of the example program “Queries for RS- 232 Using VISA and C” on page 52, uses VISA
library functions to communicate with the signal generator. The program verifies that the RS- 232
connections and interface are functional.
The following program example is available on the signal generator Documentation CD- ROM as
rs232ex2.cpp. For the full text of this program, refer to “Queries for RS- 232 Using VISA and C” on
page 135 or to the signal generator’s documentation CD-ROM.
status = viOpenDefaultRM(&defaultRM);// Initializes the system
// Open communication with Serial Port 2
status = viOpen(defaultRM, "ASRL2::INSTR", VI_NULL, VI_NULL, &instr);
52Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Using IO Interfaces
Using USB (Agilent MXG)
Using USB (Agilent MXG)
CAUTIONUSB cables are not industrial graded and potentially allows data loss in noisy
environments.
USB cables do not have a latching mechanism and the cables can be pulled out of the
PC or instrument relatively easily.
The maximum length for USB cables is 30 m, including the use of inline repeaters.
NOTEThe USB interface is available only on the Agilent MXG signal generator.
The Agilent MXG’s USB 2.0 interface supports USBTMC or USBTMC- USB488 specifications.
For more information on connecting instruments to the USB, refer to the Agilent Connection
Expert in the Agilent IO Libraries Help.
USB 2.0 connectors can be used to communicate with the signal generator. The N5181A/82A is
equipped with a Mini- B 5 pin rear panel connector (device USB). Use a Type- A to Mini- USB 5 pin
cable to connect the signal generator to the computer (Refer to “Setting Up the USB Interface” on
page 55). Connect the Type-A front panel connector (host USB) can be used to connect a mouse, a
keyboard, or a USB 1.1/2.0 flash drive (USB media). (Refer to the User’s Guide.) ARB waveform
encryption of proprietary information is supported. Many functions provided by GPIB, including GET,
non- SCPI remote languages, and remote mode are available using the USB interface.
NOTEFor a list of compatible flash drives to use with the USB external interface. Refer to
http://www.agilent.com/find/mxg.
Do not use the Type A front panel USB to connect to a computer.
The following sections contain information on selecting and connecting I/O libraries and the USB
interface that are required to remotely program the signal generator via computer and combining
those choices with one of several possible USB interface protocols.
• “Selecting I/O Libraries for USB” on page 54
• “Setting Up the USB Interface” on page 55
• “Verifying USB Functionality” on page 56
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide53
Using IO Interfaces
Using USB (Agilent MXG)
Selecting I/O Libraries for USB
CAUTIONThe Agilent MXG’s USB interface requires Agilent IO Libraries Suite 14.1 or newer to
run properly. For more information on connecting instruments to the USB, refer to the
Agilent Connection Expert in the Agilent IO Libraries Help.
The I/O libraries can be downloaded from the National Instrument website, http://www.ni.com, or
Agilent’s website, http://www.agilent.com. The following is a discussion on these libraries.
NOTEI/O applications such as IVI- COM or VXIplug&play can be used in place of VISA.
VISA VISA is an I/O library used to develop I/O applications and instrument drivers
that comply with industry standards. It is recommended that the VISA library be
used for programming the signal generator. The NI- VISA and Agilent VISA
libraries are similar implementations of VISA and have the same commands,
syntax, and functions. The differences are in the lower level I/O libraries used to
communicate over the USB; NI- 488.2 and SICL respectively.
NI- 488.2 NI- 488.2 I/O libraries can be used to develop applications for the USB interface.
SICL Agilent SICL can be used to develop applications for the USB interface. See
See National Instrument’s website for information on NI- 488.2.
Agilent’s website for information on SICL.
CAUTIONBecause of the potential for portability problems, running Agilent SICL without the
VISA overlay is not recommended by Agilent Technologies.
54Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Using IO Interfaces
Using USB (Agilent MXG)
Setting Up the USB Interface
Rear Panel Interface (Mini–B 5 pin)
To use USB, connect the USB cable (Refer to Table 2- 3, “USB Interface Cable,” on page 55, for USB
cable information.) between the computer and the signal generator’s rear panel Mini- B 5- pin USB
connector.
Ta b l e 2 -3 U SB In te rf a ce C a b l e
QuantityDescriptionAgilent Part Number
1USB cable Mini- B 5 pin to Type- A82357- 61601
Front Panel USB (Type–A)
For details on using the front panel USB (Type- A) and the front panel USB Media operation, refer to
the User’s Guide.
Using the Internal Storage and USB Media (Non-volatile Memories)
For details on using the internal storage and the front panel USB Media operation, refer to the User’s
Guide.
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide55
Using IO Interfaces
Using USB (Agilent MXG)
Verifying USB Functionality
Mini-B 5 Pin Rear Panel Connector
NOTEFor information on verifying your Mini- B 5 pin USB (rear panel) functionality, refer to the
Agilent Connection Expert in the Agilent IO Libraries Help. The Agilent IO libraries are
included with your signal generator or Agilent GPIB interface board, or they can be
downloaded from the Agilent website: http://www.agilent.com.
Type-A Front Panel USB Connector
For details on using the front panel USB (Type- A) and the front panel USB Media operation, refer to
the User’s Guide.
56Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
3Programming Examples
• “Using the Programming Interface Examples” on page 58
• “GPIB Programming Interface Examples” on page 62
• “LAN Programming Interface Examples” on page 101
• “RS-232 Programming Interface Examples (ESG/PSG/E8663B Only)” on page 131
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide57
Programming Examples
Using the Programming Interface Examples
Using the Programming Interface Examples
The programming examples for remote control of the signal generator use the GPIB, LAN, and
RS- 232 interfaces and demonstrate instrument control using different IO libraries and programming
languages. Many of the example programs in this chapter are interactive; the user will be prompted
to perform certain actions or verify signal generator operation or functionality. Example programs are
written in the following languages:
HP BasicC#
C/C++Microsoft Visual Basic 6.0
JavaMATLAB
Perl
These example programs are also available on the signal generator Documentation CD- ROM, enabling
you to cut and paste the examples into a text editor.
NOTEThe example programs set the signal generator into remote mode; front panel keys, except
the Agilent MXG Local/Esc/Cancel or the ESG, PSG, and E8663B’s Local key, are disabled.
Press the Agilent MXG Local/Esc/Cancel or the ESG, PSG, and E8663B’s Local key to revert to
manual operation.
To have the signal generator’s front panel update with changes caused by remote operations, enable
the signal generator’s Update in Remote function.
NOTEThe Update in Remote function will slow test execution. For faster test execution, disable the
Update in Remote function. (For more information, refer to or “Configuring the Display for
Remote Command Setups (Agilent MXG)” on page 17.) or “Configuring the Display for
Remote Command Setups (ESG/PSG/E8663B)” on page 17.
Programming Examples Development Environment
The C/C++ examples were written using an IBM- compatible personal computer (PC), configured as
follows:
•Pentium® processor (Pentium is a registered trademark of Intel Corporation.)
• Windows NT 4.0 operating system or later
• C/C++ programming language with the Microsoft Visual C++ 6.0 IDE
• National Instruments PCI- GPIB interface card or Agilent GPIB interface card
• National Instruments VISA Library or Agilent VISA library
• COM1 or COM2 serial port available
•LAN interface card
The HP Basic examples were run on a UNIX 700 series workstation.
58Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Using the Programming Interface Examples
Programming Examples
Running C++ Programs
When using Microsoft Visual C++ 6.0 to run the example programs, include the following files in your
project.
When using the VISA library:
• add the visa32.lib file to the Resource Files
• add the visa.h file to the Header Files
When using the NI- 488.2 library:
• add the GPIB-32.OBJ file to the Resource Files
• add the windows.h file to the Header Files
• add the Deci- 32.h file to the Header Files
For information on the NI- 488.2 library and file requirements refer to the National Instrument
website. For information on the VISA library see the Agilent website or National Instrument’s
website.
NOTETo communicate with the signal generator over the LAN interface you must enable the
VXI- 11 SCPI service. For more information, refer to “Configuring the DHCP LAN (Agilent
MXG)” on page 33 and “Configuring the VXI-11 for LAN (ESG/PSG/E8663B)” on page 30.
C/C++ Examples
• “Interface Check for GPIB Using VISA and C” on page 68
• “Queries for RS-232 Using VISA and C” on page 135
• “Local Lockout Using NI-488.2 and C++” on page 71
• “Queries Using NI-488.2 and Visual C++” on page 73
• “Queries for GPIB Using VISA and C” on page 75
• “Generating a CW Signal Using VISA and C” on page 77
• “Generating an Externally Applied AC- Coupled FM Signal Using VISA and C” on page 79
• “Generating an Internal FM Signal Using VISA and C” on page 81
• “Generating a Step- Swept Signal Using VISA and C++” on page 83
• “Reading the Data Questionable Status Register Using VISA and C” on page 90
• “Reading the Service Request Interrupt (SRQ) Using VISA and C” on page 94
• “VXI- 11 Programming Using SICL and C++” on page 102
• “VXI- 11 Programming Using VISA and C++” on page 103
• “Sockets LAN Programming and C” on page 105
• “Interface Check Using VISA and C” on page 132
• “Queries for RS-232 Using VISA and C” on page 135
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide59
Programming Examples
Using the Programming Interface Examples
Running C# Examples
To run the example program State_Files.cs on page 326, you must have the .NET framework installed
on your computer. You must also have the Agilent IO Libraries installed on your computer. The .NET
framework can be downloaded from the Microsoft website. For more information on running C#
programs using .NET framework, see Chapter 6.
NOTETo communicate with the signal generator over the LAN interface you must enable the
VXI- 11 SCPI service. For more information, refer to “Configuring the VXI- 11 for LAN
(Agilent MXG)” on page 29 and “Configuring the VXI- 11 for LAN (ESG/PSG/E8663B)” on
page 30.
Running Basic Examples
The BASIC programming interface examples provided in this chapter use either HP Basic or Visual
Basic 6.0 languages.
Visual Basic 6.0 Programming Examples
To run the example programs written in Visual Basic 6.0 you must include references to the IO
Libraries. For more information on VISA and IO libraries, refer to the Agilent VISA User’s Manual,
available on Agilent’s website: http://www.agilent.com. In the Visual Basic IDE (Integrated
Development Environment) go to Project–References and place a check mark on the following
references:
• Agilent VISA COM Resource Manager 1.0
•VISA COM 1.0 Type Library
NOTEIf you want to use VISA functions such as viWrite, then you must add the visa32.bas module
The signal generator’s VXI- 11 SCPI service must be on before you can run the Download Visual Basic
6.0 programming example.
NOTETo communicate with the signal generator over the LAN interface you must enable the
60Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
to your Visual Basic project.
VXI- 11 SCPI service. For more information, refer to “Configuring the VXI- 11 for LAN
(Agilent MXG)” on page 29 and “Configuring the VXI- 11 for LAN (ESG/PSG/E8663B)” on
page 30.
Using the Programming Interface Examples
You can start a new Standard EXE project and add the required references. Once the required
references are included, you can copy the example programs into your project and add a command
button to Form1 that will call the program.
The example Visual Basic 6.0 programs are available on the signal generator Documentation CD- ROM,
enabling you to cut and paste the examples into your project.
Visual Basic Examples
The Visual Basic examples enable the use of waveform files and are located in Chapter 5.
• “Creating I/Q Data—Little Endian Order” on page 262
• “Downloading I/Q Data” on page 265
HP Basic Examples
• “Interface Check using HP Basic and GPIB” on page 66
• “Local Lockout Using HP Basic and GPIB” on page 69
• “Queries Using HP Basic and GPIB” on page 72
• “Queries Using HP Basic and RS- 232” on page 134
• “Using 8757D Pass-Thru Commands (PSG with Option 007 Only)” on page 98
Programming Examples
Running Java Examples
The Java program “Sockets LAN Programming Using Java” on page 128, connects to the signal
generator via sockets LAN. This program requires Java version 1.1 or later be installed on your PC.
For more information on sockets LAN programming with Java, refer to “Sockets LAN Programming
Using Java” on page 128.
Running MATLAB Examples
For information regarding programming examples and files required to create and play waveform
files, refer to Chapter 5.
NOTETo communicate with the signal generator over the LAN interface you must enable the
VXI- 11 SCPI service. For more information, refer to “Configuring the VXI- 11 for LAN
(Agilent MXG)” on page 29 and “Configuring the VXI- 11 for LAN (ESG/PSG/E8663B)” on
page 30.
Running Perl Examples
The Perl example “Sockets LAN Programming Using PERL” on page 130, uses PERL script to control
the signal generator over the sockets LAN interface.
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide61
Programming Examples
Using GPIB
Using GPIB
GPIB enables instruments to be connected together and controlled by a computer. GPIB and its
associated interface operations are defined in the ANSI/IEEE Standard 488.1- 1987 and ANSI/IEEE
Standard 488.2- 1992. See the IEEE website, http://www.ieee.org, for details on these standards.
The following sections contain information for installing a GPIB interface card or NI- GPIB interface
card for your PC or UNIX-based system.
• “Installing the GPIB Interface Card” on page 62
For more information on setting up a GPIB interface card or NI- GPIB interface card, refer to:
• “Set Up the GPIB Interface” on page 24
• “Verify GPIB Functionality” on page 25
NOTEYou can also connect GPIB instruments to a PC USB port using the Agilent 82357A
USB/GPIB Interface Converter, which eliminates the need for a GPIB card. For more
information, go to http://www.agilent.com/find/gpib.
Installing the GPIB Interface Card
Refer to “Installing the GPIB Interface” on page 22.
GPIB Programming Interface Examples
• “Interface Check using HP Basic and GPIB” on page 66
• “Interface Check Using NI- 488.2 and C++” on page 67
• “Interface Check for GPIB Using VISA and C” on page 68
• “Local Lockout Using HP Basic and GPIB” on page 69
• “Local Lockout Using NI-488.2 and C++” on page 71
• “Queries Using HP Basic and GPIB” on page 72
• “Queries Using NI-488.2 and Visual C++” on page 73
• “Queries for GPIB Using VISA and C” on page 75
• “Generating a CW Signal Using VISA and C” on page 77
• “Generating an Externally Applied AC- Coupled FM Signal Using VISA and C” on page 79
• “Generating an Internal FM Signal Using VISA and C” on page 81
• “Generating a Step- Swept Signal Using VISA and C++” on page 83
• “Generating a Swept Signal Using VISA and Visual C++” on page 84
• “Saving and Recalling States Using VISA and C” on page 88
• “Reading the Data Questionable Status Register Using VISA and C” on page 90
• “Reading the Service Request Interrupt (SRQ) Using VISA and C” on page 94
• “Using 8757D Pass-Thru Commands (PSG with Option 007 Only)” on page 98
Before Using the GPIB Examples
HP Basic addresses the signal generator at 719. The GPIB card is addressed at 7 and the signal
generator at 19. The GPIB address designator for other libraries is typically GPIB0 or GPIB1.
62Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
GPIB Programming Interface Examples
Programming Examples
GPIB Function Statements (Command Messages)
Function statements are the basis for GPIB programming and instrument control. These function
statements, combined with SCPI, provide management and data communication for the GPIB interface
and the signal generator.
This section describes functions used by different IO libraries. For more information, refer to the
NI- 488.2 Function Reference Manual for Windows, Agilent Standard Instrument Control Library
reference manual, and Microsoft Visual C++ 6.0 documentation.
Abort Function
The HP Basic function ABORT and the other listed IO library functions terminate listener/talker
activity on the GPIB and prepare the signal generator to receive a new command from the computer.
Typically, this is an initialization command used to place the GPIB in a known starting condition.
LibraryFunction StatementInitialization Command
HP BasicThe ABORT function stops all GPIB activity.10 ABORT 7
VISA LibraryIn VISA, the viTerminate command requests a VISA session
to terminate normal execution of an asynchronous operation.
The parameter list describes the session and job id.
NI- 488.2The NI-488.2 library function aborts any asynchronous read,
write, or command operation that is in progress. The
parameter ud is the interface or device descriptor.
SICLThe Agilent SICL function aborts any command currently
executing with the session id. This function is supported
with C/C++ on Windows 3.1 and Series 700 HP- UX.
viTerminate (parameter list)
ibstop(int ud)
iabort (id)
Remote Function
The HP Basic function REMOTE and the other listed IO library functions change the signal generator
from local operation to remote operation. In remote operation, the front panel keys are disabled
except for the Local key and the line power switch. Pressing the Local key restores manual operation.
LibraryFunction StatementInitialization Command
HP BasicThe REMOTE 719 function disables the front panel operation
of all keys with the exception of the Local key.
VISA LibraryThe VISA library, at this time, does not have a similar
command.
NI- 488.2The NI-488.2 library function asserts the Remote Enable
(REN) GPIB line. All devices listed in the parameter list are
put into a listen- active state although no indication is
generated by the signal generator. The parameter list
describes the interface or device descriptor.
10 REMOTE 719
N/A
EnableRemote (parameter
list)
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide63
SICLThe Agilent SICL function puts an instrument, identified by
the id parameter, into remote mode and disables the front
panel keys. Pressing the Local key on the signal generator
front panel restores manual operation. The parameter id is
the session identifier.
iremote (id)
Local Lockout Function
The HP Basic function LOCAL LOCKOUT and the other listed IO library functions disable the front
panel keys including the Local key. With the Local key disabled, only the controller (or a hard reset of
line power) can restore local control.
LibraryFunction StatementInitialization Command
HP BasicThe LOCAL LOCKOUT function disables all front-panel signal
generator keys. Return to local control can occur only by
cycling power on the instrument, when the LOCAL command
is sent or if the Preset key is pressed.
VISA LibraryThe VISA library, at this time, does not have a similar
command.
NI- 488.2The LOCAL LOCKOUT function disables all front-panel signal
generator keys. Return to local control can occur only by
cycling power on the instrument, when the LOCAL command
is sent or if the Preset key is pressed.
SICLThe Agilent SICL igpibllo prevents function prevents user
access to front panel keys operation. The function puts an
instrument, identified by the id parameter, into remote
mode with local lockout. The parameter id is the session
identifier and instrument address list.
10 LOCAL LOCKOUT 719
N/A
SetRWLS (parameter list)
igpibllo (id)
Local Function
The HP Basic function LOCAL and the other listed functions return the signal generator to local
control with a fully enabled front panel.
LibraryFunction StatementInitialization Command
HP BasicThe LOCAL 719 function returns the signal generator to
manual operation, allowing access to the signal generator’s
front panel keys.
VISA LibraryThe VISA library, at this time, does not have a similar
command.
64Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
10 LOCAL 719
N/A
GPIB Programming Interface Examples
LibraryFunction StatementInitialization Command
Programming Examples
NI- 488.2The NI-488.2 library function places the interface in local
mode and allows operation of the signal generator’s front
panel keys. The ud parameter in the parameter list is the
interface or device descriptor.
SICLThe Agilent SICL function puts the signal generator into
Local operation; enabling front panel key operation. The id
parameter identifies the session.
ibloc (int ud)
iloc(id)
Clear Function
The HP Basic function CLEAR and the other listed IO library functions clear the signal generator.
LibraryFunction StatementInitialization Command
HP BasicThe CLEAR 719 function halts all pending output-parameter
operations, resets the parser (interpreter of programming
codes) and prepares for a new programming code, stops any
sweep in progress, and turns off continuous sweep.
VISA LibraryThe VISA library uses the viClear function. This function
performs an IEEE 488.1 clear of the signal generator.
NI- 488.2The NI-488.2 library function sends the GPIB Selected
Device Clear (SDC) message to the device described by ud.
SICLThe Agilent SICL function clears a device or interface. The
function also discards data in both the read and write
formatted IO buffers. The id parameter identifies the
session.
10 CLEAR 719
viClear(ViSession vi)
ibclr(int ud)
iclear (id)
Output Function
The HP Basic IO function OUTPUT and the other listed IO library functions put the signal generator
into a listen mode and prepare it to receive ASCII data, typically SCPI commands.
LibraryFunction StatementInitialization Command
HP BasicThe function OUTPUT 719 puts the signal generator into
remote mode, makes it a listener, and prepares it to receive
data.
VISA LibraryThe VISA library uses the above function and associated
parameter list to output data. This function formats
according to the format string and sends data to the device.
The parameter list describes the session id and data to send.
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide65
NI- 488.2The NI-488.2 library function addresses the GPIB and writes
data to the signal generator. The parameter list includes the
instrument address, session id, and the data to send.
SICLThe Agilent SICL function converts data using the format
string. The format string specifies how the argument is
converted before it is output. The function sends the
characters in the format string directly to the instrument.
The parameter list includes the instrument address, data
buffer to write, and so forth.
ibwrt(parameter list)
iprintf (parameter
list)
Enter Function
The HP Basic function ENTER reads formatted data from the signal generator. Other IO libraries use
similar functions to read data from the signal generator.
LibraryFunction StatementInitialization Command
HP BasicThe function ENTER 719 puts the signal generator into
remote mode, makes it a talker, and assigns data or status
information to a designated variable.
VISA LibraryThe VISA library uses the viScanf function and an
associated parameter list to receive data. This function
receives data from the instrument, formats it using the
format string, and stores the data in the argument list. The
parameter list includes the session id and string argument.
NI- 488.2The NI-488.2 library function addresses the GPIB, reads
data bytes from the signal generator, and stores the data
into a specified buffer. The parameter list includes the
instrument address and session id.
10 ENTER 719;
viScanf (parameter list)
ibrd (parameter list)
SICLThe Agilent SICL function reads formatted data, converts it,
and stores the results into the argument list. The conversion
is done using conversion rules for the format string. The
parameter list includes the instrument address, formatted
data to read, and so forth.
iscanf (parameter list)
Interface Check using HP Basic and GPIB
This simple program causes the signal generator to perform an instrument reset. The SCPI command
*RST places the signal generator into a pre- defined state and the remote annunciator (R) appears on
the front panel display.
The following program example is available on the signal generator Documentation CD- ROM as
160 Sig_gen=719 ! Declares a variable to hold the signal generator's address
170 LOCAL Sig_gen ! Places the signal generator into Local mode
180 CLEAR Sig_gen ! Clears any pending data I/O and resets the parser
190 REMOTE 719 ! Puts the signal generator into remote mode
200 CLEAR SCREEN ! Clears the controllers display
210 REMOTE 719
220 OUTPUT Sig_gen;"*RST" ! Places the signal generator into a defined state
230 PRINT "The signal generator should now be in REMOTE."
240 PRINT
250 PRINT "Verify that the remote [R] annunciator is on. Press the `Local' key, "
260 PRINT "on the front panel to return the signal generator to local control."
270 PRINT
280 PRINT "Press RUN to start again."
290 END ! Program ends
Programming Examples
Interface Check Using NI-488.2 and C++
This example uses the NI- 488.2 library to verify that the GPIB connections and interface are
functional. Launch Microsoft Visual C++ 6.0, add the required files, and enter the following code into
your .cpp source file.
The following program example is available on the signal generator Documentation CD- ROM as
Addr4882_t Address[31]; // Declares an array of type Addr4882_t
int main(void)
{
int sig; // Declares a device descriptor variable
sig = ibdev(0, 19, 0, 13, 1, 0); // Aquires a device descriptor
ibclr(sig); // Sends device clear message to signal generator
ibwrt(sig, "*RST", 4); // Places the signal generator into a defined state
// Print data to the output window
cout << "The signal generator should now be in REMOTE. The remote indicator"<<endl;
cout <<"annunciator R should appear on the signal generator display"<<endl;
return 0;
}
Interface Check for GPIB Using VISA and C
This program uses VISA library functions and the C language to communicate with the signal
generator. The program verifies that the GPIB connections and interface are functional. Launch
Microsoft Visual C++ 6.0, add the required files, and enter the following code into your .cpp source
file. visaex1.cpp performs the following functions:
• verifies the GPIB connections and interface are functional
• switches the signal generator into remote operation mode
The following program example is available on the signal generator Documentation CD- ROM as
viPrintf(vi, "*RST\n"); // initializes signal generator
// prints to the output window
printf("The signal generator should now be in REMOTE. The remote indicator\n");
printf("annunciator R should appear on the signal generator display\n");
printf("\n");
viClose(vi); // closes session
viClose(defaultRM); // closes default session
}
Programming Examples
Local Lockout Using HP Basic and GPIB
This example demonstrates the Local Lockout function. Local Lockout disables the front panel signal
generator keys. basicex2.txt performs the following functions:
• resets instrument
• places signal generator into local
• places signal generator into remote
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide69
130 Sig_gen=719 ! Declares a variable to hold signal generator address
140 CLEAR Sig_gen ! Resets signal generator parser and clears any output
150 LOCAL Sig_gen ! Places the signal generator in local mode
160 REMOTE Sig_gen ! Places the signal generator in remote mode
170 CLEAR SCREEN ! Clears the controllers display
180 OUTPUT Sig_gen;"*RST" ! Places the signal generator in a defined state
190 ! The following print statements are user prompts
200 PRINT "The signal generator should now be in remote."
210 PRINT "Verify that the 'R' and 'L' annunciators are visable"
220 PRINT ".......... Press Continue"
230 PAUSE
240 LOCAL LOCKOUT 7 ! Puts the signal generator in LOCAL LOCKOUT mode
250 PRINT ! Prints user prompt messages
260 PRINT "Signal generator should now be in LOCAL LOCKOUT mode."
270 PRINT
280 PRINT "Verify that all keys including `Local' (except Contrast keys) have no effect."
290 PRINT
300 PRINT ".......... Press Continue"
310 PAUSE
320 PRINT
330 LOCAL 7 ! Returns signal generator to Local control
340 ! The following print statements are user prompts
350 PRINT "Signal generator should now be in Local mode."
360 PRINT
370 PRINT "Verify that the signal generator's front-panel keyboard is functional."
380 PRINT
390 PRINT "To re-start this program press RUN."
400 END
70Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
GPIB Programming Interface Examples
Programming Examples
Local Lockout Using NI-488.2 and C++
This example uses the NI- 488.2 library to set the signal generator local lockout mode. Launch
Microsoft Visual C++ 6.0, add the required files, and enter the following code into your .cpp source
file. niex2.cpp performs the following functions:
• all front panel keys, except the contrast key
• places the signal generator into remote
• prompts the user to verify the signal generator is in remote
• places the signal generator into local
The following program example is available on the signal generator Documentation CD- ROM as
SetRWLS(GPIB0, Address); // Places device in Remote with Lockout State.
cout<< "The signal generator should now be in LOCAL LOCKOUT. Verify that all
keys"<<endl;
cout<< "including the 'Local' key are disabled (Contrast keys are not
cout <<"Press Enter to continue"<<endl;
cin.ignore(10000,'\n');
ibloc(sig); // Returns signal generator to local control
cout<<endl;
cout <<"The signal generator should now be in local mode\n";
return 0;}
}
affected)"<<endl;
Queries Using HP Basic and GPIB
This example demonstrates signal generator query commands. The signal generator can be queried for
conditions and setup parameters. Query commands are identified by the question mark as in the
identify command *IDN? basicex3.txt performs the following functions:
• clears the signal generator
• queries the signal generator’s settings
The following program example is available on the signal generator Documentation CD- ROM as
120 DIM A$[10],C$[100],D$[10] ! Declares variables to hold string response data
130 INTEGER B ! Declares variable to hold integer response data
140 Sig_gen=719 ! Declares variable to hold signal generator address
150 LOCAL Sig_gen ! Puts signal generator in Local mode
160 CLEAR Sig_gen ! Resets parser and clears any pending output
170 CLEAR SCREEN ! Clears the controller’s display
180 OUTPUT Sig_gen;"*RST" ! Puts signal generator into a defined state
190 OUTPUT Sig_gen;"FREQ:CW?" ! Querys the signal generator CW frequency setting
200 ENTER Sig_gen;F ! Enter the CW frequency setting
210 ! Print frequency setting to the controller display
72Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
GPIB Programming Interface Examples
220 PRINT "Present source CW frequency is: ";F/1.E+6;"MHz"
230 PRINT
240 OUTPUT Sig_gen;"POW:AMPL?" ! Querys the signal generator power level
250 ENTER Sig_gen;W ! Enter the power level
260 ! Print power level to the controller display
270 PRINT "Current power setting is: ";W;"dBM"
280 PRINT
290 OUTPUT Sig_gen;"FREQ:MODE?" ! Querys the signal generator for frequency mode
300 ENTER Sig_gen;A$ ! Enter in the mode: CW, Fixed or List
310 ! Print frequency mode to the controller display
320 PRINT "Source's frequency mode is: ";A$
330 PRINT
340 OUTPUT Sig_gen;"OUTP OFF" ! Turns signal generator RF state off
350 OUTPUT Sig_gen;"OUTP?" ! Querys the operating state of the signal generator
360 ENTER Sig_gen;B ! Enter in the state (0 for off)
370 ! Print the on/off state of the signal generator to the controller display
380 IF B>0 THEN
390 PRINT "Signal Generator output is: on"
400 ELSE
410 PRINT "Signal Generator output is: off"
420 END IF
430 OUTPUT Sig_gen;"*IDN?" ! Querys for signal generator ID
440 ENTER Sig_gen;C$ ! Enter in the signal generator ID
450 ! Print the signal generator ID to the controller display
460 PRINT
470 PRINT "This signal generator is a ";C$
480 PRINT
490 ! The next command is a query for the signal generator's GPIB address
500 OUTPUT Sig_gen;"SYST:COMM:GPIB:ADDR?"
510 ENTER Sig_gen;D$ ! Enter in the signal generator's address
520 ! Print the signal generator's GPIB address to the controllers display
530 PRINT "The GPIB address is ";D$
540 PRINT
550 ! Print user prompts to the controller's display
560 PRINT "The signal generator is now under local control"
570 PRINT "or Press RUN to start again."
580 END
Programming Examples
Queries Using NI-488.2 and Visual C++
This example uses the NI- 488.2 library to query different instrument states and conditions. Launch
Microsoft Visual C++ 6.0, add the required files, and enter the following code into your .cpp source
file. niex3.cpp performs the following functions:
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide73
rdVal[ibcntl] = '\0'; // Null character indicates end of array
// Prints the signal generator address
cout<<"Source GPIB address is : "<<rdVal;
cout<<endl;
cout<<"Press the 'Local' key to return the signal generator to LOCAL control”<<endl; cout<<endl;
return 0;
}
Programming Examples
Queries for GPIB Using VISA and C
This example uses VISA library functions to query different instrument states and conditions. Launch
Microsoft Visual C++ 6.0, add the required files, and enter the following code into your .cpp source
file. visaex3.cpp performs the following functions:
• verifies the GPIB connections and interface are functional
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide75
viPrintf(vi, "*RST\n"); // Resets signal generator
viPrintf(vi, "FREQ:CW?\n"); // Querys the CW frequency
76Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
viScanf(vi, "%t", rdBuffer); // Reads response into rdBuffer
// Prints the source frequency
printf("Source CW frequency is : %s\n", rdBuffer);
printf("Press any key to continue\n");
printf("\n"); // Prints new line character to the display
getch();
viPrintf(vi, "POW:AMPL?\n"); // Querys the power level
viScanf(vi, "%t", rdBuffer); // Reads the response into rdBuffer
// Prints the source power level
printf("Source power (dBm) is : %s\n", rdBuffer);
printf("Press any key to continue\n");
printf("\n"); // Prints new line character to the display
getch();
viPrintf(vi, "FREQ:MODE?\n"); // Querys the frequency mode
viScanf(vi, "%t", rdBuffer); // Reads the response into rdBuffer
// Prints the source freq mode
printf("Source frequency mode is : %s\n", rdBuffer);
printf("Press any key to continue\n");
printf("\n"); // Prints new line character to the display
getch();
viPrintf(vi, "OUTP OFF\n"); // Turns source RF state off
viPrintf(vi, "OUTP?\n"); // Querys the signal generator's RF state
viScanf(vi, "%1i", &num); // Reads the response (integer value)
// Prints the on/off RF state
if (num > 0 ) {
printf("Source RF state is : on\n");
}else{
printf("Source RF state is : off\n");
}
// Close the sessions
viClose(vi);
viClose(defaultRM);
}
GPIB Programming Interface Examples
Programming Examples
Generating a CW Signal Using VISA and C
This example uses VISA library functions to control the signal generator. The signal generator is set
for a CW frequency of 500 kHz and a power level of −2.3 dBm. Launch
Microsoft Visual C++ 6.0, add the required files, and enter the code into your .cpp source file.
visaex4.cpp performs the following functions:
• verifies the GPIB connections and interface are functional
• resets the signal generator
• queries the instrument (CW frequency, power level, frequency mode, and RF state)
• reads responses into the rdBuffer (CW frequency, power level, and frequency mode)
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide77
viPrintf(vi, "*RST\n"); // Reset the signal generator
viPrintf(vi, "FREQ 500 kHz\n"); // Set the source CW frequency for 500 kHz
78Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
viPrintf(vi, "FREQ:CW?\n"); // Query the CW frequency
viScanf(vi, "%t", rdBuffer); // Read signal generator response
printf("Source CW frequency is : %s\n", rdBuffer); // Print the frequency
viPrintf(vi, "POW:AMPL -2.3 dBm\n"); // Set the power level to -2.3 dBm
viPrintf(vi, "POW:AMPL?\n"); // Query the power level
viScanf(vi, "%t", rdBuffer); // Read the response into rdBuffer
printf("Source power (dBm) is : %s\n", rdBuffer); // Print the power level
viPrintf(vi, "OUTP:STAT ON\n"); // Turn source RF state on
viPrintf(vi, "OUTP?\n"); // Query the signal generator's RF state
viScanf(vi, "%1i", &num); // Read the response (integer value)
// Print the on/off RF state
if (num > 0 ) {
printf("Source RF state is : on\n");
}else{
printf("Source RF state is : off\n");
}
printf("\n");
printf("Verify RF state then press continue\n");
printf("\n");
getch();
viClear(vi);
viPrintf(vi,"OUTP:STAT OFF\n"); // Turn source RF state off
viPrintf(vi, "OUTP?\n"); // Query the signal generator's RF state
viScanf(vi, "%1i", &num); // Read the response
// Print the on/off RF state
if (num > 0 ) {
printf("Source RF state is now: on\n");
}else{
printf("Source RF state is now: off\n");
}
// Close the sessions
printf("\n");
viClear(vi);
viClose(vi);
viClose(defaultRM);
}
GPIB Programming Interface Examples
Programming Examples
Generating an Externally Applied AC-Coupled FM Signal Using VISA and C
In this example, the VISA library is used to generate an ac- coupled FM signal at a carrier frequency
of 700 MHz, a power level of −2.5 dBm, and a deviation of 20 kHz. Before running the program:
• Connect the output of a modulating signal source to the signal generator’s EXT 2 input connector.
• Set the modulation signal source for the desired FM characteristics.
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide79
80Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
printf("Example program to set up the signal generator\n");
printf("for an AC-coupled FM signal\n");
printf("Press any key to continue\n");
printf("\n");
getch();
printf("\n");
viPrintf(vi, "*RST\n"); // Resets the signal generator
viPrintf(vi, "FM:SOUR EXT2\n"); // Sets EXT 2 source for FM
viPrintf(vi, "FM:EXT2:COUP AC\n"); // Sets FM path 2 coupling to AC
viPrintf(vi, "FM:DEV 20 kHz\n"); // Sets FM path 2 deviation to 20 kHz
viPrintf(vi, "FREQ 700 MHz\n"); // Sets carrier frequency to 700 MHz
viPrintf(vi, "POW:AMPL -2.5 dBm\n"); // Sets the power level to -2.5 dBm
viPrintf(vi, "FM:STAT ON\n"); // Turns on frequency modulation
viPrintf(vi, "OUTP:STAT ON\n"); // Turns on RF output
// Print user information
printf("Power level : -2.5 dBm\n");
printf("FM state : on\n");
printf("RF output : on\n");
printf("Carrier Frequency : 700 MHZ\n");
printf("Deviation : 20 kHZ\n");
printf("EXT2 and AC coupling are selected\n");
printf("\n"); // Prints a carrage return
// Close the sessions
viClose(vi);
viClose(defaultRM);
}
GPIB Programming Interface Examples
Programming Examples
Generating an Internal FM Signal Using VISA and C
In this example the VISA library is used to generate an internal FM signal at a carrier frequency of
900 MHz and a power level of −15 dBm. The FM rate will be 5 kHz and the peak deviation will be
100 kHz. Launch Microsoft Visual C++ 6.0, add the required files, and enter the following code into
your .cpp source file. visaex6.cpp performs the following functions:
•error checking
• resets the signal generator
• sets up the signal generator for FM path 2 and internal FM rate of 5 kHz
• sets up FM path 2 deviation to 100 kHz
• sets carrier frequency to 900 MHz
• sets the power level to - 15 dBm
• turns on frequency modulation and RF output
The following program example is available on the signal generator Documentation CD- ROM as
printf("Example program to set up the signal generator\n");
printf("for an AC-coupled FM signal\n");
printf("\n");
printf("Press any key to continue\n");
getch();
viClear(vi); // Clears the signal generator
viPrintf(vi, "*RST\n"); // Resets the signal generator
viPrintf(vi, "FM2:INT:FREQ 5 kHz\n"); // Sets FM path 2 to internal at a modulation rate of 5 kHz
viPrintf(vi, "FM2:DEV 100 kHz\n"); // Sets FM path 2 modulation deviation rate of 100 kHz
viPrintf(vi, "FREQ 900 MHz\n"); // Sets carrier frequency to 900 MHz
viPrintf(vi, "POW -15 dBm\n"); // Sets the power level to -15 dBm
viPrintf(vi, "FM2:STAT ON\n"); // Turns on frequency modulation
82Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
GPIB Programming Interface Examples
viPrintf(vi, "OUTP:STAT ON\n"); // Turns on RF output
printf("\n"); // Prints a carriage return
// Print user information
printf("Power level : -15 dBm\n");
printf("FM state : on\n");
printf("RF output : on\n");
printf("Carrier Frequency : 900 MHZ\n");
printf("Deviation : 100 kHZ\n");
printf("Internal modulation : 5 kHz\n");
printf("\n"); // Print a carrage return
// Close the sessions
viClose(vi);
viClose(defaultRM);
}
Programming Examples
Generating a Step-Swept Signal Using VISA and C++
In this example the VISA library is used to set the signal generator for a continuous step sweep on
a defined set of points from 500 MHz to 800 MHz. The number of steps is set for 10 and the dwell
time at each step is set to 500 ms. The signal generator will then be set to local mode which allows
the user to make adjustments from the front panel. Launch Microsoft Visual C++ 6.0, add the required
files, and enter the following code into your .cpp source file. visaex7.cpp performs the following
functions:
• clears and resets the signal generator
• sets up the instrument for continuous step sweep
• sets up the start and stop sweep frequencies
• sets up the number of steps
• sets the power level
• turns on the RF output
The following program example is available on the signal generator Documentation CD- ROM as
viPrintf(vi, "*RST\n"); // Resets the signal generator
viPrintf(vi, "*CLS\n"); // Clears the status byte register
viPrintf(vi, "FREQ:MODE LIST\n"); // Sets the sig gen freq mode to list
viPrintf(vi, "LIST:TYPE STEP\n"); // Sets sig gen LIST type to step
viPrintf(vi, "FREQ:STAR 500 MHz\n"); // Sets start frequency
viPrintf(vi, "FREQ:STOP 800 MHz\n"); // Sets stop frequency
viPrintf(vi, "SWE:POIN 10\n"); // Sets number of steps (30 mHz/step)
viPrintf(vi, "SWE:DWEL .5 S\n"); // Sets dwell time to 500 ms/step
viPrintf(vi, "POW:AMPL -5 dBm\n"); // Sets the power level for -5 dBm
viPrintf(vi, "OUTP:STAT ON\n"); // Turns RF output on
viPrintf(vi, "INIT:CONT ON\n"); // Begins the step sweep operation
// Print user information
printf("The signal generator is in step sweep mode. The frequency range is\n");
printf("500 to 800 mHz. There is a .5 sec dwell time at each 30 mHz step.\n");
printf("\n"); // Prints a carriage return/line feed
viPrintf(vi, "OUTP:STAT OFF\n"); // Turns the RF output off
printf("Press the front panel Local key to return the\n");
printf("signal generator to manual operation.\n");
// Closes the sessions
printf("\n");
viClose(vi);
viClose(defaultRM);
}
Generating a Swept Signal Using VISA and Visual C++
This example sets up the signal generator for a frequency sweep from 1 to 2 GHz with 101 points
84Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
GPIB Programming Interface Examples
Programming Examples
and a .01 second dwell period for each point. A loop is used to generator 5 sweep operations. The
signal generator triggers each sweep with the :INIT command. There is a wait introduced in the loop
to allow the signal generator to complete all operations such as set up and retrace before the next
sweep is generated. visaex11.cpp performs the following functions:
• sets up the signal generator for a 1 to 2 GHz frequency sweep
• sets up the signal generator to have a dwell time of .01 seconds and 101 points in the sweep
• sleep function is used to allow the instrument to complete its sweep operation
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide85
In this example, instrument settings are saved in the signal generator’s save register. These settings
can then be recalled separately; either from the keyboard or from the signal generator’s front panel.
Launch Microsoft Visual C++ 6.0, add the required files, and enter the following code into your .cpp
source file. visaex8.cpp performs the following functions:
•error checking
• clears the signal generator
• resets the status byte register
• resets the signal generator
• sets up the signal generator frequency, ALC off, power level, RF output on
• checks for operation complete
• saves to settings to instrument register number one
• recalls information from register number one
• prompts user input to put instrument into Local and checks for operation complete
The following program example is available on the signal generator Documentation CD- ROM as
viPrintf(vi, "*RCL 1\n"); // Recalls stored register #1 state
viPrintf(vi, "*OPC?\n"); // Checks for operation complete
while (!lngDone)
viScanf (vi ,"%d",&lngDone); // Waits for setup to complete
// Print user information
printf("The signal generator has been returned to it's Register #1 state\n");
printf("Press Enter to continue\n");
printf("\n"); // Prints new line character
getch(); // Waits for user input
lngDone=0; // Reset the operation complete flag
viPrintf(vi, "*RST\n"); // Resets the signal generator
viPrintf(vi, "*OPC?\n"); // Checks for operation complete
while (!lngDone)
viScanf (vi ,"%d",&lngDone); // Waits for setup to complete
// Print user information
printf("Press Local on instrument front panel to return to manual mode\n");
printf("\n"); // Prints new line character
// Close the sessions
viClose(vi);
viClose(defaultRM);
}
Reading the Data Questionable Status Register Using VISA and C
In this example, the signal generator’s data questionable status register is read. You will be asked to
set up the signal generator for error generating conditions. The data questionable status register will
be read and the program will notify the user of the error condition that the setup caused. Follow the
user prompts presented when the program runs. Launch Microsoft Visual C++ 6.0, add the required
files, and enter the following code into your .cpp source file. visaex9.cpp performs the following
functions:
•error checking
• clears the signal generator
• resets the signal generator
• the data questionable status register is enabled to read an unleveled condition
• prompts user to manually set up the signal generator for an unleveled condition
• queries the data questionable status register for any set bits and converts the string data to
numeric
• based on the numeric value, program checks for a corresponding status check value
• similarly checks for over or undermodulation condition
The following program example is available on the signal generator Documentation CD- ROM as