Agilent E4401B Programmers Guide

Programmer’s Guide
Agilent Technologies ESA Spectrum Analyzers
This guide documents firmware revision 04.00 and prior versions.
ESA-E Series
E4401B (9 kHz–1.5 GHz) E4402B (9 kHz–3.0 GHz) E4404B (9 kHz–6.7 GHz) E4405B (9 kHz–13.2 GHz) E4407B (9 kHz–26.5 GHz)
and
ESA-L Series
E4411B (9 kHz–1.5 GHz) E4403B (9kHz–3.0 GHz) E4408B (9 kHz–24.5 GHz)
Manufacturing Part Number: E4401-90179
Supersedes E4401-90109
Printed in USA
February 2000
© Copyright 1999, 2000 Agilent Technologies
The information contained in this document is subject to change without notice.
Agilent Technologiesmakesnowarrantyofanykindwithregard to this material, including but not limited to, the implied warranties of merchantability and fitness for a particular purpose. Agilent Technologies shall not be liable for errors contained herein or for incidental or consequential damages in connection with the furnishing, performance, or use of this material.
The following safety symbols are used throughout this manual. Familiarize yourself with the symbols and their meaning before operating this instrument.
WARNING Warning denotes a hazard. It calls attention to a procedure
which, if not correctly performed or adhered to, could result in injury or loss of life. Do not proceed beyond a warning note until the indicated conditions are fully understood and met.
CAUTION Caution denotes a hazard. It calls attention to a procedure that, if not
correctly performed or adhered to, could result in damage to or destruction of the instrument. Do not proceed beyond a caution sign until the indicated conditions are fully understood and met.
NOTE Note calls out special information for the user’s attention. It provides
operational information or additional instructions of which the user should be aware.
ii
The instruction documentation symbol. The product is marked with this symbol when it is necessary for the user to refer to the instructions in the documentation.
This symbol is used to mark the on position of the power line switch.
This symbol is used to mark the standby position of the power line switch.
This symbol indicates that the input power required is AC.
WARNING This is a Safety Class 1 Product (provided with a protective
earthing ground incorporated in the power cord). The mains plug shall only be inserted in a socket outlet provided with a protected earth contact. Any interruption of the protective conductor inside or outside of the product is likely to make the product dangerous. Intentional interruption is prohibited.
WARNING If this product is not used as specified, the protection provided
by the equipment could be impaired. This product must be used in a normal condition (in which all means for protection are intact) only.
iii
Warranty
This Agilent Technologies instrument product is warranted against defects in material and workmanship for a period of three years from date of shipment. During the warranty period, Agilent Technologies will, at its option, either repair or replace products which prove to be defective.
For warranty service or repair, this product must be returned to a service facility designated by Agilent Technologies. Buyer shall prepay shipping charges to Agilent Technologies and Agilent Technologies shall pay shipping charges to return the product to Buyer. However, Buyer shall pay all shipping charges, duties, and taxes for products returned to Agilent Technologies from another country.
Agilent Technologies warrants that its software and firmware designated by Agilent Technologies for use with an instrument will execute its programming instructions when properly installed on that instrument. Agilent Technologies does not warrant that the operation of the instrument, or software, or firmware will be uninterrupted or error-free.
LIMITATION OF WARRANTY
The foregoing warranty shall not apply to defects resulting from improper or inadequate maintenance by Buyer, Buyer-supplied software or interfacing, unauthorized modification or misuse, operation outside of the environmental specifications for the product, or improper site preparation or maintenance.
NO OTHER WARRANTY IS EXPRESSED OR IMPLIED. AGILENT TECHNOLOGIES SPECIFICALLY DISCLAIMS THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
EXCLUSIVE REMEDIES
THE REMEDIES PROVIDED HEREIN ARE BUYER’S SOLE AND EXCLUSIVE REMEDIES. AGILENT TECHNOLOGIES SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER BASED ON CONTRACT, TORT, OR ANY OTHER LEGAL THEORY.
iv
Where to Find the Latest Information
Documentation is updated periodically.For the latest information about Agilent ESA Spectrum Analyzers, including firmware upgrades and application information, please visit the following Internet URL:
http://www.agilent.com/find/esa
v
Contents
1. Programming Fundamentals
Creating Valid Commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-3
Command Notation Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-4
Special Characters in Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-5
Parameters in Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-6
Putting Multiple Commands on the Same Line. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-8
SCPI Termination and Separator Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-8
Overview of GPIB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-10
GPIB Instrument Nomenclature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-10
GPIB Command Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-10
Overview of RS-232 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-12
Settings for the Serial Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-12
Handshake and Baud Rate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-12
Character Format Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-12
Modem Line Handshaking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-13
Data Transfer Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-13
Printer Setup and Operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-14
Equipment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-14
Interconnection and Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-14
Testing Printer Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-16
2. Status Registers
Use Status Registers to Determine the State of Analyzer Events and Conditions . . . . . . . .2-2
What are the Status Registers? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-3
How Do You Access the Status Registers?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-6
Using the Service Request (SRQ) Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-8
Generating a Service Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-8
Setting and Querying the Status Register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-10
Details of Bits in All Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-11
Status Byte Register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-11
Service Request Enable Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-13
Standard Event Status Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-14
Standard Event Status Event Enable Register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-16
STATus:OPERation Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-17
STATus:OPERation Condition Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-18
STATus:OPERation Event Enable Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-19
STATus:QUEStionable Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-20
STATus:QUEStionable:POWer Condition Register Bits . . . . . . . . . . . . . . . . . . . . . . . . . .2-22
STATus:QUEStionable:FREQuency Condition Register Bits . . . . . . . . . . . . . . . . . . . . . .2-22
STATus:QUEStionable:CALibration Condition Register Bits. . . . . . . . . . . . . . . . . . . . . .2-23
STATus:QUEStionable:INTegrity Condition Register Bits . . . . . . . . . . . . . . . . . . . . . . . .2-24
STATus:QUEStionable:INTegrity:UNCalibrated Condition Register Bits . . . . . . . . . . . .2-26
3. Programming Examples
List of Programming Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-2
Programming Examples System Requirements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-3
C Programming Examples using VTL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-4
Typical Example Program Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-4
vii
Contents
Linking to VTL Libraries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
Compiling and Linking a VTL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
Example Program. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
Including the VISA Declarations File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
Opening a Session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8
Device Sessions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8
Addressing a Session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10
Closing a Session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11
Using Marker Peak Search and Peak Excursion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
Example:. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
Using Marker Delta Mode and Marker Minimum Search . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16
Performing Internal Self-alignment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
Reading Trace Data using ASCII Format (HP-IB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-24
Reading Trace Data Using 32-bit
Real Format (HP-IB). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-29
Reading Trace Data Using ASCII Format (RS-232) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-34
Reading Trace Data Using 32-bit Real Format (RS-232) . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-39
Using Limit Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-44
Measuring Noise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-49
Entering Amplitude Correction Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-53
Status Register–Determine When a Measurement is Done . . . . . . . . . . . . . . . . . . . . . . . . . 3-57
Determine if an Error has Occurred. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-63
Measuring Harmonic Distortion (HP-IB). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-69
Measuring Harmonic Distortion (RS-232) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-78
Making Faster Measurements (multiple measurements). . . . . . . . . . . . . . . . . . . . . . . . . . . 3-87
4. Programming Command Cross References
Functional Index to SCPI Subsection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
5. Language Reference
SCPI Sections and Subsections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
IEEE Common Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5
Calibration Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5
Clear Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5
Standard Event Status Enable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5
Standard Event Status Register Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6
Identification Query 094 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6
Instrument State Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6
Operation Complete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7
Query Instrument Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7
Recall. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7
Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-8
Save. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-8
Service Request Enable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-8
Read Status Byte Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-8
Trigger. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-9
Self Test Query. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-9
Wait-to-Continue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-9
viii
Contents
ABORt Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-10
Abort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-10
CALCulate Subsystem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-11
NdBpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-11
NdBresults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-11
NdBstate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-12
Test Current Trace Data Against all Limit Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-12
CALCulate:LLINe Subsection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-12
CALCulate:MARKer Subsection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-19
CALCulate:NTData Subsection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-31
CALibration Subsystem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-32
Align All Instrument Assemblies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-32
Set Auto Align Mode All or Not RF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-32
Automatic Alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-33
Return to the Default Alignment Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-33
Align FM Demodulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-33
Query the Internal or External Frequency Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-33
Coarse Adjust the Frequency Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-34
Fine Adjust the Frequency Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-34
Select the Frequency Corrections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-34
Align the RF Circuitry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-34
Select the Source State for Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-35
Calibrate the Tracking Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-35
CONFigure Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-37
Configure the Adjacent Channel Power Measurements. . . . . . . . . . . . . . . . . . . . . . . . . . .5-37
Configure the Channel Power and Density Measurements . . . . . . . . . . . . . . . . . . . . . . . .5-37
Configure the Emission Bandwidth Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-37
Configure the Harmonic Distortion Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-37
Configure the OBW and Transmit Frequency Error Measurements. . . . . . . . . . . . . . . . .5-37
COUPle Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-38
COUPle the Function to Other Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-38
DISPlay Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-39
Display Viewing Angle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-39
Date and Time Display Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-39
Date and Time Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-39
Display Annotation Title Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-40
Turn the Entire Display On/Off . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-40
Window Annotation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-40
Trace Graticule Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-41
Trace X-Axis Scale Offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-41
Set the Display Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-41
Control the Display Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-42
Normalized Reference Level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-42
Normalized Reference Level Position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-42
Reference Level Auto Ranging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-43
Trace Y-Axis Amplitude Scaling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-43
Trace Y-Axis Frequency Scaling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-43
Trace Y-Axis Reference Level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-44
Trace Y-Axis Reference Level Offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-44
ix
Contents
Vertical Axis Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-45
FETCh Subsystem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-46
Return Main, Lower, and Upper Channel Power. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-46
Return Main Channel Power. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-46
Return Lower Channel Power. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-46
Return Upper Channel Power. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-47
Return Channel Power and Density . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-47
Return Channel Power. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-47
Return Channel Power Density. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-47
Return Emission Bandwidth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-47
Return Harmonic Amplitudes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-47
Return Harmonic N Amplitude. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-48
Return % Total Harmonic Distortion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-48
Return Harmonic Frequency List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-48
Return Harmonic N Frequency. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-49
Return Fundamental Frequency. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-49
Return OBW and Transmit Frequency Error. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-49
Return Occupied Bandwidth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-50
Return Transmit Frequency Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-50
FORMat Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-51
Byte Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-51
Numeric Data format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-51
HCOPy Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-54
Abort the Print . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-54
Printer Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-54
Color Hard Copy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-54
Print a Hard Copy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-55
Form Feed the Print Item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-55
Page Orientation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-55
Number of Items Printed on a Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-55
INITiate Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-57
Continuous or Single Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-57
Take New Data Acquisitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-58
Restart Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-59
INPut Subsystem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-60
Input Port Coupling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-60
Select Internal or External Mixer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-60
Select Mixer Type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-61
Clear the Input Overload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-61
INSTrument Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-62
Select Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-62
MEASure Subsystem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-63
Measure Main, Lower, and Upper Channel Power. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-63
Measure Main Channel Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-63
Measure Lower Channel Power. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-63
Measure Upper Channel Power. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-64
Measure Channel Power and Density. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-64
Measure Channel Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-64
Measure Channel Power Density . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-64
x
Contents
Measure Emission Bandwidth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-64
Return Harmonic Amplitudes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-64
Return Harmonic N Amplitude . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-65
Return % Total Harmonic Distortion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-65
Return Harmonic Frequency List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-65
Return Harmonic N Frequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-66
Return Fundamental Frequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-66
Measure OBW and Transmit Frequency Error. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-66
Measure Occupied Bandwidth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-67
Measure Transmit Frequency Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-67
MMEMory Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-68
Catalog the Selected Memory Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-68
Copy a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-68
Move Data to File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-69
Delete a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-69
Load a Corrections Table from a File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-69
Load a Limit Line from Memory to the Instrument . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-69
Load an Instrument State from a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-70
Load a Trace From a File to the Instrument . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-70
Create a New Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-71
Delete a Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-71
Store a Corrections Table to a File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-71
Store a Limit Line in a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-72
Store a Screen Image in a Graphic File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-72
Store an Instrument State in a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-72
Store a Trace in a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-72
OUTPut Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-73
Turn Output On/Off . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-73
READ Subsystem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-74
Measure Main, Lower, and Upper Channel Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-74
Measure Main Channel Power. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-74
Measure Lower Channel Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-74
Measure Upper Channel Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-74
Measure Channel Power and Density . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-75
Measure Channel Power. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-75
Measure Channel Power Density. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-75
Measure Emission Bandwidth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-75
Return Harmonic Amplitudes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-75
Return Harmonic N Amplitude . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-76
Return % Total Harmonic Distortion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-76
Return Harmonic Frequency List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-76
Return Harmonic N Frequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-77
Return Fundamental Frequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-77
Measure OBW and Transmit Frequency Error. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-77
Measure Occupied Bandwidth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-78
Measure Transmit Frequency Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-78
SENSe Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-79
[:SENSe]:ACPower Subsection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-80
[:SENSe]:AVERage Subsection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-81
xi
Contents
[:SENSe]:BANDwidth Subsection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-82
[:SENSe]:CHPower Subsection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-84
[:SENSe]:CORRection Subsection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-85
[:SENSe]:DEMod Subsection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-88
[:SENSe]:DETector Subsection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-90
[:SENSe]:EBWidth Subsection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-90
[:SENSe]:FREQuency Subsection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-92
[:SENSe]:HARMonics Subsection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-95
[SENSe]:MIXer Subsection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-97
[:SENSe]:OBWidth Subsection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-100
[:SENSe]:POWer Subsection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-101
[:SENSe]:SIDentify Subsection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-103
[:SENSe]:SWEep Subsection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-105
SOURce Subsystem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-109
Sets the Output Power Offset Correction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-109
Source Attenuation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-109
Automatic Source Attenuation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-110
Sets the Output Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-110
Sets the Source Output Power Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-110
Set the Source Sweep Power Range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-111
Set the Output Power at the Start of the Sweep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-111
Set the Output Power to Step Automatically . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-111
Set the Output Power Step Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-112
Set the Source Sweep Power Range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-112
Output Power Tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-112
Output Power Tracking Peak . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-113
STATus Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-114
Operation Condition Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-114
Operation Enable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-114
Operation Event Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-114
Operation Negative Transition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-115
Operation Positive Transition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-115
Preset the Status Byte . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-115
STATus:QUEStionable Subsection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-116
SWEEp Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-125
Sweep Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-125
SYSTem Subsystem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-126
GPIB Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-126
Serial Port DTR Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-126
Serial Port RTS Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-127
Serial Port Baud Rate Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-128
Serial Port Receive Pace Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-128
Serial Port Transmit Pace Setup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-129
Hardware Configuration Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-129
Display the Hardware Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-130
System Configuration Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-130
Display System Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-130
Set Date . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-130
Error Information Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-131
xii
Contents
Host Identification Query. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-131
License Key – Install Application/Option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-131
Delete a License Key. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-132
Query Instrument Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-132
Power On Elapsed Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-132
Power On Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-132
Power On Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-133
Enable IF/Video/Sweep Output Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-133
Preset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-133
Persistent State Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-134
Save User Preset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-134
Preset Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-134
Speaker Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-134
Set Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-135
SCPI Version Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-135
TRACe Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-136
Copy Trace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-136
Transfer Trace Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-136
Exchange Traces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-137
Trace Math Add . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-137
Mean Trace Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-138
Query the Signal Peaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-138
Query Number of Peaks Found . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-138
Peak Sorting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-138
Smooth Trace Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-139
Number of Points for Smoothing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-140
Trace Math Subtract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-141
Trace Math Subtract From Display Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-141
Select Trace Display Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-141
TRIGger Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-143
External Trigger, Line and TV Trigger Delay Value . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-143
External Trigger, Line and TV Trigger Delay Enable . . . . . . . . . . . . . . . . . . . . . . . . . . .5-143
External Trigger Slope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-143
Trigger Offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-144
Trigger Offset On/Off . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-145
Trigger Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-145
Set TV Field Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-146
Set TV Line Number for Synchronization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-147
Set Analyzer for TV Picture Monitoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-147
Set the Video Waveform Sync. Pulse Direction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-147
Select TV Signal Path. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-148
Select TV Standard. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-148
Video Trigger Level Amplitude . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-149
Video Trigger Level Frequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-150
UNIT Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-151
Select Power Units of Measure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-151
xiii
Contents
6. Agilent 8590/ESA Spectrum Analyzers Programming Conversion Guide
7. Error Messages
Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2
Status Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3
Informational Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8
Error Queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-13
Error Message Format. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-14
Error Message Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-15
0:
No Error. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-17
–499 to –400:
Query Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-18
–299 to –200:
Execution Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-20
Execution Error Message Descriptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-20
–199 to –100:
Command Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-21
201 to 799:
Device-Specific Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-26
Greater than 1000:
Personality Specific Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-36
xiv

1 Programming Fundamentals

The purpose of this chapter is to serve as a reminder of SCPI (Standard Commands for Programmable Instruments) fundamentals to those who have previous experience in programming SCPI. This chapter is not intended to teach you everything about the SCPI programming language.
1-1
Programming Fundamentals
The SCPI Consortium or IEEE can provide detailed information on the subject of SCPI programming. Refer to IEEE Standard 488.1-1987,
IEEE Standard Digital Interface for Programmable Instrumentation. New York, NY, 1987, or to IEEE Standard 488.2-1992, IEEE Standard Codes, Formats, Protocols and Common Commands for Use with ANSI/IEEE Std 488.1-1987. New York, NY, 1992.
Valid ESA Spectrum Analyzer SCPI commands are used for examples in this chapter. Topics included in this chapter are:
• “Creating Valid Commands”
• “Command Notation Syntax”
• “Special Characters in Commands”
• “Putting Multiple Commands on the Same Line”
• “Overview of GPIB”
• “Overview of RS-232”
• “Printer Setup and Operation”
1-2 Chapter1

Creating Valid Commands

Commands are not case sensitive and there are often many different ways of writing a particular command. These are examples of valid commands for a given command syntax:
Command Syntax Sample Valid Commands
Programming Fundamentals
Creating Valid Commands
[:SENSe]:BANDwidth[:RESolution] <freq>
:MEASure:HARMonics:AMPLitude [n?]
[:SENSe]:DETector[:FUNCtion] NEGative|POSitive|SAMPle
The following sample commands are all identical. They will all cause the same result.
:Sense:Band:Res 1700
:BANDWIDTH:RESOLUTION 1.7e3
:sens:band 1.7KHZ
:SENS:band 1.7E3Hz
:band 1.7kHz
:bandwidth:RES 1.7e3Hz The last command below returns different
results than the commands above it. The number 3 in the command causes this. See the command description for more information.
:MEAS:HARM:AMPL?
:Meas:Harm:Ampl?
:MEAS:HARM:AMPL3?
DET:FUNC NEG
:Sense:Detector:Function Sample
:INITiate:CONTinuous OFF|ON|0|1 The sample commands below are identical.
:INIT:CONT ON
:init:continuous 1
Chapter 1 1-3
Programming Fundamentals

Command Notation Syntax

Command Notation Syntax
A typical command is made up of key words set off by colons. The key words are followed by parameters that can be followed by optional units.
Example: :TRIGger:SEQuence:VIDeo:LEVel 2.5V The instrument does not distinguish between upper and lower case
letters. In the documentation, upper case letters indicate the short form of the key word. The upper and lower case letters, together, indicate the long form of the key word. Either form may be used in the command.
Example: Trig:Seq:Vid:Lev 2.5V is the same as trigger:sequence:video:level 2.5V.
NOTE The command TRIGG:Sequence:Video:Level 2.5V is not valid
because TRIGG is neither the long, nor the short form of the command.
1-4 Chapter1

Special Characters in Commands

Special Characters in Commands
Programming Fundamentals
Special Character
| A vertical stroke between
[ ] Key words in square
Meaning Example
parameters indicates
alternative choices. The effect of the command is different depending on which parameter is selected.
A vertical stroke between key words indicates identical effects exist for several key words. Only one of these key wordsis used at a time. The command functions the same for either key word.
brackets are optional when composing the command. These implied key words will be executed even if they are omitted.
Command:[:SENSe]:DETect
or[:FUNCtion] NEGative|POSitive|SAMP le
The choices are neg, pos, and samp..
:SENSe:DETector:FUNCtio n SAMPle
is one possible command choice.
Command:
[:SENSe]:ACPower:BANDw idth|BWIDth:ACHannel
Two identical commands are:
:SENSe:ACPower:BANDwid th:ACHannel :SENSe:ACPower:BWIDth: ACHannel
Command:
[:SENSe]:ACPower:AVERa ge[:STATe]OFF|ON|0|1
The following commands are all valid and have identical effects:
:SENSe:ACPower:AVERa ge:STATe OFF :ACPower:AVERage:STA Te OFF ACPower:AVERage OFF
< > Angle brackets around a
word, or words, indicates they are not to be used literally in the command. They represent the needed item.
Chapter 1 1-5
Command:
:SENSe:ACPower:CSPacin g <freq>
In this command example the word <freq> should be replaced by an actual frequency:
:SENSe:ACPower:CSPacin g 9.7MHz
Programming Fundamentals
Special Characters in Commands
Special Character
{ } Parameters in braces can
Meaning Example
Command: optionally be used in the command either not at all, once, or several times.
[SENSe:]CORRection:CSE
T[1]|2|3|4:DATA:MERGe
<freq>,<rel_ampl>{,<fr
eq>,<rel_ampl>}
A valid form of this command
is:
[SENSe:]CORRection:CSE
T1:DATA:MERGe
740000,.94 1250000,.31
3320000,1.7

Parameters in Commands

There are four basic types of parameters: boolean, key words, variables and arbitrary block program data.
Boolean
The expression OFF|ON|0|1 is a two state boolean-type parameter. The numeric value 0 is equivalent to OFF. Any numeric value other than 0 is equivalent to ON. The numeric values of 0 or 1 are commonly used in the command instead of OFF or ON, and queries of the parameter always return a numeric value of 0 or 1.
Key Word
The parameter key words that are allowed for a particular command are defined in the command description and are separated with a vertical slash.
Units
Numerical variables may include units. The valid units for a command depends on the variable type being used. See the following variable descriptions. If no units are sent, the indicated default units will be used. Units can follow the numerical value with, or without, a space.
Variable
A variable can be entered in exponential format as well as standard numeric format. The appropriate variable range and its optional units are defined in the command description.
In addition to these values, the following key words may also be used in commands where they are applicable.
MINimum - sets the parameter to the smallest possible value. MAXimum - sets the parameter to the largest possible value.
1-6 Chapter1
Programming Fundamentals
Parameters in Commands
Include the key word MINimum or MAXimum after the question mark in a query in order to return the numeric value of the key word.
Example query: [:SENSE]:FREQuency:CENTer? MAXimum
Variable Parameters
<freq> A frequency parameter is a positive rational number followed by
optional units. The default unit is Hz. Acceptable units include: Hz, kHz, MHz, GHz.
<time> A time parameter is a rational number followed by optional units. The
default units are seconds. Acceptable units include: S, MS, US. <ampl>, <rel_ampl> The <ampl> (amplitude) parameter and the <rel_ampl> (relative
amplitude) parameter consist of a rational number followed by optional units. Acceptable units include: V, mV, µV, dBm, dBmV, dBµV, Watts, W.
<angle> An angle parameter is a rational number followed by optional units.
The default units are degrees. Acceptable units include: DEG, RAD. <integer> There are no units associated with an integer parameter. <percent> A percent parameter is a rational number between 0 and 100, with no
units. <string> A string parameter includes a series of alpha numeric characters.
Block Program Data
Definite length arbitrary block response data is defined in section
8.7.9.2 of IEEE Standard 488.2-1992, IEEE Standard Codes, Formats,
Protocols and Common Commands for Use with ANSI/IEEE Std
488.1-1987. New York, NY, 1992.
<definite_length_block> It allows data to be transmitted over the system interface as a series of
8 bit data bytes. This element is particularly useful for sending large quantities of data, 8 bit extended ASCII codes, or other data that are not able to be directly displayed.
Chapter 1 1-7
Programming Fundamentals

Putting Multiple Commands on the Same Line

Putting Multiple Commands on the Same Line
Multiple commands can be written on the same line, reducing your code space requirement. To do this:
• Commands must be separated with a semicolon (;).
• If the commands are in different subsystems, the key word for the new subsystem must be preceded by a colon (:).
• If the commands are in the same subsystem, the full hierarchy of the command key words need not be included. The second command can start at the same key word level as the command that was just executed.

SCPI Termination and Separator Syntax

A terminator must be provided when an instrument is controlled using RS-232. There are several issues to be understood about choosing the proper SCPI terminator and separator when this is the case. There is no current SCPI standard for RS-232. Although one intent of SCPI is to be interface independent, <END> is only defined for IEEE 488 operation. At the time of this writing, the RS-232 terminator issue was in the process of being addressed in IEEE standard 1174 .
A semicolon (;) is not a SCPI terminator, it is a separator. The purpose of the separator is to queue multiple commands or queries in order to obtain multiple actions and/or responses. Make sure that you do not attempt to use the semicolon as a terminator when using RS-232 control.
Basically all binary trace and response data is terminated with <NL><END>, as defined in Section 8.5 of IEEE Standard 488.2-1992,
IEEE Standard Codes,Formats, Protocols and Common Commands for Use with ANSI/IEEE Std 488.1-1987. New York, NY, 1992.
The following are some examples of good and bad commands. The examples are created from an ESA spectrum analyzer with the simple set of commands indicated below:
[:SENSe]
:POWer
[:RF] :ATTenuation 40dB
:TRIGger
[:SEQuence] :EXTernal [1]
:SLOPe
POSitive
[:SENSe]
1-8 Chapter1
Programming Fundamentals
Putting Multiple Commands on the Same Line
:FREQuency
:STARt :POWer [:RF]
:MIXer
:RANGe
[:UPPer]
Bad Command Good Command
PWR:ATT 40dB POW:ATT 40dB The short form of POWER is POW, not PWR. FREQ:STAR 30MHz;MIX:RANG
–20dBm
The MIX:RANG command is in the same :SENSE subsystem as FREQ, but executing the FREQ command puts you back at the SENSE level. You must specify POW to get to the MIX:RANG command.
FREQ:STAR 30MHz;POW:MIX RANG –20dBm
MIX and RANG require a colon to separate them. :POW:ATT 40dB;TRIG:FREQ:STAR
2.3GHz :FREQ:STAR is in the :SENSE subsystem, not the :TRIGGER subsystem. :POW:ATT?:FREQ:STAR? :POW:ATT?;:FREQ:STAR? :POW and FREQ are within the same :SENSE subsystem, but they are two
separate commands, so they should be separated with a semicolon, not a colon.
:POW:ATT -5dB;:FREQ:STAR 10MHz
Attenuation cannot be a negative value.
FREQ:STAR 30MHz;POW:MIX:RANG –20dBm
FREQ:STAR 30MHz;POW:MIX:RANG –20dBm
:POW:ATT 40dB;:FREQ:STAR
2.3GHz
:POW:ATT 5dB;:FREQ:STAR 10MHz
Chapter 1 1-9
Programming Fundamentals

Overview of GPIB

Overview of GPIB

GPIB Instrument Nomenclature

An instrument that is part of an 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. Any number of instruments in the GPIB network can be listeners simultaneously.
Talker A talker is a device capable of transmitting data or
commands to other instruments. To avoid confusion, an GPIB system allows only one device at a time to be an active talker.
Controller A controller is an instrument, typically a computer,
capable of managing the various GPIB activities. Only one device at a time can be an active controller.

GPIB Command Statements

Command statements form the nucleus of GPIB programming. They are understood by all instruments in the network. When combined with the programming language codes, they provide all management and data communication instructions for the system. Refer to the your programming language manual and your computers I/O programming manual for more information.
The seven fundamental command functions are as follows:
• An abort function that stops all listener/talker activity on the interface bus, and prepares all instruments to receive a new command from the controller. Typically, this is an initialization command used to place the bus in a known starting condition (sometimes called: abort, abortio, reset, halt).
• A remote function that causes an instrument to change from local control to remote control. In remote control, the front panel keys are disabled except for the Local key and the line power switch (sometimes called: remote, resume).
• A local lockout function, that can be used with the remote function, to disable the front panel Local key. With the Local key disabled, only the controller (or a hard reset by the line power switch) can restore local control (sometimes called: local).
1-10 Chapter1
Programming Fundamentals
Overview of GPIB
• A local function that is the complement to the remote command, causing an instrument to return to local control with a fully enabled front panel (sometimes called: local, resume).
• A clear function that causes all GPIB instruments, or addressed instruments, to assume a cleared condition. The definition of clear is unique for each instrument (sometimes called: clear, reset, control, send).
• An output function that is used to send function commands and data commands from the controller to the addressed instrument (sometimes called: output, control, convert, image, iobuffer, transfer).
• An enter function that is the complement of the output function and is used to transfer data from the addressed instrument to the controller (sometimes called: enter, convert, image, iobuffer, on timeout, set timeout, transfer).
Chapter 1 1-11
Programming Fundamentals

Overview of RS-232

Overview of RS-232
Serial interface programming techniques are similar to most general I/O applications.
Due to the asynchronous nature of serial I/O operations, special care must be exercised to ensure that data is not lost by sending to another device before the device is ready to receive. Modem line handshaking can he used to help solve this problem. These and other topics are discussed in greater detail in your programming language documentation.

Settings for the Serial Interface

Please refer to the documentation on your computer and I/O to configure the serial bus. Some common serial interface configuration settings are:
Baud Rate to 9600 Bits per character to 8 Parity to Odd or disabled Stop bits to 1

Handshake and Baud Rate

To determine hardware operating parameters, you need to know the answer for each of the following questions about the peripheral device:
• Which of the following signal and control lines are actively used during communication with the peripheral?
— Data Set Ready (DSR) — Clear to Send (CTS)
• What baud rate is expected by the peripheral?

Character Format Parameters

To define the character format, you must know the requirements of the peripheral device for the following parameters:
• Character Length: Eight data bits are used for each character, excluding start, stop, and parity bits.
• Parity Enable: Parity is disabled (absent) for each character.
• Stop Bits: One stop bit is included with each character.
1-12 Chapter1
Programming Fundamentals
Overview of RS-232

Modem Line Handshaking

To use modem line handshaking for data transfer you would consider the following tasks:
1. Set Data Terminal Ready and Request-to-Send modem lines to active state.
2. Check Data Set Ready and Clear-to-Send modem lines to be sure they are active.
3. Send information to the interface and thence to the peripheral.
4. After data transfer is complete, clear Data Terminal Ready and Request-to-Send signals.
For ENTER operations:
1. Set Data Terminal Ready line to active state. Leave Request-to-Send inactive.
2. Check Data Set Ready and Data Carrier Detect modem lines to be sure they are active.
3. Input information from the interface as it is received from the peripheral.
4. After the input operation is complete, clear the Data Terminal Ready signal.

Data Transfer Errors

The serial interface can generate several types of errors when certain conditions are encountered while receiving data from the peripheral device. Errors can be generated by any of the following conditions:
• Parity error. The parity bit on an incoming character does not match the parity expected by the receiver.This condition is most commonly caused by line noise.
• Framing error. Start and stop bits do not match the timing expectations of the receiver. This can occur when line noise causes the receiver to miss the start bit or obscures the stop bits.
• Overrun error. Incoming data buffer overrun caused a loss of one or more data characters. This is usually caused when data is received by the interface, but no ENTER statement has been activated to input the information.
• Break received. A BREAK was sent to the interface by the peripheral device. The desktop computer program must be able to properly interpret the meaning of a break and take appropriate action.
Chapter 1 1-13
Programming Fundamentals

Printer Setup and Operation

Printer Setup and Operation

Equipment

• ESA Spectrum Analyzer equipped with Options A4H and Parallel Interface) or 1AX (RS-232 and Parallel Interface).
• IEEE 1284 compliant printer cable (such as C2950A).
• Supported printer equipped with a parallel interface. (A supported printer is one that accepts Printer Control Language Level 3 or 5).
— PCL3 printers include most HP DeskJet printers. — PCL5 printers include most HP LaserJet printers and the 1600C
DeskJet printer.

