Keysight Technologies X Series Programming Manual

Text of the manual

X-Series Signal Generators

© Keysight Technologies, Inc.

2012-2019 No part of this manual may be reproduced in any form or by any means (including electronic storage and retrieval or translation into a foreign language) without prior agreement and written consent from Keysight Technologies, Inc. as governed by United States and international copyright laws. Trademark Acknowledgments Manual Part Number N5180-90074 Edition Edition 1, July 2019 Supersedes: February 2019 Printed in USA/Malaysia Published by: Keysight Technologies 1400 Fountaingrove Parkway Santa Rosa, CA 95403 Warranty THE MATERIAL CONTAINED IN THIS DOCUMENT IS PROVIDED “AS IS,” AND IS SUBJECT TO BEING CHANGED, WITHOUT NOTICE, IN FUTURE EDITIONS. FURTHER, TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, KEYSIGHT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED WITH REGARD TO THIS MANUAL AND ANY INFORMATION CONTAINED HEREIN, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. KEYSIGHT 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 INFORMATION CONTAINED HEREIN. SHOULD KEYSIGHT AND THE USER HAVE A SEPARATE WRITTEN AGREEMENT WITH WARRANTY TERMS COVERING THE MATERIAL IN THIS DOCUMENT THAT CONFLICT WITH THESE TERMS, THE WARRANTY TERMS IN THE SEPARATE AGREEMENT WILL CONTROL. Technology Licenses The hardware and/or software described in this document are furnished under a license and may be used or copied only in accordance with the terms of such license. U.S. Government Rights The Software is “commercial computer software,” as defined by Federal Acquisition Regulation (“FAR”) 2.101. Pursuant to FAR 12.212 and 27.405-3 and Department of Defense FAR Supplement (“DFARS”) 227.7202, the U.S. government acquires commercial computer software under the same terms by which the software is customarily provided to the public. Accordingly, Keysight provides the Software to U.S. government customers under its standard commercial license, which is embodied in its End User License Agreement (EULA), a copy of which can be found at http://www.keysight.com/find/sweula The license set forth in the EULA represents the exclusive authority by which the U.S. government may use, modify, distribute, or disclose the Software. The EULA and the license set forth therein, does not require or permit, among other things, that Keysight: (1) Furnish technical information related to commercial computer software or commercial computer software documentation that is not customarily provided to the public; or (2) Relinquish to, or otherwise provide, the government rights in excess of these rights customarily provided to the public to use, modify, reproduce, release, perform, display, or disclose commercial computer software or commercial computer software documentation. No additional government requirements beyond those set forth in the EULA shall apply, except to the extent that those terms, rights, or licenses are explicitly required from all providers of commercial computer software pursuant to the FAR and the DFARS and are set forth specifically in writing elsewhere in the EULA. Keysight shall be under no obligation to update, revise or otherwise modify the Software. With respect to any technical data as defined by FAR 2.101, pursuant to FAR 12.211 and 27.404.2 and DFARS 227.7102, the U.S. government acquires no greater than Limited Rights as defined in FAR 27.401 or DFAR 227.7103-5 (c), as applicable in any technical data. Safety Notices A CAUTION notice denotes a hazard. It calls attention to an operating procedure, practice, or the like that, if not correctly performed or adhered to, could result in damage to the product or loss of important data. Do not proceed beyond a CAUTION notice until the indicated conditions are fully understood and met. A WARNING notice denotes a hazard. It calls attention to an operating procedure, practice, or the like that, if not correctly performed or adhered to, could result in personal injury or death. Do not proceed beyond a WARNING notice until the indicated conditions are fully understood and met.

Where to Find the Latest Information

Documentation is updated periodically. For the latest information about these products, including instrument software upgrades, application information, and product information, browse to one of the following URLs, according to the name of your product: http://www.keysight.com/find/mxg To receive the latest updates by email, subscribe to Keysight Email Updates at the following URL: http://www.keysight.com/find/MyKeysight Information on preventing instrument damage can be found at: www.keysight.com/find/PreventingInstrumentRepair Is your product software up-to-date? Periodically, Keysight releases software updates to fix known defects and incorporate product enhancements. To search for software updates for your product, go to the Keysight Technical Support website at: http://www.keysight.com/find/techsupport

Table of Contents

1. Getting Started with Remote Operation Programming and Software/Hardware Layers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14 Interfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-15 IO Libraries and Programming Languages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16 Keysight IO Libraries Suite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16 Windows XP, 2000 Professional and Vista Business Keysight IO Libraries 15.0 (and Newer). . . . . . . . . . . . 1-17 Windows NT and Keysight IO Libraries M (and Earlier) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-19 Selecting IO Libraries for GPIB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-21 Selecting IO Libraries for LAN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-21 Programming Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-22 Using the Web Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-23 Modifying the Signal Generator Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-24 Enabling the Signal Generator Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-26 LAN Configuration System Defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-28 Displaying the LAN Configuration Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-29 Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-30 Configuring the Display for Remote Command Setups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-30 Getting Key Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-30 Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-31 Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-32 Error Message File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-32 Error Message Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-33 2. Using IO Interfaces Using GPIB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-36 Installing the GPIB Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-36 Set Up the GPIB Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-38 Verify GPIB Functionality. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-38 GPIB Interface Terms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-39 GPIB Programming Interface Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-40 Before Using the GPIB Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-40 Interface Check using HP Basic and GPIB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-40 Interface Check Using NI–488.2 and C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-41 Using LAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-42 Setting Up the LAN Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-43 Setting up Private LAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-45 Verifying LAN Functionality. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-46 Using VXI–11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-50 Using Sockets LAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-51 Using Telnet LAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-52 Using FTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-56 Using USB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-58 Selecting I/O Libraries for USB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-59 Setting Up the USB Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-59

Using the Programming Interface Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-62

Programming Examples Development Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-62 Running C++ Programs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-63 Running C# Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-64 Running Basic Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-64 Running Java Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-65 Running MATLAB Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-66 Running Perl Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-66 Using GPIB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-67 Installing the GPIB Interface Card . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-67 GPIB Programming Interface Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-68 Before Using the GPIB Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-68 GPIB Function Statements (Command Messages) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-68 Interface Check using HP Basic and GPIB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-72 Interface Check Using NI-488.2 and C++. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-73 Interface Check for GPIB Using VISA and C. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-75 Local Lockout Using HP Basic and GPIB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-76 Local Lockout Using NI-488.2 and C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-78 Queries Using HP Basic and GPIB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-80 Queries Using NI-488.2 and Visual C++. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-82 Queries for GPIB Using VISA and C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-85 Generating a CW Signal Using VISA and C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-88 Generating an Externally Applied AC-Coupled FM Signal Using VISA and C. . . . . . . . . . . . . . . . . . . . . . . . 3-91 Generating an Internal FM Signal Using VISA and C. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-93 Generating a Step-Swept Signal Using VISA and C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-96 Generating a Swept Signal Using VISA and Visual C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-98 Saving and Recalling States Using VISA and C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-101 Reading the Data Questionable Status Register Using VISA and C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-104 Reading the Service Request Interrupt (SRQ) Using VISA and C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-110 LAN Programming Interface Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-115 VXI-11 Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-115 VXI-11 Programming Using SICL and C++. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-116 VXI-11 Programming Using VISA and C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-118 Sockets LAN Programming and C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-120 Queries for Lan Using Sockets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-124 Sockets LAN Programming Using Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-150 Sockets LAN Programming Using Perl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-153 TCP-IP (LAN) Programming Using Matlab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-154 4. Programming the Status Register System Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-168 Overall Status Byte Register Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-170 Status Register Bit Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-172 Example: Enable a Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-172 Example: Query a Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-172 Accessing Status Register Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-173

Determining What to Monitor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-173

