Agilent 86100A Programmers Manual

DCA and DCA-J
Agilent 86100A/B/C Wide-Bandwidth Oscilloscope Programmer’s Guide
Notices
© Agilent Technologies, Inc. 2000-2005
No part of this manual may be repro­duced in any form or by any means (including electronic storage and retrieval or translation into a foreign lan­guage) without prior agreement and writ­ten consent from Agilent Technologies, Inc. as governed by United States and international copyright lays.
Manual Part Number
86100-90079
Edition
First edition, June 2005
Printed in USA
Agilent Technologies, Inc. Digital Signal Analysis Division 1400 Fountaingrove Parkway Santa Rosa, CA 95403, USA
Warranty
The material contained in this document is provided “as is,” and is subject to being changed, without notice, in future edi­tions. Further, to the maximum extent permitted by applicable law, Agilent dis­claims all warranties, either express or implied, with regard to this manual and any information contained herein, includ­ing but not limited to the implied warran­ties of merchantability and fitness for a particular purpose. Agilent shall not be liable for errors or for incidental or conse­quential damages in connection with the furnishing, use, or performance of this document or of any information con­tained herein. Should Agilent and the user have a separate written agreement with warranty terms covering the mate­rial in this document that conflict with these terms, the warranty terms in the separate agreement shall control.
Technology Licenses
The hardware and/or software described in this document are furnished under a license and may be used or copied only in accordance with the terms of such license.
LZW compression/decompression: Licensed under U.S. Patent No. 4,558,302 and foreign counterparts. The purchase or use of LZW graphics capability in a licensed product does not authorize or permit an end user to use any other prod­uct or perform any other method or activ­ity involving use of LZW unless the end user is separately licensed in writing by Unisys.
Restricted Rights Legend
If software is for use in the performance of a U.S. Government prime contract or subcontract, Software is delivered and licensed as “Commercial computer soft­ware” as defined in DFAR 252.227-7014 (June 1995), or as a “commercial item” as defined in FAR 2.101(a) or as “Restricted computer software” as defined in FAR
52.227-19 (June 1987) or any equivalent agency regulation or contract clause. Use, duplication or disclosure of Software is subject to Agilent Technologies’ standard commercial license terms, and non-DOD Departments and Agencies of the U.S. Government will receive no greater than Restricted Rights as defined in FAR
52.227-19(c)(1-2) (June 1987). U.S. Gov­ernment users will receive no greater than Limited Rights as defined in FAR
52.227-14 (June 1987) or DFAR 252.227­7015 (b)(2) (November 1995), as appli­cable in any technical data.
Safety Notices
CAUTION
Caution denotes a hazard. It calls attention to a procedure which, if not correctly per­formed or adhered to, could result in damage to or destruction of the product. Do not proceed beyond a caution sign until the indicated conditions are fully understood and met.
WARNING
Warning denotes a hazard. It calls attention to a procedure which, if not correctly per­formed or adhered to, could result in injury or loss of life. Do not proceed beyond a warning sign until the indicated conditions are fully understood and met.
Trademark Acknowledgements
MATLAB ® is a U.S. registered trademark of The Math Works, Inc.
2

Contents

1 Introduction
Introduction 1-2 Starting a Program 1-4 Multiple Databases 1-6 Files 1-8 Status Reporting 1-11 Command Syntax 1-23 Interface Functions 1-33 Language Compatibility 1-36 New and Revised Commands 1-42 Commands Unavailable in Jitter Mode 1-42 Error Messages 1-44
2 Sample Programs
Sample C Programs 2-3 Listings of the Sample Programs 2-15
3 Common Commands
4 Root Level Commands
5 System Commands
6 Acquire Commands
7 Calibration Commands
8 Channel Commands
9 Clock Recovery Commands
10 Disk Commands
11 Display Commands
12 Function Commands
Contents-1
ContentsContents
13 Hardcopy Commands
14 Histogram Commands
15 Limit Test Commands
16 Marker Commands
17 Mask Test Commands
18 Measure Commands
19 Signal Processing Commands
20 TDR/TDT Commands
21 Timebase Commands
22 Trigger Commands
23 Waveform Commands
24 Waveform Memory Commands
Contents-2
1
Introduction 1-2 Starting a Program 1-4 Multiple Databases 1-6 Files 1-8 Status Reporting 1-11 Command Syntax 1-23 Interface Functions 1-33 Language Compatibility 1-36 New and Revised Commands 1-42 Commands Unavailable in Jitter Mode 1-42 Error Messages 1-44

Introduction

Introduction

Introduction
Introduction
This chapter explains how to program the instrument. The programming syntax conforms to the IEEE 488.2 Standard Digital Interface for Programmable Instrumentation and to the Standard Commands for Programmable Instruments (SCPI). This edition of the manual doc­uments all 86100-series software revisions up through A.04.10. For a listing of commands that are new or revised for software revisions A.04.00 and A.04.10, refer to “New and Revised
Commands” on page 1-42.
If you are unfamiliar with programming instruments using the SCPI standard, refer to “Com-
mand Syntax” on page 1-23. For more detailed information regarding the GPIB, the IEEE
488.2 standard, or the SCPI standard, refer to the following books:
• International Institute of Electrical and Electronics Engineers. IEEE Standard 488.1-1987, IEEE Standard Digital Interface for Programmable Instrumentation. New York, NY, 1987.
• International Institute of Electrical and Electronics Engineers. IEEE Standard 488.2-1987,
IEEE Standard Codes, Formats, Protocols and Common commands For Use with ANSI/ IEEE Std 488.1-1987. New York, NY, 1987.
Throughout this book, BASIC and ANSI C are used in the examples of individual commands. If you are using other languages, you will need to find the equivalents of BASIC commands like OUTPUT, ENTER, and CLEAR, to convert the examples.
The instrument’s GPIB address is configured at the factory to a value of 7. You must set the output and input functions of your programming language to send the commands to this address. You can change the GPIB address from the instrument’s front panel.
Data Flow The data flow gives you an idea of where the measurements are made on the acquired data
and when the post-signal processing is applied to the data. The following figure is a block dia­gram of the instrument. The diagram is laid out serially for a visual perception of how the data is affected by the instrument.
1-2
Figure 1-1. Sample Data Processing
Introduction
Introduction
The sample data is stored in the channel memory for further processing before being dis­played. The time it takes for the sample data to be displayed depends on the number of post processes you have selected. Averaging your sampled data helps remove any unwanted noise from your waveform.
You can store your sample data in the instrument’s waveform memories for use as one of the sources in Math functions, or to visually compare against a waveform that is captured at a future time. The Math functions allow you to apply mathematical operations on your sampled data. You can use these functions to duplicate many of the mathematical operations that your circuit may be performing to verify that your circuit is operating correctly. The measure­ments section performs any of the automated measurements that are available in the instru­ment. The measurements that you have selected appear at the bottom of the display. The Connect Dots section draws a straight line between sample data points, giving an analog look to the waveform. This is sometimes called linear interpolation.
1-3
Introduction

Starting a Program

Starting a Program
The commands and syntax for initializing the instrument are listed in Chapter 3, “Common
Commands”. Refer to your GPIB manual and programming language reference manual for
information on initializing the interface. To make sure the bus and all appropriate interfaces are in a known state, begin every program with an initialization statement. For example, BASIC provides a CLEAR command which clears the interface buffer. When you are using GPIB, CLEAR also resets the instrument's parser. After clearing the interface, initialize the instrument to a preset state using the *RST command.
The AUTOSCALE command is very useful on unknown waveforms. It automatically sets up the vertical channel, time base, and trigger level of the instrument.
A typical instrument setup configures the vertical range and offset voltage, the horizontal range, delay time, delay reference, trigger mode, trigger level, and slope. An example of the commands sent to the instrument are:
:CHANNEL1:RANGE 16;OFFSET 1.00<terminator> :SYSTEM:HEADER OFF<terminator> :TIMEBASE:RANGE 1E-3;DELAY 100E-6<terminator>
This example sets the time base at 1 ms full-scale (100 µs/div), with delay of 100 µs. Vertical
is set to 16 V full-scale (2 V/div), with center of screen at 1 V, and probe attenuation of 10.
The following program demonstrates the basic command structure used to program the instrument.
10 CLEAR 707 ! Initialize instrument interface 20 OUTPUT 707;"*RST" !Initialize instrument to preset state 30 OUTPUT 707;":TIMEBASE:RANGE 5E-4"! Time base to 500 us full scale 40 OUTPUT 707;":TIMEBASE:DELAY 25E-9"! Delay to 25 ns 50 OUTPUT 707;":TIMEBASE:REFERENCE CENTER"! Display reference at center 60 OUTPUT 707;":CHANNEL1:RANGE .16"! Vertical range to 160 mV full scale 70 OUTPUT 707;":CHANNEL1:OFFSET -.04"! Offset to -40 mV 80 OUTPUT 707;":TRIGGER:LEVEL,-.4"! Trigger level to -0.4 90 OUTPUT 707;":TRIGGER:SLOPE POSITIVE"! Trigger on positive slope 100 OUTPUT 707;":SYSTEM:HEADER OFF"<terminator> 110 OUTPUT 707;":DISPLAY:GRATICULE FRAME"! Grid off 120 END
• Line 10 initializes the instrument interface to a known state and Line 20 initializes the instrument to a preset state.
• Lines 30 through 50 set the time base, the horizontal time at 500 µs full scale, and 25 ns of
delay referenced at the center of the graticule.
• Lines 60 through 70 set the vertical range to 160 millivolts full scale and the center screen at
1-4
Introduction
Starting a Program
−40 millivolts.
• Lines 80 through 90 configure the instrument to trigger at 0.4 volts with normal triggering.
• Line 100 turns system headers off.
• Line 110 turns the grid off.
The DIGITIZE command is a macro that captures data using the acquisition (ACQUIRE) sub­system. When the digitize process is complete, the acquisition is stopped. The captured data can then be measured by the instrument or transferred to the computer for further analysis. The captured data consists of two parts: the preamble and the waveform data record. After changing the instrument configuration, the waveform buffers are cleared. Before doing a measurement, the DIGITIZE command should be sent to ensure new data has been collected. You can send the DIGITIZE command with no parameters for a higher throughput. Refer to the DIGITIZE command in Chapter 4, “Root Level Commands” for details. When the DIGI­TIZE command is sent to an instrument, the specified channel’s waveform is digitized with the current ACQUIRE parameters. Before sending the :WAVEFORM:DATA? query to get waveform data, specify the WAVEFORM parameters. The number of data points comprising a waveform varies according to the number requested in the ACQUIRE subsystem. The ACQUIRE subsystem determines the number of data points, type of acquisition, and number of averages used by the DIGITIZE command. This allows you to specify exactly what the dig­itized information contains. The following program example shows a typical setup:
OUTPUT 707;":SYSTEM:HEADER OFF"<terminator> OUTPUT 707;":WAVEFORM:SOURCE CHANNEL1"<terminator> OUTPUT 707;":WAVEFORM:FORMAT BYTE"<terminator> OUTPUT 707;":ACQUIRE:COUNT 8"<terminator> OUTPUT 707;":ACQUIRE:POINTS 500"<terminator> OUTPUT 707;":DIGITIZE CHANNEL1"<terminator> OUTPUT 707;":WAVEFORM:DATA?"<terminator>
This setup places the instrument to acquire eight averages. This means that when the DIGI­TIZE command is received, the command will execute until the waveform has been averaged at least eight times. After receiving the :WAVEFORM:DATA? query, the instrument will start passing the waveform information when queried. Digitized waveforms are passed from the instrument to the computer by sending a numerical representation of each digitized point. The format of the numerical representation is controlled with the :WAVEFORM:FORMAT command and may be selected as BYTE, WORD, or ASCII. The easiest method of entering a digitized waveform depends on data structures, available formatting, and I/O capabilities. You must scale the integers to determine the voltage value of each point. These integers are passed starting with the leftmost point on the instrument's display. For more information, refer to Chapter 23, “Waveform Commands”. When using GPIB, a digitize operation may be aborted by sending a Device Clear over the bus (for example, CLEAR 707).
NOTE The execution of the DIGITIZE command is subordinate to the status of ongoing limit tests. (See commands
ACQuire:RUNTil on page 6-4, MTEST:RUNTil on page 17-7, and LTEST:RUNTil on page 15-4.) The DIGITIZE command will not capture data if the stop condition for a limit test has been met.
1-5
Introduction

Multiple Databases

Multiple Databases
Eye/Mask measurements are based on statistical data that is acquired and stored in the color grade/gray scale database. The color grade/gray scale database consists of all data samples displayed on the display graticule. The measurement algorithms are dependent upon histo­grams derived from the database. This database is internal to the instrument’s applications. The color grade/gray scale database cannot be imported into an external database applica­tion.
If you want to perform an eye measurement, it is necessary that you first produce an eye dia­gram by triggering the instrument with a synchronous clock signal. Measurements made on a pulse waveform while in Eye/Mask mode will fail.
Firmware revision A.03.00 and later allows for multiple color grade/gray scale databases to be acquired and displayed simultaneously, including
• all four instrument channels
• all four math functions
• one saved color grade/gray scale file
Using Multiple Databases in Remote Programs
The ability to use multiple databases allows for the comparison of
• channels to each other
• channels to a saved color grade/gray scale file
• functions to the channel data on which it is based
The advantage of acquiring and displaying channels and functions simultaneously is test times are greatly reduced. For example, the time taken to acquire two channels in parallel is approximately the same time taken to acquire a single channel.
Most commands that control histograms, mask tests, or color grade data have additional optional parameters that were not available in firmware revisions prior to A.03.00. You can use the commands to control a single channel or add the argument APPend to enable more than one channel. The following example illustrates two uses of the CHANnel<n>:DISPlay command.
SYSTem:MODE EYE CHANnel1:DISPlay ON CHANnel2:DISPlay ON
The result using the above set of commands, is Channel 1 cleared and disabled while Channel 2 is enabled and displayed. However, by adding the argument APPend to the last command of the set, both Channels 1 and 2 will be enabled and displayed .
SYSTem:MODE EYE CHANnel1:DISPlay ON
1-6
Introduction
Multiple Databases
CHANnel2:DISPlay ON,APPend
For a example of using multiple databases, refer to “multidatabase.c Sample Program” on
page 2-35.
Downloading a Database
The general process for downloading a color grade/gray scale database is as follows:
1 Send the command :WAVEFORM:SOURCE CGRADE
This will select the color grade/gray scale database as the waveform source.
2 Issue :WAVeform:FORMat WORD.
Database downloads only support word formatted data (16-bit integers).
3 Send the query :WAVeform:DATA?
The data will be sent by means of a block data transfer as a two-dimensional array, 451 words wide by 321 words high (refer to “Definite-Length Block Response Data” on page 1-26). The data is transferred starting with the upper left pixel of the display graticule, column by column, until the lower right pixel is transferred.
4 Send the command :WAVeform:XORigin to obtain the time of the left column.
5 Send the command :WAVeform:XINC to obtain the time increment of each column.
6 Send the command :WAVeform:YORigin to obtain the voltage or power of the vertical center
of the database.
7 Send the command :WAVeform:YORigin to obtain the voltage or power of the incremental row.
The information from steps 4 through 7 can also be obtained with the command :WAVe­form:PREamble.
Auto Skew Another multiple database feature is the auto skew. You can use the auto skew feature to set
the horizontal skew of multiple, active channels with the same bit rate, so that the waveform crossings align with each other. This can be very convient when viewing multiple eye dia­grams simultaneously. Slight differences between channels and test devices may cause a phase difference between channels. Auto skew ensures that each eye is properly aligned, so that measurements and mask tests can be properly executed.
In addition, auto skew optimizes the instrument trigger level. Prior to auto skew, at least one channel must display a complete eye diagram in order to make the initial bit rate measure­ment. Auto skew requires more data to be sampled; therefore, acquisition time during auto skew is slightly longer than acquisition time during measurements.
1-7
Introduction

Files

Files
When specifying a file name in a remote command, enclose the name in double quotation marks, such as "filename". If you specify a path, the path should be included in the quotation marks. All files stored using remote commands have file name extensions as listed in
Table 1-1. You can use the full path name, a relative path name, or no path.
Table 1-1. File Name Extensions
File Type File Name Extension Command
Waveform - internal format .wfm “STORe” on page 10-8
Waveform - text format (Verbose or Y values) .txt “STORe” on page 10-8
Pattern Waveform .csv “PWAVeform:SAVE” on page 10-6
Setup .set “STORe” on page 10-8
Color grade - Gray Scale .cgs “STORe” on page 10-8
Jitter Memory .jd “STORe” on page 10-8
Screen image
Mask .msk, .pcm “SAVE” on page 17-7
TDR/TDT .tdr “STORe” on page 10-8
MATLAB script .m “MATLab:SCRipt” on page 19-5
a
.bmp, .eps, .gif, .pcx, .ps, .jpg, .tif “SIMage” on page 10-6
a. For .gif and .tif file formats, this instrument uses LZW compression/decompression licensed under U.S. patent No 4,558,302 and foreign counterparts. End user should not modify, copy, or distribute LZW compression/decompression ca­pability. For .jpg file format, this instrument uses the .jpg software written by the Independent JPEG Group.
If you do not specify an extension when storing a file, or specify an incorrect extension, it will be corrected automatically according to the following rules:
• No extension specified: add the extension for the file type.
• Extension does not match file type: retain the filename, (including the current extension) and add the appropriate extension.
You do not need to use an extension when loading a file if you use the optional destination parameter. For example, :DISK:LOAD "STM1_OC3",SMASK will automatically add .msk to the file name. ASCII waveform files can be loaded only if the file name explicitly includes the .txt extension. Table 1-2 on page 1-9 shows the rules used when loading a specified file.
1-8
Introduction
Files
Table 1-2. Rules for Loading Files
File Name Extension Destination Rule
No extension Not specified Default to internal waveform format; add .wfm extension
Extension does not match file type Not specified Default to internal waveform format; add .wfm extension
Extension matches file type Not specified Use file name with no alterations; destination is based on extension
file type
No extension Specified Add extension for destination type; default for waveforms is internal
format (.wfm)
Extension does not match destination file type
Extension matches destination file type
File Locations If you don’t specify a directory when storing a file, the location of the file will be based on the
file type. The following table shows the default locations for storing files. On 86100C instru­ments, files are stored on the D: drive. On 86100A/B instruments, files are stored on the C: drive.
Specified Retain file name; add extension for destination type. Default for
waveforms is internal format (.wfm)
Specified Retain file name; destination is as specified
Table 1-3. Default File Locations
File Type Default Location
Waveform - internal format, text format (Verbose or Y values), D:\User Files\waveforms
Pattern Waveforms D:\User Files\waveforms
Setup D:\User Files\setups
Color Grade - Gray Scale D:\User Files\colorgrade-grayscale
Jitter Memory D:\User Files\jitter data
Screen Image D:\User Files\screen images
Mask C:\Scope\masks (standard masks)
D:\User Files\masks (user-defined masks)
TDR/TDT calibration data D:\User Files\TDR normalization
MATLAB script D:\User Files\Matlab scripts
When loading a file, you can specify the full path name, a relative path name, or no path name. The following table shows the rules for locating files, based on the path specified. Stan­dard masks loaded from D:\Scope\masks. Files may be stored to or loaded from any path external drive or on any mapped network drive.
1-9
Introduction
Files
Table 1-4. File Locations (Loading Files)
File Name Rule
Full path name Use file name and path specified
Relative path name Full path name is formed relative to the present working directory, set with the command :DISK:CDIR. The
present working directory can be read with the query :DISK:PWD?
File name with no preceding path
Add the file name to the default path (D:\User Files) based on the file type. (C drive on 86100A/B instruments.)
1-10
Introduction