Interconnection and Setup

1. Turn off the printer and the analyzer.
2. Connect the printer to the analyzer parallel I/O interface connector using an IEEE 1284 compliant parallel printer cable.
3. If appropriate, configure your printer using configuration menus or switches. Refer to your printer’s documentation for more specific information on configuring your printer.
4. Turn on the analyzer and printer.
5. Press
Print Setup on the front panel and then press the Printer Type
menu key. Printer Type accesses the following keys:
None None disables the analyzer from attempting to print
to a printer. This is the appropriate setting if no printer is connected to the analyzer.
Custom Custom allows you to access the Define Custom menu
keys. The
Define Custom menu keys allow you to
specify printer characteristics such as PCL Level and printer color capability.
Auto Auto enables the analyzer to automatically attempt
to identify the connected printer when the is pressed or when
Printer Type is set to Auto.
Print key
1-14 Chapter1
Programming Fundamentals
Printer Setup and Operation
6. Press Printer Type to access the Printer Type menu keys. Press Auto to make the analyzer attempt to identify the connected printer. When you press
Auto, the analyzer will respond in one of the three
following ways:
• The
Print Setup menu will be displayed with the Auto key selected
and no new message will be displayed in the display status line. This indicates that the analyzer has successfully identified the connected printer and no further setup is required. As long as
Auto remains selected in the Printer Type menu, the analyzer will
attempt to identify the printer when the front panel
Print key is
pressed.
• The
Print Setup menu will be displayed with the Custom key
selected and one of the following diagnostic messages will be displayed in the display status line:
Unknown printer, Define Custom to set up printer No printer response, Define Custom to set up
printer Invalid printer response, Define Custom to set up
printer
This indicates that the analyzer was unable to automatically identify the connected printer, and the
Printer Type menu. Press Print Setup, Define Custom to select
Custom has been selected in
specific printer characteristics such as the printer language (PCL3 or PCL5) and color printing capability. Once you have set these characteristics to match those of your connected printer, the printer setup process is complete. As long as selected in the
Printer Type menu, the analyzer will not attempt to
Custom remains
automatically identify the connected printer when the front panel
Print key is pressed.
• The
Print Setup menu will be displayed with the None key selected
and the following message will appear in the display status line:
Unsupported printer, Printer Type set to None
This indicates that the analyzer has successfully identified the connected printer, but the printer is not supported by the analyzer. As long as
None is selected in the Printer Type menu, the
analyzer will respond to any print command by displaying the message Printer Type is None in the display status line.
Chapter 1 1-15
Programming Fundamentals
Printer Setup and Operation

