HP 53181A Operating instructions

Programming
Guide
HP 53181A
Frequency Counter


This guide describes how to program the HP 53181A 225 MHz Frequency Counter.
The information in this guide applies to instruments having the number prefix listed
below, unless accompanied by a “Manual Updating Changes” package indicating
otherwise.
SERIAL PREFIX NUMBER: 3711 and above
Programming Guide
HP 53181A 225 MHz
Frequency Counter

Copyright Hewlett-Packard
Company 1994, 1995,1997
All Rights Reserved.
Reproduction, adaptation, or
translations without prior written
permission is prohibited, except
as allowed under the copyright
laws.
Printed: June 1997
Printed in USA
Manual part number
53181-90002
Certification
and Warranty
Certification
Hewlett-Packard Company
certifies that this product met its
published specification at the
time of shipment from the
factory. Hewlett-Packard further
certifies that its calibration
measurements are traceable to the
United States National Institute
of Standards and Technology
(formerly National Bureau of
Standards), to the extent allowed
by the Institute's calibration
facility, and to the calibration
facilities of other International
Standards Organization
members.
Warranty
This Hewlett-Packard instrument
product is warranted against
defects in material and
workmanship for a period of
three years from date of
shipment. During the warranty
period, Hewlett-Packard
Company will, at its option,
either repair or replace products
which prove to be defective.
For detailed warranty
information, see back matter.
Safety Considerations
General
This product and related
documentation must be reviewed
for familiarization with this
safety markings and instructions
before operation.
This product is a safety Class I
instrument (provided with a
protective earth terminal).
Before Cleaning
Disconnect the product from
operating power before cleaning.
Before Applying Power
Verify that the product is set to
match the available line voltage
and the correct fuse is installed.
Refer to instructions in Chapter 1
(page 1-11) of the Manual.
Safety Earth Ground
An uninterruptible safety earth
ground must be provided from
the mains power source to the
product input wiring terminals or
supplied power cable.
Warning Symbols That May
Be Used In This Book
Instruction manual symbol; the
product will be marked with this
symbol when it is necessary for
the user to refer to the instruction
manual.
Indicates hazardous voltages.
Safety Considerations
(contd)
Indicates earth (ground) terminal.
or
Indicated terminal is connected to
chassis when such connection is
not apparent.
Indicates Alternating
current.
Indicates Direct current.
WARNING
BODILY INJURY OR DEATH
MAY RESULT FROM
FAILURE TO HEED A
WARNING. DO NOT
PROCEED BEYOND A
WARNING SIGN UNTIL THE
INDICATED CONDITIONS
ARE FULLY UNDERSTOOD
AND MET.
CAUTION
Damage to equipment, or
incorrect measurement
data, may result from
failure to heed a caution. Do
not proceed beyond a
CAUTION sign until the
indicated conditions are
fully understood and met.
For additional safety and
acoustic noise information, see
back matter.
Hewlett-Packard Company
Santa Clara Division
5301 Stevens Creek Boulevard
Santa Clara, California 95052-8059

iii
1 Before You Start . . .
Introduction 1-2
Getting Started 1-3
How to Use This Guide 1-3
New Users 1-3
What You Should Understand 1-3
Learning to Program the Counter 1-4
Experienced Programmers 1-4
Applications 1-5
Programming Guide Contents 1-6
Assumptions 1-6
Related Documentation 1-7
2 Commands Summary
Introduction 2-2
Chapter Summary 2-2
Front Panel to SCPI Command Maps 2-3
HP 53181A Command Summary 2-16
SCPI Conformance Information 2-16
IEEE 488.2 Common Commands 2-17
HP 53181A SCPI Subsystem Commands 2-20
Std/New Column 2-20
Parameter Form Column 2-20
*RST Response 2-32
3 Programming Your Counter for Remote Operation
Introduction 3-2
Chapter Summary 3-2
Where to Find Some Specific Information 3-2
Where to Find HP BASIC Programming Examples 3-3
Where to Find QuickBASIC Programming Examples 3-3
Where to Find Turbo C Programming Examples 3-3
Contents

