Agilent 4155B Programmers Guide

Page 1
Programmer’s Guide
Agilent 4155B Semiconductor Parameter Analyzer
Agilent 4156B Precision Semiconductor Parameter Analyzer
Agilent Part No. 04156-90400
Printed in Japan January 2000
Edition 4
Page 2
Legal Notice
Copyright © 1997, 1998 Agilent Technologies
This document contains information which is protected by copyright. All rights are reserved. Reproduction, adaptation, or translation without prior written permission is prohibited, except as allowed under the copyright laws.
Product Warranty
Agilent Technologies warrant Agilent Technologies hardware, accessories and supplies against defects in materials and workmanship for the period of one year from the warranty start date specified below. If Agilent Technologies receive notice of such defects during the warranty period, Agilent Technologies will, at its option, either repair or replace products which prove to be defective. Replacement products may be either new or like-new.
Warranty service of this product will be performed at Agilent Technologies. Buyer shall prepay shipping charges to Agilent Technologies and Agilent Technologies shall pay shipping charges to return the product to Buyer. However, Buyer shall pay all shipping charges, duties, and taxes for products returned to Agilent Technologies from another country.
Agilent Technologies do not warrant that the operation of Agilent Technologies products will be uninterrupted or error free. If Agilent is unable, within a reasonable time, to repair or replace any product to a condition as warranted, customer will be entitled to a refund of the purchase price upon prompt return of the product.
The Agilent Technologies products may contain remanufactured parts equivalent to new in performance or may have been subject to incidental use.
The warranty period begins on the date of delivery or on the date of installation if installed by Agilent Technologies. If customer schedules or delays Agilent Technologies installation more than 30 days after delivery, warranty begins on the 31st day from delivery.
Warranty does not apply to defects resulting from (a) improper or inadequate maintenance or calibration, (b) software, interfacing, parts or supplies not supplied by Agilent Technologies, (c) unauthorized modification or misuse, (d) operation outside of the published environmental specifications for the product, or (e) improper site preparation or maintenance.
2 Agilent 4155B/4156B Programmer’s Guide, Edition 4
Page 3
To the extent allowed by local law, the above warranties are exclusive and no other warranty or condition, whether written or oral, is expressed or implied and Agilent Technologies specifically disclaim any implied warranties or conditions of merchantability, satisfactory quality, and fitness for a particular purpose.
Agilent Technologies will be liable for damage to tangible property per incident up to the greater of $300,000 or the actual amount paid for the product that is the subject of the claim, and for damages for bodily injury or death, to the extent that all such damages are determined by a court of competent jurisdiction to have been directly caused by a defective Agilent Technologies product.
To the extent allowed by local law, the remedies in this warranty statement are customers sole and exclusive remedies. Expect as indicated above, in no event will Agilent Technologies or its suppliers be liable for loss of date or for direct, special, incidental, consequential (including lost profit or date), or other damage, whether based in contract, tort, or otherwise.
For consumer transactions in Australia and New Zealand: the warranty terms contained in this statement, except to the extent lawfully permitted, do not exclude, restrict or modify and are in addition to the mandatory statutory rights applicable to the sale of this product to you.
Assistance
Product maintenance agreements and other customer assistance agreements are available for Agilent Technologies products.
For any assistance, contact your nearest Agilent Technologies Sales Office.
Certification
Agilent Technologies Inc. certifies that this product met its published specifications at the time of shipment from the factory. Agilent further certifies that its calibration measurements are traceable to the National Institute of Standards and Technology (NIST), to the extent allowed by the Institute’s calibration facility, and to the calibration facilities of other International Standards Organization members.
Agilent 4155B/4156B Programmers Guide, Edition 4 3
Page 4
Printing History
Edition 1: August 1997
Edition 2: September 1997
Edition 3: September 1998
Edition 4: January 2000
Microsoft, Windows, MS-DOS and Excel are registered trademarks of Microsoft Corporation.
Lotus and 1-2-3 are registered trademarks of Lotus Development Corporation.
NFS is a trademark of Sun Microsystems, Inc.
4 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 5
Programming Overview
Agilent 4155B/4156B can be fully controlled from an external computer or by using built-in Instrument BASIC (IBASIC) controller. IBASIC is a programming environment that allows full control of the 4155B/4156B without using an external computer.
The 4155B/4156B has three command modes:
4155/4156 SCPI command mode
SCPI means Standard Commands for Programmable Instruments. This mode is the default mode of the 4155B/4156B, and allows you to control all functions of the 4155B/4156B.
4155/4156 FLEX command mode
FLEX means Fast Language for EXecution. This mode allows you to control measurement functions of the 4155B/4156B. Command execution is faster than the SCPI command mode.
4145 syntax command mode
This mode allows you to execute the 4145A/B programs on the 4155B/4156B directly with little or no modification. In this command mode, you cannot control all functions of the 4155B/4156B.
Agilent 4155B/4156B Programmers Guide, Edition 4 5
Page 6
How to Migrate the 4145A/B Programs
The 4145A/B Auto Sequence Program (ASP) programs run on the 4145A/B built-in programming environment and allow basic control of the 4145A/B without using an external computer. To run the ASP programs on the 4155B/4156B, you do one of the following and execute the program in the 4155/4156 SCPI command mode:
Create a program that performs the same operations as the desired ASP program by using the IBASIC editor typing aid softkeys to enter commands that correspond to each ASP command. This program can run on IBASIC only, not on an external computer. Refer to Chapter 5 for details.
Create a program using SCPI commands that performs same operations as the desired ASP program. This program can run on IBASIC or on an external computer. Refer to Programming Example for the 4145 Users in Chapter 2 for details.
The 4145A/B GPIB programs run on an external computer and allow full control of the 4145A/B. To run these programs on the 4155B/4156B, do one of the following:
Directly run the 4145A/B program on the 4155B/4156B with little or no modification. You must run this program in the 4145 syntax command mode from IBASIC or an external computer. Refer to Chapter 4 for details.
Create a program using SCPI commands that performs same operations as the 4145A/B program. You must run this program in the 4155/4156 SCPI command mode from IBASIC or an external computer.
Create a program using FLEX commands that performs same operations as the 4145A/B program. You must run this program in the 4155/4156 FLEX command mode from IBASIC or an external computer.
6 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 7
In This Manual
This manual describes how to control the 4155B/4156B by using GPIB commands from an external computer or built-in Instrument BASIC.
This manual consists of the following chapters:
Using Instrument BASIC
4155B/4156B SCPI Command Programming
4155B/4156B FLEX Command Programming
Running 4145A/B Program Directly on 4155B/4156B
ASP-Like IBASIC Programming
Refer to SCPI Command Reference for SCPI commands. And refer to GPIB Command Reference for the FLEX commands and for the 4145 syntax commands.
See User's Guide General Information and User's Guide Measurement and Analysis for information about the 4155B/4156B itself.
Text Conventions
The following text conventions are used in this manual:
key Represents a key physically located on the 4155B/4156B or
exxternal keyboard.
Screen Text Represents text that appears on screen of the 4155B/4156B.
Italic Refers to a related document, or is used for emphasis.
Agilent 4155B/4156B Programmers Guide, Edition 4 7
Page 8
8 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 9
Contents
1. Using Instrument BASIC
Before Operating IBASIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
To Switch Screen Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
To Use the Help Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
Creating and Executing a Simple IBASIC Program . . . . . . . . . . . . . . . . . . . . . . . 1-6
Modifying Program by using Editor Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8
Saving and Getting a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-12
Summary of Softkeys and Keyboard Operations for Editor . . . . . . . . . . . . . . . . 1-14
Other Basic Features of IBASIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-15
Branching/Repeating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-15
Subprograms and COM Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16
IBASIC Basic Operation Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17
IBASIC Editor Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-20
Controlling IBASIC from External Computer . . . . . . . . . . . . . . . . . . . . . . . . . . 1-24
IBASIC Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-28
All IBASIC Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-29
IBASIC Status Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-31
Keys for IBASIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-32
Front-panel Keys for IBASIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-32
Primary Softkeys in Idle, Pause, Run, or Input? execution status . . . . . . . . . . 1-35
Secondary Softkeys in Idle or Pause execution status . . . . . . . . . . . . . . . . . . . 1-36
Secondary Softkeys in Run or Input? execution status . . . . . . . . . . . . . . . . . . 1-37
Primary Softkeys in Edit execution status . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-37
Secondary Softkeys in Edit execution status . . . . . . . . . . . . . . . . . . . . . . . . . . 1-38
External Keyboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-41
4155B/4156B Specific IBASIC Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-45
Available I/O Resources for IBASIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-47
Agilent 4155B/4156B Programmer’s Guide, Edition 4 Contents - 1
Page 10
Contents
LCD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-48
GPIB Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-49
Parallel Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-49
Built-in Flexible Disk Drive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-50
Differences from 4155A/4156A Programming . . . . . . . . . . . . . . . . . . . . . . . . . 1-51
Using Text Display and Graphics Display . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-52
Using :HCOP:DEST Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-53
Using :HCOP:DEV:LANG Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-54
2. SCPI Command Programming
SCPI Programming Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
Preparation before Controlling 4155B/56B via GPIB . . . . . . . . . . . . . . . . . . . 2-3
SCPI Command Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
To Control 4155B/56B by HP BASIC Programming . . . . . . . . . . . . . . . . . . . . 2-6
Getting Started on SCPI Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
Creating a Simple Measurement Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
Programming for Data Extraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19
Complete Example Program for Vth Measurement . . . . . . . . . . . . . . . . . . . . 2-24
Example Application Setup for Vth Measurement . . . . . . . . . . . . . . . . . . . . . 2-26
Programming: Measurement Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-30
To Set or Change 4155/56 Setup Data Values . . . . . . . . . . . . . . . . . . . . . . . . 2-31
To Read 4155/56 Setup Data Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-33
Programming: Measurement Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-34
To Execute a Sweep or Sampling Measurement . . . . . . . . . . . . . . . . . . . . . . . 2-35
To Force Stress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-37
To Start the Knob Sweep Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-39
To Control Standby Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-40
Programming: File Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-42
To Store Setup Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-43
Contents - 2 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 11
Contents
To Store Measurement Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-44
To Load Setup Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-45
To Load Measurement Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-46
Programming: Data Transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-47
To Read 4155/56 Measurement Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-48
To Transfer Data to 4155B/4156B (Using User Variable) . . . . . . . . . . . . . . . 2-49
Programming: Print/Plot Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-53
To Output Setup Data to Printer/Plotter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-56
To Output Graphics Result Data to Printer/Plotter . . . . . . . . . . . . . . . . . . . . . 2-60
To Output List Results Data to Printer/Plotter . . . . . . . . . . . . . . . . . . . . . . . . 2-63
To Dump Screen Image to Printer/Plotter . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-66
To Save Hardcopy Image to a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-69
Other Programming Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-70
Disabling Instrument Screen Update to Improve Speed . . . . . . . . . . . . . . . . . 2-70
Auto-loading of Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-71
Differences From 4155A/4156A SCPI Commands . . . . . . . . . . . . . . . . . . . . 2-72
Programming Example for 4145 Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-75
3. FLEX Command Programming
Programming Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
Controlling 4155B/4156B via GPIB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
Controlling 4155B/4156B Using HP BASIC Programming . . . . . . . . . . . . . . . 3-4
High-Speed Spot Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
Spot Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8
1 Channel Pulsed Spot Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11
Staircase Sweep Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
Pulsed Sweep Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
Staircase Sweep with Pulsed Bias Measurements . . . . . . . . . . . . . . . . . . . . . . . 3-24
Agilent 4155B/4156B Programmers Guide, Edition 4 Contents - 3
Page 12
Contents
Sampling Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28
Stress Force . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-32
Controlling PGU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-36
Using Program Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-39
Reading and Writing Data to a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-44
Printing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-53
Reading Binary Output Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-56
Using the US42 Control Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-60
Programming Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-63
Confirming Operation Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-63
Improving Measurement Speed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-64
4. Running 4145A/B Program Directly on 4155B/4156B
Non-supported Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
Considerations about Differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
Spot Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
Sweep Steps in Logarithmic Step Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
Terminator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-5
5. ASP-Like IBASIC Programming
Creating ASP-like IBASIC Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
Programming Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6
Reading 4155/56 Data to IBASIC Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7
Auto Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-8
4145 ASP and 4155B/4156B Corresponding Keywords . . . . . . . . . . . . . . . . . 5-9
ASP-like Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-10
EXECUTE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-10
Contents - 4 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 13
Contents
GET SETUP Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-11
SINGLE Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-11
STANDBY directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-12
STRESS Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-12
AUTO-SCALE Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-12
SAVE DATA Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-13
READ DATA VARIABLE Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14
DEFINE USER VARIABLE Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-15
PRINT/PLOT Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16
CURVE PLOT Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16
Agilent 4155B/4156B Programmers Guide, Edition 4 Contents - 5
Page 14
Contents
Contents - 6 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 15

1 Using Instrument BASIC

Agilent 4155B/4156B Programmers Guide, Edition 4
Page 16
Using Instrument BASIC
The Instrument BASIC (IBASIC) is a system controller built into Agilent 4155B/4156B. By using IBASIC, you can run a program to control the 4155B/4156B and other instruments (connected via interfaces of the 4155B/4156B) without using an external computer.
IBASIC is a subset of HP BASIC. Programs created by IBASIC can run on an HP BASIC controller with little or no modification.
This chapter consists of the following sections.
The following sections provide step-by-step instructions to operate IBASIC by using examples. You can learn the basics of IBASIC programming and operations. If you are not familiar with IBASIC, we recommend to read through these sections first.
Before Operating IBASIC
Creating and Executing a Simple IBASIC Program
Modifying Program by using Editor Functions
Saving and Getting a Program
Summary of Softkeys and Keyboard Operations for Editor
Other Basic Features of IBASIC
The following sections are a task oriented reference for IBASIC. You can quickly find the desired IBASIC task.
IBASIC Basic Operation Tasks
IBASIC Editor Tasks
Controlling IBASIC from External Computer
The following sections provide the reference information of IBASIC.
IBASIC Screen
Keys for IBASIC
4155B/4156B Specific IBASIC Commands
Available I/O Resources
The following section provides the differences from the 4155A/4156A IBASIC programming.
Differences from 4155A/4156A Programming
1-2 Agilent 4155B/4156B Programmer’s Guide, Edition 4
Page 17
Using Instrument BASIC