Status Reporting

Status Reporting
Almost every program that you write will need to monitor the instrument for its operating status. This includes querying execution or command errors and determining whether or not measurements have been completed. Several status registers and queues are provided to accomplish these tasks. In this section, you’ll learn how to enable and read these registers.
• Refer to Figure 1-4 on page 1-14 for an overall status reporting decision chart.
• See Figure 1-3 and Figure 1-4 to learn the instrument's status reporting structure which allows you to monitor specific events in the instrument.
Table 1-5 on page 1-17 lists the bit definitions for each bit in the status reporting data struc­ture.
The Status Byte Register, the Standard Event Status Register group, and the Output Queue are defined as the Standard Status Data Structure Model in IEEE 488.2-1987. IEEE 488.2 defines data structures, commands, and common bit definitions for status reporting. There are also instrument-defined structures and bits.
To monitor an event, first clear the event, then enable the event. All of the events are cleared when you initialize the instrument. To generate a service request (SRQ) interrupt to an external computer, enable at least one bit in the Status Byte Register. To make it possible for any of the Standard Event Status Register bits to generate a summary bit, the corresponding bits must be enabled. These bits are enabled by using the *ESE common command to set the corresponding bit in the Standard Event Status Enable Register. To generate a service request (SRQ) interrupt to the computer, at least one bit in the Status Byte Register must be enabled. These bits are enabled by using the *SRE common command to set the correspond­ing bit in the Service Request Enable Register. These enabled bits can then set RQS and MSS (bit 6) in the Status Byte Register. For more information about common commands, see
Chapter 3, “Common Commands”.
Status Byte Register
The Status Byte Register is the summary-level register in the status reporting structure. It contains summary bits that monitor activity in the other status registers and queues. The Sta­tus Byte Register is a live register. That is, its summary bits are set and cleared by the pres­ence and absence of a summary bit from other event registers or queues. If the Status Byte Register is to be used with the Service Request Enable Register to set bit 6 (RQS/MSS) and to generate an SRQ, at least one of the summary bits must be enabled, then set. Also, event bits in all other status registers must be specifically enabled to generate the summary bit that sets the associated summary bit in the Status Byte Register.
The Status Byte Register can be read using either the *STB? common command query or the GPIB serial poll command. Both commands return the decimal-weighted sum of all set bits in the register. The difference between the two methods is that the serial poll command reads
1-11
Introduction
Status Reporting
bit 6 as the Request Service (RQS) bit and clears the bit which clears the SRQ interrupt. The *STB? query reads bit 6 as the Master Summary Status (MSS) and does not clear the bit or have any affect on the SRQ interrupt. The value returned is the total bit weights of all of the bits that are set at the present time.
Figure 1-2. Status Reporting Decision Chart
1-12
Introduction
Status Reporting
The use of bit 6 can be confusing. This bit was defined to cover all possible computer inter­faces, including a computer that could not do a serial poll. The important point to remember is that, if you are using an SRQ interrupt to an external computer, the serial poll command clears bit 6. Clearing bit 6 allows the instrument to generate another SRQ interrupt when another enabled event occurs. The only other bit in the Status Byte Register affected by the *STB? query is the Message Available bit (bit 4). If there are no other messages in the Output Queue, bit 4 (MAV) can be cleared as a result of reading the response to the *STB? query.
If bit 4 (weight = 16) and bit 5 (weight = 32) are set, a program would print the sum of the two weights. Since these bits were not enabled to generate an SRQ, bit 6 (weight = 64) is not set.
Figure 1-3. Status Reporting Overview
1-13
Introduction
Status Reporting
Figure 1-4. Status Reporting Data Structures
1-14
Introduction
Status Reporting
Status Reporting Data Structures (continued)
1-15
Introduction
Status Reporting
This BASIC example uses the *STB? query to read the contents of the instrument’s Status Byte Register when none of the register's summary bits are enabled to generate an SRQ inter­rupt.
10 OUTPUT 707;":SYSTEM:HEADER OFF;*STB?"!Turn headers off 20 ENTER 707;Result!Place result in a numeric variable 30 PRINT Result!Print the result 40 End
The next program prints 132 and clears bit 6 (RQS) of the Status Byte Register. The differ­ence in the decimal value between this example and the previous one is the value of bit 6 (weight = 64). Bit 6 is set when the first enabled summary bit is set, and is cleared when the Status Byte Register is read by the serial poll command.
This example uses the BASIC serial poll (SPOLL) command to read the contents of the instrument’s Status Byte Register.
10 Result = SPOLL(707) 20 PRINT Result 30 END
Use Serial Polling to Read the Status Byte Register. Serial polling is the preferred method to read the contents of the Status Byte Register because it resets bit 6 and allows the next enabled event that occurs to generate a new SRQ interrupt.
Service Request Enable Register
Trigger Event Register (TRG)
Setting the Service Request Enable Register bits enables corresponding bits in the Status Byte Register. These enabled bits can then set RQS and MSS (bit 6) in the Status Byte Regis­ter. Bits are set in the Service Request Enable Register using the *SRE command, and the bits that are set are read with the *SRE? query. Bit 6 always returns 0. Refer to the Status Reporting Data Structures shown in Figure 1-4This example sets bit 4 (MAV) and bit 5 (ESB) in the Service Request Enable Register.
OUTPUT 707;"*SRE 48"
This example uses the parameter “48” to allow the instrument to generate an SRQ interrupt under the following conditions:
• When one or more bytes in the Output Queue set bit 4 (MAV).
• When an enabled event in the Standard Event Status Register generates a summary bit that sets bit 5 (ESB).
This register sets the TRG bit in the status byte when a trigger event occurs. The TRG event register stays set until it is cleared by reading the register or using the *CLS (clear status) command. If your application needs to detect multiple triggers, the TRG event register must be cleared after each one. If you are using the Service Request to interrupt a computer oper­ation when the trigger bit is set, you must clear the event register after each time it is set.
1-16
Introduction
Status Reporting
Table 1-5. Status Reporting Bit Definition (1 of 2)
Bit Description Definition
ACQ Acquisition Indicates that acquisition test has completed in the Acquisition Register.
AREQD Autoscale Required Indicates that a parameter change in Jitter Mode has made an autoscale necessary.
CLCK CloCk Indicates that one of the enabled conditions in the Clock Recovery Register has
occurred.
CME Command Error Indicates if the parser detected an error.
COMP Complete Indicates the specified test has completed.
DDE Device Dependent Error Indicates if the device was unable to complete an operation for device dependent
reasons.
EFAIL Edge Characterization
Fail
ESB Event Status Bit Indicates if any of the enabled conditions in the Standard Event Status Register have
EXE Execution Error Indicates if a parameter was out of range or was inconsistent with the current
FAIL Fail Indicates the specified test has failed.
JLOSS Pattern Synchronization
Loss
LCL Local Indicates if a remote-to-local transition occurs.
LOCK LOCKed Indicates that a locked or trigger capture condition has occurred in the Clock Recovery
LOSS Time Reference Loss Indicates the Precision Timebase (provided by the Agilent 86107A module) has
LTEST Limit Test Indicates that one of the enabled conditions in the Limit Test Register has occurred.
MAV Message Available Indicates if there is a response in the output queue.
MSG Message Indicates if an advisory has been displayed.
MSS Master Summary Status Indicates if a device has a reason for requesting service.
MTEST Mask Test Indicates that one of the enabled conditions in the Mask Test Register has occurred.
NSPR1 No Signal Present
Receiver 1
NSPR2 No Signal Present
Receiver 2
OPC Operation Complete Indicates if the device has completed all pending operations.
OPER Operation Status
Register
PON Power On Indicates power is turned on.
Indicates that the characterizing of edges in Jitter Mode has failed.
occurred.
settings.
Indicates that the pattern synchronization is lost in Jitter Mode.
Module.
detected a time reference loss due to a change in the reference clock signal.
Indicates that the Clock Recovery Module has detected the loss of an optical signal on receiver one.
Indicates that the Clock Recovery Module has detected the loss of an optical signal on receiver two.
Indicates if any of the enabled conditions in the Operation Status Register have occurred.
1-17
Introduction
Status Reporting
Table 1-5. Status Reporting Bit Definition (2 of 2)
Bit Description Definition
PTIME Precision Timebase Indicates that one of the enabled conditions in the Precision Timebase Register has
occurred.
QYE Query Error Indicates if the protocol for queries has been violated.
RQL Request Control Indicates if the device is requesting control.
RQS Request Service Indicates that the device is requesting service.
SPR1 Signal Present
Receiver 1
SPR2 Signal Present
Receiver 2
TRG Trigger Indicates if a trigger has been received.
UNLK UNLoCKed Indicates that an unlocked or trigger loss condition has occurred in the Clock Recovery
URQ Not used. Permanently set to zero.
USR User Event Register Indicates if any of the enabled conditions have occurred in the User Event Register.
Indicates that the Clock Recovery Module has detected an optical signal on receiver one.
Indicates that the Clock Recovery Module has detected an optical signal on receiver two.
Module.
Standard Event Status Register
The Standard Event Status Register (SESR) monitors the following instrument status events:
•PON - Power On
• CME - Command Error
• EXE - Execution Error
• DDE - Device Dependent Error
• QYE - Query Error
• RQC - Request Control
• OPC - Operation Complete
When one of these events occurs, the corresponding bit is set in the register. If the corre­sponding bit is also enabled in the Standard Event Status Enable Register, a summary bit (ESB) in the Status Byte Register is set. The contents of the Standard Event Status Register can be read and the register cleared by sending the *ESR? query. The value returned is the total bit weights of all of the bits set at the present time. If bit 4 (weight = 16) and bit 5 (weight = 32) are set, the program prints the sum of the two weights.
This example uses the *ESR? query to read the contents of the Standard Event Status Regis­ter.
10 OUTPUT 707;":SYSTEM:HEADER OFF"!Turn headers off 20 OUTPUT 707;"*ESR?" 30 ENTER 707;Result!Place result in a numeric variable 40 PRINT Result!Print the result 50 End
1-18
Introduction
Status Reporting
Standard Event Status Enable Register
NOTE Disabled SESR Bits Respond, but Do Not Generate a Summary Bit. Standard Event Status Register bits that are
User Event Register (UER)
Local Event Register (LCL)
For any of the Standard Event Status Register (SESR) bits to generate a summary bit, you must first enable the bit. Use the *ESE (Event Status Enable) common command to set the corresponding bit in the Standard Event Status Enable Register. Set bits are read with the *ESE? query. Suppose your application requires an interrupt whenever any type of error occurs. The error status bits in the Standard Event Status Register are bits 2 through 5. The sum of the decimal weights of these bits is 60. Therefore, you can enable any of these bits to generate the summary bit by sending:
OUTPUT 707;"*ESE 60"
Whenever an error occurs, the instrument sets one of these bits in the Standard Event Status Register. Because the bits are all enabled, a summary bit is generated to set bit 5 (ESB) in the Status Byte Register. If bit 5 (ESB) in the Status Byte Register is enabled (via the *SRE com­mand), a service request interrupt (SRQ) is sent to the external computer.
not enabled still respond to their corresponding conditions (that is, they are set if the corresponding event occurs). However, because they are not enabled, they do not generate a summary bit in the Status Byte Register.
This register hosts the LCL bit (bit 0) from the Local Events Register. The other 15 bits are reserved. You can read and clear this register using the UER? query. This register is enabled with the UEE command. For example, if you want to enable the LCL bit, you send a mask value of 1 with the UEE command; otherwise, send a mask value of 0.
This register sets the LCL bit in the User Event Register and the USR bit (bit 1) in the Status byte. It indicates a remote-to-local transition has occurred. The LER? query is used to read and to clear this register.
Operation Status Register (OPR)
This register hosts the CLCK bit (bit 7), the LTEST bit (bit 8), the ACQ bit (bit 9) and the MTEST bit (bit 10). The CLCK bit is set when any of the enabled conditions in the Clock Recovery Event Register have occurred. The LTEST bit is set when a limit test fails or is com­pleted and sets the corresponding FAIL or COMP bit in the Limit Test Events Register. The ACQ bit is set when the COMP bit is set in the Acquisition Event Register, indicating that the data acquisition has satisfied the specified completion criteria. The MTEST bit is set when the Mask Test either fails specified conditions or satisfies its completion criteria, setting the corresponding FAIl or COMP bits in the Mask Test Events Register. The PTIME bit is set when there is a loss of the precision timebase reference occurs setting a bit in the Precision Timebase Events Register. The JIT bit is set in Jitter Mode when a bit is set in the Jitter Events Register. This occurs when there is a failure or an autoscale is needed. If any of these bits are set, the OPER bit (bit 7) of the Status Byte register is set. The Operation Status Reg­ister is read and cleared with the OPER? query. The register output is enabled or disabled using the mask value supplied with the OPEE command.
1-19
Introduction
Status Reporting
Acquisition Event Register (AER)
Clock Recovery Event Register (CRER)
Bit 0 (COMP) of the Acquisition Event Register is set when the acquisition limits complete. The Acquisition completion criteria are set by the ACQuire:RUNtil command. Refer to
“RUNTil” on page 6-4. The Acquisition Event Register is read and cleared with the ALER?
query. Refer to “ALER?” on page 4-3.
This register hosts the UNLK bit (bit 0), LOCK bit (bit 1), NSPR1 bit (bit 2), SPR1 bit (bit 3), NSPR2 bit (bit 4) and SPR2 (bit 5). Bit 0 (UNLK) of the Clock Recovery Event Register is set when an 83491/2/3/4/5/6A clock recovery module becomes unlocked or trigger loss has occurred. Bit 1 (LOCK) of the Clock Recovery Event Register is set when a clock recovery module becomes locked or a trigger capture has occurred. If an 83496A module is locked, sending the CRECovery:RELock command does not set UNLK bit (bit 0) or LOCK bit (bit 1). To determine if the RELock command has completed, use the CRECovery:LOCKed? query. Refer to “RELock” on page 9-10.
Bits 2 through 5 provide information on optical signals and so are not effected by 83495A modules. Bit 2 (NSPR1) of the Clock Recovery Event Register is set when an clock recovery module transitions to no longer detecting an optical signal on receiver one. Bit 3 (SPR1) of the Clock Recovery Event Register is set when an clock recovery module transitions to detecting an optical signal on receiver one. Bit 4 (NSPR2) of the Clock Recovery Event Regis­ter is set when an clock recovery module transitions to no longer detecting an optical signal on receiver two. Bit 5 (SPR2) of the Clock Recovery Event Register is set when an clock recovery module transitions to detecting an optical signal on receiver two. The Clock Recov­ery Event Register is read and cleared with the CRER? query. Refer to “CRER?” on page 4-6. When either of the UNLK, LOCK, NSPR1, SPR1, NSPR2 or SPR2 bits are set, they in turn set CLCK bit (bit 7) of the Operation Status Register. Results from the Clock Recovery Event Register can be masked by using the CREE command to set the Clock Recovery Event Enable Register. Refer to Refer to “CREE” on page 4-5 for enable and mask value definitions.
Limit Test Event Register (LTER)
Jitter Event Register (JIT)
Bit 0 (COMP) of the Limit Test Event Register is set when the Limit Test completes. The Limit Test completion criteria are set by the LTESt:RUN command. Refer to “RUNTil” on
page 15-4. Bit 1 (FAIL) of the Limit Test Event Register is set when the Limit Test fails. Fail-
ure criteria for the Limit Test are defined by the LTESt:FAIL command. Refer to “FAIL” on
page 15-2. The Limit Test Event Register is read and cleared with the LTER? query. Refer to “LTER?” on page 4-9. When either the COMP or FAIL bits are set, they in turn set the LTEST
bit (bit 8) of the Operation Status Register. You can mask the COMP and FAIL bits, thus pre­venting them from setting the LTEST bit, by defining a mask using the LTEE command. Refer
to “LTEE” on page 4-9. When the COMP bit is set, it in turn sets the ACQ bit (bit 9) of the
Operation Status Register. Results from the Acquisition Register can be masked by using the AEEN command to set the Acquisition Event Enable Register to the value 0. You enable the COMP bit by setting the mask value to 1.
Bit 0 (EFAIL) of the Jitter Event Register is set when characterizing edges in Jitter Mode fails. Bit 1 (JLOSS) of the register is set when pattern synchronization is lost in Jitter Mode. Bit 2 (AREQD) of the register is set when a parameter change in Jitter Mode has made autoscale necessary. Bit 12 of the Operation Status Register (JIT) indicates that one of the
1-20
Introduction
Status Reporting
enabled conditions in the Jitter Event Register has occurred. You can mask the EFAIL, JLOSS, and AREQD bits, thus preventing them from setting the JIT bit, by setting corre­sponding bits to zero using the JEE command. Refer to “JEE” on page 4-7.
Mask Test Event Register (MTER)
Precision Timebase Event Register (PTER)
Error Queue As errors are detected, they are placed in an error queue. This queue is first in, first out. If
Bit 0 (COMP) of the Mask Test Event Register is set when the Mask Test completes. The Mask Test completion criteria are set by the MTESt:RUNTil command. Refer to “RUNTil” on
page 17-6. Bit 1 (FAIL) of the Mask Test Event Register is set when the Mask Test fails. This
will occur whenever any sample is recorded within any region defined in the mask. The Mask Test Event Register is read and cleared with the MTER? query. Refer to “MTER?” on
page 4-10. When either the COMP or FAIL bits are set, they in turn set the MTEST bit (bit
10) of the Operation Status Register. You can mask the COMP and FAIL bits, thus preventing them from setting the MTEST bit, by setting corresponding bits to zero using the MTEE com­mand. Refer to “MTEE” on page 4-10.
The Precision Timebase feature requires the installation of the Agilent 86107A Precision Timebase Module. Bit 0 (LOSS) of the Precision Timebase Event Register is set when loss of the time reference occurs. Time reference is lost when a change in the amplitude or fre­quency of the reference clock signal is detected. The Precision Timebase Event Register is read and cleared with the PTER? query. Refer to “PTER?” on page 4-12. When the LOSS bit is set, it in turn sets the PTIME bit (bit 11) of the Operation Status Register. Results from the Precision Timebase Register can be masked by using the PTEE command to set the Precision Timebase Event Enable Register to the value 0. You enable the LOSS bit by setting the mask value to 1. Refer to “PTEE” on page 4-11.
the error queue overflows, the last error in the queue is replaced with error –350, “Queue overflow”. Any time the queue overflows, the oldest errors remain in the queue, and the most recent error is discarded. The length of the instrument's error queue is 30 (29 positions for the error messages, and 1 position for the “Queue overflow” message). The error queue is read with the SYSTEM:ERROR? query. Executing this query reads and removes the oldest error from the head of the queue, which opens a position at the tail of the queue for a new error. When all the errors have been read from the queue, subsequent error queries return 0, “No error.” The error queue is cleared when any of the following occurs:
• When the instrument is powered up.
• When the instrument receives the *CLS common command.
• When the last item is read from the error queue.
For more information on reading the error queue, refer to the SYSTEM:ERROR? query in
Chapter 5, “System Commands”. For a complete list of error messages, refer to “Error Mes­sages” on page 1-44.
1-21
Introduction
Status Reporting
Output Queue The output queue stores the instrument-to-computer responses that are generated by cer-
tain instrument commands and queries. The output queue generates the Message Available summary bit when the output queue contains one or more bytes. This summary bit sets the MAV bit (bit 4) in the Status Byte Register. The output queue may be read with the BASIC ENTER statement.
Message Queue The message queue contains the text of the last message written to the advisory line on the
screen of the instrument. The queue is read with the SYSTEM:DSP? query. Note that mes­sages sent with the SYSTem:DSP command do not set the MSG status bit in the Status Byte Register.
Clearing Registers and Queues
The *CLS common command clears all event registers and all queues except the output queue. If *CLS is sent immediately following a program message terminator, the output queue is also cleared.
1-22
Introduction

