This guide describes how to program the HP 53150A, 53151A, and 53152A
Microwave Frequency Counters. 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:3735A and above (53150A)
3736A and above (53151A)
3737A and above (53152A)
HP 53150A/151A/152A Microwave
Frequency Counter
Page 4
y
y
y
y
y
WARNING
CAUTION
y
WARNING
Copyright Hew le tt-Packard
Company 1996
All Rights Reserved.
Reproduction, adaptation, or
translations without prior
written permission is
prohibited, except as allowed
under the copyright laws.
Printed: November 1997
Printed in USA
Manual part number
53150-90002
Certification
and Warrant
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.
Warrant
HP warrants HP hardware,
accessories and supplies against
defects in materials and
workmanship for a period of one
year from date of shipment. If
HP receives notice of such
defects during the warranty
period, HP will, at its option,
either repair or replace products
which prove to be defective.
Replacement products may be
either new or like-new.
HP warrants that HP software
will not fail to execute its
programming instructions, for
the period specified above, due
to defects in material and
workmanship when properly
installed and used. If HP
receives notice of such defects
during the warranty period, HP
will replace software media
which does not execute its
programming instructions due
to such defects.
For detailed warranty
information, see back matter.
Considerations
Safet
General
This product and related
documentation must be
reviewed for familiarization
with this safety markings and
instructions before operation.
Before Cleaning
Disconnect the product from
operating power before
cleaning.
Warning S
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.
Indicates earth (ground)
terminal.
or
Indicates terminal is connected
to chassis when such connection
is not apparent.
Indicates Alternating current.
Indicates Direct current.
mbols That May
Considerations
Safet
(contd)
BODILY INJURY OR DEATH
MAY RESULT FROM
FAILURE TO HEED A
WARNING. DO NOT
PROCEED BEYOND A
WARNING UNTIL THE
INDICATED CONDITIONS
ARE FULLY UNDERSTOOD
AND MET .
Damage to equipment, or
incorrect measurement data,
may result from failure to
heed a caution. Do not
proceed beyond a
until the indic ated conditio ns
are fully understood and met.
Earth Ground
Safet
An uninterruptible safety earth
ground must be maintaine d
from the mains power source to
the product’s ground circuitry.
WHEN MEASURING POWER
LINE SIGNALS, BE
EXTREMELY CAREFUL AND
ALWAYS USE A
STEP-DOWN ISOLATION
TRANSFORMER WHICH
OUTPUT IS COMPATIBLE
WITH THE INPUT
MEASUREMENT
CAPABILITIES OF THIS
PRODUCT. THIS PRODUCT’S
FRONT AND REAR PANELS
ARE TYPCIALLY AT EARTH
GROUND.
TO MEASURE AC POWER
LINE SIGNALS WITHOUT AN
ISOLATION TRANSFORMER.
For additional safety and
acoustic noise information, see
back matter.
CAUTION
THUS, NEVER TRY
Hewlett-Packard Company8.NC.NL.A.11.03.97.R1.P.CW1C3NC
Santa Clara Divisio n
5301 Stevens Creek Boulevard
Santa Clara, California 95052-8059
Page 5
Contents
y
1Before You Start ...
Introduction1-2
Getting Started1-3
How to Use This Guide1-3
New Users1-4
Experienced Programmers1-5
Applications1-5
Programming Guide Contents1-6
Assumptions1-7
Related Documentation1-8
2Command Summar
Introduction2-2
Chapter Summary2-2
Front Panel to SCPI Command Map2-3
HP 53150A/151A/152A Command Summary2-8
SCPI Conformance Information2-8
IEEE 488.2 Common Commands2-9
HP 53150A/151A/152A SCPI Subsystem Commands2-12
Std/New Column2-12
Parameter Form Column2-12
*RST Response2-19
3Programming Your Counter
for Remote Operation
Introduction3-2
Chapter Summary3-3
Where to Find Some Specific Information3-4
Programming Examples3-4
Programming Guidev
Page 6
Contents
Connecting the Counter to a Computer3-5
To Connect With the HP-IB3-5
IEEE 488.1 Interface Capabilities3-6
To Connect With the RS-232 Serial Interface3-7
Remote/Local Operation3-11
Overview of Command Types and Formats3-12
Common Command Format3-12
SCPI Command and Query Format3-12
Response Messages3-21
Response Message Syntax3-21
Response Message Data Types3-23
Status Reporting3 -25
Status Byte Register and
Service Request Enable Register3-27
Standard Event Status Register Group3-30
The Operation and Questionable Data Status Register
Groups3-33
viProgramming Guide
Page 7
Contents
Programming the Counter
for Status Reporting3-41
Determining the Condition of the Counter3-41
Resetting the Counter and Clearing
the Remote Interface—Exa mple 13-42
Using the Standard Event Status Register to
Trap an Incorrect Command—Example 23-42
Using the Operation Status Register to Alert the Computer
When Measuring has
Completed—Example 33-43
Programming the Counter
to Display Results3-46
Configuring the Counter's Display3-46
Commands for Displaying Results3-47
Command for Displaying Raw Results3-47
Commands for Displaying Relative Results3-47
Commands for Enabling and Disabling the Display3-47
Programming the Counter to
Synchronize Measurements3-48
Synchronizing Measurement Completion3-48
Resetting the Counter and Clearing the Inte rface3-48
Using the *WAI Command3-49
Using the *OPC? Command3-49
Using the *OPC Command to Assert SRQ3-50
Writing SCPI Programs3-52
Programming Guidevii
Page 8
Contents
Programming Examples3-54
Using HP BASIC3-54
Using C3-55
List of the Programming Examples3-55
Making a Frequency Measurement (HP BASIC)3-56
Making a Frequency Measurement (QuickBASIC)3-57
Making a Frequency Measurement (C)3-58
4Command Reference
Introduction4-2
:ABORt Command4-4
:DISPlay Subsystem4-5
Group Execute Trigger
(GET)4-7
:INITiate Subsystem4 -8
:INPut Sub s ys tem4-9
:MEASure Subsystem4-10
Introduction5-2
Reading an Error5-3
Error Queue5-4
Error Types5-5
No Error5-5
Command Error5-6
Execution Error5-6
Device- or Counter-Specific Error5-7
Query Error5-7
Error List5-7
Programming Guideix
Page 10
Contents
xProgramming Guide
Page 11
1
Before You Start ...
Page 12
Chapter 1 Before You Start ...
Introduction
Introduction
1
This programming guide contains programming information for the
HP 53150A, 53151A, and 53152A Microwave Frequency Counters.
This guide assumes you are familiar with the front-panel operation of the
Counter. See the
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 want to perform makes the programming task much
easier. The operating guide provides explanations and 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, you can remotely operate many of the Counter's front-panel
functions via the Hewlett-Packard Interface Bus (HP-IB) or the RS-232
serial interface. These programming commands conform to the
Commands for Programmable Instruments (SCPI) Standard Version
1992.0
instruments over the Hewlett-Packard Interface Bus (HP-IB) or the
RS-232 serial interface. 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.
. The SCPI standard does not completely redefine how to program
HP 53150A/151A/152A Operating Guide
for detailed
Standard
If you have programmed any HP instruments that have been released
over the last few years, you ha ve probably se en a general trend t oward 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.
1-2Programming Guide
Page 13
Chapter 1 Before You Start ...
Getting Started
Getting Started
NOTE
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 mea surements you want to
perform.
With two minor exceptions, the only differen ce between programming the
Counter using the HP-IB interface and the RS-232 serial interface is the
manner in which you connect the Counter to the computer. These
exceptions are:
1
1. The Counter sends a command prompt over the RS-232 interface (but
not the HP-IB) after receiving and executing each command.
2. When an error is detected ( during the Self-Test or during o peration),
the Counter automatically sends an error message (or messages) over
the RS-232 interface (error messages must be requested over the
HP-IB). For additional information on error messages, see Appendix B
of the
HP 3150A/151A/152A Operating Guide
Programming Guide1-3
.
Page 14
Chapter 1 Before You Start ...
How to Use This Guide
New Users
1
What You Should Un de rs t a nd
As a new user, you must have some understanding of a high-level
language, such as BASIC or C, 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, the command strings that control
the Counter remain the same.
Learning to Program the Co un te r
To learn how to program the Counter, perform the following:
•Scan the summary tables in Chapter 2, “Command Summary,”
to get a feeling for the number and structure of commands
available to you.
•Read and study map drawings in the s ection t itled “F ront Panel to
SCPI Command Map” in Chapter 2.
•Read Chapter 3, “Programming Your Counter for Remote
Operation,” for an overview of SCPI concepts as they relate to the
HP 53150A, 53151A, and 53152A Frequency Counters. 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 titled “Programming
Examples.”
•Modify some of the programming examples to select speci f ic
measurement functions. If the programs work, consider yourself
an experienced programmer and use Chapter 4, “Command
Reference,” as a reference for detailed information of all the
Counter's SCPI commands.
1-4Programming Guide
Page 15
Chapter 1 Before You Start ...
How to Use This Guide
Experienced Programmers
If you have programmed other HP-IB instruments, you are probably
familiar with many of the concepts and techniques discussed in this guide.
Using the SCPI commands is also very similar to using the earlier HP-IB
commands. The main difference between the two command sets is the
hierarchy of the subsystem commands. (However, this type of structure
has previously been used on other instruments.)
Because the SCPI command set and some of the status reporting
techniques are new, we advise you 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
provided in Chapter 3, “Programming Your Counter for Remote
Operation.”
•Review the summary tables in Chapter 2, “Command Summary.”
If this chapter contains sufficient information to get you started,
write some test programs to explore the Counter's capabilities. If
you need additional information on any command, refer to the
applicable command description in Chapter 4, “Command
Reference .”
1
•Review the remaining information in this guide to determine what
is applicable to your programming requirements.
If you need more information than is contained in this guide, see the
section in this chapter titled “Related Documentation.”
Applications
After you have read the appropriate information and written some
measurement programs, you may want to expand the scope of your
applications. The following two techniques are explained in detail:
•If you are going to write interrupt-driven programs (or if you just
want to determine the status of the Counter), read the sect ion
titled “Status Reporting” in Chapter 3.
•If you are going to write programs to transfer data between the
Counter and an external computer, read the section titled
“Overview of Response Message Formats” in Chapter 3.
Programming Guide1-5
Page 16
Chapter 1 Before You Start ...
Programming Guide Contents
1
Programming Guide Contents
The following information is contained in this guide:
•Table of Contents
•Chapter 1 (this chapter),“Before You Start ...,” is a preface that
introduces you to the programming guide.
•Chapter 2, “Command Summary,” is a quick reference that
summarizes the Counter's programming commands. It provides
you with front-panel to SCPI command maps, SCPI conformance
information, and command-summary tables.
•Chapter 3, “Programming Your Counter for Remote Operation,”
describes how to connect and set up the Counter for remote
operation, briefly explains the SCPI elements and formats,
describes status reporting, describes how to write programs, and
provides programming examples for each of the main tasks that
you want the Counter to perform.
•Chapter 4, “Command Reference,” is a command dictionary that
describes the SCPI subsystems and IEEE 488.2 Common
commands.
•Chapter 5, “Errors,” lists all of the error messages the Counter
generates and the cause(s) for each error.
•Index
1-6Programming Guide
Page 17
Chapter 1 Before You Start ...
Assumptions
Assumptions
This guide assumes the Counter is correctly installed and interfaced to an
external computer. If it is not, and you intend to use the HP-IB, see the
IEEE HP-IB Interconnection information in
Tutorial Description of the Hewlett-Packard Interface Bus, 1987.
section in this chapter titled “Related Documentation” for ordering
information.) If you intend to use the RS-232 serial interface, see the
section in Chapter 3 titled “To Connect With the RS-232 Serial Interface.”
As previously mentioned, this guide also assumes you are familiar with
the front-panel opera tion of th e Counte r . See th e
Operating Guide
Knowing how to control the Counter from the front panel and
understanding the measurements yo u need to perform makes the
programming task much easier.
for detailed information about front-panel operation.
Hewlett-Packard Company,
(See the
HP 53150A/151A/152A
1
Programming Guide1-7
Page 18
Chapter 1 Before You Start ...
Related Documentation
Related Documentation
1
This section contains a list of documentation that relates to the use of the
Counter. Additional information that may be useful is contained in the
following publications:
1.
HP 53150A/151A/152A Microwave Frequency Counter Operating
(HP Part Number 53150-90001)
Guide
2.
Beginner's Guide to SCPI
Edition).
3.
Beginner's Guide to SCPI
Addison-Wesley Publishing Co. 1991).
4.
Standard Commands for Programmable Instruments (SCPI)
version).
This standard is a guide for the selection of messages to be included in
programmable instrumentation. It is primarily intended for
instrument firmware engineers. Howe ver, you may find it useful if y ou
are programming more than one instrument that claims conformance
to the SCPI standard. You can verify the use of standard SCPI
commands in different instruments.
To obtain a copy of this standard, contact:
SCPI Consortium
8380 Hercules, Suite P3
La Mesa, CA 91942
Phone: (619) 697-8790
FAX: (619) 697-5955
(HP Part Number H2325-90002, July 1990
, Barry Eppler (Hewlett-Packard Press,
, (latest
5. The International Institute of Electrical Engineers and Electronic
Engineers,
Interface for Programmable Instrumentation
1-8Programming Guide
IEEE Standard 488.1-1987, IEEE Standard Digital
.
Page 19
Chapter 1 Before You Start ...
Related Documentation
This standard defines the technical details required to design and
build an HP-IB (IEEE 488.1) interface. This standard contains
electrical specifications and information on protocol that is beyond the
needs of most programmers. However, it can be useful to clarify
formal definitions of certain terms used in related documents.
To obtain a copy of this standard, write to:
Institute of Electrical and Electronic Engineers Inc.
345 East 47th Street
New York, NY 10017 USA
6. The International Institute of Electrical Engineers and Electronic
Engineers, IEEE Standard 488.2-1987, IEEE Standard Codes,
Formats, Protocols, and Common Commands for Use with
ANSI/IEEE Std 488.1-1987 Programmable Instrumentation.
This standard defines the underl ying message forma ts and dat a types
used in SCPI. It is intended more for firmware engineers than for
instrument users/programmers. However, it can be useful if you need
to know the precise definition of specific message formats, data types,
or common commands.
1
To obtain a copy of this standard, write to:
The Institute of Electrical and Electronic Engineers Inc.
345 East 47th Street
New York, NY 10017 USA
This HP BASIC manual contains a good non-technical description of
the HP-IB (IEEE 488.1) interface in Chapter 12, “The HP-IB
Interface.” Subsequent revisions o f HP BASI C may use a slightly
different title for this manual or chapter. This manual is the best
reference on I/O for HP BASIC programmers.
To obtain a copy of this manual, contact your nearest Hewlett-Packard
Sales office.
8. Hewlett-Packard Company, Tutorial Description of the Hewlett-Packard Interface Bus, 1987.
To obtain a copy of this manual, contact your nearest Hewlett-Packard
Sales office.
Programming Guide1-9
Page 20
Chapter 1 Before You Start ...
Related Documentation
1
1-10Programming Guide
Page 21
2
Command Summary
A Quick Reference
Page 22
Chapter 2 Command Summary
Introduction
Introduction
This chapter is a quick reference that summarizes the Counter's
programming commands.
Chapter Summary
Front Panel to SCPI Command Map
•
HP 53150A/151A/152A Command Summary
•
SCPI Conformance Informationpg. 2-8
2
–
IEEE 488.2 Common Commandspg. 2-9
–
HP 53150A/151A/152A SCPI Subsystem Commandspg. 2-12
–
*RST Response
•
3
1
pg. 2-3
2
pg. 2-8
pg. 2-19
1 The section titled “Front Panel to SCPI Command Map” provides maps that show the front-panel keys and their
corresponding (or related) SCPI commands.
2 The section titled “HP 53150A/151A/152A Command Summary” lists the IEEE 488.2 Common Commands
and SCPI Subsystem commands in Table 2-1 and Table 2-2, respectively.
3 The section titled “*RST Response,” lists the states of all of the commands that are affected by the *RST
command in Table 2-3. This section also lists commands that are unaffected by *RST in Table 2-4.
2-2Programming Guide
Page 23
Chapter 2 Command Summary
y
Front Panel to SCPI Command Map
Front Panel to SCPI Command Map
Figures 2-1 and 2-2 are command maps that shows the relationships
between the front-panel keys and the SCPI commands. This map should
help you to identify commands, if you are already familiar with the front
panel.
NOTE
Some SCPI S
[ ] An element inside brackets is optional. Note, the
1 | 2 Means use either 1 or 2.
<numeric_value> Means enter a number.
SENSe Means you
When you see quotation marks in a command’s parameter (shown in the
Parameter Form column in Table 2-2), you must send the quotation marks
with the command. Refer to the section titled “Using HP BASIC” on
page 3-54 of this guide for details on how to use double quotes or single
quotes to enclose the string parameter of a command.
ntax Conventions:
brackets are
be sent to the Counter.
the entire word. The lo wer case letters are opt ional . For
example, SENS and SENSE are both valid. However,
SEN is not valid. (Note SENSe is used here as an
example, but this conven t io n applie s to all SCP I
commands.)
part of the command and should
not
use either all the upper case letters or
must
not
2
Programming Guide2-3
Page 24
Chapter 2 Command Summary
Front Panel to SCPI Command Map
Shift + Freq OffsetShift + Pwr Offset
3
RateAvg
2
MODIFY
Rate
Clear
On/Off
Pwr
Offset
Avg
+/-
HPIB
Resol
Enter
Reset/
Local
Shift
Freq
Offset
Reset/Local
2
1
Menu
Shift + HPIB
Resolution
Chan Select
12
Freq Offset On/Off
11
FREQ
Chan
Select
Rel Freq
Offset
On/Off
Gate
Shift + On/Off
POWER
Channel 2
dBm/ W
Display
Power
Rel Pwr
Offset
On/Off
8
Display Power
Power Offset On/Off
4
5
6
7
9
10
Figure 2-1. Front Panel Control to SCPI Command Map
(Part 1 of 2)
Figure 2-2. Front Panel Menu to SCPI Command Map
(Part 2 of 2)
2
Programming Guide2-7
Page 28
Chapter 2 Command Summary
HP 53150A/151A/152A Command Summary
HP 53150A/151A/152A Command Summary
This section summarizes both the IEEE 488.2 Common and
HP 53150A/151A/152A Standard Commands for Programmable
Instruments (SCPI) commands in tabular format. IEEE 488.2 Common
Commands are listed first, followed by SCPI commands.
SCPI Conformance Information
The SCPI commands used in the HP 53150A/151A/152A Counters are in
2
conformance with the SCPI Standard Version 1995.0. The SCPI command
set consists of the followi n g:
•Common Commands as defined in IEEE 488.2-1987—listed and
summarized in Table 2-1.
•SCPI Subsystem commands as confirmed (and listed) in the SCPI
Standard—the commands defined in Table 2-2 as “Std.”
•SCPI Subsystem commands designed for the instrument in
conformance with SCPI standards but not yet listed in the SCPI
Standard—the commands defined in Table 2-2 as “New.”
•Details of all HP 53150A/151A/152A commands can be found in
Chapter 4, “Command Reference.”
Information on the SCPI commands format, syntax, parameter, and
response types is provided in Chapter 3, “Programming Your Counter for
Remote Operation.”
2-8Programming Guide
Page 29
Chapter 2 Command Summary
HP 53150A/151A/152A Command Summary
IEEE 488.2 Common Commands
The Common Commands are general-purpose commands that are
common to all instruments (as defined in IEEE 488.2). Common
Commands are easy to recognize because they all begin with an “*” (for
example, *RST, *IDN?, *OPC). These commands are generally not related
to measurement configuration. They are used for functions like resetting
the instrument, identification, or synchronization.
Table 2-1 lists the IEEE 488.2 Common Commands supported by the
HP 53150A/151A/152A in alphabetical order by mnemonic, name, and
function. More information concerning the operation of IEEE 488.2
status-reporting commands and structure can be found i n the “Status
Reporting” section of Chapter 3. Standard explanations of the IEEE 488.2
Common Commands can be found in the ANSI/IEEE Std. 488.2-1987, IEEE Standard Codes, Formats, Protocols, and Common Commands
document.
2
Programming Guide2-9
Page 30
Chapter 2 Command Summary
HP 53150A/151A/152A Command Summary
Table 2-1. IEEE 488.2 Common Commands
Mnemonic Command NameFunction
*CLSClear StatusClears all event status registers summarized in the
status byte and empt ies the Error Queue.
*DDT <arbitrary block>Defi ne Device Trigger
Command
*DDT?Define Device Trigger
Query
*ESE <NRf>Standard Event Statu s
Enable
*ESE?Standard Event Statu s
2
*ESR?Event Status Register
*IDN?Identification QueryQueries the Counter identification.
*IST?Instrument Status
*OPCOperation CompleteCauses Counter to set the operation compl ete bit in
*OPC?Operation Complete
*PRE <NRf>Parallel Poll Enable
*PRE?Parallel Poll Enable
*RCL <NRf>RecallRestores the state of the Counter’s user settings from
*RSTResetResets the Counter to a known state, as defined in
*SAV <NRf>SaveStores the current state of the Counter’s user settings
*SRE <NRf>Service Request Enable Sets the Service Request Enable register.
Enable Query
Query
Query
Query
Register
Register Query
Defines which command is executed when the
Counter receives a GET or *TRG command.
Queries which command is executed when the
Counter receives a GET or *TRG command.
Sets the Standard Event Status Enable Register.
Queries the Standard Event Status Enable Register.
Queries and then clears the Standard Event Status
Register.
Queries the current state of the parallel poll response
(Instrument Status).
the Standard Event Status Register when all pending
operations (see Note at the end of table) are finished.
Places an ASCII "1" in the Output Queue when all
pending operation s (see Note at the end of table) are
completed.
Sets the value of the Parallel Poll Enable register.
Queries the value of the Parallel Poll Enable register.
a copy stored in local no n-vol atile me mory (0 throug h
9 are valid memory registers).
this manual.
in local non-vo latile memory (0 through 9 are valid
memory registers).
2-10Programming Guide
Page 31
Chapter 2 Command Summary
HP 53150A/151A/152A Command Summary
Table 2-1. IEEE 488.2 Common Commands (Continued)
Mnemonic Command NameFunction
*SRE?Service Request Enable
Query
*STB?Status Byte QueryQueries the Status Byte and Master Sum mary Status
*TRGTriggerThis trigger command is the device-specific analog of
*TST?Self-Test QueryExecutes an internal self-te st and re port s the re sul ts.
*WAIWait-to-ContinueMakes the Counter wait until all pending operations
Note: Pending operations include measurements in progress.
Queries the Serv ice R equest Enable regi ste r .
bit.
the IEEE 488.1 defined GET. It initiates the action
specified by the *DDT command.
(see Note) are completed before executing commands
that follow the *WAI command.
2
Programming Guide2-11
Page 32
2
CAUTION
Chapter 2 Command Summary
HP 53150A/151A/152A Command Summary
HP 53150A/151A/152A SCPI Subsystem Commands
SCPI Subsystem commands include all measurement functions and some
general-purpose functions. SCPI Subsystem Commands use a hierarchy
relationship between keywords that is indicated by a colon (:). For
example, in the SYST:ERR? query, the “:” between SYST and ERR?
indicates ERR? is subordinate to SYST.
Table 2-2 lists the SCPI Subsystem Commands in alphabetical order by
the command keyword. The table shows the Subsystem commands
hierarchical relationship, related parameters (if any), and any associated
information and comments.
Not all commands have a query form. Unless otherwise stated in
Table 2-2, commands have both a command and a query form. Any
command in the table that is shown with a “?” at the end, is a “Query
Only” command.
Std/New Col u mn
Std/New
The
respect to the SCPI standard. The “Std” commands operate as defined in
the SCPI standard and as defined in this guide.
The category of “New” consists of commands that could be:
•SCPI approved but are not yet in the SCPI manual
•HP approved and submitted for SCPI approval.
•Not approved at all.
The “New” commands operate as defined in this guide.
column in Table 2-2 shows the status of the command with
Parameter Form Column
Refer to the section titled “Parameter Types” on page 3-16, “Programming
Your Counter for Remote Operation,” for descriptions of the different
parameter types (such as <Boolean>, <NRf>, <arbitrary block>, etc.).
2-12Programming Guide
Page 33
Chapter 2 Command Summary
HP 53150A/151A/152A Command Summary
Table 2-2. HP 53150A/151A/152A SCPI Command Summary
Keyword/SyntaxParameter FormStd/New Comments
:ABORt
:CONFigure
:DISPlay
:ENABle
[:WINDow]
:BACKground
[:STATe]
:FETCh
:INITiate
:CONTinuous
[:IMMediate]
:INPut
:FILTer
[:LPASs]
[:STATe]
:MEASure
<Boolean>
<Boolean>
<Boolean>
<Boolean>
StdEvent; no query. Resets the trigger system
and aborts any measu re m ent in pro gr e s s.
Places the trigger system in the IDLE state.
StdSee Measurement Instructions in this table.
Std
Std
New
StdSee Measurement Instructions in this table.
Std
Std
Std
Std
Std
Std
Std
StdSee Measurement Instructions in this table.
Subsystem. Controls t he se l ect i on and
presentation of textual info rm at ion on the
display.
Controls whether or not the entire dis play is
visible.
Turns the LCD display backlight ON or
OFF.
Subsystem. Controls the ini t iation of
measurements.
Sets the instrument for cont inuously
initiated or user-initiated me asurements.
Event; no query. Causes the instrument to
initiate and complete one full measurement
cycle.
Subsystem. Controls t he ch aracteristics of
the instrument’s Channel 1 input port.
Subtree. Controls a filter that can be
inserted in the path of the measurement
signal.
Subtree. Selects the Low-PASs filter.
Enables or disables the Channel 1
low-pass filter (approx. 50 KHz).
2
Programming Guide2-13
Page 34
Chapter 2 Command Summary
CONFigure
:CONFigure?
:MEASure:
:READ
:FETCh
HP 53150A/151A/152A Command Summary
Table 2-2. HP 53150A/151A/152A SCPI Command Summary (Continued)
Keyword/SyntaxParam eter FormStd/NewComments
Measurem ent Instructions
:
[:SCALar]:<function>
See <parameters>
and <source_list>
below.
Std
Configures the
instrument to perform th e
specified measurement.
Std
2
[:SCALar]:<function>?
[:SCALar]:<function>?
[:SCALar]:<function>?
*The <function> and corresponding <parameters> and <source_list> are defined below:
Returns the function
configured by the last
:CONFigure or
:MEASure command.
Configures the
instrument, initiates
measurement, and
queries for t he result
(i.e., provides a complete
measurement sequence.
Initiates measurem en t,
and queries for the
result. (Performs a
:FETCh? on “fresh”
data.)
Queries the
measurement made by a
previous :MEASure,
:READ, or :INITiate
command.
Std
Std
___________________________________
*<source_list> has the same syntax as SCPI <channel_list>. For example, a frequency
measurement on channel 2 uses (@2) to specify channel 2.
2-14Programming Guide
Page 35
Chapter 2 Command Summary
HP 53150A/151A/152A Command Summary
Table 2-2. HP 53150A/151A/152A SCPI Command Summary (Continued)
Keyword/SyntaxParameter FormStd/New Comments
Std
:MEMory
:CLEAr[:NAME]
:DATA
:DATA?
:NSTates?
:READ
[:SENSe]
:AVERage
[:STATe]
:COUNt
:CORRection
:CSET
:SELect
:STATe
:DATA?
:FILTer
:FM
:AUTO
<name>
<name>, <data>
<name>
<Boolean>
<numeric_value>
<character_data>
CORR1 | CORR2 . . . CORR9
<Boolean>
<data_handle>
"[XNONe]FREQuency [1 | 2]"
"[XNONe]POWer [2]"
<Boolean>
New
New
New
New
Subsystem. Manages instrumen t memory.
Std
Event; no query. Restores the frequency
values in the named correction profil e to the
default values and sets al l los s values to
zero.
Std
Stores data in the named correction profile.
Std
Queries the data in the named correction
profile.
Std
Query only. Returns the number of available
*SAV/*RCL states in the instrument.
StdSee Measurement Instructions in this table.
Std
Subsystem setup commands.
Subtree. Configures the aver aging function.
Turns averaging O N and OFF.
Specifi es the number of measurements to
combine when AVERage:STATe is ON.
Std
Subtree. Configures the power-correction
function.
Std
Selects a power-correctio n pr of ile.
Std
When STATe is ON, power measurements
are modified according to the dat a i n the
correction profile select ed w it h :S ELect.
Std
Query only. Returns the current
measurement result da ta of the S EN Se
subsystem.
Std
Frequency on channel 1 or 2.
Std
Power on channel 2.
Std
Subtree. Controls the use of filtering
routines in the instrument .
Turns automatic FM compensatio n O N or
OFF.
2
Programming Guide2-15
Page 36
Chapter 2 Command Summary
HP 53150A/151A/152A Command Summary
Table 2-2. HP 53150A/151A/152A SCPI Command Summary (Continued)
Keyword/SyntaxParameter FormStd/New Comments
[:SENSe]
:OFFSet
:STATe
(cont.)
:FREQuency
<numeric_v alue>[frequency u nit]
<Boolean>
New
2
:RESolution
:TRACking
:FUNCtion
[:OFF]
[:ON]
:STAT e?
:POWer
:AC
:REFerence
:STATe
:ROSCillator
:SOURce<character_program_data>
<numeric_v alue>[frequency u nit]
<character_data>
F AST | SLOW | OFF
<sensor_function>[,<sensor_function>]
"[XNONe]FREQuency [1 | 2]"
"[XNONe]POWer [2]"
<sensor_function>[,<sensor_function>]
"[XNONe]FREQuency [1 | 2]"
"[XNONe]POWer [2]"
<sensor_function>
<numeric_value>
<Boolean>
INT ernal | EXTer nal
New
New
.
Subtree. Controls the frequency-measuring
Std
capabilities of the instrument.
Sets a reference frequency fo r all other
Std
absolute frequency sett i ngs in the
instrument.
When STATe is ON, frequency
measurements are modi f ied by the value of
FREQ:OFFset.
Std
Sets the frequency-meas ur em ent
resolution.
Selects one of three signal-tracking modes.
Std
Subtree. Selects the <sensor _f unction>(s)
to be sensed by the instrument.
Selects the <sensor_function>(s) to be
turned OFF.
Std
Selects the <sensor_function> to be sensed
by the instrument.
Std
Query that returns a Boolea n val ue which
indicat es whether the specified
<sensor_function> is O N or OFF.
Std
Subtree. Configures the instrument for
power measurement on channel 2.
Std
Sets a reference amplitud e (in dB) for
display of power measur em ents.
Std
Determines whether amplitude is measured
in absolute or relative mode.
Std
Subtree. Controls the reference oscillator.
StdSets the selection of a reference t imebase
(INTernal or EXTernal).
2-16Programming Guide
Page 37
Chapter 2 Command Summary
HP 53150A/151A/152A Command Summary
Table 2-2. HP 53150A/151A/152A SCPI Command Summary (Continued)
Keyword/SyntaxParameter FormStd/New Comments
Std
:STATus
:OPERation
:CONDition?
:ENABle
[:EVENt]?
:NTRansition
:PTRansition
:PRESet
:QUEStionable
[:EVENt]?
:CONDition?
:ENABle
<non-decimal numeric> | <NRf>
<non-decimal numeric> | <NRf>
<non-decimal numeric> | <NRf>
<non-decimal numeric> | <NRf>
Subsystem. Controls the SCPI-defined
(Operation and Questio nable)
status-reporting structures.
Std
Subtree.
Std
Query only. Queries the Operation
Condition Status Register.
Std
Sets the Operation Event Status Enable
Register.
Std
Query only. Queries and then clears the
Operation Event Status Register.
Std
Sets and queries the negati ve transition
filter for the Operation statu s re po rt ing
structure.
Std
Sets and queries the positive transition filter
for the Operation status rep or ting structure
Std
Event; No query. Presets the enable
registers and transitio n fil te rs associated
with the Operation and Questionable status
reporting structures .
Std
Subtree.
Std
Query only. Queries and then clears the
Questionable Data Event Stat us R egister.
Std
Query only. Queries the Questionable Data
Condition Status Register.
Std
Sets the Questionable Da ta E ven t Stat us
Enable Register structures.
2
Programming Guide2-17
Page 38
Chapter 2 Command Summary
HP 53150A/151A/152A Command Summary
Table 2-2. HP 53150A/151A/152A SCPI Command Summary (Continued)
Keyword/SyntaxParameter FormStd/New Comments
Std
Std
Std
Std
Std
Std
Std
Std
Std
Std
Std
Std
2
:SYSTem
:COMMunicate
:GPIB
[:SELF]
:ADDRess
:SERial
[:RECeive]
:BAUD
:ERRor?
:KEY
:CATalog?
:VERSion?
:TRIGger
[:SEQuence]
:HOLDoff
<numeric_value>
<numeric_value>
<numeric_value>
Subsystem. Collects the f unctions that are
not related to instrumen t pe rfor m ance.
Subtree. Collects togethe r co nf iguration of
control/communication interfaces.
Subtree. Controls the HPIB.
Sets the HPIB address of th e inst ru ment.
Subtree.
Sets the baud rate.
Query only. Queries the oldest error in the
Error Queue and removes the error from th e
queue (first in-first out). See Chapter 5 for
error definitions.
Simulates the pressing of a front-panel key.
Query only. Returns a list of defined key
codes.
Query only. Returns the SCPI version
number with which the Cou nt er com plies.
Subsystem.
When INIT:CONT ON, this command
specifi es the length of the delay between
measurements.
2-18Programming Guide
Page 39
Chapter 2 Command Summary
*RST Response
*RST Response
The IEEE 488.2 *RST command returns the instrument to a specified
state optimized for re mote operation. (Use *CLS to clear the status ev ent
registers and the SCPI error queue.)
The states of command settings affected by the *RST command are
described in Table 2-3. Table 2-4 lists command settings that are
unaffected by *RST.
<character_data>
<Boolean>
<numeric_value>[fr equ enc y uni t>
<Boolean>
<numeric_value>[fr equ enc y uni t>
<character_program_data>
<sensor_function>
Chapter 3 Programming Your Counter for Remote Operation
Introduction
Introduction
This chapter provides remote-operation setup and programming
information. You can use this information to configure the Counter to
operate as a remote device.
NOTE
3
Most of this chapter deals with programming the HP 53150A/151A/152A
Counters using SCPI and IEEE 488.2 commands. With two minor
exceptions, the only difference between programming these Counters
using the HP-IB interface and the RS-232 serial interface is the manner in
which you connect the Counter to the computer. These exceptions are:
1. The Counter sends a command prompt over the RS-232 interface (but
not the HP-IB) after receiving and executing each command.
2. When an error is detected (during the Self-Test or during operation),
the Counter automatically sends an error message (or messages) over
the RS-232 interface (error messages must be requested over the
HP-IB). For additional information on error messages, see Appendix B
of the
HP 53150A/151A/152A Operating Guide
.
3-2Programming Guide
Page 43
Chapter 3 Programming Your Counter for Remote Operation
Introduction
Chapter Summary
Connecting the Counter to a Computerpg. 3-5
•
Overview of Command Types and Formatspg. 3-12
•
Elements of SCPI Commandspg. 3-13
•
Using Multiple Commandspg. 3-19
•
Overview of Response Message Formatspg. 3-21
•
Status Reportingpg. 3-25
•
Programming the Counter for Status Reportingpg. 3-41
•
Programming the Counter to Display Resultspg. 3-46
•
Commands for Displaying Resultspg. 3-47
•
Programming the Counter to Synchronize Measurementspg. 3-48
•
Writing SCPI Programspg. 3-52
•
Programming Examplespg. 3-54
•
3
Programming Guide3-3
Page 44
Chapter 3 Programming Your Counter for Remote Operation
Introduction
Where to Find Some Specific Information
To Connect With the HP-IBpg. 3-5
•
Configuring the HP-IBpg. 3-5
•
IEEE 488.1 Interface Capabilitiespg. 3-6
•
To Connect With the RS-232 Serial Interfacepg. 3-7
•
Making an RS-232 Cablepg. 3-7
•
Remote/Local Operationpg. 3-11
•
Common Command Formatpg. 3-12
•
SCPI Command and Query Formatpg. 3-12
•
Abbreviated Commandspg. 3-14
•
Optional Keywordpg. 3-14
•
Parameter Typespg. 3-16
•
Parameter Separatorpg. 3-17
•
Command Terminatorpg. 3-18
3
•
Program Messagespg. 3-19
•
Response Messagespg. 3-21
•
Programming Examples
Making a Frequency Measurement (HP BASIC)pg. 3-56
•
Making a Frequency Measurement (Quick BASIC)pg. 3-57
•
Making a Frequency Measurement (C)pg. 3-58
•
3-4Programming Guide
Page 45
Chapter 3 Programming Your Counter for Remote Operation
Counter (Rear Panel)
HP 10833A/B/C/D
HP-IB Cable
WARNING:WARNING:
To avold electric shock,To avold electric shock,
do not remove covers.do not remove covers.
No user-serviceable parts inside.No user-serviceable parts inside.
Refer all servicing to qualified personnel.Refer all servicing to qualified personnel.
OPTIONSOPTIONS
001 Oven Time Base001 Oven Time Base
002 Battery002 Battery
This unit must be earth grounded.This unit must be earth grounded.
Made in U.S.A.Made in U.S.A.
with domestic and foreign contentwith domestic and foreign content
To program the Counter to operate remotely, you need to interface the
Counter with a computer. The HP 53150A, 53151A, and 53152A
Microwave Frequency Counters provide two interfaces for remote,
computer-controlled operation
describe how to connect and configure both interfaces for remote Counter
operation.
To Connect With the HP-IB
To connect the Counter to a computer using the HP-IB, install an HP-IB
cable (such as the HP 10833A cable) between the two units, as shown in
Figure 3-1.
—
HP-IB and RS-232. The following sections
Figure 3-1. HP-IB Interconnection
Configuring the HP-IB
The Counter’s HP-IB operates in Addressed (talk/listen) mode, which
provides bi-directional communication. The Counter can receive
commands and setups from a computer, and it can send data and
measurement results. There is one configurable setting related to HP-IB
communication—the HP-IB Address.
Programming Guide3-5
3
Page 46
Chapter 3 Programming Your Counter for Remote Operation
Connecting the Counter to a Computer
The following section, titled “Changing the HP-IB Address,” provides
instructions for setting the HP-IB address from the Counter’s front panel.
NOTE
Once the Counter is in Remote mode, all front-panel keys except the
Reset/Local
Reset/Local
key are disabled. As long as local-lo ckout is off, pressing the
key returns the counter to Local mode.
Changing the HP-IB Address
1Press and release the
key, and then press
Shift
HPIB (Resol)
. The HPIB
ADDR menu is displayed, the current HP-IB address is shown to the right
of the blinking indicator (>), and the LED indicator between the arrow
keys flashes.
2Press the right-arrow key. The blinking indicator changes direction (from
> to <), and the current HP-IB address blinks.
3Press (or press and hold) the up-arrow or down-arrow key to change the
HP-IB address (the available addresses are 1 to 30).
3
4When your desired address is displayed, pres s the
key. The address
Enter
you selected is assigned, and the display returns to its normal operating
NOTE
mode. You must press the
To configure the Counter so that the a specific HP-IB address is
key to complete the entry.
Enter
automatically assigned each time you turn the Counter on, select the
address, and then save your current settings in SAV 0. The settings in
SAV 0 are recalled each time the Counter is turned on.
IEEE 488.1 Interface Capabilities
The HP 53150A/151A/152A Counter has the following IEEE 488.1
Interface capabilities
SH1
AH1
T6
L3
3-6Programming Guide
:
SR1
RL1
PP1
DC1
DT1
C0
E1
Page 47
Chapter 3 Programming Your Counter for Remote Operation
Connecting the Counter to a Computer
To Connect With the RS-232 Serial Interface
The HP 53150A, 53151A, and 53152A Frequency Counters use an RJ12
modular connector for the RS-232 interface. This connector is accessible
through the back panel of the counter, as shown in Figure3-2.
Made in U.S.A.
Main ~ Power
Reference 10 MHz
11 TO 18 VDC
EXT DC
with domestic and foreign content
OPTIONS
001 Oven Time Base
Auxillary
In
or
Out
RS-232
002 Battery
WARNING:
To avold electric shock,
do not remove covers.
No user-serviceable parts inside.
Refer all servicing to qualified personnel.
This unit must be earth grounded.
AC POWER
100 – 130 VAC, 50/60/400 Hz 75 VA
220 – 240 VAC, 50/60 Hz 75 VA250 V
ISM 1-A
FUSE
1.0 A T
RS-232 (RJ12) Connector
Figure 3-2. Location of the RS-232 (RJ12) Connector
To connect the Counter to a computer using the RS-232 interface, you
need a serial cable that has an RJ12 modular connector at the Counter
end and a female DB25 connector at the computer end.
Making an RS-232 Cable
Most computers use male DB25 connectors for their serial ports.
Therefore, you must use either a cable with an RJ12 plug at the Counter
end and a female DB25 connector at the computer end or a double-ended
RJ12 cable and an RJ12-to-DB25F adapter to interface the Counter with a
computer. Since pre-manufactured RJ12/DB25 cables are rare, it is
probably most efficient to obtain the necessary parts, and assemble the
cable yourself.
Programming Guide3-7
3
Page 48
Chapter 3 Programming Your Counter for Remote Operation
Connecting the Counter to a Computer
Assembling the DB-25/RJ12 Adapter and the Cable
Use the following procedure to wire the adapter and assemble the cable:
1Obtain a male DB25 to female RJ12 adapter, such as the Voltrex
MAK206F (manufactured by SPC Technology) or equivalent, and either a
6-conductor male-to-male RJ12 cable of a suitable length or a similar
length of 6-conductor, flat telephone cable and two RJ12 plugs. RJ12
modular plugs (SPC part number TA30-6) and 6-conductor, flat telephone
cable (SPC part number TXW6151) are also available from SPC
Technology (and other manufacturers).
2Adapter kits like the Voltrex MAK206F usually include a pre-wired RJ12
modular receptacle, a DB25F connector, and the adapter body, or wiring
shroud. Wire the RJ12 receptacle to the DB25F connector according to the
diagrams in Figure 3-3, and then assemble the adapter according to the
instructions included in the kit.
DB-25F
(Female)
3
1
2
3
4
5
6
7
8
9
10
11
12
13
RED (RXD)
BLK (TXD)
GRN (GND)
(Viewed from wire (back) side of the connectors)
14
15
16
17
18
19
20
21
22
23
24
25
(Male)
1
2
3
4
5
6
RJ12
Pin 1: Not Used
Pin 2: TXD
Pin 3: RXD
Pin 4: GND
Pin 5: Not Used
Pin 6: Not Used
SPC Technology Voltrex Brand
Part number MAK206 F
DB-25F (female) to RJ12 (male) Adapter
Figure 3-3. Wiring the RJ12/DB25 Adapter (1 of 2)
3-8Programming Guide
Page 49
Chapter 3 Programming Your Counter for Remote Operation
Connecting the Counter to a Computer
DB-25F
(Female)
13
25
12
24
11
23
10
22
9
21
8
20
19
18
17
16
15
14
GRN (GND)
7
6
5
4
BLK (TXD)
3
RED (RXD)
2
1
DB-25F (female) to RJ12 (male) Adapter
(Viewed from front side of the connectors)
SPC Technology Voltrex Brand
Part number MAK206 F
RJ12
(Male)
6
5
4
3
2
1
Pin 4: GND
Pin 3: RXD
Pin 2: TXD
Figure 3-3. Wiring the RJ12/DB25 Adapter (2 of 2)
3Attach an RJ12 modular plug to each end of a suitable length of
6-conductor, flat telephone cable as shown in Figure 3-4. Be sure to attach
the connectors in the orientations shown in the figure.
3
Programming Guide3-9
Page 50
Chapter 3 Programming Your Counter for Remote Operation
Connecting the Counter to a Computer
RJ12
Modular Plug
Wire
Color
No.
6 BLU
5 YEL
4GRN
3 RED
2 BLK
1WHT
Pin #
6
5
4
3
2
1
SPC Technology
Part number TA 30-6
6
5
4
3
2
1
SPC Technology, 6-Conductor
Flat Telephone Wire
Part number TXW6151
Wire
Color
Pin #
No.
6 BLU
5 YEL
6
5
4
3
2
1
1
2
3
4
5
6
4GRN
3 RED
2 BLK
1 WHT
Figure 3-4. Assembling the Cable
3
4Connect either end of the cable to the adapter by inserting the RJ12 plug
into the receptacle on the adapter.
3-10Programming Guide
Page 51
Chapter 3 Programming Your Counter for Remote Operation
Connecting the Counter to a Computer
Connecting with the Serial Interface
Connect the female DB25 connector on the adapter to the male DB25
serial-port connector on the computer, and then insert the RJ12 plug at
the other end of the cable into the RJ12 receptacle on the back of the
counter as shown in Figure 3-5.
Computer (Rear Panel)
Serial Cable
Counter (Rear Panel)
Made in U.S.A.
with domestic and foreign contentwith domestic and foreign content
OPTIONSOPTIONS
001 Oven Time Base001 Oven Time Base
Main ~ PowerMain ~ Power
Reference 10 MHzReference 10 MHz
11 TO 18 VDC11 TO 18 VDC
InIn
oror
OutOut
EXT DCEXT DC
002 Battery002 Battery
AuxillaryAuxillary
WARNING:WARNING:
To avold electric shock,To avold electric shock,
do not remove covers.do not remove covers.
No user-serviceable parts inside.No user-serviceable parts inside.
Refer all servicing to qualified personnel.Refer all servicing to qualified personnel.
This unit must be earth grounded.This unit must be earth grounded.
LINE VOLTAGE:LINE VOLTAGE:
90-260VAC 50/60 Hz90-260VAC 50/60 Hz
FUSE:FUSE:
100-120VAC 0.5A, SB 250V100-120VAC 0.5A, SB 250V
FUSE:FUSE:
RS-232 RS-232
200-240V, 0.25A,SB 250V200-240V, 0.25A,SB 250V
3
Figure 3-5. RS-232 Serial Interconnection
Remote/Local Operation
When the counter is connected to a computer via the HP-IB, and it is in
Remote mode, the
settings cannot be affected using the front-panel controls. The
Reset/Local
key can be used to manually return the counter to local
control (if local-lockout is off).
When the Counter is in Local mode, the front-panel
display is off.
Programming Guide3-11
indicator is visible on the display, and the Counter
Rmt
Rmt
indicator in the
Page 52
Chapter 3 Programming Your Counter for Remote Operation
Overview of Command Types and Formats
Overview of Command Types and Formats
There are two types of HP 53150A/151A/152A programming commands:
IEEE 488.2 Common Commands and Standard Commands for
Programmable Instruments (S CPI). The format of each type of command
is described in the following paragraphs. (Refer to Chapter 2, “Command
Summary,” for SCPI conformance information.)
Common Command Format
The IEEE 488.2 Standard defines Common Commands as commands that
perform functions like reset, self-test, status byte query, and
identification. Common Commands always begin with the asterisk (*)
character, and may include parameters. The command keyword is
separated from the first parameter by a space character. Some examples
of Common Commands are as follows:
*RST *IDN? *RCL 1
3
SCPI Command and Query Format
SCPI commands perform functions like instrument setup. A subsystem
command has a hierarchical structure that usually consists of a top level
(or root) keyword, one or more lowe r-leve l keyword s, and p arameters. The
following example shows a command and its associated query:
:DISPlay:ENABle:ON
:DISPlay:ENABle?
In this example, DISPlay is the root-level keyword, ENABle is the secondlevel keyword, and ON is the command parameter.
3-12Programming Guide
Page 53
Chapter 3 Programming Your Counter for Remote Operation
Elements of SCPI Commands
Elements of SCPI Commands
A program command or query is composed of functional elements that
include a header (or keywords with colon separators), program data, and
terminators. These elements are sent to the Counter over the
HP-IB or the RS-232 interface as a sequence of ASCII data messages.
Examples of a typical Common Command and Subsystem Command are:
Figure 3-6 shows the simplified syntax of a Subsystem Command. You
must use a space (SP) between the last command mnemonic and the first
parameter in a Subsystem Command. Note that if you send more than one
parameter with a single command, you must separate adjacent
parameters with a comma.
:
:
mnemonic
?
sp
parameter
,
suffix
NOTE: sp = space. ASCII character decimal 32
Figure 3-6. Simplified Program Command Syntax Diagram
Common Command Syntax
Figure 3-7 shows the simplified syntax of a Common Command. You must
use a space (SP) between th e command mnemo nic and the parameter in a
Common Command.
3
Programming Guide3-13
Page 54
Chapter 3 Programming Your Counter for Remote Operation
Elements of SCPI Commands
sp
parameter
NOTE
*
mnemonic
?
NOTE: sp = space. ASCII character decimal 32
Figure 3-7. Simplified Common Command Syntax Diagram
Abbreviated Commands
The command syntax shows most keywords as a mix ture of upper- and
lowercase letters. Uppercase letters indicate the abbreviated spelling for
the command. For better program readability, you may send the entire
keyword. The HP 53150A/151A/152A accepts either command form and is
not case sensitive.
For example, if the command syntax shows DISPlay, then DISP and
3
DISPLAY are both acceptable forms. Other forms of DISPlay, such as
DISPL or DISPLA are illegal, and they generate errors. You may use
upper and/or lower case letters. Therefore, DISPLAY, display, and
DiSpLaY are all acceptable.
Keyword Separator
A colon (:) always separates one keyword from the next lower-level
keyword as shown below:
:DISPlay:ENABle?
Optional Keyword
Optional keywords are those which appear in square brackets ([ ]) in the
command syntax. (Note that the brackets are not part of the command
and are not sent to the Counter.)
Suppose you send a second level keyword without the preceding optional
keyword. In th is c ase , th e Counter assumes you intend to u s e th e opt ion al
keyword and responds as if you had sent it.
3-14Programming Guide
Page 55
Chapter 3 Programming Your Counter for Remote Operation
Elements of SCPI Commands
Examine the portion of the [:SENSe] subsystem shown below:
[:SENSe]
:FREQuency
:RESolution
The root-level keyword [:SENSe] is an optional keyword. To set the
Counter's frequency resolution, you can use either of the following:
:SENS:FREQ:RES
or
:FREQ:RES
Programming Guide3-15
3
Page 56
Chapter 3 Programming Your Counter for Remote Operation
Elements of SCPI Commands
Parameter Types
Table 3-1 contains explanations and examples of parameter types.
Parameter types may be numeric value, Boolean, literal, NRf, string, nondecimal numeric, or arbitrary block.
Table 3-1. Command and Query Parameter Types
TYPEEXPLANATIONS AND EXAMPLES
<numeric value>
<Boolean>
<literal>
3
<NRf>
<string>
<non-decimal
numeric>
<arbitrary
block>
Accepts all commonly used decimal representation of numbers including optional signs,
decimal points, and scientific notation:
123, 123e2, -123,
Special cases include MIN im um and MAXimum as follow s: MIN i m um selects minimum value
availabl e, and MAXimum selects maxim um value available.
Queries using MINimum or M AXi m um re turn th e associated numeric value.
Represents a single bin ar y condition that is either true or fa lse:
1 or ON, 0 or OFF (Query response returns only 1 or 0.)
An <NRf> is rounded to an integer. A non-zero value is interpreted as 1.
Selects from a finite numbe r of choices. These param eters use mnemonics to represent each
valid setting. An example is the INPut:COUPling AC | DC c om m and parameters (AC | DC).
Flexible numeric representation.
A string parameter is delimited by either single quotes or double quotes. Within the quotes, any
characters in the ASCII 7-bit co de may be specified.
The following HP BASIC statement sends a command containing a <string> p aram eter:
OUTPUT 703;"FUNC ‘FREQ’"
Format for specifying hex adecimal (#H1F), octal (# Q 10 77), and binary (#B10101011) numbers
using ASCII characters. Ma y be used in :STATus subsystem com m ands.
The syntax is a pound sign (#) fol l ow ed by a non-zero digit represent i ng the num ber of digits in
the subsequent decim al integer. The decimal integer specifies the num ber of 8-bit data bytes
being sent. This is followed by t he act ual da ta . Th e t ermi nator is a line feed asserted wit h EO I.
For example, for transmit tin g 8 bytes of data, the format could be:
1.23e2, .1 23, 1.23e−2, 1.23000E−01.
−
Number of digits
that follow
Number of bytes
to be transmitted
TerminatorActual data
<new line><8 bytes of data>2# 08^EOI
The “2” indicates the number of digits that follow and the two digits “08” indicate the number of
bytes to be transmitted; a zero-length block has the format: #0<new line>^EOI; <new line> is defined
as a single ASCII-encoded byte corresponding to 10 decimal.
data
3-16Programming Guide
Page 57
Chapter 3 Programming Your Counter for Remote Operation
Elements of SCPI Commands
Parameter Separator
If you send more than one parameter with a single command, you must
separate adjacent parameters with a comma.
Query Parameters
All selectable <numeric value> parameters (except Common Commands)
can be queried to return the minimum, maximum, and DEFault values
they are capable of being set to by sending a MINimum, MAXimum, or
DEFault parameter after the “?.” For example, consider the
AVERage:COUNt? query.
If you send the query without specifying a parameter (AVER:COUN?), the
present setting is returned. If you send the MIN parameter (using
AVER:COUN? MIN), the command returns the minimum acceptable
count. If you send the MAX parameter, the command returns the
maximum level currently available. Be sure to place a space between the
question mark and the parameter.
Suffixes
A suffix is the combination of suffix elements and multipliers that can be
used to interpret some <numeric value>. If a suffix is not specified, the
Counter assumes that <numeric value> is unscaled (that is, Volts,
seconds, etc.)
For example, the following two commands are equivalent:
Suffix elements, such as HZ (Hertz), S (seconds), V (volts),
OHM (Ohms), PCT (percent), and DEG (degrees) are allowed within this
format.
Programming Guide3-17
3
Page 58
Chapter 3 Programming Your Counter for Remote Operation
Elements of SCPI Commands
Suffix Multipliers
Table 3-2 lists the suffix multipliers that can be used with suffix elements
(except PCT and DEG).
Table 3-2. Suffix Multipliers
DEFINITIONMNEMONICNAME
1E15PEPETA
1E12TTERA
1E9GGIGA
1E6MA ( or M for OHM and HZ)*MEGA
1E3KKILO
1E-3M (except for OHM and HZ)*MILLI
1E-6UMICRO
1E-9NNANO
1E-12PPICO
1E-15FFEMTO
3
1E-18AATTO
The suffix units, MHZ and MOHM, are special cases that should not be confused with
*
<suffix multiplier>HZ and <suffix multiplier>OHM.
Command Terminator
A command may be terminated with a <new line> (ASCII character
decimal 10), an EOI (End-of-Identify) ass erted concurrent with last byte,
or an EOI asserted concurrent with a <new line> as the last byte.
3-18Programming Guide
Page 59
Chapter 3 Programming Your Counter for Remote Operation
Using Multiple Commands
Using Multiple Commands
Program Messages
Program Messages are a combination of one or more prope rly formatted
SCPI Commands. Program messages always go from a computer to the
Counter. They are sent to the Counter over the Counter's HP-IB or serial
interface as a sequence of ASCII data messages.
Program Message Syntax
Figure 3-8 shows the si mplifie d synta x of a pro gram mess age. You ca n see
Common Commands and Subsystem Commands in the same program
message. If you send more than one command in one message, you must
separate adjacent commands with a semicolon.
;
Subsystem Command
<new line>
Common Command
^END
^END
<new line>
<new line> = ASCII character decimal 10
^END = EOI asserted concurrent with last byte
Figure 3-8. Simplified Program Message Syntax Diagram
When using IEEE 488.2 Common Commands with SCPI Subsystem
commands on the same line, use a semicolon between adjacent commands.
For example:
*RST;:SENS:AVER ON
Programming Guide3-19
3
Page 60
Chapter 3 Programming Your Counter for Remote Operation
Using Multiple Commands
When multiple subsystem commands are sent in one program message,
the first command is always referenced to the root node. Subsequent
commands, separated by “;”, are referenced to the same level as the
preceding command if no “:” is present immediately after the command
separator (the semicolon).
For example, sending :SENS:AVER:COUN 5; STAT ON is equivalent to
sending:
:SENS:AVER:COUN 5
:SENS:AVER:STAT ON
or
:SENS:AVER:COUN 5;:SENS:AVER:STAT ON
The “:” must be present to distinguish another root level command. For
example:
:SENS:AVER:COUN 5;:INIT:CONT OFF
3
is equivalent to sending:
:SENS:AVER:COUN 5
:INIT:CONT OFF
If the “:”(which is following the “;” and is in front of INIT) is omitted, the
Counter assumes that the second command is “:SENS:AVER:INIT:CONT
OFF” and generates a syntax error.
3-20Programming Guide
Page 61
Chapter 3 Programming Your Counter for Remote Operation
Overview of Response Message Formats
Overview of Response Message Formats
Response Messages
Response messages are data sent from the Counter to a computer in
response to a query. (A query is a command followed by a question mark.
Queries are used to find out how the Counter is currently configured and
to transfer data from the Counter to the computer.)
After receiving a query, the Counter interrogates the requested
configuration and places the response in its output queue. The output
message remains in the queue until it is read or another command is
issued. When read, the message is transmitted across the HP-IB or the
serial interface to the computer. You read the mes sage by using some t ype
of enter statement that includes the device address and an appropriate
variable. Use a print statement to display the message. The following
HP BASIC example illustrates how to query the Counter and display the
message:
10 OUTPUT 703;":ROSC:SOUR?"
20 ENTER 703; A$
30 PRINT A$
40 END
3
Response Message Syntax
Figure 3-9 shows the simplified syntax of a Response Message. Response
messages may contain both commas and semicolon separators. When a
single query command returns multiple values, a comma is used to
separate each item. When multiple queries are sent in the same program
message, the groups of data co rrespondi ng to each que ry are se parat ed by
a semicolon. Note that a <new line> ^END is always sent as a response
message terminator.
Programming Guide3-21
Page 62
Chapter 3 Programming Your Counter for Remote Operation
Overview of Response Message Formats
;
,
NOTE
response data
<new line> = ASCII character decimal 10
<new line>
^END
^END = EOI asserted concurrent with last byte
; = multiple response separator (ASCII character decimal 59)
, = data separator within a response (ASCII character decimal 44)
Chapter 3 Programming Your Counter for Remote Operation
Overview of Response Message Formats
Response Message Data Types
Table 3-3 contains explanations of response data types.
T able 3-3. Response Message Data Types
TypeDescription
<NR1>This numeric representation has an implicit radix point.
+
−
The maximum number of characters in <NR1> response data is 17 (maximum
16 digits, 1 sign).
<NR2>This numeric representation has an explicit radix point.
<digit>
+
<digit>
.
<digit>
−
The maximum number of characters in <NR2> response data is 17 (maximum
15 mantissa digits, 1 sign, 1 decimal point).
<NR3>This numeric representation has an explicit radix point and an exponent.
+
<digit>
.
<digit>
−
+
E
<digit>
−
The maximum number of characters in <NR3> response data is 22 (maximum
15 mantissa digits, 2 signs, 1 decimal point, 1 'E' character, 3 exponent digits).
Not a Number “Not a Number” is represented by the value 9.91E37. (Not a Number is defined in
IEEE 754). The Counter respo nds with this num eric v alue whe n queri ed for a flo ating
point number it cannot provide. This value will be formatted as an <NR3>.
<Boolean>A single ASCII-encoded byte, 0 or 1, is returned for the query of settings that use
<Boolean> parameters.
<literal>ASCII-encoded bytes corresponding to the short form of the literal used as the
command parameter.
3
Programming Guide3-23
Page 64
Chapter 3 Programming Your Counter for Remote Operation
Overview of Response Message Formats
T a ble 3-3. Response Message Data Types (Continued)
TypeDescription
<string>A string response consists of ASCII characters enclosed by double quotes.
For example, string data is used for the “<error description>” portion of
:SYST:ERR? response and for [:SENS]:FUNC? response.
<definite length
block>
3
The syntax is a pound sign (#) followed by a non-zero digit representing the
number of digits in the subs equen t deci mal i nteger. The decimal integer s pecifi es
the number of 8-bit data byte s being se nt. This is followed by the actual da ta. The
terminator is a line feed asserted with EOI. For example, for transmitting 8 bytes
of data, the format might be:
Number of digits
that follow
Number of bytes
to be transmitted
TerminatorActual data
<new line><8 bytes of data>2# 08^EOI
The “2” indicates the number of digits that follow and the two digits “08” indicate
the number of
bytes to be transmitted.
data
A zero-length block has the format: #0<new line>^EOI
<new line> is defined as a single ASCII-encoded byte corresponding to
10 decimal.
3-24Programming Guide
Page 65
Chapter 3 Programming Your Counter for Remote Operation
Status Reporting
Status Reporting
The HP 53150A, 53151A, and 53152A status registers conform to the
SCPI and IEEE 488.2 standards.
Figure 3-10 shows all of the status-register groups and queues in the
Counter. This is a high level diagram that does not show all the registers
that are contained in each group. It is intended as a guide to the bits used
in each of these register groups to monitor the Counter's status. Note that
a summary of the Standard Status Structure Registers (defined by IEEE
488.2-1987) is shown in addition to the Operation Status and
Questionable Data/ Sig nal Reg is te r grou ps .
Refer to the section in this chapter titled “Programming the Counter for
Status Reporting” and the flowchart in Figure 3-14 for detailed
information on programming the status-reporting system.
Programming Guide3-25
3
Page 66
Chapter 3 Programming Your Counter for Remote Operation
Status Reporting
Questionable Data Status Register Group
Not Used
PowerCal
Not Used
Frequency
Not Used
Hardware Summary
Not Used
Command Warning
Not Used
(Use :STATus:QUEStionable Commands
to control and read registers.)
Standard Event Status Register Group
OUTPUT
QUEUE
(Query Counter to read the Output Queue.)
Operation Complete
Not Used
3
ERROR
QUEUE
(Use
SYSTem:ERRor?
to query the
Error Queue.)
Device Dependent Error
Using Internal Reference
(Use :STATus:OPERation Commands
to control and read registers.)
Query Error
Execution Error
Command Error
Not Used
Power On
(Use *ESR?,*ESE <NRf>,
ESE? to control and
and
*
read registers.)
Operation Status Register Group
Not Used
Not Used
Measuring
Waiting for Trigger
Not Used
Not Used
Acquiring
Locked
Not Used
(8)
(32)
(
)
4096
(
)
16384
Queue Not Empty
Queue Not Empty
(1)
(4)
(8)
(16)
(32)
(
)
128
(16)
(32)
(
)
512
(
)
2048
(
)
4096
Bits
0 to 2
3
4
5
6 to 11
12
13
14
15
Bits
Bits
0
1 to 3
4
5
7 to 8
9
10
11
12
13 to 15
LOGICAL OR
Not
Used
0
1
2
3
4
5
6
7
MAV
RQS
LOGICAL OR
LOGICAL OR
NOTES:
1. The numbers that are in parentheses and positioned
above the arrows represent the integer formed by the
binary weighting of the corresponding bit.
2. Descriptions of all registers are contained in this section.
3. To reset the Counter and initialize status reporting,
perform the following:
Reset and initialize
status reporting
Device Clear
*CLS
*RST
*SRE 0
*ESE 0
:STAT:PRES
Continue Program
4. The value of an unused bit is zero when queried and
ignored when set.
Summary of IEEE 488.2-1987
Standard Status Data Struture
Service Request Enable and Status Byte Registers
Read by Serial Poll
(4)
EAV
QSB
(8)
(16)
ESB
(32)
(64)
OSB
(
)
128
Bits
0 to 1
2
3
4
5
6
7
Read with *STB?
MSS
(64)
(
*SRE <NRf> and
Use
SRE? to control and read
*
the Service Request
Enable Register.)
LOGICAL OR
Service
Request
Generation
SRQ
Interrupt
to Computer
Figure 3-10. 53150A/151A/152A SCPI Status Reporting Summary Functional Diagram
3-26Programming Guide
Page 67
Chapter 3 Programming Your Counter for Remote Operation
Status Reporting
Status Byte Register and
Service Request Enable Register
Error/Event
Queue
Questionable
Data
Status Register
Group
Status of
Output Queue
Standard Event
Status Register
Group
Operation Status
Register Group
Status Byte
Register
0
1
EAV
QSB
MAV
ESB
RQS /MSS
OSB
Service
Request
Generation
&
(Logical AND)
&
&
&
&
&
Logical OR
Service Request
Enable Register
0
1
2
3
4
5
&
7
SRQ Interrupt
to Computer
3
Figure 3-11. Status Byte and Service Request Enable
Status Byte Register
The Status Byte Register is the summary-level register in the status
reporting structure. It contains summary bits that monitor activity in the
other status registers and queues as shown in Figure 3-11. The Status
Byte Register is a live register—its summary bits are set TRUE or FALSE
(one or zero) by the presence or absence of the condition whi ch is being
summarized.
The Status Byte Register can be read with either a serial poll or the *STB?
query, but it is altered only when the state of the overlying status data
structures is altered. The entire Status Byte Register can be cleared by
sending just the *CLS command to the Counter in a program message.
Table 3-4 lists the Status Byte Register bits and briefly describes each bit.
Programming Guide3-27
Page 68
Chapter 3 Programming Your Counter for Remote Operation
Status Reporting
Table 3-4. Status Byte Register
BITWEIGHTSYMBOLDESCRIPTION
0
1
24EAVError/Event Queue Not Empty
38QSB
416MAVMessage Available Summary Bit
532ESBStandard Event Status Register Summary Bit
664RQS/MSSRequest Service/Master Status Summary Bit
7128OSBOperation Status Register Summary Bit
——
——
Not used
Not used
Questionable Data/Signal Status Register
Summary Bit
A detailed description of each bit in the Status Byte Register follows:
3
•Bits 0 - 1 are not used.
•Bit 2 (EAV) Summarizes the Error/Event Queue.
This bit is set when the Error/Event Queue is not empty.
•Bit 3 (QSB) summarizes the Questionable Data Status Event
Register.
This bit indicates whether or not one or more of the enabled
Questionable Data events have occurred since the last reading or
clearing of the Questionable Data Status Event Register.
This bit is set TRUE (one) when an enabled event in the Questionable
Data Status Event Register is set TRUE. Conversely, this bit is set
FALSE (zero) when no enabled events are set TRUE.
•Bit 4 (MAV) (Message AVailabl e) sum marize s the Out p ut Queu e .
This bit indicates whether or not the Output Queue is empty.
This bit is set TRUE (one) when the Counter is ready to accept a
request by the external computer to output data bytes; that is, the
3-28Programming Guide
Page 69
Chapter 3 Programming Your Counter for Remote Operation
Status Reporting
Output Queue is not empty. This bit is set FALSE (zero) when the
Output Queue is empty.
•Bit 5 (ESB) summarizes the Standard Event Status Register.
This bit indicat es whether or not one of the enabled Standard Event
Status Register events have occurred since the last reading or clearing
of the Standard Event Status Register.
This bit is set TRUE (one) when an enabled event in the Standard
Event Status Register is set TRUE. Conversely, this bit is set FALSE
(zero) when no enabled events are set TRUE.
When a serial poll is used to read the Status Byte Register, the RQS
bit indicates if the device was sending SRQ TRUE. The RQS bit is set
FALSE by a serial poll.
When *STB? is used to read the Status Byte Register, the MSS bit
indicates the Master Summary Status. The MSS bit indicates whether
or not the Counter has at least one reason for requesting service.
•Bit 7 (OSB) summarizes the Operation Status Event Register.
3
This bit indicates wh ether or not one or more of the enabl ed Operati on
events have occurred since the last reading or clearing of the
Operation Status Event Register.
This bit is set TRUE (one) when an enabled event in the Operation
Status Event Register is set TRUE. Conversely, this bit is set FALSE
(zero) when no enabled events are set TRUE.
Service Request Enable Register
The Service Request Enable Register selects which summary bits in the
Status Byte Register may cause service requests as shown in
Figure 3-7.
Use *SRE to write to this register and *SRE? to read this register.
Use *SRE 0 to clear the register. A cleared register does not allow status
information to generate the service requests. (Power-on also clears this
register.)
Programming Guide3-29
Page 70
Chapter 3 Programming Your Counter for Remote Operation
Status Reporting
Standard Event Status Register Group
Standard Event
Enable Register
0
1
2
3
4
5
6
7
&
&
&
&
&
&
Logical OR
&
&
Standard Event
Status Register
0
1
2
3
4
5
6
7
Operation Complete
Not Used
Query Error
Device-Dependent Error
Execution Error
Command Error
Not Used
Power On
To ESB bit (bit 5) of the
Status Byte Register
Figure 3-12. Standard Event Status Reporting
Standard Event Status Register
3
The Standard Event Status Register contains bits that monitor specific
IEEE 488.2-defined events as shown in Figure3-12.
Use *ESR? to read this register.
Use *ESR? or *CLS to clear this register.
Table 3-5 lists the Standard Event Status Register bits and briefly describes
each bit.
3-30 Programming Guide
Page 71
Chapter 3 Programming Your Counter for Remote Operation
(RQC)Not used because this instrument cannot request
permission to become active IEEE 488.1 controller-incharge.
(URQ)Not used, because this instrument does not define any
local controls as “User Request” controls.
NOTE
A detailed description of each bit in the Standard Event Status Register
follows:
•Bit 0 (Operation Complete) is an event bit which is generated in
response to the *OPC command. This bit indicates that the Counter
has completed all pending operations (the pending operation condition
has transitioned from TRUE to FALSE).
If AVERage:STATe is OFF, the command INIT;*OPC sets the OPC bit
once the instrument completes a measurement; if AVERage:STATe is
ON, the comma nd INIT ;*OP C se ts th e OPC bi t onc e th e inst rumen t
completes a measurement consisting of AVERage:COUNt
measurements.
The OPC bit is not in any way affected by the *OPC? query.
•Bit 1 is not used.
•Bit 2 (Quer
Error) is an event bit which indicates that either 1) an
attempt was made to read the Output Queue when it was empty or 2)
data in the Output Queue has been lost.
Programming Guide3-31
3
Page 72
Chapter 3 Programming Your Counter for Remote Operation
Status Reporting
Errors -400 through -499 are query errors.
•Bit 3 (Device-Specific Error) is an event bit which indicates an
operation did not properly complete due to some condition of the
Counter.
Errors -300 through -399 and all those with positive error numbers
are device-specific errors.
•Bit 4 (Execution Error) is an event bit which indicates that a
command could not be executed 1) because the parameter was out of
range or inconsistent with the Counter's capabilit ies, or 2) because of
some condition of the Counter.
Errors -200 through -299 are execution errors.
•Bit 5 (Command Error) is an event bit which indicates one of the
following has occurred: 1) an IEEE 488.2 syntax error, 2) a semantic
error indicating an unrecognized command, or 3) a Group Execute
Trigger was entered into the input b uffer ins ide of a pro gram messa ge.
•Bit 6 is not used.
3
•Bit 7 (Power On) is an event bit which indicates that an off-to-on
transition has occurred in the Counter's power supply.
Standard Event Status Enable Register
The Standard Event Status Enable Register selects which events in the
Standard Event Status Register are reflected in the ESB summary bit
(bit 5) of the Status Byte Register as shown in Figure 3-8.
Use *ESE to write to this register and *ESE? to read this register.
Use *ESE 0 to clear the register. (Power-on also clears this register.)
3-32Programming Guide
Page 73
Chapter 3 Programming Your Counter for Remote Operation
Status Reporting
The Operation and Questionable Data Status Register
Groups
The Operation and Questionable Data Status Register Groups have the
following registers:
•a condition register
•one or more transition filters
•an event register
•an event enable register
Figure 3-13 shows the model that these register groups follow.
= positive transition, or
*
negative transition, or
either transition.
See Table 3-6.
Event
Enable
Register
0
1
2
n-1
&
n
Device Status
Continuously
Monitored
Condition
Register
0
1
2
n-1
n
Transition
Filter
*
*
*
*
*
Event
Register
0
1
2
n-1
n
(Logical AND)
&
&
&
Logical OR
Summary Bit
(OSB or QSB)
Status Byte Register
&
Figure 3-13. Operation and Questionable Data Status Reporting Model
Programming Guide3-33
3
Page 74
Chapter 3 Programming Your Counter for Remote Operation
Status Reporting
Condition R eg i ster
A condition register continuously monitors the hardware and firmware
status of the Counter. There is no latching or buffering for this register; it
is updated in real time. Reading a condition register does not change its
contents.
A transition filter specifies the transition criteria for setting event bits
TRUE.
When the transition filter specifies a positive transition, the event
becomes TRUE when its associated condition makes a FALSE to TRUE
3
transition only.
When the transition filter specifies a negative transition, the event
becomes TRUE when its associated condition makes a TRUE to FALSE
transition only.
When the transition filters specify both a positive and a negative
transition, the event becomes TRUE when its associated condition makes
either a FALSE to TRUE or a TRUE to FALSE transition.
A transition filter is defined by positive and negative transition filter
registers. Table 3-6 describes how the transition filter registers define the
transition criteria for setting an event bit TRUE.
3-34Programming Guide
Page 75
Chapter 3 Programming Your Counter for Remote Operation
Status Reporting
T able 3-6. Transition Filter Definition
Positive
Transition
Filter Bit
TRUEFALSEpositive transition
FALSETRUEnegative transition
TRUETRUEeither a positive or negative transition
FALSEFALSEneither transition (event reporting is disabled)
Negative
Transition
Filter Bit
Transition Which Causes the Event-Bit to be set TRUE
Transition filt ers ar e unaff ect ed b y * CLS or qu er ie s. T rans i tion fi lt ers are
set to default values by :STATus:PRESet and power-on.
To write to the Operation Status transition filter registers use:
An event register captures ch anges in conditions.
An event register bit (event bit) is set TRUE when an associated event
occurs. These bits, once set, are “sticky.” That is, they cannot be cleared
even if they do not reflect the current status of a related condition, until
they are read.
Programming Guide3-35
3
Page 76
Chapter 3 Programming Your Counter for Remote Operation
The event enable registers are cleared by :STATus:PRESet and
power-on.
3-36Programming Guide
Page 77
Chapter 3 Programming Your Counter for Remote Operation
Status Reporting
Operation Status Registe r Group
The Operation Status Register Group monitors conditions which are part
of the Counter's normal operation and ha s a complet e se t of reg iste rs that
consist of the following:
•a condition register
•a positive transition filter register (PTR)
•a negative transition filter register (NTR)
•an event register
•an event enable register
Table 3-7 lists the Operation Status Register bits and briefly describes
each bit.
Table 3-7. Operation Status Register
BITWEIGHT DESCRIPTION
Figure 3-13 shows the model that these register groups follow.
0—Not used
1 - 3—Not used
416Measuring
532Waiting for Trigger
6 - 8—Not used
9512Using Internal Refe rence
10—Not used
11Acquiring
12Locked
13 - 14—Not used
15—Not used, since some cont rollers may have diffic ulty reading
a 16-bit unsigned integer. The value of this bit is always 0.
Programming Guide3-37
3
Page 78
Chapter 3 Programming Your Counter for Remote Operation
Status Reporting
A detailed description of each bit in the Operation Status Register follows:
•Bits 0-3 are not used.
•Bit 4 (Measuring) is a condition bit which indicates the Counter is
actively measuring.
The condition bit is TRUE (one) during a measurement and FALSE
(zero) otherwise.
•Bits 5 (Waiting for Trigger)
The condition bit is TRUE (one) when the Counter is in the HOLD
mode (INIT:CONT OFF), and it has not been triggered.
•Bits 6-8 are not used.
•Bit 9 (Using Internal Reference) is a condition bit which indicates
the Counter is using the internal reference.
The condition bit is TRUE (one) when the Counter i s using the
internal reference. The condition bit is FALSE (zero) while the
Counter is using the external reference. The setting of this bit is not
3
affected by the setting of the REF OSC option in the user settings
menu.
•Bit 10 is not used.
•Bit 11 (Acquiring) indicates that the counter is searching for a
signal.
The condition bit is high while the counter is searching. It goes low
when a search is complete, whether or not a signal was found. If a
signal was not found, the bit goes high again after a delay (when the
next search begins).
•Bit 12 (Locked) a value of 1 indicates that the counter has found a
measurable signal and has locked onto it.
•Bits 13-15 are not used.
3-38Programming Guide
Page 79
Chapter 3 Programming Your Counter for Remote Operation
Status Reporting
Questionable Data Status Register Group
The Questionable Data Status Register Group monitors
SCPI-defined conditions.
NOTE
For this register group, the transition filter is fixed as PTR with all bits
set to ones. This cannot be changed or queried.
Table 3-8 lists the Questionable Data Status Register bits and briefly
describes each bit.
Not used, since some controllers may have difficulty reading
a 16-bit unsigned integer. The value of this bit is always 0.
A detailed description of each bit in the Questionable Data Status
Register Group follows:
3
• Bits 0-2 are not used.
• Bit 3 (Power). Power Cal is turned off or the Power Cal tables in
EEPROM are defective or missing.
• Bit 5 (Frequenc
y) is a condition bit which indicates that frequency
measurements may be affected by component failures.
• Bits 6-11 are not used.
Programming Guide 3-39
Page 80
Chapter 3 Programming Your Counter for Remote Operation
Status Reporting
•Bit 12 (Hardware Summary) This condition is TRUE when an
internal hardware fault has been detected, either in normal operation
or by the self test.
•Bit 13 is not used.
•Bit 14 (Command Warning) is an event bit indicating a command,
such as CONFigure or MEASure, ignored a parameter during
execution.
Since this is an event bit, the transition filters have no effect on it.
•Bit 15 is not used.
3
3-40Programming Guide
Page 81
Chapter 3 Programming Your Counter for Remote Operation
Programming the Counter for Status Reporting
Programming the Co unter
for Status Reporting
Determining the Condition of the Counter
The Counter has status registers that are used to indicate its condition.
There are four register groups that can be examined individually, or used
to alert a computer. These registers, shown in Figure 3-10, are:
• Operation Status Register Group
• Questionable Data/Signal Regis ter Gr oup
• Standard Event Status Register Group
• Status Byte Register Group
The first three groups all have event registers that can be fed into the
Status Byte Register. The Status Byte Register can be used to assert the
SRQ line and thus alert the computer that the Counter needs attention.
The following examples show how each of the regi ster groups can be used.
(Figure3-14 is a flowchart that shows how to program the Counter for
Status Reporting.)
3
Programming Guide 3-41
Page 82
Chapter 3 Programming Your Counter for Remote Operation
Programming the Counter for Status Reporting
Resetting the Counter and Clearing
the Remote Interface—Example 1
Before attempting any programming, it is a good idea to set the Counter to
a known state. The following command grouping shows how to reset the
Counter. Before issuing these commands, execute a device clear to reset
the interface and Counter. Consult your interfac e card's documentation
for how to issue a device clear since the device clear command will be
specific to the interface you are using. Perform the following:
1. Issue an Interface Clear and a Device Clear. (See your computer or
interface card documentation on how to issue this command).
2. Issue the following commands:
*RST
*CLS
*SRE 0
*ESE 0
:STAT:PRES
3
Using the Standard Event Status Register to
Trap an Incorrect Command—Example 2
The following command grouping shows how to use the Standard Event
Status Register and the Status Byte Register to alert the computer when
an incorrect command is sent to the Counter. The command *ESE 32 tells
the Counter to summarize the command error bit (bit 5 of the Event
Status Register) in the Status Byte Register. The command error bit is set
when an incorrect command is received by the Counter. The command
*SRE 32 tells the Counter to assert the SRQ line when the Event Status
Register summary bit is set to 1. If the Counter is serial-polled after a
command error, the serial poll result is 96 (Bit 6 + Bit 5).
Event Status Register
*ESE 32 Enable for bad command.
*SRE 32 Assert SRQ from Standard Event Status Register summary.
3-42Programming Guide
Page 83
Chapter 3 Programming Your Counter for Remote Operation
Programming the Counter for Status Reporting
Using the Operation Status Register to Alert the
Computer When Measuring has
Completed—Example 3
The following command grouping illustrates how to use the Operation
Status register and the Status Byte register to alert the computer when
measuring has completed. This is useful if the Counter is making a long
measurement. When the measurement is complete, the Counter can alert
the computer.
The first line tells t he Counter to wa tch for a nega tive transit ion from true
(measuring) to false (non-measuring) of bit 4. This negative transition
indicates that the Counter has completed a measurement. The next line
tells the Counter to summarize the detected event (bit 4 of the Operation
Status Register) in the Status Byte Register. The command *SRE 128 tells
the Counter to assert SRQ when the summary bit for the Operation
Status register is set to 1. A serial poll will return 192 when a
measurement has completed.
Operation Status Register
:STAT:OPER:PTR 0; NTR 16 Detect transition from measuring to
non-measuring.
:STAT:OPER:ENABLE 16Enable to detect measuring.
*SRE 128 Assert SRQ on Operation Summary bit.
Programming Guide3-43
3
Page 84
Chapter 3 Programming Your Counter for Remote Operation
Programming the Counter for Status Reporting
Do you want
to do Status
Reporting?
YES
Reset and initialize the Counter
as follows:
Device Clear
RST
*
CLS
*
SRE 0
*
ESE 0
*
:STAT:PRES
continue program
Do you
want to report events
monitored by the Standard
Event Status
Register?
YES
3
Use the following:
ESE 189
*
This enables any of the available
bits to generate a summary bit to
the Status Byte Register.
(See Note 1)
NO
Skip this section ("Status Reporting").
NO
want to report events
monitored by the
Operation Status
Do you
Group?
YES
Use the following:
:STAT:OPER:ENAB 6704
This enables any of the available bits to
generate a summary bit to the Status Byte
Register. (See Note 1)
Do you
want to report a
measurement complete
event from the
Operation Status
Group?
Use the following:
:STAT:OPER:PTR 6688
:STAT:OPER:NTR 16
This enables the negative transition of the
"measuring event" bit to generate a summary
bit to the Status Byte Register.
Do you want
NO
to report events
monitored by the
Questionable Data/Signal
Status Group?
NO
YES
NO
NOTES:
1. All of the enable commands, used on this figure, enable all of the active
bits for each event register and the Status Byte Register. You do not have
to enable all bits. Read the description of each register to determine which
bits you want to enable.
2. Additional analysis should be performed if more than one bit is set.
Figure 3-14. Status Reporting Flowchart (1 of 2)
3-44Programming Guide
YES
Use the following:
:STAT:QUES:ENAB 20 520
This enables any of the available bits to
generate a summary bit to the Status Byte
Register. (See Note 1)
Go to sheet 2 of 2
Page 85
From sheet 1 of 2
Chapter 3 Programming Your Counter for Remote Operation
Programming the Counter for Status Reporting
Do you
want to send a
Service Request (SRQ)
interrupt to the
computer?
YES
Use the following:
*SRE 188
This enables any of the available
bits to generate the RQS/MSS
bit to set bit 6 in the Status Byte
Register and send an SRQ interrupt to the Computer. (See Note 1)
Are you
planning to
monitor the OPC bit of
the Event Status
Register?
YES
Enable OPC bit of Event Status
Register:
OPC
*
Activate the Counter function that
you want to monitor. For example,
use the following:
INIT
This initiates the selected
measurement.
When an interrupt occurs, perform
a Serial poll.
Write a subroutine to determine
which bits in the Status Byte
Register are set.
NO
NO
Initiate a Counter function.
For example, use the following:
INIT
This initiates the selected measurement.
To read the Status Byte Register, use the
following:
*STB?
enter A
print A
This reads the decimal value of the Status
Byte Register. (You can also use the serial
poll command to read this value.)
If bit 4 (MAV) is set, read the message in
the Output Queue. How you do this depends on what data is expected.
(See Note 2)
If bit 3 (QSB) is set, use the following:
:STAT:QUES:EVENt?
This returns the decimal value of the event
register. It also clears the register so that
subsequent events can be monitored.
If bit 5 (ESB) is set, use the following:
*ESR?
This returns the decimal value of the event
register. It also clears the register so that
subsequent events can be monitored.
If bit 7 (OSB) is set, use the following:
:STAT:OPER:EVEN?
This returns the decimal value of the event
register. It also clears the register so that
subsequent events can be monitored.
Write the necessary subroutines
to determine which events have
occured and what actions are
required.
NO
Is SRQ
interrupt enabled?
YES
3
Figure 3-14. Status Reporting Flowchart (2 of 2)
Programming Guide3-45
Page 86
Chapter 3 Programming Your Counter for Remote Operation
Programming the Counter to Display Results
Programming the Counter
to Display Results
Configuring the Counter's Display
The Counter has three display modes:
1. Raw results. This display mode is used on power-up.
2. Relative results - results modified by offset values
3. Display Disabled - All LCD display segments disabled.
The following command groupings show how to program the Counter to
any of the above display modes.
3
3-46Programming Guide
Page 87
Chapter 3 Programming Your Counter for Remote Operation
Commands for Displaying Results
Commands for Displaying Results
Command for Displaying Raw Results
The following command always causes raw measurement results to be
displayed:
*RSTTurns off all offsets.
Commands for Displaying Relative Results
FREQ:OFFS:STAT ON
POW:AC:REF:STAT ON
Turns on offsets.
Turns on offsets.
Commands for Enabling and Disabling the Display
The Counter display can be turned on or off. The normal condition is for
the display to be on.
:DISP:ENABLE OFF
:DISP:ENABLE ON
Disable the display, all segments off.
Normal display mode.
3
Programming Guide3-47
Page 88
Chapter 3 Programming Your Counter for Remote Operation
Programming the Counter to Synchronize Measurements
Programming the Counter to
Synchronize Measurements
Synchronizing Measurement Completion
There are three commands for synchronizing the end of a measurement
and computer transfer of data:
1. The *WAI command
2. The *OPC? command
3. The *OPC command to assert SRQ
The following discussion shows how to use these three commands.
Resetting the Counter and Clearing the Interface
Before attempting any programming, it is best to set the Counter to a
3
known state. The fo llowin g command grouping i llustrat es how to re set the
Counter. Before issuing these commands, execute a device clear to reset
the interface and the Counter. You should consult your interface card's
documentation for information on issuing a device clear, since the device
clear command is specific to the interface you are using. Perform the
following steps:
1. Issue an Interface Clear and a Device Clear. (See your computer or
interface card documentation for information on how to issue this
command.)
2. Issue the following commands:
*RST
*CLS
*SRE 0
*ESE 0
:STAT:PRES
3-48Programming Guide
Page 89
Chapter 3 Programming Your Counter for Remote Operation
Programming the Counter to Synchronize Measurements
Using the *WAI Command
This command is most useful when only the Counter is on the bus, and
you want the Counter to send the data when it is ready. In this example,
the Counter is instructed to take 50 measurements and return the
average for these 50 measurements. The *WAI command that follows the
:INIT command instructs the Counter to hold off execution of any further
commands until the 50 measurements are complete. When the Counter
has completed the 50 measurements and averages, it executes the DATA?
command, which requests the results.
:AVERAGE:STATE ON
:AVERAGE:COUNT 50
:INIT
*WAI
DATA?
Enable averaging.
Base the result on 50 measurements
Start 50 measurements.
Wait until 50 measurements are complete
before parsing another command. At this
point, commands can be issued to other
instruments. Th e Coun t er sto r e s
subsequent commands but ignores them
until the measurement is complete.
Asks for the results of the 50
measurements. This command is not
executed until all 50 measurements are
complete and the average is computed.
Using the *OPC? Command
This method is useful if you want to hold off execution of the program
while you wait for the Counter to complete any pending activity. In the
*WAI example above, the li ne following t he *WAI command is accepte d by
the Counter. However, the Counter does not execute the command
3
Programming Guide3-49
Page 90
Chapter 3 Programming Your Counter for Remote Operation
Programming the Counter to Synchronize Measurements
because of the preceding *WAI command. If this line had been a command
to address another instrument, it would be immediatel y executed. If you
had wanted to hold off the command to ano ther instrumen t, you would use
the *OPC? command instead of the *WAI command.
:AVERAGE:COUNT 50
:AVERAGE ON
:INIT
*OPC?
Read the Counter. The program waits until the Counter returns a 1. (The
HP-IB timeout must be set so that it is longer than the expected
measurement time.)
On INIT, take 50 measurements.
Enable averaging.
Start making measurements.
Tell Counter to put a 1 in the output buffer
when 50th measurement is complete.
Using the *OPC Command to Assert SRQ
3
This method is recommended when the Counter is interfaced with many
other instruments, any of which can assert SRQ. The commands *OPC,
*ESE 1 and *SRE 32 are used to assert the SRQ line to alert the computer
that the Counter has completed a measurement. It is up to the comput er
to use the serial poll command to determine which of the instruments on
the bus requested service.
Of the three procedures discussed here, this one is the most flexible, but it
is also the most complex:
:AVERAGE:COUNT 50
:AVERAGE ON
*ESE 1
*SRE 32
3-50Programming Guide
On INIT, take N measurements.
Enable averaging.
Summarize OPC bit for Status Byte Register.
SRQ when event summary bit is 1.
Page 91
Chapter 3 Programming Your Counter for Remote Operation
Programming the Counter to Synchronize Measurements
Set up program to specify service routine and enable interrupt when SRQ
is asserted:
:INIT
*OPC
The program can do other things while it is waiting for SRQ.
When SRQ occurs, and the Co unter has b een iden tifie d as th e cause of t he
SRQ, ask for the data:
DATA?Ask for data.
Start measuremen t s.
Enable OPC bit.
3
Programming Guide3-51
Page 92
Chapter 3 Programming Your Counter for Remote Operation
Writing SCPI Programs
Writing SCPI Programs
Figure 3-15 is a general summation of how to write SCPI programs. It
shows a typical sequence you might go through in the process of writing a
program. You do not have to follow this exact sequence, but it will help
you to become familiar with the Counter's capabilities and to direct you to
sections of the guide which will be useful while writing programs.
3
3-52Programming Guide
Page 93
Chapter 3 Programming Your Counter for Remote Operation
Writing SCPI Programs
Reset and initialize the Counter
as follows:
Device Clear
:ABORt
RST
*
CLS
*
SRE 0
*
ESE 0
*
:STAT:PRES
Do you
want to do Status
Reporting?
YES
Configure status reporting.
See section titled "Status
Reporting" in this chapter.
See Chapter 4, :STATus,
and *SRE.
See Figure 3-14.
*
NO
ESE,
Do you want to
average?
YES
Configure Averaging.
See Averaging in Chapter 3.
Initiate a measurement.
See Figure 2-1.
See Chapter 4, :INITiate .
NO
Do you
want to make a new
measurement?
YES
Select the function you want to
perform.
See Figure 2-1.
See [SENS]:FUNC in Chapter 4.
NO
To transfer measurement data,
see Chapter 4, [:SENS]:DATA?
Figure 3-15. SCPI Programming Flowchart
Programming Guide3-53
3
Page 94
Chapter 3 Programming Your Counter for Remote Operation
Programming Examples
Programming Examples
In this section, you will see how to program the HP 53150A/151A/152A to
make common measurements. Examples are provided in the following
programming languages:
•HP BASIC
•Microsoft QuickBASIC
•C
Using HP BASIC
This guide uses doubles quotes to enclose string parameters in syntax
descriptions, but uses single quotes in the HP BASIC programming
examples for readability.
The Counter allows string parameters to be enclosed by either double or
3
single quotes. Each method is discussed in the following sub-sections.
Sending Double-Quoted and Single-Quoted Strings
In HP BASIC OUTPUT statements, strings enclosed in double quotes
need special consideration. For example, you can send the FUNC "FREQ
1" command as follows:
OUTPUT 703;"FUNC ""FREQ 1"""
Note that a pair of double quotes (shown in bold) is required to embed a
double quote within an HP BASIC string. For more readable HP BASIC
OUTPUT statements, you can send the following command instead:
OUTPUT 703;"FUNC 'FREQ 1'"
Note that the pair of single quotes (shown in bold) is more readable.
Microsoft is a U.S. registered trademark of Microsoft Corporation.
*
Turbo C is a product of Borland International, Inc.
**
3-54Programming Guide
Page 95
Chapter 3 Programming Your Counter for Remote Operation
Programming Examples
Using C
The C examples assume you have an HP 82335A HP-IB Interface card
inside your IBM PC or compatible.
List of the Programming Examples
The following examples are provided:
1. Making a Frequency Measurement (HP BASIC)
2. Making a Frequency Measurement (QuickBASIC)
3. Making a Frequency Measurement (C)
NOTE
All programming examples use the ASCII format to transfer data from the
Counter to the computer. The ASCII format is the default format when
*RST is used.
3
Programming Guide3-55
Page 96
Chapter 3 Programming Your Counter for Remote Operation
Programming Examples
Making a Frequency Measurement ( H P BASIC)
10 ! This program sets up the counter to make 10 frequency
20 ! measurements on channel 2.
30 ! The results are displayed on the computer CRT.
40 ! ASCII format is used to preserve resolution.
50 !
60 INTEGER I! Declare variables
70 DIM Freq$(10)[22]! Declare string to enter data
80 !Using strings to enter ASCII format
90 ! data yields results formatted to the
100 ! correct resolution. ASCII is the
110 ! default format for the counter.
120 Samples=10 ! Take 10 measurements
130 !
140 ASSIGN @Count TO 703 ! Assign I/O path for counter
150 CLEAR 703 ! Clear the counter and interface
160 OUTPUT @Count;”*RST” ! Reset the counter
170 OUTPUT @Count;”*CLS”! Clear event registers and error queue
180 OUTPUT @Count;”*SRE 0” ! Clear service request enable register
190 OUTPUT @Count;”*ESE 0” ! Clear event status enable register
200 OUTPUT @Count;”:STAT:PRES” ! Preset enable registers and
210 ! transition filters for operation and
220 ! questionable status structures.
230 OUTPUT @Count;”:FUNC ‘FREQ 2’” ! Measure frequency on channel 1
270 !
280 CLEAR SCREEN! Clear the computer display
290 FOR I=1 TO Samples! Start making measurements
300 OUTPUT @Count;”INIT:*WAI;:DATA?” ! Start a measurement and
3
320 ENTER @Count;Freq$(I)! fetch the data
330 PRINT USING “11A,DD,4A,22A,3A”;”Frequency (“;I;”) = “;Freq$(I);” Hz”
340 NEXT I
350 LOCAL 703! Return counter to local
360 END
3-56Programming Guide
Page 97
Chapter 3 Programming Your Counter for Remote Operation
Programming Examples
Making a Frequency Measuremen t (QuickBASIC)
‘This program configures the counter to make 10 frequency measurements
‘on channel 2.
‘The results are printed on the computer monitor.
‘Data is sent in ASCII format to preseve resolution.
‘
‘The SUB sendhp sends commands to the counter
DECLARE SUB sendhp (code$)
REM $INCLUDE: ‘QBSETUP.BAS’‘Required by HP 82335A
DIM SHARED source AS LONG‘Address and select code
DIM i AS INTEGER‘i is used for loops
DIM samples AS INTEGER
samples = 10‘Number of measurements
DIM freqs(10) AS STRING * 23‘String to be read
source& = 703‘Counter at address 3
isc&p; = 7‘Select code 7
state% = 1‘Used in IOEOI
CLS‘Clear screen
CALL IOEOI(isc&p;, state%) ‘Make sure EOI enabled
CALL IOCLEAR(source&) ‘Clear the counter and interface
CALL sendhp(“*RST”) ‘Reset counter and stop autotriggering
CALL sendhp(“*CLS”) ‘Clear event registers and error queue
CALL sendhp(“*SRE 0”) ‘Clear service request enable register
CALL sendhp(“*ESE 0”) ‘Clear event status enable register
CALL sendhp(“:STAT:PRES”) ‘Preset enable registers and
transition
CALL sendhp(“:func “ + CHR$(34) + “FREQ 2” + CHR$(34)) ‘Measure frequency
CLS‘Clear computer screen
FOR i = 1 TO samples
CALL sendhp(“INIT;*WAI;:DATA?”)‘Initiate a measurement and
CALL IOENTERS(source&ng, freqs(i), 23, actf%) ‘Read the ASCII characters
PRINT “Frequency”; i; “= “; freqs(i)
NEXT i
END
‘ Subroutine to send command to HP 5315xA/
SUB sendhp (code$)
CALL iooutputs(source, code$, LEN(code$))
END SUB
‘Reading ASCII formatted data
‘gives results to the correct
‘resolution. Must be read into
‘a string. The maximum number
‘of characters that can ever be
‘sent is 20 per measurement.
‘filters for operation and questionable
‘status structures
‘get the result
3
Programming Guide3-57
Page 98
Chapter 3 Programming Your Counter for Remote Operation
Programming Examples
Making a Frequency Measurement ( C)
/* This program configures the counter to make 10 frequency measurements
on channel 1 followed by 10 on channel 2.
The results are displayed on the computer monitor.
The program comments discuss the meaning of each command.
ASCII result format is used to preserve resolution. */
#include <stdio.h
#include <string.h
#include “CHPIB.H”
#include “CFUNC.H”
void sendhp(char *); /* function to send command to counter */
/* global data */
long ctr=703; /* Counter is at address 03. HP-IB is at select code 7 */
int error;
void main()
{
long isc=7; /* Select code 7 */
int state=1; /* Used in IOEOI */
int i; /* Used for loop counter */
int samples=10; /* Number of measurements to take */
int length=23; /* Max number of bytes per measurements */
char freq[23]; /* Array to hold frequency string */
IORESET(isc); /* Clear the HP-IB interface */
sendhp(“*RST”); /* Reset the counter */
sendhp(“*CLS”); /* Clear event registers and error queue */
sendhp(“*SRE 0”); /* Clear service request enable register */
sendhp(“*ESE 0”); /* Clear event status enable register */
3
sendhp(“:STAT:PRES”); /* Preset enable registers and transition
IOEOI(isc,state); /* Enable use of EOI */
sendhp(“:FUNC ‘FREQ 1’”);/* Measure frequency on channel 1
for (i=1; i<=samples ;i++)
{
sendhp(“INIT”); /* Start a measurement */
sendhp(“DATA?”);
IOENTERS(ctr,freq,&length); /* fetch the data */
length=strlen(freq); /* Get length of result so */
freq[length-1]=’\0’; /* the linefeed can be removed*/
printf (“Frequency %d = %s Hz\n”,i,freq);
}
printf(“Press a key to continue\n”);
getch();
sendhp(“:FUNC ‘FREQ 2’”); /* Change channels */
for (i=1; i<=samples ;i++)
{
sendhp(“INIT;*WAI;:DATA?”); /* Start a measurement */
IOENTERS(ctr,freq,&length); /* fetch the data */
length=strlen(freq); /* Get length of result so */
freq[length-1]=’\0’; /* the linefeed can be removed*/
printf (“Frequency %d = %s Hz\n”,i,freq);
}
printf(“Press a key to continue\n”);
filters for operation and questionable
status structures */
Note that the function must
be a quoted string. The actual
string sent to the counter is ‘FREQ 1’. */
3-58Programming Guide
Page 99
Chapter 3 Programming Your Counter for Remote Operation
Programming Examples
getch();
}
/* Function to send command to HP 5315xA */
void sendhp(hpib_cmd)
char *hpib_cmd;
{
char hpcmd[80]; /* Variables used by function */
int length;
strcpy(hpcmd, hpib_cmd);
length=strlen(hpcmd);
error=IOOUTPUTS(ctr, hpcmd, length); /* Send command to HP 5315xA */
if (error!=0)
printf(“Error during HP-IB: %d Command %s\n”,error,hpcmd);
}
Programming Guide3-59
3
Page 100
Chapter 3 Programming Your Counter for Remote Operation
Programming Examples
3
3-60Programming Guide
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.