Keysight (Agilent) 8712ET User’s Handbook Supplement

HP Instrument BASIC User’s Handbook
Supplement
HP 8712ET/ES and HP 8714ET/ES
RF Network Analyzers
HP Part No. 08714-90019
Printed in USA
Print Date: October 1998
© Copyright 1998 Hewlett-Packard Company
Notice
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.
Firmware Revision
This manual documents analyzers with firmware revisions E.06.00 and above.
Contents
1. Introduction
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Overview of HP Instrument BASIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
Using HP Instrument BASIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
Allocating Internal Memory for IBASIC Use. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5
Typographical Conventions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
2. Recording Programs
Keystroke Recording . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
What Is Keystroke Recording?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
IBASIC Programs and the Input Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
What's in a Recorded Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
The OUTPUT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
The ASSIGN Statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
SCPI Mnemonics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7
How Recording Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-8
Operations that Do Not Record. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
Front Panel Operations without Mnemonics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
HP Instrument BASIC Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
Operations Requiring Additional Programming. . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
Mnemonics with No Corresponding Front Panel Operation . . . . . . . . . . . . . . . . . . 2-12
Avoiding Recording Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13
Use Instrument Preset. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13
Specifically Select Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13
Use HP-IB Echo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-14
3. Running, Pausing, and Stopping Programs
Starting Programs Automatically. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
Running and Continuing a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
Pausing and Continuing a Program. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
Using LOCAL LOCKOUT 8 to Disable the Pause Key . . . . . . . . . . . . . . . . . . . . . . . 3-7
Stopping a Program. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8
i
Contents
4. Saving and Recalling Programs
Selecting a Disk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-3
Saving a Program. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-4
AUTOST Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-6
Recalling a Program. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-7
CAT to a String Array Exception. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-8
5. Developing Programs
External Editors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-3
HP BASIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-3
ASCII Word Processors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-4
Programming Editors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-4
Editing Your Program Using Edit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-5
The IBASIC Editor Softkeys. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-6
Recording into an Existing Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-7
Editing with an External Keyboard. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-8
Entering Program Lines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-11
Editing from the Front Panel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-12
Removing Program Text. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-14
Renumbering, Copying, Moving, and Indenting Lines . . . . . . . . . . . . . . . . . . . . . . .5-16
Using IBASIC Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-17
Using UTILITIES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-20
6. Debugging Programs
Setting Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-3
Examining Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-4
Examining Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-5
Examining Arrays. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-5
Displaying the Last Error Encountered . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-6
7. Graphics and Display Techniques
Display Partitions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-2
Using the Display Partitions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-3
Allocating Display Partitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-4
De-Allocating Display Partitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-5
Operation with No Display Partition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-5
ii
Contents
Displaying Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7
Getting Text to the Screen Quickly. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9
Pop-Up Message Windows and Custom Annotations. . . . . . . . . . . . . . . . . . . . . . . . . 7-9
Graphics Initialization and Scaling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10
Using Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11
Drawing Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-12
Graphics Exceptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-14
Labeling with Different Partitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-14
SCPI Graphics Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-15
For More Information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-17
8. Interfacing with External Devices
Communication with Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3
HP-IB Device Selectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3
Moving Data through the HP-IB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4
General Structure of the HP-IB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-5
Using the Serial and Parallel Ports. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-6
Using the Analyzer Ports in IBASIC Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-6
General Bus Management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-9
REMOTE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-10
LOCAL LOCKOUT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-10
LOCAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-11
TRIGGER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-11
CLEAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-12
ABORT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-12
HP-IB Service Requests. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-13
Passing and Regaining Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-17
The IBASIC HP-IB Model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-18
The External Bus and the Internal Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-18
Service Request Indicators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-18
IBASIC as the Active Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-19
Passing Active Control to the Instrument. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-20
IBASIC as a Non-Active Controller. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-21
Interfacing with an External Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-22
Synchronizing IBASIC with an External Controller . . . . . . . . . . . . . . . . . . . . . . . . 8-23
Transferring Data between Programs Using OUTPUT and ENTER Statements . 8-25
iii
Contents
Transferring Programs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-27
IBASIC Communication across the LAN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-29
9. Using Subprograms
User-Created Subprograms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-2
Built-In High-Speed Subprograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-3
Avoiding Multiple Loads of Subprograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-9
10. IBASIC Keyword Summary
Keywords in Alphabetic Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-3
Keywords in Category Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-14
iv

1 Introduction

1-1

Introduction