Command Syntax

Command Syntax
In accordance with IEEE 488.2, the instrument’s commands are grouped into “subsystems.” Commands in each subsystem perform similar tasks. Starting with Chapter 5, “System Com-
mands” each chapter covers a separate subsystem.
Sending a Command
Short or Long Forms
It’s easy to send a command to the instrument. Simply create a command string from the commands listed in this book, and place the string in your program language’s output state­ment. For commands other than common commands, include a colon before the subsystem name. For example, the following string places the cursor on the peak laser line and returns the power level of this peak:
OUTPUT 720;”:MEAS:SCAL:POW? MAX”
Commands can be sent using any combination of uppercase or lowercase ASCII characters. Instrument responses, however, are always returned in uppercase.
The program instructions within a data message are executed after the program message ter­minator is received. The terminator may be either a NL (new line) character, an EOI (End­Or-Identify) asserted in the GPIB interface, or a combination of the two. Asserting the EOI sets the EOI control line low on the last byte of the data message. The NL character is an ASCII linefeed (decimal 10). The NL (New Line) terminator has the same function as an EOS (End Of String) and EOT (End Of Text) terminator.
Commands and queries may be sent in either long form (complete spelling) or short form (abbreviated spelling). The description of each command in this manual shows both versions; the extra characters for the long form are shown in lowercase. However, commands can be sent using any combination of uppercase or lowercase ASCII characters. Instrument responses, however, are always returned in uppercase. Programs written in long form are easily read and are almost self-documenting. Using short form commands conserves the amount of controller memory needed for program storage and reduces the amount of I/O activity.
The short form is the first four characters of the keyword, unless the fourth character is a vowel. Then the mnemonic is the first three characters of the keyword. If the length of the keyword is four characters or less, this rule does not apply, and the short form is the same as the long form.
For example:
:TIMEBASE:DELAY 1E-6 is the long form.
:TIM:DEL 1E-6 is the short form.
1-23
Introduction
Command Syntax
.
Table 1-6. Long and Short Command Forms
Long Form Short Form How the Rule is Applied
RANGE RANG Short form is the first four characters of the keyword.
PATTERN PATT Short form is the first four characters of the keyword.
DISK DISK Short form is the same as the long form.
DELAY DEL Fourth character is a vowel, short form is the first three characters.
White Space White space is defined to be one or more characters from the ASCII set of 0 through 32 deci-
mal, excluding 10 (NL). White space is usually optional, and can be used to increase the read­ability of a program.
Combining Commands
You can combine commands from the same subsystem provided that they are both on the same level in the subsystem’s hierarchy. Simply separate the commands with a semi-colon (;). If you have selected a subsystem, and a common command is received by the instrument, the instrument remains in the selected subsystem. For example, the following commands turn averaging on, then clears the status information without leaving the selected subsystem.
":ACQUIRE:AVERAGE ON;*CLS;COUNT 1024"
You can send commands and program queries from different subsystems on the same line. Simply precede the new subsystem by a semicolon followed by a colon.
Multiple commands may be any combination of compound and simple commands. For exam­ple:
:CHANNEL1:RANGE 0.4;:TIMEBASE:RANGE 1
Adding parameters to a command
String Arguments Strings contain groups of alphanumeric characters which are treated as a unit of data by the
Many commands have parameters that specify an option. Use a space character to separate the parameter from the command as shown in the following line:
OUTPUT 720;”:INIT:CONT ON”
Separate multiple parameters with a comma (,). Spaces can be added around the commas to improve readability.
OUTPUT 720;”:MEAS:SCAL:POW:FREQ? 1300, MAX”
instrument. You may delimit embedded strings with either single (') or double (") quotation marks. These strings are case-sensitive, and spaces act as legal characters just like any other character. For example, this command writes the line string argument to the instrument’s advisory line:
:SYSTEM:DSP ""This is a message.""
1-24
Introduction
Command Syntax
Numbers Some commands require number arguments. All numbers are expected to be strings of ASCII
characters. You can use exponential notation or suffix multipliers to indicate the numeric value. The following numbers are all equal:
28 = 0.28E2 = 280E-1 = 28000m = 0.028K = 28E-3K
When a syntax definition specifies that a number is an integer, any fractional part is ignored and truncated. Using "mV" or "V" following the numeric voltage value in some commands will cause Error 138–Suffix not allowed. Instead, use the convention for the suffix multiplier.
.
Table 1-7. <suffix mult>
Value Mnemonic Value Mnemonic
1E18 EX 1E-3 m
1E15 PE 1E-6 u
1E12 T 1E-9 n
1E9 G 1E-12 p
1E6 MA 1E-15 f
1E3 K 1E-18 a
Infinity Representation
Sequential and Overlapped Commands
Table 1-8. <suffix unit>
Suffix Referenced Unit
VVolt
s Second
WWatt
BIT Bits
dB Decibel
% Percent
Hz Hertz
The representation for infinity for this instrument is 9.99999E+37. This is also the value returned when a measurement cannot be made.
IEEE 488.2 makes a distinction between sequential and overlapped commands. Sequential commands finish their task before the execution of the next command starts. Overlapped commands run concurrently. Commands following an overlapped command may be started before the overlapped command is completed. The common commands *WAI and *OPC may be used to ensure that commands are completely processed before subsequent commands are executed.
1-25
Introduction
Command Syntax
Definite-Length Block Response Data
Queries Command headers immediately followed by a question mark (?) are queries. After receiving a
Definite-length block response data allows any type of device-dependent data to be transmit­ted over the system interface as a series of 8-bit binary data bytes. This is particularly useful for sending large quantities of data or 8-bit extended ASCII codes. The syntax is a pound sign (#) followed by a non-zero digit representing the number of digits in the decimal integer. After the non-zero digit is the decimal integer that states the number of 8-bit data bytes being sent. This is followed by the actual data. For example, for transmitting 4000 bytes of data, the syntax would be:
#44000 <4000 bytes of data> <terminator>
The leftmost “4” represents the number of digits in the number of bytes, and “4000” repre­sents the number of bytes to be transmitted.
query, the instrument interrogates the requested subsystem and places the answer in its out­put queue. The answer remains in the output queue until it is read or until another command is issued. When read, the answer is transmitted across the bus to the designated listener (typically a computer). For example, the query:
:TIMEBASE:RANGE?
places the current time base setting in the output queue. In BASIC, the computer input state­ment:
ENTER < device address >;Range
passes the value across the bus to the computer and places it in the variable Range. You can use query commands to find out how the instrument is currently configured. They are also used to get results of measurements made by the instrument. For example, the command:
:MEASURE:RISETIME?
tells the instrument to measure the rise time of your waveform and place the result in the output queue. The output queue must be read before the next program message is sent. For example, when you send the query :MEASURE:RISETIME? you must follow it with an input statement. In BASIC, this is usually done with an ENTER statement immediately followed by a variable name. This statement reads the result of the query and places the result in a speci­fied variable. If you send another command or query before reading the result of a query, the output buffer is cleared and the current response is lost. This also generates a query-inter­rupted error in the error queue. If you execute an input statement before you send a query, it will cause the computer to wait indefinitely.
If a measurement cannot be made because of the lack of data, because the source signal is not displayed, the requested measurement is not possible (for example, a period measure­ment on an FFT waveform), or for some other reason, 9.99999E+37 is returned as the mea-
surement result. In TDR mode with ohms specified, the returned value is 838MΩ.
You can send multiple queries to the instrument within a single program message, but you must also read them back within a single program message. This can be accomplished by either reading them back into a string variable or into multiple numeric variables. For exam­ple, you could read the result of the query :TIMEBASE:RANGE?;DELAY? into the string vari­able Results$ with the command: ENTER 707;Results$
1-26
Introduction
Command Syntax
When you read the result of multiple queries into string variables, each response is separated by a semicolon. For example, the response of the query :TIMEBASE:RANGE?;DELAY? would be:
<range_value>;<delay_value>
Use the following program message to read the query :TIMEBASE:RANGE?;DELAY? into multiple numeric variables:
ENTER 707;Result1,Result2
The Command Tree
The command tree in Figure 1-5 on page 1-29 shows all of the commands in the Agilent 86100A and the relationship of the commands to each other. The IEEE 488.2 com­mon commands do not affect the position of the parser within the tree.
A leading colon or a program message terminator (<NL> or EOI true on the last byte) places the parser at the root of the command tree. A leading colon is a colon that is the first charac­ter of a program header. Executing a subsystem command places you in that subsystem until a leading colon or a program message terminator is found.
The commands in this instrument can be placed into three types: common commands, root level commands, and subsystem commands.
• Common commands (defined by IEEE 488.2) control functions that are common to all IEEE
488.2 instruments. These commands are independent of the tree and do not affect the position of the parser within the tree. *RST is an example of a common command.
• Root level commands control many of the basic functions of the instrument. These commands reside at the root of the command tree. They can always be parsed if they occur at the begin­ning of a program message or are preceded by a colon. Unlike common commands, root level commands place the parser back at the root of the command tree. AUTOSCALE is an example of a root level command.
• Subsystem commands are grouped together under a common node of the command tree, such as the TIMEBASE commands. Only one subsystem may be selected at a given time. When the instrument is initially turned on, the command parser is set to the root of the command tree and no subsystem is selected.
Command headers are created by traversing down the command tree. A legal command header from the command tree would be :TIMEBASE:RANGE. It consists of the subsystem followed by a command separated by colons. The compound header contains no spaces.
In the command tree, use the last mnemonic in the compound header as a reference point (for example, RANGE). Then find the last colon above that mnemonic (TIMEBASE:). That is the point where the parser resides. Any command below this point can be sent within the current program message without sending the mnemonics which appear above them (for example, REFERENCE).
Use a colon to separate two commands in the same subsystem.
OUTPUT 707;":CHANNEL1:RANGE 0.5;OFFSET 0"
1-27
Introduction
Command Syntax
The colon between CHANNEL1 and RANGE is necessary because CHANNEL1:RANGE spec­ifies a command in a subsystem. The semicolon between the RANGE command and the OFF­SET command is required to separate the two commands. The OFFSET command does not need CHANNEL1 preceding it because the CHANNEL1:RANGE command sets the parser to the CHANNEL1 node in the tree.
1-28
Introduction
Command Syntax
Figure 1-5. Command Tree
1-29
Introduction
Command Syntax
Command Tree (Continued)
1-30
Introduction
Command Syntax
Command Tree (Continued)
1-31
Introduction
Command Syntax
Command Tree (Continued)
1-32
Introduction

Interface Functions

Command Tree (Continued)
Interface Functions
The interface functions deal with general bus management issues, as well as messages that can be sent over the bus as bus commands. In general, these functions are defined by IEEE
488.1. The instrument is equipped with a GPIB interface connector on the rear panel. This allows direct connection to a GPIB equipped computer. You can connect an external GPIB compatible device to the instrument by installing a GPIB cable between the two units. Finger tighten the captive screws on both ends of the GPIB cable to avoid accidentally disconnecting the cable during operation. A maximum of fifteen GPIB compatible instruments (including a
1-33
Introduction
Interface Functions
computer) can be interconnected in a system by stacking connectors. This allows the instru­ments to be connected in virtually any configuration, as long as there is a path from the com­puter to every device operating on the bus. The interface capabilities of this instrument, as defined by IEEE 488.1, are listed in the Table 1-9 on page 1-35.
CAUTION Avoid stacking more than three or four cables on any one connector. Multiple connectors produce leverage that
can damage a connector mounting.
GPIB Default Startup Conditions
Command and Data Concepts
Communicating Over the Bus
The following default GPIB conditions are established during power-up: 1) The Request Ser­vice (RQS) bit in the status byte register is set to zero. 2) All of the event registers, the Stan­dard Event Status Enable Register, Service Request Enable Register, and the Status Byte Register are cleared.
The GPIB has two modes of operation, command mode and data mode. The bus is in the com­mand mode when the Attention (ATN) control line is true. The command mode is used to send talk and listen addresses and various bus commands such as group execute trigger (GET). The bus is in the data mode when the ATN line is false. The data mode is used to con­vey device-dependent messages across the bus. The device-dependent messages include all of the instrument specific commands, queries, and responses found in this manual, including instrument status information.
Device addresses are sent by the computer in the command mode to specify who talks and who listens. Because GPIB can address multiple devices through the same interface card, the device address passed with the program message must include the correct interface select code and the correct instrument address.
Device Address = (Interface Select Code * 100) + (Instrument Address)
The examples in this manual assume that the instrument is at device address 707. Each inter­face card has a unique interface select code. This code is used by the computer to direct com­mands and communications to the proper interface. The default is typically “7” for GPIB interface cards. Each instrument on the GPIB must have a unique instrument address between decimal 0 and 30. This instrument address is used by the computer to direct com­mands and communications to the proper instrument on an interface. The default is typically “7” for this instrument. You can change the instrument address in the Utilities, Remote Inter­face dialog box.
NOTE Do Not Use Address 21 for an Instrument Address. Address 21 is usually reserved for the Computer interface
Talk/Listen address and should not be used as an instrument address.
Bus Commands The following commands are IEEE 488.1 bus commands (ATN true). IEEE 488.2 defines
many of the actions that are taken when these commands are received by the instrument. The device clear (DCL) and selected device clear (SDC) commands clear the input buffer and output queue, reset the parser, and clear any pending commands. If either of these com­mands is sent during a digitize operation, the digitize operation is aborted. The group execute trigger (GET) command arms the trigger. This is the same action produced by sending the
1-34
Introduction
Interface Functions
RUN command. The interface clear (IFC) command halts all bus activity. This includes unad­dressing all listeners and the talker, disabling serial poll on all devices, and returning control to the system computer.
Table 1-9. Interface Capabilities
Code Interface Function Capability
SH1 Source Handshake Full Capability
AH1 Acceptor Handshake Full Capability
T5 Talker Basic Talker/Serial Poll/Talk Only Mode/. Unaddress if Listen Address (MLA)
L4 Listener Basic Listener/. Unaddresses if Talk Address (MTA)
SR1 Service Request Full Capability
RL1 Remote Local Complete Capability
PP1 Parallel Poll Remote Configuration
DC1 Device Clear Full Capability
DT1 Device Trigger Full Capability
C0 Computer No Capability
E2 Driver Electronics Tri State (1 MB/SEC MAX)
1-35
Introduction

Language Compatibility