Before Operating IBASIC

Before Operating IBASIC
The 4155B/4156B provides the following three screen modes for operating IBASIC.
"All IBASIC" screen
Entire screen including softkeys is used for IBASIC, so no instrument setup screen is displayed.
You can execute programs, but no instrument setup screen appears in this mode.
"IBASIC Status" screen
Softkeys and bottom two lines are used for IBASIC. Rest of screen is for instrument setup screen.
In this mode, you can start the IBASIC editor. The displayed softkeys are for IBASIC operation. You can execute IBASIC commands interactively. Characters you type are displayed at the bottom of the screen.
"All Instrument" screen
.This is regular instrument screen and the default display mode at power on. Entire screen is for instrument setup screen, and all softkeys are for interactive use of instrument. In this mode, you cannot use the IBASIC editor. Only the front-panel keys of IBASIC key group and external keyboard are available to execute or pause program for the Instrument BASIC from this screen mode.
Ctrl+U (Run) and Ctrl+P (Pause) on
For details about the Instrument BASIC screens, refer to “IBASIC Screen” on page 1-28.

To Switch Screen Mode

To switch the screen mode, repeat one of the following instruction until the desired screen is displayed. This operation toggles screen display as shown below:
From instrument front panel, press
From external keyboard, press
Agilent 4155B/4156B Programmers Guide, Edition 4 1-3
Display of IBASIC key group.
Ctrl+G.
Page 18
Using Instrument BASIC Before Operating IBASIC

To Use the Help Function

By using the built-in help function of the 4155B/4156B, you can easily get information (name, syntax, and description) about programming commands, and can enter the desired command into the program without typing.
To start the help function for the programming commands, press are in the IBASIC editor.
In the help function, the programming commands are divided into the following three categories, which you can access by secondary softkeys.
Softkey Category
IBASIC IBASIC commands.
PA G E IMAGE COMMAND
SCPI COMMAND
The upper part of the help screen displays a list of the command names. The lower part displays a description of the selected (by field pointer) command.
There are no Help function for the 4155/4156 FLEX command mode and the 4145 Syntax command mode.
SCPI commands specific for the 4155B/4156B. These are the help commands associated with the instrument setup screen that begin with :PAGE.
Standard SCPI commands.
Help key while you
1-4 Agilent 4155B/4156B Programmer’s Guide, Edition 4
Page 19
To move the field pointer
To move the field pointer, refer to the following table:
Using Instrument BASIC
Before Operating IBASIC
Rotary knob or Arrow keys
PAGE CONTROL keys
MEASUREMENT keys
Get and Save
Basically, you move the field pointer by using the rotary knob or arrow keys.
Field pointer moves to first PAGE IMAGE command that is associated with the pressed key. PAGE CONTROL keys are
Chan, Meas, Display, Graph/List, Stress, and System.
Field pointer moves to the PAGE IMAGE command that is associated with the pressed key. MEASUREMENT keys
Single, Repeat, and Append.
are
Field pointer moves to the associated SCPI command.
front-panel keys
Alphabetical keys Field pointer moves to next command that has a keyword
that begins with same letter as the pressed key. If you are in the PAGE IMAGE command category, search is only within the instrument screen group of the currently selected command.
To search for a command
To search for a command:
1. Press SEARCH secondary softkey.
2. Type in command string that you want to search for, then press
Enter
To enter a command into the editor
The command specified by the field pointer is displayed on the entry line. If you
Enter, the command is entered into the editor.
press
If command specified by the field pointer is a PAGE IMAGE or SCPI command, first select the OUTPUT @Hp415x secondary softkey. The entry line becomes OUTPUT @Hp415x;"command", where command is command specified by field pointer. Then, press
Enter.
OUTPUT @Hp415x;"command" is entered into the editor.
Agilent 4155B/4156B Programmers Guide, Edition 4 1-5
Page 20
Using Instrument BASIC Creating and Executing a Simple IBASIC Program

Creating and Executing a Simple IBASIC Program

In this section, let's try to create and execute a simple program.
Before creating a program in the IBASIC editor, first change the screen display mode to IBASIC Status screen mode or All IBASIC screen mode by pressing IBASIC following sections, the All IBASIC screen display mode is used.
1. Editing
2. Exiting from Editor
3. Executing Program
Step 1 Editing
Select EDIT secondary softkey or type EDIT, then press
10
The following program prints the numbers from 1 to 10. Type as follows:
10 FOR I=1 TO 10 20 PRINT I 30 NEXT I 40 END
Display key as described in To Switch Screen Mode on page 1-3. In
Enter.
NOTE To start the editor at a specific program line or label
Ty pe EDIT linenum or EDIT label.
For example, if you type EDIT 30, the cursor appears at line 30. If you do not specify a line number or label, the cursor will appear at line 10.
NOTE Always insert mode
Editor is always in insert mode, and cannot be changed to overwrite mode. If you typed wrong characters, use
Backspace to move back a character, or move cursor
using Ü key, then use Delete to delete a character. Then type correct characters.
NOTE Program End
In IBASIC, END must be at end of main program. In above example, line 40 is the last line of the program.
1-6 Agilent 4155B/4156B Programmer’s Guide, Edition 4
Page 21
Step 2 Exiting from Editor
Select the End edit primary softkey to exit from the editor.
Step 3 Executing Program
To execute the program, press softkey, or type RUN and press screen:
1 2 3 4 5 6 7 8 9 10
NOTE If an error message appears
If an error message appears, you probably typed wrong characters. The error message indicates the line number where the error occurs. You need to modify the line.
Using Instrument BASIC
Creating and Executing a Simple IBASIC Program
Run of the IBASIC key group, select RUN primary
Enter. The following should be displayed on the
Agilent 4155B/4156B Programmers Guide, Edition 4 1-7
Page 22
Using Instrument BASIC Modifying Program by using Editor Functions

Modifying Program by using Editor Functions

In this section, you can learn the following editor functions:
1. Inserting lines
2. Deleting a line
3. Renumbering
4. Inserting characters
5. Recalling deleted line
6. Indenting
1-8 Agilent 4155B/4156B Programmer’s Guide, Edition 4
Page 23
Step 1 Inserting Lines
Ty pe EDIT 20, then press
10 FOR I=1 TO 10 20 PRINT I 30 NEXT I 40 END
Select Insert line or press Insert to insert a line above line 20.
10 FOR I=1 TO 10 11 20 PRINT I 30 NEXT I 40 END
Type as follows:
10 FOR I=1 TO 10 11 PRINT I^2 20 PRINT I 30 NEXT I 40 END
I^2 means the second power of I. The above program increments I from 1 to 10, and displays second power of I and I for each step.
Using Instrument BASIC
Modifying Program by using Editor Functions
Enter. Cursor appears at line 20.
Select End edit to exit editor, then press is displayed:
1 1 4 2 9 3 : : 81 9 100 10
Run to execute the program. The following
Agilent 4155B/4156B Programmers Guide, Edition 4 1-9
Page 24
Using Instrument BASIC Modifying Program by using Editor Functions
Step 2 Deleting a Line
Ty pe EDIT 20 to start editor at line 20.
10 FOR I=1 TO 10 11 PRINT I^2 20 PRINT I 30 NEXT I 40 END
Then, select Delete line or press Shift+Delete to delete line 20. The result is as follows:
10 FOR I=1 TO 10 11 PRINT I^2 30 NEXT I 40 END
The above program increments I from 1 to 10, and displays the second power of I at each step.
If you exit editor and execute the program, the following is displayed:
1 4 9 : : 81 100
Step 3 Renumbering
In above example, line numbers are not in equal increments. To change the line number increment to 10, select Re-number softkey. Line numbers will be changed as follows:
10 FOR I=1 TO 10 20 PRINT I^2 30 NEXT I 40 END
If you use the Re-number softkey, the renumbering is always as follows: first line is 10 and the increment is 10.
If you desire other numbering, you need to exit the editor, and use the REN command. For example, if you want first line number to be 100 and increment to be 20, type as follows:
REN 100, 20
1-10 Agilent 4155B/4156B Programmers Guide, Edition 4
Enter
Page 25
Step 4 Inserting Characters
Ty pe EDIT 20, then press
10 FOR I=1 TO 10 20 PRINT I^2 30 NEXT I 40 END
Move the cursor by using right key.
10 FOR I=1 TO 10 20 PRINT I^2 30 NEXT I 40 END
Then type I, as follows:
10 FOR I=1 TO 10 20 PRINT I,I^2 30 NEXT I 40 END
Above program increments I from 1 to 10, and displays I and the second power of I on one line at each step. Exit editor, then execute the program. The following is displayed:
11 24 39 :: :: 981 10 100
Using Instrument BASIC
Modifying Program by using Editor Functions
Enter.
Step 5 Recalling Deleted Line
To restore the most recently deleted line, press
Step 6 Indenting
Move to desired line, then select Indent to indent the line. Indenting makes the program flow easier to understand.
10 FOR I=1 TO 10 20 PRINT I,I^2 30 NEXT I 40 END
Agilent 4155B/4156B Programmers Guide, Edition 4 1-11
Recall front-panel key.
Page 26
Using Instrument BASIC Saving and Getting a Program

Saving and Getting a Program

The created program can be saved to a diskette. So, you can get the saved program from the diskette, then execute it.
In this section, you can learn the following file operation tasks:
1. Saving a Program
2. Listing Contents of Diskette
3. Clearing a Program
4. Getting a Program
Step 1 Saving a Program
Insert a diskette into the built-in flexible disk drive. Then, type SAVE "filename", then press
Enter. For this example, we will type SAVE "PROG1".
Step 2 Listing Contents of Diskette
Ty pe CAT to list contents of the diskette.
If you are using an MS-DOS format diskette, the display is similar to the following example:
DIRECTORY : \:INTERNAL,4 LABEL: 4156 FORMAT: DOS AVAILABLE SPACE : 5692
FILE NAME TYPE RECS LEN DATE TIME PERMISSION ============ ====== ======= ===== ========= ===== ========== PROG1 DOS 65 1 27-Jun-94 14:30 RW-RW-RW-
FILE NUM REC MODIFIED
You can also check the contents of the diskette by using the filer (SYSTEM: FILER screen) of the 4155B/4156B. But you cannot save and get the IBASIC programs by using the filer.
1-12 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 27
Step 3 Clearing a Program
To clear the program, enter the editor, then select Scratch softkey. Then, select Yes secondary softkey.
Existing program will be cleared, and following is displayed:
10 COM @Hp415x 20 ASSIGN @Hp415x TO 800 30! 9990 END
COM @Hp415x and ASSIGN @Hp415x TO 800 are used to control the 4155B/4156B as follows.
COM @Hp415x
Declares COM so that subprograms can access the I/O path (that is assigned in line 20) for controlling the 4155B/56B. Refer to the Instrument BASIC Users Handbook for details.
ASSIGN @Hp415x TO 800
Assigns the I/O path for controlling the 4155B/56B. 800 means built-in IBASIC controller.
Using Instrument BASIC
Saving and Getting a Program
Refer to “Subprograms and COM Blocks” on page 1-16.
NOTE To ASSIGN I/O path
Built-in IBASIC controller
Specify select code 8. For the GPIB address, you can use any number between 0 to 31. Refer to the following example:
10 ASSIGN @Hp4155 TO 800
HP BASIC on an external computer
Specify the select code of the external computer. And specify the GPIB address that you entered into the GPIB ADDRESS field on the SYSTEM: MISCELLANEOUS screen. In the following example, the select code of the external computer is 7 and GPIB address of the 4155B/4156B is 17:
10 ASSIGN @Hp4155 TO 717
Step 4 Getting a Program
Ty pe GET "PROG1", then press Enter. When the LED turns off, enter the editor if you want to display the program.
Agilent 4155B/4156B Programmers Guide, Edition 4 1-13
Page 28
Using Instrument BASIC Summary of Softkeys and Keyboard Operations for Editor

Summary of Softkeys and Keyboard Operations for Editor

Front-panel keys
Arrow keys Move the cursor
Delete Delete character
Recall Recall most recently deleted line
External Keyboard
Esc Exit editor
F1 to F8 Primary softkeys
Shift+ F1 to F7 Secondary softkeys
F9 Toggle screen mode
F11 Clear to end
Insert Insert line
Delete Delete character at cursor
Shift+Delete Delete line
Home Beginning of line
End End of line
Page Up or Page Down Scroll pages
Primary Softkeys
Back space Delete character before cursor
Insert line Insert line
Delete line Delete line
Re-number Renumber the lines
Indent Indent the line
Scratch Clear program
End edit Exit editor
1-14 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 29
Using Instrument BASIC

Other Basic Features of IBASIC

Other Basic Features of IBASIC
This section describes the following:
Branching/Repeating
Subprograms and COM Blocks

Branching/Repeating

Branch and Repeat Keywords of IBASIC are shown in the following table:
IBASIC Keyword Function
FOR, NEXT Repeat specified number of times.
IF THEN, ELSE, END IF Branch.
WHILE, END WHILE Repeat until specified condition is false.
REPEAT, UNTIL Repeat until specified condition is true.
Following program tests 1000 devices, and judges them pass or fail.
1 COM Data(1:1000) 2 DIM Id(1:1000) 10 EXECUTE ("GETSETUP 'SAMPL.MES'") 20 FOR I=1 TO 1000 30 EXECUTE ("SINGLE") 40 EXECUTE ("READDATAVAR'Id'") 50 IF Id(I)<1E-6 THEN 60 PRINT "FAIL LOWER" 70 Data(I)=1 80 ELSE 90 IF Id(I)>1E-4 THEN 100 PRINT "FAIL HIGHER" 110 Data(I)=2 120 ELSE 130 PRINT "PASS" 140 Data(I)=0 150 END IF 160 END IF 170NEXTI 180 CALL Save_data 190 END 200! 210 SUB Save_data 220 COM Data(*) 230 CREATE "data_file",1 240 ASSIGN @File TO "data_file";FORMAT ON 250 OUTPUT @File;Data(*) 260 ASSIGN @File TO * 270 SUBEND
Agilent 4155B/4156B Programmers Guide, Edition 4 1-15
Page 30
Using Instrument BASIC Other Basic Features of IBASIC