Introduction
Introduction
This manual describes how to create and use HP Instrument BASIC (IBASIC) software in the analyzer. It demonstrates how to use IBASIC's programming, editing and debugging features. It also describes how to save and recall programs and how certain instrument-specific IBASIC features are implemented in the analyzer. The reader should be familiar with the operation of the analyzer and BASIC before programming the analyzer.Related information can be found in the following references that were shipped with your analyzer:
• The Programmer’s Guide, a companion to this book, provides general-purpose programming information. The Programmer’s Guide describes all valid instrument commands.
• The User’s Guide provides information on making measurements with the analyzer.
• The HP Instrument BASIC User’s Handbook provides information on HP Instrument BASIC (IBASIC) .
• The Example Programs Disk — DOS format: part number 08714-10003, is included with the analyzer. This disk provides copies of all of the example programs in the Example Programs Guide.
• Additional information on HP BASIC programming is available in the manual set for the BASIC revision being used. For example: BASIC
7.0 Programming Techniques and BASIC 7.0 Language Reference.
Other information that may be helpful can be found in the following reference materials:
• The Tutorial Description of the Hewlett-Packard Interface Bus (HP literature no. 5021-1927) provides information on using the HP-IB.
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.

Overview of HP Instrument BASIC

HP-IB
Overview of HP Instrument BASIC
HP Instrument BASIC (IBASIC) can be used for a wide range of applications, from simple recording and playback of measurement sequences to remote control of other instruments. IBASIC is a complete language with over 200 keywords.
IBASIC is a complete system controller residing inside your analyzer. It communicates with the analyzer via HP-IB commands over an internal interface bus (select code 8). It can also communicate with other instruments, computers, and peripherals using the external HP-IB interface (select code 7) or the serial (select code 9) or parallel (select code
15) I/O ports.
NOTE The analyzer can also be controlled by an external controller.
It has a factory default external HP-IB address of 16. When using IBASIC to control other instruments, no other device should use the same address.The external HP-IB address can be changed using either the front panel keys under the , menu, or the SCPI mnemonic SYST:COMM:GPIB:ADDR.
SYSTEM OPTIONS
Introduction
HP IBASIC Supplement 1-3
Introduction

Using HP Instrument BASIC

Using HP Instrument BASIC
Y ou need not be proficient in a programming language to successfully use IBASIC. In keystroke recording mode, IBASIC automatically builds an executable program by capturing measurement sequences as they are performed. With little or no editing of these program lines, you can immediately put your program to work to control and automate your analyzer.
The IBASIC language is a subset of the HP BASIC language. In fact, IBASIC programs can be run on any HP BASIC workstation with very few changes. When an external PC keyboard (with a DIN connector) is connected to the analyzer, the IBASIC user interface emulates the user interface of the HP BASIC. The PC keyboard can be used for command entry, editing and program inputs.
You can use IBASIC to do the following:
• create on screen graphics
• control other instruments and peripherals
• create interactive prompts
• simplify keystrokes with the key
• create programs by recording keystrokes
• run applications
IBASIC also works in conjunction with an external controller which can download and run programs, query variables and respond to service requests (SRQs).
BEGIN

Allocating Internal Memory for IBASIC Use

Select Disk
Configure VOL_RAM
Modify Size
Modify Size
Allocating Internal Memory for IBASIC Use
Your analyzer contains a volatile RAM disk that is configured for use with IBASIC. The default condition set at the factory allocates most of this disk's memory for IBASIC use. To see what the current allocations are for this disk, press
display that shows total memory available, and how the memory is currently allocated.
To change the allocations, use the softkey. The number you enter with the softkey, is the percentage of memory that will be used for normal disk functions (such as storing instrument states). The remainder will be allocated for use with IBASIC.
NOTE Cycle power after changing the allocations.
You must cycle the power on the analyzer for new allocations to take effect.
SAVE RECALL
. A message will appear on the analyzer's
Introduction
HP IBASIC Supplement 1-5
Introduction
Softkey
Softkey ON off
Softkey 1
Softkey 2

Typographical Conventions

Typographical Conventions
The following conventions are used in this manual when referring to various parts of the HP Instrument BASIC and analyzer operation environments:
HARDKEY
HARDKEY
<element> Angle brackets are used to signify a syntax element in a statement. computer font User input and computer output is shown with a mono-spaced font.
The name of a hardkey on the front panel of the analyzer. This notation is also used to represent keys on an external keyboard connected to the analyzer's DIN interface.
The label of a softkey. Upper case selection in a softkey indicates the state after the
softkey is pressed. A series of hardkeys and softkeys represents the path to a given
softkey or menu.