Deciding How to Monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-173 Status Register SCPI Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-176 Status Byte Group. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-179 Status Byte Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-180 Service Request Enable Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-180 Status Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-181 Standard Event Status Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-182 Standard Operation Status Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-184 Data Questionable Status Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-187 Data Questionable Power Status Group. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-190 Data Questionable Frequency Status Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-193 Data Questionable Calibration Status Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-196 Data Questionable BERT Status Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-199 5. Creating and Downloading Waveform Files Overview of Downloading and Extracting Waveform Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-204 Waveform Data Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-205 Understanding Waveform Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-206 Bits and Bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-206 LSB and MSB (Bit Order). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-207 Little Endian and Big Endian (Byte Order) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-207 Byte Swapping. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-208 DAC Input Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-209 2’s Complement Data Format. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-211 I and Q Interleaving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-212 Waveform Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-214 File Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-214 Marker File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-214 I/Q File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-216 Waveform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-216 Waveform Phase Continuity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-217 Phase Discontinuity, Distortion, and Spectral Regrowth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-217 Avoiding Phase Discontinuities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-218 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-220 Memory Allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-222 Memory Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-224 Commands for Downloading and Extracting Waveform Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-225 Waveform Data Encryption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-225 File Transfer Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-226 SCPI Command Line Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-227 Commands and File Paths for Downloading and Extracting Waveform Data . . . . . . . . . . . . . . . . . . . . . . . 5-227 FTP Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-231 Creating Waveform Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-235 Code Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-235 Downloading Waveform Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-241 Using Simulation Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-241

Using Advanced Programming Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-243

Loading, Playing, and Verifying a Downloaded Waveform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-247 Loading a File from Non–Volatile Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-247 Playing the Waveform. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-247 Verifying the Waveform. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-248 Building and Playing Waveform Sequences. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-248 Using the Download Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-250 Downloading E443xB Signal Generator Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-251 E443xB Data Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-252 SCPI Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-252 Programming Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-253 C++ Programming Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-254 MATLAB Programming Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-284 Visual Basic Programming Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-301 HP Basic Programming Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-308 Troubleshooting Waveform Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-317 Configuring the Pulse/RF Blank . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-318 6. Creating and Downloading User–Data Files Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-320 Signal Generator Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-321 Memory Allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-323 Memory Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-324 Checking Available Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-325 User File Data (Bit/Binary) Downloads. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-327 User File Bit Order (LSB and MSB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-328 Bit File Type Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-328 Binary File Type Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-331 User File Size. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-332 Determining Memory Usage for Custom User File Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-333 Downloading User Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-334 Commands for Bit File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-338 Commands for Binary File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-339 Selecting a Downloaded User File as the Data Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-341 Modulating and Activating the Carrier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-341 Modifying User File Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-341 Real–Time Custom High Data Rates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-344 Pattern RAM (PRAM) Data Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-346 Understanding PRAM Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-346 PRAM File Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-349 SCPI Command for a List Format Download . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-351 SCPI Command for a Block Data Download . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-351 Selecting a Downloaded PRAM File as the Data Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-354 Modulating and Activating the Carrier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-356 Storing a PRAM File to Non–Volatile Memory and Restoring to Volatile Memory . . . . . . . . . . . . . . . . . . . 6-356 Extracting a PRAM File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-356 Modifying PRAM Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-358

FIR Filter Coefficient Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-360

Data Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-360 Data Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-360 Downloading FIR Filter Coefficient Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-361 Selecting a Downloaded User FIR Filter as the Active Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-362 Using the Equalization Filter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-364 Save and Recall Instrument State Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-365 Save and Recall SCPI Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-365 Save and Recall Programming Example Using VISA and C# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-366 User Flatness Correction Downloads Using C++ and VISA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-379 Data Transfer Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-384 User File Download Problems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-384 PRAM Download Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-385 User FIR Filter Coefficient File Download Problems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-387

Getting Started Guide

— Safety Information — Receiving the Instrument — Environmental & Electrical Requirements — Basic Setup — Accessories — Operation Verification — Regulatory Information User’s Guide — Signal Generator Overview — Preferences & Enabling Options — Basic Operation — Optimize Performance — Avionics VOR/ILS (Option N5180302B) — Analog Modulation (Option UNT) — Pulse Modulation (Options UNW or N5180320B) — Basic Digital Operation—No BBG Option — Basic Digital Operation (Options 653/655/656/657) — Digital Signal Interface Module (Option 003 /004) — Baseband Operating Mode—Primary, BERT, or N5102A — BERT (Option N5180UN7B) — Real–Time Noise—AWGN (Option N5180403B) — Real–Time Phase Noise Impairments (Option N5180432B) — Real-Time Fading (Option 660) — Custom Digital Modulation (Option N5180431B) — Multitone and Two-Tone Waveforms (Option N5180430B) — Troubleshooting — Working in a Secure Environment Programming Guide — Getting Started with Remote Operation — Using IO Interfaces — Programming Examples — Programming the Status Register System — Creating and Downloading Files — Creating and Downloading User–Data Files SCPI Reference — SCPI Basics — Basic Function Commands — System Commands — Analog Modulation Commands — Arb Commands — Avionics VOR/ILS Commands — Bit Error Rate Test (BERT) Commands — Digital Signal Interface Module Commands — Real-Time Commands

Provides a listing of SCPI commands and programming codes for

signal generator models that are supported by the Keysight EXG and MXG X- Series signal generators. Service Guide — Troubleshooting — Replaceable Parts — Assembly Replacement — Post–Repair Procedures — Safety and Regulatory Information — Instrument History Error Messages Guide — Error Messages — Error Message Format — Error Message Type — List of Error Messages Key Helpa — Key function description — Related SCPI commands a. Press the Help key, and then the key for which you wish help.

X-Series Signal Generators

Programming Guide 1 Getting Started with Remote Operation — Programming and Software/Hardware Layers on page 14 — Interfaces on page 15 — IO Libraries and Programming Languages on page 16 — Using the Web Browser on page 23 — Preferences on page 30 — Error Messages on page 32 Keysight does not recommend going backwards in firmware versions (loading older firmware versions into newer instruments) as hardware/firmware conflicts can result.

14 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Getting Started with Remote Operation Programming and Software/Hardware Layers Programming and Software/Hardware Layers Keysight X-Series signal generators support the following interfaces: 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. Figure 1-1 Software/Hardware Layers Table 1-1 Instrument Interfaces Supported Keysight N51xxB EXG/MXG GPIB, LAN, and USB 2.0

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 15

Getting Started with Remote Operation Interfaces Interfaces Table 1-2 GPIB GPIB is used extensively when a dedicated computer is available for remote control of 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 36. LAN Data 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 following protocols can be used to communicate with the signal generator over the LAN: — VXI-11 (recommended) — Sockets — TELNET — FTP The Keysight N51xxB EXG/MXG supports LXI Class C functionality. 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 42. USB — The rear panel Type-B or 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; however, longer latency makes small USB transfers slower and less efficient than GPIB. For additional information, refer to the Keysight SICL or VISA User’s Guide.) For more information on connecting the signal generator to the USB, refer to the “Keysight IO Libraries Suite” on page 16 and the Keysight Connection Expert in the Keysight IO Libraries Help. For more information on configuring the signal generator to communicate over the USB, refer to “Using USB” on page 58.

16 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

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 Keysight IO libraries are included on an Automation-Ready CD with your signal generator and Keysight GPIB interface board, or they can be downloaded from the Keysight website: http://www.keysight.com. Keysight IO Libraries Suite The Keysight IO Libraries Suite replaces earlier versions of the Keysight IO Libraries. Keysight IO Libraries Suite does not support Windows NT. If you are using the Windows NT platform, you must use Keysight IO Libraries version M or earlier. Once the libraries are loaded, you can use the Keysight 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. Refer to the Keysight IO Libraries Suite Help documentation for details about this software. To learn about using IO libraries with Windows XP or newer operating systems, refer to the Keysight 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 Keysight GPIB interface board’s CD, or downloaded from the Keysight website: http://www.keysight.com. To better understand setting up Windows XP operating systems and newer, using PC LAN port settings, refer to Chapter 2. The USB interface requires Keysight IO Libraries Suite 14.1 or newer. For more information on connecting instruments using USB, refer to the Keysight Connection Expert in the Keysight IO Libraries Help. The signal generator ships with an Automation-Ready CD that contains the Keysight IO Libraries Suite 14.0 for users who use Windows 98 and Windows ME. These older systems are no longer supported in Keysight IO Libraries Suite version 14.1 and higher. Before setting the LAN interface, the signal generator must be configured for VXI-11 SCPI. Refer to “Configuring the VXI–11 Service” on page 43.

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 17