Testing Printer Operation

When you have completed the printer setup for the analyzer, press Print
Setup, Print (Screen) and then press Print on the front panel. If the
printer is ready and the printer setup was successful, a printout of the analyzer display will be printed. If the printer is not ready, the message
Printer Timeout will appear on the analyzer display. Printer Timeout will remain on the display until the printer is ready or until
you press
ESC to cancel the printout request.
1-16 Chapter1

2 Status Registers

This chapter contains a comprehensive description of status registers explaining what status registers are and how to use them. Information pertaining to all bits of the registers in Agilent ESA analyzers is also provided.
2-1
Status Registers

Use Status Registers to Determine the State of Analyzer Events and Conditions

Use Status Registers to Determine the State of Analyzer Events and Conditions
Programs often need to detect and manage error conditions or changes in analyzer status. Agilent ESA products allow this function to be performed using status registers. You can determine the state of certain analyzer hardware and firmware events and conditions by programming the status register system.
Refer to Figure 2-1. The status system is comprised of multiple registers arranged in a hierarchical order. The service request enable register is at the top of the hierarchy and contains the general status information for the analyzer events and conditions. The lower-priority status registers propagate their data to the higher-priority registers in the data structures by means of summary bits. These registers are used to determine the states of specific events or conditions.
The two methods used to programmatically access the information in status registers are the polling method and the service request method. An explanation of these methods is given in the next section “What are
the Status Registers?”
2-2 Chapter2
Use Status Registers to Determine the State of Analyzer Events and Conditions
Figure 2-1 Status Register System Simplified Block Diagram
Status Registers

What are the Status Registers?

Refer to Figure 2-2, which shows the overall status register system in detail. Most status registers are composed of the five individual registers described below. One such status register in the figure is entitled “STATus: QUEStionable,” which is both the name of the register, and the SCPI command form used to access the register. From now on, the SCPI command form will be used when referring to the various registers. There are IEEE common SCPI commands noted under some register names in parenthesis. These commands are associated with those registers, and their effects are described under
“How Do You Access the Status Registers?” in this chapter, and in the
beginning of Chapter 5, “Language Reference” in this guide.
Chapter 2 2-3
Status Registers
Use Status Registers to Determine the State of Analyzer Events and Conditions
Refer to the right-hand part of the STATus: QUEStionable register while reading the following register descriptions.
Condition Register A condition register continuously monitors the
hardware and firmware status of the analyzer. There is no latching or buffering for a condition register.
Negative Transition Filter A negative transition filter specifies the bits in the
condition register that will set corresponding bits in the event register when the condition bit changes from 1 to 0.
Positive Transition Filter A positive transition filter specifies the bits in the
condition register that will set corresponding bits in the event register when the condition bit changes from 0 to 1.
Event Register An event register latches transition events from the
condition register as specified by the positive and negative transition filters. Bits in the event register are latched, and once set, they remain set until cleared by either querying the register contents or sending the *CLS command.
Event Enable Register An event enable register specifies the bits in the event
register that can generate a summary bit. Summary bits are, in turn, used by the status byte register.
2-4 Chapter2
Use Status Registers to Determine the State of Analyzer Events and Conditions
Figure 2-2 Overall Status Register System
Status Registers
Chapter 2 2-5
Status Registers
Use Status Registers to Determine the State of Analyzer Events and Conditions
Status registers (except for the status byte register and the standard event status register) consist of the registers whose contents can be used to produce status summary bits.
These summary bits are then manipulated as follows: The condition register passes summary bits to the negative and positive transition filters, after which they are stored in the event register. The contents of the event register are logically ANDed with the contents of the event enable register and the result is logically ORed to produce a status summary bit. The status summary bit is then passed to the status byte register either directly, or through the STATus: QUEStionable register. Next, the summary bits are logically ANDed with the contents of the service request enable register and the result is logically ORed to produce the request service (*RQS) bit in the status byte register.

How Do You Access the Status Registers?

There are two different methods to access the status registers:
• Common Commands Accesses and Controls
• Status Subsystem Commands
Common Command Access and Control
Most monitoring of the analyzer conditions is done at the highest level using the following IEEE common commands:
*CLS (clear status) clears the status byte by emptying the error queue and clearing all the event registers.
*ESE,*ESE? (event status enable) sets and queries the bits in the enable register part of the standard event status register.
*ESR? (event status register) queries and clears the standard event status register.
*OPC (operation complete) sets bit 0 in the standard event status register when all operations are complete.
*SRE,*SRE? (service request enable) sets and queries the value of the service request enable register.
*STB? (status byte) queries the value of the status byte register without erasing its contents.
Complete command descriptions are given in Chapter 5, “Language
Reference” under the subsection entitled “IEEE Common Commands”
on page 5-5.
2-6 Chapter2
Status Registers
Use Status Registers to Determine the State of Analyzer Events and Conditions
NOTE If you are using the status bits and the analyzer mode is changed, the
status bits should be read, and any error conditions resolved, prior to switching modes. Error conditions that exist prior to switching modes cannot be detected using the condition registers after the mode change. This is true unless they recur after the mode change, although transitions of these conditions can be detected using the event registers.
Changing modes resets all SCPI status registers and mask registers to their power-on defaults. Hence any event or condition register masks must be re-established after a mode change. Also note that the power up status bit is set by any mode change, since that is the default state after power up.
Status Subsystem Commands
Individual status registers can be set and queried using the commands in the STATus subsystem in Chapter 5, “Language Reference” in this guide. There are two methods used to programmatically detect and manage error conditions or changes in analyzer status. Either method allows you to monitor one or more conditions. The two methods are:
• The Polling Method
• The Service Request (SRQ) Method
The Polling Method
In the polling method, the analyzer has a passive role. It only tells the controller that conditions have changed when the controller asks the right question. The polling method works well if you do not need to know about changes the moment they occur. This method is very efficient.
Use the polling method when either: — your programming language/development environment does not
support SRQ interrupts
— you want to write a simple, single-purpose program and don’t want
the added complexity of setting up an SRQ handler
The Service Request (SRQ) Method
The SRQ method allows timely communication of information without requiring continuous controller involvement. Using this method, the analyzer takes a more active role. It tells the controller when there has been a condition changewithoutthe controller asking. The SRQ method should be used if you must know immediately when a condition changes. This is in contrast to the polling method, which requires the program to repeatedly read the registers to detect a change.
Use the SRQ method when either: — you need time-critical notification of changes
Chapter 2 2-7
Status Registers
Use Status Registers to Determine the State of Analyzer Events and Conditions
— you are monitoring more than one device which supports SRQs — you need to have the controller do something else while the analyzer
is making a measurement
— you can’t afford the performance penalty inherent to polling

Using the Service Request (SRQ) Method

Your language, bus, and programming environment must be able to support SRQ interrupts (for example, using C and C++ with the GPIB). When you monitor a condition with the SRQ method, you must establish the following parameters:
1. Determine which bit monitors the condition.
2. Determine how that bit reports to the request service (RQS) bit of the status byte.
3. Send GPIB commands to enable the bits that monitor the condition and to enable the summary bits that report the condition to the RQS bit.
4. Enable the controller to respond to service requests.
When the condition changes, the analyzer sets the RQS bit and the GPIB SRQ line. The controller is informed of the change as soon as it occurs. The time the controller would otherwise have used to monitor the condition can now be used to perform other tasks. Your program
also determines how the controller responds to the SRQ.

Generating a Service Request

Before using the SRQ method of generating a service request, first become familiar with how service requests are generated. Bit 6 of the status byte register is the request service summary (RQS) bit. The RQS bit is set whenever there is a change in the register bit that it has been configured to monitor. The RQS bit will remain set until the condition that caused it is cleared. It can be queried without erasing the contents using the *STB? command. Configure the RQS function using the *SRE command.
When a register set causes a summary bit in the status byte to change from 0 to 1, the analyzer can initiate the service request (SRQ) process. However, the process is only initiated if both of the following conditions are true:
• The corresponding bit of the service request enable register is also set to 1.
• The analyzer does not have a service request pending. (A service request is considered to be pending between the time the analyzer SRQ process is initiated, and the time the controller reads the status byte register.)
2-8 Chapter2
Status Registers
Use Status Registers to Determine the State of Analyzer Events and Conditions
The SRQ process sets the GPIB SRQ line true. It also sets the status byte request service (RQS) bit to 1. Both actions are necessary to inform the controller that the analyzer requires service. Setting the SRQ line only informs the controller that some device on the bus requires service. Setting the RQS bit allows the controller to determine which device requires service.
If your program enables the controller to detect and respond to service requests, it should instruct the controller to perform a serial poll when the GPIB SRQ line is set true. Each device on the bus returns the contents of its status byte register in response to this poll. The device, whose RQS bit is set to 1, is the device that requested service.
NOTE When you read the analyzer status byte register with a serial poll, the
RQS bit is reset to 0. Other bits in the register are not affected. Restarting a measurement with the :INITiate command can cause the
measuring bit to pulse low. A low pulse causes an SRQ if the status register is configured to SRQ upon end-of-measurement. To avoid this, perform the following steps:
1. Set :INITiate:CONTinuous off.
2. Set/enable the status registers.
3. Restart the measurement (send :INITiate).
Example of Monitoring Conditions Using the :STATus Command
Use the following steps to monitor a specific condition:
1. Determine which register contains the bit that reports the condition.
2. Send the unique SCPI query that reads that register.
3. Examine the bit to see if the condition has changed.
4. Act upon the cause of the condition and the SRQ to re-enable the method.
The examples below show how to use the :STATus command to perform the following tasks:
• Check the analyzer hardware and firmware status. Do this by querying the condition registers which continuously
monitor status. These registers represent the current state of the analyzer. Bits in a condition register are updated in real time. When the condition monitored by a particular bit becomes true, the bit is set to 1. When the condition becomes false, the bit is reset to 0.
• Monitor a particular bit (condition), or bits.
Chapter 2 2-9
Status Registers
Use Status Registers to Determine the State of Analyzer Events and Conditions
Once you have enabled a bit using the event enable register, the analyzer will monitor that particular bit. If the bit becomes true in the event register it will stay set until the event register is cleared. Querying the event register allows you to detect that this condition occurred even if the condition no longer exists. The event register can only be cleared by querying it or sending the *CLS command, which clears all event registers.
• Monitor a change in the condition of a particular bit, or bits. Once you have enabled a bit, the analyzer will monitor it for a
change in its condition. The transition registers are preset to respond to the condition of going from 0 to 1 (positive transitions). This can be changed so that the selected bit is detected if it goes from 1 to 0 (negative transition), or if either transition occurs. Query the event register to determine whether or not a change has been made to how the transition registers respond. The event register can only be cleared by querying it or sending the *CLS command, which clears
all event registers.

Setting and Querying the Status Register

See Figure 2-3. Each bit in a register is represented by a numerical value based on its location. This number is sent with the command to enable a particular bit. Toenable more than one bit, send the sum of all of the bits involved.
For example, to enable bit 0 and bit 6 of the standard event status register, you would send the command *ESE 65 (1 + 64).
The results of a query are evaluated in a similar way. If the *STB? command returns a decimal value of 140, (140 = 128 + 8 + 4) then bit 7 is true, bit 3 is true, and bit 2 is true.
Figure 2-3 Status Register Bit Values
1024
512
Decimal Value
32768
16384
8192
4096
2048
256
128
64
32
16
8
2
4
1
Bit Number
89101112131415
7
6
2-10 Chapter2
432
5
0
1
ck730a
Use Status Registers to Determine the State of Analyzer Events and Conditions

Details of Bits in All Registers

Refer to Figure 2-2. The rest of this chapter lists the bits in each register shown in the figure, along with descriptions of their purpose.

Status Byte Register

Figure 2-4 Status Byte Register
Status Byte Register
Unused
0
Unused
1
Error/Event Queue Summary Bit
2
Questionable Summary BitStatus
3
Message Available (MAV)
4
Standard Event Summary Bit
5
Request Service Summary (RQS)
6
Operation Summary BitStatus
7
Status Registers
&
&
&
&
&
&
&
2
1
0
4
3
6
5
7
Service Request Enable Register
+
ck763a
Chapter 2 2-11
Figure 2-5
Status Registers
Use Status Registers to Determine the State of Analyzer Events and Conditions
The status byte register contains the following bits:
Description
Operation S Summary Bittatus
Bit Number 76543210
Request Service (RQS) Summary Bit
Standard Event Status Summary Bit
*STB?
Message Available (MAV)
Questionable Summary BitStatus
Error/Event Queue Summary Bit
Unused
Unused
Status Byte Register
Bit Description
0, 1 These bits are always set to 0.
2 A 1 in this bit position indicates that the SCPI error queue is not empty. The SCPI error
queue contains at least one error message.
3 A 1 in this bit position indicates that the questionable status summary bit has been set.
The questionable status event register can then be read to determine the specific condition that caused this bit to be set.
4 A 1 in this bit position indicates that the analyzer has data ready in the output queue.
There are no lower status groups that provide input to this bit.
5 A 1 in this bit position indicates that the standard event status summary bit has been
set. The standard event status register can then be read to determine the specific event that caused this bit to be set.
6 A 1 in this bit position indicates that the analyzer has at least one reason to report a
status change. This bit is also called the master summary status bit (MSS).
ck764a
7 A 1 in this bit position indicates that the operation status summary bit has been set. The
operation status event register can then be read to determine the specific event that caused this bit to be set.
To query the status byte register, send the *STB command. The response will be the decimal sum of the bits that are set to 1. For example, if bit number 7 and bit number 3 are set to 1, the decimal sum of the 2 bits is 128 plus 8. So the decimal value 136 is returned.
2-12 Chapter2
Status Registers
Use Status Registers to Determine the State of Analyzer Events and Conditions

