The information contained in this document is subject to change without
notice.
Hewlett-Packard makes no warranty of any kind with regard to this material,
including but not limited to, the implied warranties of merchantability and
fitness for a particular purpose. Hewlett-Packard shall not be liable for errors
contained herein or for incidental or consequential damages in connection
with the furnishing, performance, or use of this material.
This manual documents analyzers with firmware revisions C. 04.52 or later.
Some features will not be available or will require different keystrokes
in analyzers with earlier firmware revisions. For full compatibility, you
can upgrade your firmware to the latest version. Contact your nearest
Hewlett-Packard sales or service office for information.
@Copyright 1996, 1997, 1998 Hewlett-Packard Company
HP-IB Programming
This document is an introduction to programming your analyzer over the
Hewlett-Packard Interface Bus (HP-IB). Its purpose is to provide concise
information about the operation of the instrument under
It provides some background information on the HP-IB and a tutorial
introduction using progr
amming
examples to demonstrate the remote
operation of the analyzer. The examples are provided on two disks that are
included with the analyzer. Both disks contain the same examples written
mainly in HP BASIC; only the disk format is different. These programs can
run on the analyzer’s internal controller (Option
lC2)
controller.
l
Example Programs Disk -
l
ExammpLe
Programs Disk -
DOSFbvmat
LIFRrrmat
: part number 08712-10019
: part number 08712-10021
You should become familiar with the operation of your network analyzer
before controlling it over HP-IB. This document is not intended to teach
programming or to discuss HP-IB theory except at an introductory level.
Related information can be found in the following references. Contact the
nearest HP sales office for ordering information. A list of HP sales and service
offices can be found in the “Specifications and Characteristics” chapter of the
User’s Guide.
HP-II3
control.
or on an external
l
Information on making measurements with the analyzer is available in the
analyzer’s User’s Guide.
l
Information on HP Instrument BASIC is available in the
BASIC User’s Handbook.
0
Information on HP BASIC progr
amming
the BASIC revision being used. For example:
Rchniques
l
Information on using the HP-IB is available in the
Device
Limit
Questionable Status Register
Standard Event Status Register
Measuring Status Register
Averaging Status Register
Operational Status Register
STATus:PRESet Settings
Analyzer Register
HP-IB - the Hewlett-Packard Interface Bus - is a high-performance bus
that allows individual instruments and computers to be combined into
integrated test systems. The bus and its associated interface operations are
defined by the IEEE 488.1 standard. The IEEE 488.2 standard defines the
interface capabilities of instruments and controllers in a measurement system,
including some frequently used commands.
HP-IB cables provide the physical link between devices on the bus. There are
eight data lines on each cable that are used to send data from one device to
another. Devices that send data over these lines are called
are devices that receive data over the same lines. There are also five control
lines on each cable that are used to manage
control other interface operations. Controllers are devices that use these
control lines to specify the talker and listener in a data exchange. When an
HP-IB system contains more that one device with controller capabilities,
only one of the devices is allowed to control data exchanges at any given
time. The device currently controlling data exchanges is called the Active
Controller. Also, only one of the controller-capable devices can be designated
as the System Controller, the one device that can take control of the bus
even if it is not the active controller. The network analyzer can act as a
talker, listener, active controller or system controller at different times.
trafhc
on the data lines and to
Talkers.
Listeners
HP-IB addresses provide a way to identify devices on the bus. The active
controller uses HP-IB addresses to specify which device talks and which
device listens during a data exchange. This means that each device’s address
must be unique. A device’s address is set on the device itself, using either a
front-panel key sequence or a rear-panel switch.
To set the HP-IB address on the analyzer use the
[SYSTEM OPTIONS) HP-IB menu. The factory default address for the analyzer
is 16.
l-2
softkeys
located in the
NOTE
Throughout this manual, the following conventions are used:
Introduction to HP-IB Programming
Square brackets
programming the command; that is, the instrument will process the command to have the same
effect whether the option node is omitted or not.
Parameter types
A vertical bar (I
I
Cc II
are used to enclose a keyword that is optional or implied when
(C >I
are distinguished by enclosing the type name in angle brackets.
)
can be read as “or” and is used to separate alternative parameter options.
I
l-3
Bus Structure
Data Bus
The data bus consists of eight lines that are used to transfer data from one
device to another. Programming commands and data sent on these lines is
typically encoded in the ASCII format, although binary encoding is often used
to speed up the transfer of large arrays. Both ASCII and binary data formats
are available to the analyzer. In addition, every byte transferred over HP-IB
undergoes a handshake to ensure valid data.
Handshake Lines
Control lines
A three-line handshake scheme coordinates the transfer of data between
talkers and listeners. This technique forces data transfers to occur at the
speed of the slowest device, and ensures data integrity in multiple listener
transfers. With most computing controllers and instruments, the handshake is
performed automatically, which makes it transparent to the programmer.
The data bus also has five control lines that the controller uses both to send
bus commands and to address devices:
IFC
ATN
l-4
Interface Clear. Only the system controller uses this line.
When this line is true (low) all devices (addressed or not)
unaddress and go to an idle state.
Attention. The active controller uses this line to define
whether the information on the data bus is a command or is
data. When this line is true (low) the bus is in the command
mode and the data lines carry bus commands. When this
line is false (high) the bus is in the data mode and the data
lines carry device-dependent instructions or data.
Introduction to HP-IB Programming
Bus
Structure
SRQ
REN
EOI
Service Request. This line is set true (low) when a
device requests service: the active controller services the
requesting device. The analyzer can be enabled to pull the
SRQ line for a variety of reasons.
Remote Enable. Only the system controller uses this line.
When this line is set true (low) the bus is in the remote
mode and devices are addressed either to listen or talk.
When the bus is in remote and a device is addressed, the
device receives instructions from HP-IS rather than from its
front panel (pressing the
Beturn to Local softkey
returns
the device to front panel operation). When this line is set
false (high) the bus and all devices return to local operation.
End or Identify. This line is used by a talker to indicate the
last data byte in a multiple byte transmission, or by an
active controller to initiate a parallel poll sequence. The
analyzer recognizes the EOI line as a terminator and it pulls
the EOI line with the last byte of a message output (data,
markers, plots, prints, error messages). The analyzer does
not respond to parallel poll.
l-5
Sending Commands
Commands are sent over the HP-IB via a controller’s language system,
such as
send HP-IB commands vary among systems. When determining the correct
keywords to use, keep in mind that there are two different kinds of HP-IB
commands:
l
l
Language systems usually deal differently with these two kinds of HP-IB
commands. For example, HP BASIC uses a unique keyword to send each bus
management command, but always uses the keyword OUTPUT to send device
commands.
The following example shows how to send a typical device command:
IBASIC, QuickBASIC
or C. The keywords used by a controller to
Bus management commands, which control the HP-IB interface.
Device commands, which control analyzer functions.
OUTPUT 7 16 ; “CALCULATE : MARKER : MAXIMUM”
This sends the command within the quotes (CALCULATE : MARKER : MAXIMUM)
to the
HP-II3
device at address 716. If the device is an analyzer, the command
instructs the analyzer to set a marker to the maximum point on the data
trace.
l-6
HP-IB Requirements
Number of
Devices:
Interconnection
Path/Maximum Cable Length:
Message
Data
Address Capability:
Multiple Controller Capability:
Interconnected
Transfer
Rate:
Scheme:
15 maximum
20 meters maximum or 2 meters per device,
whichever is less.
Byte serial/ bit parallel asynchronous data
transfer using a
Maximum of 1 megabyte per second over
limited distances with tri-state drivers.
Actual data rate depends on the transfer rate
of the slowest device involved.
Primary addresses: 31 talk, 31 listen. A
maximum of 1 talker and 14 listeners at one
time.
In systems with more than one controller
(like the analyzer system), only one can
be active at a time. The active controller
can pass control to another controller, but
only the system controller can assume
unconditional control. Only one system
controller is allowed. The system controller
is hard-wired to assume bus control after a
power failure.
3-line
handshake system.
l-7
Interface Capabilities
The analyzer has the following interface capabilities, as defined by the
IEEE 488.1 standard:
SHl
AH1
T6
TEO
L4
LEO
I
SRl
1 RLl
OCI
I
Cl
c2
c3
I
c4l
CB1
c122
E2
full Source handshake capability
full Acceptor handshake capability
basic Talker, Serial Poll, no Talk Only, unaddress if MLA
no Extended Talker capability
basic Listener, no Listen Only, unaddress if MTA
no Extended Listener capability
I
full Service Request capability
I
1
full Remote/local capability
full Device Clear caoabilitv
I
System Controller capability
I
send
IFC
and take charge Controller capability
send REN Controller capability
respond to
send IFC, receive control, pass control, pass control to self
send IF messages, receive control, pass control
tri-state drivers
SRC
I
I
I
I
1-8
LIT1
PPO
1
only when an HP Instrument BASIC program is running
2 only when an HP Instrument BASIC program is not running
full device trigger capability
no parallel poll capability
Programming Fundamentals
This section includes
analyzer. It includes how the analyzer interacts with a controller, how data
is transferred between the analyzer and a controller, and how to use the
analyzer’s status register structure to generate service requests.
specific
information for programming your network
Controller Capabilities
The analyzer can be
a talker/listener on the bus.
the System Controller or the
@YSTEM
The analyzer is not usually
only controller on the bus. This setup would be used if the analyzer only
needed to control printers or plotters. It would also be used if HP Instrument
BASIC was being used to control other test equipment.
When the analyzer is used with another controller on the bus, it is usually
conEgured
passed control it can function as the active controller.
0PrloNs)
as a talker/listener. In this
conEgured
‘Ib configure
HP-IB menu.
conEgured
as an
HP-IIl
the analyzer, select either
TalkerlListeaer
as the system controller unless it is the
conEguration,
system controller or as
softkey
when the analyzer is
in the
l-9
Introduction to
HP-IR
Programming
Programming Fundamentals
Response to Bus Management Commands
The HP-IB contains an attention (ATN) line that determines whether
the interface is in command mode or data mode. When the interface is
in command mode (ATN TRUE) a controller can send bus management
commands over the bus. Bus management commands specify which devices
on the interface can talk (send data) and which can listen (receive data).
They also instruct devices on the bus, either individually or collectively, to
perform a particular interface operation.
This section describes how the analyzer responds to the HP-IB bus
management commands. The commands themselves are defined by the
IEEE 488.1 standard. Refer to the documentation for your controller’s
language system to determine how to send these commands.
Device Clear
Go To local
(DC11
(GTLI
Interface Clear
(IFC)
When the analyzer receives this command, it:
l
Clears its input and output queues.
l
Resets its command parser (so it is ready to receive a new program
message).
l
Cancels any pending
*OPC
command or query.
The command does not affect:
l
Front panel operation.
l
Any analyzer operations in progress (other than those already mentioned).
l
Any instrument settings or registers (although clearing the output queue
may indirectly affect the Status Byte’s Message Available (MAV) bit).
This command returns the analyzer to local (front-panel) control. All keys on
the analyzer’s front-panel are enabled.
This command causes the analyzer to halt all bus activity. It discontinues
any input or output, although the input and output queues are not cleared.
If the analyzer is designated as the active controller when this command is
received, it relinquishes control of the bus to the system controller. If the
analyzer is enabled to respond to a Serial Poll it becomes Serial Poll disabled.
l-10
Introduction to
Programming Fundamentals
HP-16
Programming
local lockout
Parallel Poll
Remote Enable
(1101
(RENI
This command causes the analyzer to enter the local lockout mode, regardless
of whether it is in the local or remote mode. The analyzer only leaves the
local lockout mode when the HP-IB’s Remote Enable (REN) line is set FALSE.
Local Lockout ensures that the analyzer’s remote
Rstunr ta LOCAL softkey)
is disabled when the analyzer is in the remote
softkey
menu (including the
mode. When the key is enabled, it allows a front-panel operator to return the
analyzer to local mode, enabling all other front-panel keys. When the key is
disabled, it does not allow the front-panel operator to return the analyzer to
local mode.
The analyzer ignores all of the following parallel poll commands:
l
Parallel Poll
l
Parallel Poll
l
Parallel Poll Enable (PPE).
l
Parallel Poll Disable (PPD).
REN is a single line on the
ConEgure
(PPC).
UnconEgure (PPU).
HP-IR.
When it is set TRUE, the analyzer will
enter the remote mode when addressed to listen. It will remain in remote
mode until it receives the Go to Local (GTL) command or until the REN line is
set FALSE.
When the analyzer is in remote mode and local lockout mode, all front panel
keys are disabled. When the analyzer is in remote mode but not in local
lockout mode, all front panel keys are disabled except for the softkeys. The
remote softkey menu includes seven keys that are available for use by a
program. The eighth
softkey
is the
Bet-
to LOCAL key which allows a
front-panel operator to return the analyzer to local mode, enabling all other
front-panel keys.
l-11
Introduction to
HP-18
Programming
Programming Fundamentals
Selected Device Clear
(SDC)
Serial Poll
The analyzer responds to this command in the same way that it responds to
the Device Clear (DCL) command.
When the analyzer receives this command it:
l
Clears its input and output queues.
l
Resets its command parser (so it is ready to receive a new program
message).
l
Cancels any pending
*OPC
command or query.
The command does not affect:
l
Front-panel operation.
l
Any analyzer operations in progress (other than those already mentioned).
l
Any analyzer settings or registers (although clearing the output queue may
indirectly affect the Status Byte’s MAV bit).
The analyzer responds to both of the serial poll commands. The Serial Poll
Enable (SPE) command causes the analyzer to enter the serial poll mode.
While the analyzer is in this mode, it sends the contents of its Status Byte
register to the controller when addressed to talk.
When the Status Byte is returned in response to a serial poll, bit 6 acts as the
Request Service (RQS) bit. If the bit is set, it will be cleared after the Status
Byte is returned.
The Serial Poll Disable (SPD) command causes the analyzer to leave the serial
poll mode.
Take Control Talker
ITCTI
If the analyzer is addressed to talk, this command causes it to take control
of the HP-IB. It becomes the active controller on the bus. The analyzer
automatically passes control back when it completes the operation that
required it to take control. Control is passed back to the address
the
*PCB
command (which should be sent prior to passing control).
speciEed
by
If the analyzer does not require control when this command is received, it
immediately passes control back.
1-12
Introduction to HP-IB Programming
Programming Fundamentals
Message Exchange
The analyzer communicates with the controller and other devices on the
HP-IB using program messages and response messages. Program messages are
used to send commands, queries, and data to the analyzer.
Response messages are used to return data from the analyzer. The syntax for
both kinds of messages is discussed in Chapter 10.
There are two important things to remember about the message exchanges
between the analyzer and other devices on the bus:
l
The analyzer only talks after it receives a terminated query (see “Query
Response Generation” later in this section).
l
Once it receives a terminated query, the analyzer expects to talk before it is
told to do something else.
HP-IB Queues
Queues enhance the exchange of messages between the analyzer and other
devices on the bus. The analyzer contains:
l
An input queue.
l
An error queue.
l
An output queue.
Input Queue.
The input queue temporarily stores the following until they are read by the
analyzer’s command parser:
l
Device commands and queries.
l
The HP-IB END message (EOI asserted while the last data byte is on the
bus).
The input queue also makes it possible for a controller to send multiple
program messages to the analyzer without regard to the amount of time
required to parse and execute those messages. The queue holds up to
128 bytes. It is cleared when:
l
The analyzer is turned on.
l
The Device Clear (DCL) or Selected Device Clear (SDC) command is
received.
1-13
Introduction to
HP-M
Programming
Programming Fundamentals
Error Queue.
The error queue temporarily stores up to 20 error messages. Each time
the analyzer detects an error, it places a message in the queue. When you
send the
SYST:ERR?
query, one message is moved from the error queue to
the output queue so it can be read by the controller. Error messages are
delivered to the output queue in the order they were received.
The error queue is cleared when:
l
All the error messages are read using the SYST : ERR? query.
l
The analyzer is turned on.
l
The *CLS command is received.
Output Queue.
The output queue temporarily stores a single response message until it is read
by a controller. It is cleared when:
l
The message is read by a controller.
l
The analyzer is turned on.
l
The Device Clear (DCL) or Selected Device Clear (SDC) command is
received.
Command Parser
The command parser reads program messages from the input queue in the
order they were received from the bus. It analyzes the messages to determine
what actions the analyzer should take.
One of the parser’s most important functions is to determine the position of a
program message in the analyzer’s command tree (described in Chapter 10).
When the command parser is reset, the next command it receives is expected
to arise from the base of the analyzer’s command tree.
The parser is reset when:
l
The analyzer is turned on.
l
The Device Clear (DCL) or Selected Device Clear (SDC) command is
received.
l
A colon immediately follows a semicolon in a program message. (For more
information see “Sending Multiple Commands” in Chapter 10.)
l
A program message terminator is received. A program message terminator
can be an ASCII carriage return
(‘n)
or
newline
character or the HP-IS
END message (EOI set true).
1-14
Introduction to HP-IB Programming
Query Response
Generation
When the analyzer parses a query, the response to that query is placed in
the analyzer’s output queue. The response should be read immediately after
the query is sent. This ensures that the response is not cleared before it is
read. The response is cleared when one of the following message exchange
conditions occurs:
l
Unterminated condition - the query is not properly terminated with an
ASCII carriage return character or the HP-IB END message (EOI set true)
before the response is read.
l
Interrupted condition - a second program message is sent before the
response to the
l
Buffer deadlock - a program message is sent that exceeds the length of the
first
is read.
input queue or that generates more response data than Ets in the output
queue.
1-15
Introduction to HP-IB Programming
2
Synchronizing the
Analyzer
and a Controller
Synchronizing the Analyzer
and a Controller
The IEEE 488.2 standard provides tools that can be used to synchronize the
analyzer and a controller. Proper use of these tools ensures that the analyzer
is in a known state when you send a particular command or query.
Device commands can be divided into two broad classes:
l
Sequential commands.
l
Overlapped commands.
Most of the analyzer’s commands are processed sequentially. A sequential
command holds off the processing of subsequent commands until it has been
completely processed.
Some commands do not hold off the processing of subsequent commands;
they are called overlapped commands.
2-2
Overlapped Commands
Typically, overlapped commands takelongerto process than sequential
commands. Forexample,the
measurement. The command is not considered to have been completely
processed until the measurement is complete. This
a narrow or fine system bandwidth or when averaging is enabled.
The analyzer has the following overlapped commands:
The analyzer uses a No Pending Operation (NPO) flag to keep track of
overlapped commands. The NPO flag is reset to 0 when an overlapped
command has not completed (still pending). It is set to 1 when no overlapped
commands are pending. The NPO flag cannot be read directly but all of the
following common commands take some action based on the setting of the
flag.
*WA1
*0PC?
*0PC
Holds off the processing of subsequent commands until the NPO
flag is set to 1. This ensures that commands in the analyzer’s input
queue are processed in the order received.
The program continues to run, and additional commands are
received and parsed by the analyzer (but not executed), while
waiting for the NPO flag to be set. Use of the
*WA1
command is
explained later in this section and is demonstrated in the SETUP
example program.
Places a 1 in the analyzer’s output queue when the NPO flag is set
to 1. lf the program is designed to read the output queue before it
continues, this effectively pauses the controller until all pending
overlapped commands are completed. Use of the *OPC? command is
explained later in this chapter and is demonstrated in the TRANCAL
and REFLCAL example programs.
Sets bit 0 of the Standard Event Status event register to 1 when the
NPO flag is set to 1. The analyzer’s status registers can then be
used to generate a service request when all pending overlapped
commands are completed. This synchronizes the controller to the
completion of an overlapped command, but also leaves the controller
free to perform other tasks while the command is executing.
NOTE
*OPC
only informs you when the NPO flag is set to 1.
subsequent commands. No commands should be sent to the analyzer between sending the
command and receiving the service request. Any command sent will be executed and may affect how
the instrument responds to the previously sent
*OPC.
It
does not hold off the processing of
*OPC
2-5
Synchronizing the Analyzer
and a Controller
The NPO Flag
CAUTION
The *CLS and
*RST
commands cancel any preceding
*OPC
command
or query. Pending overlapped commands are still completed, but their
completion is not reported in either the status register or the output queue.
Two
HP-H3
bus management commands - Device Clear (DCL) and Selected
Device Clear (SDC) - also cancel any preceding *OPC command or query.
NOTE
Use
*WAI, *OPC?
is to send
ALWAYS
trigger an individual sweep (using *OPC? and waiting for the
*OPC?
or
*OPC
whenever overlapped commands are used. A recommended technique
at the end of each group of commands.
reply) before reading data over the bus or executing a marker function. The
analyzer has the ability to process the commands it. receives faster than it can
make a measurement,. lf the measurement is not complete when the data is
read or a marker search function is executed the results are invalid.
The command to use (in an
OUTPUT
ENTER
QHp87ll;“ABOR;:INIT:CONT
OHp87ll;Opc-done
IBASIC
OUTPUT statement) is:
OFF;:INIT;*OPC?”
or another form of the :
with the *OPC? query.
Refer to
“%king
Sweeps” in Chapter 6 for more information.
2-6
INITiate Cl I21 C:
IMMediateI command combined
l
WAl
Synchronizing the Analyzer
and a Controller
The NPO Flag
Usage of *WA1 and *OPC?
The following example describes the use of the
discussion, remember that a sequential command holds off the processing of
subsequent commands until it has been completely processed. An overlapped
command does not.
*WA1
command. For this
10 OUTPUT QRfna;
20 OUTPUT
(PRf
“commandi”
na;
“command2
;
*WAI”
30 OUTPUT QRfna;“command3;”
40 OUTPUT
QRf
na;
“command4”
50 END
In the example above:
l
Commands 1 through 4 are sent to the analyzer as fast as the HP-IB bus
traffic will allow, and the program may very well end before any command
has been completed.
l
Command 1 begins execution first.
l
The order in which commands 1 and 2 are
completed
depends on the
command types. If both commands are overlapped commands (versus
sequentid
l
Commands 3 and 4 will not be parsed until commands 1 and 2 are
commands), the order of completion is unknown.
completed.
l
Command 3 will begin execution before command 4.
l
The order in which commands 3 and 4 are
ccnnpktm
depends on the
command types. If both commands are overlapped commands (versus
sequential commands), the order of completion is unknown.
2-7
Synchronizing the Analyzer
and a Controller
*oPc?
The following example describes the use of the *OPC? query and command.
For this discussion, remember that a sequential command holds off the
processing of subsequent commands until it has been completely processed.
An overlapped command does not.
10 OUTPUT ORfna;
20 OUTPUT QRfna;
“commandi”
“command2; *OPC?”
30 ENTER ORfna;Opc-done
40 OUTPUT
50 OUTPUT QRfna;
(QRf
na;
“command3
“command4; *OPC?”
;
I’
60 ENTER ORfna;Opc-done
70
END
In the example above:
l
Commands 1 and 2 are sent to the analyzer as fast as the HP-IB bus traffic
will allow.
l
Command 1 will begin execution before command 2.
l
The order in which commands 1 and 2 are
cowzpktm!
depends on the
command types. If both commands are overlapped commands (versus
sequential commands), the order of completion is unknown.
l
When commands 1 and 2 are completed, commands 3 and 4 will be sent to
the analyzer as fast as the HP-IB bus
l
Command 3 will begin execution before command 4.
traffic
will allow.
l
The order in which commands 3 and 4 are
completed
depends on the
command types. If both commands are overlapped commands (versus
sequential commands), the order of completion is unknown.
l
This program will not end until the OPC in line 60 is returned.
2-8
3
Passing Control
Passing Control
When an external controller is connected to the analyzer with an HP-IB
cable, passing control may be needed to control devices such as printers and
plotters that are also connected on the HP-IB. For some operations the active
controller must pass control to the analyzer. When the analyzer completes
the operation, it automatically passes control of the bus back to the external
controller.
An example program, PASSCTRL, demonstrates passing control to the
analyzer. In this example program control is passed so the analyzer can
control a printer for hardcopy output. See Chapter 8, “Example Programs.”
NOTE
Pass Control is not needed to control peripherals connected to the serial, parallel, or LAN ports.
I
I
For smooth passing of control, take steps that ensure the following conditions
are met:
l
The analyzer must know the controller’s address so it can pass control
back.
l
The controller must be informed when the analyzer passes control back.
3-2
Passing Control
The following is a procedure for passing control:
1. Send the controller’s HP-IB address to the analyzer with the *PCB
command.
2. Clear the analyzer’s status registers with the
*CLS
command.
3. Enable the analyzer’s status registers to generate a service request when
the Operation Complete bit is set. (Send
*ESE
with a value of 1 and *SRE
with a value of 32.)
4. Enable the controller to respond to the service request.
5. Send the command that requires control of the bus followed by the *OPC
command.
6. Pass control to the analyzer and wait for the service request. The service
request indicates that the command has been completed and control has
been passed back to the controller.
NOTE
For this procedure to work properly, only the command that requires control of the bus should be
pending. Other overlapped commands should not. For more information on overlapped commands, see
Chapter 2, “Synchronizing the Analyzer and a Controller.”
3-3
Passing Control
4
Data Types and Encoding
Data Types and Encoding
Data is transferred between the analyzer and a controller via the HP-IB data
lines,
DIOl
through
at a time), bit-parallel (8 bits at a time) manner. This section discusses the
following aspects of data transfer:
l
The different data types used during data transfers.
l
Data encoding used during transfers of numeric block data.
DIOS.
Such transfers occur in a byte-serial (one byte
4-2
Data Types
The analyzer uses a number of different data types during data transfers.
Data transfer occurs in response to a query. The data type used is determined
by the parameter being queried. The different parameter types are described
in the “Parameter Types” section of Chapter 10. Data types described in this
section are:
l
Numeric Data.
l
Character Data
l
String Data
l
Expression Data
l
Block Data
Numeric Data
The analyzer returns three types of numeric data in response to queries:
NRl
data
Integers (such as + 1,
response type for boolean parameters as
-1, 123, -12345). This is the
0,
weII
as some
numeric parameters.
NR2
data
Floating point numbers with an explicit decimal point (such
as 12.3, +1.234, -0.12345).
NR3
data
Floating point numbers in scientific notation (such as
+1.23E+5,
+123.4E-3,
-456.789E+6).
4-3
Data Types and Encoding
Data Types
Character Data
Character data consists of
that represent specific instrument settings (such as
or
MLOGarithmic).
mnemonic in upper-case alpha characters.
The analyzer always returns the short form of the
ASCII
characters grouped together in mnemonics
MAXimum
,
MINimum
String Data
String data consists of ASCII characters. The string must be enclosed by a
delimiter, either single quotes (‘This is string data. ‘) or double quotes
(“This is also string data.
the string it must be typed twice without any characters in between. The
analyzer always uses double quotes when it returns string data.
‘I).
To include the delimiter as a character in
Expression Data
Expression data consists of mathematical expressions that use character
parameters. When expression data is sent to the analyzer it is always
enclosed in parentheses
returns expression data enclosed in double quotes.
(such
as
(IMPL/CHlSMEM)
or
(IMPL)).
The analyzer
4-4
Data Types and Encoding
Data Types
Block Data
Block data are typically used to transfer large quantities of related data (like a
data trace). Blocks can be sent as
blocks - the instrument will accept either form. The analyzer always returns
definite length block data in response to queries.
deEnite
length blocks or indefinite length
Definite Block length
The general form for a
definite
block length transfer is:
#Q-mm-digits><num,bytes><data,bytes>
ln
the definite length block, two numbers must be
decimal digit
<num,digits> speciEes
how many digits are contained in
<num,bytes>. The decimal number <num-bytes)
bytes will follow in <data-bytes>. An example
statement to send ABC+XYZ as a
deEnite
block length parameter is shown,
specified.
speciEes
IBASIC
The single
how many data
(or HP BASIC)
note that the data block contains seven bytes (7) and only one digit is needed
to describe the block length 1.
OUTPUT 716;
NOTE
This analyzer will send an additional
definite length block form for your analyzer is:
“#17ABC+XYZ”
cc~>
with EOI asserted for definite block length transfers. The
#<num,digits><num,bytes><data-bytes><cn><EOI>
<num,bytes>is the number of <data-bytes> without counting
<Cn><EOI>.
4-5
Data Types and Encoding
Data Types
indefinite Block length
The general form for an indefinite block length transfer is:
After the last data byte is sent, the
by sending a carriage return or
termination of the program message. An example
statement to send ABC+XYZ as an
indehnite
newline
indeEnite
length block must be terminated
with EOI asserted. This forces the
IBASIC
(or HP BASIC)
block length parameter is shown,
note that ,END is used to properly terminate the message.
OUTPUT
716;
“#OABC+XYZ”
,END
4-6
Data Encoding for Large Data Transfers
The
FORMat :DATA
encoding that is used to transfer large blocks of numeric data between the
analyzer and a controller. There are two specifiers:
command selects the type of data and the type of data
REAL
INTeger
ASCii
Blocks that contain mixed data - both numbers and
ignore the setting of
definite length or indefinite length block data. The following commands
transfer blocks of mixed data:
PROGram[:SELectedl :DEFine
SYSTem:SET
specifies the block data type. Either the definite or indefinite
length syntax can be used. The block is transferred as
a series of binary-encoded floating-point numbers. Data
transfers of the REAL, 64 data type are demonstrated in the
REALDATA
specifies the block data type. Either the
length syntax can be used. The block is transferred as an
array of binary-encoded data with each point represented
by a set of three
internal format- it should only be used for data that will be
returned to the instrument for later use. Data transfers of
the
and LOADCALS example programs.
specifies
The data is transferred as a series of
separated by commas. ASCii formatted data transfers are
demonstrated in the ASCDATA example program.
example program.
16-bit
INTeger,
FORMat :DATA.
16 data type are demonstrated in the INTDATA
the numeric data type
These blocks always transfer as either
detiite
integers. This is the instrument’s
(NRl, NR2
ASCX-encoded
ASCII
or indefinite
or
NR3
syntax).
numbers
characters
-
4-7
Data Types and Encoding
Data Encoding for large Data Transfers
ASCII Encoding
The ANSI
X3.4-1977
standard
dehnes
the ASCII
7-bit
code. When an
ASCII-encoded byte is sent over the HP-IB, bits 0 through 6 of the byte
(bit 0 being the least
through
D107. D108
signihcant
is ignored.
bit) correspond to the HP-IB data lines
DIOl
When ASCII encoding is used for large blocks of data, the number of
significant digits to be returned for each number in the block can be
For example, the following command returns all numbers as
NR3
specitied.
data with 7
significant digits.
FORMat:DATA
ASCii,7
Binary Encoding
When binary encoding is used for large blocks of data, all numbers in the
block are transferred as
an array of
16-bit
the IEEE 754-1985 standard.
FORMat:DATA
FORMat:DATA
FORMat
: DATA
32-bit
or
64-bit
binary floating point numbers or as
integers. The binary floating-point formats are defined in
REAL,32
REAL,64
INTeger ,16
selects the IEEE
ported by
selects the IEEE
selects the
BASIC
16&t
32&t format
or HP BASIC).
64&t
format.
integer format.
(not sup-
4-8
Data Types and Encoding
Byte Swapping
PC compatibles frequently use a modification of the IEEE floating point
formats with the byte order reversed. To reverse the byte order for data
transfer into a PC, the
FORMat :BORDer
command should be used.
FORMat
FORMat
:
BORDer SWAPped
:
BORDer NORMal
selects the byte-swapped format
selects the standard format
4-9
Data Types and Encoding
Using Status Registers
Using Status Registers
The analyzer’s status registers contain information about the condition of the
network analyzer and its measurements. This section describes the registers
and their use in
Example programs using the status registers are included in Chapter 8,
“Example Programs. ’These programs include
use service request interrupt routines, PASSCTRL which uses the status byte
to request control of the
condition register.
HP-lB
programming.
HP-lB
SRQ
and GRAPHICS which
and LIMITEST which uses the Limit Fail
5-2
Bit Weights
:
4
8
16
32
64
128
256
512
1.024
2.048
4,096
8,192
16.384
32,768
General Status Register Model
The analyzer’s status system is based on the general status register model
shown in Figure 5-l. Most of the analyzer’s register sets include all of the
registers shown in the model, although commands are not always available
for reading or writing a particular register. The information flow within a
register set starts at the condition register and ends at the register summary
bit (see Figure 5-2). This flow is controlled by setting bits in the transition
and enable registers.
Two register sets - the Status Byte and the Standard Event Status
Register - are S-bits wide. All others are
signihcant
bit (bit 15) in the larger registers is always set to 0.
Condition registers continuously monitor the instrument’s hardware and
firmware status. Bits in a condition register are not latched or buffered, they
are updated in real time. When the condition monitored by a specific bit
becomes true, the bit is set to 1. When the condition becomes false the bit is
reset to 0. Condition registers are read-only.
Transition Registers
Transition registers control what type of change in a condition register will
set the corresponding bit in the event register. Positive state transitions
(0 to 1) are only reported to the event register if the corresponding positive
transition bit is set to 1. Negative state transitions (1 to 0) are only reported
if the corresponding negative transition bit is set to 1. Setting both transition
bits to 1 causes both positive and negative changes to be reported. Transition
registers are read-write, and are unaffected by
They are reset to instrument default conditions at power up and after *RST
and
SYSTem
:
PRESet
commands.
*CLS
(clear status) or queries.
Event Register
Event registers latch any reported condition changes. When a transition bit
allows a condition change to be reported, the corresponding event bit is set
to 1. Once set, an event bit is no longer affected by condition changes. It
remains set until the event register is cleared. Event registers are read-only.
An event register is cleared when you read it. All event registers are cleared
when you send the
5-4
*CLS
(clear status) command.
Using Status Registers
General Status Register Model
Enable Register
Enable registers control the reporting of events (latched conditions) to the
register summary bit. If an enable bit is set to 1 the corresponding event
is included in the logical
summary bit. (The summary bit is only set to 1 if one or more enabled event
bits are set to 1.) Summary bits are recorded in the instrument’s status byte.
Enable registers are read-write and are cleared by
Positive
Transition
Register
ORing
process that determines the state of the
*CLS
(clear status).
Condition
Register
I-
c
F
Negative
Transitton
Register
Enable
Register
rh
tvent
Register
AND
Note:
The Event Register remains set until it is read
or the
*CLS
command is sent.
Figure 5-2. Flow of information within a register set
5-5
How to Use Registers
There are two methods of accessing the information in status registers:
l
The direct-read method.
l
The service request (SRQ) method
In the direct-read method the analyzer is passive. It only tells the controller
that conditions have changed when the controller asks the right question. In
the SRQ method, the analyzer is more active. It tells the controller when
there has been a condition change without the controller asking. Either
method allows you to monitor one or more conditions.
The following steps are used to monitor a condition with the direct read
method:
1. Determine which register contains the bit that monitors the condition.
2. Send the unique
HP-IS
query that reads that register.
3. Examine the bit to see if the condition has changed.
The direct-read method works well when it is not necessary to know
about changes the moment they occur. It does not work well if immediate
knowledge of the condition change is needed. A program that used this
method to detect a change in a condition would need to continuously read the
registers at very short intervals. The SRQ method is better suited for that
type of need.
5-6
The Service Request Process
The following steps are used to monitor a condition with the SRQ method:
1. Determine which bit monitors the condition.
2. Determine how that bit reports to the request service (RQS) bit of the
Status Byte.
3. Send HP-IB commands to enable the bit that monitors the condition and to
enable the summary bits that report the condition to the RQS bit.
4. Enable the controller to respond to service requests.
When the condition changes, the analyzer sets its RQS bit and the HP-IB’s
SRQ line. The controller is informed of the change as soon as it occurs. The
tune the controller would otherwise have used to monitor the condition can
now be used to perform other tasks. The controller’s response to the SRQ is
determined by the program being run.
Using Status Registers
The Service Request Process
The process of preparing the analyzer to generate a service request, and the
handling of that interrupt when it is received by a program, are demonstrated
in the SRQ example program.
When a register set causes its summary bit in the Status Byte to change from
0 to 1, the analyzer can initiate the service request (SRQ) process. If both the
following conditions are true the process is initiated:
l
The corresponding bit of the Service Request enable register is
also set to 1.
l
The analyzer does not have a service request pending. (A service request is
considered to be pending between the time the analyzer’s SRQ process is
initiated and the time the controller reads the Status Byte register with a
serial poll
.)
The SRQ process sets the
HP-IB’s
SRQ line true and sets the Status Byte’s
request service (RQS) bit to 1. Both actions are necessary to inform the
controller that the analyzer requires service. Setting the SRQ line informs
the controller that some device on the bus requires service. Setting the RQS
bit allows the controller to determine that the analyzer was the device that
initiated the request.
When a program enables a controller to detect and respond to service
requests, it should instruct the controller to perform a serial poll when the
HP-IB’s SRQ line is set true. Each device on the bus returns the contents of
its Status Byte register in response to this poll. The device whose RQS bit is
set to 1 is the device that requested service.
NOTE
When the analyzer’s Status Byte is read with a serial poll, the RCIS bit is reset to 0. Other bits in the
register are not affected.
As implied in Figure 5-3, bit 6 of the Status Byte register serves two
functions; the request service function (RQS) and the master summary status
function (MSS). Two different methods for reading the register allow you to
access the two functions. Reading the register with a serial poll allows you to
access the bit’s RQS function. Reading the register with
*STB
allows you to
access the bit’s MSS function.
5-9
The Analyzer’s Status Register Sets
The analyzer uses eight register sets to keep track of instrument status:
Status Byte
Device Status
Limit Fail
Questionable Status
Standard Event Status
Measuring Status
Averaging Status
Their reporting structure is summarized in Figure 5-4. They are described in
greater detail in the following section.
NOTE
Register bits not explicitly presented in the following sections are not used by the analyzer. A query to
one of these bits returns a value of 0.
5-10
Device Status
Using Status Registers
The Analyzer’s Status Register Sets
Standard Event
Status Register
Measuring
Limit Fall
Questionable Status
Output Queue ,
Figure 5-4. Analyzer Register Sets
I
Status
I
I
B&e
5-11
Bit Weights
Using Status Registers
The Analyzer’s Status Register Sets
Status Byte
The Status Byte register set summarizes the states of the other register sets
and monitors the analyzer’s output queue. It is also responsible for generating
service requests (see “Generating a Service Request” earlier in this chapter).
See Figure 5-5.
serial poll (bit 6 - Request Service)
*SIB?
(bit 6 Master Summary Status)
-
Device Status Summary
Questionable
Request Service/Master Summary Status
OperatIonal
Status Summary
Message Available
Standard Event Summary
Status Summary
r-z
Figure 5-5. The Status Byte Register Set
The Status Byte register set does not conform to the general status register
model described at the beginning of this chapter. It contains only two
registers: the Status Byte register and the Service Request enable register.
The Status Byte register behaves like a condition register for all bits except
bit 6. The Service Request enable register behaves like a standard enable
register except that bit 6 is always set to 0.
5-12
Using Status Registers
The Analyzer’s Status Register Sets
Bits in the Status Byte register are set to 1 under the following conditions:
Device
Questionable
Status
Status
Summary(bit 2) is set to 1 when one or more enabled
Summary
Message Available
StandardEventStatus
Summary
Master Summary Status
Request Service
Operational
Status
Summary
bits in the Device Status event register are
set to 1.
(bit 3) is set to 1 when one or more enabled
bits in the Questionable Status event register
are set to 1.
(bit 4) is set to 1 when the output queue
contains a response message.
(bit 5) is set to 1 when one or more enabled
bits in the Standard Event Status event
register are set to 1.
(bit 6, when read by
*STB)
is set to 1 when
one or more enabled bits in the Status Byte
register are set to 1.
(bit 6, when read by serial poll) is set
to 1 by the service request process (see
“Generating a Service Request” earlier in
this chapter).
(bit 7) is set to 1 when one or more enabled
bits in the Operational Status event register
are set to 1.
5-13
Using Status Registers
The Analyzer’s Status Register Sets
The commands used to read and write the Status Byte registers are listed
below :
SPOLL
*STB?
*SRE <num>
*SRE?
an
IBASIC
(or HP BASIC) command used in the service
request process to determine which device on the bus is
requesting service.
reads the value of the instrument’s status byte. This is a
non-destructive read, the Status Byte is cleared by the *CLS
command.
sets bits in the Service Request Enable register. The current
setting of the Service Request Enable register is stored in
non-volatile memory. If *PSC has been set, it will be saved
at power on.
reads the current state of the Service Request Enable
register.
5-14
Using Status Registers
The Analyzer’s Status Register Sets
Device Status Register Set
The Device Status register set monitors the state of device-specific
parameters.
Bits in the Device Status condition register are set to 1 under the following
conditions:
Key Pressed
Any
Softkey
Pressed
Any
External
Keyboard Key
Pressed
Front
Knob Turned
Panel
(bit 0) is set to 1 when one of the analyzer’s front panel
keys has been pressed.
(bit 1) is set to 1 when one of the analyzer’s
been pressed.
(bit 2)
external keyboard connected to the DIN KEYBOARD
connector on the rear panel of the analyzer.
(bit 3) is set to 1 when the analyzer’s front panel knob is
turned.
is set to 1 when a key has been pressed on an
softkeys
has
5-15
Using Status Registers
The Analyzer’s Status Register Sets
Limit Fail Register Set
The Limit Fail register set monitors limit test results for both measurement
channels.
Bits in the Limit Fail condition register are set to 1 under the following
conditions (refer also to Figure 5-6.)
Measurement
Channel 1
Limit Failed
Measurement
Channel 2
Limit Failed
Measurement
Channel 1
Marker Limit
Failed
Measurement
Channel 2
Marker Limit
Failed
(bit 0) is set to 1 when limit testing is enabled and any point
on measurement channel 1 fails the limit test, or when any
enabled marker limit on measurement channel 1 has failed.
(bit 1) is set to 1 when limit testing is enabled and any point
on measurement channel 2 fails the limit test, or when any
enabled marker limit on measurement channel 2 has failed.
(bit 2) is set to 1 when any enabled marker limit on
measurement channel 1 has failed.
(bit 3) is set to 1 when any enabled marker limit on
measurement channel 2 has failed.
5-16
Using Status Registers
The Analyzer’s Status Register Sets
5-18
Using Status Registers
The Analyzer’s Status Register Sets
Questionable Status Register Set
The Questionable Status register set monitors conditions that affect the
quality of measurement data.
Bits in the Questionable Status condition register are set to 1 under the
following conditions:
Limit Fail
Data
Questionable
(bit 9) is set to 1 when one or more enabled bits in the Limit
Fail event register are set to 1.
(bit 10) is set to 1 when a change in the analyzer’s
configuration requires that new measurement data be taken.
5-19
Bit Wetghts
Using Status Registers
The Analyzer’s Status Register Sets
Standard Event Status Register Set
The Standard Event Status register set monitors HP-B errors and
synchronization conditions. See Figure 5-7.
Operation Complete
Request Control
Dewce
Query Error
Dependent Error
Execution
Error
Command Error
User Request
Power On
>+
Status
Bit
5
Byte
Figure 5-7. The Standard Event Status Register Set
The Standard Event Status register set does not conform to the general status
register model described at the beginning of this section. It contains only two
registers: the Standard Event Status event register and the Standard Event
Status enable register. The Standard Event Status event register is similar
to other event registers, but behaves like a register set that has a positive
transition register with all bits set to 1. The Standard Event Status enable
register is the same as other enable registers.
Operation
Complete
(bit 0) is set to one when the following two events occur
(in the order listed):
l
The *OPC command is sent to the analyzer.
l
The analyzer completes all pending overlapped
commands.
5-20
Using Status Registers
The Analyzer’s Status Register Sets
Request Control
(bit 1) .
1s
set to 1 when both of the following conditions
are true:
l
The analyzer is configured as a talker/listener for
HP-B
operation.
l
The analyzer is instructed to do something (such as
plotting or printing) that requires it to take control of
the bus.
Query Error
(bit 2) is set when the command parser detects a query
error. A query error indicates:
1. an attempt to read data from the Output Queue when
no data was present.
2. that data in the Output Queue was lost. An example
of this would be queue overflow.
Device Dependent (bit 3) is set to 1 when the command parser detects a
Error
device-dependent error. A device-dependent error is any
analyzer operation that did not execute properly due
to some internal condition such as over-range. This bit
indicates that the error was not a command, query, or an
execution error.
Execution Error
(bit 4) is set to 1
when the command parser detects an
execution error. Execution errors occur when:
Command Error
1. a <PROGRAM DATA> element received in a command
was outside the legal range for the analyzer, or
inconsistent with the operation of the analyzer.
2. the analyzer could not execute a valid command due
to some analyzer condition.
(bit 5) is set to 1 when the command parser detects a
command error. The following events cause a command
error:
1. An IEEE 488.2 syntax error. This means that the
analyzer received a message that did not follow the
syntax defined by the 488.2 standard.
2. A semantic error occurred. For example, the analyzer
received an incorrectly spelled command. Another
5-21
Using Status Registers
The Analyzer’s Status Register Sets
example would be that the analyzer received an
optional 488.2 command that it does not implement.
Power On(bit 7) is set to 1 when you turn on the analyzer.
The commands used to read and write the Standard Event Status registers are
listed below:
*ESR?
*ESE
<mm>
*ESE?
reads the value of the standard event status register.
sets bits in the standard event status enable register. The
current setting of the standard event statue enable register
is stored in non-volatile memory. If *PSC has been set, it
will be saved at power on.
reads the current state of the standard event status enable
register.
5-22
Using Status Registers
The Analyzer’s Status Register Sets
Measuring Status Register Set
The Measuring Status register set monitors conditions in the analyzer’s
measurement process.
Bits in the Measuring Status condition register are set to 1 under the
following conditions:
Channel 1 Measuring
Channel 2 Measuring
(bit 0) is set to 1 while the analyzer is collecting
measurement data on channel 1.
(bit 1) is set to 1 while the analyzer is collecting
measurement data on channel 2.
Averaging Status Register Set
The Averaging Status register set monitors conditions in the analyzer’s
measurement process when the trace averaging function is in use.
Bits in the Averaging Status condition register are set to 1 under the following
conditions :
Measurement Channel
1 Averaging
Measurement Channel
2 Averaging
(bit 0) is set to 1 while the analyzer is sweeping on
measurement channel 1 and the number of sweeps
completed (since “average restart”) is less than the
averaging factor.
(bit 1) is set to 1 while the analyzer is sweeping on
measurement channel 2 and the number of sweeps
completed (since “average restart”) is less than the
averaging factor.
5-23
Using Status Registers
The Analyzer’s Status Register Sets
Operational Status Register Set
The Operation Status register set monitors conditions in the analyzer’s
measurement process, disk operations, and printing/plotting operations. It
also
monitors the state of the current HP Instrument BASIC program.
Bits in the Operational Status condition register are set to 1 under the
following conditions:
Calibrating(bit 0) is set to 1 while the instrument is zeroing the
broadband diode detectors.
Settling
Measuring
Correcting
Averaging
Hardcopy
Running
Test Running
Program Running
(bit 1) is set to 1 while the measurement hardware is
settling.
(bit 4) is set to 1 when one or more enabled bits in the
Measuring Status event register are set to 1.
(bit 7) is set to 1 while the analyzer is performing a
calibration function.
(bit 8) is set to 1 when one or more enabled bits in the
Averaging Status event register are set to 1.
(bit 9) is set to 1 while the analyzer is performing a
hardcopy (print or plot) function.
(bit 10) is set to 1 when one of the analyzer’s internal
service tests is being run.
(bit 14) is set to 1 while an HP Instrument BASIC
program is running on the analyzer’s internal controller.
5-24
STATus:PRESet Settings
Using Status Registers
The Analyzer’s Status Register Sets
Executing the STATUS :
(ENAB), positive transition (PTR) and negative transition (NTR) registers. The
table below shows the settings after the command is executed.
This chapter explains how to read (query) the measurement data trace from
the analyzer into your program. It also describes how to send data from your
program to the analyzer’s measurement arrays. Accessing the measurement
arrays is done using SCPI commands. If you are using
you can also access the measurement arrays using high-speed subroutines.
Refer to the
HP Instrument BASIC User’s Handbook
Figure 6-l is a data processing flow diagram that represents the flow of
numerical data. The data passes through several math operations, denoted in
the figure by single-line boxes. Most of these operations can be selected and
controlled with the front panel CONFIGURE block menus.
in arrays along
places in
the
the
way, denoted by double-line boxes. These
flow
pathwheredata is
accessible
single flow path is shown, two identical paths are available, corresponding to
measurement channels 1 and 2.
IBASIC
(Option
for more details.
The data is stored
via
HP-IB. While only a
lC2),
arraysare
Raw Data
A,B,R...
1-I
Ratio
6-2
Figure
Averaqlng
i
Error
Coefficient
Arrays
1
6-l.
Numeric Data Flow Through the Network Analyzer
Data Trace
Memory Trace
cs650
Querying the Measurement Trace Using BASIC
After making a measurement, you can read the resultant measurement trace
out of the analyzer using the SCPI query
“TRACE : DATA?CHIFDATA”
The BASIC program segment below shows how to read the trace from the
analyzer into an array in your program.
10
REAL
Trace(l:201)
ASSIGN
20
30
40
50
60
70
! Take sweep here
OUTPUT
OUTPUT
ENTER
DISP Trace(l)
QHp8711
QHp871l;“FORM:DATA ASCII,5”
@Hp871l;“TRACE:DATA? CHlFDATA”
OHp87ll;Trace(*)
TO 716
,Trace(2) ,Trace(3)
,‘I. . .
.I’
In this program, the TRACE:DATA? query returns
points as a single block. The analyzer computes the
using the measurement format selected by the [FORMAT] menu (CALC:FORM
SCPI command), and returns a block of data
The values of each point correspond to the values displayed on the screen, or
those shown in the marker readouts. The frequency stimulus value (X-axis) of
each point is not returned by the TRACE:DATA? query; only the measurement
response (Y-axis) values are returned.
When transferring the block of trace data, you may select either binary or
ASCII data encoding. This is explained in Chapter 4 in the section titled
“Data Encoding for Large Data Transfers.” Notice that the terms “encoding
format” and “measurement format” are not the same. The encoding
format determines how the numbers are represented as bytes, while the
measurement format corresponds to the meaning of the
The easiest way to transfer a measurement data trace is to use ASCII data
encoding.
In the example above, the array Trace(l:201) contains 201
numbers. The SCPI command
encoding, with 5 significant digits. The command “TRACE : DATA?
instructs the analyzer to send the measurement trace. The ENTER statement
reads the measurement data sent by the analyzer into the
“FORM:DATA
ASCII
all
of the measurement
value
for each point
called
the formatted data array.
value
of the numbers.
real
(floating point)
,5”
specifies ASCII data
Trace(l:201)
CHIFDATA”
array.
6-3
Trace Data Transfers
Querying the Measurement Trace Using BASIC
It is important to make sure that the Trace array declared in your program
is the same size as the measurement trace on the analyzer, or an error will
occur. The ENTER statement attempts to read data from the analyzer until
it completely
fills
the Trace array, at which point it expects to receive a
end-of-data terminator from the analyzer. To be safe, your program should
use the
“SENS
: SWE
:POIN”
SCPI command to set the number of measurement
data points to the desired value.
Refer to the example program ASCDATA in Chapter 8 for a complete
example.
@Smith Chart and Polar Formats
Each measurement point is represented by a single floating point number.
This is the case for all of the analyzer’s measurement formats except Smith
Chart and Polar in the HP
format is selected, each point is represented by two numbers, the first one
being the real portion and the second being the imaginary portion of the
complex measurement value.
8712C
and
8714C.
When Smith Chart or Polar
10
20
30
40
50
60
70
Below is a modified example program that will work when using Smith Chart
or Polar formats.
Abort current sweep and put analyzer sweep in hold
iprintf(analyzer,
iprintf(analyzer,
/*
Take one sweep,
iprintf(analyzer,
iprintf(analyzer,
= iopen("hpib,l6");
sizeof(data-buf);
*/
"ABORT\n");
“INIT
: CONT
wait until done
"INITl\n");
"*OPC?\n");
OFF\n”)
Set to max allowable bytes
*/
*/
;
*/
*/
6-5
Trace Data Transfers
Querying the Measurement Trace Using
iscanf(analyzer, "(/l*s");
/*
Request the trace data in
iprintfcanalyzer,
iprintfcanalyzer,
"FORM:BORD NORM\n");
"FORM:DATA REAL,32\n");
32-bit
SIC1
floating point format
*/
/*
Query the trace,
iprintfcanalyzer,
read into data-buf
"TRAC? CHlFDATA\n");
iscanf(analyzer, "%#bX*c", &mm-trace-bytes,
/*
Print the trace values.
for (pt
printf("X4d
= 0; pt <
mm-trace-bytes/sizeof(float);
%g\n" ,
*/
pt,
data-buf[ptl);
1
/*
Close analyzer and exit.
*/
iclose(analyzer);
return 0;
1
Cl.
*/
&data-buf
pt++) (
COl>;
6-6
Using Binary Data Encoding
The previous section describes how to query the measurement trace, and
transfer it into your program using
used for faster data transfers, as shown in the table below:
Table
6-l.
Typical Trace Transfer Times (ms)
When using binary data transfers, the entire trace is sent from the analyzer
to your program in a block called a definite length block. The details of block
data are described in detail in Chapter 4. The
header and a data section. The header indicates how many bytes are in the
data section.
ASCII
encoding. Binary encoding can be
Points
Binary
21
23
30
62
i
delinite
length block contains a
ln
order to read the
delinite
length block, your program must first read
the header, and then read the data section. Refer to the example program
REALDATA
In the
in Chapter 8 for an example of how to do this.
REALDATA
program, you will notice the following lines which read the
definite block header:
180
190
ENTER
ENTER
QHp8711
QHp8711
USING
USING
“%,A,D”;A$,Digits
“%,“&VAL$(Digits)&“D” ;Bytes
and these lines which read the data section:
200
210
ASSIGN
ENTER
OHp87ll;Datal(*)
QHp8711;FORMAT
OFF
6-7
Trace Data Transfers
Using Binary Data Encoding
Each measurement point in the data section is represented as 4 or 8 bytes
(32 or 64 bits), depending on whether single precision or double precision
numbers are requested. When using HP BASIC or
IBASIC,
you must select
double precision numbers to match BASIC’s “REAL” data type. Do this
using the SCPI command “FORM : DATA REAL,
64”.
If you are using another
language that supports single precision data types, you can select single
precision using the SCPI command “FORM : DATA REAL,
as
QuickBASIC
and C have support for both single and double precision
32”.
Languages such
floating point numbers.
When transferring data using binary encoding, you may need to reverse
the order of the bytes in each measurement point, since PCs frequently
store IEEE floating point numbers with the byte order reversed. To instruct
the analyzer to reverse the byte order of the data, send the command
“FORMAT:BORDer SWAPped”
before querying the trace data.
6-8
Trace Data Transfers
Using Binary Data Encoding
Trace Data Transfer Sizes
The following table shows how many bytes are transmitted during trace
data transfers. The left column shows the format of the data, which you can
specify using the SCPI command Format : DATA. As you can see, the size of
the measurement point data and trace data varies as you change format.
Table 6-2. Size of Trace Data Transfers (in Bytes) Using the
Format Type
(FORMat:DATA)
REAL.32
REAL,64
ASCII,5
ASCII,3
INT,16
When transmitting data in “REAL” or “INT” format, a header is sent before
the data block. The header indicates the size of the data block. The header
size varies in length from 3 to 11 bytes. Refer to Chapter 4 for details on the
header.
Transmitting ASCII data requires no header. The ASCII values are separated
by commas, and a
table include the size of the comma(s) and terminating linefeed. Typical data
in
ASCII,5
Type of Data
IEEE
32-bit
Floating Point
IEEE
64-bit
Floating Point
ASCII numbers
ASCII numbers
Internal Binary
format:
Single Measurement Point
I
Real
4
8
13
11
linefeed
is sent after the last value. The sizes shown in the
Complex
TRACESIATA SCPI
201 Point Trace
1614
2613
2211
-
Command
I
-1.2254E+000,+5.0035E-001,+4.5226E-OOl,...
The analyzer stores its internal data with approximately 5
of resolution. Using
for data transfers. However,
REAL,32
or
ASCII,5
REAL,64
format provides sufficient precision
may be necessary when using a
programming language which does not support IEEE
signitlcant
32-bit
floating point.
digits
6-9
Transferring Data with
IBASIC
If you are using BASIC, your
BASIC
program can avoid the overhead of
using OUTPUT and ENTER to transfer trace data, and instead use the
analyzer’s built-in high-speed subprograms. These built-in subroutines let
you quickly move data between the analyzer’s measurement arrays and your
program’s data arrays. For example, to read the
array, use the
10 DIM
20 INTEGER
30
LOADSUH
40
50
Read-fdata(Chan,Fmt(*))
Refer to the
The table below compares the speed of
foIIowing:
Fmt(l:201)
Ghan
Read-f data FROM
“XFER:
Chan=l
HP Instrument BASIC User’s Handbook
IBASIC
anaIyzer’s
formatted data
MEM 0,O”
for more details.
using high-speed transfer
subroutines with that of a fast external controller using the SCPI
TRACE:DATA?
1
Number of Points
CHlFDATAquery.
Table 6-3. Typical Trace Transfer Times (msl
Controller Using Binary
5151
201201
401401
TRACE : DATA?
212177
2323IOIO
30301313
1 IBASIC
Using
Read-f data
6-10
16011601
82823232
T&king
When making measurements and querying traces, your program should
perform the following steps:
1. Place the analyzer’s sweep in hold
2. Initiate a single sweep
3. Wait for the sweep to complete
4. Query the measurement trace
Use the following program lines perform these steps:
Sweeps
10 OUTPUT
20 OUTPUT
30 OUTPUT
35 ENTER
40 OUTPUT
45 ENTER QHp8711;Fmt(*)
If you query the measurement trace while the analyzer is in continuous
sweep, the query will still work, but the data may not be correct. Using
and *OPC? ensures that a complete sweep has finished before you query the
measurement data. In many cases, you can also use the command
place of the
30 OUTPUT
However, there are cases where
case is when using
“*WAI”
executed until the commands before the
subprograms don’t use SCPI commands to access the trace data,
ineffective, and
When using
until the previous SCPI commands are complete, preventing your program
from executing beyond the ENTER statement. When using
program can continue to run and send SCPI commands, and the analyzer
The preceding sections describe how to query the formatted data array using
the TRACE:DATA? query with the argument
is the last array in the analyzer’s data processing chain, and is generally of
most interest.
The analyzer also allows you to query other measurement arrays which
are earlier in its data processing chain. Figure 6-2, below, shows the data
processing chain.
CHlFDATA.
The formatted array
Raw Data
A.B.R...Correction
1-d
Ratio
1
Figure
6.2.
Numeric Data Flow Through the Network Analyzer
The first array is the Raw Data Array, which contains each of the separate
input components (A, B, R,
measured. These arrays can be queried and set, but doing so is of limited
use, since the data values contained in the arrays are uncorrected, and are
not directly correlated to any meaningful reference, such as 0
Error
t
Error
Coefficient
Arrays
Format
Markers
-
Limit Testing
B*,
R*, X, Y, AUX) immediately after they are
Offs.4
SCCll.5
DotaTrace
Memory Trace
dBm.
6-14
Trace Data Transfers
Accessing Other Measurement Arrays
The Error Coefficient Arrays contain default correction values or values
created during a measurement calibration. These arrays can be queried
and set, but care should be exercised in setting them since incorrect
measurements may result. If you wish to apply your own corrections in
addition to the analyzer’s current correction, the best technique is to use the
Corrected Memory array and the Data/Memory feature, explained below.
The Corrected Data array contains the results of the currently selected
measurement (Transmission, Reflection, etc.) after error correction and
averaging have been applied. The measurement data in these arrays is
represented as complex number pairs. When measuring the transmission
response of a through cable, the magnitude of the complex numbers will be
very close to 1 .O. When measuring an open circuit, the magnitude of the
complex numbers will be very close to 0.0. When measuring an
amplilier,
the
magnitude of the complex numbers will be greater than 1.0.
The Corrected Memory array is filled with a copy of the Corrected Data array
when the Data --> Memory operation is performed. It can be used to apply
a gain correction to the measured data. This is described in the following
section.
The Formatted Data array contains the measurement data after it has been
formatted using the format selected by the [FORMAT] menu. Querying the
Formatted Data array is described in detail at the beginning of this chapter.
You can also download data to this array, and the analyzer will display the
data using the current Scale and Reference values.
6-15
Applying Gain Correction Using the
Memory Trace
The Corrected Memory array is Elled with a copy of the Corrected Data array
when the Data --> Memory operation is performed. By setting the analyzer
to perform Data/Memory trace math, you can apply your own correction
factor to the measurement data trace by filling the Corrected Memory array
with the appropriate complex numbers.
In general, you should use the analyzer’s calibration feature to correct for
errors in your system. However, there may be cases where you wish to
simulate the effect of adding a cable in series with your DUT, and observe
how this imaginary cable will attenuate the measured response versus
frequency. Or you may wish to apply an absolute offset to simulate the effect
of adding or removing a pad from the measurement. These simulations are
easily accomplished using the Corrected Memory array and the Data/Memory
feature.
The Corrected Data and Memory arrays contain complex linear data, as
opposed to logged data. When displaying the traces using Lin Mag format,
the result of the Data divided by Memory operation
to divide each point of the data trace by each point of the memory trace.
When displaying data in Log Mag format, the result of Data/Memory will be
equivalent to subtracting the Log Mag
the Data trace.
value
of the Memory trace from that of
(Data/Mem)
will be
6-16
Trace Data Transfers
Applying Gain Correction Using the
Memory Trace
The following example BASIC code segment shows how to download a
complex array from your program to the analyzer’s Memory trace. The
program’s “Mem” array is initialized with the proper values such that when
the analyzer computes Data divided by Memory, the desired increasing gain
will be applied.
100
110
120
130
140
150
160
170
180
190
200
210
220
230
240
250
260
270
280
290
300
310
320
REAL
Mem(l:201,1:2)
ASSIGN
! Fill memory array (denominator in
QHp8711
TO 716
Data/Mem)
! with values that will result in an
! upward sloping gain factor vs. frequency.
! Used to compensate for cable loss vs. frequency
! Adds 0 dB of gain at start freq; 3
The example above downloads data to the corrected memory array. The data
is sent by the program to the analyzer using ASCII encoding. The data is
sent as ASCII characters, separated by commas. The analyzer accepts the
comma separated list of numbers until it receives a
linefeed
to terminate
the command. The program uses semicolons at the end of some OUTPUT
statements to avoid sending a
linefeed
until all of the data has been sent.
After the last number is sent, the program sends a linefeed, and the analyzer
accepts the data.
Remember, for faster transfers, use binary data encoding instead of ASCII.
6-17
Performing Your Own Data Processing
After the analyzer has made a measurement, you can read the measurement
trace and perform your own post-processing on it, and display the result on
the screen. This is done using these steps:
1. Initiate a sweep
2. Wait for the sweep to
3. Read the measurement data into an array in your program
4. Perform your post-processing on the measurement data
5. Write (download) the post-processed data to the analyzer’s memory trace.
You may want to instruct the analyzer to display only the memory trace and
not the data trace, so that only your post-processed data is seen.
Crush
6-18
Trace Data Transfers
Performing Your Own Data Processing
The program below demonstrates how to perform data post-processing. It
takes the measurement data and reverses it, such that the low frequency
data is displayed on the right end of the trace, and the high frequency data is
displayed on the left.
100
110
120
130
140
150
160
170
180
190
200
210
220
230
235
240
250
260
270
280
290
! Display the measurement data backwards
REAL
Fmt(l:201)
ASSIGN
OHp8711
TO 716
I
OUTPUT
OUTPUT
OUTPUT
QHp871l;"FORM:DATA
QHp87ll;"ABOR;INIT:CONT
OHp87ll;"DISP:WIND:TRACl
ASCII"
OFF;*WAI"
OFF;TRAC2
ON"
LOOP
! Take sweep
OUTPUT
QHp8711;"INITl;*WAI"
! Read the trace from the formatted data array
OUTPUT
ENTER
OHp871l;"TRACE:DATA?
QHp8711;Fmt(*)
CHlFDATA"
! Download the trace, backwards,
! to the formatted memory array
OUTPUT
QHp87ll;"TRACE:DATA CHIFMEM";
! Note the
FOR Pt=l TO 201
OUTPUT
OHp87ll;",";Fmt(202-Pt);
! Note the
NEXT Pt
OUTPUT
(QHp8711;""
! Send
linefeed
END LOOP
";'I
'I;"
This example program uses ASCII trace data transfers. Higher speed can be
achieved using binary data transfers. If using
can be used for even greater performance. Refer to the
BASIC,
high-speed subroutines
IBASIC
Handbook for
details.
6-19
Downloading Trace Data Using
Binary Encoding
Data traces can be downloaded to the analyzer using binary encoding.
Using binary encoding is faster than using ASCII encoding. As mentioned
in Chapter 4, the binary encoded trace is transferred as a block; the block
containing a header and a data section. There are two different types of
blocks that can be used: a definite length block, and an indefinite length
block.
To send trace data using a definite length block, your program must calculate
the number of bytes in the data segment of the block, and create a block
header which tells the analyzer how many bytes are in the data segment.
For example, if you are sending a trace with 201 data points and using
floating point numbers for each data point (“FORM:DATA
block’s data segment will contain 1608 bytes (201 points * 8 bytes/point).
The header characters for a 1608 byte block are:
after the
In this case, 4 digits follow, and those digits are “
block contains 1608 bytes.
For example :
When you send a definite length block to the analyzer, the analyzer will will
read the data segment bytes, stopping when it receives the number specified
in the block header.
To send trace data using an indefinite length block, your program simply
sends a block header of
the data segment, your program must terminate the data block by sending an
EOI. The analyzer
an EOI. To send an EOI using BASIC, you can use the statement:
“#“,
“4” tells how many following digits are used to specify the size.
TRAC
CHlFDATA,#41608<binary_data_starts_here>
“#O”,
followed by the data segment. After sending
will
read the data segment bytes, stopping when it receives
OUTPUT
QHp871l;END
“#41608”.
1608”,
REAL,64”),
The
meaning that the
lirst
64-bit
the
digit
6-20
Internal Measurement Arrays
The following sections describe the sequence of math operations and the
resulting data arrays as the measurement information flows from the raw
data arrays to the display. This information explains the measurement arrays
accessible via
Figure 6-3 is a data processing flow diagram that represents the flow of
numerical data. The data passes through several math operations, denoted in
the figure by single-line boxes. Most of these operations can be selected and
controlled with the front panel CONFIGURE block menus. The data is stored
in arrays along the way, denoted by double-line boxes. These arrays are
places in the flow path where data is accessible via HP-IB. While only a
single flow path is shown, two identical paths are available, corresponding to
measurement channels 1 and 2.
HP-B
Averaging
Format
Limit Testing
Figure 6-3. Numeric Data Flow Through the Network Analyzer
Offset
Scale
DataTrace
Memory
Trace
6-21
Trace Data Transfers
Internal Measurement Arrays
Raw Data Arrays
These arrays are linear measurements of the inputs used in the selected
measurement. Note that these numbers are complex pairs. These arrays are
directly accessible via
and CH Cl I23 RFWD.
HP-E3
and referenced as CH Cl
Table 6-4. Raw Data Arrays
I21
AFWD, CH Cl
I21
BFWD
Selected Measurement
Transmission IB/RJ
Reflection
A
B
lA.Ffl
R
Power 18”)
Conversion
R”
AM Delay (Y/XI
X
Y
Y/R”
Y/X,
1
loss IB”/R*l
XN
NOTE
Raw data far AUX INPUT is not available via HP-IB. Use the corrected data array to access AUX
INPUT data.
B -
CH[l
21BFWD,
A =
CH[l
21AFWD.
A -
CH[l
21AFWD
B -
CH[l
21BFWD
R-
CH[l
21RFWD
B’
=
CH[:
lZ]BFWD
= CH[I12]BFWD,
B”
R”
- CH[li21RFWD
Y -
CH[ltZ]BFWD,X- CHCll21RFWD
X =
CHC1121RFWD
Y -
CH[ltZ]BFWD
Y -
CH[1121BFWD,
Y =
CH[1121BFWD,X =
Raw Arrays
RR
R”
R”
I21RFWD
-
CHCl
121RFWD
-
CH[l
= CH[llZ]RFWD
- CHCll21RFWD
CHkl21RFWD
I
6-22
Ratio Calculations
Trace Data Transfers
Internal Measurement Arrays
These are performed if the selected measurement is a ratio (e.g. A/R or
This is simply a complex divide operation. If the selected measurement is
absolute (e.g. A or B), no operation is performed.
B/R).
Error Correction
Error correction is performed next if correction is turned on. Error correction
removes repeatable systematic errors (stored in the error coefficient arrays)
from the raw arrays. The operations performed depend on the selected
measurement type.
Error Coefficient Arrays
The error coefficient arrays are either default values or are created during
a measurement calibration. These are used whenever correction is on.
They contain complex number pairs, and are accessible via HP-IB and are
referenced as CH [l
CHClt21SCORR4.
I21 SCORRl,
CH [l
I21 SCORR2,
CH Cl
I21 SCORR3
and
6-23
Trace Data Transfers
Internal Measurement Arrays
Table 6-5. Error Coefficient Arrays
Selected Measurement
Transmission fB/R) Response
Transmission
[B/RI
Response & Isolation
CH [I f 21
CH[ll2]SCORRI
CH [l
Transmission (B/RI Enhanced Response
CH [l
CH [l
CH
CH
Reflection
[AIR]
CH
CH
CH[l
Broadband Internal
NOTE
These arrays do not apply to Broadband External measurements.
CH[ll2]SCORRl
Error Coefficient Arrays
SCORRI
f 21
SCORRZ
I21SCORRl
f 21
SCORR2
[I
I 21
SCORR3
[I
I 21
SCORR4
[I
I 21
SCORRI
[I 121
SCORR2
I21
SCORR3
=
Tracking
-
Tracking
-
Isolation Term
-
Directivity
=
Source Match
-
Reflection Tracking
-
Transmission Tracking
=
Diractivity
-
Source Match
-
Tracking
-
A” Response
6-24
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.