Language Compatibility
This section lists Agilent 83480A commands that are not used in the 86100A/B/C.
Agilent 83480A/54750A Commands Not Used in the Instrument (1 of 6)
Programming Commands/Queries Replacement Commands/Queries
Common Commands
*LRN SYSTEM:SETUP
Root Level Commands
:AER? No replacement
:ERASe No replacement
:HEEN :AEEN
:MENU No replacement
:MERGe No replacement
:STORe:PMEMory1 No replacement
:TEER No replacement
System Commands :SYSTem
:SYSTem:KEY No replacement
Calibration Commands :CALibrate
:CALibrate:FRAMe:CANCel :CALibrate:CANcel
:CALibrate:FRAMe:CONTinue :CALibrate:CONTinue
:CALibrate:FRAMe:DATA No replacement
:CALibrate:FRAMe:DONE? :CALibrate:STATus?
:CALibrate:FRAMe:MEMory? No replacement
:CALibrate:PLUGin:ACCuracy :CALibrate:MODule:STATus
:CALibrate:PLUGin:CANCel :CALibrate:CANcel
:CALibrate:PLUGin:CONTinue :CALibrate:CONTinue
:CALibrate:PLUGin:DONE? :CALibrate:STATus?
:CALibrate:PLUGin:MEMory? No replacement
:CALibrate:PLUGin:OFFSet :CALibrate:MODule:OFFSet
:CALibrate:PLUGin:OPOWer :CALibrate:MODule:OPOWer
1-36
Agilent 83480A/54750A Commands Not Used in the Instrument (2 of 6)
:CALibrate:PLUGin:OPTical :CALibrate:MODule:OPTical
:CALibrate:PLUGin:OWAVelength :CALibrate:MODule:OWAVelength
:CALibrate:PLUGin:TIME? :CALibrate:MODule:TIME?
:CALibrate:PLUGin:VERTical :CALibrate:MODule:VERtical
:CALibrate:PROBe :CALibrate:PROBe CHANnel<N>
Channel Commands :CHANnel
:CHANnel<N>:AUTOscale :AUToscale
:CHANnel<N>:SKEW :CALibrate:SKEW
Disk Commands :DISK
:DISK:DATA? No replacement
:DISK:FORMat No replacement
Display Commands :DISPlay
:DISPlay:ASSign No replacement
:DISPlay:CGRade :SYSTem:MODE EYE
:DISPlay:CGRade? :SYSTem:MODE?
:DISPlay:COLumn :DISPlay:LABel
:DISPlay:DATA :WAVeform:DATA
:DISPlay:DWAVeform No replacement
:DISPlay:FORMat No replacement
:DISPlay:INVerse :DISPlay:LABel
:DISPlay:LINE :DISPlay:LABel
:DISPlay:MASK No replacement
:DISPlay:ROW :DISPlay:LABel
:DISPlay:SOURce No replacement
:DISPlay:STRing :DISPlay:LABel
:DISPlay:TEXT :DISPlay:LABel:DALL
FFT Commands :FFT
FFT is not available in the 86100A/B.
Function Commands :FUNCtion
:FUNCtion<N>:ADD No replacement
:FUNCtion<N>:BWLimit No replacement
:FUNCtion<N>:DIFFerentiate No replacement
Introduction
Language Compatibility
1-37
Introduction
Language Compatibility
Agilent 83480A/54750A Commands Not Used in the Instrument (3 of 6)
:FUNCtion<N>:DIVide No replacement
:FUNCtion<N>:FFT No replacement, FFT not available
:FUNCtion<N>:INTegrate No replacement
:FUNCtion<N>:MULTiply No replacement
:FUNCtion<N>:ONLY :FUNCtion<N>:MAGNify
Hardcopy Commands :HARDcopy
:HARDcopy:ADDRess :HARDcopy:DPRinte
:HARDcopy:BACKground :HARDcopy:IMAGe INVert
:HARDcopy:BACKground? No replacement
:HARDcopy:DESTination No replacement
:HARDcopy:DEVice No replacement
:HARDcopy:FFEed No replacement
:HARDcopy:FILename No replacement
:HARDcopy:LENGth No replacement
:HARDcopy:MEDia No replacement
Histogram Commands :HISTogram
:HISTogram:RRATe :DISPlay:RRATe
:HISTogram:RUNTil :ACQuire:RUNTil
:HISTogram:SCALe :HISTogram:SCALe:SIZE
:HISTogram:SCALe:OFFSet :HISTogram:SCALe:SIZE
:HISTogram:SCALe:RANGe :HISTogram:SCALe:SIZE
:HISTogram:SCALe:SCALe :HISTogram:SCALe:SIZE
:HISTogram:SCALe:TYPE :HISTogram:SCALe:SIZE
Limit Test Commands :LTESt
:LTESt:SSCReen:DDISk:BACKground :LTESt:SSCReen:IMAGe
:LTESt:SSCReen:DDISk:MEDia No replacement
:LTESt:SSCReen:DDISk:PFORmat No replacement
:LTESt:SSCReen:DPRinter:ADDRess No replacement
:LTESt:SSCReen:DPRinter:BACKground No replacement
:LTESt:SSCReen:DPRinter:MEDia No replacement
:LTESt:SSCReen:DPRinter:PORT No replacement
:LTESt:SSUMmary:ADDRess No replacement
1-38
Agilent 83480A/54750A Commands Not Used in the Instrument (4 of 6)
:LTESt:SSUMmary:MEDia No replacement
:LTESt:SSUMmary:PFORmat No replacement
:LTESt:SSUMmary:PORT No replacement
Marker Commands :MARKer
:MARKer:CURSor? No replacement. Use individual queries.
:MARKer:MEASurement:READout No replacement
:MARKer:MODE :MARKer:STATe
:MARKer:MODE? No replacement
:MARKer:TDELta? :MARKer:XDELta?
:MARKer:TSTArt :MARKer:X1Position
:MARKer:TSTOp :MARKer:X2Position
:MARKer:VDELta :MARKer:YDELta
:MARKer:VSTArt :MARKer:Y1Position
:MARKer:VSTOp :MARKer:Y2Position
Mask Test Commands :MTESt
:MTESt:AMASk:CReate No replacement
:MTESt:AMASk:SOURce No replacement
:MTESt:AMASk:UNITs No replacement
:MTESt:AMASk:XDELta No replacement
:MTESt:AMASk:YDELta No replacement
:MTESt:AMODe No replacement
:MTESt:COUNt:FWAVeforms? MTESt:COUNt:HITS? TOTal
:MTESt:FENable No replacement
:MTESt:MASK:DEFine
:MTESt:POLYgon:DEFine
:MTESt:POLYgon:DELete
:MTESt:POLYgon:MOVE
No replacement
No replacement
No replacement
No replacement
:MTESt:RECall :MTESt:LOAD
:MTESt:SAVE No replacement
:MTESt:SSCReen:DDISk:BACKground :MTESt:SSCReen:IMAGe
:MTESt:SSCReen:DDISk:MEDia No replacement
:MTESt:SSCReen:DDISk:PFORmat No replacement
a
a
a
a
Introduction
Language Compatibility
1-39
Introduction
Language Compatibility
Agilent 83480A/54750A Commands Not Used in the Instrument (5 of 6)
:MTESt:SSCReen:DPRinter No replacement
:MTESt:SSCReen:DPRinter:ADDRess No replacement
:MTESt:SSCReen:DPRinter:BACKground No replacement
:MTESt:SSCReen:DPRinter:MEDia No replacement
:MTESt:SSCReen:DPRinter:PFORmat No replacement
:MTESt:SSCReen:DPRinter:PORT No replacement
:MTESt:SSUMmary:ADDRess No replacement
:MTESt:SSUMmary:BACKground No replacement
:MTESt:SSUMmary:MEDia No replacement
:MTESt:SSUMmary:PFORmat No replacement
:MTESt:SSUMmary:PORT No replacement
Measure Commands :MEASure
:MEASure:CGRade:ERCalibrate :CALibrate:ERATio:STARt CHANnel<N>
:MEASure:CGRade:ERFactor No replacement
:MEASure:CGRade:QFACtor :MEASure:CGRade:ESN
:MEASure:FFT No replacement. FFT not available.
:MEASure:HISTogram:HITS Query only
:MEASure:HISTogram:MEAN Query only
:MEASure:HISTogram:MEDian Query only
:MEASure:HISTogram:M1S Query only
:MEASure:HISTogram:M2S Query only
:MEASure:HISTogram:OFFSET? No replacement
:MEASure:HISTogram:PEAK Query only
:MEASure:HISTogram:PP Query only
:MEASure:PREShoot No replacement
:MEASure:STATistics No replacement. Statistics always on.
:MEASure:TEDGe Query only
:MEASure:VLOWer No replacement
:MEASure:VMIDdle No replacement
:MEASure:VTIMe Query only
:MEASure:VUPPer No replacement
Timebase Commands :TIMebase
1-40
Agilent 83480A/54750A Commands Not Used in the Instrument (6 of 6)
:TIMebase:DELay :TIMebase:POSition
:TIMebase:VIEW No replacement
:TIMebase:WINDow:DELay No replacement
:TIMebase:WINDow:POSition No replacement
:TIMebase:WINDow:RANGe No replacement
:TIMebase:WINDow:SCALe No replacement
:TIMebase:WINDow:SOURce No replacement
Trigger Commands :TRIGger
:TRIGger:SWEep :TRIGger:SOURce FRUN
:TRIGger:SWEep? :TRIGger:SOURce?
:TRIGger<N>:BWLimit :TRIGger:BWLimit and :TRIGger:GATed
:TRIGger<N>:PROBe :TRIGger:ATTenuation
Waveform Commands :WAVeform
:WAVeform:COMPlete No replacement
:WAVeform:COUPling No replacement
:WAVeform:VIEW? No replacement
Introduction
Language Compatibility
a
Refer to the Infiniium DCA Online Help to view information about defining custom masks.
1-41
Introduction

New and Revised Commands

New and Revised Commands
This section lists all new and revised commands for the 86100C software revisions A.4.20. Each command listed is followed by the page number where the command is documented.
Clock Recovery Commands
Measure Commands
Signal Processing Commands
TDR/TDT Commands
CLBandwidth 9-5 CRATe 9-5 LBWMode 9-6 ODRatio 9-7 ODRatio:AUTO 9-7 RDIVider 9-9 RELock 9-10 TDENsity? 9-11
JITTer:DDJVsbit:EARLiest? 18-21 JITTer:DDJVsbit:LATest? 18-21 JITTer:RJSTabilize 18-25 JITTer:RJSValue 18-25
LFEQualizer:FDELay 19-3 LFEQualizer:TAP:AUTomatic 19-4
HPOLarity 20-2 NVALid? 20-3 STIMulus 20-11

Commands Unavailable in Jitter Mode

This section describes the commands that can generate errors when controlling the instru­ment in Jitter mode. This can be due to the command or one of its arguments that are not allowed in Jitter mode. Refer to the individual command reference for detailed information.
Refer to “New and Revised Commands” on page 1-42 for a list of commands that can be used
to control Jitter mode.
1-42
Introduction
Commands Unavailable in Jitter Mode
Waveform Files Waveform and Color Grade/Gray Scale files cannot be saved or loaded in Jitter mode. The
commands listed below produce a "Settings conflict" error when executed in Jitter Mode.
DISK:STORe 10-8
When used with sources other than SETup and JDMemory.
STORe:WAVeform 4-13 ACQuire:SWAVeform 6-6 LTESt:SWAVeform 15-8 MTESt:SWAVeform 17-13
Waveform Queries
Waveform Memory Load/ Store
WAveform Memory Display
Waveform and Color Grade-Gray Scale Memory
Timebase Scale And Delay
Only jitter database waveforms may be set or queried in Jitter mode. Using the following com­mand produces the error, "Signal or trigger source selection is not available".
:WAVeform:DATA 23-4
Waveforms cannot be saved into waveform memories in Jitter mode. All waveform memories are turned off when entering Jitter mode. The commands listed below produce a "Settings conflict" error when executed in Jitter mode.
WMEMory<N>:LOAD 24-2 WMEMory<N>:SAVE 24-3 DISK:LOAD 10-3
When used with sources other than SETup and JDMemory.
Waveform memories cannot be turned on in Jitter mode. The following command produces a "Settings conflict" error when executed in Jitter mode.
WMEMory<N>:DISPlay 24-2
The Waveform and Color Grade/Gray Scale memories cannot be turned on in Jitter mode. The following command produces an "Illegal parameter value" error when executed in Jitter mode.
VIEW 4-14
When used with arguments other than JDMemory.
Scale and position controls on the Horizontal setup dialog are disabled in Jitter Mode. The fol­lowing commands produce a "Settings conflict" error when executed in Jitter Mode:
TIMebase:RANGe 21-4 TIMebase:SCALe 21-5
TIMebase:POSition 21-2
Channel Scale And Offset
Channel scale and offset controls are disabled in Jitter mode. The following commands pro­duce a "Settings conflict" error when executed in Jitter Mode.
CHANnel<N>:OFFSet 8-4 CHANnel<N>:RANGe 8-5 CHANnel<N>:SCALe 8-6
1-43
Introduction

Error Messages

Acquisition Settings
Histograms Histograms are turned off when entering Jitter mode. The following commands produce a
Software Skewing of Channels
Acquisition (Averaging) controls are disabled in Jitter mode. The following commands pro­duce a "Settings conflict" error when executed in Jitter mode.
ACQuire:AVERage 6-2 ACQuire:BEST 6-2 ACQuire:POINts 6-3
"Control is set to default" error.
HISTogram:MODE 14-3
VIEW 4-14
All skew adjustments are disabled in jitter mode. The following commands produce a "Set­tings conflict" error when executed in Jitter mode.
CALibrate:SKEW 7-9 CALibrate:SKEW:AUTO 7-10
Error Messages
This chapter describes the error messages and how they are generated. The possible causes for the generation of the error messages are also listed in Table 1-10 on page 1-46.
Error Queue As errors are detected, they are placed in an error queue. This queue is first in, first out. If
the error queue overflows, the last error in the queue is replaced with error –350, “Queue overflow.” Anytime the error queue overflows, the oldest errors remain in the queue, and the most recent error is discarded. The length of the instrument's error queue is 30 (29 positions for the error messages, and 1 position for the “Queue overflow” message). Reading an error from the head of the queue removes that error from the queue, and opens a position at the tail of the queue for a new error. When all errors have been read from the queue, subsequent error queries return 0, “No error.”
The error queue is cleared when any of the following occur:
• the instrument is powered up,
• a *CLS command is sent,
• the last item from the queue is read, or
• the instrument is switched from talk only to addressed mode on the front panel.
1-44
Introduction
Error Messages
Error Numbers The error numbers are grouped according to the type of error that is detected.
• +0 indicates no errors were detected.
• –100 to –199 indicates a command error was detected.
• –200 to –299 indicates an execution error was detected.
• –300 to –399 indicates a device-specific error was detected.
• –400 to –499 indicates a query error was detected.
• +1 to +32767 indicates an instrument-specific error has been detected. Refer to the Agilent 86100A/B/C online Help for instrument specific errors.
Command Error An error number in the range –100 to –199 indicates that an IEEE 488.2 syntax error has
been detected by the instrument's parser. The occurrence of any error in this class sets the command error bit (bit 5) in the event status register and indicates that one of the following events occurred:
• An IEEE 488.2 syntax error was detected by the parser. That is, a controller-to-instrument message was received that is in violation of the IEEE 488.2 standard. This may be a data ele­ment that violates the instrument's listening formats, or a data type that is unacceptable to the instrument.
• An unrecognized header was received. Unrecognized headers include incorrect instrument­specific headers and incorrect or unimplemented IEEE 488.2 common commands.
• A Group Execute Trigger (GET) was entered into the input buffer inside of an IEEE 488.2 pro­gram message.
Events that generate command errors do not generate execution errors, instrument-specific errors, or query errors.
Execution Error An error number in the range –200 to –299 indicates that an error was detected by the instru-
ment's execution control block. The occurrence of any error in this class causes the execu­tion error bit (bit 4) in the event status register to be set. It also indicates that one of the following events occurred:
• The program data following a header is outside the legal input range or is inconsistent with the instrument's capabilities.
• A valid program message could not be properly executed due to some instrument condition.
Execution errors are reported by the instrument after expressions are evaluated and round­ing operations are completed. For example, rounding a numeric data element will not be reported as an execution error. Events that generate execution errors do not generate com­mand errors, instrument specific errors, or query errors.
Device- or Instrument­Specific Error
An error number in the range of –300 to –399 or +1 to +32767 indicates that the instrument has detected an error caused by an instrument operation that did not properly complete. This may be due to an abnormal hardware or firmware condition. For example, this error may be generated by a self-test response error, or a full error queue. The occurrence of any error in this class causes the instrument-specific error bit (bit 3) in the event status register to be set.
1-45
Introduction
Error Messages
Query Error An error number in the range –400 to –499 indicates that the output queue control of the
instrument has detected a problem with the message exchange protocol. An occurrence of any error in this class causes the query error bit (bit 2) in the event status register to be set. An occurrence of an error also means one of the following is true:
• An attempt is being made to read data from the output queue when no output is either present or pending.
• Data in the output queue has been lost.
Table 1-10. Error Messages Returned by Instrument Parser (1 of 3)
0 No error The error queue is empty. Every error in the queue has been read (SYSTEM:ERROR?
query) or the queue was cleared by power-up or *CLS.
-100 Command error This is the generic syntax error used if the instrument cannot detect more specific errors.
-101 Invalid character A syntactic element contains a character that is invalid for that type.
-102 Syntax error An unrecognized command or data type was encountered.
-103 Invalid separator The parser was expecting a separator and encountered an illegal character.
-104 Data type error The parser recognized a data element different than one allowed. For example, numeric or string data was expected but block data was received.
-105 GET not allowed A Group Execute Trigger was received within a program message.
-108 Parameter not allowed More parameters were received than expected for the header.
-109 Missing parameter Fewer parameters were received than required for the header.
-112 Program mnemonic too long The header or character data element contains more than twelve characters.
-113 Undefined header The header is syntactically correct, but it is undefined for the instrument. For example, *XYZ is not defined for the instrument.
-121 Invalid character in number An invalid character for the data type being parsed was encountered. For example, a “9” in octal data.
-123 Numeric overflow Number is too large or too small to be represented internally.
-124 Too many digits The mantissa of a decimal numeric data element contained more than 255 digits excluding leading zeros.
-128 Numeric data not allowed A legal numeric data element was received, but the instrument does not accept one in this position for the header.
-131 Invalid suffix The suffix does not follow the syntax described in IEEE 488.2 or the suffix is inappropriate for the instrument.
-138 Suffix not allowed A suffix was encountered after a numeric element that does not allow suffixes.
-141 Invalid character data Either the character data element contains an invalid character or the particular element received is not valid for the header.
-144 Character data too long
-148 Character data not allowed A legal character data element was encountered where prohibited by the instrument.
-150 String data error This error can be generated when parsing a string data element. This particular error message is used if the instrument cannot detect a more specific error.
1-46
Introduction
Error Messages
Table 1-10. Error Messages Returned by Instrument Parser (2 of 3)
-151 Invalid string data A string data element was expected, but was invalid for some reason. For example, an END message was received before the terminal quote character.
-158 String data not allowed A string data element was encountered but was not allowed by the instrument at this point in parsing.
-160 Block data error This error can be generated when parsing a block data element. This particular error message is used if the instrument cannot detect a more specific error.
-161 Invalid block data
-168 Block data not allowed A legal block data element was encountered but was not allowed by the instrument at this point in parsing.
-170 Expression error This error can be generated when parsing an expression data element. It is used if the instrument cannot detect a more specific error.
-171 Invalid expression
-178 Expression data not allowed Expression data was encountered but was not allowed by the instrument at this point in parsing.
-200 Execution error This is a generic syntax error which is used if the instrument cannot detect more specific errors.
-220 Parameter error Indicates that a program data element related error occurred.
-221 Settings conflict Indicates that a legal program data element was parsed but could not be executed due to the current device state.
-222 Data out of range Indicates that a legal program data element was parsed but could not be executed because the interpreted value is outside the legal range defined by the instrument.
-223 Too much data Indicates that a legal program data element of block, expression, or string type was received that contained more data than the instrument could handle due to memory or related instrument-specific requirements.
-224 Illegal parameter value Used where exact value, from a list of possibles, was expected.
-225 Out of memory The device has insufficient memory to perform the requested operation.
-231 Data questionable Indicates that measurement accuracy is suspect.
-240 Hardware error Indicates that a legal program command or query could not be executed because of a hardware problem in the device.
-241 Hardware missing Indicates that a legal program command or query could not be executed because of missing device hardware; for example, an option was not installed, or current module does not have hardware to support command or query. Definition of what constitutes missing hardware is completely device-specific or module specific.
-250 Mass storage error Indicates that a mass storage error occurred.
-251 Missing mass storage Indicates that a legal program command or query could not be executed because of missing mass storage; for example, an option that was not installed.
-252 Missing media Indicates that a legal program command or query could not be executed because of a missing media; for example, no disk.
1-47
Introduction
Error Messages
Table 1-10. Error Messages Returned by Instrument Parser (3 of 3)
-253 Corrupt media Indicates that a legal program command or query could not be executed because of corrupt media; for example, bad disk or wrong format.
-254 Media full Indicates that a legal program command or query could not be executed because the media was full; for example, there is no room on the disk.
-255 Directory full Indicates that a legal program command or query could not be executed because the media directory was full.
-256 File name not found Indicates that a legal program command or query could not be executed because the file name on the device media was not found; for example, an attempt was made to read or copy a nonexistent file.
-257 File name error Indicates that a legal program command or query could not be executed because the file name on the device media was in error; for example, an attempt was made to copy to a duplicate file name.
-258 Media protected Indicates that a legal program command or query could not be executed because the media was protected; for example, the write-protect tab on a disk was present.
-300 Service specific error
-310 System error Indicates that a system error occurred.
-340 Calibration failed Indicates that a calibration has failed.
-350 Queue overflow Indicates that there is no room in the error queue and an error occurred but was not recorded.
-400 Query error This is the generic query error.
-410 Query INTERRUPTED
-420 Query UNTERMINATED
-430 Query DEADLOCKED
-440 Query UNTERMINATED
after indefinite response
1-48
2
Sample C Programs 2-3
init.c - Initialization 2-3 init.c - Global Definitions and Main Program 2-4 init.c - Initializing the Analyzer 2-4 init.c - Acquiring Data 2-5 init.c - Making Automatic Measurements 2-6 init.c - Error Checking 2-7 init.c - Transferring Data to the PC 2-9 init.c - Converting Waveform Data 2-10 init.c - Storing Waveform Time and Voltage Information 2-11 gen_srq.c - Generating a Service Request 2-11 Initializing the Analyzer 2-12 Setting Up a Service Request 2-13 Generating a Service Request 2-14
Listings of the Sample Programs 2-15
hpib_decl.h Sample Program 2-15 init.c Sample Program 2-17 gen_srq.c Sample Program 2-23 srq.c Sample Program 2-25 learnstr.c Sample Program 2-26 sicl_IO.c Sample Program 2-29 natl_IO.c Sample Program 2-32 multidatabase.c Sample Program 2-35 init.bas Sample Program 2-38 srq.bas Sample Program 2-44 lrn_str.bas Sample Program 2-47

Sample Programs

Sample Programs
Sample Programs
Each program in this chapter demonstrates specific sets of instructions. This chapter shows you some of those functions, and describes the commands being executed. The sample pro­gram listings are included at the end of this chapter. Both C and BASIC examples are included. The header file is:
hpibdecl.h
The C examples include:
•init.c
• gen_srq.c
•srq.c
•learnstr.c
• sicl_IO.c
• natl_IO.c
• multidatabase.c
The BASIC examples include:
• init.bas
• srq.bas
• lrn_str.bas
This chapter includes segments of both the C and BASIC sample programs. Each program includes the basic functions of initializing the interface and analyzer, capturing the data, and analyzing the data. In general, both the C and BASIC sample programs typically contain the following fundamental segments:
Segment Description
main program Defines global variables and constants, specifies include files, and
calls various functions.
initialize Initializes the GPIB and analyzer, and sets up the analyzer and the ACQuire subsystem.
acquire_data Digitizes the waveform to capture data.
auto_measurements Performs simple parametric measurements.
transfer_data Brings waveform data and voltage/timing information (the preamble) into the computer.
2-2
Sample Programs