Subprograms and COM Blocks

One of the most powerful constructs available is the subprogram. A subprogram has its own "context" or state that is distinct from the main program and all other subprograms. There are several benefits of subprograms.
The subprogram allows you to take advantage of the "top-down design" method of programming.
You can remove all subtasks from the overall logic flow of the main program.
You can debug the program by testing each subprogram independently.
The subprograms can be used to reduce the overall size of the program.
Libraries of commonly used subprograms can be assembled for widespread use.
Refer to the example program in the previous section. Line 180 calls a subprogram to store data into a DOS file.
: : 160 END IF 170NEXTI 180 CALL Save_data 190 END 200! 210 SUB Save_data 220 COM Data(*) 230 CREATE "data_file",1 240 ASSIGN @File TO "data_file";FORMAT ON 250 OUTPUT @File;Data(*) 260 ASSIGN @File TO * 270 SUBEND
COM blocks
COM blocks are used by the subprogram to communicate with the main program or with other subprograms.
If you create subprograms and want to use common variables between main program and subprograms, you should use COM blocks.
Refer to the above example.
In the main program, line 1 declares that the Data array will be a COM array. Then, the main program assigns values to this array. Line 220 specifies that the subprogram Save_data will also use the Data array. So, Data array of main program can be operated on in the Save_data subprogram.
1-16 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 31

IBASIC Basic Operation Tasks

IBASIC Basic Operation Tasks
This section describes the following basic operations to use the Instrument BASIC.
1. Executing the Instrument BASIC commands
2. Executing program
3. Listing files
4. Retrieving program
5. Saving program
Step 1 Executing the Instrument BASIC Commands
1. Confirm your 4155B/4156B is in the following status:
a program is not executing.
another command is not executing.
Editor is not running.
Using Instrument BASIC
the screen is "All IBASIC" screen or "IBASIC Status" screen. For "All Instrument" screen,
Ctrl+P (Pause) on external keyboard are available.
2. Type in commands by using front-panel keys in the ENTRY key group or external keyboard.
3. Press
Enter front-panel key or Enter key on external keyboard.
Step 2 Executing Program
To execute the program, perform one of the following instruction:
From instrument front panel, press group.
From external keyboard, press
Agilent 4155B/4156B Programmers Guide, Edition 4 1-17
Run and Pause front-panel keys and Ctrl+U (Run) and
Run front-panel key in the IBASIC key
Ctrl+U on external keyboard.
Page 32
Using Instrument BASIC IBASIC Basic Operation Tasks
Step 3 Listing Files
1. Confirm your 4155B/4156B is in the following status:
the screen is "All IBASIC" screen.
a program is not executing.
another command is not executing.
Editor is not running.
2. Insert a 3.5 inch diskette (that contains the files you want to list) into the built-in flexible disk drive.
3. Select CAT secondary softkey, then press
The file names on diskette are listed on the screen.
Step 4 Retrieving Program
1. Confirm your 4155B/4156B is in the following status:
the screen is "All IBASIC" screen or "IBASIC Status" screen.
a program is not executing.
another command is not executing.
Editor is not running.
2. Insert the 3.5 inch diskette (that contains the program you want to retrieve) into the built-in flexible disk drive.
3. Select GET "" secondary softkey.
4. Type in file name to be retrieved. Typed name is inserted after first ".
5. Press
Enter front-panel key, or Enter key on external keyboard.
NOTE External disk drive
An external disk drive cannot be connected to the 4155B/4156B. For using a disk drive connected to external controller, see Controlling IBASIC from External Computer on page 1-24.
Enter front-panel key.
1-18 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 33
Step 5 Saving Program
1. Confirm your 4155B/4156B is in the following status:
the screen is "All IBASIC" screen or "IBASIC Status" screen.
a program is not executing.
another command is not executing.
Editor is not running.
2. Insert a 3.5 inch diskette into the built-in flexible disk drive.
3. Select SAVE "" secondary softkey.
4. Type in name of file to which you want to save program.
If the file already exists on the diskette, SAVE cannot be used. If you want to overwrite an existing file, select RE-SAVE secondary softkey instead of SAVE secondary softkey in the previous step.
Using Instrument BASIC
IBASIC Basic Operation Tasks
5. Press
Enter front-panel key or Enter key on the external keyboard.
NOTE External disk drive
An external disk drive cannot be connected to the 4155B/4156B. For using a disk drive connected to external controller, see Controlling IBASIC from External Computer on page 1-24.
Agilent 4155B/4156B Programmers Guide, Edition 4 1-19
Page 34
Using Instrument BASIC IBASIC Editor Tasks

IBASIC Editor Tasks

This section describes the following tasks to use built-in editor of the Instrument BASIC.
1. Starting the editor
2. Quitting the editor
3. Moving the cursor
4. Inserting characters
5. Deleting character
6. Inserting line
7. Deleting line
8. Scrolling pages
9. Recalling most recently deleted line
Step 1 Starting the Editor
1. Confirm the screen is "All IBASIC" screen or "IBASIC Status" screen.
2. Select EDIT secondary softkey.
3. Press
4. If a program is loaded into the 4155B/4156B, the program is displayed.
If you start the editor from the "IBASIC Status" screen, the screen switches to "All IBASIC" screen, and the editor starts.
Step 2 Quitting the Editor
Select End edit primary softkey.
If you started the editor from the "IBASIC Status" screen, the screen returns from "All IBASIC" screen to the "IBASIC Status" screen after you quit the editor.
1-20 Agilent 4155B/4156B Programmers Guide, Edition 4
Enter front-panel key or Enter key on the external keyboard.
If you want to start the editor to edit a specific program line, type in the line number or label of the program line, then press starts, and cursor is displayed on specified line.
If no program is loaded, 10 is automatically displayed and rest of screen is empty.
Enter front-panel key. The editor
Page 35
Step 3 Moving the Cursor
To move the cursor, use the following keys.
Direction Front-panel Keyboard
Up Ý key of MARKER/CURSOR group Ý key
Down ß key of MARKER/CURSOR group ß key
Right Þ key of ENTRY group Þ key
Using Instrument BASIC
IBASIC Editor Tasks
Rotate rotary knob counter-clockwise
Rotate rotary knob clockwise
Left Ü key of ENTRY group Ü key
Beginning of Line FAST+ Ü of MARKER/CURSOR group Home
End of Line FAST+ Þ of MARKER/CURSOR group End
Step 4 Inserting Characters
1. Move the cursor to character you want to insert before.
2. Characters you type will be automatically inserted.
3. After you insert characters, you must select the inserted characters into the program.
Editor is always in insert mode, and cannot be changed to overwrite mode.
Þ key of MARKER/CURSOR group
Ctrl+F
Ü key of MARKER/CURSOR group Ctrl+B
Shift
+ Ü
Shift
+ Þ
Enter key to enter the line with
Agilent 4155B/4156B Programmers Guide, Edition 4 1-21
Page 36
Using Instrument BASIC IBASIC Editor Tasks
Step 5 Deleting Character
1. Move the cursor to character you want to delete.
2. Press key according to the following table:
Delete of ENTRY group Delete
Front-panel Keyboard
3. After you delete characters, you must select the deleted characters into the program.
Step 6 Inserting Line
1. Move the cursor to the line that you want to insert a new line before.
2. Press key or softkey according to following table:
3. After you type in a new line, you must select the into the program.
Step 7 Deleting Line
1. Move the cursor to line you want to delete.
2. Press key or softkey according to the following table:
Front-panel Keyboard
Insert line primary softkey
Front-panel Keyboard
Delete line primary softkey
Enter key to enter the line with
Shift+Insert
Alt
+I
Enter key to enter the new line
Shift+Delete
Alt
+D
1-22 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 37
Step 8 Scrolling Pages
To scroll the editor by one-half screen, use the following keys:
Using Instrument BASIC
IBASIC Editor Tasks
Direction Front-panel Keyboard
Up n.a.
Down n.a. Page Down
Step 9 Recalling Most Recently Deleted Line
To display the line most recently deleted line, use the following keys.
Front-panel Keyboard
Recall
¯
Shift+Page Up
If you want to enter the line into the program, you must select the
Page Up
Enter key.
Agilent 4155B/4156B Programmers Guide, Edition 4 1-23
Page 38
Using Instrument BASIC Controlling IBASIC from External Computer

Controlling IBASIC from External Computer

This section describes how to control the IBASIC program on the 4155B/4156B from a program that is running on an external computer:
Controlling execution of a 4155B/4156B program.
Downloading a program to the 4155B/4156B.
Uploading a program from the 4155B/4156B.
Before executing a program on external computer to control the 4155B/4156B, do as follows:
1. Connect an GPIB cable from the external computer to the GPIB connector on rear panel of the 4155B/4156B.
2. Set the "4155B/4156B is" field on the SYSTEM: MISCELLANEOUS screen to NOT SYSTEM CONTROLLER.
3. Enter the GPIB address of your 4155B/4156B into the GPIB ADDRESS field.
Step 1 To Control State of the 4155B/4156B Program
:PROGram[:SELected]:STATe command from external computer can control the Instrument BASIC program in the 4155B/4156B as follows:
To run the program:
OUTPUT @Hp4155;":PROGram[:SELected]:STATe RUN"
To continue the program:
OUTPUT @Hp4155;":PROGram[:SELected]:STATe CONT"
To stop the program:
OUTPUT @Hp4155;":PROGram[:SELected]:STATe STOP"
To pause the program:
OUTPUT @Hp4155;":PROGram[:SELected]:STATe PAUSE"
1-24 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 39
Controlling IBASIC from External Computer
Step 2 To Download a Program to the 4155B/4156B
To download a program from the external computer to the 4155B/4156B, you need to use the :PROGram[:SELected]:DEFine command.
The following is an example of an HP BASIC program (running on external computer) that reads an Instrument BASIC program file (ASCII file stored in a disk drive connected to external computer) and downloads it to the 4156B.
10 OPTION BASE 1 20 ! 30 DIM Line$[1024] 40 ! 50 ASSIGN @Hp4156 TO 717 60 ! 70 OUTPUT @Hp4156;":PROG:DEL:ALL" !Clears program in 4156B 80 File_name$="prog" 90 ASSIGN @File TO File_name$ !Opens file and assigns dat a path 100 OUTPUT @Hp4156;":PROG:DEF #0" !Sends header to 4156B 110 ON ERROR GOTO Done 120 LOOP 130 Line$="" 140 ENTER @File;Line$ !Reads one program line 150 OUTPUT @Hp4156;Line$ !Downloads line to 4156B 160 END LOOP 170 Done:! 180 OFF ERROR 190 OUTPUT @Hp4156;Line$ 200 OUTPUT @Hp4156;" " END 210 ASSIGN @File TO * 220 END
Using Instrument BASIC
Line
Number
Description
50 assigns I/O path to control the 4155B/4156B.
70 deletes existing the Instrument BASIC program in the 4155B/4156B.
80 name of file (in disk drive of external computer) that contains desired the
Instrument BASIC program
90 opens file and assigns data path
100 #0 indicates that an indefinite length of parameters (program lines) will be
downloaded
110 to 160 reads program lines from the file and downloads them until EOF.
210 closes file.
Agilent 4155B/4156B Programmers Guide, Edition 4 1-25
Page 40
Using Instrument BASIC Controlling IBASIC from External Computer
Step 3 To Upload a Program from the 4155B/4156B
To upload a program from the 4155B/4156B to external computer, you need to use the :PROGram[:SELected]:DEFine? command.
The following is an example of an HP BASIC program (running on external computer) that uploads an Instrument BASIC program (ASCII file) from the 4156B and stores the program on a disk drive that is connected to external computer.
10 OPTION BASE 1 20 ! 30 DIM Num_dig$[2] 40 INTEGER Byte 50 ! 60 ASSIGN @Hp4156 TO 717 70 ! 80 OUTPUT @Hp4156;":PROG:DEF?" 90 ENTER @Hp4156 USING "%,2A";Num_dig$ 100 PRINT Num_dig$ 110 ! 120 Byte=VAL(Num_dig$[2]) 130 ! 140 ALLOCATE Data_byt$[Byte] 150 ! 160 FOR I=1 TO Byte 170 ENTER @Hp4156 USING "#,A";Data_byt$[I;1] !Enter length of p rogram 180 NEXT I 190 ! 200 D=VAL(Data_byt$) 210 PRINT D 220 ALLOCATE Prog$[D] 230 PRINTER IS CRT;WIDTH D 240 ENTER @Hp4156 USING "-K";Prog$ !Enter the program
into Prog$ 250 PRINT Prog$ 260 ENTER @Hp4156;B$ 270 PRINT B$ 280 ! 290 CREATE "prog",1 300 ASSIGN @File TO "prog";FORMAT ON 310 OUTPUT @File;Prog$ 320 ASSIGN @File TO * 330 ! 340 END
1-26 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 41
Using Instrument BASIC
Controlling IBASIC from External Computer
Line
Number
60 Assigns I/O path to control the 4155B/4156B.
80 Sends :PROGram[:SELected]:DEFine? query command.
90 Reads first two characters of response. These two bytes indicate how many
bytes are used to specify length of program.
160 to 180 Reads the bytes that specify length of program.
200 Calculates length of program.
220 Allocates string variables for program.
240 Reads program.
260 Reads terminator.
290 Creates file "prog"
300 Assigns I/O path to "prog"
310 Stores program into "prog" file.
320 Closes file.
Description
Agilent 4155B/4156B Programmers Guide, Edition 4 1-27
Page 42
Using Instrument BASIC IBASIC Screen

IBASIC Screen