Contents
iv
Configuring the HP-IB 3-4
To Set the HP-IB Mode and Address 3-4
To Connect the Counter to a Computer 3-6
Remote/Local Operation 3-6
Overview of Command Types and Formats 3-7
Common Command Format 3-7
SCPI Command and Query Format 3-7
Elements of SCPI Commands 3-8
Subsystem Command Syntax 3-8
Common Command Syntax 3-8
Abbreviated Commands 3-9
Keyword Separator 3-9
Optional Keyword 3-10
Parameter Types 3-11
Parameter Separator 3-12
Query Parameters 3-12
Suffixes 3-12
Suffix Elements 3-12
Suffix Multipliers 3-13
Command Terminator 3-13
Using Multiple Commands 3-14
Program Messages 3-14
Program Message Syntax 3-14
Overview of Response Message Formats 3-16
Response Messages 3-16
Response Message Syntax 3-16
Response Message Data Types 3-18
Status Reporting 3-20
Status Byte Register and Service Request Enable Register 3-22
Status Byte Register 3-22
Service Request Enable Register 3-24
Standard Event Status Register Group 3-25
Standard Event Status Register 3-25
Standard Event Status Enable Register 3-28

Contents
v
Operation Status Register Group and Questionable Data/Signal
Status Register Group 3-28
Condition Register 3-30
Transition Filter 3-30
Event Register 3-31
Event Enable Register 3-31
Operation Status Register Group 3-32
Questionable Data/Signal Status Register Group 3-34
Command Settings for Optimizing Throughput 3-37
Commands to Set Counter for Optimal Throughput 3-37
Typical Optimizing Throughput Results for Different Computers 3-39
How to Program the Counter for Status Reporting 3-40
Determining the Condition of the Counter 3-40
Resetting the Counter and Clearing the HP-IB Interface—
Example 1 3-40
Using the Standard Event Status Register to Trap an Incorrect
HP-IB command—Example 2 3-41
Event Status Register 3-41
Using the Questionable Data/Signal Status Register to Alert the Computer When
Automatic Interpolator Calibration is Disabled—Example 3 3-41
Questionable Data Status Register 3-42
Using the Operation Status Register to Alert the Computer When Measuring has
Completed—Example 4 3-42
Operation Status Register 3-42
How to Program the Counter to Display Results 3-45
Configuring the Counter's Display 3-45
Commands for Displaying Non-Scaled/Offset Results 3-45
Commands for Displaying Scaled/Offset Results 3-46
Commands for Displaying the Limit Graph 3-46
Commands for Displaying Statistics Results 3-46
Commands for Enabling and Disabling the Display 3-47
How to Program the Counter to Synchronize Measurements 3-48
Synchronizing Measurement Completion 3-48
Resetting the Counter and Clearing the HP-IB Interface 3-48
Using the *WAI Command 3-48
Using the *OPC? Command 3-49
Using the *OPC Command to Assert SRQ 3-50

Contents
vi
How to Program the Counter for Math/Limit Operations 3-51
Updating Math and Limit Results Over HP-IB 3-51
Using the Scale and Offset Over HP-IB 3-52
How to Program the Counter to Define Macros 3-54
Writing SCPI Programs 3-57
Programming Examples 3-60
Using HP BASIC 3-60
To Send a Double-Quoted String 3-60
To Send a Single-Quoted String 3-60
Using QuickBASIC 3-61
Using Turbo C 3-61
List of the Programming Examples 3-61
Easiest Way to Make a Measurement (HP BASIC) 3-62
To Make a Frequency Measurement (HP BASIC) 3-64
To Perform Limit Testing (HP BASIC) 3-65
To Measure the Statistics of 50 Measurements(HP BASIC) 3-66
To Use Limits to Filter Data Before Measuring Stats (HP BASIC) 3-68
To Read and Store Calibration Information (HP BASIC) 3-70
To Optimize Throughput (HP BASIC) 3-71
To Use Macros (HP BASIC) 3-73
To Make a Frequency Measurement (QuickBASIC) 3-75
To Perform Limit Testing (QuickBASIC) 3-76
To Measure the Statistics of 50 Measurements (QuickBASIC) 3-78
To Use Limits to Filter Data Before Measuring Stats
(QuickBASIC) 3-80
To Read and Store Calibration Data (QuickBASIC) 3-82
To Optimize Throughput (QuickBASIC) 3-83
To Use Macros (QuickBASIC) 3-85
To Make a Frequency Measurement (Turbo C) 3-88
To Use Limits to Filter Data Before Measuring Statistics
(Turbo C) 3-90
To Optimize Throughput (Turbo C) 3-93