2 Recording Programs

2-1
Recording Programs
Keystroke recording, described in this chapter, is ideal for creating simple programs or measurement sequences for instrument control. Other methods of program development may be used to supplement keystroke recording and create more sophisticated programs. If a program requires data processing, decision making, operator input, or a display of graphical diagrams, other program development methods are needed. These methods are covered in Chapter 5, “Developing Programs.”
IBASIC programs for the analyzer can be created and edited using the following methods:
• the front panel keys and knob
• an external keyboard (Option 1CL)
• an HP controller running HP BASIC
• a workstation or PC using a text editor or programming editor
Recording Programs
IBASIC
Key Record on OFF
IBASIC
Key Record on OFF
Run
IBASIC

Keystroke Recording

Keystroke Recording
Keystroke recording is the easiest way to create IBASIC programs. It requires only a couple of steps to set up and run, and very little programming knowledge is required.

What Is Keystroke Recording?

Keystroke recording is a way to automatically create IBASIC measurement sequence programs. To record a program, press the following keys:
SYSTEM OPTIONS
• Normal key sequences for the measurement
• to
SYSTEM OPTIONS
terminate recording
The resulting program can then be run by pressing in the
SYSTEM OPTIONS
menu.
Keystroke recording works by finding the SCPI mnemonic that fits each operation performed by the instrument; then it builds a program line to perform that operation when the recorded program is executed. All program lines built by keystroke recording are entered into the analyzer's program buffer. If the buffer contains no existing lines, a complete executable program will be created. If there is a program in the buffer when recording is turned on, the recorded statements are inserted into the existing program. Refer to Chapter 5, “Developing Programs,” for a description of how to record into existing programs.
HP IBASIC Supplement 2-3
Recording Programs
Keystroke Recording

IBASIC Programs and the Input Buffer

Recorded programs send commands to the instrument, and use the same set of commands used by external controllers for remote operation of the instrument.
These commands are stored in an input buffer by the instrument. An IBASIC program generally outputs the commands much faster than the instrument can execute them. This often causes the program to complete while the instrument is still executing commands in the input buffer . The instrument continues processing these commands until the buffer is empty.
This may have some side-effects if you are not aware of this interaction. For example, it may not be immediately obvious that the program has actually finished, since the instrument is still functioning “remotely.” This could cause confusion if you try to pause and continue a program that has actually ended.
You can clear the buffer from within your program by inserting the statement CLEAR 8 at the beginning of your program (see Chapter 5 for information on editing programs).
Another side-effect of the speed with which the analyzer processes commands is that it is possible for a command to execute before a previous command has completed execution. The most common example of this is a data query that executes before a measurement sweep is complete. This interaction can lead to erroneous data being collected. F or more information on synchronizing the execution of commands, refer to “Synchronizing the Analyzer and a Controller” in the Programmer's Guide.
Recording Programs

What's in a Recorded Program

What's in a Recorded Program
A program created using keystroke recording is composed of three fundamental IBASIC statements: ASSIGN, OUTPUT and END. The following simple program demonstrates these statements:
1 ASSIGN @Rfna TO 800 2 OUTPUT @Rfna;”SOUR1:POW -10 dBm” 10 END
The ASSIGN and END statements are automatically created when keystroke recording is used to create a new program (as opposed to modifying an existing one).
There will only be one ASSIGN statement at the beginning of a program and one END statement at the end, but in a typical program there will be many OUTPUT statements. Since the OUTPUT statement does the actual work of controlling the analyzer, let's take a closer look at how it is used.
NOTE Each analyzer model requires a unique ASSIGN statement.
The ASSIGN statement, which is automatically created, will vary depending on the model of the analyzer:
HP 8712ES/ET ASSIGN @Hp8712 To 800 HP 8714ES/ET ASSIGN @Hp8714 TO 800
HP IBASIC Supplement 2-5
Recording Programs
What's in a Recorded Program

The OUTPUT Statement

The IBASIC statement
OUTPUT <destination>;<data>
tells the internal computer to send some information(data) to a device at a specific address(destination). The destination can be a device selector number (example: OUTPUT 800), or a name representing a number, called a path name (example: OUTPUT@Rfna). In recorded IBASIC programs, the data are strings containing commands for the instrument (mnemonics).
The following represents a typical OUTPUT command from a recording session:
OUTPUT @Rfna;”SOUR1:POW -10 dBm”
Notice that the OUTPUT command is followed by a name representing a device selector (@Rfna), followed by a semicolon and the data (SOUR1:POW -10 dBm).