The 4155B/4156B provides the following three screen modes for operating IBASIC.
"All IBASIC" screen
Entire screen including softkeys is used for IBASIC, so no instrument setup screen is displayed.
You can execute programs, but no instrument setup screen appears in this mode.
"IBASIC Status" screen
Softkeys and bottom two lines are used for IBASIC. Rest of screen is for instrument setup screen.
In this mode, you can start the IBASIC editor. The displayed softkeys are for IBASIC operation. You can execute IBASIC commands interactively. Characters you type are displayed at the bottom of the screen.
"All Instrument" screen
.This is regular instrument screen and the default display mode at power on. Entire screen is for instrument setup screen, and all softkeys are for interactive use of instrument. In this mode, you cannot use the IBASIC editor. Only the front-panel keys of IBASIC key group and external keyboard are available to execute or pause program for IBASIC from this screen mode.
Ctrl+U (Run) and Ctrl+P (Pause) on
Display front-panel key or Ctrl+G (or F9) on external keyboard are used to toggle the
screen display mode as shown in the following figure:
1-28 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 43
Using Instrument BASIC
IBASIC Screen

All IBASIC Screen

For the "All IBASIC" screen, the entire screen including softkeys is used for IBASIC. The following describes each part of this screen:
IBASIC Output Area
Command Entry Line
System Message and Display Line
Execution Status This field displays the execution status of IBASIC:
Screen output commands of IBASIC (such as PRINT and OUTPUT 1;) display characters in this area. This area has 23 lines and 58 columns (58 characters in a line).
IBASIC command you type is displayed on this line. The length of this line is 58 characters.
For displaying IBASIC error messages and other system messages, and DISP and INPUT commands of IBASIC.
Idle IBASIC program is stopped. IBASIC commands can be executed.
Run IBASIC program or command is being executed.
Pause IBASIC program is paused.
Input? IBASIC program is waiting for input from front-panel keys or external
keyboard.
Edit IBASIC editor is running.
Agilent 4155B/4156B Programmers Guide, Edition 4 1-29
Page 44
Using Instrument BASIC IBASIC Screen
Blue Key & Green Key Shift Status
This field displays the shift status of ENTRY front-panel keys. The shift status is controlled by using the blue and green front-panel keys:
The following statuses are displayed:
Non-shift status: B, b, or G is not displayed. You can enter numeric values.
Uppercase shift status: B is displayed, G is not displayed. You can enter
uppercase alphabet characters.
Lowercase shift status: b is displayed. G is not displayed. You can enter
lowercase alphabet characters.
Non-alphanumeric status: G is displayed. You can enter one non-alphanumeric
character. So, you must press green key before entering each alphanumeric character.
Basically, you can change between these states as follows:
To toggle between non-shift and shift status: press blue key,
To toggle between uppercase and lowercase shift status: press green key, then
blue key.
To enter one non-alphanumeric character: press green key, then character.
1-30 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 45
Using Instrument BASIC
IBASIC Screen

IBASIC Status Screen

For the "IBASIC Status" screen, the two bottom lines are used to display the status of IBASIC. These two lines are the same as in "All IBASIC" screen. Refer to “All IBASIC Screen on page 1-29. Also, the softkeys are for IBASIC.
The other part of the screen is the normal 4155B/4156B screen. This is useful if you want to view a graph of the measurement results while executing IBASIC program.
Agilent 4155B/4156B Programmers Guide, Edition 4 1-31
Page 46
Using Instrument BASIC Keys for IBASIC

Keys for IBASIC

This section provides information about the following keys for IBASIC:
Front-panel Keys
Primary Softkeys
Secondary Softkeys
External Keyboard Keys

Front-panel Keys for IBASIC

PAGE CONTROL key group
MARKER/CURSOR key group
In "IBASIC Status" screen:
Changes to "All Instrument" screen and displays the specified screen.
In "All IBASIC" screen:
All front-panel keys in this group are ignored.
In "IBASIC Status" screen:
When you operate MARKER/CURSOR front-panel keys, the screen changes to "All Instrument" screen and function of operated key is executed.
In all IBASIC screen:
Rotary Knob When the editor is running, the rotary knob moves the
cursor vertically in the edit area.
When the editor is not running, the rotary knob scrolls the IBASIC output area.
Ý, ß When the editor is running, these keys move the cursor
vertically.
When the editor is not running, these keys scroll the IBASIC output area.
Ü, Þ Moves the cursor horizontally on the IBASIC Editor or
Command Entry line.
If you hold down the
1-32 Agilent 4155B/4156B Programmers Guide, Edition 4
Fast key, the arrow keys move the cursor faster.
Page 47
Using Instrument BASIC
Keys for IBASIC
MEASUREMENT key group
In "IBASIC Status" screen:
Single, Repeat,Append Changes the display to GRAPH/LIST: GRAPHICS or
GRAPH/LIST: LIST screen and executes the measurement.
Standby Toggles the operation state of the standby channels between
the standby state and the idle state.
Stop Stops the measurement or stress forcing.
Stre ss Changes the display to the STRESS: STRESS FORCE
screen and starts to force stress.
Short, Medium,Long Changes the measurement integration time.
In "All IBASIC" screen:
Standby Toggles the operation state of the standby channels between
the standby state and the idle state.
Stop Stops the measurement or stress forcing.
Other front-panel keys in this group are ignored.
IBASIC key group The following front-panel keys of IBASIC key group are available to control
IBASIC in any display mode.
Run Executes IBASIC program that is loaded into internal memory
of the 4155B/4156B.
Pause Pauses program execution until CONT command is executed or
Continue primary softkey is pressed. If the program is modified while paused, RUN command must be used to restart program execution.
Display Toggles the display mode in the following sequence.
Agilent 4155B/4156B Programmers Guide, Edition 4 1-33
Page 48
Using Instrument BASIC Keys for IBASIC
ENTRY key group Recall¯ When the editor is running, this key displays the last deleted
line. To enter this displayed line as part of the program, press
Enter front-panel key.
When the editor is not running, this key cycles through the 10 commands that were most recently entered on the Command Entry line.
Recall
When the editor is running, this key is same as Recall¯.
When the editor is not running, this key is same as
Recall
,
¯
but cycles through commands in opposite order.
Save, Get These keys are ignored.
Other front-panel keys in ENTRY group are available to enter characters on the Command Entry line or Editor. For the usage of the blue and green front-panel keys to enter characters, see “All IBASIC Screen” on page 1-29.
Other Keys
Help Displays information about IBASIC. And can be used to select
and enter SCPI and IBASIC commands into Editor or Command Entry line.
Plot/Print If present screen is "All IBASIC", dumps "All IBASIC" screen
image to the printer or plotter.
If present screen is "IBASIC Status", prints/plots instrument part of screen.
1-34 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 49
Using Instrument BASIC
Keys for IBASIC

Primary Softkeys in Idle, Pause, Run, or Input? execution status

This section describes the primary softkeys that are displayed during the Idle, Pause, Run, or Input? execution status.
Refer to Primary Softkeys in Edit execution status” on page 1-37 for primary softkeys that are displayed when the editor is running.
Step 1. Executes the paused program line of paused program or the first program line of
stopped (idle) program.
2. Displays next program line on system message line of the screen.
3. Pauses program again.
Conti-nue Starts execution of paused program from paused program line.
RUN Starts program execution immediately from first program line.
Pause Pauses program execution immediately. And displays line at which execution was
paused.
Stop Stops program execution after current line executes.
Clear I/O Stops I/O operation of program.
Reset Stops program execution immediately.
Agilent 4155B/4156B Programmers Guide, Edition 4 1-35
Page 50
Using Instrument BASIC Keys for IBASIC

Secondary Softkeys in Idle or Pause execution status

This section describes the secondary softkeys that are displayed during the Idle or Pause execution status.
For the secondary softkeys that are displayed during the Run or Input? status, refer to Secondary Softkeys in Run or Input? execution status on page 1-37.
For the secondary softkeys that are displayed when the editor is running, refer to Secondary Softkeys in Edit execution status on page 1-38.
CAT Clears the Command Entry line, and types in CAT.
To list file names on the diskette, press
SAVE "" 1. Clears the Command Entry line.
2. Types in SAVE " ".
3. Positions the cursor after first ".
To save program to diskette, type name of file to which you want to save program, then press
Enter.
If file already exists on diskette, program will not be saved.
RE-SAVE "" 1. Clears the Command Entry line.
2. Types in RE-SAVE " ".
3. Positions the cursor after first ".
To save program to diskette, type name of file to which you want to save program, then press
Enter.
If file already exists on diskette, file will be overwritten, so previous data in file is lost.
GET "" 1. Clears the Command Entry line.
2. Types in GET " ".
3. Positions the cursor after first ".
Enter.
To get a program from diskette, type name of file to get, then press
Enter.
1-36 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 51
PURGE "" 1. Clears the Command Entry line.
2. Types in PURGE " ".
3. Positions the cursor after first ".
Using Instrument BASIC
Keys for IBASIC
To delete a file from diskette, type in the file name to be deleted, then press
EDIT Clears the Command Entry line and types in EDIT. To start the editor, press
front-panel key.
REN umber Clears the Command Entry line and types in REN.
To re-number lines of a program, type in appropriate parameters, then press For more details about REN command, refer to the Instrument BASIC User's Handbook.

Secondary Softkeys in Run or Input? execution status

When the execution status is Run or Input?, user-defined softkeys, which are defined by using ON KEY command in the program, are displayed in the secondary softkey area.

Primary Softkeys in Edit execution status

This section describes the primary softkeys that are displayed when the IBASIC editor is running (Edit execution status is displayed).
Back space Deletes the character before the cursor.
Insert line Inserts a line between the cursor line and the previous line.
Enter.
Enter
Enter.
Delete line Deletes the cursor line.
Re-number Changes the program line numbers so that first line is 10 and line number increment
is 10.
Indent Indents so that all program lines begin at the same position.
Scratch Clears the program and all variables not in COM. Before clearing, YES and NO
secondary softkeys are displayed for confirmation.
End edit Exits the editor.
Agilent 4155B/4156B Programmers Guide, Edition 4 1-37
Page 52
Using Instrument BASIC Keys for IBASIC

Secondary Softkeys in Edit execution status

This section describes the secondary softkeys that are displayed when the IBASIC editor is running (Edit execution status is displayed).
These softkeys help you enter program commands. For commands that require you to type in some parameters, these softkeys display the command. You must enter the parameters, then you must press For commands that do not have parameters, the commands are entered directly into the program. Commands are entered at the cursor line.
For the EXECUTE command, refer to “EXECUTE” in Chapter 5 for details.
For secondary softkeys that are displayed during Idle or Pause execution status, refer to Secondary Softkeys in Idle or Pause execution status on page 1-36.
For secondary softkeys that are displayed during Run or Input? execution status, refer to Secondary Softkeys in Run or Input? execution status on page 1-37.
In Edit execution status, there are three kinds of secondary softkey menu. To move to next menu, press MORE secondary softkey.
GET SETUP 1. Displays the following program line for loading a setup file:
Enter key to enter the command into the program.
EXECUTE("GETSETUP ")
2. Positions cursor at second double quotes. You enter the file name to be loaded, then select
Enter key.
SINGLE Enters the following program line for triggering a single measurement:
EXECUTE("SINGLE")
STANDBY 1. Displays the following program line for changing the operation state of the
standby channels:
EXECUTE("STANDBY ")
2. Positions the cursor at the second double quote. You enter ON or OFF, then select
Enter key.
STRESS Enters the following program line for triggering stress force:
EXECUTE("STRESS")
AUTO SCALE Enters the following program line for autoscaling:
EXECUTE("AUTOSCALE")
1-38 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 53
Using Instrument BASIC
Keys for IBASIC
SAVE DATA 1. Displays the following program line for saving measurement data to a file:
EXECUTE("SAVEDATA ")
2. Positions the cursor at the second double quote. You enter file name to which you want to save measurement data, then select
Enter key.
READ DATA VARIA BL
1. Displays the following program line for reading the values of an 4155B/4156B data variable, then storing the values into an IBASIC program variable:
EXECUTE("READDATAVAR ,")
2. Positions the cursor at the comma. You enter names of the 4155B/4156B data
DEFINE USER VARIA BL
variable and IBASIC program variable, then select
1. Displays the following program line for defining a user variable:
EXECUTE("DEFUSERVAR ,,,")
Enter key.
2. Positions the cursor at the first comma. You enter the user variable name, number of data, name of IBASIC program variable that contains desired data, and user variable unit, then select
Enter key.
PRINT/PLOT Enters following program line for printing/plotting the instrument window:
EXECUTE("PRINTPLOT")
CURVE PLOT Enters following program line for printing/plotting a graphics plot of measurement
results:
EXECUTE("CURVEPLOT")
OUTPUT @Hp415x 1. Displays the following program line for outputting a command to the
4155B/4156B:
OUTPUT @Hp415x;""
2. Positions the cursor at the second double quotes. You enter desired command, then select
Enter key.
ENTER @Hp415x 1. Displays the following program line for entering data from the 4155B/4156B:
ENTER @Hp415x;
2. Positions the cursor after the semicolon. You enter desired variable, then select
Enter key.
Agilent 4155B/4156B Programmers Guide, Edition 4 1-39
Page 54
Using Instrument BASIC Keys for IBASIC
PAUSE Enters the following program line for pausing a program:
PAUSE
DISP 1. Displays the following program line for displaying a message:
DISP ""
2. Positions the cursor at the second double quotes. You enter the message that you want to display, then select
Enter key.
INPUT 1. Displays the following program line for assigning keyboard input to program
variable:
INPUT "",
2. Positions the cursor at the second double quote. Enter string that you want to be displayed on the screen, and name of variable in which you want to store keyboard input, then select
Enter key.
IF THEN ELSE END IF
1. Displays the following program lines for conditional branching:
IF THEN ELSE END IF
2. Positions the cursor before THEN. Fill in as desired, then select Enter key.
WHILE END WHILE
1. Displays the following program lines for defining a loop:
WHILE END WHILE
2. Positions the cursor after WHILE. Fill in as desired, then select Enter key.
FOR NEXT 1. Displays the following program lines for defining a loop:
FOR=TO STEP NEXT
2. Positions the cursor at =. Fill in as desired, then select Enter key.
1-40 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 55
Using Instrument BASIC
Keys for IBASIC