Contents
vii
4 Commands Reference
Introduction 4-2
:ABORt 4-4
:CALCulate Subsystems 4-5
:CALCulate[1] Subsystem 4-7
:CALCulate[1]:DATA? 4-7
:CALCulate[1]:FEED "[:]SENSe[1]" 4-8
:CALCulate[1]:IMMediate 4-8
:CALCulate[1]:IMMediate:AUTO 4-9
:CALCulate[1]:MATH Subtree 4-9
:CALCulate[1]:MATH[:EXPRession]:CATalog? 4-9
:CALCulate[1]:MATH[:EXPRession][:DEFine]? 4-10
:CALCulate[1]:MATH[:EXPRession]:NAME
SCALE_OFFSET 4-10
:CALCulate[1]:MATH[:EXPRession]:SELect
SCALE_OFFSET 4-10
:CALCulate[1]:MATH:STATe 4-10
:CALCulate2 Subsystem 4-11
:CALCulate2:FEED "[:]CALCulate[1]" 4-11
:CALCulate2:IMMediate 4-11
:CALCulate2:IMMediate:AUTO 4-12
:CALCulate2:LIMit Subtree 4-12
:CALCulate2:LIMit:CLEar:AUTO 4-13
:CALCulate2:LIMit:CLEar[:IMMediate] 4-13
:CALCulate2:LIMit:DISPlay 4-13
:CALCulate2:LIMit:FAIL? 4-14
:CALCulate2:LIMit:FCOunt:LOWer? 4-15
:CALCulate2:LIMit:FCOunt[:TOTal]? 4-15
:CALCulate2:LIMit:FCOunt:UPPer? 4-15
:CALCulate2:LIMit:LOWer[:DATA] 4-16
:CALCulate2:LIMit:PCOunt[:TOTal]? 4-17
:CALCulate2:LIMit:STATe 4-17
:CALCulate2:LIMit:UPPer[:DATA] 4-18

Contents
viii
:CALCulate3 Subsystem 4-19
:CALCulate3:AVERage Subtree 4-19
:CALCulate3:AVERage:ALL? 4-19
:CALCulate3:AVERage:CLEar 4-20
:CALCulate3:AVERage:COUNt 4-20
:CALCulate3:AVERage:COUNt:CURRent? 4-21
:CALCulate3:AVERage[:STATe] 4-21
:CALCulate3:AVERage:TYPE 4-22
:CALCulate3:DATA? 4-22
:CALCulate3:FEED "[:]CALCulate[1]" 4-23
:CALCulate3:LFILter Subtree 4-23
:CALCulate3:LFILter:LOWer[:DATA] 4-23
:CALCulate3:LFILter:STATe 4-24
:CALCulate3:LFILter:UPPer[:DATA] 4-24
:CALCulate3:PATH? 4-25
:CALibration Subsystem 4-26
:CALibration[:ALL]? 4-26
:CALibration:COUNt? 4-26
:CALibration:DATA 4-27
:CALibration:SECurity Subtree 4-28
:CALibration:SECurity:CODE 4-28
:CALibration:SECurity:STATe 4-28
:CONFigure Subsystem 4-30
Device Clear 4-31
:DIAGnostic Subsystem 4-32
:DIAGnostic:CALibration:INPut[1]:GAIN:AUTO 4-32
:DIAGnostic:CALibration:INPut[1]:OFFSet:AUTO 4-33
:DIAGnostic:CALibration:INTerpolator:AUTO 4-33
:DIAGnostic:CALibration:ROSCillator:AUTO 4-34
:DIAGnostic:CALibration:STATus? 4-34
:DIAGnostic:MEASure:RESolution? 4-35