Getting Started with Remote Operation IO Libraries and Programming Languages Windows XP, 2000 Professional and Vista Business Keysight IO Libraries 15.0 (and Newer) 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. Refer to the VISA Assistant Help menu and the Keysight VISA User’s Manual (available on Keysight’s website) for more information. VISA Configuration (Automatic) 1. Run the VISA Assistant program: Start > All Programs > Keysight IO Libraries Suite > Keysight Connection Expert > Tools > Visa Assistant >. 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. Windows NT is not supported on Keysight IO Libraries 14.0 and newer. For additional information on older versions of Keysight IO libraries, refer to the Keysight Connection Expert in the Keysight IO Libraries Help. The Keysight IO libraries are included with your signal generator or Keysight GPIB interface board, or they can be downloaded from the Keysight website: http://www.keysight.com.

18 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Getting Started with Remote Operation IO Libraries and Programming Languages Using VISA Configuration (Manual) Use the Keysight IO Libraries Suite 15.0 to perform the following steps to use the Connection Expert and VISA to manually configure an interface. 1. Run the Keysight Connection Expert program: Start > All Programs > Keysight IO Libraries Suite > Keysight Connection Expert >. 2. On the tool bar select the Add Interface button. 3. Click LAN Interface in the Available interface types text box. 4. Click the ADD button. 5. Verify that the Auto (automatically detect protocol) bubble is checked. Click O.K. to use the default settings. 6. Click LAN(TCPIPO) in the Instrument I/O on this PC text box. 7. On the tool bar select the Add Instrument button. 8. Click the Add Address button in the Add LAN Instruments window. 9. Enter the hostname of the instrument or select the Use IP Address check box and enter the IP address. 10.Click OK.

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 19

Getting Started with Remote Operation IO Libraries and Programming Languages Windows NT and Keysight IO Libraries M (and Earlier) Using IO Config for Computer-to-Instrument Communication with VISA (Automatic or Manually) After installing the Keysight 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. 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, available with the Keysight 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 Keysight VISA User’s Manual (available on Keysight’s website) for more information. Windows NT is not supported on Keysight IO Libraries 14.0 and newer. The following sections are specific to Keysight IO Libraries versions M and earlier and apply only to the Windows NT platform. For additional information on older versions of Keysight IO libraries, refer to the Keysight Connection Expert in the Keysight IO Libraries Help. The Keysight IO libraries are included with your signal generator or Keysight GPIB interface board, or they can be downloaded from the Keysight website: http://www.keysight.com. You can also connect GPIB instruments using the Keysight 82357A USB/GPIB Interface Converter, which eliminates the need for a GPIB card. For more information, go to http://www.keysight.com/find/gpib.

20 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Getting Started with Remote Operation IO Libraries and Programming Languages 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. Click 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.

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 21