External Keyboard

You can connect an external keyboard to the 4155B/4156B and use to enter text.
Also, you can use the keyboard for other tasks as described in this chapter.
In this section, the notation "
Esc Exits the editor.
F1 through F8 Primary softkeys. Corresponds to the primary softkeys.
Shift+ F1 through F7 Secondary softkeys. Corresponds to the secondary softkeys.
F9 Screen mode. Same as Ctrl+G. Toggles the screen mode as follows:
F11 Clear to end. Deletes characters from cursor to end of line. Same as Ctrl+Delete
Shift
+F11 Clear line.
When editor is running, same as
KeyA+KeyB" means to hold down KeyA and press KeyB.
F11.
When editor is not running, deletes characters on the Command Entry line.
F12 Clear display. Clears the display for IBASIC. When the editor is running, exits from
the editor, and clears the display for IBASIC.
Print Screen Clear I/O. Stops I/O operation of program.
Scroll Lock Stop. Stops program execution after executing the current line. Same as Shift+Pause.
Shift+Scroll Lock Reset. Stops program execution immediately.
Pause Pause. Same as Ctrl+P. Pauses program execution until CONT is executed or
Continue primary softkey is pressed. If the program is modified while paused, RUN must be used to restart program execution.
Shift+Pause Stop. Stops program execution after executing the current line. Same as Scroll Lock .
Agilent 4155B/4156B Programmers Guide, Edition 4 1-41
Page 56
Using Instrument BASIC Keys for IBASIC
Insert Insert. Same as Alt+I.
When the editor is running, opens a new line before the current line.
When the editor is not running, inserts text at the cursor (press
Insert again to end
insert mode).
Shift+Insert Insert. Same as Insert.
Delete Delete. Deletes character at the cursor.
Shift+Delete Delete line. Same as Alt+D.
When the editor is running, deletes the current line.
When the editor is not running, deletes character at cursor.
Ctrl+Delete Clear to end. Deletes characters from cursor to end of line. Same as F11.
Home Beginning of line. Moves the cursor to beginning of the line. Same as Shift+ Ü.
Shift+Home Page move.
When the editor is running, same as
Page Up. Also, same as Shift+ Ý.
When the editor is not running, jumps to the top of the IBASIC output area. Also, same as
End End of line. Moves cursor to end of line. Same as Shift+ Þ.
Shift+End Page move.
Shift+ ß.
When the editor is running, same as
When the editor is not running, jumps to the bottom of the IBASIC output area. Same as
Page Up Page move.
Shift+ Ý.
When the editor is running, moves the cursor one-half display page toward the beginning of the program. Same as
When the editor is not running, moves display down one page.
1-42 Agilent 4155B/4156B Programmers Guide, Edition 4
Page Down. Also, same as Shift+ ß.
Shift+Home. Same as Shift+ Ý.
Page 57
Shift+Page Up Recall.
When the editor is running, displays last deleted line. To enter line into program, press
Enter.
When the editor is not running, cycles through the 10 commands that were most recently entered on the Command Entry line.
Page Down Page move.
When the editor is running, moves the cursor one-half display page toward the end of the program. Same as
When the editor is not running, moves display up one page.
Shift+Page Down Recall backward.
Using Instrument BASIC
Keys for IBASIC
Shift+End. Same as Shift+ ß.
When the editor is running, same as
When the editor is not running, cycles through the 10 commands that were most recently entered on the Command Entry line in reverse order of
Ý Previous line.
When the editor is running, moves cursor up one line.
When the editor is not running, display on the IBASIC output area moves one line toward the end.
Shift+Ý Page move.
When the editor is running, same as
When the editor is not running, jumps to the bottom of the IBASIC output area. Same as
Alt+Ý Recall backward.
Shift+End.
When the editor is running, same as
When the editor is not running, same as
ß Next line.
When the editor is running, cursor moves down one line.
Shift+Page Up.
Shift+Page Up.
Page Up. Also, same as Shift+Home.
Shift+Page Up.
Shift+Page Down.
When editor is not running, display on IBASIC output area moves one line toward beginning.
Agilent 4155B/4156B Programmers Guide, Edition 4 1-43
Page 58
Using Instrument BASIC Keys for IBASIC
Shift+ ß Page move.
When the editor is running, same as
Page Down. Also, same as Shift+End.
When the editor is not running, jumps to the top of the IBASIC output area. Same as
Shift+Home.
Alt+ ß Recall. Same as Shift+Page Up.
Ü, Þ Move cursor. Moves the cursor one character in indicated direction.
Shift+ Ü Beginning of line. Moves the cursor to beginning of line. Same as Home.
Shift+ Þ End of line. Moves the cursor to end of line. Same as End.
Backspace Backspace.
When the editor is running, deletes the character before cursor.
When the editor is not running, deletes the character before cursor (if mode is insert mode). If mode is not insert move, moves cursor to left by one cursor.
Alt+D Delete line. Same as Shift+Delete.
When the editor is running, deletes the current line.
When the editor is not running, deletes the character at the cursor.
Alt+I Insert line. Same as Insert.
When the editor is running, opens a new line before the current line.
When the editor is not running, inserts text at the cursor (press
Insert again to end
insert mode).
Ctrl+U Run. Executes the program.
Ctrl+P Pause. Same as Pause. Pauses program execution until CONT is executed or Continue
primary softkey is pressed. If the program is modified while paused, RUN must be used to restart program execution.
Ctrl+G Screen mode. Same as F9. Toggles the screen mode as follows:
1-44 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 59
Using Instrument BASIC

4155B/4156B Specific IBASIC Keywords

4155B/4156B Specific IBASIC Keywords
The following keywords are not standard IBASIC keywords, or are standard keywords, but with a difference. These keywords are specific to the 4155B/4156B.
EXECUTE Not standard IBASIC keyword. Refer to ASP-like
Commands” in Chapter 5 for details.
ON KEY Standard IBASIC keyword, except the range of key selector is 1
to 7. 1 to 7 of key selector corresponds to secondary softkeys 1 to 7, respectively.
PEN Standard IBASIC keyword, except the range of pen selector is
7. The following table shows the corresponding color for each pen selector.
pen
selector
1 color defined for Foreground on SYSTEM: COLOR SETUP screen.
2 color defined for Y1 Axis on SYSTEM: COLOR SETUP screen.
3 color defined for Y2 Axis on SYSTEM: COLOR SETUP screen.
4 color defined for Marker/Cursor/Line on SYSTEM: COLOR SETUP
screen.
5 color defined for Active Mkr/Csr/Lne on SYSTEM: COLOR SETUP
screen.
6 color defined for Advisory on SYSTEM: COLOR SETUP screen.
7 color defined for Title on SYSTEM: COLOR SETUP screen.
Color
Agilent 4155B/4156B Programmers Guide, Edition 4 1-45
Page 60
Using Instrument BASIC 4155B/4156B Specific IBASIC Keywords
The following IBASIC keywords are not implemented in the 4155B/4156B's Instrument BASIC.
ALPHA ON/OFF
AREA
CLIP
CONTROL
DUMP
EDGE
FILL
FRAME
GESCAPE
GLOAD
GRAPHICS
GRID
GSTORE
LINE TYPE
PLOTTER IS
POLYGON
POLYLINE
RATIO
RECTANGLE
SET PEN
SHOW
STATUS
VIEWPORT
WINDOW
1-46 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 61
Using Instrument BASIC

Available I/O Resources for IBASIC

Available I/O Resources for IBASIC
This section provides information about available I/O resources for IBASIC of the 4155B/4156B.
The following I/O resources are available for IBASIC.
LCD Display
External keyboard and front-panel keyboard
GPIB Interface on rear panel
Internal pseudo GPIB Interface (to control the 4155B/4156B itself)
Parallel Interface
Built-in Flexible Disk Drive (no select code)
The following table shows available I/O interfaces and their select codes.
Select Code Interface
1LCD
2 External and front-panel keyboard
7 GPIB Interface on rear panel
8 Internal pseudo GPIB Interface
9 Parallel Interface
LAN interface on the 4155B/4156B rear panel is not available for the built-in IBASIC.
Agilent 4155B/4156B Programmers Guide, Edition 4 1-47
Page 62
Using Instrument BASIC Available I/O Resources for IBASIC
LCD
IBASIC can display text or graphics on the display of the 4155B/4156B.
Following figure shows the display area image on the 4155B/4156B screen.
(0,479)*-----------------------------*----*(639,479)
||| ||| ||| ||| ||| ||| | Text Display Area | | ||| ||| ||| ||| ||| | (522,88)| |
(0,88)*-----------------------------* |
| Softkey Display Area | ||
(0,0)*----------------------------------*(639,0)
Graphics Display Area
(522,479)
Text display
Text can be displayed in the IBASIC output area of "All IBASIC" screen. This area has 23 lines and 58 columns (58 characters in a line), and does not covers the softkey display area.
The x and y coordinate values of the area are as follows:
lower left corner: (x,y)=(0,88)
upper right corner: (x,y)=(522,479)
The following table shows the area used to display a character. In this table, Reserved column shows the area captured to display a character. This area covers a character, and includes space between characters. Actual column shows the area for a character only.
1-48 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 63
Using Instrument BASIC
Available I/O Resources for IBASIC
Reserved Actual
Size (dots) 9 ´ 17 5 ´ 10
Lower Left Corner (9 ´ (N-1), 479 -17 ´ M) (9 ´ (N-1), 483 -17 ´ M)
Upper Right Corner (9 ´ N, 479 -17 ´ (M-1)) (9 ´ N-4, 476 -17 ´ (M-1))
where, N and M are integer value (N=1 to 58, M=1 to 23).
Graphics display
In "All IBASIC" screen, you can display a graphical plot.
The x and y coordinate values of this area are as follows:
lower left corner: (x,y)=(0,0)
upper right corner: (x,y)=(639,479)
This area covers the softkey display area.

GPIB Interfaces

Internal pseudo GPIB
By using select code 8, you can control the 4155B/4156B via internal pseudo GPIB interface. The GPIB address of the 4155B/4156B has no meaning, so you can use any address (0 through 30).
GPIB on rear panel
You can access GPIB interface on rear panel by using select code 7.

Parallel Interface

You can use parallel interface on the rear panel for the printer interface. Select code is 9.
Agilent 4155B/4156B Programmers Guide, Edition 4 1-49
Page 64
Using Instrument BASIC Available I/O Resources for IBASIC

Built-in Flexible Disk Drive

If you specify optional volume specifier when accessing the built-in flexible disk drive, the volume specifier must be ":INTERNAL,4".
Available diskettes
You can use the following types of 3.5 inch diskettes:
2HD 1.44 MB
2DD 720 KB
Diskette must be formatted as LIF or the following DOS format:
80 tracks/side
18 sectors/track (2HD), 9 sectors/track (2DD)
512 bytes/sector
1-50 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 65
Using Instrument BASIC

Differences from 4155A/4156A Programming

Differences from 4155A/4156A Programming
Programming differences between the 4155A/4156A and the 4155B/4156B come from the differences of the screen and the SCPI commands supported by the instruments.
For the most case, you can execute the IBASIC program created for the 4155A/4156A on the 4155B/4156B built-in IBASIC controller. But the following programs should be modified to execute on the 4155B/4156B's IBASIC controller.
Programs use both text display and graphics display.
Programs use the :HCOPy:DESTination command.
Programs use the :HCOPy:DEVice:LANGuage command.
This section provides the information to modify the program.
For the SCPI commands which the 4155A/4156A does not support but the 4155B/4156B supports, refer to Differences From 4155A/4156A SCPI Commands” in Chapter 2.
NOTE Using 4155B/4156B FLEX Command Set
If you use the 4155B/4156B FLEX command set, you cannot reuse the SCPI programs of the 4155A/4156A, and you need to create new program.
Refer to Chapter 3.
Agilent 4155B/4156B Programmers Guide, Edition 4 1-51
Page 66
Using Instrument BASIC Differences from 4155A/4156A Programming

Using Text Display and Graphics Display

By the difference of the screen, the 4155B/4156B display area is different from the 4155A/4156A as shown in the following table. So if you execute the IBASIC program for the 4155A/4156A on the 4155B/4156B built-in IBASIC controller, the graphics will lie on the text.
Modify the program by using the following information.
4155A/4156A 4155B/4156B
Text display
a
58 characters/line 58 characters/line
23 lines 23 lines
814 dots/character 917 dots/character
Graphics display
b
lower left (0,0) lower left (0,0)
upper right (546,399) upper right (639,479)
a. Text display area does not cover the softkey display area. b. Graphics display area covers the text display area and the softkey dis-
play area.
Following figure shows the display area image on the 4155B/4156B screen.
(0,479)*-----------------------------*----*(639,479)
||| ||| ||| ||| ||| ||| | Text Display Area | | ||| ||| ||| ||| ||| | (522,88)| |
(0,88)*-----------------------------* |
| Softkey Display Area | ||
(0,0)*----------------------------------*(639,0)
Graphics Display Area
(522,479)
1-52 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 67
Using Instrument BASIC
Differences from 4155A/4156A Programming
The following table shows the area used to display a character. In this table, Reserved column shows the area captured to display a character. This area covers a character, and includes space between characters. Actual column shows the area for a character only.
where, N and M are integer value (N=1 to 58, M=1 to 23).
Reserved Actual
Size (dots) 9 ´ 17 5 ´ 10
Lower Left Corner (9 ´ (N-1), 479 -17 ´ M) (9 ´ (N-1), 483 -17 ´ M)
Upper Right Corner (9 ´ N, 479 -17 ´ (M-1)) (9 ´ N-4, 476 -17 ´ (M-1))

Using :HCOP:DEST Command