Contents
ix
:DISPlay Subsystem 4-36
:DISPlay:ENABle 4-36
:DISPlay:MENU[:STATe] OFF 4-36
:DISPlay[:WINDow]:TEXT:FEED "[:]CALCulate2" |
"[:]CALCulate3" 4-37
:DISPlay[:WINDow]:TEXT:MASK 4-38
:DISPlay[:WINDow]:TEXT:RADix 4-39
:FETCh Subsystem 4-40
:FORMat Subsystem 4-41
:FORMat[:DATA] 4-41
Group Execute Trigger(GET) 4-42
:HCOPy Subsystem 4-43
:HCOPy:CONTinuous 4-43
:INITiate Subsystem 4-44
:INITiate:AUTO 4-44
:INITiate:CONTinuous 4-44
:INITiate[:IMMediate] 4-46
:INPut[1] Subsystem 4-48
:INPut[1]:ATTenuation 4-48
:INPut[1]:COUPling 4-48
:INPut[1]:FILTer[:LPASs][:STATe] 4-48
:INPut[1]:FILTer[:LPASs]:FREQuency? 4-49
:INPut[1]:IMPedance 4-49
:INPut2 Subsystem 4-50
:INPut2:COUPling? 4-50
:INPut2:IMPedance? 4-50
:MEASure Subsystem 4-51
Measurement Instructions 4-52
:CONFigure 4-53
:CONFigure? 4-54
:FETCh 4-55
:MEASure 4-56

Contents
x
:READ 4-57
:MEASure[:SCALar][:VOLTage]:FREQuency? 4-59
:MEASure[:SCALar][:VOLTage]:FREQuency:RATio? 4-61
:MEASure[:SCALar][:VOLTage]:MAXimum? 4-62
:MEASure[:SCALar][:VOLTage]:MINimum? 4-62
:MEASure[:SCALar][:VOLTage]:PERiod? 4-63
:MEASure[:SCALar][:VOLTage]:PTPeak? 4-64
Using :MEAsure 4-65
Using :CONFigure with :READ? 4-66
Using :CONFigure with :INITiate and :FETCh? 4-66
:MEMory Subsystem 4-68
:MEMory:DELete:MACRo 4-68
:MEMory:FREE:MACRo? 4-68
:MEMory:NSTates? 4-68
[:SENSe] Subsystem 4-69
[:SENSe]:DATA? ["[:]SENSe[1]"] 4-69
[:SENSe]:EVENt[1] Subtree 4-69
[:SENSe]:EVENt[1]:HYSTeresis:RELative 4-69
[:SENSe]:EVENt[1]:LEVel[:ABSolute] 4-70
[:SENSe]:EVENt[1]:LEVel[:ABSolute]:AUTO 4-71
[:SENSe]:EVENt[1]:LEVel:RELative 4-71
[:SENSe]:EVENt[1]:SLOPe 4-72
[:SENSe]:EVENt2 Subtree 4-72
[:SENSe]:EVENt2:LEVel[:ABSolute]? 4-72
[:SENSe]:EVENt2:SLOPe? 4-73
[:SENSe]:FREQuency Subtree 4-73
[:SENSe]:FREQuency:ARM Subtree 4-73
[:SENSe]:FREQuency:ARM[:STARt]:SLOPe 4-73
[:SENSe]:FREQuency:ARM[:STARt]:SOURce 4-74
[:SENSe]:FREQuency:ARM:STOP:DIGits 4-74
[:SENSe]:FREQuency:ARM:STOP:SLOPe 4-75
[:SENSe]:FREQuency:ARM:STOP:SOURce 4-75
[:SENSe]:FREQuency:ARM:STOP:TIMer 4-75
[:SENSe]:FREQuency:EXPected[1|2] 4-76
[:SENSe]:FREQuency:EXPected[1|2]:AUTO 4-77
[:SENSe]:FUNCtion[:ON] 4-77