Getting Started with Remote Operation IO Libraries and Programming Languages 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 Keysight website. See also, “IO Libraries and Programming Languages” on page 16 for information on IO libraries. The following is a discussion on these libraries. 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 Keysight 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 Keysight VISA library with the Keysight GPIB interface card or NI-VISA with the NI PCI-GPIB interface card. SICL Keysight 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 Keysight SICL (Keysight 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 Keysight 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 Keysight website. The following is a discussion on these libraries. Because of the potential for portability problems, running Keysight SICL without the VISA overlay is not recommended by Keysight Technologies. . NI-VISA is a registered trademark of National Instruments Corporation.

22 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Getting Started with Remote Operation IO Libraries and Programming Languages Keysight VISA VISA is an IO library used to develop IO applications and instrument drivers that comply with industry standards. Use the Keysight VISA library for programming the signal generator over the LAN interface. SICL Keysight SICL is a lower level library that is installed along with Keysight VISA. 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® (MATLAB is a registered trademark of The MathWorks.) — HP Basic — LabView — Java™ (Java is a U.S. trademark of Sun Microsystems, Inc.) — Visual Basic® (Visual Basic is a registered trademark of Microsoft Corporation.) — PERL — Keysight VEE For examples, using some of these languages, refer to Chapter 3.

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 23

Getting Started with Remote Operation 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 or the hostname as the URL in your browser. Refer to Figure 1-2, “The Signal Generator Web Service” on page 24. The signal generator web page, shown at right and page 27, 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 Keysight’s products, support, manuals, and website. For additional information on memory catalog access (file storing), and FTP, refer to the User’s Guide and “” on page 220 and for FTP, see “Using FTP” on page 56 and “FTP Procedures” on page 231. The Web Server service is compatible with the Microsoft Internet Explorer (6.0 and 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 26. The following example for accessing the Web-Enabled X-Series web page uses the newly shipped instrument’s predetermined default hostname (a--). The procedure that follows assumes the signal generator is running firmware A.01.20 or later. Web-Enabled SCPI command capability is not available for versions of Internet Explorer ≥7.0. (The SCPI Telnet softkey is inactive for these versions.) To use the Telnet SCPI, refer to the figure on page 24. For more information on LAN Connectivity, refer to the Keysight Connectivity Guide (E2094-90009) or to the LAN Connectivity FAQs for details on using the instrument over LAN.

24 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Getting Started with Remote Operation Using the Web Browser Figure 1-2 The Signal Generator Web Service Modifying the Signal Generator Configuration 1. From the welcome page of the Web-Enabled interface, click View & Modify Configuration to show the instrument’s currently assigned IP address and other parameters. Use Help with this Page for assistance with the Web-Enabled interface. The Keysight N51xxB EXG/MXG supports LXI Class C functionality. For more information on the LXI standards, refer to http://www.lxistandard.org/home. To operate the signal generator, click the keys. NOTE: If you 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. Remote SCPI commands requires the Telnet feature on the computer. The Telnet feature is available from a variety of sources. Some software updates can block (break) this Telnet connection (e.g. Internet Explorer 7). When using Internet Explorer as a browser, only versions

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 25

Getting Started with Remote Operation Using the Web Browser 2. Enter the new settings and click Save. 3. Click Renew LAN Settings to cause the new settings to take effect. Figure 1-3 View & Modify Configuration

26 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Getting Started with Remote Operation Using the Web Browser Enabling the Signal Generator Web Server 1. Turn on the Web server as shown below. Keysight X-Series Web Server On 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 42). 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 LXI password box is displayed on the computer. Refer to the Web-Enabled Help. 6. Click Submit. 7. The front panel web page displays. Javascript or Active Scripts must be enabled to use the web front panel controls. If necessary, toggle Web Server to On. For details on each key and for equivalent SCPI commands, use the key help. Refer to “Getting Key Help” on page 30 and the User’s Guide. For additional SCPI command information, refer to the SCPI Command Reference.

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 27

Getting Started with Remote Operation Using the Web Browser To control the signal generator, either click the front panel keys or enter SCPI commands. FTP enables the transfer of files between the instrument and a computer. The FTP access button provides drag-and-drop file capability. 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. The FTP access button opens a window that displays the signal generator’s memory catalog files. Use the FTP window to drag and drop files from the FTP page to your computer.

28 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Getting Started with Remote Operation Using the Web Browser LAN Configuration System Defaults 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 on page 28. Refer to “Displaying the LAN Configuration Summary” on page 29. 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 > More 2 of 2 > Restore LAN Settings to Default Values > Confirm Restore LAN Settings to Default Values For more information, refer to the signal generator’s Web Server Interface Help. The 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” on page 26 and to “Displaying the LAN Configuration Summary” on page 29. There are no SCPI commands associated with this LXI password factory reset. Table 1-3 LAN Configuration Summary Values Parameter Default Signal Generator LAN Configuration Summary Hostname: Keysight–– Config Type: AUTO IP Address: 127.0.0.1 Connection Monitoring: On Subnet: 255.255.255.0 DNS Server Override: Off Gateway: 0.0.0.0 Dynamic DNS Naming: On RFC NETBIOS Naming: On DNS Server: 0.0.0.0 TCP Keep Alive: On

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 29

Getting Started with Remote Operation Using the Web Browser Displaying the LAN Configuration Summary Domain Name:a TCP Keep Alive Timeout: 1800.0 sec Signal Generator Web Server Interface Description: Keysight () SICL Interface Nameb: gpib0 Web Password: agilent a. The Domain Name defaults to a null field. b. This information is part of the “Advanced Information about this Web-Enabled ” Table 1-3 LAN Configuration Summary Values Parameter Default For details on each key and for equivalent SCPI commands (if applicable), 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 Table 1-3 on page 28. Utility > IO Config SCPI command: Not applicable

30 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Getting Started with Remote Operation Preferences Preferences The following commonly-used manual command sections are included here: “Configuring the Display for Remote Command Setups” on page 30 “Getting Key Help” on page 30 Configuring the Display for Remote Command Setups Getting Key Help For details on each key and for equivalent SCPI commands (if applicable), use the key help (described below and in the 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 and for equivalent SCPI commands (if applicable), use the key help (described in User’s Guide). When you press the front-panel Help button: Help displays for the next key you press. The “key help” includes a description of the key’s functionality and a list of equivalent SCPI commands (if they exist). This feature is especially useful if you are building a SCPI program based on front-panel key presses. 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.

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 31

Getting Started with Remote Operation Troubleshooting Troubleshooting In each section of this document, there is information that is related to troubleshooting that topic, if applicable. Refer to those corresponding sections in this document as well as to the User’s Guide, before using the diagnostics mode referred to in the Service Guide and in the caution below. All X-Series signal generators have a fail-safe and diagnostic mode that should only be used if all other troubleshooting mentioned in this document has been attempted and failed. If the diagnostic mode is determined to be needed, refer to the Service Guide. If the LAN Reset hardkey has been pressed and then the power is cycled on the instrument, the web-server will be enabled after reboot.

32 Keysight CXG, EXG, and MXG X-Series 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. When accessing error messages using the SCPI (remote interface) error queue, the error numbers and the portions of the error query response are displayed on the host terminal. 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. For additional general information on troubleshooting problems with your connections, refer to the Help in the Keysight IO Libraries and documentation. Characteristic SCPI Remote Interface Error Queue Capacity (#errors) 30 Overflow Handling Linear, first-in/first-out. Replaces newest error with: -350, Queue overflow Viewing Entriesa Use SCPI query SYSTem:ERRor[:NEXT]? Clearing the Queueb Power up Send a *CLS command Read last item in the queue Unresolved Errorsc Re-reported after queue is cleared. No Errors 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" a. 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. 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.

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 33

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 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 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.

34 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Getting Started with Remote Operation Error Messages

X-Series Signal Generators

Programming Guide 2 Using IO Interfaces Using the programming examples with GPIB, LAN, and USB interfaces: — Using GPIB on page 36 — Using LAN on page 42 — Using USB on page 58

36 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

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 36 — “Set Up the GPIB Interface” on page 38 — “Verify GPIB Functionality” on page 38 Installing the GPIB Interface A GPIB interface card can be installed in a computer. Two common GPIB interface cards are the Keysight 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 Keysight website, http://www.keysight.com for details on GPIB interface cards. You can also connect GPIB instruments to a PC USB port using the Keysight 82357A USB/GPIB Interface Converter, which eliminates the need for a GPIB card. For more information, refer to the table on page 36 or go to http://www.keysight.com/find/gpib. Interface Type Operating System IO Library Languages Backplane/ BUS Max IO (kB/sec) Buffering USB/GPIB Interface Converter for PC–Based Systems Keysight 82357A Converter Windows 98(SE)/ME/ 2000/XP VISA / SICL C/C++, Visual Basic, Keysight VEE, HP Basic for Windows, NI Labview USB 2.0 (1.1 compatible ) 850 Built–in GPIB Interface Card for PC–Based Systems Keysight 82341C for ISA bus computers Windows 95/98/NT /2000 VISA / SICL C/C++, Visual Basic, Keysight VEE, HP Basic for Windows ISA/EISA, 16 bit 750 Built–in Keysight 82341D Plug&Play for PC Windows 95 VISA / SICL C/C++, Visual Basic, Keysight VEE, HP Basic for Windows ISA/EISA, 16 bit 750 Built–in

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 37

Using IO Interfaces Using GPIB Keysight 82350A for PCI bus computers Windows 95/98/NT /2000 VISA / SICL C/C++, Visual Basic, Keysight VEE, HP Basic for Windows PCI 32 bit 750 Built–in Keysight 82350B for PCI bus computers Windows 98(SE)/ME/200 0/XP VISA / SICL C/C++, Visual Basic, Keysight VEE, HP Basic for Windows PCI 32 bit > 900 Built–in NI–GPIB Interface Card for PC–Based Systems National Instruments PCI–GPIB Windows 95/98/2000/ ME/NT VISA NI–488.2 a C/C++, Visual BASIC, LabView PCI 32 bit 1.5 MBps Built–in National Instruments PCI–GPIB+ Windows NT VISA NI–488.2 C/C++, Visual BASIC, LabView PCI 32 bit 1.5 MBps Built–in GPIB Interface Card for HP–UX Workstations Keysight E2071C HP–UX 9.x, HP–UX 10.01 VISA/SICL ANSI C, Keysight VEE, HP BASIC, HP– UX EISA 750 Built–in Keysight E2071D HP–UX 10.20 VISA/SICL ANSI C, Keysight VEE, HP BASIC, HP– UX EISA 750 Built–in Keysight E2078A HP–UX 10.20 VISA/SICL ANSI C, Keysight VEE, HP BASIC, HP– UX PCI 750 Built–in a. NI–488.2 is a trademark of National Instruments Corporation. Interface Type Operating System IO Library Languages Backplane/ BUS Max IO (kB/sec) Buffering USB/GPIB Interface Converter for PC–Based Systems

38 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Using IO Interfaces Using GPIB Set Up the GPIB Interface Enter the GPIB address as shown in Figure 2-1. Figure 2-1 Setting the GPIB Address Connect a GPIB interface cable between the signal generator and the computer. (The following table lists cable part numbers.) Verify GPIB Functionality To verify GPIB functionality, use the VISA Assistant, available with the Keysight 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 3). 2. Remove all other instruments connected through 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. For details on each key, use the key help. Refer to “Getting Key Help” on page 30 and the User’s Guide. For additional SCPI command information, refer to the SCPI Command Reference. Default address: 19 Range: 0–30 SCPI commands: :SYSTem:COMMunicate:GPIB:ADDRess :SYSTem:COMMunicate:GPIB:ADDRess? Model 10833A 10833B 10833C 10833D 10833F 10833G Length 1 meter 2 meters 4 meters .5 meter 6 meters 8 meters

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 39

Using IO Interfaces Using GPIB 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 instruments. Several instruments in the GPIB network can be listeners simultaneously. talker A talker is a device capable of transmitting data. To avoid confusion, a GPIB system allows only one device at a time to be an active talker. controller A controller, typically a computer, can specify the talker and listeners (including itself) for an information transfer. Only one device at a time can be an active controller.

40 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Using IO Interfaces GPIB Programming Interface Examples GPIB Programming Interface Examples — “Interface Check using HP Basic and GPIB” on page 40 — “Interface Check Using NI–488.2 and C++” on page 41 Before Using the GPIB Examples If the Keysight GPIB interface card is used, the Keysight VISA library should be installed along with Keysight 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 21 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 40, 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 72 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 The 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.”

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 41

Using IO Interfaces GPIB Programming Interface Examples 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 41, 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 73 or to the signal generator’s documentation CD–ROM. #include "stdafx.h" #include #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

42 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Using IO Interfaces Using LAN Using LAN The signal generator can be remotely programmed through 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. The signal generator supports the following LAN interface protocols: — VXI–11 (See page 50) — Sockets LAN (See page 51) — Telephone Network (TELNET) (See page 52) — File Transfer Protocol (FTP) (See page 56) — LXI 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. LXI is used to communicate with multiple instruments through LAN events using precision time protocols. For more information on the LXI standards, refer to www.keysight.com/find/lxi. The following sections contain information on selecting and connecting IO libraries and LAN interface hardware that are required to remotely program the signal generator through 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 43 — “Verifying LAN Functionality” on page 46 For more information on configuring your signal generator for LAN, refer to the User’s Guide for your signal generator. You can also refer to www.keysight.com and search on the FAQs: Hardware Configurations and Installation. For more information on configuring the signal generator to communicate over the LAN, refer to “Using VXI–11” on page 50.

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 43

Using IO Interfaces 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.) Configuring the VXI–11 Service 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.) Verify that the signal generator is connected to the LAN using a 100Base– T LAN or 10Base–T LAN cable. NOTE For optimum performance, use a 100Base–T LAN cable to connect the signal generator to the LAN. For details on each key or for a list of equivalent SCPI commands, use the front-panel key help. For information describing the key help, refer to “Getting Key Help” on page 30 and the User’s Guide. For additional SCPI command information, refer to the SCPI Command Reference. Utility > IO Config