From differences of the supported interfaces, the command parameters are different from the 4155A/4156A as shown below:
Model Serial Parallel GPIB LAN file
4155A/4156A SERial RDEVice MMEMory
4155B/4156B PARallel RDEVice NETn MMEMory
where, n is 1, 2, 3 or 4.
The meaning of the parameters is as follows:
SERial Selects serial interface.
PARallel Selects parallel interface.
RDEVice Selects GPIB interface.
NETn Selects a remote printer. n= 1, 2, 3 or 4.
MMEMory Not make hardcopy. Outputs to a file in the device specified by
the :MMEM:DEST command.
Agilent 4155B/4156B Programmers Guide, Edition 4 1-53
Page 68
Using Instrument BASIC Differences from 4155A/4156A Programming

Using :HCOP:DEV:LANG Command

Differences of the supported output format for the print/plot function make the differences on the command parameters as shown below.
Model PCL
4155A/4156A PCL HPGL
4155B/4156B PCL HRPCl HPGL TIFF HRTIff
a. high resolution PCL. b. high resolution TIFF.
The meaning of the parameters is as follows:
PCL Selects PCL format.
HRPCl Selects high resolution PCL format.
HPGL Selects HP-GL format.
TIFF Selects TIFF format. For file output only.
HRTIff Selects high resolution TIFF format. For file output only.
HR PCL
a
HP-GL TIFF
HR TIFF b
1-54 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 69

2 SCPI Command Programming

Agilent 4155B/4156B Programmers Guide, Edition 4
Page 70
SCPI Command Programming
Standard Commands for Programmable Instruments (SCPI) is a universal programming language for electronic test and measurement instruments, and based on IEEE 488.1 and IEEE488.2.
This chapter describes how to create programs that contain SCPI commands to control Agilent 4155B/56B, and consists of the following sections.
SCPI Programming Basics
Getting Started on SCPI Programming
Measurement Setup
Measurement Execution
File Operation
Data Transfer
Print/Plot Operation
Other Programming Tips
Example for 4145 Users
If you are not familiar with the 4155B/4156B programming, Getting Started on SCPI Programming” on page 2-8 provides step-by-step tutorials for programming and helps you to understand quickly.
In addition to this chapter, Sample Application Programs Guide Book provides some application examples which are helpful to increase your understanding.
Refer to SCPI Command Reference for the command syntax and description of the SCPI commands available for the 4155B/4156B.
2-2 Agilent 4155B/4156B Programmer’s Guide, Edition 4
Page 71

SCPI Programming Basics

This section provides the following basic tasks to control and program the 4155B/4156B:
Preparation before controlling the 4155B/56B via GPIB
SCPI Command Hierarchy
To control 4155B/4156B by HP BASIC programming

Preparation before Controlling 4155B/56B via GPIB

You can use an external computer or the built-in Instrument BASIC (IBASIC) controller to control the 4155B/4156B via GPIB.
NOTE Device Clear
The 4155B/4156B requires approx. 0.5 seconds for the GPIB device clear. For the HP BASIC or IBASIC, enter CLEAR command.
SCPI Command Programming
SCPI Programming Basics
Controlling from external computer
You must do as follows before controlling the 4155B/4156B from an external computer:
1. Connect the GPIB interface of external computer to GPIB interface on rear panel of the 4155B/4156B.
2. Set the 4155B/56B is field on the SYSTEM: MISCELLANEOUS screen to NOT SYSTEM CONTROLLER.
3. Enter the GPIB address of your 4155B/4156B into the GPIB ADDRESS field.
Agilent 4155B/4156B Programmers Guide, Edition 4 2-3
Page 72
SCPI Command Programming SCPI Programming Basics
Controlling from built-in IBASIC controller
If you use built-in IBASIC controller to control only the 4155B/4156B, you do not need to prepare anything before controlling the 4155B/4156B because built-in IBASIC controller is always connected to the 4155B/4156B via internal GPIB.
However, to control external instruments, do following:
1. Connect the GPIB interface of external instruments to GPIB interface on rear panel of the 4155B/4156B.
2. Set "4155B/56B is" field on the SYSTEM: MISCELLANEOUS screen to SYSTEM CONTROLLER.
To use the 4155B/4156B print/plot function, do following:
1. Connect printer/plotter to the 4155B/4156B.
2. If the printer/plotter interface is GPIB:
a. Set "4155B/56B is" field to SYSTEM CONTROLLER before executing
printing/plotting out.
b. Enter the GPIB address of printer/plotter into "GPIB ADDRESS" "HARD
COPY" field on the SYSTEM: MISCELLANEOUS screen.
3. If you use the remote printer connected to the print server:
a. Connect the 4155B/4156B to your LAN.
b. Set the "4155B/56B NETWORK SETUP" table and "NETWORK
PRINTER SETUP" table on the SYSTEM: MISCELLANEOUS screen.
To use the network file system on the NFS server, do following:
1. Connect the 4155B/4156B to your LAN.
2. Set the "4155B/56B NETWORK SETUP" table and "NETWORK DRIVE SETUP" table on the SYSTEM: MISCELLANEOUS screen.
2-4 Agilent 4155B/4156B Programmer’s Guide, Edition 4
Page 73

SCPI Command Hierarchy

SCPI commands use a hierarchical structure for subsystem commands similar to the file system.
For example, in :PAGE:MEASURE:SWEEP command, the hierarchy is as follows:
PAGE root
MEASURE sub-level 1
SWEEP sub-level 2
The colon at the beginning of the command means root. The colons between two command keywords means moving down to a lower level.
NOTE Using a Semicolon to Reduce Typing
A semicolon enables two commands to be sent on the same line.
For example, :PAGE:MEAS:VAR1:START 0;STOP 5 is the same as the following two commands:
:PAGE:MEAS:VAR1:START 0 :PAGE:MEAS:VAR1:STOP 5
So, using a semicolon reduces typing and simplifies the program.
SCPI Command Programming
SCPI Programming Basics
A command terminator (such as a <newline>) resets the path to root.
Agilent 4155B/4156B Programmers Guide, Edition 4 2-5
Page 74
SCPI Command Programming SCPI Programming Basics

To Control 4155B/56B by HP BASIC Programming

1. Assign I/O path for controlling the 4155B/4156B.
Use ASSIGN command to assign I/O path:
Built-in IBASIC
Specify select code 8. For the GPIB address, you can use any number between 0 to 31. Refer to the following example:
10 ASSIGN @Hp415x TO 800
HP BASIC on an external computer
Specify the select code of the external computer. And specify the GPIB address that you entered into the GPIB ADDRESS field on the SYSTEM: MISCELLANEOUS screen. In the following example, the select code of the external computer is 7 and GPIB address of the 4155B/56B is 17:
10 ASSIGN @Hp415x TO 717
2. Use OUTPUT command to send commands to the 4155B/4156B.
3. Use ENTER command to get query response from the 4155B/4156B.
2-6 Agilent 4155B/4156B Programmer’s Guide, Edition 4
Page 75
SCPI Command Programming
SCPI Programming Basics
Example
The following is the example program to control the 4155B/4156B:
10 DIM I3(1:501) 20 ! 30 ASSIGN @Hp415x TO 717 40 ! 50 OUTPUT @Hp415x;"*RST" 60 ! 70 OUTPUT @Hp415x;":MMEM:LOAD:STAT 0,'SWP.MES','DISK'" 80 ! 90 OUTPUT @Hp415x;":PAGE:SCON:SING" 100 OUTPUT @Hp415x;"*OPC?" 110 ENTER @Hp415x;Complete 120 ! 130 OUTPUT @Hp415x;":FORM:DATA ASC" 140 OUTPUT @Hp415x;":DATA? 'I3'" 150 ENTER @Hp415x;I3(*) 160 ! 170 END
Line Number Description
30 Assigns I/O path to control the 4155B/4156B.
50 Resets the 4155B/4156B by sending *RST command.
70 Loads measurement setup data from diskette file SWP.MES.
90 to 110 Executes measurement
130 to 150 Gets the measurement data
Agilent 4155B/4156B Programmers Guide, Edition 4 2-7
Page 76
SCPI Command Programming Getting Started on SCPI Programming

Getting Started on SCPI Programming

This section provides step-by-step tutorials for programming to control the 4155B/4156B along with programming examples. In this section, you do SCPI programming by using the built-in IBASIC.
This section consists of the following sections:
Creating a Simple Measurement Program
This section introduces how to create a measurement program.
Programming for Data Extraction
This section provides the programming tutorials for data extraction.
Complete Example Program for Vth Measurement
This section shows complete example program based on the parts described in the other sections.
Example Application Setup for Vth Measurement
This section describes an example application setup that you should save to the file named VTH.MES on diskette before executing program examples (that use VTH.MES) described in this section.
2-8 Agilent 4155B/4156B Programmer’s Guide, Edition 4
Page 77
SCPI Command Programming
Getting Started on SCPI Programming

Creating a Simple Measurement Program