Contents
xi
[:SENSe]:ROSCillator Subtree 4-79
[:SENSe]:ROSCillator:EXTernal:CHECk 4-79
[:SENSe]:ROSCillator:EXTernal:FREQuency? 4-79
[:SENSe]:ROSCillator:SOURce 4-80
[:SENSe]:ROSCillator:SOURce:AUTO 4-80
:STATus Subsystem 4-82
:STATus:OPERation Subtree 4-82
:STATus:OPERation:CONDition? 4-82
:STATus:OPERation:ENABle 4-83
:STATus:OPERation[:EVENt]? 4-83
:STATus:OPERation:NTRansition 4-84
:STATus:OPERation:PTRansition 4-84
:STATus:PRESet 4-85
:STATus:QUEStionable Subtree 4-86
:STATus:QUEStionable:CONDition? 4-86
:STATus:QUEStionable:ENABle 4-87
:STATus:QUEStionable[:EVENt]? 4-87
:STATus:QUEStionable:NTRansition 4-88
:STATus:QUEStionable:PTRansition 4-88
:SYSTem Subsystem 4-90
:SYSTem:COMMunicate Subtree 4-90
:SYSTem:COMMunicate:SERial:CONTrol:DTR 4-90
:SYSTem:COMMunicate:SERial:TRANsmit:BAUD 4-91
:SYSTem:COMMunicate:SERial:TRANsmit:PARity[:TYPE] 4-92
:SYSTem:COMMunicate:SERial:TRANsmit:PACE 4-92
:SYSTem:ERRor? 4-92
:SYSTem:KEY 4-94
:SYSTem:KEY:LOG? 4-95
:SYSTem:VERSion? 4-95
:TRACe Subsystem 4-96
:TRACe:CATalog? 4-96
:TRACe[:DATA] OFFSET 4-96
:TRACe[:DATA]? OFFSET 4-96
:TRACe[:DATA] SCALE 4-97
:TRACe[:DATA]? SCALE 4-97
:TRIGger Subsystem 4-98
:TRIGger:COUNt:AUTO 4-98

Contents
xii
*CAL?(Calibration Query) 4-99
*CLS(Clear Status Command) 4-100
*DDT(Define Device Trigger Command) 4-101
*DMC(Define Macro Command) 4-102
*EMC(Enable Macro Command) 4-103
*EMC?(Enable Macro Query) 4-103
*ESE(Standard Event Status Enable Command) 4-104
*ESE?(Standard Event Status Enable Query) 4-104
*ESR?(Event Status Register Query) 4-106
*GMC?(Get Macro Contents Query) 4-107
*IDN?(Identification Query) 4-108
*LMC?(Learn Macro Query) 4-109
*OPC(Operation Complete Command) 4-110
*OPC?(Operation Complete Query) 4-111
*OPT?(Option Identification Query) 4-112
*PMC(Purge Macro Command) 4-113
*RCL(Recall Command) 4-114
*RST(Reset Command) 4-116
*SAV(Save Command) 4-117
*SRE(Service Request Enable Command) 4-119
*SRE?(Service Request Enable Query) 4-119
*STB?(Status Byte Query) 4-120
*TRG(Trigger Command) 4-121
*TST?(Self-Test Query) 4-122
*WAI(Wait-to-Continue Command) 4-123

Contents
xiii
5 Errors
Introduction 5-2
Displaying Errors 5-2
Reading an Error 5-2
Error Queue 5-3
Error Types 5-4
No Error 5-4
Command Error 5-4
Execution Error 5-5
Device- or Counter-Specific Error 5-5
Query Error 5-6
Index

Contents
xiv

1
Before You Start ...