44 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Using IO Interfaces Using LAN Manual LAN 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. Manual LAN Configuration Sequence 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. Your hostname can be up to 20 characters long. Utility > IO Config SCPI commands: :SYSTem:COMMunicate:LAN:CONFig MANual :SYSTem:COMMunicate:LAN:CONFig?

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 45

Using IO Interfaces Using LAN DHCP LAN 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. AUTO (DHCP/Auto–IP) Configuration 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. DHCP/Auto-IP LAN Configuration Sequence Setting up Private LAN You can connect the Keysight X-Series signal generator 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.keysight.com, and search on the Connectivity Guide (E2094–90009) or use the Keysight Connection Expert’s Help to see the Connection Guide. 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 (MXG-A models only): 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. Utility > IO Config SCPI commands: :SYSTem:COMMunicate:LAN:CONFig DHCP|AUTO :SYSTem:COMMunicate:LAN:CONFig?

46 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Using IO Interfaces Using LAN 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 “LAN Ping Responses” on page 46. From a UNIX workstation, type: ping 64 10 where 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 where 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. 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. For additional information on troubleshooting your LAN connection, refer to the Help in the Keysight IO Libraries and documentation for LAN connections and problems. LAN Ping Responses For additional information on troubleshooting your LAN connection, refer to “If You Have Problems” on page 46 and to the Help in the Keysight IO Libraries and documentation for LAN connections and problems. In 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. Normal Response for UNIX A normal response to the ping command will be a total of 9 or 10 packets received with a 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. Normal Response for DOS or Windows A normal response to the ping command will be a total of 9 or 10 packets received if 10 echo requests were specified.

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 47

Using IO Interfaces Using LAN Using Interactive IO Use the VISA Assistant utility available in the Keysight IO Libraries Suite to verify instrument communication over the LAN interface. Refer to the section on the “IO Libraries and Programming Languages” on page 16 for more information. The Keysight IO Libraries Suite is supported on all platforms except Windows NT. If you are using Windows NT, refer to the section below on using the VISA Assistant to verify LAN communication. See the section on “Windows NT and Keysight IO Libraries M (and Earlier)” on page 19 for more information. Error Messages If error messages appear, then check the command syntax before continuing with 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 command from the command prompt. No Response If there is no response from a ping, no packets were received. Check that the typed address or hostname matches the IP address or hostname assigned to the signal generator in the System LAN Setup menu. For more information, refer to “DHCP/Auto-IP LAN Configuration Sequence” on page 45. 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 Response If 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. The following sections are specific to Keysight IO Libraries versions M and earlier and apply only to the Windows NT platform.

48 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Using IO Interfaces Using LAN Using VISA Assistant Use the VISA Assistant, available with the Keysight 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. Click 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. For Keysight 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-3 on page 51.

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 49

Using IO Interfaces Using LAN Figure 2-2 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 48. 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.

50 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Using IO Interfaces Using LAN 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 GPIB 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 Keysight VISA/SICL support. Configuring for VXI–11 The Keysight 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 Keysight IO library from the Keysight website. Refer to the Keysight 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 115 of this programming guide. It is recommended that the VXI–11 protocol be used for instrument communication over the LAN interface. To communicate with the signal generator over the LAN interface you must enable the VXI–11 SCPI service. For more information, refer to “DHCP/Auto-IP LAN Configuration Sequence” on page 45. If you are using the Windows NT platform, refer to “Windows NT and Keysight IO Libraries M (and Earlier)” on page 19 for information on using Keysight IO Libraries versions M or earlier to configure the interface. For Keysight IO library version J.01.0100, the “Identify devices at run– time” check box must be unchecked. Refer to Figure 2-3.

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 51

Using IO Interfaces Using LAN Figure 2-3 Show Devices Form (Keysight IO Library version J.01.0100) Using Sockets LAN 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: Users 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.

52 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Using IO Interfaces Using LAN — Standard mode. Available on port 5025. Use this port for simple programming. — TELNET mode. The telnet SCPI service is available on port 5024. An example using sockets LAN is given in “LAN Programming Interface Examples” on page 115 of this programming guide. 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. The following telnet LAN connections are discussed: — “Using Telnet On a PC With a Host/Port Setting Menu GUI” on page 53 — “Using Telnet On a PC With a Command Prompt Interface” on page 53 — “The Standard UNIX Telnet Command” on page 54 A Telnet example is provided in “Unix Telnet Example” on page 56. The default telnet port is 5024. Telnet port 5023 is still available for backwards compatibility. Refer to the SCPI Command Reference. Some systems use a command prompt style interface for the Telnet client. Refer to the Figure 2-6 on page 54 for an example of this interface. For Windows XP and newer, 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. For Windows 7, Telnet functionality is disabled by default. To enable Telnet, got to Start > Control Panel > Programs and Features > Turn Windows features on or off and select the Telnet Client checkbox. Click OK and restart your PC.

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 53

Using IO Interfaces Using LAN Using Telnet On a PC With a Host/Port Setting Menu GUI 1. Launch either the Start Menu’s Command Prompt or Run utility. 2. Type Telnet and press the Enter key (Command Prompt) or click OK (Run utility). 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-4. 4. Enter the hostname, port number, and TermType then click Connect. — Host Name−signal generator’s IP address or hostname — Port−5024 — Term Type−vt100 5. At the SCPI> prompt, enter SCPI commands. Refer to Figure 2-5 on page 53. 6. To signal device clear, press Ctrl–C. 7. Select Exit from the Connect menu to end the Telnet session. Figure 2-4 Connect Form (Keysight IO Library version J.01.0100) Figure 2-5 Telnet Window Using Telnet On a PC With a Command Prompt Interface 1. Launch either the Start Menu’s Command Prompt or Run utility.

54 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Using IO Interfaces Using LAN 2. Type Telnet and press the Enter key (Command Prompt) or click OK (Run utility). The Telnet client screen will be displayed. See Figure 2-6 on page 54. 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 5024, which is the Telnet port associated with the signal generator. 5. At the SCPI> prompt, enter SCPI commands. 6. To escape from the SCPI> session type Ctrl-]. 7. Type quit at the prompt to end the Telnet session. Figure 2-6 Telnet Command Prompt 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

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 55

Using IO Interfaces Using LAN 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. If 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.

56 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Using IO Interfaces Using LAN Unix Telnet Example To connect to the instrument with host name myInstrument and port number 5024, enter the following command on the command line: telnet myInstrument 5024. 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 5024 Trying.... Connected to signal generator Escape character is ‘^]’. Keysight Technologies, N51xx 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-7 shows the FTP interface and lists the directories in the signal generator’s user level directory. File access is limited to the signal generator’s /user directory.

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 57

Using IO Interfaces Using LAN Figure 2-7 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.

58 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Using IO Interfaces Using USB Using USB USB 2.0 connectors can be used to communicate with the signal generator. N51xxB EXG/MXG signal generators are equipped with a Type-B 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 59). 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. 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 through the computer and combining those choices with one of several possible USB interface protocols. — “Selecting I/O Libraries for USB” on page 59 — “Setting Up the USB Interface” on page 59 — “Verifying USB Functionality” on page 60 USB 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. The USB 2.0 interface supports USBTMC or USBTMC–USB488 specifications. For more information on connecting instruments to the USB, refer to the Keysight Connection Expert in the Keysight IO Libraries Help. For a list of compatible flash drives to use with the USB external interface. Refer to http://www.keysight.com/find/mxg. Do not use the front panel USB (Type-A) connector to connect to a computer.

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 59