Service Request Enable Register

In addition to the status byte register, the status byte group also contains the service request enable register. The status byte service request enable register lets you choose which bits in the Status Byte Register will trigger a service request.
Send the *SRE <number> command (where <number> is the sum of the decimal values of the bits you want to enable plus the decimal value of bit 6). For example, assume that you want to enable bit 7 so that whenever the operation status summary bit is set to 1, it will trigger a service request. Send the *SRE 192 (128 + 64) command. The *SRE? command returns the decimal value of the sum of the bits enabled previously with the *SRE <number> command.
NOTE You must always add 64 (the numeric value of RQS bit 6) to your
numeric sum when you enable any bits for a service request. The service request enable register contains the following bits:
Figure 2-6
4
1
Decimal Value
Bit Number
128
7
6
64
54
*SRE <num> *SRE?
32
16
3
8
2
Service Request Enable Register
NOTE The service request enable register presets to zeros (0).
2
1
0
ck726a
Chapter 2 2-13
Status Registers
Use Status Registers to Determine the State of Analyzer Events and Conditions

Standard Event Status Register

The standard event status register is used to determine the specific event that sets bit 5 in the status byte register. The standard event status register does not have negative and positive transition registers, nor a condition register. Use the IEEE common commands at the beginning of Chapter 5, “Language Reference” in this guide to access the register.
To query the standard event status register, send the *ESR command. The response will be the decimal sum of the bits which are set to 1. For example, if bit number 7 and bit number 3 are set to 1, the decimal sum of the 2 bits is 128 plus 8. So the decimal value 136 is returned.
Figure 2-7 Standard Event Status Register
Operation Complete
Request Bus Control
Query Error
Device Dependent Error
Execution Error
Command Error
User Request
Power On
Event Register
&
+
Event Enable Register
To Status Byte Register Bit #5
01234567
&
&
&
&
&
&
&
01234567
ck723a
2-14 Chapter2
Figure 2-8
Status Registers
Use Status Registers to Determine the State of Analyzer Events and Conditions
The standard event status register contains the following bits:
Description
Request Bus Control
1
0
Operation Complete
Bit Number
7
Power On
User Request Key (Local)
6
Command Error
54
*ESR?
Execution Error
Device Dependent Error
3
Query Error
2
Standard Event Status Register
Bit Description
0 A 1 in this bit position indicates that all operations were completed following execution of
the *OPC command. 1 This bit is always set to 0. (The analyzer does not request control.) 2 A 1 in this bit position indicates that a query error has occurred. Query errors have SCPI
error numbers from −499 to –400. 3 A 1 in this bit position indicates that a device dependent error has occurred. Device
dependent errors have SCPI error numbers from –399 to –300 and 1 to 32767. 4 A 1 in this bit position indicates that an execution error has occurred. Execution errors
have SCPI error numbers from –299 to –200. 5 A 1 in this bit position indicates that a command error has occurred. Command errors
have SCPI error numbers from –199 to –100. 6 A 1 in this bit position indicates that the LOCAL key has been pressed. This is true even if
the analyzer is in local lockout mode.
ck765a
7 A 1 in this bit position indicates that the analyzer has been turned off and then on.
Chapter 2 2-15
Figure 2-9
Status Registers
Use Status Registers to Determine the State of Analyzer Events and Conditions

Standard Event Status Event Enable Register

The event enable register (contained in the standard event status register) lets you choose which bits will set the summary bit (bit 5 of the status byte register) to 1. Send the *ESE <number> command (where <number> is the sum of the decimal values of the bits you want to enable).
For example, to enable bit 7 and bit 6 so that whenever either of those bits is set to 1, the standard event status summary bit of the status byte register will also be set to 1, send the *ESE 192 (128 + 64) command. The *ESE? command returns the decimal value of the sum of the bits previously enabled with the *ESE <number> command.
Decimal Value
Bit Number
Standard Event Status Enable Register
128
7
6
64
54
*ESE <num> *ESE?
32
16
3
8
2
4
1
2
1
0
ck728a
2-16 Chapter2
Use Status Registers to Determine the State of Analyzer Events and Conditions

STATus:OPERation Register

The STATus:OPERation register is used to determine the specific event that sets bit 7 in the status byte register. This register also monitors the current measurement state and checks to see if the analyzer is performing any of these functions:
• measuring
• calibrating
• sweeping
• waiting for a trigger
Figure 2-10 STATus:OPERation Register
Status Registers
Chapter 2 2-17
Status Registers
Use Status Registers to Determine the State of Analyzer Events and Conditions

STATus:OPERation Condition Register

The STATus:OPERation condition register continuously monitors the hardware and firmware status of the analyzer, and is read-only. To query the register, send the :STATus:OPERation:CONDition? command. The response will be the decimal sum of the bits that are set to 1. For example, if bit number 9 and bit number 3 are set to 1, the decimal sum of the 2 bits is 512 plus 8. So the decimal value 520 is returned.
The transition filter specifies which types of bit state changes in the condition register will set corresponding bits in the event register. The changes may be positive (from 0 to 1) or negative (from 1 to 0). Send the :STATus:OPERation:NTRansition <num> (negative transition) command or the :STATus:OPERation:PTRansition <num> (positive transition) command (where <num> is the sum of the decimal values of the bits you want to enable).
The STATus:OPERation event register latches transition events from the condition register as specified by the transition filters. Event registers are destructive read-only data. Reading data from an event register will clear the content of that register. To query the event register, send the :STATus:OPERation:[:EVENt]? command.
Figure 2-11
The STATus:OPERation condition register contains the following bits:
2-18 Chapter2
Status Registers
Use Status Registers to Determine the State of Analyzer Events and Conditions
Bit Description
0 A 1 in this bit position indicates that the analyzer is
performing a self-calibration.
1, 2 Unused. These bits are always set to 0.
3 A 1 in this bit position indicates that a sweep is in
progress.
a
4
5 A 1 in this bit position indicates that a measurement is in
6, 7 Unused. These bits are always set to 0.
b
8
9–14 Reserved. These bits are not used by the analyzer,but are
15 Always Zero (0).
A 1 in this bit position indicates that a measurement is in progress.
a “wait for trigger” state.
A 1 in this bit position indicates that the instrument is in the paused state of the measurement.
for future use with other Agilent products.
a. The description of this bit refers to any measurement under
the
MEASURE key.
b. This bit applies to ESA optional measurement personalities
only, and may or may not be implemented in all such person­alities.

STATus:OPERation Event Enable Register

The STATus:OPERation event enable register lets you choose the bits that will set the operation status summary bit (bit 7) of the status byte register to 1. Send the :STATus:OPERation:ENABle <num> command where <num> is the sum of the decimal values of the bits you want to enable.
Forexample, to enable bit 9 and bit 3 (so that whenever either bit 9 or 3 is set to 1, the operation status summary bit of the status byte register will be set to 1), send the :STATus:OPERation:ENABle 520 (512 + 8) command. The :STATus:OPERation:ENABle? command returns the decimal value of the sum of the bits previously enabled with the :STATus:OPERation:ENABle <num> command.
Chapter 2 2-19
Figure 2-12
Status Registers
Use Status Registers to Determine the State of Analyzer Events and Conditions
Decimal Value
Bit Number
Operation Event Enable RegisterStatus

STATus:QUEStionable Registers

STATus:QUEStionable registers monitor the overall analyzer condition. They are accessed with the :STATus:OPERation and :STATus:QUEStionable commands in the :STATus command subsystem.
The STATus:QUEStionable registers also monitor the analyzer to see if there are any questionable events that occurred. These registers look for anything that may cause an error or that may induce a faulty measurement. Signs of a faulty measurement include the following:
• hardware problems
• out of calibration situations
• unusual signals
512
256
32768
16384
8192
2048
1024
4096
89101112131415
STATus:OPERation:ENABle <num> STATus:OPERation:ENABle?
128
7
6
64
32
432
5
16
8
1
2
4
1
0
ck767a
NOTE All bits are summary bits from lower-level event registers. (For a
general diagram of the STATus:QUEStionable register, see Figure 2-13 on page 2-21.)
2-20 Chapter2
Use Status Registers to Determine the State of Analyzer Events and Conditions
Figure 2-13 STATus:QUEStionable Register
Reserved Reserved Reserved POWer Summary Reserved FREQuency Summary Reserved Reserved
CALibration Summary INTregrity Sum
Reserved Reserved Reserved Reserved Reserved Always Zero (0)
Status Registers
QUEStionable Condition Register
QUEStionable Positive Transition Filter
QUEStionable Negative Transition Filter
QUEStionable Event Register
+
QUEStionable Event Enable Register
Status
Status
Status
Status
Status
012345678910111214 1315
3
45678910111214 1315
3
45678910111214 1315
3
45678910111214 1315
&
&
&
&
&
&
&
&
&
&
&
&
&
012
012
012
&
&
&
012345678910111214 1315
To Status Byte Register Bit #3
Chapter 2 2-21
ck759a
Status Registers
Use Status Registers to Determine the State of Analyzer Events and Conditions

STATus:QUEStionable:POWer Condition Register Bits

Bit
00Reserved This bit is not used by the analyzer, but is
12Source Unleveled A 1 in this bit position indicates
24Source LO Unleveled A 1 in this bit position
38LO Unleveled A 1 in this bit position indicates that
41650 MHz Osc Unleveled A 1 in this bit position
532Reserved This bit is not used by the analyzer, but is
664Input Overload Tripped A 1 in this bit position
Decimal
Value
Description
for future use with other Agilent products.
that the source (tracking generator) output is unlevelled.
indicates that the local oscillator (LO) in the source (tracking generator) is unlevelled.
the analyzer local oscillator (LO) is unlevelled.
indicates that the 50 MHz amplitude reference signal is unlevelled.
for future use with other Agilent products.
indicates that the input overload protection is tripped (Agilent ESA models E4401B and E4411B only).
7 128 LO Out Unleveled A 1 in this bit position indicates
that the first local oscillator (LO) output is unlevelled. (Agilent ESA model E4407B option AYZ, External Mixing, only).
8–14 ––– Unused These bits are always set to 0.
15 32768 Always Zero (0) This bit is always set to 0.

STATus:QUEStionable:FREQuency Condition Register Bits

Bit
00Source Synth Unlocked A 1 in this bit position
12Freq Ref Unlocked A 1 in this bit position indicates
2, 3 4, 8 Reserved This bit is not used by the analyzer, but is
Decimal
Value
Description
indicates that the synthesizer in the source (tracking generator) is unlocked.
that the analyzer frequency reference is unlocked.
for future use with other Agilent products.
2-22 Chapter2
Status Registers
Use Status Registers to Determine the State of Analyzer Events and Conditions
Bit
416Synth Unlocked A 1 in this bit position indicates
532Invalid BW A 1 in this bit position indicates that an
6–8 ––– Reserved These bits are not used by the analyzer, but
9–14 ––– Unused These bits are always set to 0.
15 32768 Always Zero (0) This bit is always set to 0.
Decimal
Value
Description
that the analyzer synthesizer is unlocked.
invalid bandwidth setting has been requested.
are for future use with other Agilent products.

STATus:QUEStionable:CALibration Condition Register Bits

Bit
0, 1 0, 2 Reserved These bits are not used by the analyzer, but
Decimal
Value
Description
are for future use with other Agilent products.
24TG Align Failure A 1 in this bit position indicates
that a failure has occurred while trying to align the tracking generator (TG).
38RF Align Failure A 1 in this bit position indicates
that a failure has occurred while trying to align the RF section.
416IF Align Failure A 1 in this bit position indicates
that a failure has occurred while trying to align the IF section.
532LO Align Failure A 1 in this bit position indicates
that a failure has occurred while trying to align the local oscillator (LO).
664ADC Align Failure A 1 in this bit position indicates
that a failure has occurred while trying to align the analog-to-digital converter (ADC).
7 128 FM Demod Align Failure A 1 in this bit position
indicates that a failure has occurred while trying to align the FM demodulation circuitry. (Agilent ESA models E4401B, E4402B, E4404B, E4405B, and E4407B Option BAA, FM Demodulation, only).
Chapter 2 2-23
Status Registers
Use Status Registers to Determine the State of Analyzer Events and Conditions
Bit
8 256 Qpeak Align Failure A 1 in this bit position
9 512 Unused This bit is always set to 0.
10 1024 Tracking Peak Needed A 1 in this bit position
11 2048 Align RF Skipped A 1 in this bit position indicates
12 4096 Align RF Needed A 1 in this bit position indicates
13 8192 Reserved This bit is not used by the analyzer, but is
Decimal
Value
Description
indicates that a failure has occurred while trying to align the quasi-peak detector. (Agilent ESA- E700A Series models only).
indicates that a tracking peak needs to be performed (the tracking generator is in operation). (Agilent ESA models E4402B, E4403B, E4405B, E4407B, and E4408B, Option 1DN, Tracking Generator, only).
that the alignment of the RF section was skipped, perhaps due to an external 50 MHz signal having been detected.
that the RF section needs to be aligned.
for future use with other Agilent products.
14 16384 Align Needed A 1 in this bit position indicates that
a full alignment is needed, perhaps due to a large temperature change having been detected with auto align off, or due to default data being used.
15 32768 Always Zero (0) This bit is always set to 0.

STATus:QUEStionable:INTegrity Condition Register Bits

Bit
00Reserved This bit is not used by the analyzer, but is
a
1
a
2
38Data Uncalibrated Summary This is the summary
Decimal
Value
for future use with other Agilent products.
2 No Result Available A 1 in this bit position
indicates that a measurement terminated with no measurement results.
4 Measurement Timeout A 1 in this bit position
indicates that a measurement terminated due to a timeout.
bit for the QuestionableStatus Integrity Uncalibrated Register.
Description
2-24 Chapter2
Status Registers
Use Status Registers to Determine the State of Analyzer Events and Conditions
Bit
Decimal
Value
Description
416IF/ADC Over Range The signal input level is too
high, causing the analyzer analog-to-digital converter (ADC) range to be exceeded. This may occur with resolution bandwidths less than or equal to 300 Hz in zero span. (Agilent ESA models E4401B, E4402B, E4404B, E4405B, and E4407B only).
a
5
32 Over Range A 1 in this bit position indicates that the
signal is too large at the analog-to-digital converter (ADC).
a
6
64 Under Range A 1 in this bit position indicates that
the signal is too small at the analog-to-digital converter (ADC).
a
7
128 Insufficient Data A 1 in this bit position
indicates that there is not enough information to perform the measurement or function.
a
8
256 Acquisition Failure A 1 in this bit position
indicates that the demod algorithm cannot correlate to the signal.
a
9
512 Memory Problem A 1 in this bit position indicates a
failure of the file system memory or digital signal processor (DSP) memory.
10
a
1024 Auto-Trigger Timeout A 1 in this bit position
indicates that the measurement timed out due to no trigger.
11
a
2048 Trigger Problem A 1 in this bit position indicates
that the measurement timed out due to no trigger.
12 4096 Invalid Data A 1 in this bit position indicates that
the present trace data does not reflect the existing analyzer state. Trigger a new sweep and/or measurement.
13
a
8192 Unidentified Error A 1 in this bit position
indicates that a measurement has terminated for a reason other than that given in any of the other bits.
14
a
16384 Setting Limited/Readjusted A 1 in this bit
position indicates that the user settings could not be achieved with the existing hardware; values were set to limits.
15 32768 Always Zero (0) This bit is always set to 0.
a. This bit applies to ESA optional measurement personalities
only, and may or may not be implemented in all such person­alities.
Chapter 2 2-25
Status Registers
Use Status Registers to Determine the State of Analyzer Events and Conditions