The ASSIGN Statement

The destination in an OUTPUT statement specifies the address of the device. In recorded programs this address is represented by the I/O path name @Rfna. The following line appears in all recorded programs before any OUTPUT statements:
ASSIGN @Rfna to 800
The ASSIGN statement allows you to substitute an I/O path name (a variable preceded by the @ symbol) for a device selector number. Therefore, after the above ASSIGN statement, the program line
OUTPUT @Rfna;”SOUR1:POW -10 dBm”
is equivalent to
OUTPUT 800;”SOUR1:POW -10 dBm”
The device selector 800 specifies the host instrument as the destination of any data sent by the OUTPUT command. The program communicates with the analyzer via select code 8, the internal HP-IB interface, which is
used only for communication between IBASIC programs and the analyzer. The analyzer will respond to any address on the internal interface from 800 to 899 (800 is typically used).

SCPI Mnemonics

The data sent to the analyzer by the OUTPUT command is called a SCPI (Standard Commands for Programmable Instruments) mnemonic and is found in quotes following the device selector path name and semicolon. See Figure 2-1.
Figure 2-1 Example IBASIC OUTPUT Command Syntax
OUTPUT @Rfna;"SOUR1:POW -10 dBm”
Recording Programs
What's in a Recorded Program
IBASIC command
IBASIC variable: Holds device selector path name (analyzer address)
SCPI is a standard instrument control programming language that provides commands that are common from one product to another, thus reducing the number of device specific commands. It uses easy-to-learn, self-explanatory syntax that provides flexibility for both novice and expert programmers.
The SCPI mnemonic codes used by IBASIC are the same ones used to control the instrument remotely via an external computer. External computers communicate with the analyzer over the external HP-IB bus while IBASIC programs communicate with it over the internal bus. In our example, the mnemonic “SOUR1:POW -10 dBm” tells the instrument to set the source power to 10 dBm.
For more information on HP-IB interfacing using IBASIC, refer to
Chapter 8, “Interfacing with External Devices.” The SCPI mnemonics for
the analyzer are documented in the Programmer's Guide.
Delimiter: Separates IBASIC command from SCPI mnemonic
SCPI mnemonic (command)
HP IBASIC Supplement 2-7
Recording Programs
Level
2
Enter

How Recording Works

How Recording Works
Keystroke recording works by recording the functional operation of the instrument, not by recording every keystroke. A sequence of SCPI mnemonics forms the recorded sequence of operations.
As you press a sequence of keys to perform an operation, SCPI mnemonics for that operation are generated and recorded. The operation may take one keystroke or several keystrokes, but the mnemonic is not generated until the operation is complete.
In other words, it is the functional operation of the instrument that is recorded as a mnemonic. The separate, individual keystrokes to perform that operation are not recorded.
For example , recording the simple key sequence:
1 0
mnemonic that is generated after the keystroke sequence is completed:
“SOUR1:POW -10dBm”
This mnemonic is then automatically formed into the command
OUTPUT @Rfna;”SOUR1:POW -10 dBm”
and is inserted into the program. If you accidentally press an incorrect key in a sequence, it may not show
up in the recorded program. Also, you cannot exactly mimic keystrokes to leave the instrument in a specific front panel state, unless this state appears as a natural consequence of a completed operation.
As shown in the above example, pressing the hardkey in a recording session has the effect of bringing up the menu, but does not, by itself, generate a program line. You could not, therefore, leave the instrument with the menu displayed.
requires six keystrokes and produces a single
POWER
POWER
POWER
POWER
Recording Programs
IBASIC

Operations that Do Not Record

Operations that Do Not Record
Although keystroke recording works automatically in most situations, some operations cannot be captured or can only be partially captured using this method. This is true for one of the following reasons:
• There is no corresponding SCPI mnemonic for the front panel keystrokes (such as transitional key sequences).
• The keystrokes are IBASIC front panel operations (such as some of the softkey operations found under the
menu).
• The operation requires additional programming steps (such as passing control of the HP-IB to the instrument for hardcopy output).
• The HP-IB operation has no front panel equivalent (such as HP-IB query commands or data transfer).
• The keystrokes are service menu keys (in general).
SYSTEM OPTIONS
NOTE Do not recall programs in keystroke record mode.
This will overwrite previously recorded program steps.

Front Panel Operations without Mnemonics