Using IO Interfaces Using USB Selecting I/O Libraries for USB The I/O libraries can be downloaded from the National Instrument website, http://www.ni.com, or Keysight’s website, http://www.keysight.com. The following is a discussion on these libraries. 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 Keysight 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. See National Instrument’s website for information on NI–488.2. SICL Keysight SICL can be used to develop applications for the USB interface. See Keysight’s website for information on SICL. Setting Up the USB Interface Rear Panel Interface (Mini–B 5 pin) To use USB, connect the USB cable (Refer to Table 2-1, “USB Interface Cable,” on page 60, for USB cable information.) between the computer and the signal generator’s rear panel Mini–B 5–pin USB connector. The Keysight X-Series USB interface requires Keysight IO Libraries Suite 14.1 or newer to run properly. For more information on connecting instruments to the USB, refer to the Keysight Connection Expert in the Keysight IO Libraries Help. I/O applications such as IVI–COM or VXIplug&play can be used in place of VISA. Because of the potential for portability problems, running Keysight SICL without the VISA overlay is not recommended by Keysight Technologies.

60 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Using IO Interfaces Using USB 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. Verifying USB Functionality Mini–B 5 Pin Rear Panel Connector 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. Table 2-1 USB Interface Cable Quantity Description Keysight Part Number 1 USB cable Mini–B 5 pin to Type–A 82357–61601 For information on verifying your Mini–B 5 pin USB (rear panel) functionality, refer to the Keysight Connection Expert in the Keysight IO Libraries Help. The Keysight IO libraries are included with your signal generator or Keysight GPIB interface board, or they can be downloaded from the Keysight website: http://www.keysight.com.

X-Series Signal Generators

Programming Guide 3 Programming Examples — Using the Programming Interface Examples on page 62 — GPIB Programming Interface Examples on page 68 — LAN Programming Interface Examples on page 115

62 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

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 and LAN 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: 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. To have the signal generator’s front panel update with changes caused by remote operations, enable the signal generator’s Update in Remote function. 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 Keysight GPIB interface card — National Instruments VISA Library or Keysight VISA library — LAN interface card The HP Basic examples were run on a UNIX 700 series workstation. HP Basic C# C/C++ Microsoft Visual Basic 6.0 Java MATLAB Perl The example programs set the signal generator into remote. Press the Keysight MXG Local/Esc/Cancel key to revert to manual operation. The 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” on page 30.

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 63

Programming Examples Using the Programming Interface 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 Keysight website or National Instrument’s website. To communicate with the signal generator over the LAN interface you must enable the VXI-11 SCPI service. For more information, refer to “DHCP/Auto-IP LAN Configuration Sequence” on page 45.

64 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Programming Examples Using the Programming Interface Examples C/C++ Examples — “Interface Check for GPIB Using VISA and C” on page 75 — “Local Lockout Using NI-488.2 and C++” on page 78 — “Queries Using NI-488.2 and Visual C++” on page 82 — “Queries for GPIB Using VISA and C” on page 85 — “Generating a CW Signal Using VISA and C” on page 88 — “Generating an Externally Applied AC-Coupled FM Signal Using VISA and C” on page 91 — “Generating an Internal FM Signal Using VISA and C” on page 93 — “Generating a Step-Swept Signal Using VISA and C++” on page 96 — “Reading the Data Questionable Status Register Using VISA and C” on page 104 — “Reading the Service Request Interrupt (SRQ) Using VISA and C” on page 110 — “VXI-11 Programming Using SICL and C++” on page 116 — “VXI-11 Programming Using VISA and C++” on page 118 — “Sockets LAN Programming and C” on page 120 Running C# Examples To run the example program State_Files.cs on page 367, you must have the .NET framework installed on your computer. You must also have the Keysight 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. 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 Keysight VISA User’s Manual, available on Keysight’s website: http://www.keysight.com. In the Visual Basic IDE (Integrated Development Environment) go to Project–References and place a check mark on the following references: — Keysight VISA COM Resource Manager 1.0 — VISA COM 1.0 Type Library To 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 Service” on page 43.

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 65

Programming Examples Using the Programming Interface Examples The signal generator’s VXI-11 SCPI service must be on before you can run the Download Visual Basic 6.0 programming example. 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 301 — “Downloading I/Q Data” on page 304 HP Basic Examples — “Interface Check using HP Basic and GPIB” on page 72 — “Local Lockout Using HP Basic and GPIB” on page 76 — “Queries Using HP Basic and GPIB” on page 80 Running Java Examples The Java program “Sockets LAN Programming Using Java” on page 150, connects to the signal generator through 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 150. If you want to use VISA functions such as viWrite, then you must add the visa32.bas module to your Visual Basic project. To 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 Service” on page 43.

66 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Programming Examples Using the Programming Interface Examples Running MATLAB Examples For information regarding programming examples and files required to create and play waveform files, refer to Chapter 5. Running Perl Examples The Perl example “Sockets LAN Programming Using Perl” on page 153, uses PERL script to control the signal generator over the sockets LAN interface. To 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 Service” on page 43.

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 67

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 67 For more information on setting up a GPIB interface card or NI-GPIB interface card, refer to: — “Set Up the GPIB Interface” on page 38 — “Verify GPIB Functionality” on page 38 Installing the GPIB Interface Card Refer to “Installing the GPIB Interface” on page 36. You can also connect GPIB instruments to a PC USB port using the Keysight 82357A USB/GPIB Interface Converter, which eliminates the need for a GPIB card. For more information, go to http://www.keysight.com/find/gpib.

68 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Programming Examples GPIB Programming Interface Examples GPIB Programming Interface Examples • “Interface Check using HP Basic and GPIB” on page 72 • “Interface Check Using NI-488.2 and C++” on page 73 • “Interface Check for GPIB Using VISA and C” on page 75 • “Local Lockout Using HP Basic and GPIB” on page 76 • “Local Lockout Using NI-488.2 and C++” on page 78 • “Queries Using HP Basic and GPIB” on page 80 • “Queries Using NI-488.2 and Visual C++” on page 82 • “Queries for GPIB Using VISA and C” on page 85 • “Generating a CW Signal Using VISA and C” on page 88 • “Generating an Externally Applied AC-Coupled FM Signal Using VISA and C” on page 91 • “Generating an Internal FM Signal Using VISA and C” on page 93 • “Generating a Step-Swept Signal Using VISA and C++” on page 96 • “Generating a Swept Signal Using VISA and Visual C++” on page 98 • “Saving and Recalling States Using VISA and C” on page 101 • “Reading the Data Questionable Status Register Using VISA and C” on page 104 • “Reading the Service Request Interrupt (SRQ) Using VISA and C” on page 110 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. 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, Keysight 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. Library Function Statement Initialization Command HP Basic The ABORT function stops all GPIB activity. 10 ABORT 7

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 69

Programming Examples GPIB Programming Interface Examples 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. VISA Library In 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. viTerminate (parameter list) NI-488.2 The 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. ibstop(int ud) SICL The Keysight 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. iabort (id) Library Function Statement Initialization Command Library Function Statement Initialization Command HP Basic The REMOTE 719 function disables the front panel operation of all keys with the exception of the Local key. 10 REMOTE 719 VISA Library The VISA library, at this time, does not have a similar command. N/A NI-488.2 The 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. EnableRemote (parameter list) SICL The Keysight 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)

70 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Programming Examples GPIB Programming Interface Examples 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. 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. Library Function Statement Initialization Command HP Basic The 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. 10 LOCAL LOCKOUT 719 VISA Library The VISA library, at this time, does not have a similar command. N/A NI-488.2 The 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. SetRWLS (parameter list) SICL The Keysight 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. igpibllo (id) Library Function Statement Initialization Command HP Basic The LOCAL 719 function returns the signal generator to manual operation, allowing access to the signal generator’s front panel keys. 10 LOCAL 719 VISA Library The VISA library, at this time, does not have a similar command. N/A NI-488.2 The 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. ibloc (int ud) SICL The Keysight SICL function puts the signal generator into Local operation; enabling front panel key operation. The id parameter identifies the session. iloc (id)

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 71