STATus:QUEStionable:INTegrity:UNCalibrated Condition Register Bits

Bit
00Oversweep (Meas Uncal) A 1 in this position
12Signal Ident ON A 1 in this bit position indicates
2–14 ––– Reserved These bits are not used by the analyzer, but
15 32768 Always Zero (0) This bit is always set to 0.
Decimal
Value
Description
indicates that the anlyzer is in a state that could lead to uncalibrated measurements. This is typically caused by sweeping too fast for the current combination of span, resolution bandwidth, and video bandwidth. Auto coupling may resolve this problem.
that amplitude measurements may be in error due to signal identification routines being active. Amplitude accuracy is degraded when signal identification is active. (Agilent ESA model E4407B Option AYZ, External Mixing, only).
are for future use with other Agilent products.
2-26 Chapter2
3 Programming Examples
This chapter includes examples of how to program the analyzer using the analyzer SCPI programming commands. Twelve examples are written for an analyzer with an HP-IB interface (Option A4H). Three examples are written for an analyzer with an RS-232 interface (Option 1AX).
3-1
Programming Examples

List of Programming Examples

List of Programming Examples
The programming examples included in this chapter are:
“Using Marker Peak Search and Peak Excursion” on page 3-12 “Using Marker Delta Mode and Marker Minimum Search” on
page 3-16 “Performing Internal Self-alignment” on page 3-20 “Reading Trace Data using ASCII Format (HP-IB)” on page 3-24 “Reading Trace Data Using 32-bit Real Format (HP-IB)” on
page 3-29 “Reading Trace Data Using ASCII Format (RS-232)” on page 3-34 “Reading Trace Data Using 32-bit Real Format (RS-232)” on
page 3-39 “Using Limit Lines” on page 3-44 “Measuring Noise” on page 3-49 “Entering Amplitude Correction Data” on page 3-53 “Status Register–Determine When a Measurement is Done” on
page 3-57 “Determine if an Error has Occurred” on page 3-63 “Measuring Harmonic Distortion (HP-IB)” on page 3-69 “Measuring Harmonic Distortion (RS-232)” on page 3-78 “Making Faster Measurements (multiple measurements)” on
page 3-87
3-2 Chapter3
Programming Examples

Programming Examples System Requirements

Programming Examples System Requirements
These examples were written for use on an IBM compatible PC configured as follows:
Pentium processorWindows 95 or Windows NT 4.0 operating systemC programming languageHP/Agilent 82341C HP-IB interface card (for ESAs with Option
A4H)
HP VISA Transition Libraries (VTL)COM1 serial port configured as follows (for ESAs with Option 1AX)
• 9600 baud
• 8 data bits
• 1 stop bit
• no parity bits
• hardware flow control
A National Instruments GPIB card may be substituted for the HP/Agilent 82341C, and the National Instruments VISA libraries may be substituted for the HP VISA Transition Libraries. If substitutions are made, the subdirectories for the include and library files will be different than those listed in the following paragraphs. Refer to the documentation for your interface card and the VISA libraries for details.
Chapter 3 3-3
Programming Examples

C Programming Examples using VTL

C Programming Examples using VTL
The programming examples that are provided in this guide are written using the C programming language and the VTL (VISA transition library). This section includes some basic information about programming in the C language. Refer to your C programming language documentation for more details. (This information is taken from the manual “HP VISA Transition Library”, HP part number E2090-90026.) If you are using the National Instruments VISA library, most of this information will still apply, but the include and library files will be in different subdirectories. Also, this information assumes a computer running a Windows 95 operating system with an HP/Agilent 82341C HP-IB interface card is being used. The following topics are included:
“Typical Example Program Contents” on page 3-4 “Linking to VTL Libraries” on page 3-5 “Compiling and Linking a VTL Program” on page 3-5 “Example Program” on page 3-7 “Including the VISA Declarations File” on page 3-7 “Opening a Session” on page 3-8 “Device Sessions” on page 3-8 “Addressing a Session” on page 3-10 “Closing a Session” on page 3-11

Typical Example Program Contents

The following is a summary of the VTL function calls used in the example programs.
visa.h This file is included at the beginning of the file to
provide the function prototypes and constants defined by VTL.
ViSession The ViSession is a VTL data type. Each object that
will establish a communication channel must be defined as ViSession.
viOpenDefaultRM You must first open a session with the default
resource manager with the viOpenDefaultRM function. This function will initialize the default resource manager and return a pointer to that resource manager session.
viOpen This function establishes a communication channel
with the device specified. A session identifier that can be used with other VTL functions is returned. This call must be made for each device you will be using.
3-4 Chapter3
Programming Examples
C Programming Examples using VTL
viPrintf viScanf These are the VTL formatted I/O functions that are
patterned after those used in the C programming language. The viPrintf call sends the SCPI commands to the analyzer. The viPrintf call can also be used to query the analyzer. The viScanf call is then used to read the results.
viClose This function must be used to close each session. When
you close a device session, all data structures that had been allocated for the session will be deallocated. When you close the default manager session, all sessions opened using the default manager session will be closed.

Linking to VTL Libraries

Your application must link to one of the VTL import libraries: 32-bit Version (assumes Windows 95 operating system):
C:\VXIPNP\WIN95\LIB\MSC\VISA32.LIB for Microsoft compilers C:\VXIPNP\WIN95\LIB\BC\VISA32.LIB for Borland compilers
16-bit Version:
C:\VXIPNP\WIN\LIB\MSC\VISA.LIB for Microsoft compilers C:\VXIPNP\WIN\LIB\BC\VISA.LIB for Borland compilers
See the following section for information on how to use the VTL run-time libraries.

Compiling and Linking a VTL Program

32-bit Applications (assumes Windows 95 operating system)
The following is a summary of important compiler-specific considerations for several C/C++ compiler products when developing WIN32 applications.
For Microsoft Visual C++ version 2.0 compilers:
• Select Project | Update All Dependencies from the menu.
• Select Project | Settings from the menu. Click on the C/C++ button. Select Code Generation from the Use Run-Time Libraries list box. VTL requires these definitions for WIN32. Click on OK to close the dialog boxes.
Chapter 3 3-5
Programming Examples
C Programming Examples using VTL
• Select Project | Settings from the menu. Click on the Link button and add visa32.lib to the Object / Library Modules list box. Optionally, you may add the library directly to your project file. Click on OK to close the dialog boxes.
• You may wish to add the include file and library file search paths. They are set by doing the following:
1. Select Tools | Options from the menu.
2. Click on the Directories button to set the include file path.
3. Select Include Files from the Show Directories For list
box.
4. Click on the Add button and type in the following:
C:\VXIPNP\WIN95\INCLUDE
5. Select Library Files from the Show Directories For list
box.
6. Click on the Add button and type in the following:
C:\VXIPNP\WIN95\LIB\MSC
For Borland C++ version 4.0 compilers:
• You may wish to add the include file and library file search paths. They are set under the Options | Project menu selection. Double click on Directories from the Topics list box and add the following:
C:\VXIPNP\WIN95\INCLUDE C:\VXIPNP\WIN95\LIB\BC
16-bit Applications
The following is a summary of important compiler-specific considerations for the Windows compiler.
For Microsoft Visual C++ version 1.5:
• To set the memory model, do the following:
1. Select Options | Project.
2. Click on the Compiler button, then select Memory Model from
the Category list.
3. Click on the Model list arrow to display the model options, and
select Large.
4. Click on OK to close the Compiler dialog box.
• You may wish to add the include file and library file search paths. They are set under the Options | Directories menu selection:
C:\VXIPNP\WIN\INCLUDE
3-6 Chapter3
Programming Examples
C Programming Examples using VTL
C:\VXIPNP\WIN\LIB\MSC
Otherwise, the library and include files should be explicitly specified in the project file.

Example Program

This example program queries a GPIB device for an identification string and prints the results. Note that you must change the address if something other than the ESA default value of 18 is required.
/*idn.c - program filename */
#include "visa.h" #include <stdio.h>
void main () {
/*Open session to HP-IB device at address 18 */
ViOpenDefaultRM(&defaultRM); ViOpen(defaultRM, “GPIB0::18::INSTR”, VI_NULL,
VI_NULL, &vi);
/*Initialize device */
viPrintf(vi, “*RST\n”);
/*Send an *IDN? string to the device */
printf(vi, “*IDN?\n”);
/*Read results */
viScanf(vi, "%t", &buf);
/*Print results */
printf(“Instrument identification string: %s\n”, buf);
/* Close the sessions */
viClose(vi); viClose(defaultRM);
}

Including the VISA Declarations File

For C and C++ programs, you must include the visa.h header file at the beginning of every file that contains VTL function calls:
#include “visa.h”
This header file contains the VISA function prototypes and the definitions for all VISA constants and error codes. The visa.h header file includes the visatype.h header file.
Chapter 3 3-7
Programming Examples
C Programming Examples using VTL
The visatype.h header file defines most of the VISA types. The VISA types are used throughout VTL to specify data types used in the functions. For example, the viOpenDefaultRM function requires a pointer to a parameter of type ViSession. If you find ViSession in the visatype.h header file, you will find that ViSession is eventually typed as an unsigned long.

Opening a Session

A session is a channel of communication. Sessions must first be opened on the default resource manager, and then for each device you will be using. The following is a summary of sessions that can be opened:
•Aresource manager session is used to initialize the VISA system. It is a parent session that knows about all the opened sessions. A resource manager session must be opened before any other session can be opened.
•Adevice session is used to communicate with a device on an interface. A device session must be opened for each device you will be using. When you use a device session you can communicate without worrying about the type of interface to which it is connected. This insulation makes applications more robust and portable across interfaces. Typically a device is an instrument, but could be a computer, a plotter, or a printer.
NOTE All devices that you will be using need to be connected and in working
condition prior to the first VTL function call (viOpenDefaultRM). The system is configured only on the first viOpenDefaultRM per process. Therefore, if viOpenDefaultRM is called without devices connected and then called again when devices are connected, the devices will not be recognized. You must close ALL resource manager sessions and re-open with all devices connected and in working condition.

Device Sessions

There are two parts to opening a communications session with a specific device. First you must open a session to the default resource manager with the viOpenDefaultRM function. The first call to this function initializes the default resource manager and returns a session to that resource manager session. You only need to open the default manager session once. However, subsequent calls to viOpenDefaultRM returns a session to a unique session to the same default resource manager resource.
Next, you open a session with a specific device with the viOpen function. This function uses the session returned from viOpenDefaultRM and returns its own session to identify the device session. The following shows the function syntax:
3-8 Chapter3
Programming Examples
C Programming Examples using VTL
viOpenDefaultRM (sesn); viOpen (sesn, rsrcName, accessMode, timeout, vi);
The session returned from viOpenDefaultRM must be used in the sesn parameter of the viOpen function. The viOpen function then uses that session and the device address specified in the (resource name) parameter to open a device session. The vi parameter in viOpen returns a session identifier that can be used with other VTL functions.
Your program may have several sessions open at the same time by creating multiple session identifiers by calling the viOpen function multiple times.
The following summarizes the parameters in the previous function calls:
sesn This is a session returned from the viOpenDefaultRM
function that identifies the resource manager session.
rsrcName This is a unique symbolic name of the device (device
address).
accessMode This parameter is not used for VTL. Use VI_NULL. timeout This parameter is not used for VTL. Use VI_NULL. vi This is a pointer to the session identifier for this
particular device session. This pointer will be used to identify this device session when using other VTL functions.
The following is an example of opening sessions with an HP-IB multimeter and an HP-IB/VXI scanner:
ViSession defaultRM, dmm, scanner; . . viOpenDefaultRM(&defaultRM); viOpen(defaultRM, “GPIB0::22::INSTR”, VI_NULL,
VI_NULL, &dmm);
viOpen(defaultRM, “GPIB-VXI0::24::INSTR”, VI_NULL,
VI_NULL, &scanner); . . viClose(scanner); viClose(dmm); viClose(defaultRM);
Chapter 3 3-9
Programming Examples
C Programming Examples using VTL
The above function first opens a session with the default resource manager. The session returned from the resource manager and a device address is then used to open a session with the HP-IB device at address
22. That session will now be identified as dmm when using other VTL functions. The session returned from the resource manager is then used again with another device address to open a session with the HP-IB/VXI device at primary address 9 and VXI logical address 24. That session will now be identified as scanner when using other VTL functions. See the following section for information on addressing particular devices.

Addressing a Session

As seen in the previous section, the rsrcName parameter in the viOpen function is used to identify a specific device. This parameter is made up of the VTL interface name and the device address. The interface name is determined when you run the VTL Configuration Utility. This name is usually the interface type followed by a number. The following table illustrates the format of the rsrcName for the different interface types:
Interface Syntax
VXI VXI [board]::VXI logical address[::INSTR] HP-IB/VXI GPIB-VXI [board]::VXI logical address[::INSTR] HP-IB GPIB [board]::primary address[::secondary address][::INSTR]
The following describes the parameters used above: board This optional parameter is used if you have more than
one interface of the same type. The default value for
board is 0.
VXI logical address This is the logical address of the VXI instrument.
primary address This is the primary address of the HP-IB device.
secondary address This optional parameter is the secondary address of the
HP-IB device. If no secondary address is specified, none is assumed.
INSTR This is an optional parameter that indicates that you
are communicating with a resource that is of type INSTR, meaning instrument.
NOTE If you want to be compatible with future releases of VTL and VISA, you
must include the INSTR parameter in the syntax.
3-10 Chapter3
Programming Examples
C Programming Examples using VTL
The following are examples of valid symbolic names: VXI0::24::INSTR Device at VXI logical address 24 that is of VISA type
INSTR.
VXI2::128 Device at VXI logical address 128, in the third VXI
system (VXI2).
GPIB-VXI0::24 A VXI device at logical address 24. This VXI device is
connected via an HP-IB/VXI command module.
GPIB0::7::0 An HP-IB device at primary address 7 and secondary
address 0 on the HP-IB interface.
The following is an example of opening a device session with the HP-IB device at primary address 23.
ViSession defaultRM, vi; .
. viOpenDefaultRM(&defaultRM); viOpen(defaultRM, “GPIB0::23::INSTR”, VI_NULL,VI_NULL,&vi); .
. viClose(vi); viClose(defaultRM);

Closing a Session

The viClose function must be used to close each session. You can close the specific device session, which will free all data structures that had been allocated for the session. If you close the default resource manager session, all sessions opened using that resource manager will be closed.
Since system resources are also used when searching for resources (viFindRsrc) or waiting for events (viWaitOnEvent), the viClose function needs to be called to free up find lists and event contexts.
Chapter 3 3-11
Programming Examples

Using Marker Peak Search and Peak Excursion

Using Marker Peak Search and Peak Excursion

Example:

/************************************************************/ /* Using Marker Peak Search and Peak Excursion */ /* */ /* This C programming example does the following. */ /* The SCPI instrument commands used are given as */ /* reference. */ /* */ /* - Opens an HP-IB session at address 18 */ /* - Clears the Analyzer */ /* *CLS */ /* - Resets the Analyzer */ /* *RST */ /* - Sets the analyzer center frequency and span */ /* SENS:FREQ:CENT freq */ /* SENS:FREQ:SPAN freq */ /* - Set the input port to the 50 MHz amplitude reference */ /* CAL:SOUR:STAT ON */ /* - Set the analyzer to single sweep mode */ /* INIT:CONT 0 */ /* - Prompt the user for peak excursion and set them */ /* CALC:MARK:PEAK:EXC dB */ /* - Set the peak threshold to -90 dBm */ /* TRAC:MATH:PEAK:THR:STAT ON */ /* TRAC:MATH:PEAK:THR -90 */ /* - Trigger a sweep */ /* INIT:IMM */ /* - Check for operation complete */ /* *OPC? */ /* - Set the marker to the maximum peak */ /* CALC:MARK:MAX */ /* - Query and read the marker frequency and amplitude */ /* CALC:MARK:X? */ /* CALC:MARK:Y? */ /* - Close the session */ /************************************************************/
#include <stdio.h>
3-12 Chapter3
Using Marker Peak Search and Peak Excursion
#include <stdlib.h> #include <math.h> #include <conio.h> #include <ctype.h> #include <string.h> #include "visa.h"
#define hpESA_IDN_E4401B "Hewlett-Packard, E4401B" #define hpESA_IDN_E4411B "Hewlett-Packard, E4411B"
ViSession defaultRM, viESA; ViStatus errStatus; ViChar cIdBuff[256]= {0}; char cEnter = 0; int iResult = 0;
/*Set the input port to 50MHz amplitude reference*/ void Route50MHzSignal() {
Programming Examples
viQueryf(viESA, "*IDN?\n", "%t", &cIdBuff); iResult = (strncmp( cIdBuff, hpESA_IDN_E4401B, strlen(hpESA_IDN_E4401B)) &&
strncmp( cIdBuff, hpESA_IDN_E4411B, strlen(hpESA_IDN_E4411B)));
if( iResult == 0 ) {
/*Set the input port to the 50MHz amplitude reference for the models*/ /*E4411B and E4401B*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n"); } else {
/* For the analyzers having frequency limits >= 3GHz, prompt the user*/
/* to connect the amplitude reference output to the input*/
printf ("Connect AMPTD REF OUT to the INPUT \n");
printf ("......Press Return to continue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Signal*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n"); }
}
void main() {
/*Program Variables*/ ViStatus viStatus = 0;
Chapter 3 3-13
Programming Examples
Using Marker Peak Search and Peak Excursion
double dMarkerFreq = 0; double dMarkerAmpl = 0; float fPeakExcursion =0; long lOpc = 0L;
/*Open an HP-IB session at address 18.*/ viStatus=viOpenDefaultRM(&defaultRM); viStatus=viOpen(defaultRM,"GPIB0::18",VI_NULL,VI_NULL,&viESA); if(viStatus) {
printf("Could not open a session to HP-IB device at address 18!\n");
exit(0); } /*Clear the instrument*/ viClear(viESA);
/*Reset the instrument*/ viPrintf(viESA,"*RST\n");
/*Set the analyzer center frequency to 50MHZ*/ viPrintf(viESA,"SENS:FREQ:CENT 50e6\n");
/*Set the analyzer span to 50MHZ*/ viPrintf(viESA,"SENS:FREQ:SPAN 50e6\n");
/*Display the program heading */ printf("\n\t\t Marker Program \n\n" );
/* Check for the instrument model number and route the 50MHz signal accordingly*/ Route50MHzSignal();
/*Set analyzer to single sweep mode*/ viPrintf(viESA,"INIT:CONT 0 \n");
/*User enters the peak excursion value*/ printf("\t Enter PEAK EXCURSION in dB: "); scanf( "%f",&fPeakExcursion);
/*Set the peak excursion*/ viPrintf(viESA,"CALC:MARK:PEAK:EXC %1fDB \n",fPeakExcursion);
/*Set the peak thresold */ viPrintf(viESA,"CALC:MARK:PEAK:THR -90 \n");
/*Trigger a sweep*/ viPrintf(viESA,"INIT:IMM\n");
3-14 Chapter3
Programming Examples
Using Marker Peak Search and Peak Excursion
/*Make sure the previous command has been completed*/ viQueryf(viESA, "*OPC?\n", "%d", &lOpc); if (!lOpc) {
printf("Program Abort! error ocurred: last command was not completed!\n");
exit(0); } /*Set the marker to the maximum peak*/ viPrintf(viESA,"CALC:MARK:MAX \n");
/*Query and read the marker frequency*/ viPrintf(viESA,"CALC:MARK:X? \n"); viScanf(viESA,"%lf",&dMarkerFreq); printf("\n\t RESULT: Marker Frequency is: %lf MHZ \n\n",dMarkerFreq/10e5);
/*Query and read the marker amplitude*/ viPrintf(viESA,"CALC:MARK:Y?\n"); viScanf(viESA,"%lf",&dMarkerAmpl); printf("\t RESULT: Marker Amplitude is: %lf dBm \n\n",dMarkerAmpl);
/*Close the session*/ viClose(viESA); viClose(defaultRM);
}
Chapter 3 3-15
Programming Examples

Using Marker Delta Mode and Marker Minimum Search