The following descriptions indicate areas of front panel operation which have no corresponding SCPI mnemonics:
• Most operations on the front panel requiring numeric entry allow use of the knob to increment or decrement the current value. This will not record as a program line. Always use the numeric keypad or step keys
to enter any value if you want the operation to be recorded.
• During a measurement sequence, it may take several key presses to cause an operation that will generate a mnemonic. The transitional sequences between actual instrument events are not recordable. For example, pressing the key displays the scale numeric entry, but nothing is recorded until you enter a value for the scale parameter.
HP IBASIC Supplement 2-9
SCALE
Recording Programs
IBASIC
Run
Continue
Edit
Programs
Operations that Do Not Record
• Any default states which you set up prior to recording or which you encounter while recording (and consequently do not select) are not recorded.
• Use of step keys is not recommended because the results may depend on the function's step size, which may change as other parameters change.
NOTE Instrument states that are not specifically selected or changed are not
recorded. Since these default states are not recorded, you must either actively select them to generate a program statement, or make sure the instrument is in exactly the same state when the program is run as when it was recorded. This is discussed further in “A voiding Recording Errors” later in this chapter.

HP Instrument BASIC Operations

Some softkeys under the menu cannot be recorded. Operations on programs, such as , ,
and , do not record. You can,
SAVE RECALL
however, record display partitions and all other save and recall operations not having to do with IBASIC programs.
Although IBASIC operations cannot be recorded, many do have corresponding SCPI mnemonics that allow an external controller to control and communicate with internal IBASIC programs. For more information, refer to Chapter 8, “Interfacing with External Devices.”
SYSTEM OPTIONS

Operations Requiring Additional Programming

Some operations that work well when performed manually from the front panel require special attention when used in a program. This is due to two interactions: synchronization and active control.
Recording Programs
Start
Abort
Operations that Do Not Record
Synchronization
Often, one event must be completed before another can occur. Suppose you want your program to perform a limit test on data, but only after a sweep has been completed. You can record the command to perform the limit test by pressing key sequences. However, to detect when the instrument has completed a sweep, you must edit the program and include a routine that waits for a status register to indicate the end of the sweep.
CAUTION Synchronization is required only with overlapped commands.
Overlapped commands, such as the command to trigger a sweep, don't hold off the processing of subsequent commands, and are not necessarily completed when the next command begins. The analyzer adds a “wait” command (*WAI) when an overlapped command is created using keystroke recording. *WAI delays processing of subsequent commands until previous commands have been parsed. *WAI does not insure previous commands have completed. For more information on synchronization, see “Synchronizing the Analyzer and a Controller” in the Programmer's Guide.
Active Control of the HP-IB Interface
Some operations require the analyzer to be the active controller on the external HP-IB bus. The analyzer must be the System Controller (or active control must be passed to it from an external controller). When an IBASIC program begins running, control of the external interface is automatically passed to the program, so active control must be passed back to the analyzer before these operations can be performed.
These operations include all of the following actions when they are directed to HP-IB devices.
HARDCOPY
HARDCOPY
NOTE Active control of the HP-IB interface is only a problem if that bus is being
used. Hardcopy output to devices on the serial or parallel ports do not require control of the HP-IB.
HP IBASIC Supplement 2-11
Recording Programs
Operations that Do Not Record
The example program “PASSCTRL” in theExample Programs Guide and on the Example Programs Disk illustrates these concepts.
You can use keystroke recording for any of these operations but you will not be able to successfully run the program that is generated. You will need to enter the program lines necessary to first pass control to the analyzer and then wait for control to be passed back to the program.
See “Passing and Regaining Control” in Chapter 8 for an example of passing control to the analyzer.
Mnemonics with No Corresponding Front Panel Operation
Several of the analyzer SCPI mnemonics for the instrument perform operations that are not available from the front panel and cannot be recorded. These include operations such as querying instrument status, transferring data over HP-IB, setting and clearing status registers, and general HP-IB housekeeping.
These operations are useful for the more advanced HP-IB programmer using IBASIC. Because they fall outside the direct operating realm of the analyzer, they cannot be recorded. They can be added to a recorded program using the built-in editor or another editing environment. See your analyzer's Programmer's Guide for a complete description of the analyzer's HP-IB command set. See also “Built-In High Speed Subprograms” in Chapter 9.

Avoiding Recording Errors

Log Mag
Trigger
Hold
Continuous

Use Instrument Preset