This section introduces how to create a measurement program.
A simple measurement program created by using built-in IBASIC controller is provided as an example and you learn step-by-step how to create a measurement program.
This section consists of the following:
1. Getting a setup file from a diskette and making a measurement
2. Changing the sweep setup parameters
3. Changing the display setup parameters
4. Saving the measurement results to a diskette
5. Printing the measurement results
Before Creating a Program
This section assumes that you have already saved a measurement setup file for Vth measurement to diskette.
Prepare the diskette and save the measurement setup (described in “Example Application Setup for Vth Measurement” on page 2-26) to the file named "VTH.MES" on the diskette.
Before starting this section, do following:
1. If the 4155B/4156B has already been turned on, turn the 4155B/4156B off.
2. Connect a printer to the parallel interface or GPIB interface on the rear panel. You will use the printer at Step 5.
3. Turn the 4155B/4156B on.
4. Set the SYSTEM: PRINT/PLOT SETUP screen and SCREEN DUMP dialog as you want. Or set only the "DESTINATION" and "PAPER" fields on the SYTEM: PRINT/PLOT SETUP screen.
5. If you use the GPIB printer:
a. Set "4155B/56B is" field on the SYSTEM: MISCELLANEOUS screen
to SYSTEM CONTROLLER.
b. Enter the GPIB address of printer/plotter into "GPIB ADDRESS" "HARD
COPY" field.
Agilent 4155B/4156B Programmers Guide, Edition 4 2-9
Page 78
SCPI Command Programming Getting Started on SCPI Programming
Step 1 Getting the Setup File and Making a Measurement
In this step, you can create a program to get a setup file from the diskette and execute a measurement.
1. Press IBASIC
2. Select EDIT softkey, then press
Display key until screen display mode is All IBASIC mode.
Enter key to start the IBASIC editor.
3. If there is an existing program, save it if necessary.
4. Delete existing program and assign I/O path to control the 4155B/56B.
Ty pe SCRATCH, then
Enter. Or select Scratch primary softkey, then YES
secondary softkey to delete the program.
Existing program is deleted and the following program lines are entered automatically. These lines are for assigning the 4155B/56B control I/O path.
10 COM @Hp415x 20 ASSIGN @Hp415x TO 800 30 !
9990 END
line 10 Declares COM so that subprograms can access the I/O path (that is
assigned in line 20) for controlling the 4155B/56B. Refer to the Instrument BASIC Users Handbook for details.
line 20 Assigns the I/O path for controlling the 4155B/56B. 800 means
built-in IBASIC controller.
5. Select OUTPUT @Hp415x secondary softkey.
The following characters are automatically entered:
30 OUTPUT @Hp415x;""
Do not press Enter yet.
6. Use the help function to find the command for getting a setup file:
a. Press
b. Press
Help.
Get.
The cursor in help window automatically jumps to the command (:MMEM:LOAD:STAT) for getting a setup file.
7. Press
Enter to insert the command into the program line.
Now line 30 is as follows:
30 OUTPUT @Hp415x;":MMEM:LOAD:STAT"
2-10 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 79
SCPI Command Programming
Getting Started on SCPI Programming
8. Type in the command parameters as in following example:
30 OUTPUT @Hp415x;":MMEM:LOAD:STAT 0,'VTH.MES','DISK'"
The following table shows the meaning of the parameters:
Parameter Description
0 Dummy parameter (no meaning).
VTH.MES File name to be loaded.
DISK Source mass storage is diskette.
Then press
Enter. Then select the Insert line softkey.
To Specify Mass Storage Device
When the 4155B/4156B is in the power on state, the mass storage device is set to the built-in flexible disk drive.
If you specify the device, enter the :MMEM:DEST command before the :MMEM:LOAD:STAT command. The following parameters are available for the :MMEM:DEST command:
INTernal Selects the built-in flexible disk drive.
NETn Selects the NFS server. n= 1, 2, 3 or 4.
9. Select OUTPUT @Hp415x secondary softkey.
40 OUTPUT @Hp415x;""
10. Press Help, then press Single, Append, or Repeat to find the command for executing a measurement.
Relation between the execution keys and commands are shown below:
Execution Key Command
Single :PAGE:SCON:MEAS:SING
Append :PAGE:SCON:MEAS:APP
Repeat :PAGE:SCON:MEAS:REP
Agilent 4155B/4156B Programmers Guide, Edition 4 2- 11
Page 80
SCPI Command Programming Getting Started on SCPI Programming
11. Press Enter to insert the found command into the program line.
10 COM @Hp415x 20 ASSIGN @Hp415x TO 800 30 OUTPUT @Hp415x;":MMEM:LOAD:STAT 0,'VTH.MES','DISK'" 40 OUTPUT @Hp415x;":PAGE:SCON:MEAS:SING"
9990 END
Then press Enter
12. Press End edit softkey to exit from the editor.
Now you have created a measurement program.
To execute the program, do as follows:
1. Press IBASIC
Display key until screen display mode is All Instrument or IBASIC
Status mode. This allows you to monitor the measurement on GRAPH/LIST: GRAPHICS screen.
2. Press
Run front-panel key. The measurement program is executed.
2-12 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 81
Getting Started on SCPI Programming
Step 2 Changing the Sweep Setup Parameters
Modify measurement program created in previous step so that you can enter new sweep start and stop values while program is running:
SCPI Command Programming
1. Press IBASIC
2. Select EDIT softkey, then press
Display key until the screen display mode is All IBASIC mode.
Enter key to start the IBASIC editor.
3. Insert program lines that allow you to enter the sweep start and stop values from the keyboard during program running.
a. Move the cursor to program line 30.
b. Select Insert line primary softkey.
c. Type the following program lines:
21 ! 22 INPUT "Sweep Start (V)?",Start_v 23 INPUT "Sweep Stop (V)?",Stop_v 24 !
4. If you do not know the SCPI commands for changing the sweep start and stop parameters, do as follows:
a. Press IBASIC
b. Press
Meas to change to MEASURE: SWEEP SETUP screen.
Display key until screen display mode is All Instrument mode.
c. Move the field pointer to the parameter that you want to change.
d. Press
Help key.
The corresponding command is displayed at the bottom of the help window: You need to remember the commands, so that you can enter them in the next step.
Command Description
:PAGE:MEAS:SWE:VAR1:STAR VAR1 sweep start
:PAGE:MEAS:SWE:VAR1:STOP VAR1 sweep stop
e. Select the EXIT HELP softkey.
Agilent 4155B/4156B Programmers Guide, Edition 4 2-13
Page 82
SCPI Command Programming Getting Started on SCPI Programming
5. Press IBASIC Display key until screen display mode is All IBASIC mode. Then, do the following to insert the program lines for changing the sweep start and stop values.
a. Move the cursor to the program line 40.
b. Select Insert line primary softkey.
c. Select the OUTPUT @Hp415x softkey.
d. Type in the SCPI command. Or you can use the help function to enter the
command. For the help function, see To Use the Help Function in Chapter
1.
After you finish, the program lines should look as follows:
31 OUTPUT @Hp415x;":PAGE:MEAS:SWE:VAR1:STAR ";Start_v 32 OUTPUT @Hp415x;":PAGE:MEAS:SWE:VAR1:STOP ";Stop_v
Now the program is as follows:
10 COM @Hp415x 20 ASSIGN @Hp415x TO 800 21 ! 22 INPUT "Sweep Start (V)?",Start_v 23 INPUT "Sweep Stop (V)?",Stop_v 24 ! 30 OUTPUT @Hp415x;":MMEM:LOAD:STAT 0,'VTH.MES','DISK'" 31 OUTPUT @Hp415x;":PAGE:MEAS:SWE:VAR1:STAR ";Start_v 32 OUTPUT @Hp415x;":PAGE:MEAS:SWE:VAR1:STOP ";Stop_v 40 OUTPUT @Hp415x;":PAGE:SCON:MEAS:SING"
9990 END
6. Select End edit softkey to exit from the editor.
7. Press IBASIC
8. Press
Run to execute the program.
Display key until screen display mode is IBASIC Status mode.
9. Sweep Start (V)? is displayed on the display line. Enter the desired sweep start voltage.
10. Sweep Stop (V)? is displayed on the display line. Enter the desired sweep stop voltage.
2-14 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 83
Getting Started on SCPI Programming
Step 3 Changing the Display Setup Parameters
In this step, change X-axis range of display setup parameters to match the sweep start and stop values.
SCPI Command Programming
1. Press IBASIC
2. Select EDIT softkey, then press
Display key until screen display mode is All IBASIC mode.
Enter key to start the IBASIC editor.
3. If you do not know the SCPI commands for changing the X-axis parameters, do as follows:
a. Press IBASIC
b. Press PAGE CONTROL
Display key until screen display mode is All Instrument mode.
Display key to change to DISPLAY: DISPLAY
SETUP screen.
c. Move the field pointer to the parameter that you want to change.
d. Press
Help key.
The corresponding commands are displayed at the bottom of the help window. You need to remember the commands, so that you can enter them in the next step.
Command Description
:PAGE:DISP:SET:GRAP:X:MIN minimum value of X-axis
:PAGE:DISP:SET:GRAP:X:MAX maximum value of X-axis
e. Select the EXIT HELP softkey.
4. Press IBASIC
Display key until screen display mode is All IBASIC mode. Then,
do the following to insert the program lines for changing the X-axis display parameters:
a. Move the cursor to the program line 40.
b. Select Insert line primary softkey.
c. Select the OUTPUT @Hp415x softkey.
d. Type in the SCPI command. Or you can use the help function to enter the
command. For the help function, see To Use the Help Function in Chapter
1. After you finish, the program lines should look as follows:
33 OUTPUT @Hp415x;":PAGE:DISP:SET:GRAP:X:MIN ";Start_v 34 OUTPUT @Hp415x;":PAGE:DISP:SET:GRAP:X:MAX ";Stop_v
Agilent 4155B/4156B Programmers Guide, Edition 4 2-15
Page 84
SCPI Command Programming Getting Started on SCPI Programming
Now the program is as follows:
10 COM @Hp415x 20 ASSIGN @Hp415x TO 800 21 ! 22 INPUT "Sweep Start (V)?",Start_v 23 INPUT "Sweep Stop (V)?",Stop_v 24 ! 30 OUTPUT @Hp415x;":MMEM:LOAD:STAT 0,'VTH.MES','DISK'" 31 OUTPUT @Hp415x;":PAGE:MEAS:SWE:VAR1:STAR ";Start_v 32 OUTPUT @Hp415x;":PAGE:MEAS:SWE:VAR1:STOP ";Stop_v 33 OUTPUT @Hp415x;":PAGE:DISP:SET:GRAP:X:MIN ";Start_v 34 OUTPUT @Hp415x;":PAGE:DISP:SET:GRAP:X:MAX ";Stop_v 40 OUTPUT @Hp415x;":PAGE:SCON:MEAS:SING"
9990 END
5. Select End edit softkey to exit from the editor.
6. Press IBASIC
7. Press
Run to execute the program.
Display key until screen mode is IBASIC Status mode.
8. Enter the desired sweep start and stop values as prompted. The minimum and maximum X-axis values of the graph will be the same as these entered values.
2-16 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 85
SCPI Command Programming
Getting Started on SCPI Programming
Step 4 Saving All Measurement Results to a Diskette
In this step, add program lines that save the setup data and measurement results to the diskette.
1. Press IBASIC
2. Select EDIT softkey, then press
Display key until screen display mode is All IBASIC mode.
Enter key to start the IBASIC editor.
3. Move the cursor to program line 9990.
4. Select Insert line primary softkey.
5. Insert the following program lines, which wait until the measurement is completed.
50 OUTPUT @Hp415x;"*OPC?" 60 ENTER @Hp415x;Complete
When measurement is completed, the 4155B/56B returns 1 to the Complete variable.
6. Insert the following program line, which saves the measurement setup and results to a file named VTH.DAT:
70 OUTPUT @Hp415x;":MMEM:STOR:TRAC DEF,'VTH.DAT'"
Now the program is as follows:
10 COM @Hp415x 20 ASSIGN @Hp415x TO 800 21 ! 22 INPUT "Sweep Start (V)?",Start_v 23 INPUT "Sweep Stop (V)?",Stop_v 24 ! 30 OUTPUT @Hp415x;":MMEM:LOAD:STAT 0,'VTH.MES','DISK'" 31 OUTPUT @Hp415x;":PAGE:MEAS:SWE:VAR1:STAR ";Start_v 32 OUTPUT @Hp415x;":PAGE:MEAS:SWE:VAR1:STOP ";Stop_v 33 OUTPUT @Hp415x;":PAGE:DISP:SET:GRAP:X:MIN ";Start_v 34 OUTPUT @Hp415x;":PAGE:DISP:SET:GRAP:X:MAX ";Stop_v 40 OUTPUT @Hp415x;":PAGE:SCON:MEAS:SING" 50 OUTPUT @Hp415x;"*OPC?" 60 ENTER @Hp415x;Complete 70 OUTPUT @Hp415x;":MMEM:STOR:TRAC DEF,'VTH.DAT'"
9990 END
7. Select End edit softkey to exit from the editor.
8. Press IBASIC
Display key until screen display mode changes to IBASIC Status
mode.
9. Press
Run to execute the program.
The measurement setup and results are automatically saved to the diskette after measurement is performed.
Agilent 4155B/4156B Programmers Guide, Edition 4 2-17
Page 86
SCPI Command Programming Getting Started on SCPI Programming
Step 5 Printing the Measurement Results
In this step, add program lines that print the measurement results.
1. Press
2. Select EDIT softkey, then press
Display key until screen display mode is All IBASIC mode.
Enter key to start the IBASIC editor.
3. Move the cursor to the program line 70.
4. Select Insert line primary softkey.
5. Insert the following program lines, which print a screen dump of the results:
61 OUTPUT @Hp415x;":HCOP:SDUM" 62 DISP "Printing" 63 OUTPUT @Hp415x;"*OPC?" 64 ENTER @Hp415x;Complete 65 DISP "Done"
:HCOP immediately initiates the plot or print according to the current setup. After printing is finished, the 4155B/56B returns 1 to the Complete variable, then "Done" is displayed on the screen.
Now the program is as follows:
10 COM @Hp415x 20 ASSIGN @Hp415x TO 800 21 ! 22 INPUT "Sweep Start (V)?",Start_v 23 INPUT "Sweep Stop (V)?",Stop_v 24 ! 30 OUTPUT @Hp415x;":MMEM:LOAD:STAT 0,'VTH.MES','DISK'" 31 OUTPUT @Hp415x;":PAGE:MEAS:SWE:VAR1:STAR ";Start_v 32 OUTPUT @Hp415x;":PAGE:MEAS:SWE:VAR1:STOP ";Stop_v 33 OUTPUT @Hp415x;":PAGE:DISP:SET:GRAP:X:MIN ";Start_v 34 OUTPUT @Hp415x;":PAGE:DISP:SET:GRAP:X:MAX ";Stop_v 40 OUTPUT @Hp415x;":PAGE:SCON:MEAS:SING" 50 OUTPUT @Hp415x;"*OPC?" 60 ENTER @Hp415x;Complete 61 OUTPUT @Hp415x;":HCOP:SDUM" 62 DISP "Printing" 63 OUTPUT @Hp415x;"*OPC?" 64 ENTER @Hp415x;Complete 65 DISP "Done" 70 OUTPUT @Hp415x;":MMEM:STOR:TRAC DEF,'VTH.DAT'"
9990 END
2-18 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 87

Programming for Data Extraction

This section provides the following programming tutorials for data extraction:
1. Reading the 4155/56 setup data
2. Reading values of data variables (measurement results)
3. Transferring data into a file
Step 1 Reading 4155/56 Setup Data
To read setup data from the 4155/56 into an IBASIC variable, use the query form of the corresponding setting command. To make the query form of a command, simply add a question mark (?) to the end of the command.
Refer to the following program lines of example program:
60 OUTPUT @Hp415x;":PAGE:MEAS:SWE:VAR1:STAR?" 70 ENTER @Hp415x;Vd_start 80 OUTPUT @Hp415x;":PAGE:MEAS:SWE:VAR1:STOP?"
90 ENTER @Hp415x;Vd_stop 100 OUTPUT @Hp415x;":DISP:ALL BAS" 110 CLEAR SCREEN 120 PRINT TABXY(1,1);"Vd START=";Vd_start;"(V)" 130 PRINT TABXY(1,2);"Vd STOP =";Vd_stop;"(V)"
Line 60 This query command tells the 4155B/56B to put the VAR1 start
value in its output buffer.
SCPI Command Programming
Getting Started on SCPI Programming
:PAGE:MEAS:SWE:VAR1:STAR is the command for setting the VAR1 start value. By adding ?, the command becomes the query command for reading the VAR1 start value.
Line 70 This gets the start value from the output buffer, then enters it in
the Vd_start variable.
Line 80 to 90 These lines tell the 4155B/56 to put VAR1 stop value in its
output buffer, then the value is entered into the Vd_stop variable.
Agilent 4155B/4156B Programmers Guide, Edition 4 2-19
Page 88
SCPI Command Programming Getting Started on SCPI Programming
Step 2 Reading 4155/56 Measurement Data
To read read-out function values or data variable values (output data, measurement data, and user function values) from the 4155/56 to IBASIC variables, use the :DATA? command.
Refer to the following program lines in the example program:
410 OUTPUT @Hp415x;":PAGE:SCON:MEAS:SING" 420 OUTPUT @Hp415x;"*OPC?" 430 ENTER @Hp415x;Complete 440 OUTPUT @Hp415x;":DATA? 'VTH'" 450 ENTER @Hp415x;Vth
Line 410 Execute single measurement.
Line 420 to 430 Wait for measurement completion.
Line 440 Send :DATA? query command to read the result value of user
function "VTH".
Line 450 Store the result value into Vth variable.
NOTE Variable Names
Be aware that data variable names, such as user functions and user variables, are case sensitive. For example, if you set up user function name VTH on the CHANNEL: USER FUNCTION DEFINITION screen, then to read it, you must use :DATA? 'VTH', not :DATA? 'Vth'.
2-20 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 89
Getting Started on SCPI Programming
Step 3 Transferring Specific 4155/56 Data to a File
To transfer data from the 4155B/56B to a file, do as follows:
1. Create a data file.
2. Open an I/O path for transferring data into the file.
3. Store data into the file.
4. Close the I/O path.
Create a data file
You can create three types of data files: DOS, LIF ASCII, or BDAT as follows:
CREATE "data_file",1 ! Creates a DOS file.
CREATE ASCII "ascii_file",100 ! Creates a LIF ASCII file.
CREATE BDAT "binary_file",100 ! Creates a BDAT file.
DOS files are compatible with MS-DOS, which are easy to transfer to PCs and other computers.
LIF ASCII files are compatible with HP computers that support this file type, so this type is best is you are transferring files among HP computers that support this file type.
SCPI Command Programming
BDAT (binary data) files provide more flexibility (can specify both number of records and record length) and faster transfer rate. But BDAT files cannot be interchanged with as many other systems.
The first parameter of each statement specifies the file name to create.
The second parameter specifies number of records to allocate for the file as follows:
DOS Second parameter specifies how many records are to be initially
allocated for the file. A DOS file system automatically allocates additional space for the file as new data is written to it, so you can always specify 1 for this parameter.
LIF ASCII Second parameter specifies total number of records to allocate
for the file, so you must specify a sufficient number of records. The length of one record is 256 bytes.
For example, the following statement would create a file with 100 records (each record is 256 bytes):
CREATE ASCII "File",100
Agilent 4155B/4156B Programmers Guide, Edition 4 2-21
Page 90
SCPI Command Programming Getting Started on SCPI Programming
BDAT Second parameter specifies total number of records to allocate
for the file, so you must specify a sufficient number of records. You can specify a record length by using an optional third parameter (default length is 256 bytes).
For example, the following statement creates a file with 7 records (each record is 128 bytes):
CREATE BDAT "B_file",7,128
The following statement creates a file with 7 records (each record is 256 bytes):
CREATE BDAT "B_file",7
Open an I/O path for transferring data into the file
To open an I/O path to the file, assign an I/O path name to the file by using an ASSIGN statement as in the following example:
340 INPUT "Enter file name to store data",File$ 350 CREATE File$,1 360 ASSIGN @File TO File$;FORMAT ON
Line 350 creates a DOS file, then line 360 opens an I/O path to the file.
For DOS and BDAT files, ASSIGN statement can also specify the following:
FORMAT ON ASCII data representations are used. Specify this if you need to
transport data between IBASIC and other machines.
FORMAT OFF IBASIC internal data representations are used. Specify this if
you need a faster transfer rate and space efficiency.
Store data into the file
To store data into a file, use OUTPUT and ENTER statements as in the following examples:
340 INPUT "Enter file name to store data",File$ 350 CREATE File$,1 360 ASSIGN @File TO File$;FORMAT ON
390 REPEAT
440 OUTPUT @Hp415x;":DATA? 'VTH'" 450 ENTER @Hp415x;Vth 460 OUTPUT @File;Vth
630 UNTIL Stop$="S" OR Stop$="s"
:
:
:
2-22 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 91
SCPI Command Programming
Getting Started on SCPI Programming
The above program repeats appending Vth variable value to a DOS file in ASCII format.
In addition to numeric data, array data and string data can be stored to a file as in following examples:
Array data:
1 DIM Vth(1:100)
: 340 INPUT "Enter file name to store data",File$ 350 CREATE File$,1 360 ASSIGN @File TO File$;FORMAT ON
: 390 FOR I=1 TO 100
: 440 OUTPUT @Hp415x;":DATA? 'VTH'" 450 ENTER @Hp415x;Vth(I) 460 NEXT I 470 OUTPUT @File;Vth(*)
:
String data:
10 DIM Data$[10](1:100) 20 CREATE "DATAFILE",1 30 ASSIGN @File TO "DATAFILE";FORMAT ON 40 FOR I=1 TO 100 50 Data$(I)="ABC" 60 NEXT I 70 OUTPUT @File;Data$(*)
:
Close the I/O path
To close an I/O path to a file, ASSIGN the path name to an (asterisk) as in the following example:
340 INPUT "Enter file name to store data",File$ 350 CREATE File$,1 360 ASSIGN @File TO File$;FORMAT ON
:
460 OUTPUT @File;Vth
:
590 ASSIGN @File TO *
In this program, line 590 closes the I/O path that was opened by line 360.
Agilent 4155B/4156B Programmers Guide, Edition 4 2-23
Page 92
SCPI Command Programming Getting Started on SCPI Programming