Using Marker Delta Mode and Marker Minimum Search
/************************************************************/ /* Using Marker Delta Mode and Marker Minimum Search */ /* */ /* This C programming example does the following. */ /* The SCPI instrument commands used are given as */ /* reference. */ /* */ /* - Opens an HP-IB session at address 18 */ /* - Clears the Analyzer */ /* - Resets the Analyzer */ /* *RST */ /* - Set the input port to the 50 MHz amplitude reference */ /* CAL:SOUR:STAT ON */ /* - Set the analyzer to single sweep mode */ /* INIT:CONT 0 */ /* - Prompts the user for the start and stop frequencies */ /* - Sets the start and stop frequencies */ /* SENS:FREQ:START freq */ /* SENS:FREQ:STOP freq */ /* - Trigger a sweep */ /* INIT:IMM */ /* - Check for operation complete */ /* *OPC? */ /* - Set the marker to the maximum peak */ /* CALC:MARK:MAX */ /* - Set the analyzer to activate the delta marker */ /* CALC:MARK:MODE DELT */ /* - Trigger a sweep */ /* INIT:IMM */ /* - Check for operation complete */ /* *OPC? */ /* - Set the marker to the minimum amplitude mode */ /* CALC:MARK:MIN */ /* - Query and read the marker amplitude */ /* CALC:MARK:Y? */ /* - Close the session */ /************************************************************/
#include <stdio.h> #include <stdlib.h> #include <math.h>
3-16 Chapter3
Programming Examples
Using Marker Delta Mode and Marker Minimum Search
#include <conio.h> #include <ctype.h> #include <string.h> #include "visa.h"
#define hpESA_IDN_E4401B "Hewlett-Packard, E4401B" #define hpESA_IDN_E4411B "Hewlett-Packard, E4411B"
ViSession defaultRM, viESA; ViStatus errStatus; ViChar cIdBuff[256] ={0}; char cEnter = 0; int iResult =0;
/*Set the input port to the 50MHz amplitude reference*/ void Route50MHzSignal() {
viQueryf(viESA, "*IDN?\n", "%t", &cIdBuff); iResult = (strncmp( cIdBuff, hpESA_IDN_E4401B, strlen(hpESA_IDN_E4401B)) &&
strncmp( cIdBuff, hpESA_IDN_E4411B, strlen(hpESA_IDN_E4411B)));
if( iResult == 0 ) {
/*Set the input port to the 50MHz amplitude reference for the models*/
/*E4411B and E4401B*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n"); } else {
/* For the analyzers having frequency limits >= 3GHz, prompt the user*/
/* to connect the amplitude reference output to the input*/
printf ("Connect AMPTD REF OUT to the INPUT \n");
printf ("......Press Return to continue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Signal*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n"); }
}
void main() {
/*Program Variable*/ ViStatus viStatus = 0; double dStartFreq =0.0; double dStopFreq =0.0; double dMarkerAmplitude = 0.0;
Chapter 3 3-17
Programming Examples
Using Marker Delta Mode and Marker Minimum Search
long lOpc =0L;
/* Open an HP-IB session at address 18*/ viStatus=viOpenDefaultRM(&defaultRM); viStatus=viOpen(defaultRM,"GPIB0::18",VI_NULL,VI_NULL,&viESA); if(viStatus) {
printf("Could not open a session to HP-IB device at address 18!\n");
exit(0); } /*Clear the instrument*/ viClear(viESA);
/*Reset the instrument*/ viPrintf(viESA,"*RST\n");
/*Display the program heading */ printf("\n\t\t Marker Delta Program \n\n" );
/*Check for the instrument model number and route the 50MHz signal accordingly*/ Route50MHzSignal();
/*Set the analyzer to single sweep mode*/ viPrintf(viESA,"INIT:CONT 0\n");
/*Prompt the user for the start frequency*/ printf("\t Enter the Start frequency in MHz ");
/*The user enters the start frequency*/ scanf("%lf",&dStartFreq);
/*Prompt the user for the stop frequency*/ printf("\t Enter the Stop frequency in MHz ");
/*The user enters the stop frequency*/ scanf("%lf",&dStopFreq);
/*Set the analyzer to the values given by the user*/ viPrintf(viESA,"SENS:FREQ:STAR %lf MHZ \n;:SENS:FREQ:STOP %lf
MHZ\n",dStartFreq,dStopFreq);
/*Trigger a sweep*/ viPrintf(viESA,"INIT:IMM\n");
/*Check for operation complete*/ viQueryf(viESA, "*OPC?\n", "%d", &lOpc);
3-18 Chapter3
Using Marker Delta Mode and Marker Minimum Search
if (!lOpc) {
printf("Program Abort! error ocurred: last command was not completed!\n");
exit(0); } /*Set the marker to the maximum peak*/ viPrintf(viESA,"CALC:MARK:MAX\n");
/*Set the analyzer to activate delta marker mode*/
viPrintf(viESA,"CALC:MARK:MODE DELT\n");
/*Trigger a sweep*/ viPrintf(viESA,"INIT:IMM\n");
/*Check for operation complete*/ viQueryf(viESA, "*OPC?\n", "%d", &lOpc); if (!lOpc) {
printf("Program Abort! error ocurred: last command was not completed!\n");
exit(0); } /*Set the marker to minimum amplitude*/ viPrintf(viESA,"CALC:MARK:MIN\n");
Programming Examples
/*Query and read the marker amplitude*/ viPrintf(viESA,"CALC:MARK:Y?\n"); viScanf(viESA,"%lf",&dMarkerAmplitude);
/*print the marker amplitude*/ printf("\n\n\tRESULT: Marker Amplitude Delta = %lf dB\n\n",dMarkerAmplitude);
/*Close the session*/ viClose(viESA); viClose(defaultRM);
}
Chapter 3 3-19
Programming Examples

Performing Internal Self-alignment

Performing Internal Self-alignment
/************************************************************/ /* Performing Internal Self-alignment */ /* */ /* This example shows two ways of executing an internal */ /* self-alignment. The first demonstrates using the *OPC? */ /* query to determine when the alignment has completed. The */ /* second demonstrates using the query form of the CAL:ALL */ /* command to not only determine when the alignment has */ /* been completed, but the pass/fail status of the align- */ /* ment process. */ /* */ /* This C programming example does the following. */ /* The SCPI instrument commands used are given as */ /* reference. */ /* */ /* - Opens an HP-IB session at address 18 */ /* - Clears the Analyzer */ /* *CLS */ /* - Resets the Analyzer */ /* *RST */ /* - VISA function sets the time out to infinite */ /* - Initiate self-alignment */ /* CAL:ALL */ /* - Query for operation complete */ /* *OPC? */ /* - Query for results of self-alignment */ /* CAL:ALL? */ /* - Report the results of the self-alignment */ /* - Close the session */ /************************************************************/
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <ctype.h> #include <string.h> #include "visa.h"
#define hpESA_IDN_E4401B "Hewlett-Packard, E4401B" #define hpESA_IDN_E4411B "Hewlett-Packard, E4411B"
ViSession defaultRM, viESA;
3-20 Chapter3
Programming Examples
Performing Internal Self-alignment
ViStatus errStatus; ViChar cIdBuff[256]= {0}; char cEnter = 0; int iResult = 0;
/*Set the input port to 50MHz amplitude reference*/ void Route50MHzSignal() {
viQueryf(viESA, "*IDN?\n", "%t", &cIdBuff); iResult = (strncmp( cIdBuff, hpESA_IDN_E4401B, strlen(hpESA_IDN_E4401B)) &&
strncmp( cIdBuff, hpESA_IDN_E4411B, strlen(hpESA_IDN_E4411B)));
if( iResult == 0 ) {
/*Set the input port to the 50MHz amplitude reference for the models*/
/*E4411B and E4401B*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n"); } else {
/* For the analyzers having frequency limits >= 3GHz, prompt the user*/
/* to connect the amplitude reference output to the input*/
printf ("Connect AMPTD REF OUT to the INPUT \n");
printf ("......Press Return to continue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Signal*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n"); }
}
void main() {
/*Program Variables*/ ViStatus viStatus = 0; long lOpc =0L; long lResult =0L;
/* Open a HP-IB session at address 18*/ viStatus=viOpenDefaultRM(&defaultRM); viStatus=viOpen(defaultRM,"GPIB0::18",VI_NULL,VI_NULL,&viESA); if(viStatus) {
printf("Could not open a session to HP-IB device at address 18!\n");
exit(0); }
Chapter 3 3-21
Programming Examples
Performing Internal Self-alignment
/*Clear the instrument*/ viClear(viESA);
/*Reset the instrument*/ viPrintf(viESA,"*RST\n");
/*Display the program heading */ printf("\n\t\t Internal Self-Alignment Program \n\n" );
/*Check for the instrument model number and route the 50MHz-signal accordingly*/ Route50MHzSignal();
/*VISA function sets the time out to infinite for this specified session*/ viSetAttribute(viESA, VI_ATTR_TMO_VALUE, VI_TMO_INFINITE);
printf("\t Performing first self alignment ..... " );
/*Initiate a self-alignment */ viPrintf(viESA,"CAL:ALL\n");
/*Query for operation complete*/ viQueryf(viESA, "*OPC?\n", "%d", &lOpc); printf ("\n\n\t First Self Alignment is Done \n\n"); if (!lOpc) {
printf("Program Abort! error ocurred: last command was not completed!\n");
exit(0); } printf ("\n\n\t Press Return to continue with next alignment \n\n"); scanf( "%c",&cEnter);
printf("\t Performing next self alignment ..... " );
/* Query for self-alignment results*/ viPrintf(viESA,"CAL:ALL?\n"); viScanf(viESA,"%d",&lResult); if (lResult)
printf ("\n\n\t Self-alignment Failed \n"); else
printf ("\n\n\t Self-alignment Passed \n");
/* Query for operation complete*/ viQueryf(viESA, "*OPC?\n", "%d", &lOpc); if (!lOpc) {
printf("Program Abort! error ocurred: last command was not completed!\n");
exit(0); }
3-22 Chapter3
/*Close the session*/ viClose(viESA); viClose(defaultRM);
}
Programming Examples
Performing Internal Self-alignment
Chapter 3 3-23
Programming Examples

Reading Trace Data using ASCII Format (HP-IB)

Reading Trace Data using ASCII Format (HP-IB)
/************************************************************/ /* Reading Trace Data using ASCII Format (HP-IB) */ /* */ /* This C programming example does the following. */ /* The required SCPI instrument commands are given as */ /* reference. */ /* */ /* - Opens an HP-IB session at address 18 */ /* - Clears the Analyzer */ /* - Resets the Analyzer */ /* *RST */ /* - Set the input port to the 50 MHz amplitude reference */ /* E4411B or E4401B */ /* CAL:SOUR:STAT ON */ /* E4402, E4403B, E4404BE, 4405B, E4407B or E4408B */ /* Prompt to connect AMPTD REF OUT to INPUT */ /* CAL:SOUR STAT ON */ /* - Query for the number of sweep points (only applies to */ /* firmware revisions A.04.00 and later); default is 401 */ /* SENS:SWE:POIN? */ /* - Sets the analyzer center frequency to 50 MHz */ /* SENS:FREQ:CENT 50 MHZ */ /* - Sets the analyzer span to 50 MHz */ /* SENS:FREQ:SPAN 50 MHZ */ /* - Set the analyzer to single sweep mode */ /* INIT:CONT 0 */ /* - Trigger a sweep */ /* INIT:IMM */ /* - Check for operation complete */ /* *OPC? */ /* - Specify units in dBm */ /* UNIT:POW DBM */ /* - Set the analyzer trace data to ASCII */ /* FORM:DATA: ASC */ /* - Trigger a sweep */ /* INIT:IMM */ /* - Check for operation complete */ /* *OPC? */ /* - Query the trace data */ /* TRAC:DATA? TRACE1 */ /* - Remove the "," from the ACSII data */
3-24 Chapter3
Reading Trace Data using ASCII Format (HP-IB)
/* - Save the trace data to an ASCII file */ /* - Close the session */ /************************************************************/
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <conio.h> #include <ctype.h> #include <string.h> #include "visa.h"
#define hpESA_IDN_E4401B "Hewlett-Packard, E4401B" #define hpESA_IDN_E4411B "Hewlett-Packard, E4411B"
ViSession defaultRM, viESA; ViStatus errStatus; ViChar cIdBuff[256] ={0}; char cEnter =0; int iResult =0;
Programming Examples
/*Set the input port to 50MHz amplitude reference*/ void Route50MHzSignal() {
viQueryf(viESA, "*IDN?\n", "%t", &cIdBuff); iResult = (strncmp( cIdBuff, hpESA_IDN_E4401B, strlen(hpESA_IDN_E4401B)) &&
strncmp( cIdBuff, hpESA_IDN_E4411B, strlen(hpESA_IDN_E4411B)));
if( iResult == 0 ) {
/*Set the input port to the 50MHz amplitude reference for the models*/ /*E4411B and E4401B*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n"); } else {
/* For the analyzers having frequency limits >= 3GHz, prompt the user*/
/* to connect the amplitude reference output to the input*/
printf ("Connect AMPTD REF OUT to the INPUT \n");
printf ("......Press Return to continue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Signal*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n"); }
}
Chapter 3 3-25
Programming Examples
Reading Trace Data using ASCII Format (HP-IB)
void main() {
/*Program Variable*/ ViStatus viStatus = 0; /*Dimension cResult to 13 bytes per sweep point, 8192 sweep points maximum*/
ViChar _VI_FAR cResult[106496] = {0};
FILE *fTraceFile;
static ViChar *cToken ;
int iNum =0; int iSwpPnts = 401; long lCount=0L; long lOpc=0;
/*iNum set to 13 times number of sweep points, 8192 sweep points maximum*/ iNum =106496;
lCount =0;
/* Open an HP-IB session at address 18*/ viStatus=viOpenDefaultRM(&defaultRM); viStatus=viOpen(defaultRM,"GPIB0::18",VI_NULL,VI_NULL,&viESA); if(viStatus) {
printf("Could not open a session to HP-IB device at address 18!\n");
exit(0); } /* Clear the instrument */ viClear(viESA);
/*Reset the instrument. This will set number of sweep points to default of 401*/ viPrintf(viESA,"*RST\n");
/*Display the program heading */ printf("\n\t\t Read in Trace Data using ASCII Format (HPIB) Program \n\n" );
/* Check for the instrument model number and route the 50MHz signal accordingly*/ Route50MHzSignal();
/*Query number of sweep points per trace (firmware revision A.04.00 and later)*/ /*For firmware revisions prior to A.04.00, the number of sweep points is 401*/ iSwpPnts = 401;
viQueryf(viESA,"SENSE:SWEEP:POINTS?\n","%d",&iSwpPnts);
/*Set the analyzer center frequency to 50MHz*/ viPrintf(viESA,"SENS:FREQ:CENT 50 MHz\n");
/*Set the analyzer to 50MHz Span*/
3-26 Chapter3
Programming Examples
Reading Trace Data using ASCII Format (HP-IB)
viPrintf(viESA,"SENS:FREQ:SPAN 50 MHz\n");
/*Set the analyzer to single sweep mode */ viPrintf(viESA,"INIT:CONT 0 \n");
/*Trigger a spectrum measurement*/ viPrintf(viESA,"INIT:IMM\n");
/*Read the operation complete query */ viQueryf(viESA, "*OPC?\n", "%d", &lOpc); if (!lOpc) {
printf("Program Abort! error ocurred: last command was not completed!\n");
exit(0); } /* Specify units in dBm*/ viPrintf(viESA,"UNIT:POW DBM \n");
/*Set analyzer trace data format to ASCII Format*/ viPrintf(viESA,"FORM:DATA ASC \n");
/*Trigger a spectrum measurement*/ viPrintf(viESA,"INIT:IMM \n");
/*Read the operation complete query */ viQueryf(viESA, "*OPC?\n", "%d", &lOpc); if (!lOpc) {
printf("Program Abort! error ocurred: last command was not completed!\n");
exit(0); } /*Query the Trace Data using ASCII Format */ viQueryf(viESA,"%s\n", "%#t","TRAC:DATA? TRACE1" , &iNum , cResult);
/*Remove the "," from the ASCII trace data for analyzing data*/
cToken = strtok(cResult,",");
/*Save trace data to an ASCII to a file, by removing the "," token*/ fTraceFile=fopen("C:\\temp\\ReadAscHpib.txt","w"); fprintf(fTraceFile,"ReadAscHpib.exe Output\nHewlett-Packard 1999\n\n"); fprintf(fTraceFile,"\tAmplitude of point[%d] = %s dBm\n",lCount+1,cToken);
while (cToken != NULL)
{
lCount++;
cToken =strtok(NULL,",");
if (lCount != iSwpPnts)
Chapter 3 3-27
Programming Examples
Reading Trace Data using ASCII Format (HP-IB)
fprintf(fTraceFile,"\tAmplitude of point[%d] = %s
dBm\n",lCount+1,cToken);
}
fprintf(fTraceFile,"\nThe Total trace data points of the spectrum are :[%d]
\n\n",lCount);
fclose(fTraceFile);
/*Close the session*/ viClose(viESA); viClose(defaultRM);
}
3-28 Chapter3

Reading Trace Data Using 32-bit Real Format (HP-IB)

Reading Trace Data Using 32-bit Real Format (HP-IB)
/************************************************************/ /* Reading Trace Data using 32-bit Real Format (HP-IB) */ /* */ /* This C programming example does the following. */ /* The SCPI instrument commands used are given as */ /* reference. */ /* */ /* - Opens an HP-IB session at address 18 */ /* - Clears the Analyzer */ /* - Resets the Analyzer */ /* *RST */ /* - Set the input port to the 50 MHz amplitude reference */ /* CAL:SOUR:STAT ON */ /* - Query for the number of sweep points (for firmware */ /* revisions A.04.00 and later). Default is 401. */ /* SENS:SWE:POIN? */ /* - Calculate the number of bytes in the header */ /* - Set the analyzer to single sweep mode */ /* INIT:CONT 0 */ /* - Sets the analyzer center frequency and span to 50 MHz */ /* SENS:FREQ:CENT 50 MHZ */ /* SENS:FREQ:SPAN 50 MHZ */ /* - Specify 10 dB per division for the amplitude scale in */ /* and dBm Units */ /* DISP:WIND:TRAC:Y:SCAL:PDIV 10 dB */ /* UNIT:POW DBM */ /* - Set the analyzer trace data to 32-bit Real */ /* FORM:DATA: REAL,32 */ /* - Set the binary order to swap */ /* FORM:BORD SWAP */ /* - Trigger a sweep */ /* INIT:IMM */ /* - Check for operation complete */ /* *OPC? */ /* - Calculate the number of bytes in the trace record */ /* - Query the trace data */ /* TRAC:DATA? TRACE1 */ /* - Remove the "," from the ACSII data */ /* - Save the trace data to an ASCII file */ /* - Close the session */ /************************************************************/
Programming Examples
Chapter 3 3-29
Programming Examples
Reading Trace Data Using 32-bit Real Format (HP-IB)
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <conio.h> #include <ctype.h> #include <string.h> #include "visa.h"
#define hpESA_IDN_E4401B "Hewlett-Packard, E4401B" #define hpESA_IDN_E4411B "Hewlett-Packard, E4411B"
ViSession defaultRM, viESA; ViChar cIdBuff[256]; char cEnter =0; int iResult =0;
void Route50MHzSignal() { viQueryf(viESA, "*IDN?\n", "%t", &cIdBuff); iResult = (strncmp( cIdBuff, hpESA_IDN_E4401B, strlen(hpESA_IDN_E4401B)) &&
strncmp( cIdBuff, hpESA_IDN_E4411B, strlen(hpESA_IDN_E4411B))); if( iResult == 0 ) {
/*Set the input port to the 50MHz internal reference source for the models*/ /*E4411B and E4401B*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n"); } else {
/* For the analyzers having frequency limits >= 3GHz, prompt the user to*/
/* connect the amplitude reference output to the input*/
printf ("Connect AMPTD REF OUT to the INPUT \n");
printf ("......Press Return to continue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Signal*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n"); } }
void main() { /*Program Variables*/ ViStatus viStatus= 0; ViChar _VI_FAR cResult[5000] = {0};
3-30 Chapter3
Programming Examples
Reading Trace Data Using 32-bit Real Format (HP-IB)
ViReal32 dTraceArray[401] = {0}; char cBufferInfo[6]= {0}; long lNumberBytes =0L; long lOpc =0L; unsigned long lRetCount = 0L; int iSize = 0; /*BytesPerPoint is 4 for Real32 or Int32 formats, 8 for Real64, and 2 for Uint16*/ int iBytesPerPnt = 4; int iSwpPnts = 401; int iDataBytes=1604; int iHeaderBytes=6; FILE *fTraceFile;
/* Open a HP-IB session at address 18*/ viStatus=viOpenDefaultRM(&defaultRM); viStatus=viOpen(defaultRM,"GPIB0::18",VI_NULL,VI_NULL,&viESA); if(viStatus) {
printf("Could not open a session to HP-IB device at address 18!\n");
exit(0); } /*Clear the instrument */ viClear(viESA);
/*Reset the instrument. This will set number of sweep points to default of 401*/ viPrintf(viESA,"*RST\n");
/*Display the program heading */ printf("\n\t\t Read in Trace Data using 32-bit Real Format (using HP-IB) \n\n" );
/* Set the input port to the 50MHz amplitude reference*/ Route50MHzSignal();
/*Query number of sweep points per trace (firmware revision A.04.00 and later)*/ /*For firmware revisions prior to A.04.00, the number of sweep points is 401*/ iSwpPnts=401; viQueryf(viESA,"SENSE:SWEEP:POINTS?\n","%d",&iSwpPnts);
/*Calculate number of bytes in the header. The header consists of the "#" sign*/ /*followed by a digit representing the number of digits to follow. The digits */ /*which follow represent the number of sweep points multiplied by the number */ /*of bytes per point. */ iHeaderBytes = 3; /*iDataBytes >3, plus increment for "#" and "n"*/ iDataBytes = (iSwpPnts*iBytesPerPnt); lNumberBytes = iDataBytes; while ((iDataBytes = (iDataBytes / 10 )) > 0 )
Chapter 3 3-31
Programming Examples
Reading Trace Data Using 32-bit Real Format (HP-IB)
{
iHeaderBytes++;
}
/*Set analyzer to single sweep mode */ viPrintf(viESA,"INIT:CONT 0 \n");
/*Set the analyzer to 50MHz-center frequency */ viPrintf(viESA,"SENS:FREQ:CENT 50 MHZ\n");
/*Set the analyzer to 50MHz Span */ viPrintf(viESA,"SENS:FREQ:SPAN 50 MHZ\n");
/* Specify dB per division of each vertical division and Units */ viPrintf(viESA,"DISP:WIND:TRAC:Y:SCAL:PDIV 10dB\n"); viPrintf(viESA,"UNIT:POW DBM\n");
/*Set analyzer trace data format to 32-bit Real */ viPrintf(viESA,"FORM:DATA REAL,32 \n");
/*Set the binary byte order to SWAP */ viPrintf(viESA, "FORM:BORD SWAP\n");
/*Trigger a sweep */ viPrintf(viESA,"INIT:IMM \n");
/*Read the operation complete query */ viQueryf(viESA, "*OPC?\n", "%d", &lOpc); if (!lOpc) {
printf("Program Abort! error ocurred: last command was not completed!\n");
exit(0); } /*Calculate size of trace record. This will be sum of HeaderBytes, NumberBytes*/ /*(the actual data bytes) and the "/n" terminator*/ iSize = lNumberBytes +iHeaderBytes+1;
/*Get trace header data and trace data */ viPrintf(viESA,"TRAC:DATA? TRACE1\n"); viRead (viESA,(ViBuf)cResult,iSize,&lRetCount);
/*Extract the trace data*/
memcpy(dTraceArray,cResult+iHeaderBytes,(size_t)lNumberBytes);
/*Save trace data to an ASCII file*/ fTraceFile=fopen("C:\\temp\\ReadTrace32Hpib.txt","w");
3-32 Chapter3
Programming Examples
Reading Trace Data Using 32-bit Real Format (HP-IB)
fprintf(fTraceFile,"ReadTrace32Hpib.exe Output\nHewlett-Packard 1999\n\n"); fprintf(fTraceFile,"The %d trace data points of the
spectrum:\n\n",(lNumberBytes/4)); for ( long i=0;i<lNumberBytes/4;i++)
fprintf(fTraceFile,"\tAmplitude of point[%d] = %.2lf
dBm\n",i+1,dTraceArray[i]); fclose(fTraceFile);
/*Close the session*/ viClose(viESA); viClose(defaultRM); }
Chapter 3 3-33
Programming Examples

Reading Trace Data Using ASCII Format (RS-232)

Reading Trace Data Using ASCII Format (RS-232)
/************************************************************/ /* Reading Trace Data using ASCII Format (RS-232) */ /* */ /* This C programming example does the following. */ /* The SCPI instrument commands used are given as */ /* reference. */ /* */ /* - Opens an RS-232 session at COM1/COM2 */ /* - Clears the Analyzer */ /* - Resets the Analyzer */ /* *RST */ /* - Set the input port to the 50 MHz amplitude reference */ /* CAL:SOUR:STAT ON */ /* - Query for the number of sweep points (for firmware */ /* revisions A.04.00 and later). Default is 401. */ /* SENS:SWE:POIN? */ /* - Set the analyzer to single sweep mode */ /* INIT:CONT 0 */ /* - Sets the analyzer center frequency and span to 50 MHz */ /* SENS:FREQ:CENT 50 MHZ */ /* SENS:FREQ:SPAN 50 MHZ */ /* - Trigger a sweep */ /* INIT:IMM */ /* - Check for operation complete */ /* *OPC? */ /* - Specify dBm Unit */ /* UNIT:POW DBM */ /* - Set the analyzer trace data ASCII */ /* FORM:DATA: ASC */ /* - Trigger a sweep */ /* INIT:IMM */ /* - Check for operation complete */ /* *OPC? */ /* - Query the trace data */ /* TRAC:DATA? TRACE1 */ /* - Remove the "," from the ACSII data */ /* - Save the trace data to an ASCII file */ /* - Close the session */ /************************************************************/
#include <stdio.h>
3-34 Chapter3
Programming Examples
Reading Trace Data Using ASCII Format (RS-232)
#include <stdlib.h> #include <math.h> #include <conio.h> #include <ctype.h> #include <string.h> #include "visa.h"
#define hpESA_IDN_E4401B "Hewlett-Packard, E4401B" #define hpESA_IDN_E4411B "Hewlett-Packard, E4411B"
ViSession defaultRM, viESA; ViStatus errStatus; ViChar cIdBuff[256] ={0}; char cEnter ={0}; int iResult =0;
/*Set the input port to 50MHz amplitude reference*/ void Route50MHzSignal() { viQueryf(viESA, "*IDN?\n", "%t", &cIdBuff); iResult = (strncmp( cIdBuff, hpESA_IDN_E4401B, strlen(hpESA_IDN_E4401B)) &&
strncmp( cIdBuff, hpESA_IDN_E4411B, strlen(hpESA_IDN_E4411B))); if( iResult == 0 ) {
/*Set the input port to the 50MHz amplitude reference for the models*/ /*E4411B and E4401B*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n"); } else {
/* For the analyzers having frequency limits >= 3GHz, prompt the user to/*
/* connect the amplitude reference output to the input*/
printf ("Connect AMPTD REF OUT to the INPUT \n");
printf ("......Press Return to continue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Signal*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n"); } }
void main() { /*Program Variable*/ ViStatus viStatus = 0; /*Dimension cResult to 13 bytes per sweep point, 8192 sweep points maximum*/
Chapter 3 3-35
Programming Examples
Reading Trace Data Using ASCII Format (RS-232)
ViChar _VI_FAR cResult[106496] = {0}; FILE *fTraceFile; static ViChar *cToken; int iNum =0; int iSwpPnts = 401; long lCount=0L; long lOpc=0L;
/*iNum set to 13 times number of sweep points, 8192 sweep points maximum*/ iNum =106496; lCount =0;
/* Open a serial session at COM1 */ viStatus=viOpenDefaultRM(&defaultRM); if (viStatus =viOpen(defaultRM,"ASRL1::INSTR",VI_NULL,VI_NULL,&viESA) !=
VI_SUCCESS) {
printf("Could not open a session to ASRL device at COM1!\n");
exit(0); } /* Clear the instrument */ viClear(viESA);
/*Reset the instrument. This will set number of sweep points to default of 401*/
viPrintf(viESA,"*RST\n");
/*Display the program heading */ printf("\n\t\tRead in Trace Data using ASCII Format (RS232) Program \n\n" );
/* Check for the instrument model number and route the 50MHz signal accordingly*/ Route50MHzSignal();
/*Query number of sweep points per trace (firmware revision A.04.00 and later)*/ /*For firmware revisions prior to A.04.00, the number of sweep points is 401 */ iSwpPnts = 401; viQueryf(viESA, "SENSE:SWEEP:POINTS?\n","%d",&iSwpPnts);
/*Set the analyzer center frequency to 50MHz */ viPrintf(viESA,"SENS:FREQ:CENT 50 MHz\n");
/*Set the analyzer to 50MHz Span*/ viPrintf(viESA,"SENS:FREQ:SPAN 50 MHz\n");
/*set the analyzer to single sweep mode*/ viPrintf(viESA,"INIT:CONT 0 \n");
3-36 Chapter3
Reading Trace Data Using ASCII Format (RS-232)
/*Trigger a spectrum measurement*/ viPrintf(viESA,"INIT:IMM \n");
/*Read the operation complete query*/ viQueryf(viESA, "*OPC?\n", "%d", &lOpc); if (!lOpc) {
printf("Program Abort! error ocurred: last command was not completed!\n");
exit(0); } /*Specify units in dBm*/ viPrintf(viESA,"UNIT:POW DBM \n");
/*Set analyzer trace data format to ASCII Format*/ viPrintf(viESA,"FORM:DATA ASC \n");
/*Trigger a spectrum measurement*/ viPrintf(viESA,"INIT:IMM \n");
Programming Examples
/*Read the operation complete query */ viQueryf(viESA, "*OPC?\n", "%d", &lOpc); if (!lOpc) {
printf("Program Abort! error ocurred: last command was not completed!\n");
exit(0); } /*Query the Trace Data using ASCII Format */ viQueryf(viESA,"%s\n", "%#t","TRAC:DATA? TRACE1" , &iNum , cResult);
/*Remove the "," from the ASCII trace data for analyzing data*/ cToken = strtok(cResult,",");
/*Save trace data to an ASCII to a file, by removing the "," token*/ fTraceFile=fopen("C:\\temp\\ReadAscRS232.txt","w"); fprintf(fTraceFile,"ReadAscRS232.exe Output\nHewlett-Packard 1999\n\n"); fprintf(fTraceFile,"\tAmplitude of point[%d] = %s dBm\n",lCount+1,cToken); while (cToken != NULL)
{
lCount++;
cToken =strtok(NULL,",");
if (lCount != iSwpPnts) fprintf(fTraceFile,"\tAmplitude of point[%d] = %s
dBm\n",lCount+1,cToken);
} fprintf(fTraceFile,"\nThe Total trace data points of the spectrum are :[%d]
\n\n",lCount);
Chapter 3 3-37
Programming Examples
Reading Trace Data Using ASCII Format (RS-232)
fclose(fTraceFile);
/*Close the session*/ viClose(viESA); viClose(defaultRM); }
3-38 Chapter3

Reading Trace Data Using 32-bit Real Format (RS-232)

Reading Trace Data Using 32-bit Real Format (RS-232)
/************************************************************/ /* Reading Trace Data using 32-bit Real Format (RS-232) */ /* */ /* This C programming example does the following. */ /* The SCPI instrument commands used are given as */ /* reference. */ /* */ /* - Opens an RS-232 session at COM1/COM2 */ /* - Clears the Analyzer */ /* - Resets the Analyzer */ /* *RST */ /* - Set the input port to the 50 MHz amplitude reference */ /* CAL:SOUR:STAT ON */ /* - Query for the number of sweep points (for firmware */ /* revision A.04.00 and later). Default is 401. */ /* SENS:SWE:POIN? */ /* - Calculate the number of bytes in the header */ /* - Set the analyzer to single sweep mode */ /* INIT:CONT 0 */ /* - Sets the analyzer center frequency and span to 50 MHz */ /* SENS:FREQ:CENT 50 MHZ */ /* SENS:FREQ:SPAN 50 MHZ */ /* - Specify 10 dB per division for the amplitude scale in */ /* and dBm Units */ /* DISP:WIND:TRAC:Y:SCAL:PDIV 10 dB */ /* UNIT:POW DBM */ /* - Set the analyzer trace data to 32-bit Real */ /* FORM:DATA: REAL,32 */ /* - Set the binary order to swap */ /* FORM:BORD SWAP */ /* - Trigger a sweep */ /* INIT:IMM */ /* - Check for operation complete */ /* *OPC? */ /* - Calculate the number of bytes in the trace record */ /* - Set VISA timeout to 60 seconds, to allow for slower */ /* transfer times caused by higher number of sweep points */ /* at low baud rates. */ /* - Set VISA to terminate read after buffer is empty */ /* - Query the trace data */ /* TRAC:DATA? TRACE1 */
Programming Examples
Chapter 3 3-39
Programming Examples
Reading Trace Data Using 32-bit Real Format (RS-232)
/* - Reset VISA timeout to 3 seconds */ /* - Remove the "," from the ACSII data */ /* - Save the trace data to an ASCII file */ /* - Close the session */ /************************************************************/
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <conio.h> #include <ctype.h> #include <string.h> #include "visa.h"
#define hpESA_IDN_E4401B "Hewlett-Packard, E4401B" #define hpESA_IDN_E4411B "Hewlett-Packard, E4411B"
ViSession defaultRM, viESA; ViStatus errStatus; ViChar cIdBuff[256]= {0}; char cEnter = 0; int iResult = 0;
/*Set the input port to 50MHz amplitude reference*/ void Route50MHzSignal() {
viQueryf(viESA, "*IDN?\n", "%t", &cIdBuff); iResult = (strncmp( cIdBuff, hpESA_IDN_E4401B, strlen(hpESA_IDN_E4401B)) &&
strncmp( cIdBuff, hpESA_IDN_E4411B, strlen(hpESA_IDN_E4411B))); if( iResult == 0 ) {
/*Set the input port to the 50MHz amplitude reference for the models*/ /*E4411B and E4401B*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n"); } else {
/* For the analyzers having frequency limits >= 3GHz, prompt the user to*/
/* connect the amplitude reference output to the input*/
printf ("Connect AMPTD REF OUT to the INPUT \n");
printf ("......Press Return to continue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Signal*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
3-40 Chapter3
Programming Examples
Reading Trace Data Using 32-bit Real Format (RS-232)
} }
void main() { /*Program Variables*/ ViStatus viStatus= 0; ViChar _VI_FAR cResult[1024000] = {0}; ViReal32 dTraceArray[1024] = {0}; char cBufferInfo[7]= {0}; long lNumberBytes =0L; long lOpc =0L; unsigned long lRetCount = 0L; int iSize = 0; /*BytesPerPnt is 4 for Real32 or Int32 formats, 8 for Real64, and 2 for Uint16*/ int iBytesPerPnt = 4; int iSwpPnts = 401; /*Number of points per sweep*/ int iDataBytes = 1604;/*Number of data points, assuming 4 bytes per point*/ int iHeaderBytes = 6; /*Number of bytes in the header, assuming 1604 data bytes*/ FILE *fTraceFile;
/* Open a serial session at COM1 */ viStatus=viOpenDefaultRM(&defaultRM); if (viStatus =viOpen(defaultRM,"ASRL1::INSTR",VI_NULL,VI_NULL,&viESA) !=
VI_SUCCESS) {
printf("Could not open a session to ASRL device at COM1!!\n");
exit(0); } /*Clear the instrument */ viClear(viESA);
/*Reset the instrument. This will set number of sweep points to default of 401*/ viPrintf(viESA,"*RST\n");
/*Display the program heading */ printf("\n\t\t Read in Trace Data using ASCII Format (using RS-232) Program \n\n"
);
/* Set the input port to the internal 50MHz reference source */ Route50MHzSignal();
/*Query number of sweep points per trace (firmware revision A.04.00 or later)*/ /*For firmware revisions prior to A.04.00, the number of sweep points is 401 */ iSwpPnts = 401; viQueryf(viESA,"SENSE:SWEEP:POINTS?\n","%d",&iSwpPnts);
Chapter 3 3-41
Programming Examples
Reading Trace Data Using 32-bit Real Format (RS-232)
/*Calculate number of bytes in the header. The header consists of the "#" sign*/ /*followed by a digit representing the number of digits to follow. The digits */ /*which follow represent the number of sweep points multiplied by the number */ /*of bytes per point. */ iHeaderBytes = 3; /*iDataBytes >0, plus increment for "#" and "n" */ iDataBytes = (iSwpPnts*iBytesPerPnt); lNumberBytes = iDataBytes; while ((iDataBytes = (iDataBytes / 10 )) > 0 ) {
iHeaderBytes++;
}
/*Set analyzer to single sweep mode */ viPrintf(viESA,"INIT:CONT 0 \n");
/* Set the analyzer to 50MHz-center frequency */ viPrintf(viESA,"SENS:FREQ:CENT 50 MHZ\n");
/*Set the analyzer to 50MHz Span */ viPrintf(viESA,"SENS:FREQ:SPAN 50 MHZ\n");
/* Specify dB per division of each vertical division & Units */ viPrintf(viESA,"DISP:WIND:TRAC:Y:SCAL:PDIV 10dB\n"); viPrintf(viESA,"UNIT:POW DBM\n");
/*Set analyzer trace data format to 32-bit Real */ viPrintf(viESA,"FORM:DATA REAL,32\n");
/*Set the binary byte order to SWAP */ viPrintf(viESA, "FORM:BORD SWAP\n");
/*Trigger a sweep */ viPrintf(viESA,"INIT:IMM\n");
/*Read the operation complete query */ viQueryf(viESA, "*OPC?\n", "%d", &lOpc); if (!lOpc) {
printf("Program Abort! error ocurred: last command was not completed!\n");
exit(0); } /*Calculate size of trace record. This will be the sum of HeaderBytes, Number*/ /*Bytes (the actual data bytes) and the "\n" terminator*/ iSize = lNumberBytes + iHeaderBytes + 1;
3-42 Chapter3
Programming Examples
Reading Trace Data Using 32-bit Real Format (RS-232)
/*Increase timeout to 60 sec*/ viSetAttribute(viESA,VI_ATTR_TMO_VALUE,60000);
/*Set RS-232 interface to terminate when the buffer is empty*/ viSetAttribute(viESA,VI_ATTR_ASRL_END_IN,VI_ASRL_END_NONE);
/*Get trace header data and trace data*/ viPrintf(viESA,"TRAC:DATA? TRACE1\n"); viRead (viESA,(ViBuf)cResult,iSize,&lRetCount);
/*Reset timeout to 3 sec*/ viSetAttribute(viESA,VI_ATTR_TMO_VALUE,3000);
/*Extract the trace data*/ memcpy(dTraceArray,cResult+iHeaderBytes,(size_t)lNumberBytes);
/*Save trace data to an ASCII file*/ fTraceFile=fopen("C:\\temp\\ReadTrace32Rs232.txt","w"); fprintf(fTraceFile,"ReadTrace32Rs232.exe Output\nHewlett-Packard 1999\n\n"); fprintf(fTraceFile,"The %d trace data points of the
spectrum:\n\n",(lNumberBytes/4)); for ( long i=0;i<lNumberBytes/iBytesPerPnt;i++)
fprintf(fTraceFile,"\tAmplitude of point[%d] = %.2lf
dBm\n",i+1,dTraceArray[i]); fclose(fTraceFile);
/*Close the session*/ viClose(viESA); viClose(defaultRM); }
Chapter 3 3-43
Programming Examples

Using Limit Lines

Using Limit Lines
/************************************************************/ /* Using Limit Lines */ /* */ /* This C programming example does the following. */ /* The SCPI instrument commands used are given as */ /* reference. */ /* */ /* */ /* - Open an HP-IB session at address 18. */ /* - Clear the analyzer. */ /* *CLR */ /* - Reset the analyzer. */ /* *RST */ /* - Define the upper limit line to have frequency/ */ /* amplitude pairs. */ /* CALC:LLINE1:CONT:DOM FREQ */ /* CALC:LLINE1:TYPE UPP */ /* CALC:LLINE1:DISP ON */ /* CALC:LLINE1:DATA freq1,amp1,1,freq2,amp2,1... */ /* - Define the lower limit line to have frequency/amplitude*/ /* pairs. */ /* CALC:LLINE2:CONT:DOM FREQ */ /* CALC:LLINE2:TYPE LOW */ /* CALC:LLINE2:DISP ON */ /* CALC:LLINE2:DATA freq1,amp1,1,freq2,amp2,1... */ /* - Turn the limit line test function on. */ /* CALC:LLINE2:STAT ON */ /* - Set the analyzer to a center frequency of 50 MHz, span */ /* to 20 MHz, and resolution bandwidth to 1 MHz. */ /* SENS:FREQ:SPAN 20 MHZ */ /* SENS:FREQ:CENT 50 MHZ */ /* SENS:BWID:RES 1 MHZ */ /* - Turn the limit line test function on. */ /* - Set the analyzer reference level to 0 dBm. */ /* DISP:WIND:TRAC:Y:SCAL:RLEV 0 */ /* - Set the input port to the 50 MHz amplitude reference. */ /* CAL:SOUR:STAT ON */ /* - Check to see if limit line passes or fails. It should */ /* pass. */ /* CALC:LLINE:FAIL? */ /* - Pause for 5 seconds. */ /* - Deactivate the 50 MHz alignment signal. */
3-44 Chapter3
/* CAL:SOUR:STAT OFF */ /* - The limit line test should fail. */ /* - Close the session. */ /************************************************************/
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <conio.h> #include <ctype.h> #include <string.h> #include <windows.h> #include "visa.h" #define YIELD Sleep(5000)
#define hpESA_IDN_E4401B "Hewlett-Packard, E4401B" #define hpESA_IDN_E4411B "Hewlett-Packard, E4411B"
Programming Examples
Using Limit Lines
ViSession defaultRM, viESA; ViStatus errStatus; ViChar cIdBuff[256]= {0}; char cEnter = 0; int iResult = 0; long lLimitTest =0L;
/*Set the input port to 50MHz amplitude reference*/ void Route50MHzSignal() {
viQueryf(viESA, "*IDN?\n", "%t", &cIdBuff); iResult = (strncmp( cIdBuff, hpESA_IDN_E4401B, strlen(hpESA_IDN_E4401B)) &&
strncmp( cIdBuff, hpESA_IDN_E4411B, strlen(hpESA_IDN_E4411B)));
if( iResult == 0 ) {
/*Set the input port to the 50MHz amplitude reference for the models*/ /*E4411B and E4401B*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n"); } else {
/* For the analyzers having frequency limits >= 3GHz, prompt the user*/
/* to connect the amplitude reference output to the input*/
printf ("Connect AMPTD REF OUT to the INPUT \n");
printf ("......Press Return to continue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Signal*/
Chapter 3 3-45
Loading...