Before You Start ...
Introduction
1-2
Introduction
This programming guide contains programming information for the
HP 53181A Frequency Counter.
This guide assumes you are familiar with the front-panel operation of the Counter.
See the HP 53181A Operating Guidefor detailed information about front-panel
operation. You should use this programming guide together with the operating
guide. Knowing how to control the Counter from the front panel and understanding
the measurements you wish to perform makes the programming task much easier.
The operating guide provides explanations and task procedures for all of the
Counter's measurement functions, and contains the specifications for the Counter.
By sending Standard Commands for Programmable Instruments (SCPI) commands,
all of the Counter's front-panel functions can be remotely operated via the Hewlett-
Packard Interface Bus (HP-IB), as well as the additional throughput optimizing
function not available from the front panel.
This Counter programming commands conform to the Standard Commands for
Programmable Instruments (SCPI) Standard Version 1992.0. The SCPI standard
does not completely redefine how to program instruments over the Hewlett-Packard
Interface Bus (HP-IB). However, it does standardize the structure and content of an
instrument's command set to reflect the best programming practices developed by
people using HP-IB. It also establishes standard command mnemonics for similar
functions in all of the instruments that conform to the SCPI standard.
If you have programmed any HP instruments that have been released over the last
few years, you will have seen a general trend toward the techniques specified in the
SCPI standard. For example, several instruments are already using a hierarchy of
commands that is similar to the command structure defined by the SCPI standard.

Before You Start ...
Getting Started
1-3
Getting Started
Before attempting to program the Counter, take some time to familiarize yourself
with the content of this guide. The remainder of this chapter contains the following
information:
•An explanation of how you should use the programming guide based on your
experience programming instruments and your testing requirements.
•A description of the guide contents.
•A statement of assumptions that are made in the guide.
•A list of related documentation.
How to Use This Guide
How you use this guide depends upon how much you already know about
programming instruments and how complex your measurement requirements are.
Let's start by establishing your programming background, and then discuss the type
of measurements you want to perform.
New Users
What You Should Understand
As a new user, you should understand that you must have some understanding of a
high-level language such as Pascal, BASIC, C, or FORTRAN before you can use
the command set defined in this guide to control the Counter. (In Chapter 3,
“Programming Your Counter for Remote Operation,” there are programming
examples provided in HP BASIC, Microsoft QuickBASIC, and Borland
Turbo C.) However, whatever language you use, command strings that control the
Counter remain the same.

Before You Start ...
How to Use This Guide
1-4
Learning to Program the Counter
To learn how to program the Counter, perform the following:
•Scan the summary tables in Chapter 2, “Commands Summary,”
to get a feeling for the number and structure of commands available to you.
•Read and study map drawings in the section titled “Front Panel to SCPI
Command Maps” in Chapter 2.
•Read Chapter 3, “Programming Your Counter for Remote Operation,” for an
overview of the SCPI concepts as they relate to the HP 53181A Frequency
Counter. Look at the flowcharts, which illustrate some of the decisions you
must make when programming the Counter.
•Read the section at the end of Chapter 3 title d “Programming Examples for
Making Common Measurements,” which provides programming examples.
•Modify some of the programming examples to select specific measurement
functions. If the programs work, consider yourself an experienced
programmer and use Chapter 4, “Commands Reference,” as a reference for
detailed information of all the Counter's SCPI commands.
Experienced Programmers
If you have programmed other HP-IB instruments, you will probably be familiar
with many of the concepts and techniques discussed in this guide. Also, you will
find that using the SCPI commands is very similar to using the older HP-IB
commands. The main difference is the hierarchy of the subsystem commands.
(However, this type of structure has been previously used on other instruments.)
Because the SCPI command set and some of the status reporting techniques are
new, you may want to use the following sequence to learn the Counter programming
requirements:
•Look over the steps for a new user and perform any that you think are
applicable to your current level of knowledge. In particular, look at the
measurement techniques and examples provide in Chapter 3, “Programming
Your Counter for Remote Operation.”
Table of contents
Other HP Cash Counter manuals