Programming Examples GPIB Programming Interface Examples Clear Function The HP Basic function CLEAR and the other listed IO library functions clear the signal generator. 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. Library Function Statement Initialization Command HP Basic The 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. 10 CLEAR 719 VISA Library The VISA library uses the viClear function. This function performs an IEEE 488.1 clear of the signal generator. viClear (ViSession vi) NI-488.2 The NI-488.2 library function sends the GPIB Selected Device Clear (SDC) message to the device described by ud. ibclr (int ud) SICL The Keysight 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. iclear (id) Library Function Statement Initialization Command HP Basic The function OUTPUT 719 puts the signal generator into remote mode, makes it a listener, and prepares it to receive data. 10 OUTPUT 719 VISA Library The 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. viPrintf (parameter list) NI-488.2 The 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. ibwrt (parameter list) SICL The Keysight 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. iprintf (parameter list)

72 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Programming Examples GPIB Programming Interface Examples 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. 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 basicex1.txt. 10 !****************************************************************** 20 ! 30 ! PROGRAM NAME: basicex1.txt 40 ! 50 ! PROGRAM DESCRIPTION: This program verifies that the GPIB connections and 60 ! interface are functional. 70 ! 80 ! Connect a controller to the signal generator using a GPIB cable. 90 ! Library Function Statement Initialization Command HP Basic The function ENTER 719 puts the signal generator into remote mode, makes it a talker, and assigns data or status information to a designated variable. 10 ENTER 719; VISA Library The 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. viScanf (parameter list) NI-488.2 The 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. ibrd (parameter list) SICL The Keysight 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)

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 73

Programming Examples GPIB Programming Interface Examples 100 ! 110 ! CLEAR and RESET the controller and type in the following commands and then 120 ! RUN the program: 130 ! 140 !****************************************************************** 150 ! 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 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 niex1.cpp. // ******************************************************************* // // PROGRAM NAME: niex1.cpp

74 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Programming Examples GPIB Programming Interface Examples // // PROGRAM DESCRIPTION: This program verifies that the GPIB connections and // interface are functional. // // Connect a GPIB cable from the PC GPIB card to the signal generator // Enter the following code into the source .cpp file and execute the program // // ******************************************************************* #include "stdafx.h" #include #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 // Print data to the output window cout << "The signal generator should now be in REMOTE. The remote indicator"<

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 75

Programming Examples GPIB Programming Interface Examples cout <<"annunciator R should appear on the signal generator display"< #include #include "StdAfx.h" #include void main () { ViSession defaultRM, vi; // Declares a variable of type ViSession // for instrument communication

76 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Programming Examples GPIB Programming Interface Examples ViStatus viStatus = 0; // Opens a session to the GPIB device // at address 19 viStatus=viOpenDefaultRM(&defaultRM); viStatus=viOpen(defaultRM, "GPIB::19::INSTR", VI_NULL, VI_NULL, &vi); if(viStatus){ printf("Could not open ViSession!\n"); printf("Check instruments and connections\n"); printf("\n"); exit(0);} 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 } 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 The following program example is available on the signal generator Documentation CD-ROM as basicex2.txt. 10 !****************************************************************** 20 !

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 77

Programming Examples GPIB Programming Interface Examples 30 ! PROGRAM NAME: basicex2.txt 40 ! 50 ! PROGRAM DESCRIPTION: In REMOTE mode, access to the signal generators 60 ! functional front panel keys are disabled except for 70 ! the Local and Contrast keys. The LOCAL LOCKOUT 80 ! command will disable the Local key. 90 ! The LOCAL command, executed from the controller, is then 100 ! the only way to return the signal generator to front panel, 110 ! Local, control. 120 !****************************************************************** 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

78 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Programming Examples GPIB Programming Interface Examples 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 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 niex2.cpp. // ******************************************************************* // PROGRAM NAME: niex2.cpp // // PROGRAM DESCRIPTION: This program will place the signal generator into // LOCAL LOCKOUT mode. All front panel keys, except the Contrast key, will be disabled. // The local command, 'ibloc(sig)' executed via program code, is the only way to // return the signal generator to front panel, Local, control. // *******************************************************************

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 79

Programming Examples GPIB Programming Interface Examples #include "stdafx.h" #include #include "windows.h" #include "Decl-32.h" using namespace std; int GPIB0= 0; // Board handle Addr4882_t Address[31]; // Declares a variable of type Addr4882_t int main() { int sig; // Declares variable to hold interface descriptor sig = ibdev(0, 19, 0, 13, 1, 0); // Opens and initialize a device descriptor ibclr(sig); // Sends GPIB Selected Device Clear (SDC) message ibwrt(sig, "*RST", 4); // Places signal generator in a defined state cout << "The signal generator should now be in REMOTE. The remote mode R "<

80 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Programming Examples GPIB Programming Interface Examples cout <<"Press Enter to continue"<

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 81

Programming Examples GPIB Programming Interface Examples 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 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

82 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Programming Examples GPIB Programming Interface Examples 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 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: — resets the signal generator — queries the signal generator for various settings — reads the various settings The following program example is available on the signal generator Documentation CD-ROM as niex3.cpp. //***************************************************************** // PROGRAM NAME: niex3.cpp // // PROGRAM DESCRIPTION: This example demonstrates the use of query commands.

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 83

Programming Examples GPIB Programming Interface Examples // // The signal generator can be queried for conditions and instrument states. // These commands are of the type "*IDN?" where the question mark indicates // a query. // //***************************************************************** #include "stdafx.h" #include #include "windows.h" #include "Decl-32.h" using namespace std; int GPIB0= 0; // Board handle Addr4882_t Address[31]; // Declare a variable of type Addr4882_t int main() { int sig; // Declares variable to hold interface descriptor int num; char rdVal[100]; // Declares variable to read instrument responses sig = ibdev(0, 19, 0, 13, 1, 0); // Open and initialize a device descriptor ibloc(sig); // Places the signal generator in local mode ibclr(sig); // Sends Selected Device Clear(SDC) message ibwrt(sig, "*RST", 4); // Places signal generator in a defined state ibwrt(sig, ":FREQuency:CW?",14); // Querys the CW frequency ibrd(sig, rdVal,100); // Reads in the response into rdVal

84 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Programming Examples GPIB Programming Interface Examples rdVal[ibcntl] = '\0'; // Null character indicating end of array cout<<"Source CW frequency is "< 0){ cout<<"Source RF state is : On"<

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 85

Programming Examples GPIB Programming Interface Examples ibrd(sig, rdVal,100); // Reads the source ID rdVal[ibcntl] = '\0'; // Null character indicating end of array cout<<"Source ID is : "<

86 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Programming Examples GPIB Programming Interface Examples // generator can be queried for conditions and instrument states. These commands are of // the type "*IDN?"; the question mark indicates a query. // //***************************************************************** #include #include "StdAfx.h" #include #include #include using namespace std; void main () { ViSession defaultRM, vi; // Declares variables of type ViSession // for instrument communication ViStatus viStatus = 0; // Declares a variable of type ViStatus // for GPIB verifications char rdBuffer [256]; // Declares variable to hold string data int num; // Declares variable to hold integer data // Initialize the VISA system viStatus=viOpenDefaultRM(&defaultRM); // Open session to GPIB device at address 19 viStatus=viOpen(defaultRM, "GPIB::19::INSTR", VI_NULL, VI_NULL, &vi); if(viStatus){ // If problems, then prompt user printf("Could not open ViSession!\n"); printf("Check instruments and connections\n"); printf("\n");

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 87

Programming Examples GPIB Programming Interface Examples exit(0);} viPrintf(vi, "*RST\n"); // Resets signal generator viPrintf(vi, "FREQ:CW?\n"); // Querys the CW frequency 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");

88 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Programming Examples GPIB Programming Interface Examples }else{ printf("Source RF state is : off\n"); } // Close the sessions viClose(vi); viClose(defaultRM); } 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) — turns signal generator RF state off — verifies RF state off The following program example is available on the signal generator Documentation CD-ROM as visaex4.cpp. //***************************************************************** // PROGRAM FILE NAME: visaex4.cpp // // PROGRAM DESCRIPTION: This example demonstrates query commands. The signal generator // frequency and power level. // The RF state of the signal generator is turn on and then the state is queried. The // response will indicate that the RF state is on. The RF state is then turned off and // queried. The response should indicate that the RF state is off. The query results are // printed to the to the display window. // //*****************************************************************

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 89