Complete Example Program for Vth Measurement

The example program shown below uses the measurement setup file described in Example Application Setup for Vth Measurement on page 2-26. This is a complete example program based on the parts described in the previous sections.
10 COM @Hp415x 20 ASSIGN @Hp415x TO 800 30 OUTPUT @Hp415x;":MMEM:LOAD:STAT 0,'VTH.MES','DISK'" 40 ! 50 ! Read and Disp. Measurement Conditions 60 OUTPUT @Hp415x;":PAGE:MEAS:SWE:VAR1:STAR?" 70 ENTER @Hp415x;Vd_start 80 OUTPUT @Hp415x;":PAGE:MEAS:SWE:VAR1:STOP?" 90 ENTER @Hp415x;Vd_stop 100 OUTPUT @Hp415x;":DISP:ALL BAS" 110 CLEAR SCREEN 120 PRINT TABXY(1,1);"Vd START=";Vd_start;"(V)" 130 PRINT TABXY(1,2);"Vd STOP =";Vd_stop;"(V)" 140 ! 150 ! Parameter Change 160 Change$="n" 170 Change: ! 180 INPUT "Change these parameters? (y/n default=n)",Change$ 190 SELECT Change$ 200 CASE "Y","y" 210 INPUT "New Vd START (V)?",Vd_start 220 INPUT "New Vd STOP (V)?",Vd_stop 230 OUTPUT @Hp415x;":PAGE:MEAS:SWE:VAR1:STAR ";Vd_start 240 OUTPUT @Hp415x;":PAGE:MEAS:SWE:VAR1:STOP ";Vd_stop 250 PRINT TABXY(1,1);"Vd START=";Vd_start;"(V)" 260 PRINT TABXY(1,2);"Vd STOP =";Vd_stop;"(V)" 270 CASE "N","n" 280 GOTO Store_file 290 CASE ELSE 300 GOTO Change 310 END SELECT 320 ! 330 Store_file: ! 340 INPUT "Enter file name to store data",File$ 350 CREATE File$,1 360 ASSIGN @File TO File$;FORMAT ON 370 ! 380 No_of_data=0 390 REPEAT 400 OUTPUT @Hp415x;":DISP:ALL BST" 410 OUTPUT @Hp415x;":PAGE:SCON:MEAS:SING" 420 OUTPUT @Hp415x;"*OPC?" 430 ENTER @Hp415x;Complete 440 OUTPUT @Hp415x;":DATA? 'VTH'" 450 ENTER @Hp415x;Vth 460 OUTPUT @File;Vth 470 No_of_data=No_of_data+1 480 OUTPUT @Hp415x;":DISP:ALL BASIC" 490 PRINT TABXY(1,10);"Last measured Vth =";Vth;"(V)" 500 PRINT TABXY(1,11);"Total number of die tested=";No_of_ data
2-24 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 93
SCPI Command Programming
Getting Started on SCPI Programming
510 Stop_query:INPUT "Continue to next die or Stop test? (c/s)" ,Stop$ 520 SELECT Stop$ 530 CASE "C","c" 540 DISP "Move to the next die, then press [Continue]" 550 PAUSE 560 DISP "" 570 CASE "S","s" 580 PRINT TABXY(1,24);"Test Stopped!!" 590 ASSIGN @File TO * 600 CASE ELSE 610 GOTO Stop_query 620 END SELECT 630 UNTIL Stop$="S" OR Stop$="s" 640 END
Agilent 4155B/4156B Programmers Guide, Edition 4 2-25
Page 94
SCPI Command Programming Getting Started on SCPI Programming

Example Application Setup for Vth Measurement

This section describes an example application setup that you should save to the file named VTH.MES on diskette before executing program examples (that use VTH.MES) described previously in this section.
A frequently used method of measuring Vth is to synchronously sweep the exact same voltage to gate and drain, and measure the characteristics in the saturation region.
The theoretical value of drain current in the saturation region is calculated as follows:
Id = b ´ ( Vg - Vth ) Where b is the gain factor, which is -1/2 ´ ( meox W/L) ´ tox. Therefore, if you take
the square root of both sides of the equation: ÖId
= Öb ´ (Vg - Vth)
ÖId
is proportional to Vg, and the slope is Öb. At the point where ÖId is equal 0, Vth
is equal to Vg. So, to know Vth, we need to find that point.
The measurement conditions are explained below:
2
CHANNELS: CHANNEL DEFINITION
MEASUREMENT MODE
SWEEP
CHANNELS
MEASURE
UNIT VNAME INAME MODE FCTN
SMU1 Vd Id V VAR1'
SMU2 Vg Ig V VAR1
SMU3 Vs Is COMMON CONST
SMU4 Vsb Isb V CONST
2-26 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 95
SCPI Command Programming
Getting Started on SCPI Programming
MEASURE: SWEEP SETUP
This is the sweep source setup for the Id-Vg characteristics measurement.
VA R I A B L E
VA R 1 VA R 1 ’
UNIT SMU2 UNIT SMU1
NAME Vg NAME Vd
SWEEP MODE Single OFFSET 0.0000 V
LIN/LOG LINEAR RATIO 1.000
START 0.0000 V COMPLIANCE 100.00 mA
STOP 5.000 V POWER COMP OFF
STEP 100.0 mV
NO OF STEP 51
COMPLIANCE 100.0 mA
POWER COMP OFF
CONSTANT
UNIT SMU4
NAME Vsb
MODE V
SOURCE 0.0000 V
COMPLIANCE 100.00 mA
Agilent 4155B/4156B Programmers Guide, Edition 4 2-27
Page 96
SCPI Command Programming Getting Started on SCPI Programming
CHANNELS: USER FUNCTION DEFINITION
The following setup is necessary to calculate SQRTId (square root of Id), and GRAD (differential coefficient of SQRTId) versus Vg automatically. VTH and BETA are defined to extract Vth and b automatically by using the Read Out Functions and the Auto Analysis Functions. VTH is @L1X (X-intercept of line 1) and BETA is @L1G^2 (slope of line 1 to second power). Line 1 is drawn according to the definitions of the DISPLAY: ANALYSIS SETUP screen.
USER FUNCTION
NAME UNIT DEFINITION
SQRTId SQRT(Id)
GRAD DIFF(SQRTId,Vg)
VTH V @L1X
BETA @L1G^2
2-28 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 97
SCPI Command Programming
Getting Started on SCPI Programming
DISPLAY: DISPLAY SETUP
The following setup is to plot two curves: SQRTId versus Vg, and GRAD versus Vg. And VTH and BETA will be displayed in the data variables display area.
GRAPHICS
X-axis Y1-axis Y2-axis
NAME Vg SQRTId GRAD
SCALE LINEAR LINEAR LINEAR
MIN 0 V 0 0
MAX 5 V 200 m 80 m
GRID
ON
LINE PARAMETER
ON
DATA VARIABLES
VTH
BETA
DISPLAY: ANALYSIS SETUP
The Auto Analysis Functions are defined on DISPLAY: ANALYSIS SETUP screen.
A tangent line (line 1) is drawn to "SQRTId versus Vg" curve (Y1) at point where GRAD is maximum. VTH is the X-intercept of this line. Also, the marker is moved to point where GRAD is maximum.
* LINE1 TANGENT line on Y1 at a point where
GRAD = MAX(GRAD)
If you execute a single measurement, the two curves are drawn. Right after the measurement, a tangent line is drawn as specified in DISPLAY: ANALYSIS SETUP screen, and resulting VTH and BETA values are displayed.
Agilent 4155B/4156B Programmers Guide, Edition 4 2-29
Page 98
SCPI Command Programming Programming: Measurement Setup

Programming: Measurement Setup

To set up a measurement, you can use SCPI commands to set the setup screens of the 4155B/4156B the same way that you can by interactive operation.
Basically, there are the following three ways to set up a measurement via SCPI programming:
Load the measurement setup data from diskette, NFS server or internal memory.
Load the measurement setup data by SCPI programming. The data was previously defined and stored to the mass storage memory interactively or by SCPI programming.
Load the measurement setup data, then change some of the settings.
Load the measurement setup data from the mass storage memory, then change desired settings by SCPI programming.
Set all settings.
Set all settings for measurement setup by SCPI programming.
This section describes the following tasks:
To set or change setup data values.
To read setup data values
To load previously defined measurement setup data, refer to Programming: File Operation on page 2-42.
2-30 Agilent 4155B/4156B Programmers Guide, Edition 4
Page 99
SCPI Command Programming
Programming: Measurement Setup

To Set or Change 4155/56 Setup Data Values

Send :PAGE subsystem commands that correspond to the setup data values that you want to change or set.
There is a command subsystem for each setup screen as shown in the following table. Each command subsystem has commands for setting the setup data of the corresponding setup screen.
Setup Screen Command Subsystem
CHANNELS: CHANNEL DEFINITION :PAGE:CHANnels[:CDEFinition]
CHANNELS: USER FUNCTION DEFINITION :PAGE:CHANnels:UFUNction
CHANNELS: USER VARIABLE DEFINITION :PAGE:CHANnels:UVARiable
MEASURE: SWEEP SETUP :PAGE:MEASure[:SWEep]
MEASURE: SAMPLING SETUP :PAGE:MEASure:SAMPling
MEASURE: PGU SETUP :PAGE:MEASure:PGUSetup
MEASURE: MEASURE SETUP :PAGE:MEASure:MSETup
MEASURE: OUTPUT SEQUENCE :PAGE:MEASure:OSEQuence
DISPLAY: DISPLAY SETUP :PAGE:DISPlay[:SETup]
DISPLAY: ANALYSIS SETUP :PAGE:DISPlay:ANALysis
STRESS: CHANNEL DEFINITION :PAGE:STRess:[CDEFinition]
STRESS: STRESS SETUP :PAGE:STRess:SETup
Agilent 4155B/4156B Programmers Guide, Edition 4 2-31
Page 100
SCPI Command Programming Programming: Measurement Setup
Example To load measurement setup data, then change the sweep start and stop values:
10 ASSIGN @Hp415x TO 800 20 ! 30 OUTPUT @Hp415x;":MMEM:DEST INT" 40 OUTPUT @Hp415x;":MMEM:LOAD:STAT 0,'SWP.MES','DISK'" 50 ! 60 Swp_start=1 70 Swp_stop=10 80 ! 90 OUTPUT @Hp415x;":PAGE:MEAS:VAR1:STAR ";Swp_start 100 OUTPUT @Hp415x;":PAGE:MEAS:VAR1:STOP ";Swp_stop 110 ! 120 END
Line
Number
Description
10 Assigns I/O path to control the 4155B/4156B.
30 Sets the mass storage device to the built-in flexible disk drive.
40 Loads measurement setup data from diskette file SWP.MES.
90 Changes start value of VAR1.
100 Changes stop value of VAR1.
2-32 Agilent 4155B/4156B Programmers Guide, Edition 4
Loading...