Sample C Programs

Sample C Programs
Segments of the sample programs “init.c” and “gen_srq.c” are shown and described in this chapter.
init.c - Initialization
/* init. c */
/* Command Order Example. This program demonstrates the order of commands suggested for operation of the analyzer via GPIB.
This program initializes the scope, acquires data, performs automatic measurements, and transfers and stores the data on the PC as time/voltage pairs in a comma-separated file format useful for spreadsheet applications. It assumes a SICL INTERFACE exists as 'hpib7' and an Agilent 86100 analyzer at address 7. It also requires the cal signal attached to Channel 1.
See the README file on the demo disk for development and linking information.
*/
# include <stdio.h> /* location of: printf ( ) */ # include <stdlib.h> /* location of: atof(), atoi ( ) */ # include "hpibdecl.h" /* prototypes, global declarations, constants */
void initialize ( ); /* initialize the scope */ void acquire_data ( ); /* digitize signal */ void auto_measurements ( ); /* perform built-in automatic measurements */ void transfer_data ( ); /* transfers waveform data from scope to PC */ void convert_data ( ); /* converts data to time/voltage values */ void store_csv ( ); /* stores time/voltage pairs to comma-separated
/* variable file format */
The include statements start the program. The file “hpibdecl.h” includes prototypes and dec­larations that are necessary for the analyzer sample programs.
This segment of the sample program defines the functions, in order, that are used to initialize the scope, digitize the data, perform measurements, transfer data from the scope to the PC, convert the digitized data to time and voltage pairs, and store the converted data in comma­separated variable file format.
See the following descriptions of the program segments.
2-3
Sample Programs
Sample C Programs
init.c - Global Definitions and Main Program
/* GLOBALS */ int count; double xorg,xref,xinc; /* values necessary for conversion of data */ double yorg,yref,yinc; int Acquired_length; char data[MAX_LENGTH]; /* data buffer */ double time_value[MAX_LENGTH]; /* time value of data */ double volts[MAX_LENGTH]; /* voltage value of data */
void main( void ) { /* initialize interface and device sessions */ /* note: routine found in sicl_IO.c or natl_IO.c */
init_IO ( );
initialize ( ); /* initialize the scope and interface and set up SRQ */ acquire_data ( ); /* capture the data */ auto_measurements ( ); /* perform automated measurements on acquired data */ transfer_data ( ); /* transfer waveform data to the PC from scope */ convert_data ( ); /* convert data to time/voltage pairs */ store_csv ( ); /* store the time/voltage pairs as csv file */ close_IO ( ); /* close interface and device sessions */
} /* end main ( ) */
/* note: routine found in sicl_IO.c or natl_IO.c */
The init_IO routine initializes the analyzer and interface so that the scope can capture data and perform measurements on the data. At the start of the program, global symbols are defined which will be used to store and convert the digitized data to time and voltage values.
init.c - Initializing the Analyzer
/* * Function name: initialize * Parameters: none * Return value: none * Description: This routine initializes the analyzer for proper * acquisition of data. The instrument is reset to a known state and the * interface is cleared. System headers are turned off to allow faster * throughput and immediate access to the data values requested by queries. * The analyzer time base, channel, and trigger subsystems are then * configured. Finally, the acquisition subsystem is initialized. */ void initialize ( ) {
write_IO ("*RST"); /* reset scope - initialize to known state */
2-4
write_IO ("*CLS"); /* clear status registers and output queue */
write_IO (":SYSTem:HEADer OFF"); /* turn off system headers */
/* initialize time base parameters to center reference, */ /* 2 ms full-scale (200 us/div), and 20 us delay */ write_IO (":TIMebase:REFerence CENTer;RANGe 2e-3;POSition 20e-6");
/* initialize Channel1 1.6V full-scale (200 mv/div); offset -400mv */ write_IO (":CHANnel1:RANGe 1.6;OFFSet -400e-3");
/* initialize trigger info: channel1 signal on positive slope at 300mv */ write_IO (":TRIGger:SOURce FPANel;SLOPe POSitive"); write_IO (":TRIGger:LEVel-0.40");
/* initialize acquisition subsystem */ /* Real time acquisition - no averaging; record length 4096 */ write_IO (":ACQuire:AVERage OFF;POINts 4096");
} /* end initialize ( ) */
Sample Programs
Sample C Programs
init.c - Acquiring Data
/* * Function name: acquire_data * Parameters: none * Return value: none * Description: This routine acquires data according to the current * instrument settings. */ void acquire_data ( ) { /* * The root level :DIGitize command is recommended for acquisition of new * data when averaging is used. It will initialize data buffers, acquire new data, and ensure that * acquisition criteria are met before acquisition of data is stopped. The * captured data is then available for measurements, storage, or transfer * to a PC. Note that the display is automatically turned off by the * :DIGitize command and must be turned on to view the captured data. */
write_IO (":DIGitize CHANnel1"); write_IO (":CHANnel1:DISPlay ON"); /* turn on channel 1 display which is */
/* turned off by the :DIGitize command */
} /* end acquire_data ( ) */
2-5
Sample Programs
Sample C Programs
init.c - Making Automatic Measurements
/* * Function name: auto_measurements * Parameters: none * Return value: none * Description: This routine performs automatic measurements of volts * peak-to-peak and period on the acquired data. It also demonstrates * two methods of error detection when using automatic measurements. */
void auto_measurements ( ) { float period, vpp; unsigned char vpp_str[16]; unsigned char period_str[16]; int bytes_read;
/* * Error checking on automatic measurements can be done using one of two methods. * The first method requires that you turn on results in the Measurements * subsystem using the command :MEASure:SEND ON. When this is on, the analyzer * will return the measurement and a result indicator. The result flag is zero * if the measurement was successfully completed, otherwise a non-zero value is * returned which indicates why the measurement failed. See the Programmer's Manual * for descriptions of result indicators. * * The second method simply requires that you check the return value of the * measurement. Any measurement not made successfully will return with the value * +9.999E37. This could indicate that either the measurement was unable to be * performed, or that insufficient waveform data was available to make the * measurement. */ /* * METHOD ONE - turn on results to indicate whether the measurement completed * successfully. Note that this requires transmission of extra data from the scope. */ write_IO (":MEASure:SEND ON"); /* turn results on */ write_IO (":MEASure:VPP? CHANnel1"); /* query -- volts peak-to-peak channel 1*/
bytes_read = read_IO(vpp_str,16L); /* read in value and result flag */
if (vpp_str[bytes_read-2] != '0') printf ("Automated vpp measurement error with result %c\n",
vpp_str [bytes_read-2]); else printf ("VPP is %f\n", (float) atof (vpp_str));
write_IO (":MEASure:PERiod? CHANnel1"); /* period channel 1 */
bytes_read = read_IO (period_str,16L); /* read in value and result flag */
if period_str[bytes_read-2] != '0') printf ("Automated period measurement error with result %c\n",
2-6
period_str [bytes_read-2]); else printf ("Period is %f\n",(float)atof (period_str));
/* * METHOD TWO - perform automated measurements and error checking with * :MEAS:RESULTS OFF */ period = (float) 0; vpp = (float) 0;
/* turn off results */ write_IO (":MEASure:SEND OFF");
write_IO (":MEASure:PERiod? CHANnel1"); /*period 1 */ bytes_read = read_IO (period_str,16L); /* read in value and result flag */
period = (float) atof (period_str);
if (period > 9.99e37 ) printf ("\nPeriod could not be measured.\n"); else printf ("\nThe period of channel 1 is %f seconds.\n", period );
write_IO (":MEASure:VPP? CHANnel1"); bytes_read = read_IO ( vpp_str,16L );
Sample Programs
Sample C Programs
vpp = (float) atof (vpp_str);
if ( vpp > 9.99e37 ) printf ("Peak-to-peak voltage could not be measured.\n"); else printf ("The voltage peak-to-peak is %f volts.\n", vpp );
} /* end auto_measurements () */
init.c - Error Checking
/* Error checking on automatic measurements can be done using one of two methods. * The first method requires that you turn on results in the Measurements * subsystem using the command :MEASure:SEND ON. When this is on, the analyzer * will return the measurement and a result indicator. The result flag is zero * if the measurement was successfully completed, otherwise a non-zero value is * returned which indicates why the measurement failed. See the Programmer's Manual * for descriptions of result indicators.
* The second method simply requires that you check the return value of the * measurement. Any measurement not made successfully will return with the value * +9.999E37. This could indicate that either the measurement was unable to be * performed, or that insufficient waveform data was available to make the * measurement.
2-7
Sample Programs
Sample C Programs
* METHOD ONE - turn on results to indicate whether the measurement completed * successfully. Note that this requires transmission of extra data from the scope. */
write_IO (":MEASure:SEND ON"); /* turn results on */
/* query -- volts peak-to-peak channel 1*/ write_IO (":MEASure:VPP? CHANnel1");
bytes_read = read_IO(vpp_str,16L); /* read in value and result flag */
if (vpp_str[bytes_read-2] != '0') printf ("Automated vpp measurement error with result %c\n", vpp_str[bytes_read-2]); else printf ("VPP is %f\n",(float)atof(vpp_str));
write_IO (":MEASure:PERiod? CHANnel1"); /* period channel 1 */ bytes_read = read_IO(period_str,16L); /* read in value and result flag */
if period_str[bytes_read-2] != '0') printf ("Automated period measurement error with result %c\n", period_str[bytes_read-2]); else
printf ("Period is %f\n",(float)atof (period_str)); /* * METHOD TWO - perform automated measurements and error checking with * :MEAS:RESULTS OFF. */ period = (float) 0; vpp = (float) 0;
/* turn off results */
write_IO (":MEASure:SEND OFF");
write_IO (":MEASure:PERiod? CHANnel1"); /* period channel 1 */
bytes_read = read_IO (period_str,16L); /* read in value and result flag */
period = (float) atof (period_str);
if ( period > 9.99e37 )
printf ("\nPeriod could not be measured.\n");
else
printf ("\nThe period of channel 1 is %f seconds.\n", period );
write_IO (":MEASure:VPP? CHANnel1");
bytes_read = read_IO ( vpp_str,16L );
vpp = (float) atof (vpp_str);
if ( vpp > 9.99e37 )
printf ("Peak-to-peak voltage could not be measured.\n");
else
printf ("The voltage peak-to-peak is %f volts.\n", vpp );
} /* end auto_measurements() */
2-8
init.c - Transferring Data to the PC
/* * Function name: transfer_data * Parameters: none * Return value: none * Description: This routine transfers the waveform conversion factors and * waveform data to the PC. */
void transfer_data ( ) {
int header_length; char header_str[8]; char term;
char xinc_str[32],xorg_str[32],xref_str[32]; char yinc_str[32],yref_str[32],yorg_str[32];
int bytes_read;
/* waveform data source channel 1 */ write_IO (":WAVeform:SOURce CHANnel1"); /* setup transfer format */ write_IO (":WAVeform:FORMat BYTE"); /* request values to allow interpretation of raw data */ write_IO (":WAVeform:XINCrement?"); bytes_read = read_IO (xinc_str,32L); xinc = atof (xinc_str);
write_IO (":WAVeform:XORigin?"); bytes_read = read_IO (xorg_str,32L); xorg = atof (xorg_str);
Sample Programs
Sample C Programs
write_IO (":WAVeform:XREFerence?"); bytes_read = read_IO (xref_str,32L); xref = atof (xref_str);
write_IO (":WAVeform:YINCrement?"); bytes_read = read_IO (yinc_str,32L); yinc = atof (yinc_str);
write_IO (":WAVeform:YORigin?"); bytes_read = read_IO (yorg_str,32L); yorg = atof (yorg_str);
write_IO (":WAVeform:YREFerence?"); bytes_read = read_IO (yref_str,32L); yref = atof (yref_str);
write_IO (":WAVeform:DATA?"); /* request waveform data */ while (data[0] != ‘#’) bytes_read = read_IO (data,1L); /* find the # character */ bytes_read = read_IO (header_str,1L); /* input byte counter */
2-9
Sample Programs
Sample C Programs
header_length = atoi (header_str);
/* read number of points - value in bytes */
bytes_read = read_IO (header_str,(long)header_length);
Acquired_length = atoi (header_str); /* number of bytes */
bytes_read = read_IO (data,Acquired_length); /* input waveform data */
bytes_read = read_IO (&term,1L); /* input termination character */
} /* end transfer_data () */
An example header resembles the following when the information is stripped off:
#510225
The left-most “5” defines the number of digits that follow (10225). The number “10225” is the number of points in the waveform. The information is stripped off of the header to get the number of data bytes that need to be read from the analyzer.
init.c - Converting Waveform Data
/* * Function name: convert_data * Parameters: none * Return value: none * Description: This routine converts the waveform data to time/voltage * information using the values that describe the waveform. These values are * stored in global arrays for use by other routines. */
void convert_data ( ) {
int i;
for (i = 0; i < Acquired_length; i++)
{
time_value[i] = ((i - xref) * xinc) + xorg;/* calculate time info */
volts[i] = ((data[i] - yref) * yinc) + yorg;/* calculate volt info */
} } /* end convert_data ( ) */
The data values are returned as digitized samples (sometimes called quantization levels or q­levels). These data values must be converted into voltage and time values.
2-10
init.c - Storing Waveform Time and Voltage Information
/* * Function name: store_csv * Parameters: none * Return value: none * Description: This routine stores the time and voltage information about * the waveform as time/voltage pairs in a comma-separated variable file * format. */
void store_csv ( ) {
FILE *fp; int i;
fp = fopen ("pairs.csv","wb"); /* open file in binary mode - clear file */
/* if already exists */ if (fp != NULL) { for (i = 0; i < Acquired_length; i++) { /* write time,volt pairs to file */
fprintf ( fp,"%e,%lf\n",time_value[i],volts[i]); } fclose ( fp ); /* close file */ } else printf ("Unable to open file 'pairs.csv'\n");
Sample Programs
Sample C Programs
} /* end store_csv ( ) */
/* gen_srq.c */
/*
The time and voltage information of the waveform is stored in integer format, with the time stored first, followed by a comma, and the voltage stored second.
gen_srq.c - Generating a Service Request
Segments of the sample C program “gen_srq.c” show how to initialize the interface
and analyzer, and generate a service request.
Two include statements start the “gen_srq.c” program. The file “stdio.h” defines the standard location of the printf routine, and is needed whenever input or output functions are used. The file “hpibdecl.h” includes necessary prototypes and declarations for the analyzers sample programs. The path of these files must specify the disk drive and directory where the “include” files reside.
2-11
Sample Programs
Sample C Programs
* This example program initializes the Agilent 86100 scope, runs an autoscale, * then generates and responds to a Service Request from the scope. The program * assumes an Agilent 86100 at address 7, an interface card at interface select code 7, * and a signal source attached to channel 1. */
#include <stdio.h> /* location of: printf ( ) */ #include "hpibdecl.h"
void initialize ( ); void setup_SRQ ( ); void create_SRQ ( );
void main ( void ) {
init_IO ( ); /* initialize interface and device sessions */ initialize ( ); /* initialize the scope and interface */ setup_SRQ ( ); /* enable SRQs on scope and set up SRQ handler */ create_SRQ ( ); /* generate SRQ */ close_IO ( ); /* close interface and device sessions */
} /* end main ( ) */
The routine “init_IO” contains three subroutines that initialize the analyzer and interface, and sets up and generate a service request. The following segment describes the initialize subrou­tine.
Initializing the Analyzer
The following function is demonstrated in the “gen_srq.c” sample program.
/* * Function name: initialize * Parameters: none * Return value: none * Description: This routine initializes the analyzer for proper acquisition * of data. The instrument is reset to a known state and the interface is * cleared. System headers are turned off to allow faster throughput and * immediate access to the data values requested by queries. The analyzer * performs an autoscale to acquire waveform data. */
void initialize ( ) {
write_IO ("*RST"); /* reset scope - initialize to known state */ write_IO ("*CLS"); /* clear status registers and output queue */ write_IO (":SYSTem:HEADer OFF");/* turn off system headers */ write_IO (":AUToscale"); /* perform autoscale */
} /* end initialize ( ) */
2-12
The *RST command is a common command that resets the analyzer to a known default config­uration. Using this command ensures that the analyzer is in a known state before you config­ure it. *RST ensures very consistent and repeatable results. Without *RST, a program may run one time, but it may give different results in following runs if the analyzer is configured differ­ently. For example, if the trigger mode is normally set to edge, the program may function properly. But, if someone puts the analyzer in the advanced TV trigger mode from the front panel, the program may read measurement results that are totally incorrect. So, *RST defaults the scope to a set configuration so that the program can proceed from the same state each time. The *CLS command clears the status registers and the output queue. AUToscale finds and displays all signals that are attached to the analyzer. You should program the analyzer’s time base, channel, and trigger for the specific measurement to be made, as you would do from the front panel, and use whatever other commands are needed to configure the analyzer for the desired measurement.
Setting Up a Service Request
The following code segment shows how to generate a service request. The following function is demonstrated in the “gen_srq.c” sample program.
/* * Function name: setup_SRQ * Parameters: none * Return value: none * Description: This routine initializes the device to generate Service Requests. It * sets the Service Request Enable Register Event Status Bit and the Standard * Event Status Enable Register to allow SRQs on Command, Execution, Device * Dependent, or Query errors. */ void setup_SRQ ( ) {
/* Enable Service Request Enable Register - Event Status Bit */
Sample Programs
Sample C Programs
write_IO ("*SRE 32"); /* Enable Standard Event Status Enable Register */
/* enable Command Error - bit 5 - value 32 */ /* Query Error - bit 2 - value 4 */
write_IO ("*ESE 36");
} /* end setup_SRQ ( ) */
2-13
Sample Programs
Sample C Programs
Generating a Service Request
The following function is demonstrated in the “gen_srq.c” sample program.
/* * Function name: create_SRQ * Parameters: none * Return value: none * Description: This routine sends two illegal commands to the scope which will * generate an SRQ and will place two error strings in the error queue. The scope * ID is requested to allow time for the SRQ to be generated. The ID string * will contain a leading character which is the response placed in the output * queue by the interrupted query. */
void create_SRQ ( ) {
char buf [256] = { 0 }; //read buffer for id string int bytes_read = 0; int srq_asserted;
/* Generate query error (interrupted query)*/ /* send legal query followed by another command other than a read query response */ write_IO (":CHANnel2:DISPlay?"); write_IO (":CHANnel2:DISPlay OFF");
/* Generate command error - send illegal header */ write_IO (":CHANnel:DISPlay OFF");
/* get instrument ID - allow time for SRQ to set */ write_IO ("*IDN?"); bytes_read = read_IO (buf,256L);
/* add NULL to end of string */ buf [bytes_read] = '\0';
printf ( "%s\n", buf);
srq_asserted = check_SRQ ( );
if ( srq_asserted ) srq_handler ( );
} /* end create_SRQ ( ) */
2-14

Listings of the Sample Programs

Listings of the C sample programs in this section include:
•hpibdecl.h
•init.c
• gen_srq.c
•srq.c
• learnstr.c
• sicl_IO.c
• natl_IO.c
Listings of the BASIC sample programs in this section include:
•init.bas
•srq.bas
•lrn_str.bas
Sample Programs
Listings of the Sample Programs
hpib_decl.h Sample Program
/* hpibdecl.h */
/* * This file includes necessary prototypes and declarations for * the example programs for the Agilent 86100*/ */
/* * User must indicate which GPIB card (Agilent or National) is being used. * Also, if using a National card, indicate which version of windows * (WIN31 or WIN95) is being used. */
#define AGILENT /* Uncomment if using AGILENT interface card */ /* #define NATL */
/* #define WIN31 */ /* For National card ONLY - select windows version */ #define WIN95
2-15
Sample Programs
Listings of the Sample Programs
#ifdef AGILENT #include <sicl.h> #else
#ifdef WIN95 #include <windows.h> /* include file for Windows 95 */ #include <decl-32.h> #else #include <windecl.h> /* include file for Windows 3.1 */ #endif
#endif
#define CME 32 #define EXE 16 #define DDE 8 #define QYE 4
#define SRQ_BIT 64 #define MAX_LRNSTR 14000 #define MAX_LENGTH 4096 #define MAX_INT 4192
#ifdef AGILENT #define DEVICE_ADDR "hpib7,7" #define INTERFACE "hpib7" #else #define INTERFACE "hpib0"
#define board_index 0 #define prim_addr 7 #define second_addr 0 #define timeout 13 #define eoi_mode 1 #define eos_mode 0 #endif
#define TRUE 1 #define FALSE 0
/* GLOBALS */ #ifdef AGILENT
INST bus; INST scope;
#else
int bus; int scope;
#endif
/* GPIB prototypes */ void init_IO ( ); void write_IO ( void* ); void write_lrnstr ( void*, long ); int read_IO ( void*, unsigned long ); int check_SRQ ( );
2-16
unsigned char read_status ( ); void close_IO ( ); void hpiberr ( );
void srq_handler ( );
init.c Sample Program
/* init. c */
/* * Command Order Example. This program demonstrates the order of commands * suggested for operation of the Agilent 86100 analyzer via GPIB. * This program initializes the scope, acquires data, performs * automatic measurements, and transfers and stores the data on the * PC as time/voltage pairs in a comma-separated file format useful * for spreadsheet applications. It assumes a SICL INTERFACE exists * as 'gpib7' and an Agilent 86100 analyzer at address 7. * It also requires the cal signal attached to Channel 1. * * See the README file on the demo disk for development and linking information. */
Sample Programs
Listings of the Sample Programs
#include <stdio.h> /* location of: printf ( ) */ #include <stdlib.h> /* location of: atof(), atoi ( ) */ #include "hpibdecl.h" /* prototypes, global declarations, constants */
void initialize ( ); /* initialize the scope */ void acquire_data ( ); /* digitize signal */ void auto_measurements ( ); /* perform built-in automatic measurements */ void transfer_data ( ); /* transfers waveform data from scope to PC */ void convert_data ( ); /* converts data to time/voltage values */ void store_csv ( ); /* stores time/voltage pairs to comma-separated variable file format */
/* GLOBALS */ int count; double xorg,xref,xinc; /* values necessary for conversion of data */ double yorg,yref,yinc; int Acquired_length; char data [MAX_LENGTH]; /* data buffer */ double time_value [MAX_LENGTH];/* time value of data */ double volts [MAX_LENGTH]; /* voltage value of data */
void main( void ) {
/* initialize interface and device sessions */ /* note: routine found in sicl_IO.c or natl_IO.c */ init_IO ( );
initialize ( ); /* initialize the scope and interface and set up SRQ */
2-17
Sample Programs
Listings of the Sample Programs
acquire_data ( ); /* capture the data */ auto_measurements ( ); /* perform automated measurements on acquired data */ transfer_data ( ); /* transfer waveform data to the PC from scope */ convert_data ( ); /* convert data to time/voltage pairs */ store_csv ( ); /* store the time/voltage pairs as csv file */ close_IO ( ); /* close interface and device sessions */
} /* end main ( ) */
/* * Function name: initialize * Parameters: none * Return value: none * Description: This routine initializes the analyzer for proper * acquisition of data. The instrument is reset to a known state and the * interface is cleared. System headers are turned off to allow faster * throughput and immediate access to the data values requested by queries. * The analyzer time base, channel, and trigger subsystems are then * configured. Finally, the acquisition subsystem is initialized. */
void initialize ( ) {
write_IO ("*RST"); /* reset scope - initialize to known state */ write_IO ("*CLS"); /* clear status registers and output queue */
/* note: routine found in sicl_IO.c or natl_IO.c */
write_IO (":SYSTem:HEADer OFF"); /* turn off system headers */
/* initialize time base parameters to center reference, 2 ms full-scale (200 us/div), and 20 us delay */ write_IO (":TIMebase:REFerence CENTer;RANGe 2e-3;POSition 20e-6");
/* initialize Channel1 1.6V full-scale (200 mv/div); offset -400mv */ write_IO (":CHANnel1:RANGe 1.6;OFFSet -400e-3");
/* initialize trigger info: channel1 signal on positive slope at 300mv */ write_IO (":TRIGger:SOURce FPANel;SLOPe POSitive"); write_IO (":TRIGger:LEVel-0.40");
/* initialize acquisition subsystem */ /* Real time acquisition - no averaging; record length 4096 */ write_IO (":ACQuire:AVERage OFF;POINts 4096");
} /* end initialize ( ) */
/* * Function name: acquire_data * Parameters: none * Return value: none
2-18
Listings of the Sample Programs
* Description: This routine acquires data according to the current instrument settings. */ void acquire_data ( ) { /* * The root level :DIGitize command is recommended for acquisition of new * data. It will initialize data buffers, acquire new data, and ensure that * acquisition criteria are met before acquisition of data is stopped. * The captured data is then available for measurements, storage, or transfer * to a PC. Note that the display is automatically turned off by the * :DIGitize command and must be turned on to view the captured data. */
write_IO (":DIGitize CHANnel1"); write_IO (":CHANnel1:DISPlay ON"); /* turn on channel 1 display which is turned off by the :DIGitize command */
} /* end acquire_data() */
/* * Function name: auto_measurements * Parameters: none * Return value: none * Description: This routine performs automatic measurements of volts * peak-to-peak and period on the acquired data. It also demonstrates * two methods of error detection when using automatic measurements. */
Sample Programs
void auto_measurements ( ) {
float period, vpp; unsigned char vpp_str[16]; unsigned char period_str[16]; int bytes_read;
/* * Error checking on automatic measurements can be done using one of two methods. * The first method requires that you turn on results in the Measurements * subsystem using the command :MEASure:SEND ON. When this is on, the analyzer * will return the measurement and a result indicator. The result flag is zero * if the measurement was successfully completed, otherwise a non-zero value is * returned which indicates why the measurement failed. See the Programmer's Manual * for descriptions of result indicators.
* The second method simply requires that you check the return value of the * measurement. Any measurement not made successfully will return with the value * +9.999E37. This could indicate that either the measurement was unable to be * performed, or that insufficient waveform data was available to make the * measurement.
* METHOD ONE - turn on results to indicate whether the measurement completed * successfully. Note that this requires transmission of extra data from the scope. */
write_IO (":MEASure:SEND ON"); /* turn results on */
/* query -- volts peak-to-peak channel 1*/
2-19
Sample Programs
Listings of the Sample Programs
write_IO (":MEASure:VPP? CHANnel1");
bytes_read = read_IO (vpp_str,16L); /* read in value and result flag */
if (vpp_str[bytes_read-2] != '0') printf ("Automated vpp measurement error with result %c\n", vpp_str[bytes_read-2]); else printf ("VPP is %f\n", (float)atof (vpp_str));
write_IO (":MEASure:PERiod? CHANnel1"); /* period channel 1 */ bytes_read = read_IO (period_str,16L); /* read in value and result flag */
if (period_str[bytes_read-2] != '0') printf ("Automated period measurement error with result %c\n", period_str [bytes_read-2]); else printf ("Period is %f\n", (float) atof (period_str));
/* METHOD TWO - perform automated measurements and error checking with :MEAS:SEND OFF */
period = (float) 0; vpp = (float) 0;
/* turn off results */ write_IO (":MEASure:SEND OFF");
write_IO (":MEASure:PERiod? CHANnel1"); /* period channel 1 */ bytes_read = read_IO (period_str,16L); /* read in value and result flag */
period = (float) atof (period_str);
if ( period > 9.99e37 ) printf ("\nPeriod could not be measured.\n"); else printf ("\nThe period of channel 1 is %f seconds.\n", period );
write_IO (":MEASure:VPP? CHANnel1"); bytes_read = read_IO ( vpp_str,16L );
vpp = (float) atof (vpp_str);
if ( vpp > 9.99e37 ) printf ("Peak-to-peak voltage could not be measured.\n"); else printf ("The voltage peak-to-peak is %f volts.\n", vpp );
} /* end auto_measurements ( ) */
/* * Function name: transfer_data * Parameters: none * Return value: none * Description: This routine transfers the waveform conversion factors and waveform data to the PC. */
void transfer_data ( )
2-20
{
int header_length; char header_str[8]; char term;
char xinc_str[32],xorg_str[32],xref_str[32]; char yinc_str[32],yref_str[32],yorg_str[32];
int bytes_read;
/* waveform data source channel 1 */ write_IO (":WAVeform:SOURce CHANnel1"); /* setup transfer format */ write_IO (":WAVeform:FORMat BYTE"); /* request values to allow interpretation of raw data */ write_IO (":WAVeform:XINCrement?"); bytes_read = read_IO (xinc_str,32L); xinc = atof (xinc_str);
write_IO (":WAVeform:XORigin?"); bytes_read = read_IO (xorg_str,32L); xorg = atof (xorg_str);
write_IO (":WAVeform:XREFerence?"); bytes_read = read_IO (xref_str,32L); xref = atof (xref_str);
Sample Programs
Listings of the Sample Programs
write_IO (":WAVeform:YINCrement?"); bytes_read = read_IO (yinc_str,32L); yinc = atof (yinc_str);
write_IO (":WAVeform:YORigin?"); bytes_read = read_IO (yorg_str,32L); yorg = atof (yorg_str);
write_IO (":WAVeform:YREFerence?"); bytes_read = read_IO (yref_str,32L); yref = atof (yref_str);
write_IO (":WAVeform:DATA?"); /* request waveform data */ bytes_read = read_IO (data,1L); /* ignore leading # */ bytes_read = read_IO (header_str,1L); /* input byte counter */ header_length = atoi (header_str);
/* read number of points - value in bytes */ bytes_read = read_IO (header_str,(long)header_length);
Acquired_length = atoi (header_str); /* number of bytes */
bytes_read = read_IO (data,Acquired_length); /* input waveform data */ bytes_read = read_IO (&term,1L); /* input termination character */
} /* end transfer_data ( ) */
/* * Function name: convert_data
2-21
Sample Programs
Listings of the Sample Programs
* Parameters: none * Return value: none * Description: This routine converts the waveform data to time/voltage * information using the values that describe the waveform. These values are * stored in global arrays for use by other routines. */
void convert_data ( ) {
int i;
for (i = 0; i < Acquired_length; i++) { time_value[i] = ((i - xref) * xinc) + xorg; /* calculate time info */ volts[i] = ((data[i] - yref) * yinc) + yorg; /* calculate volt info */ }
} /* end convert_data ( ) */
/* * Function name: store_csv * Parameters: none * Return value: none * Description: This routine stores the time and voltage information about * the waveform as time/voltage pairs in a comma-separated variable file * format. */
void store_csv ( ) {
FILE *fp; int i;
fp = fopen ("pairs.csv","wb"); /* open file in binary mode - clear file if already exists */ if (fp != NULL) { for (i = 0; i < Acquired_length; i++) { /* write time,volt pairs to file */ fprintf ( fp,"%e,%lf\n",time_value[i],volts[i]);
} fclose ( fp ); /* close file */ } else printf ("Unable to open file 'pairs.csv'\n");
} /* end store_csv ( ) */
2-22
gen_srq.c Sample Program
/* gen_srq.c */
/* * This example programs initializes the Agilent 86100 scope, runs an * autoscale, then generates and responds to a Service Request from the * scope. The program assumes an Agilent 86100 at address 7, an interface card * at interface select code 7, and a signal source attached to channel 1. */
#include <stdio.h> /* location of: printf ( ) */ #include "hpibdecl.h"
void initialize ( ); void setup_SRQ ( ); void create_SRQ ( );
void main ( void ) {
init_IO ( ); /* initialize interface and device sessions */ initialize ( ); /* initialize the scope and interface */ setup_SRQ ( ); /* enable SRQs on scope and set up SRQ handler */ create_SRQ ( ); /* generate SRQ */ close_IO ( ); /* close interface and device sessions */
Sample Programs
Listings of the Sample Programs
} /* end main ( ) */
/* * Function name: initialize * Parameters: none * Return value: none * Description: This routine initializes the analyzer for proper acquisition of data. * The instrument is reset to a known state and the interface is cleared. * System headers are turned off to allow faster throughput and immediate access * to the data values requested by queries. The analyzer performs an autoscale to acquire waveform data. */ void initialize ( ) {
write_IO ("*RST"); /* reset scope - initialize to known state */ write_IO ("*CLS"); /* clear status registers and output queue */ write_IO (":SYSTem:HEADer OFF"); /* turn off system headers */ write_IO (":AUToscale"); /* perform autoscale */
} /* end initialize ( ) */
/* * Function name: setup_SRQ * Parameters: none * Return value: none * Description: This routine initializes the device to generate Service * Requests. It sets the Service Request Enable Register Event Status Bit * and the Standard Event Status Enable Register to allow SRQs on Command * or Query errors.
2-23
Sample Programs
Listings of the Sample Programs
*/
void setup_SRQ ( ) {
/* Enable Service Request Enable Register - Event Status Bit */ write_IO ("*SRE 32");
/* Enable Standard Event Status Enable Register enable Command Error - bit 4 - value 32 Query Error - bit 1 - value 4 */ write_IO ("*ESE 36");
} /* end setup_SRQ ( ) */
/* * Function name: create_SRQ * Parameters: none * Return value: none * Description: This routine sends two illegal commands to the scope which will generate an * SRQ and will place two error strings in the error queue. The scope ID is requested to allow * time for the SRQ to be generated. The ID string will contain a leading character which * is the response placed in the output queue by the interrupted query. */ void create_SRQ ( ) {
char buf [256] = { 0 }; //read buffer for id string int bytes_read = 0; int srq_asserted;
/* Generate query error (interrupted query)*/ /* send legal query followed by another command other than a read query response */ write_IO (":CHANnel2:DISPlay?");
write_IO (":CHANnel2:DISPlay OFF");
/* Generate command error - send illegal header */ write_IO (":CHANnel:DISPlay OFF");
/* get instrument ID - allow time for SRQ to set */ write_IO ("*IDN?"); bytes_read = read_IO (buf,256L);
/* add NULL to end of string */ buf [bytes_read] = '\0';
printf ( "%s\n", buf); srq_asserted = check_SRQ ( ); if ( srq_asserted ) srq_handler ( );
} /* end create_SRQ ( ) */
2-24
srq.c Sample Program
/* file: srq.c */
/* This file contains the code to handle Service Requests from an GPIB device */
#include <stdio.h> /* location of printf ( ), fopen ( ), and fclose ( ) */ #include "hpibdecl.h"
/* * Function name: srq_handler * Parameters: none * Return value: none * Description: This routine services the scope when an SRQ is generated. * An error file is opened to receive error data from the scope. */
void srq_handler ( )
{ FILE *fp; unsigned char statusbyte = 0; int i =0; int more_errors = 0; char error_str[64] ={0}; int bytes_read; int srq_asserted = TRUE;
Sample Programs
Listings of the Sample Programs
srq_asserted = check_SRQ ( );
while (srq_asserted) { statusbyte = read_status ( );
if ( statusbyte & SRQ_BIT ) { fp = fopen ( "error_list","wb" ); /* open error file */ if (fp == NULL) printf ("Error file could not be opened.\n"); /* read error queue until no more errors */ more_errors = TRUE; while ( more_errors ) { write_IO (":SYSTEM:ERROR? STRING"); bytes_read = read_IO (error_str, 64L);
error_str[bytes_read] = '\0';
/* write error msg to std IO */ printf ("Error string:%s\n", error_str );
if (fp != NULL) /* write error msg to file*/ fprintf (fp,"Error string:%s\n", error_str );
2-25
Sample Programs
Listings of the Sample Programs
if ( error_str[0] == '0' ) { /* Clear event registers and queues,except output */ write_IO("*CLS");
more_errors = FALSE;
if ( fp != NULL) fclose ( fp ); } for (i=0;i<64;i++) /* clear string */ error_str[i] = '\0';
} /* end while (more_errors) */ } else { printf (" SRQ not generated by scope.\n "); /* scope did not cause SRQ */ } srq_asserted = check_SRQ ( ); /* check for SRQ line status */
}/* end while ( srq_asserted ) */
}/* end srq_handler */
learnstr.c Sample Program
/* learnstr.c */
/* * This example program initializes the Agilent 86100 scope, runs autoscale to * acquire a signal, queries for the learnstring, and stores the learnstring * to disk. It then allows the user to change the setup, then restores the * original learnstring. It assumes that a signal is attached to the scope. */
#include <stdio.h> /* location of: printf ( ), fopen ( ), fclose ( ), fwrite ( ),getchar */ #include "hpibdecl.h"
void initialize ( ); void store_learnstring ( ); void change_setup ( ); void get_learnstring ( );
void main ( void ) {
init_IO ( ); /* initialize device and interface */
initialize ( ); /* initialize the scope and interface, and set up SRQ */ store_learnstring ( ); /* request learnstring and store */
2-26
/* Note: routine found in sicl_IO.c or natl_IO.c */
Sample Programs
Listings of the Sample Programs
change_setup ( ); /* request user to change setup */ get_learnstring ( ); /* restore learnstring */ close_IO ( ); /* close device and interface sessions */
} /* end main */ /* * Function name: initialize * Parameters: none * Return value: none * Description: This routine initializes the analyzer for proper acquisition of data. * The instrument is reset to a known state and the interface is cleared. * System headers are turned off to allow faster throughput and immediate access to the data values requested by queries. * Autoscale is performed to acquire a waveform. The signal is then * digitized, and the channel display is turned on following the acquisition. */
void initialize ( ) {
write_IO ("*RST"); /* reset scope - initialize to known state */ write_IO ("*CLS"); /* clear status registers and output queue */
write_IO (":SYSTem:HEADer ON");/* turn on system headers */
/* initialize Timebase parameters to center reference, 2 ms full-scale (200 us/div), and 20 us delay */ write_IO (":TIMebase:REFerence CENTer;RANGe 5e-3;POSition 20e-6");
/* Note: routine found in sicl_IO.c or natl_IO.c */
/* initialize Channel1 1.6v full-scale (200 mv/div); offset -400mv */ write_IO (":CHANnel1:RANGe 1.6;OFFSet -400e-3");
/* initialize trigger info: channel1 signal on positive slope at 300mv */ write_IO (":TRIGger:SOURce FPANel;SLOPe POSitive"); write_IO (":TRIGger:LEVel-0.40");
/* initialize acquisition subsystem */ /* Real time acquisition - no averaging; record length 4096 */ write_IO (":ACQuire:AVERage OFF;POINts 4096");
} /* end initialize ( ) */
/* * Function name: store_learnstring * Parameters: none * Return value: none * Description: This routine requests the system setup known as a learnstring. * The learnstring is read from the scope and stored in a file called Learn2. */
void store_learnstring ( ) {
FILE *fp; unsigned char setup[MAX_LRNSTR] ={0}; int actualcnt = 0;
2-27
Sample Programs
Listings of the Sample Programs
write_IO (":SYSTem:SETup?"); /* request learnstring */ actualcnt = read_IO (setup, MAX_LRNSTR);
fp = fopen ( "learn2","wb");
if ( fp != NULL ) { fwrite ( setup,sizeof (unsigned char), (int) actualcnt,fp); printf ("Learn string stored in file Learn2\n");
fclose ( fp ); } else printf ("Error in file open\n");
}/* end store_learnstring */
/* * Function name: change_setup * Parameters: none * Return value: none * Description: This routine places the scope into local mode to allow the customer to change the system setup. */
void change_setup ( ) {
printf ("Please adjust setup and press ENTER to continue.\n"); getchar();
} /* end change_setup */
/* * Function name: get_learnstring * Parameters: none * Return value: none * Description: This routine retrieves the system setup known as a * learnstring from a disk file called Learn2. It then restores the system setup to the scope. */
void get_learnstring ( ) {
FILE *fp; unsigned char setup[MAX_LRNSTR]; unsigned long count = 0;
fp = fopen ( "learn2","rb");
if ( fp != NULL ) { count = fread ( setup,sizeof(unsigned char),MAX_LRNSTR,fp);
fclose ( fp ); } write_lrnstr (setup,count); /* send learnstring */ write_IO (":RUN");
2-28
}/* end get_learnstring */
sicl_IO.c Sample Program
/* sicl_IO.c */
#include <stdio.h> /* location of: printf ( ) */ #include <string.h> /* location of: strlen ( ) */ #include "hpibdecl.h"
/* This file contains IO and initialization routines for the SICL libraries. */ /* * Function name: init_IO * Parameters: none * Return value: none * Description: This routine initializes the SICL environment. It sets up * error handling, opens both an interface and device session, sets timeout * values, clears the interface by pulsing IFC, and clears the instrument * by performing a Selected Device Clear. */
Sample Programs
Listings of the Sample Programs
void init_IO ( ) {
ionerror (I_ERROR_EXIT); /* set-up interface error handling */
/* open interface session for verifying SRQ line */ bus = iopen ( INTERFACE ); if ( bus == 0 ) printf ("Bus session invalid\n");
itimeout ( bus, 20000 ); /* set bus timeout to 20 sec */ iclear ( bus ); /* clear the interface - pulse IFC */
scope = iopen ( DEVICE_ADDR ); /* open the scope device session */ if ( scope == 0) printf ( "Scope session invalid\n");
itimeout ( scope, 20000 ); /* set device timeout to 20 sec */ iclear ( scope ); /* perform Selected Device Clear on scope */
} /* end init_IO */
/* * Function name: write_IO * Parameters: char *buffer which is a pointer to the character string to be * output; unsigned long length which is the length of the string to be output * Return value: none * Description: This routine outputs strings to the scope device session * using the unformatted I/O SICL commands. */
2-29
Sample Programs
Listings of the Sample Programs
void write_IO ( void *buffer )
{ unsigned long actualcnt; unsigned long length; int send_end = 1; length = strlen ( buffer ); iwrite ( scope, buffer, length, send_end, &actualcnt );
} /* end write_IO */
/* * Function name: write_lrnstr * Parameters: char *buffer which is a pointer to the character string to be * output; long length which is the length of the string to be output * Return value: none * Description: This routine outputs a learnstring to the scope device * session using the unformatted I/O SICL commands. */
void write_lrnstr ( void *buffer, long length ) {
unsigned long actualcnt; int send_end = 1;
iwrite ( scope, buffer, (unsigned long) length, send_end, &actualcnt );
} /* end write_lrnstr ( ) */
/* * Function name: read_IO * Parameters: char *buffer which is a pointer to the character string to be * input; unsigned long length which indicates the max length of the string to be input * Return value: integer which indicates the actual number of bytes read * Description: This routine inputs strings from the scope device session using SICL commands. */
int read_IO (void *buffer,unsigned long length) {
int reason; unsigned long actualcnt;
iread (scope,buffer,length,&reason,&actualcnt);
return( (int) actualcnt );
}
/* * Function name: check_SRQ * Parameters: none * Return value: integer indicating if bus SRQ line was asserted * Description: This routine checks for the status of SRQ on the bus and returns a value to indicate the status. */
2-30
int check_SRQ( ) {
int srq_asserted;
/* check for SRQ line status */ ihpibbusstatus(bus, I_GPIB_BUS_SRQ, &srq_asserted);
return ( srq_asserted );
} /* end check_SRQ ( ) */
/* * Function name: read_status * Parameters: none * Return value: unsigned char indicating the value of status byte * Description: This routine reads the scope status byte and returns the status. */
unsigned char read_status ( ) {
unsigned char statusbyte;
/* Always read the status byte from instrument */ /* NOTE: ireadstb uses serial poll to read status byte - this should clear bit 6 to allow another SRQ. */
ireadstb ( scope, &statusbyte ); return ( statusbyte );
Sample Programs
Listings of the Sample Programs
} /* end read_status ( ) */
/* * Function name: close_IO * Parameters: none * Return value: none * Description: This routine closes device and interface sessions for the * SICL environment and calls the routine _siclcleanup which de-allocates * resources used by the SICL environment. */
void close_IO ( ) {
iclose ( scope ); /* close device session */ iclose ( bus ); /* close interface session */
_siclcleanup ( ); /* required for 16-bit applications */
} /* end close_SICL ( ) */
2-31
Sample Programs
Listings of the Sample Programs
natl_IO.c Sample Program
/* natl_IO.c */
#include <stdio.h> /* location of: printf ( ) */ #include <string.h> /* location of: strlen ( ) */ #include "hpibdecl.h"
/* This file contains IO and initialization routines for the NI488.2 commands. */ /* * Function name: hpiberr * Parameters: char* - string describing error * Return value: none * Description: This routine outputs error descriptions to an error file. */
void hpiberr( char *buffer ) {
printf ("Error string: %s\n",buffer );
} /* end hpiberr ( ) */
/* * Function name: init_IO * Parameters: none * Return value: none * Description: This routine initializes the NI environment. It sets up error * handling, opens both an interface and device session, sets timeout values * clears the interface by pulsing IFC, and clears the instrument by performing * a Selected Device Clear. */
void init_IO ( ) {
bus = ibfind ( INTERFACE ); /* open and initialize GPIB board */ if ( ibsta & ERR ) hpiberr ("ibfind error");
ibconfig ( bus, IbcAUTOPOLL, 0); /* turn off autopolling */
ibsic ( bus ); /* clear interface - pulse IFC */ if ( ibsta & ERR ) { hpiberr ( "ibsic error" ); }
/* open device session */ scope = ibdev ( board_index, prim_addr, second_addr, timeout, eoi_mode, eos_mode ); if ( ibsta & ERR ) { hpiberr ( "ibdev error" ); }
2-32
ibclr ( scope ); /* clear the device( scope ) */
if ( ibsta & ERR) { hpiberr ("ibclr error" ); }
} /* end init_IO */
/* * Function name: write_IO * Parameters: void *buffer which is a pointer to the character string to be output * Return value: none * Description: This routine outputs strings to the scope device session. */ void write_IO ( void *buffer ) {
long length;
length = strlen ( buffer );
ibwrt ( scope, buffer, (long) length ); if ( ibsta & ERR ) { hpiberr ( "ibwrt error" ); }
Sample Programs
Listings of the Sample Programs
} /* end write_IO() */
/* * Function name: write_lrnstr * Parameters: void *buffer which is a pointer to the character string to * be output; length which is the length of the string to be output * Return value: none * Description: This routine outputs a learnstring to the scope device session. */ void write_lrnstr ( void *buffer, long length ) {
ibwrt ( scope, buffer, (long) length ); if ( ibsta & ERR ) { hpiberr ( "ibwrt error" ); }
} /* end write_lrnstr ( ) */
/* * Function name: read_IO * Parameters: char *buffer which is a pointer to the character string to be input; * unsigned long length which indicates the max length of the string to be input * Return value: integer which indicates the actual number of bytes read * Description: This routine inputs strings from the scope device session. */
2-33
Sample Programs
Listings of the Sample Programs
int read_IO (void *buffer,unsigned long length) { ibrd (scope, buffer, ( long ) length );
return ( ibcntl );
} /* end read_IO ( ) */
/* * Function name: check_SRQ * Parameters: none * Return value: integer indicating if bus SRQ line was asserted * Description: This routine checks for the status of SRQ on the bus and * returns a value to indicate the status. */
int check_SRQ ( ) {
int srq_asserted; short control_lines = 0;
iblines ( bus, &control_lines);
if ( control_lines & BusSRQ ) srq_asserted = TRUE; else srq_asserted = FALSE;
return ( srq_asserted );
} /* end check_SRQ ( ) */
/* * Function name: read_status * Parameters: none * Return value: unsigned char indicating the value of status byte * Description: This routine reads the scope status byte and returns the status. */ unsigned char read_status ( ) {
unsigned char statusbyte;
/* Always read the status byte from instrument */
ibrsp ( scope, &statusbyte );
return ( statusbyte );
} /* end read_status ( ) */
/* * Function name: close_IO * Parameters: none * Return value: none
2-34
* Description: This routine closes device session. */
void close_IO ( ) {
ibonl ( scope,0 ); /* close device session */
} /* end close_IO ( ) */
multidatabase.c Sample Program
/*multidatabase.c*/
/* * This example program demonstrates the use of the Multidatabase functionality of the * Agilent 86100 DCA. The program sets up an acquitision of 200 waveforms on two * channels, first serially, then in parallel. A mask test and simple * measurements are made on each channel. NOTE: the timeout value must * be set to a higher value (~30s) so that there is enough time to acquire the * data. */
#include <stdio.h>//standard c++ io funcitons #include <time.h>//time funcitons
Sample Programs
Listings of the Sample Programs
//GPIB prototypes (from IO file) void init_IO ( ); void write_IO ( char* ); int read_IO ( char*, unsigned long ); void close_IO ( );
//prototypes void initialize(); int acquire_serial(); int acquire_parallel();
void main() {
int serialTime, parallelTime; //declarations init_IO(); //initial the interface and open GPIB communications initialize(); //set up the instrument serialTime = acquire_serial();//acquire the data in serial parallelTime = acquire_parallel();//acquire the data in parallel close_IO(); //close GPIB communications
printf("\nSerial Acquisition Time: %d ms\nParallel Acquisition Time: %d ms\n",
serialTime, parallelTime);//display acquisition times printf("Time Savings: %d ms\n", serialTime-parallelTime);
//display the time savings
}//main()
2-35
Sample Programs
Listings of the Sample Programs
/* * Function Name: initialize * Paramters: none * Returned value: none * Description: This method sets up the channels and acquisition limits of the * DCA */
void initialize() {
write_IO("*RST");//reset the DCA write_IO("*CLS");//clear the status registers write_IO("SYSTem:MODE EYE");//switch to Eye/mask mode
write_IO("STOP");//stop acquistion write_IO("CDISplay");//clear the display
write_IO("ACQuire:RUNTil WAVeforms,200");
write_IO("CHANnel1:FSELect 1");//choose filter #1 on channel 1 write_IO("CHANnel1:FILTer ON");//turn on the filter
write_IO("CHANnel3:FSELect 1");//choose filter #1 on channel 3 write_IO("CHANnel3:FILTer ON");//turn on the filter
}//initialize()
/* * Funciton Name: acquireSerial * Parameters: none * Returned value: int - the time to acquire the data * Description: This routine turns on channel 1, performs an autoscale, acquires * 200 waveforms, performs a mask test, and then performs the measurements. The * process is then repeated for channel 2. */
int acquire_serial() {
printf("Serial Acquisition in progress\n");//status report
//decalrations
int start=clock(),stop; char Msk_hits1[16],Crss_pct1[16],Ext_rat1[16],buff[32]; char Msk_hits2[16],Crss_pct2[16],Ext_rat2[16];
write_IO("CHANnel1:DISPlay ON");//turn on channel one write_IO("RUN"); //start acquistion write_IO("AUToscale"); //Autoscale write_IO("*OPC?"); //query for completion read_IO(buff,5); //read completion response
//set the acquistion limit to 200 waveforms
write_IO("MTESt:LOAD \"STM016_OC48.msk\"");//load OC-48 mask write_IO("MTESt:START"); //start mask test write_IO("MTESt:COUNt:FSAMples?");//query the number of failed samples Msk_hits1[read_IO(Msk_hits1, 15)]=0;//get the number of mask hits
2-36
write_IO("MTESt:TEST OFF"); //trun off the maks test
write_IO("MEASure:CGRade:CROSsing?");//query the crossing percentage Crss_pct1[read_IO(Crss_pct1,15)]=0;//get the crossing percentage
write_IO("MEASure:CGRade:ERATio? DECibel");//query the extinction ratio Ext_rat1[read_IO(Ext_rat1,15)]=0;//get the extinction ratio
write_IO("CHANnel3:DISPlay ON");//turn on channel three write_IO("RUN"); //start acquistion write_IO("AUToscale"); //Autoscale write_IO("*OPC?"); //query for completion read_IO(buff,5); //read completion response
write_IO("MTESt:TEST ON"); //start mask test write_IO("MTESt:COUNt:FSAMples?");//query the number of failed samples Msk_hits2[read_IO(Msk_hits2, 15)]=0;//get the number of mask hits
write_IO("MEASure:CGRade:CROSsing?");//query the crossing percentage Crss_pct2[read_IO(Crss_pct2,15)]=0;//get the crossing percentage
write_IO("MEASure:CGRade:ERATio? DECibel");//query the extinction ratio Ext_rat2[read_IO(Ext_rat2,15)]=0;//get the extinction ratio
stop = clock();
//display the results printf("Channel 1:\n Mask hits:%s Crossing %%:%s Extinction Ratio:%s\n",
printf("Channel 3:\n Mask hits:%s Crossing %%:%s Extinction Ratio:%s\n",
Sample Programs
Listings of the Sample Programs
Msk_hits1,Crss_pct1,Ext_rat1);
Msk_hits2,Crss_pct2,Ext_rat2);
return (stop-start);
}//acquireSerial()
/* * Funciton Name: acquireParallel * Parameters: none * Returned value: int - the time to acquire the data * Description: This routine is identical to acquireSerial, except that the data * is aquired at the same time. */
int acquire_parallel() {
printf("Parallel Acquisition In progress\n");//status report
//decalrations
int start=clock(),stop; char Msk_hits1[16],Crss_pct1[16],Ext_rat1[16],buff[32]; char Msk_hits2[16],Crss_pct2[16],Ext_rat2[16];
write_IO("CHANnel1:DISPlay ON");//turn on channel one write_IO("CHANnel3:DISPlay ON, APPEnd");//turn on channel three write_IO("RUN"); //start acquistion write_IO("AUToscale"); //Autoscale
2-37
Sample Programs
Listings of the Sample Programs
write_IO("CALibrate:SKEW:AUTO");//auto deskew the two channels write_IO("*OPC?"); //query for completion read_IO(buff,5); //read completion response
write_IO("MTESt:LOAD \"STM016_OC48.msk\"");//load OC-48 mask write_IO("MTESt:SOURce CHANnel1");//set mask test channel1 write_IO("MTESt:START"); //start mask test write_IO("MTESt:COUNt:FSAMples?");//query the number of failed samples Msk_hits1[read_IO(Msk_hits1, 15)]=0;//get the number of mask hits
write_IO("MTESt:SOURce CHANnel3");//mask test channel3 write_IO("MTESt:TEST ON"); //start mask test write_IO("MTESt:COUNt:FSAMples?");//query the number of failed samples Msk_hits2[read_IO(Msk_hits2, 15)]=0;//get the number of mask hits
write_IO("MEASure:CGRade:SOURce CHANnel1"); //measure Channel 1 write_IO("MEASure:CGRade:CROSsing?");//query the crossing percentage Crss_pct1[read_IO(Crss_pct1,15)]=0;//get the crossing percentage
write_IO("MEASure:CGRade:ERATio? DECibel");//query the extinction ratio Ext_rat1[read_IO(Ext_rat1,15)]=0;//get the extinction ratio
write_IO("MEASure:CGRade:SOURce CHANnel3"); //measure Channel 1 write_IO("MEASure:CGRade:CROSsing?");//query the crossing percentage Crss_pct2[read_IO(Crss_pct2,15)]=0;//get the crossing percentage
write_IO("MEASure:CGRade:ERATio? DECibel");//query the extinction ratio Ext_rat2[read_IO(Ext_rat2,15)]=0;//get the extinction ratio
stop = clock();
//display the results printf("Channel 1:\n Mask hits:%s Crossing %%:%s Extinction Ratio:%s\n",
printf("Channel 3:\n Mask hits:%s Crossing %%:%s Extinction Ratio:%s\n",
return (stop-start); //return the total run time
return 1;
}//acquireParallel()
init.bas Sample Program
10 !file: init 20 ! 30 ! 40 ! This program demonstrates the order of commands suggested for operation of 50 ! the Agilent 86100 analyzer via GPIB. This program initializes the scope, acquires 60 ! data, performs automatic measurements, and transfers and stores the data on the
2-38
Msk_hits1,Crss_pct1,Ext_rat1);
Msk_hits2,Crss_pct2,Ext_rat2);
70 ! PC as time/voltage pairs in a comma-separated file format useful for spreadsheet 80 ! applications. It assumes an interface card at interface select code 7, an 90 ! Agilent 86100 scope at address 7, and the Agilent 86100 cal signal connected to Channel 1. 100 ! 110 ! 120 ! 130 COM /Io/@Scope,@Path,Interface 140 COM /Raw_data/ INTEGER Data(4095) 150 COM /Converted_data/ REAL Time(4095),Volts(4095) 160 COM /Variables/ REAL Xinc,Xref,Xorg,Yinc,Yref,Yorg 170 COM /Variables/ INTEGER Record_length 180 ! 190 ! 200 CALL Initialize 210 CALL Acquire_data 220 CALL Auto_msmts 230 CALL Transfer_data 240 CALL Convert_data 250 CALL Store_csv 260 CALL Close 270 END 280 ! 290 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 300 ! 310 ! 320 ! BEGIN SUBPROGRAMS 330 ! 340 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 350 ! 360 ! 370 ! Subprogram name: Initialize 380 ! Parameters: none 390 ! Return value: none 400 ! Description: This routine initializes the interface and the scope. The instrument 410 ! is reset to a known state and the interface is cleared. System headers 420 ! are turned off to allow faster throughput and immediate access to the 430 ! data values requested by the queries. The analyzer time base, 440 ! channel, and trigger subsystems are then configured. Finally, the 450 ! acquisition subsystem is initialized. 460 ! 470 ! 480 SUB Initialize 490 COM /Io/@Scope,@Path,Interface 500 COM /Variables/ REAL Xinc,Xref,Xorg,Yinc,Yref,Yorg 510 COM /Variables/ INTEGER Record_length 520 Interface=7 530 ASSIGN @Scope TO 707 540 RESET Interface 550 CLEAR @Scope 560 OUTPUT @Scope;"*RST" 570 OUTPUT @Scope;"*CLS" 580 OUTPUT @Scope;":SYSTem:HEADer OFF" 590 !Initialize Timebase: center reference, 2 ms full-scale (200 us/div), 20 us delay 600 OUTPUT @Scope;":TIMebase:REFerence CENTer;RANGe 2e-3;POSition 20e-6" 610 ! Initialize Channel1: 1.6V full-scale (200mv/div), -415mv offset 620 OUTPUT @Scope;":CHANnel1:RANGe 1.6;OFFSet -415e-3"
Sample Programs
Listings of the Sample Programs
2-39
Sample Programs
Listings of the Sample Programs
630 !Initialize Trigger: Edge trigger, channel1 source at -415mv 640 OUTPUT @Scope;":TRIGger:SOURce FPANel;SLOPe POSitive" 650 OUTPUT @Scope;":TRIGger:LEVel-0.415" 660 ! Initialize acquisition subsystem 665 ! Real time acquisition, Averaging off, memory depth 4096 670 OUTPUT @Scope;":ACQuire:AVERage OFF;POINts 4096" 680 Record_length=4096 690 SUBEND 700 ! 710 ! 720 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 730 ! 740 ! 750 ! Subprogram name: Acquire_data 760 ! Parameters: none 770 ! Return value: none 780 ! Description: This routine acquires data according to the current instrument 790 ! setting. It uses the root level :DIGitize command. This command 800 ! is recommended for acquisition of new data because it will initialize 810 ! the data buffers, acquire new data, and ensure that acquisition 820 ! criteria are met before acquisition of data is stopped. The captured 830 ! data is then available for measurements, storage, or transfer to a 840 ! PC. Note that the display is automatically turned off by the :DIGitize 850 ! command and must be turned on to view the captured data. 860 ! 870 ! 880 SUB Acquire_data 890 COM /Io/@Scope,@Path,Interface 900 OUTPUT @Scope;":DIGitize CHANnel1" 910 OUTPUT @Scope;":CHANnel1:DISPlay ON" 920 SUBEND 930 ! 940 ! 950 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 960 ! 970 ! 980 ! Subprogram name: Auto_msmts 990 ! Parameters: none 1000 ! Return value: none 1010 ! Description: This routine performs automatic measurements of volts peak-to-peak 1020 ! and frequency on the acquired data. It also demonstrates two methods 1030 ! of error detection when using automatic measurements. 1040 ! 1050 ! 1060 SUB Auto_msmts 1070 COM /Io/@Scope,@Path,Interface 1080 REAL Period,Vpp 1090 DIM Vpp_str$[64] 1100 DIM Period_str$[64] 1110 Bytes_read=0 1120 ! 1130 ! Error checking on automatic measurements can be done using one of two methods. 1140 ! The first method requires that you turn on results in the Measurement subsystem 1150 ! using the command ":MEASure:SEND ON". When this is on, the scope will return the 1160 ! measurement and a result indicator. The result flag is zero if the measurement 1170 ! was successfully completed, otherwise a non-zero value is returned which indicates
2-40
1180 ! why the measurement failed. See the Programmer's Manual for descriptions of result 1190 ! indicators. The second method simply requires that you check the return value of 1200 ! the measurement. Any measurement not made successfully will return with the value 1210 ! +9.999e37. This could indicate that either the measurement was unable to be 1220 ! performed or that insufficient waveform data was available to make the measurement. 1230 ! 1240 ! METHOD ONE 1250 ! 1260 OUTPUT @Scope;":MEASure:SEND ON" !turn on results 1270 OUTPUT @Scope;":MEASure:VPP? CHANnel1" !Query volts peak-to-peak 1280 ENTER @Scope;Vpp_str$ 1290 Bytes_read=LEN(Vpp_str$) !Find length of string 1300 CLEAR SCREEN 1310 IF Vpp_str$[Bytes_read;1]="0" THEN !Check result value 1320 PRINT 1330 PRINT "VPP is ";VAL(Vpp_str$[1,Bytes_read-1]) 1340 PRINT 1350 ELSE 1360 PRINT 1370 PRINT "Automated vpp measurement error with result ";Vpp_str$[Bytes_read;1] 1380 PRINT 1390 END IF 1400 ! 1410 ! 1420 OUTPUT @Scope;":MEASure:PERiod? CHANnel1" !Query frequency 1430 ENTER @Scope;Period_str$ 1440 Bytes_read=LEN(Period_str$) !Find string length 1450 IF Period_str$[Bytes_read;1]="0" THEN !Determine result value 1460 PRINT 1470 PRINT "Period is ";VAL(Period_str$[1,Bytes_read-1]) 1480 PRINT 1490 ELSE 1500 PRINT 1510 PRINT "Automated period measurement error with result ";Period_str$[Bytes_read;1] 1520 PRINT 1530 END IF 1540 ! 1550 ! 1560 ! METHOD TWO 1570 ! 1580 OUTPUT @Scope;":MEASure:SEND OFF" !turn off results 1590 OUTPUT @Scope;":MEASure:VPP? CHANnel1" !Query volts peak-to-peak 1600 ENTER @Scope;Vpp 1610 IF Vpp<9.99E+37 THEN 1620 PRINT 1630 PRINT "VPP is ";Vpp 1640 PRINT 1650 ELSE 1660 PRINT 1670 PRINT "Automated vpp measurement error ";Vpp 1680 PRINT 1690 END IF 1700 OUTPUT @Scope;":MEASure:PERiod? CHANnel1" 1710 ENTER @Scope;Period 1720 IF Freq<9.99E+37 THEN 1730 PRINT
Sample Programs
Listings of the Sample Programs
2-41
Sample Programs
Listings of the Sample Programs
1740 PRINT "Period is ";Period 1750 PRINT 1760 ELSE 1770 PRINT 1780 PRINT "Automated period measurement error";Period 1790 PRINT 1800 END IF 1810 SUBEND 1820 ! 1830 ! 1840 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1850 ! 1860 ! 1870 ! Subprogram name: Transfer_data 1880 ! Parameters: none 1890 ! Return value: none 1900 ! Description: This routine transfers the waveform data and conversion factors to 1910 ! to PC. 1920 ! 1930 ! 1940 SUB Transfer_data 1950 COM /Io/@Scope,@Path,Interface 1960 COM /Raw_data/ INTEGER Data(4095) 1970 COM /Converted_data/ REAL Time(4095),Volts(4095) 1980 COM /Variables/ REAL Xinc,Xref,Xorg,Yinc,Yref,Yorg 1990 COM /Variables/ INTEGER Record_length 2000 ! define waveform data source and format 2010 OUTPUT @Scope;":WAVeform:SOURce CHANnel1" 2020 OUTPUT @Scope;":WAVeform:FORMat WORD" 2030 ! request values needed to convert raw data to real 2040 OUTPUT @Scope;":WAVeform:XINCrement?" 2050 ENTER @Scope;Xinc 2060 OUTPUT @Scope;":WAVeform:XORigin?" 2070 ENTER @Scope;Xorg 2080 OUTPUT @Scope;":WAVeform:XREFerence?" 2090 ENTER @Scope;Xref 2100 OUTPUT @Scope;":WAVeform:YINCrement?" 2110 ENTER @Scope;Yinc 2120 OUTPUT @Scope;":WAVeform:YORigin?" 2130 ENTER @Scope;Yorg 2140 OUTPUT @Scope;":WAVeform:YREFerence?" 2150 ENTER @Scope;Yref 2160 ! 2170 ! request data 2180 OUTPUT @Scope;":WAVeform:DATA?" 2190 ENTER @Scope USING "#,1A";First_chr$ !ignore leading # 2200 ENTER @Scope USING "#,1D";Header_length !input number of bytes in header value 2210 ENTER @Scope USING "#,"&VAL$(Header_length)&"D";Record_length !Record length in bytes 2220 Record_length=Record_length/2 !Record length in words 2230 ENTER @Scope USING "#,W";Data(*) 2240 ENTER @Scope USING "#,A";Term$ !Enter terminating character 2250 ! 2260 SUBEND 2270 ! 2280 ! 2290 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2-42
2300 ! 2310 ! 2320 ! Subprogram name: Convert_data 2330 ! Parameters: none 2340 ! Return value: none 2350 ! Description: This routine converts the waveform data to time/voltage information 2360 ! using the values Xinc, Xref, Xorg, Yinc, Yref, and Yorg used to describe 2370 ! the raw waveform data. 2380 ! 2390 ! 2400 SUB Convert_data 2410 COM /Io/@Scope,@Path,Interface 2420 COM /Raw_data/ INTEGER Data(4095) 2430 COM /Converted_data/ REAL Time(4095),Volts(4095) 2440 COM /Variables/ REAL Xinc,Xref,Xorg,Yinc,Yref,Yorg 2450 COM /Variables/ INTEGER Record_length 2460 ! 2470 FOR I=0 TO Record_length-1 2480 Time(I)=(((I)-Xref)*Xinc)+Xorg 2490 Volts(I)=((Data(I)-Yref)*Yinc)+Yorg 2500 NEXT I 2510 SUBEND 2520 ! 2530 ! 2540 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2550 ! 2560 ! 2570 ! Subprogram name: Store_csv 2580 ! Parameters: none 2590 ! Return value: none 2600 ! Description: This routine stores the time and voltage information about the waveform 2610 ! as time/voltage pairs in a comma-separated variable file format. 2620 ! 2630 ! 2640 SUB Store_csv 2650 COM /Io/@Scope,@Path,Interface 2660 COM /Converted_data/ REAL Time(4095),Volts(4095) 2670 COM /Variables/ REAL Xinc,Xref,Xorg,Yinc,Yref,Yorg 2680 COM /Variables/ INTEGER Record_length 2690 !Create a file to store pairs in 2700 ON ERROR GOTO Cont 2710 PURGE "Pairs.csv" 2720 Cont: OFF ERROR 2730 CREATE "Pairs.csv",Max_length 2740 ASSIGN @Path TO "Pairs.csv";FORMAT ON 2750 !Output data to file 2760 FOR I=0 TO Record_length-1 2770 OUTPUT @Path;Time(I),Volts(I) 2780 NEXT I 2790 SUBEND 2800 ! 2810 ! 2820 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2830 ! 2840 ! 2850 ! Subprogram name: Close
Sample Programs
Listings of the Sample Programs
2-43
Sample Programs
Listings of the Sample Programs
2860 ! Parameters: none 2870 ! Return value: none 2880 ! Description: This routine closes the IO paths. 2890 ! 2900 ! 2910 SUB Close 2920 COM /Io/@Scope,@Path,Interface 2930 ! 2940 RESET Interface 2950 ASSIGN @Path TO * 2960 SUBEND
srq.bas Sample Program
10 !File: srq.bas 20 ! 30 ! This program demonstrates how to set up and check Service Requests from 40 ! the scope. It assumes an interface select code of 7 with a scope at 50 ! address 7. It also assumes a signal is connected to the scope. 60 ! 70 ! 80 COM /Io/@Scope,Interface 90 COM /Variables/Temp 100 CALL Initialize 110 CALL Setup_srq 120 ON INTR Interface CALL Srq_handler !Set up routine to handle interrupt 130 ENABLE INTR Interface;2 !Enable SRQ Interrupt for Interface 140 CALL Create_srq 150 CALL Close 160 END 170 ! 180 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 190 ! 200 ! BEGIN SUBPROGRAMS 210 ! 220 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 230 ! 240 ! 250 ! Subprogram name: Initialize 260 ! Parameters: none 270 ! Return value: none 280 ! Description: This routine initializes the interface and the scope. 290 ! The instrument is reset to a known state and the interface is 300 ! cleared. System headers are turned off to allow faster throughput 310 ! and immediate access to the data values requested by the queries. 320 ! 330 ! 340 SUB Initialize 350 COM /Io/@Scope,Interface 360 ASSIGN @Scope TO 707 370 Interface=7 380 RESET Interface
2-44
390 CLEAR @Scope 400 OUTPUT @Scope;"*RST" 410 OUTPUT @Scope;"*CLS" 420 OUTPUT @Scope;":SYSTem:HEADer OFF" 430 OUTPUT @Scope;":AUToscale" 440 SUBEND 450 ! 460 ! 470 ! 480 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 490 ! 500 ! Subprogram name: Setup_srq 510 ! Parameters: none 520 ! Return value: none 530 ! Description: This routine sets up the scope to generate Service Requests. 540 ! It sets the Service Request Enable Register Event Status Bit 550 ! and the Standard Event Status Enable REgister to allow SRQs on 560 ! Command or Query errors. 570 ! 580 ! 590 SUB Setup_srq 600 COM /Io/@Scope,Interface 610 OUTPUT @Scope;"*SRE 32" !Enable Service Request Enable Registers - Event Status bit 620 ! 630 ! Enable Standard Event Status Enable Register: 640 ! enable bit 4 - Command Error - value 32 650 ! bit 1 - Query Error - value 4 660 OUTPUT @Scope;"*ESE 36" 670 SUBEND 680 ! 690 ! 700 ! 710 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 720 ! 730 ! 740 ! Subprogram name: Create_srq 750 ! Parameters: none 760 ! Return value: none 770 ! Description: This routine will send an illegal command to the scope to 780 ! show how to detect and handle an SRQ. A query is sent to 790 ! the scope which is then followed by another command causing 800 ! a query interrupt error. An illegal command header is then 810 ! sent to demonstrate how to handle multiple errors in the error queue. 820 ! 830 ! 840 ! 850 SUB Create_srq 860 COM /Io/@Scope,Interface 870 DIM Buf$[256] 880 OUTPUT @Scope;":CHANnel2:DISPlay?" 890 OUTPUT @Scope;":CHANnel2:DISPlay OFF" !send query interrupt 900 OUTPUT @Scope;":CHANnel:DISPlay OFF" !send illegal header 910 ! Do some stuff to allow time for SRQ to be recognized 920 ! 930 OUTPUT @Scope;"*IDN?" !Request IDN to verify communication 940 ENTER @Scope;Buf$ !NOTE: There is a leading zero to this query response
Sample Programs
Listings of the Sample Programs
2-45
Sample Programs
Listings of the Sample Programs
950 PRINT !which represents the response to the interrupted query above 960 PRINT Buf$ 970 PRINT 980 SUBEND 990 ! 1000 ! 1010 ! 1020 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1030 ! 1040 ! 1050 ! Subprogram name: Srq_handler 1060 ! Parameters: none 1070 ! Return value: none 1080 ! Description: This routine verifies the status of the SRQ line. It then checks 1090 ! the status byte of the scope to determine if the scope caused the 1100 ! SRQ. Note that using a SPOLL to read the status byte of the scope 1110 ! clears the SRQ and allows another to be generated. The error queue 1120 ! is read until all errors have been cleared. All event registers and 1130 ! queues, except the output queue, are cleared before control is returned 1140 ! to the main program. 1150 ! 1160 ! 1170 ! 1180 SUB Srq_handler 1190 COM /Io/@Scope,Interface 1200 DIM Error_str$[64] 1210 INTEGER Srq_asserted,More_errors 1220 Status_byte=SPOLL(@Scope) 1230 IF BIT(Status_byte,6) THEN 1240 More_errors=1 1250 WHILE More_errors 1260 OUTPUT @Scope;":SYSTem:ERROR? STRING" 1270 ENTER @Scope;Error_str$ 1280 PRINT 1290 PRINT Error_str$ 1300 IF Error_str$[1,1]="0" THEN 1310 OUTPUT @Scope;"*CLS" 1320 More_errors=0 1330 END IF 1340 END WHILE 1350 ELSE 1360 PRINT 1370 PRINT "Scope did not cause SRQ" 1380 PRINT 1390 END IF 1400 ENABLE INTR Interface;2 !re-enable SRQ 1410 SUBEND 1420 ! 1430 ! 1440 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1450 ! 1460 ! Subprogram name: Close 1470 ! Parameters: none 1480 ! Return value: none 1490 ! Description: This routine resets the interface. 1500 !
2-46
Listings of the Sample Programs
1510 ! 1520 ! 1530 SUB Close 1540 COM /Io/@Scope,Interface 1550 1560 RESET Interface 1570 SUBEND 1580 ! 1590 ! 1600 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
lrn_str.bas Sample Program
10 !FILE: lrn_str.bas 20 ! 30 !THIS PROGRAM WILL INITIALIZE THE SCOPE, AUTOSCALE, AND DIGITIZE THE WAVEFORM 40 !INFORMATION. IT WILL THEN QUERY THE INSTRUMENT FOR THE LEARNSTRING AND WILL 50 !SAVE THE INFORMATION TO A FILE. THE PROGRAM WILL THEN PROMPT YOU TO CHANGE 60 !THE SETUP THEN RESTORE THE ORIGINAL LEARNSTRING CONFIGURATION. IT ASSUMES 70 !AN Agilent 86100 at ADDRESS 7, GPIB INTERFACE at 7, AND THE CAL SIGNAL ATTACHED TO 80 !CHANNEL 1. 90 ! 100 ! 110 COM /Io/@Scope,@Path,Interface 120 COM /Variables/Max_length 130 CALL Initialize 140 CALL Store_lrnstr 150 CALL Change_setup 160 CALL Get_lrnstr 170 CALL Close 180 END 190 ! 200 ! 210 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 220 ! 230 ! BEGIN SUBROUTINES 240 ! 250 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 260 ! Subprogram name: Initialize 270 ! Parameters: none 280 ! Return value: none 290 ! Description: This routine initializes the path descriptions and resets the 300 ! interface and the scope. It performs an autoscale on the signal, 310 ! acquires the data on channel 1, and turns on the display. 320 ! NOTE: This routine also turns on system headers. This allows the 330 ! string ":SYSTEM:SETUP " to be returned with the learnstring so the 340 ! return string is in the proper format. 350 ! 360 SUB Initialize 370 COM /Io/@Scope,@Path,Interface
Sample Programs
2-47
Sample Programs
Listings of the Sample Programs
380 COM /Variables/Max_length 390 Max_length=14000 400 ASSIGN @Scope TO 707 410 Interface=7 420 RESET Interface 430 CLEAR @Scope 440 OUTPUT @Scope;"*RST" 450 OUTPUT @Scope;"*CLS" 460 OUTPUT @Scope;":SYSTem:HEADer ON" 470 OUTPUT @Scope;":AUToscale" 480 SUBEND 490 ! 500 ! 510 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 520 ! 530 ! 540 ! Subprogram name: Store_lrnstr 550 ! Parameters: none 560 ! Return value: none 570 ! Description: This routine creates a file in which to store the learnstring 580 ! configuration (Filename:Lrn_strg). It requests the learnstring 590 ! and inputs the configuration to the PC. Finally, it stores the 600 ! configuration to the file. 610 ! 620 SUB Store_lrnstr 630 COM /Io/@Scope,@Path,Interface 640 COM /Variables/Max_length 650 ON ERROR GOTO Cont 660 PURGE "Lrn_strg" 670 Cont: OFF ERROR 680 CREATE BDAT "Lrn_strg",1,14000 690 DIM Setup$[14000] 700 ASSIGN @Path TO "Lrn_strg" 710 OUTPUT @Scope;":SYSTem:SETup?" 720 ENTER @Scope USING "-K";Setup$ 730 OUTPUT @Path,1;Setup$ 740 CLEAR SCREEN 750 PRINT "Learn string stored in file: Lrn_strg" 760 SUBEND 770 ! 780 ! 790 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 800 ! 810 ! Subprogram name: Change_setup 820 ! Parameters: none 830 ! Return value: none 840 ! Description: This subprogram requests that the user change the 850 ! scope setup, then press a key to continue. 860 ! 870 ! 880 SUB Change_setup 890 COM /Io/@Scope,@Path,Interface 900 910 PRINT 920 PRINT "Please adjust setup and press Continue to resume." 930 PAUSE
2-48
Loading...