Recording Programs
Avoiding Recording Errors
In most cases, the key/operation should be the first keystroke recorded. This sets the instrument to its default state and avoids the risk of creating a program that depends on prior instrument settings.
You can include the command to perform a preset in your program by pressing immediately after turning recording on. This inserts the following line prior to all other OUTPUT statements in your program:
OUTPUT @Rfna;”SYST:PRES;*WAI”
See your analyzer's User's Guide to determine the specific preset state for your particular analyzer.
PRESET
PRESET
Specifically Select Parameters
If you do not want to preset the instrument before running a recorded program (for example, you may be recording a section of a larger measurement sequence), be sure to specifically activate every instrument setting that you will need in your automated sequence. For example, if you want the data format to be Log Mag, press and then , even though Log Mag is already the default setting. This will generate a program line to specifically set the data format to Log Mag.
In some cases you may have to select another setting first and then re-select the original setting in order to generate the correct program line. F or example, if you w ant to generate a program line to set the sweep trigger to Continuous, and you discover that it is already set to Continuous when you start recording, press first—then press . You can easily remove unwanted program lines generated by this procedure in the editor.
MENU
FORMAT
HP IBASIC Supplement 2-13
Recording Programs
HP-IB
HP-IB Echo on OFF
Avoiding Recording Errors
NOTE Do not rely on the step keys or the front panel knob to set parameters.
Use of step keys is not recommended because the results may depend on the function's step size, which may change as other parameters change.

Use HP-IB Echo

HP-IB echo is a useful analyzer feature that allows you to view the SCPI mnemonic or mnemonics corresponding to any operation executed from the front panel. To turn on HP-IB echo, press
and . After doing this, you will see a mnemonic appear in a dialogue box on the screen as you complete any key sequence that has a matching SCPI mnemonic.
This mnemonic is used in your recorded program during a recording session.
Using HP-IB echo, you can preview the SCPI mnemonic commands that will be stored in your program before you actually record them. While this is not essential, it can be very useful when you are in doubt as to what a particular key sequence will record, or precisely when a key sequence corresponding to a mnemonic is completed.
SYSTEM OPTIONS
3 Running, P ausing, and Stopping
Programs
3-1
Running, Pausing, and Stopping Programs
This chapter describes how to start, stop, and pause a program from the front panel. Automatic execution of a program is described.
IBASIC programs can also be remotely controlled via SCPI commands over the HP-IB. For information on running, pausing and stopping programs using an external controller, see Chapter 8, “Interfacing with
External Devices.”
Running, Pausing, and Stopping Programs

Starting Programs Automatically

Starting Programs Automatically
When the analyzer is powered up, it automatically searches for a program named AUTOST or AUTOST.BAS. When an AUTOST program is found, it is automatically loaded and executed. The analyzer searches in the following order:
• internal non-volatile RAM disk
• internal floppy disk drive The AUTOST program can be used for anything from configuring the
analyzer for specific measurements, much like an internal instrument state Save/Recall register, to diagramming measurement setups using graphics commands, as in a guided measurement sequence.
Refer to Chapter 4, “Saving and Recalling Programs,” for information on using the analyzer to name programs before they are saved.
HP IBASIC Supplement 3-3
Running, Pausing, and Stopping Programs
Run
IBASIC
Run
Enter
IBASIC
IBASIC

Running and Continuing a Program

Running and Continuing a Program
To run an IBASIC program that is already in the analyzer program buffer, press the softkey in the menu. The RUN command can also be executed from an external keyboard in three ways:
SYSTEM OPTIONS
• Press the function key that corresponds to the softkey
(see note below).
• Type RUN on a command line and press . A command line is
always available when an IBASIC display is partitioned. (See
Chapter 5, “Developing Programs,” for information about display
partitions.) You can also activate a command line from an external keyboard with no IBASIC displays partitioned by pressing the key on your external keyboard.
• Press the function key when the command line is available.
NOTE The keyboard function keys duplicate softkey actions.
When an external keyboard is connected, the function keys through
always represent the analyzer's eight softkeys. The analyzer's
F8
hardkeys are each represented by a combination of or and one of the function keys. Refer to your analyzer's User's Guide for more information on the external keyboard interface. The
SYSTEM OPTIONS
keyboard using + (for ) and (for
). A keyboard template showing which keys to press for specific analyzer functions is supplied with your analyzer (HP part number 08712-80028).
Ctrl F3 SYSTEM OPTIONS F1
F1
F9
Shift Ctrl
menu can be accessed from an external
ESC
F1
Loading...
+ 131 hidden pages