Programming Examples GPIB Programming Interface Examples #include "StdAfx.h" #include #include #include #include void main () { ViSession defaultRM, vi; // Declares variables of type ViSession // for instrument communication ViStatus viStatus = 0; // Declares a variable of type ViStatus // for GPIB verifications char rdBuffer [256]; // Declare variable to hold string data int num; // Declare variable to hold integer data viStatus=viOpenDefaultRM(&defaultRM); // Initialize VISA system // Open session to GPIB device at address 19 viStatus=viOpen(defaultRM, "GPIB::19::INSTR", VI_NULL, VI_NULL, &vi); if(viStatus){ // If problems then prompt user printf("Could not open ViSession!\n"); printf("Check instruments and connections\n"); printf("\n"); exit(0);} viPrintf(vi, "*RST\n"); // Reset the signal generator viPrintf(vi, "FREQ 500 kHz\n"); // Set the source CW frequency for 500 kHz viPrintf(vi, "FREQ:CW?\n"); // Query the CW frequency viScanf(vi, "%t", rdBuffer); // Read signal generator response

90 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Programming Examples GPIB Programming Interface Examples 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

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 91

Programming Examples GPIB Programming Interface Examples printf("\n"); viClear(vi); viClose(vi); viClose(defaultRM); } 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. Launch Microsoft Visual C++ 6.0, add the required files, and enter the code into your .cpp source file. visaex5.cpp performs the following functions: — error checking — resets the signal generator — sets up the EXT 2 connector on the signal generator for FM — sets up FM path 2 coupling to AC — sets up FM path 2 deviation to 20 kHz — sets carrier frequency to 700 MHz — sets the power level to -2.5 dBm — turns on frequency modulation and RF output The following program example is available on the signal generator Documentation CD-ROM as visaex5.cpp. //***************************************************************** // PROGRAM FILE NAME:visaex5.cpp // // PROGRAM DESCRIPTION:This example sets the signal generator FM source to External 2, // coupling to AC, deviation to 20 kHZ, carrier frequency to 700 MHz and the power level // to -2.5 dBm. The RF state is set to on. // //***************************************************************** #include #include "StdAfx.h"

92 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Programming Examples GPIB Programming Interface Examples #include #include #include void main () { ViSession defaultRM, vi; // Declares variables of type ViSession // for instrument communication ViStatus viStatus = 0; // Declares a variable of type ViStatus // for GPIB verifications // Initialize VISA session viStatus=viOpenDefaultRM(&defaultRM); // open session to gpib device at address 19 viStatus=viOpen(defaultRM, "GPIB::19::INSTR", VI_NULL, VI_NULL, &vi); if(viStatus){ // If problems, then prompt user printf("Could not open ViSession!\n"); printf("Check instruments and connections\n"); printf("\n"); exit(0);} 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

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 93

Programming Examples GPIB Programming Interface Examples 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); } 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 visaex6.cpp.

94 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Programming Examples GPIB Programming Interface Examples //***************************************************************** // PROGRAM FILE NAME:visaex6.cpp // // PROGRAM DESCRIPION:This example generates an internal FM signal at a 900 // MHz carrier frequency and a power level of -15 dBm. The FM rate is 5 kHz and the peak // deviation 100 kHz // //***************************************************************** #include #include "StdAfx.h" #include #include #include void main () { ViSession defaultRM, vi; // Declares variables of type ViSession // for instrument communication ViStatus viStatus = 0; // Declares a variable of type ViStatus // for GPIB verifications viStatus=viOpenDefaultRM(&defaultRM); // Initialize VISA session // open session to gpib device at address 19 viStatus=viOpen(defaultRM, "GPIB::19::INSTR", VI_NULL, VI_NULL, &vi); if(viStatus){ // If problems, then prompt user printf("Could not open ViSession!\n"); printf("Check instruments and connections\n"); printf("\n");

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 95

Programming Examples GPIB Programming Interface Examples exit(0);} 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 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); }

96 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Programming Examples GPIB Programming Interface 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 visaex7.cpp. //***************************************************************** // PROGRAM FILE NAME:visaex7.cpp // // PROGRAM DESCRIPTION:This example will program the signal generator to perform a step // sweep from 500-800 MHz with a .5 sec dwell at each frequency step. // //***************************************************************** #include #include "StdAfx.h" #include void main () { ViSession defaultRM, vi;// Declares variables of type ViSession // vi establishes instrument communication ViStatus viStatus = 0;// Declares a variable of type ViStatus // for GPIB verifications viStatus=viOpenDefaultRM(&defaultRM); // Initialize VISA session

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 97

Programming Examples GPIB Programming Interface Examples // Open session to GPIB device at address 19 viStatus=viOpen(defaultRM, "GPIB::19::INSTR", VI_NULL, VI_NULL, &vi); if(viStatus){// If problems, then prompt user printf("Could not open ViSession!\n"); printf("Check instruments and connections\n"); printf("\n"); exit(0);} viClear(vi); // Clears the signal generator 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

98 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Programming Examples GPIB Programming Interface Examples 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 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 The following program example is available on the signal generator Documentation CD-ROM as visaex11.cpp. //***************************************************************** // PROGRAM FILE NAME: visaex11.cpp // // PROGRAM DESCRIPTION: This program sets up the signal generator to // sweep from 1-2 GHz. A loop and counter are used to generate 5 sweeps. // Each sweep consists of 101 points with a .01 second dwell at each point. // // The program uses a Sleep function to allow the signal generator to // complete it's sweep operation before the INIT command is sent. // The Sleep function is available with the windows.h header file which is // included in the project. //

Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 99

Programming Examples GPIB Programming Interface Examples // NOTE: Change the TCPIP0 address in the instOpenString declaration to // match the IP address of your signal generator. // //***************************************************************** #include "stdafx.h" #include "visa.h" #include #include void main () { ViStatus stat; ViSession defaultRM,inst; int npoints = 101; double dwell = 0.01; int intCounter=5; char* instOpenString = "TCPIP0::141.121.93.101::INSTR"; stat = viOpenDefaultRM(&defaultRM); stat = viOpen(defaultRM,instOpenString,VI_NULL,VI_NULL, &inst); // preset to start clean stat = viPrintf( inst, "*RST\n" ); // set power level for -10dBm stat = viPrintf(inst, "POW -10DBM\n"); // set the start and stop frequency for the sweep stat = viPrintf(inst, "FREQ:START 1GHZ\n"); stat = viPrintf(inst, "FREQ:STOP 2GHZ\n"); // setup dwell per point

100 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide

Programming Examples GPIB Programming Interface Examples stat = viPrintf(inst, "SWEEP:DWELL %e\n", dwell); // setup number of points stat = viPrintf(inst, "SWEEP:POINTS %d\n", npoints); // set interface timeout to double the expected sweep time // sweep takes (~15ms + dwell) per point * number of points // the timeout should not be shorter then the sweep, set it // longer long timeoutMS = long(2*npoints*(.015+dwell)*1000); // set the VISA timeout stat = viSetAttribute(inst, VI_ATTR_TMO_VALUE, timeoutMS); // set continuous trigger mode off stat = viPrintf(inst, "INIT:CONT OFF\n"); // turn list sweep on stat = viPrintf(inst, "FREQ:MODE LIST\n"); int sweepNo = 0; while(intCounter>0 ) { // start the sweep (initialize) stat = viPrintf(inst, "INIT\n"); printf("Sweep %d started\n",++sweepNo); // wait for the sweep completion with *OPC? int res ; stat = viPrintf(inst, "*OPC?\n"); stat = viScanf(inst, "%d", &res); // handle possible errors here (most likely a timeout) // err_handler( inst, stat ); puts("Sweep ended"); // delay before sending next INIT since instrument // may not be ready to receive it yet Sleep(15);

Other Portable Generator Manuals