6504 Bridge Point Parkway
Austin, TX 78730-5039
(512) 794-0100
Technical support fax: (800) 328-2203
(512) 794-5678
Branch Offices:
Australia (03) 879 9422, Austria (0662) 435986, Belgium 02/757.00.20,
Canada (Ontario) (519) 622-9310, Canada (Québec) (514) 694-8521,
Denmark 45 76 26 00, Finland (90) 527 2321, France (1) 48 14 24 24,
Germany 089/741 31 30, Italy 02/48301892, Japan (03) 3788-1921,
Netherlands 03480-33466, Norway 32-848400, Spain (91) 640 0085,
Sweden 08-730 49 70, Switzerland 056/20 51 51, U.K. 0635 523545
Limited Warranty
The GPIB-PC is warranted against defects in materials and workmanship
for a period of two years from the date of shipment, as evidenced by
receipts or other documentation. National Instruments will, at its option,
repair or replace equipment that proves to be defective during the warranty
period. This warranty includes parts and labor.
The media on which you receive National Instruments software are
warranted not to fail to execute programming instructions, due to defects in
materials and workmanship, for a period of 90 days from date of shipment,
as evidenced by receipts or other documentation. National Instruments will,
at its option, repair or replace software media that do not execute
programming instructions if National Instruments receives notice of such
defects during the warranty period. National Instruments does not warrant
that the operation of the software shall be uninterrupted or error free.
A Return Material Authorization (RMA) number must be obtained from the
factory and clearly marked on the outside of the package before any
equipment will be accepted for warranty work. National Instruments will
pay the shipping costs of returning to the owner parts which are covered by
warranty.
National Instruments believes that the information in this manual is
accurate. The document has been carefully reviewed for technical
accuracy. In the event that technical or typographical errors exist, National
Instruments reserves the right to make changes to subsequent editions of
this document without prior notice to holders of this edition. The reader
should consult National Instruments if errors are suspected. In no event
shall National Instruments be liable for any damages arising out of or
related to this document or the information contained in it.
EXCEPT AS SPECIFIED HEREIN, NATIONAL INSTRUMENTS MAKES NO
WARRANTIES
ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A
PARTICULAR PURPOSE
CAUSED BY FAULT OR NEGLIGENCE ON THE PART OF
, EXPRESS OR IMPLIED, AND SPECIFICALLY DISCLAIMS
. CUSTOMER'S RIGHT TO RECOVER DAMAGES
NATIONAL
INSTRUMENTS SHALL BE LIMITED TO THE AMOUNT THERETOFORE
PAID BY THE CUSTOMER
LIABLE FOR DAMAGES RESULTING FROM LOSS OF DATA
USE OF PRODUCTS, OR INCIDENTAL OR CONSEQUENTIAL DAMAGES,
EVEN IF ADVISED OF THE POSSIBILITY THEREOF. This limitation of the
. NATIONAL INSTRUMENTS WILL NOT BE
, PROFITS,
liability of National Instruments will apply regardless of the form of action,
whether in contract or tort, including negligence. Any action against
National Instruments must be brought within one year after the cause of
action accrues. National Instruments shall not be liable for any delay in
performance due to causes beyond its reasonable control. The warranty
provided herein does not cover damages, defects, malfunctions, or service
failures caused by owner's failure to follow the National Instruments
installation, operation, or maintenance instructions; owner's modification of
the product; owner's abuse, misuse, or negligent acts; and power failure or
surges, fire, flood, accident, actions of third parties, or other events outside
reasonable control.
Copyright
Under the copyright laws, this publication may not be reproduced or
transmitted in any form, electronic or mechanical, including photocopying,
recording, storing in an information retrieval system, or translating, in
whole or in part, without the prior written consent of National Instruments
Corporation.
Trademarks
Product and company names listed are trademarks or trade names of their
respective companies.
WARNING REGARDING MEDICAL AND
CLINICAL USE OF NATIONAL
INSTRUMENTS PRODUCTS
National Instruments products are not designed with components and
testing intended to ensure a level of reliability suitable for use in treatment
and diagnosis of humans. Applications of National Instruments products
involving medical or clinical treatment can create a potential for accidental
injury caused by product failure, or by errors on the part of the user or
application designer. Any use or application of National Instruments
products for or involving medical or clinical treatment must be performed
by properly trained and qualified medical personnel, and all traditional
medical safeguards, equipment, and procedures that are appropriate in the
particular situation to prevent serious injury or death should always
continue to be used when National Instruments products are being used.
National Instruments products are NOT intended to be a substitute for any
form of established process, procedure, or equipment used to monitor or
safeguard human health and safety in medical or clinical treatment.
Preface
Introduction to the GPIB
The GPIB is a link, or bus, or interface system, through which
interconnected electronic devices communicate.
History of the GPIB
The original GPIB was designed by Hewlett-Packard (where it is called
the HP-IB) to connect and control programmable instruments
manufactured by Hewlett-Packard. Because of its high data transfer
rates of from 250 kilobytes to 1 megabyte per second, the GPIB quickly
gained popularity in other applications such as intercomputer
communication and peripheral control. It was later accepted as the
industry standard IEEE-488. The versatility of the system prompted the
name General Purpose Interface Bus.
National Instruments expanded the use of the GPIB among users of
computers manufactured by companies other than Hewlett-Packard.
National Instruments specialized both in high performance, high-speed
hardware interfaces, and in comprehensive, full-function software that
helps users bridge the gap between their knowledge of instruments and
computer peripherals and of the GPIB itself.
The GPIB-PC Family
The GPIB-PC family consists of GPIB interface hardware products,
software, documentation, and other items for several types of personal
computers.
What Your Package Should Contain
Unless you have a special application, your GPIB-PC package consists
of the following:
• A GPIB-PC interface board for your personal computer. Each
board has a model name such as GPIB-PCIIA. This manual uses
GPIB-PC to refer generally to all models of the GPIB-PC
interface board.
•A Getting Started with your GPIB-PC pamphlet. The pamphlet
contains the directions with a minimum of explanations for
installing your hardware and software in your GPIB system.
• A GPIB-PC distribution diskette. The distribution diskette is part
of the GPIB-PC package. It contains the DOS handler, BASICA
and QuickBASIC language interfaces, and other programs.
•A GPIB-PC User Manual. The manual contains descriptions of
the GPIB-PC handler functions, BASICA, and QuickBASIC
language interfaces to the handler.
•A Programmer Reference Guide for BASIC.
• A supplement to Section Two of the manual describing your
particular interface board and how to install it in your personal
computer.
For a language other than BASICA and QuickBASIC, you also need:
• An additional GPIB-PC distribution diskette containing the
software for that language.
• A supplement to Section Four describing the GPIB functions in
the syntax and semantics of that language.
• A Programmer Reference Guide for that language.
Who Are Our Users?
Most of our users have experience in technological fields and with
computers.
How to Get Started
If you already have experience with the GPIB, you may wish to turn
directly to the Getting Started with your GPIB-PC pamphlet that was
shipped with your hardware. It contains directions, with a minimum of
explanations, for installing your hardware and software in your GPIB
system.
If you are less experienced or want more information than the pamphlet
provides, read this GPIB-PC User Manual. It explains in detail all of the
information you will need for the proper operation of the GPIB-PC.
This manual is written specifically for a GPIB-PC which is to be
installed in an IBM Personal Computer or compatible PC which is
operating under PC-DOS or MS-DOS and programmed using BASICA
and QuickBASIC. With appropriate supplements to the manual, other
GPIB-PC interfaces can be installed in other computers, using other
programming languages.
Organization of the Manual
Section One - Operation of the GPIB describes the operation of the
GPIB.
Section Two - Installation and Configuration describes the installation of
the software and the configuration program IBCONF. A supplement
contains instructions for installing your particular board into your
computer.
Section Three - GPIB-PC Functions — Introduction introduces you to the
functions used by your GPIB-PC. The features are divided into groups
as a means of helping you understand the uses of the functions.
Section Four - GPIB-PC Functions — Overview introduces you to
programming information common to all languages.
Section Four A - Function Reference — Language Interface(s) pertains to
BASICA and QuickBASIC. The descriptions are listed alphabetically
for easy reference.
Section Five - IBIC introduces you to IBIC, the interactive control
program that allows you to control and communicate with the GPIB
through functions you enter at your keyboard. IBIC is designed to help
you learn how to use the GPIB-PC functions to program your devices.
Section Six - Applications Monitor introduces you to the applications
monitor, a resident program that is useful in debugging sequences of
GPIB calls from within your application.
Appendix A - Multiline Interface Messages is a listing of Multiline
Interface Command Messages.
Appendix B - Common Errors and Their Solutions singles out the most
common errors users have encountered and some probable solutions.
Appendix C - Differences Between Software Revisions points out
differences between revisions of the GPIB-PC handler.
Appendix D - Using your Printer with the GPIB-PC gives some quick
steps to connect your GPIB-PC with your printer.
Appendix E - Application Notes is an application note about computerto-computer transfers.
Appendix F - Customer Communication contains forms you can use to
request help from National Instruments or to comment on our products
and manuals.
The Glossary contains an alphabetical list and description of terms used
in this manual, including abbreviations, acronyms, metric prefixes,
mnemonics, and symbols.
The Index contains an alphabetical list of key terms and topics in this
manual, including the page where you can find each one.
Now, with your personal computer, your GPIB-PC, your manuals and
supplements, and these instructions, you are ready to get started with
your GPIB. We hope your experience will be a rewarding one.
Customer Support
National Instruments wants to receive your comments on our products
and manuals. We are interested in the applications you develop with
our products, and we want to help if you have problems with them. For
information on how to contact us, refer to Appendix F, Customer
Communication between interconnected devices is achieved by passing
messages through the interface system.
Types of Messages
The GPIB carries two types of messages — device-dependent messages
and interface messages.
• Device-dependent messages, often called data or data messages,
contain device-specific information such as programming
instructions, measurement results, machine status, and data files.
• Interface messages manage the bus itself. They are usually
called commands or command messages. Interface messages
perform such functions as initializing the bus, addressing and
unaddressing devices, and setting device modes for remote or
local programming.
The term command as used here should not be confused with some
device instructions which can also be called commands. Such devicespecific instructions are actually data messages.
Talkers, Listeners, and Controllers
A Talker sends data messages to one or more Listeners. The Controller
manages the flow of information on the GPIB by sending commands to
all devices.
Devices can be Listeners, Talkers, and/or Controllers. A digital
voltmeter, for example, is a Talker and may be a Listener as well.
The GPIB is a bus like an ordinary computer bus except that the
computer has its circuit cards interconnected via a backplane bus
whereas the GPIB has standalone devices interconnected via a cable
bus.
The role of the GPIB Controller can also be compared to the role of the
computer's CPU, but a better analogy is to the switching center of a city
telephone system.
The switching center (Controller) monitors the communications network
(GPIB). When the Controller notices that a party (device) wants to
make a call (send a data message), it connects the caller (Talker) to
the receiver (Listener).
The Controller usually addresses a Talker and a Listener before the
Talker can send its message to the Listener. After the message is
transmitted, the Controller usually unaddresses both devices.
Some bus configurations do not require a Controller. For example, one
device may always be a Talker (called a Talk-only device) and there
may be one or more Listen-only devices.
A Controller is necessary when the active or addressed Talker or
Listener must be changed. The Controller function is usually handled by
a computer.
With the GPIB-PC interface board and its software, your personal
computer plays all three roles:
•Controller - to manage the GPIB,
•Talker - to send data, and
•Listener - to receive data.
The Controller-In-Charge and System Controller
Although there can be multiple Controllers on the GPIB, only one
Controller at a time is active, or Controller-In-Charge (CIC). Active
control can be passed from the current CIC to an idle Controller. Only
one device on the bus, the System Controller, can make itself the CIC.
The GPIB-PC is usually the System Controller.
The interface system consists of 16 signal lines and 8 ground return or
shield drain lines.
The 16 signal lines are divided into the following three groups:
•8 data lines,
•3 handshake lines, and
•5 interface management lines.
Data Lines
The eight data lines, DIO1 through DIO8, carry both data and command
messages. All commands and most data use the 7-bit ASCII or ISO
code set, in which case the 8th bit, DIO8, is unused or used for parity.
Handshake Lines
Three lines asynchronously control the transfer of message bytes
between devices:
•NRFD,
•NDAC, and
•DAV.
The process is called a three-wire interlocked handshake and it
guarantees that message bytes on the data lines are sent and received
without transmission error.
NRFD (not ready for data)
NRFD indicates when a device is ready or not ready to receive a
message byte. The line is driven by all devices when receiving
commands and by Listeners when receiving data messages.
NDAC indicates when a device has or has not accepted a message byte.
The line is driven by all devices when receiving commands and by
Listeners when receiving data messages.
DAV (data valid)
DAV tells when the signals on the data lines are stable (valid) and can
be accepted safely by devices. The Controller drives DAV lines when
sending commands and the Talker drives DAV lines when sending data
messages.
Interface Management Lines
Five lines are used to manage the flow of information across the
interface:
•ATN,
•IFC,
•REN,
•SRQ, and
•EOI.
ATN (attention)
The Controller drives ATN true when it uses the data lines to send
commands and false when it allows a Talker to send data messages.
IFC (interface clear)
The System Controller drives the IFC line to initialize the bus and
become CIC.
REN (remote enable)
The System Controller drives the REN line, which is used to place
devices in remote or local program mode.
Any device can drive the SRQ line to asynchronously request service
from the Controller.
EOI (end or identify)
The EOI line has two purposes. The Talker uses the EOI line to mark
the end of a message string. The Controller uses the EOI line to tell
devices to identify their response in a parallel poll.
Physical and Electrical Characteristics
Devices are usually connected with a cable assembly consisting of a
shielded 24-conductor cable with both a plug and receptacle connector
at each end. This design allows devices to be linked in either a linear
or a star configuration, or a combination of the two. See Figures 1.1,
1.2, and 1.3.
The standard connector is the Amphenol or Cinch Series 57
MICRORIBBON or AMP CHAMP type. An adapter cable using nonstandard cable and/or connector is used for special interconnect
applications.
The GPIB uses negative logic with standard TTL logic level. When
DAV is true, for example, it is a TTL low-level ( ≤ 0.8V), and when
DAV is false, it is a TTL high-level ( ≥ 2.0V).
To achieve the high data transfer rate that the GPIB was designed for,
the physical distance between devices and the number of devices on the
bus are limited.
The following restrictions are typical.
• A maximum separation of four meters between any two devices
and an average separation of two meters over the entire bus.
• A maximum total cable length of 20 meters.
• No more than 15 devices connected to each bus, with at least
two-thirds powered on.
Bus extenders are available from National Instruments and other
manufacturers for use when these limits must be exceeded.
Related Documents
For more information on topics covered in this section consult the
following related documents.
• IEEE Std. 488-1978, IEEE Standard Digital Interface forProgrammable Instrumentation.
The procedures for installing your GPIB-PC depend on your model of
board and your make of computer. A supplement to Section Two
contains information about your interface board. Section Two A, for
example, contains information about the model GPIB-PCIIA for the IBM
PC and compatible computers.
Installing the Hardware
To install your hardware, follow the instructions in the Section Two
supplement for your interface board.
If you change the default settings of any switches, make a note of the
new values so that you can refer to them when you configure your
software.
Install the hardware before continuing.
The GPIB-PC Software Package
Before you install your software, you might wish to review the files on
your GPIB-PC distribution diskette to gain an understanding of what
they are.
The following files are the main files of the GPIB-PC software:
•GPIB.COM - is a device handler file that is loaded at system
start-up by the DOS operating system. Handler is a term used
by National Instruments to refer to a loadable device driver.
•BIB.M - is a language interface file that provides an
application program access to the GPIB-PC handler. BIB.M is
intended for use with programs written in BASICA.
•QBIB*.OBJ - is a language interface file that provides an
application program access to the GPIB-PC handler.
QBIB*.OBJ is intended for use with programs written in
QuickBASIC.
•DECL.BAS - is a declaration file that contains code to be
placed at the beginning of the BASICA and QuickBASIC
application programs.
•QBDECL.BAS - is a declaration file that contains code to be
placed at the beginning of the QuickBASIC application
programs.
Additional Programs and Files
The following additional programs and files include installation, test,
and example programs:
•APPMON.COM - is the applications monitor program. It is a
resident program that is useful in debugging sequences of GPIB
calls from within your application. The applications monitor
provides the capability to trap on return from GPIB driver calls,
allowing you to inspect function arguments, buffers, return
values, GPIB global variables, and other pertinent data.
•IBTRAP.EXE - is a program that configures the applications
monitor.
•IBSTART.BAT - is a batch file used for installation and start-
up. It is a multipurpose program that performs the software
installation. It copies files, modifies CONFIG.SYS (the DOS
system configuration file) using MKCFG.EXE, and tests the
hardware using IBDIAG.EXE.
•IBDIAG.EXE - is a program that tests the hardware installation
before the GPIB software is configured and installed. After the
handler is installed, IBTEST.BAT confirms that both the
software and hardware are installed and functioning properly.
The test is executed in two parts using IBTSTA.EXE and
IBTSTB.EXE.
•IBCONF.EXE - is a software configuration program that allows
you to change the software parameters and other data used by
the handler.
•IBIC.EXE - is an interactive control program that allows you
to execute the handler functions interactively from your
keyboard. It helps you to learn the functions, to program your
instrument or other GPIB device, and to develop your
application program.
DIBSAMP - are example programs for BASICA, QuickBASIC,
and IBIC. The BASICA and QuickBASIC supplement of the
manual, Section Four A, contains additional examples.
Installing the Software
The term boot disk refers to the hard disk or floppy disk that contains
DOS and that is read by your computer when it is booted. The term
boot refers to the action of loading DOS into your system from your boot
disk, either when power is applied or when the warm boot keys are
pressed.
Step 1 - Preparation
Your first step is determined by whether you wish to boot from a floppy
disk or a hard disk. Perform the step that applies to your system.
Booting from a Floppy Disk
If you boot DOS from a floppy diskette, you need a boot disk with
enough free space to hold a copy of the GPIB-PC software contained on
the distribution diskette.
Insert the boot diskette into the first drive (usually named A:) and the
distribution diskette into the second drive (B:). Boot your system if you
have not already done so.
Booting from a Hard Disk
If you boot DOS from a hard disk, you need a personal computer with
one floppy drive. The hard disk must have enough free space to hold a
copy of the GPIB-PC software contained on the distribution diskette.
Boot your system. Then, insert the distribution diskette into the floppy
drive.
Finally, IBSTART advises you to complete the following actions:
•Run IBCONF if you must reconfigure the software;
•Reboot your system to load the handler into DOS; and
•Run IBTEST to test the installation of the software.
Step 3 - Run IBCONF (optional)
The pamphlet Getting Started with your GPIB-PC that comes with your
interface board explains when you must run IBCONF to reconfigure the
software. You may also run IBCONF to examine how the software is
configured.
See More About
run IBCONF and on the configurable software parameters.
NOTE: You must run IBCONF if you have a PCIIA, or wish to change
defaults.
IBCONF
later in this section for information on how to
Step 4 - Reboot
Reboot your computer from the drive you specified when you ran
IBSTART so that DOS will load the GPIB-PC handler.
Step 5 -Test Software Installation
Run IBTEST from the directory GPIB-PC in your boot area by entering:
cd gpib-pc
ibtest
IBTEST tests whether the handler is installed and functioning with the
•Did you read Getting Started with your GPIB-PC and make any
required changes? If not, do so now.
•Did you change hardware switch settings on your GPIB-PC
board? If so, run IBCONF and accurately input the new settings
for the board.
•Are the GPIB.COM and CONFIG.SYS files installed in the root
directory of your boot drive? If not, check and repeat the
installation instructions.
•Did you reboot your system before you ran IBTEST? If not, do
so now.
If you have performed these steps and IBTEST still fails, carefully note
all error information and call National Instruments.
If no errors occur, proceed to the end of this section to learn how to use
the software and to develop your application program.
More About IBCONF
IBCONF is a screen-oriented, interactive program that is included on the
distribution diskette of the GPIB-PC package.
You use IBCONF to edit the description in the handler of characteristics
of the devices and boards in the system. Running IBCONF to place this
information directly in the handler eliminates the need to restate it
inside each application program.
IBCONF passes two groups of features to the handler. The first group
consists of the characteristics of the instruments or devices attached to
your GPIB-PC. The second group consists of the characteristics of each
GPIB-PC installed in the computer.
Each instrument used with the GPIB-PC has the following
characteristics:
•A symbolic name of each device on the GPIB (such as DEV5 or
PS5010).
•A GPIB-PC access board for each device (e.g., GPIB0). The
access board is discussed in Device Map Concepts and Terms
later in this section.
•A primary and, if used, secondary address for each device.
•A time limit that is to be imposed when executing certain
functions. This is to ensure that accessing a powered-off device
does not hang up the GPIB indefinitely.
•A way to terminate I/O transmissions to and from the device.
Some devices require or append an end-of-string character, such
as the ASCII line feed character, to data strings. Others use the
GPIB END message, which is sent or received via the EOI
signal line. Still others use both. Some terminate messages
only when a predetermined number of bytes are sent or
received.
Characteristics of each GPIB-PC
Each GPIB-PC has the following characteristics:
•A symbolic name (such as GPIB0 and GPIB1).
•A computer I/O or port address.
•The capability to be designated as the System Controller of the
devices on its bus.
•A time limit that is imposed when executing certain functions.
•A way to terminate I/O transmissions to and from the board
when executing board calls, i.e., by an end-of-string character,
an END message, and/or a byte count.
•Whether it uses high-speed or normal timing when transmitting
data to a device. With normal timing, there is a delay of at
least 2 µsec after the data is placed on the GPIB before the
Data Valid (DAV) line is asserted. With high-speed timing,
this delay is decreased to about 500 nsec.
•The Internal Clock Frequency for a PC-IIA. This is the value of
the internal PC bus clock.
Default Configurations
Just as the hardware has factory default settings for switches and
jumpers, the software also has factory default configurations. For
example, the default device names of the 16 GPIB devices are DEV1
through DEV16, but you might wish to assign more descriptive names to
each device, such as METER for a digital multimeter.
You can also use IBCONF to look at the current default settings in the
handler file.
If you do not make changes using IBCONF, the default characteristics of
the software remain in effect.
Primary Default Characteristics
The following are the primary default characteristics of the handler.
•There are 16 active devices with symbolic names DEV1 through
DEV16.
•GPIB addresses of these devices are the same as the device
number; for example, DEV1 is at address 1.
•The 16 devices are assigned to GPIB0 as their access board.
GPIB0 is the symbolic name of the first GPIB-PC board in your
system. If you have an additional GPIB-PC in your system, its
symbolic name is GPIB1.
•Each GPIB-PC is System Controller of its independent bus and
has a GPIB address of 0.
•The END message is sent with the last byte of each data
message to a device. Each data message that is read from a
device is automatically terminated when END is received. No
end-of-string character is recognized.
•The time limit on I/O and wait function calls is approximately
10 seconds.
•GPIB0 is a Model GPIB-PCII, is at base I/O address hex 02B8,
and uses DMA Channel 1 and TLC Interrupt Line 7.
•You must run IBCONF if you are using a GPIB-PCIIA or if you
have changed the hardware switches/jumpers on any GPIB-PC
from the factory settings. Otherwise, it is unnecessary to run
IBCONF. Consult the appropriate supplement to Section Two
of the user manual to find the factory settings of your GPIB-PC
model.
Running IBCONF
When you ran IBSTART, a copy of IBCONF.EXE was placed on your
boot drive.
To run IBCONF, go to the root directory of the boot drive and enter:
ibconf
If you have a color monitor, the configuration program will
automatically appear in color. If you have a color monitor but want the
configuration program to appear in monochrome, enter:
ibconf -m
IBCONF scans the handler file, GPIB.COM, and reads its data structures
into memory. After you press a key, the program displays the Device
Map for board GPIB0.
IBCONF makes changes to the GPIB.COM file, which should also be in
the root directory. If you want IBCONF to make changes to a different
copy of GPIB.COM such as GPIB2.COM, enter the path and name of
the GPIB.COM file you want modified:
ibconf c:\GPIB-PC\GPIB2.COM
This will have the effect of changing the parameters within the
GPIB2.COM file in the GPIB-PC subdirectory.
Modify only the copy of GPIB.COM created by IBSTART in your boot
directory. Never modify the master copy on the distribution diskette.
This would happen if you ran IBCONF from the distribution diskette and
if the distribution diskette were not write-protected.
Upper and Lower Levels of IBCONF
IBCONF operates at both an upper and a lower level. The upper level
consists of the Device Maps and gives an overview of the GPIB system
as defined within the handler being configured. The lower level consists
of screens that describe each individual board and device in the system.
Upper Level - Device Map for Board GPIBx
This screen displays the names of all devices defined in the handler file,
and indicates which devices, if any, are accessed through the interface
board GPIBx. At this level, you may:
•Rename a device;
•Disconnect a device from its assigned GPIB-PC access board or
connect (reassign) it to a different access board; or
•Proceed to the lower level to edit or examine the
characteristics of a particular board or device.
Instructions are given on the screen for selecting the individual devices
and for changing from one device map to another, for example, from the
map for GPIB0 to that for GPIB1.
•Device Name - contains up to seven characters. The rules for
naming devices are the same as DOS rules for naming files,
except that suffixes (.xxx) are not allowed. DOS treats
uppercase and lowercase letters identically. The string
"PLOTTER" is treated the same as the string "plotter". For
this reason, the configuration program maps all lowercase
letters to uppercase.
Device names must not be given the same names as files,
directories, and/or subdirectories. If you name a device PLTR
and your file system already contains the file PLTR.DAT or a
subdirectory PLTR, a conflict results.
•Access Board - all devices on the GPIB require an access board
within the computer. The access board is the GPIB-PC
interface board that provides the hardware link to the computer.
The access board name is of the form GPIBx, where x is a
digit 0 or 1 representing the appropriate GPIB board number.
The access board name is not alterable.
The string representing a device or board name is the first
variable argument of the function IBFIND called at the
beginning of your application program. Refer to Sections Three
and Four for detailed explanations of IBFIND.
Lower Level - Device/Board Characteristics
The lower level screens display the currently defined values for
characteristics such as addressing and timeout information of a device
or board. Instructions are available on the screen for selecting a specific
field and for modifying the current settings. The configuration settings
selected for each device and each board are a means of customizing the
communications and other options to be used with that board or device.
The settings for devices specify the characteristics to be used by the
access board for that device when device functions are used.
The settings for boards specify the characteristics to be used with each
board when board functions are used. In the following explanations of
device and board characteristics, notice that some characteristics apply
to both devices and boards and some apply only to boards.
Each device and board must be assigned a unique primary address in the
range hex 00 to hex 1E. A listen address is formed by adding hex 20 to
the primary address; the talk address is formed by adding hex 40 to the
primary address. Consequently, a primary address of hex 10 corresponds
to a listen address of hex 30 and a talk address of hex 50. The GPIB
primary address of any device is set within that device, either with
hardware switches, or, in some cases, a software program. This address
and the address listed in IBCONF must be the same. Refer to the
device-specific documentation provided with your instrument for
instructions about that device's address. The primary GPIB address of
all GPIB-PC boards is 0, unless changed by IBCONF. There are no
hardware switches on the GPIB-PC to select the GPIB address.
Secondary GPIB Address
Any device or board using extended addressing must be assigned a
secondary address in the range hex 60 to hex 7E, or the option NONE
may be selected to disable secondary addressing. As with primary
addressing, the secondary GPIB address of any device is set within that
device, either with hardware switches, or, in some cases, a software
program. This address and the address listed in IBCONF must be the
same. Refer to the device documentation for instructions. Secondary
addressing is disabled for all devices and boards unless changed by
IBCONF.
Timeout Settings
The timeout value is the approximate length of time that may elapse
before I/O functions such as IBRD, IBWRT, and IBCMD complete. It is
also the length of time that the IBWAIT function waits for an event
before returning if the TIMO bit is set. Consequently, a wait for the
SRQ line to be asserted will terminate after the time limit is reached if
both the SRQI and TIMO bits are set in the mask passed to IBWAIT,
and no SRQ signal is detected. Refer to the IBWAIT function
description in Sections Three and Four for more information.
Some devices can be programmed to terminate a read operation when a
selected character is detected. A linefeed character (hex 0A) is a
popular one.
NOTE: To send the EOS character to a device in a write operation, you
must explicitly include that byte in your data string.
EOS Modes
•Terminate a Read on EOS - Some devices send an EOS byte
signaling the last byte of a data message. A yes response will
cause the GPIB-PC to terminate read operations when it
receives the EOS byte.
•Set EOI with EOS on Write - A yes response will cause the
GPIB-PC to assert the EOI (send END) line when the EOS
character is sent.
•7- or 8-bit compare on EOS - Along with the designation of an
EOS character, you may specify whether all eight bits are
compared to detect EOS, or just the seven least significant bits
(ASCII or ISO format).
Set EOI with last byte of Write
Some devices, as Listeners, require that the Talker terminate a data
message by asserting the EOI signal line (sending END) with the last
byte. A yes response will cause the GPIB-PC to assert EOI on the last
data byte.
GPIB-PC Model
The GPIB-PC Model must be specified so that the handler will use the
appropriate hardware addressing scheme.
Board is System Controller (Boards Only)
This field appears on the board characteristics screen only. Generally,
the GPIB-PC will be the System Controller. In some situations, such as
in a network of computers linked by the GPIB, another device may be
System Controller and the GPIB-PC will NOT be designated System
Controller. A yes response designates the GPIB-PC to be System
Controller. A no response designates it not to be System Controller.
It is desirable to place many devices in the local lockout state while
they are being remotely accessed. If yes is selected, the access board
will place all of its devices in local lockout state while accessing them.
Disable Auto Serial Polling (Boards Only)
This option allows you to disable automatic serial polls if this feature is
incompatible with certain devices on the bus. While this feature is on,
the handler conducts serial polls of the devices and stores positive
responses whenever the GPIB Service request (SRQ) line is asserted.
Refer to Automatic Serial Polling of Section Four for further information.
Normally, this feature will not conflict with devices that conform to the
IEEE-488 specification.
High-Speed Timing (Boards Only)
Some devices are unable to read data messages at high-speed (Tristate) timing. If your GPIB system has slower devices, you may want to
select a longer data setting time by selecting no for this field.
Interrupt Jumper Setting (Boards Only)
This field must be set to the same value as the interrupt level jumper
setting on the GPIB-PC board itself. For most personal computers, this
jumper setting reflects the actual interrupt level selected. Any
exception is explained in the Getting Started with your GPIB-PC
pamphlet that comes with the interface board. Any valid interrupt level
may be selected, provided the level does not conflict with other
equipment.
Base I/O Address (Boards Only)
The GPIB-PC may be assigned any one of the legal base I/O or port
addresses as described in the appropriate supplement to this section.
The value entered must match the hardware setting selected during
hardware configuration. If it does not match, the handler cannot
communicate with the GPIB-PC.
This field appears only on computers supporting DMA capability. The
GPIB-PC may use any of the three DMA channels, 1, 2, or 3, provided
that another device is not already using that channel. If a DMA channel
is not available, programmed I/O can be enabled by selecting NONE.
Internal Clock Frequency (Boards Only)
For the GPIB-PCII, this value is equal to the frequency of the PC bus
signal OSC divided by 2 and rounded up. Since OSC is fixed at 14.14
MHz for all IBM PCs and compatibles, this field is always set to 8.
For the GPIB-PCIIA, this value is equal to the frequency of the PC bus
signal CLK and rounded up. Since the signal CLK varies according to
the machine, this field varies as well. Typical examples are:
Ma ch i nePCII ICF valuePCIIA ICF value
IBM PC, XT, and compatibles85
IBM XT (new)88
IBM AT and compatibles86
Compaq Deskpro85,8
Compaq Deskpro 28686,8
Compaq Portable 28686,8
Notice that on some computers the CLK frequency depends on whether
the CPU is operated at normal or high-speed mode. If you want to
operate the GPIB-PC under both modes, either reconfigure the software
or use the higher value. If you are in doubt as to what value to enter,
use 8.
Exiting IBCONF
Once all changes have been made, you may exit IBCONF by typing the
function key indicated on the screen. The program will first ask if it
should save any changes before exiting. Typing a y response causes the
changes to be written to the file on disk. Before exiting, the program
will check for situations that may cause problems.
•GPIB addressing conflict between a device and its access
board;
•GPIB boards not present in the host machine at the specified
address; and
•Timeouts disabled on a device or board.
If any of these situations is encountered, you will be notified and given
the option of re-entering or exiting IBCONF. To disable auto-checking,
call IBCONF -E.
After exiting, the system MUST be rebooted for the new values to take
effect.
Some functions may be called during the execution of an application
program to change some of the configured values temporarily. These
functions are shown in Table 2.2.
Table 2.2 - Functions that Alter Default Characteristics
CharacteristicDynamically Changed by
Primary GPIB addressIBPAD
Secondary GPIB addressIBSAD
End-of-string (EOS) byteIBEOS
7- or 8- bit compare on EOSIBEOS
Set EOI with EOS on WriteIBEOS
Terminate a Read on EOSIBEOS
Set EOI w/last byte of WriteIBEOT
Change board assignmentIBBNA
Enable or disable DMAIBDMA
Change or disable time limitIBTMO
Request/release system controlIBRSC
Now that your software and hardware are installed, read Section Three
for an introduction to the functions available for the GPIB-PC. The
functions are described in the order that you will most likely use them.
Pay special attention to Group I, Group II, and Group III.
After reading about these functions, practice using them with your
programmable instrument or device in an interactive environment using
the IBIC program described in Section Five. IBIC allows you to
program your instrument interactively from the computer keyboard rather
than from an application program. This helps you understand how the
device and the handler work. It also familiarizes you with status
information that is returned by each function and that is also available
to your application program in the form of global variables.
While running IBIC, study the descriptions of each function given in
Section Four to fully understand the purpose and syntax of each
function.
Finally, referring to the appropriate language supplement of Section
Four, write your application program. Whenever possible, use IBIC to
test the sequence of the GPIB-PC function calls your application
program makes. Trying your function calls from IBIC is especially
helpful if your application program responds in an unexpected manner.
This section introduces you to the GPIB-PC handler functions and their
capabilities. They are described in the order you will most likely use
them.
Application environments for which the functions are designed are
described. Short examples illustrate how the functions operate.
Introduction to the GPIB-PC Functions
The GPIB-PC functions are high-level and low-level functions that
communicate with and control devices on the GPIB. The functions are
divided into six groups, and each group is distinguished by the type of
applications it serves. The functions contained in the first three groups
are mostly high-level, while those of the last three are mostly low-level.
High-Level Functions
High-level functions are easy to learn and use. They automatically
execute sequences of commands that handle bus management
operations required to perform activities such as reading from and
writing to devices and polling them for status. These functions free you
from having to know the GPIB protocol or bus management details
involved. Most device functions (functions that specify a device) are
high-level functions.
Low-Level Functions
In contrast, low-level functions perform rudimentary or primitive
operations that require that you know something about GPIB protocol to
use them effectively. They are needed because high-level functions do
not always meet the requirements of applications. In such cases, lowlevel functions offer the flexibility you need to solve most of your
application problems. All board functions (functions that specify a
board) are low-level functions.
Calling Syntax
The calling syntax for GPIB-PC functions varies according to the
language used. In this section, a generic syntax is used to identify the
function and its arguments.
Group I functions may be the only functions you need for many of your
instrument control applications. Group I functions are as follows:
•IBRD,
•IBWRT, and
•IBFIND.
They are suitable for your applications under the following conditions:
•Communication is between the Controller (computer) and one
device at a time. Messages are not broadcast to several
devices at once, and devices do not talk to each other directly.
•Devices do not require special services or operations, such as
polling or triggering, to send or receive data.
IBRD and IBWRT are high-level input/output (I/O) functions. IBFIND
is a start-up function that opens the device.
IBRD (bd,buf,cnt)
IBRD reads a specified number of bytes from a device and stores them
in memory. The device is automatically addressed before reading and
unaddressed afterward. If not done previously, the GPIB is initialized on
entering the function and the device is placed in remote programming
mode.
When programming in BASIC, IBRD performs string transfers. IBRDI
is available for binary transfers to an integer array.
IBWRT (bd,buf,cnt)
IBWRT writes a specified number of bytes from the memory buffer to a
device. The device is automatically addressed before writing and
unaddressed afterward. If not done previously, the GPIB is initialized on
entering the function, and the device is placed in remote programming
mode.
When programming in BASIC, IBWRT performs string transfers.
IBWRTI is available for binary transfers from an integer array.
IBFIND returns a unit descriptor associated with the name of the
device. When the software is installed, a description of each device is
placed in an internal reference table accessible by the handler. This
description includes the GPIB address, end-of-string (EOS) modes,
timeout selection, and a name for the device.
Group II
Group II functions offer additional high-level device services often
needed in common instrument control applications. Group II functions
are as follows:
•IBRSP,
•IBCLR,
•IBTRG, and
•IBLOC.
IBRSP (bd,spr)
IBRSP serially polls a device and returns its status response. The
response consists of a single byte in which the hex 40 bit is set if the
device is requesting service and asserting Service Request (SRQ).
Here are examples of a Tektronix 4041 BASIC SRQ handler call and
the corresponding IBRSP call. In this case, the device being polled is
the plotter and is at GPIB address 7:
POLL STATUS, ADDRESS; 7
CALL IBRSP (PLTR%,STATUS%)
In both cases, the plotter's status response is stored in the variable
STATUS.
Unless disabled during software configuration, any device function call
will automatically conduct serial polls if SRQ is asserted on GPIB. This
automatic serial polling is discussed in Section Four.
IBCLR clears the device by sending to it the Selected Device Clear
(SDC) and appropriate addressing commands.
Clearing the Device Versus Clearing the GPIB
There is a difference between clearing or initializing devices and
clearing or initializing the GPIB itself.
Clearing the Device
The Selected Device Clear (SDC) command that is sent by the IBCLR
function resets internal functions of the device, such as causing a digital
multimeter to change its function, range, and trigger mode back to
default settings.
Clearing the GPIB
The Interface Clear (IFC) command initializes the GPIB and the bus
interface circuits of all attached devices without affecting internal
functions. IFC is sent automatically when the first device function is
called.
A device function is a function that references a device such as the four
already described: IBRD, IBWRT, IBRSP, and IBCLR.
IBTRG (bd)
IBTRG triggers the device by sending to it the Group Execute Trigger
(GET) and appropriate addressing commands.
IBLOC (bd)
IBLOC places the device in local program mode by sending the Go To
Local (GTL) and appropriate addressing commands to the device.
Placing a Device in Remote Mode
The first device function call after power-on, in addition to sending the
IFC command as previously described, also places the device in remote
program mode by setting the GPIB Remote Enable (REN) line and
addressing the device to listen.
Devices must usually be placed in remote program mode before they
can be programmed from the GPIB. This operation is done
automatically by the handler. The IBLOC function is then used when
that device must be returned to local program mode.
In addition, unless disabled using the configuration program (IBCONF),
the handler places devices in local lockout mode, which prevents you
from returning a device to local mode using the device's front-panel
control.
The seven previously described functions will be sufficient to meet your
application needs, in most cases. They are the most important functions
for you to learn.
Group III
The functions of Group III are more flexible for controlling and
communicating with devices. Group III functions are as follows:
These functions are used under the following conditions:
•Program execution must proceed in parallel with GPIB I/O –
often called asynchronous operation.
•I/O is to or from a file rather than a memory buffer.
•Controller-In-Charge authority must be transferred to another
GPIB device.
•The timeout value must be changed.
•The handler must be reinitialized with respect to certain
devices.
IBRDA (bd,buf,cnt) and
IBWRTA (bd,buf,cnt)
These functions are similar to IBRD and IBWRT except that the
operation is asynchronous. This means that the function returns after
starting the I/O operation without waiting for it to complete.
When programming in BASIC, IBRDA and IBWRTA perform string
transfers. IBRDIA and IBWRTIA are available for transfers to and from
an integer array.
IBRDF (bd,buf,cnt) and
IBWRTF (bd,buf,cnt)
These functions are similar to IBRD and IBWRT except that data is read
into a file.
IBWAIT (bd,mask)
IBWAIT waits for one or more events to occur. For the IBRDA and
IBWRTA functions, the event to wait for is the completion of the
operation.
IBSTOP (bd)
IBSTOP aborts any asynchronous operation associated with the device.
IBTMO changes the time limit in which operations with the device must
complete.
IBONL (bd,v)
IBONL re-initializes the device and cancels any asynchronous I/O in
progress. All reconfigurable software parameters, such as the time limit
just discussed, are reset to their power-on values. See the discussion of
software configuration in Section Two for further information on
reconfigurable software parameters.
The last function in this group allows the computer to pass control to
another device capable of being the Controller.
IBPCT (bd)
IBPCT passes Controller-In-Charge authority to the specified device by
sending the Take Control (TCT) commands and appropriate addressing
commands.
Most GPIB-compatible instruments or other types of devices can be
programmed using the high-level functions of Groups I, II, or III. Not all
devices, however, are completely compatible with the IEEE-488
specification, nor are the combinations of bus management and/or I/O
operations contained in the high-level functions suitable for all
applications.
Some operations, such as interprocessor networks and peripheral
sharing, require additional capabilities and flexibility in controlling the
GPIB. This is achieved, in part, with low-level functions that perform
single GPIB activities, each with a limited scope or objective. Powerful
and versatile routines can be developed using these functions. Groups
IV, V, and VI consist mostly of low-level functions.
The functions described previously have been device functions; that is,
the bd argument referred to a device on the GPIB. This section
introduces board functions, where bd refers to a specific GPIB-PC
interface board in the computer. Group IV functions are as follows:
Group IV functions can be used under the following conditions:
•Messages are broadcast to more than one device at a time.
•Messages are sent directly from one device to another, without
passing through the Controller.
•GPIB lines, such as Attention (ATN), must be turned off or on
in a particular fashion to ensure proper operation of a device.
•Devices must be polled in parallel rather than in serial.
Purpose of Board Functions
The handler software can control or communicate over the GPIB only by
manipulating a GPIB-PC interface board. Remote devices are accessed
indirectly by programming the interface board to do specific things.
Device functions are selected sequences of some basic board functions.
Board functions provide the precise control of the GPIB that is needed
for special applications.
Multiboard Capability
The handler can control or manipulate more than one interface board.
This type of handler is commonly called a multiboard handler, as
opposed to a single board handler in which one copy of the handler can
control only one board.
Figure 3.1 shows a multiboard GPIB system with board GPIB0
connected to two devices, an oscilloscope and a digital voltmeter; and
with board GPIB1 connected to two other devices, a printer and a
plotter.
Each board is called the access board for its attached devices because
the board is used automatically by the device functions to access those
devices. More information about board and device functions is provided
in More About Device and Board Functions at the end of this section.
This is the same as the Group I function except that boards are assigned
names at configuration time in the form GPIBn, where n is a board's
decimal number (0, 1, 2, ...) within the computer. For instance, in a
system with two GPIB boards, the first is named GPIB0 and the second
GPIB1.
IBCMD (bd,buf,cnt) and
IBCMDA (bd,buf,cnt)
Both functions use the specified board to write commands from memory
to the GPIB. The messages are sent synchronously using IBCMD and
asynchronously using IBCMDA. These command functions are used, for
example, to address and unaddress GPIB devices and to send interface
messages that enable and disable devices for serial and parallel polls,
that clear and trigger devices, and that lock out front panel control of
devices.
IBRD (bd,buf,cnt) and
IBRDA (bd,buf,cnt)
Both functions use the specified board to read from a device that has
already been addressed to talk (for example, by the IBCMD or IBCMDA
function). The syntax for these low-level functions is the same as their
high-level counterparts of Group I and III. The software automatically
differentiates bd descriptors that refer to devices from those that refer to
boards, and executes the read operations appropriately.
IBRDI and IBRDIA are also available in BASIC for binary transfers to
an integer array.
Both functions use the specified board to write to one or more devices
that have already been addressed to listen (for example, by the IBCMD
or IBCMDA function). The syntax for these low-level functions is the
same as their high-level counterparts of Group I and III. The software
automatically differentiates between bd descriptors that refer to devices
and those that refer to boards, and executes the write operations
appropriately.
IBWRTI and IBWRTIA are also available in BASIC for binary transfers
from an integer array.
IBSTOP (bd)
IBSTOP aborts any asynchronous operation associated with the board.
IBWAIT (bd,mask)
IBWAIT waits for the specified board to detect one of the events
selected in the mask bit vector to occur. These events include the
completion of asynchronous input/output (CMPL); the board becoming a
talker (TACS), listener (LACS), or Controller-In-Charge (CIC);
detection of a GPIB Service Request (SRQI); assertion of the Attention
signal (ATN); detection of the END message (END); or detection of a
time limit (TIMO) or other error condition (ERR).
IBTMO (bd,v)
IBTMO changes the time limit in which operations with the board must
complete.
IBONL (bd,v)
IBONL performs the same initialization function for boards as the Group
III IBONL function does for devices. In addition, the hardware as well
as the software is reset and the board is placed online (enabled) or
offline (disabled).
IBSIC (bd)
IBSIC uses the board to initialize the GPIB by sending the Interface
Clear (IFC) message.
IBSRE uses the board to set or clear the GPIB Remote Enable (REN)
line.
IBGTS (bd,v)
IBGTS causes the board to go from Active Controller to Standby
Controller, and in so doing to turn the ATN signal off. This function is
generally used to allow two external devices to talk to each other
directly. The board can selectively participate in the handshake of the
data transfer and hold off the handshake when the END message is
detected. The board may then take control synchronously without
corrupting the transfer.
IBCAC (bd,v)
IBCAC causes the board to take control of the GPIB by setting ATN and
going from Standby to Active Controller. The board can take control
synchronously or asynchronously.
IBRPP (bd,buf)
IBRPP conducts a parallel poll and returns the result.
IBPPC (bd,v)
IBPPC remotely configures or unconfigures the devices for parallel
polls.
Before proceeding to the next group of functions, you will find it helpful
to compare how a high-level device function can be replaced by several
low-level board functions. Conducting a serial poll is a good example.
In the discussion of the IBRSP function of Group II, this BASIC
example of the device function was used:
CALL IBRSP (PLTR%,STATUS%)
This is equivalent to the following sequence using the board functions
just described:
The first IBCMD function is used to send the string of ASCII commands
assigned in the first program line. These are Unlisten (?), Serial Poll
Enable (CHR$(&H18)), talk address of the plotter (G), and listen
address of the board (!). Now that the plotter is enabled to send its
status byte and the board is addressed to receive it, the IBRD function is
called to read the byte and store it in the variable STATUS. The final
IBCMD function completes the poll by sending the command string
consisting of three messages: Untalk (_), Unlisten (? ), and Serial Poll
Disable (CHR$(&H19)).
You can see that a high-level device function is easier to use. However,
when an application requires a more complex serial poll routine than the
one just described, such as a serial poll routine which polls several
devices in succession and provides other servicing operations at the
same time, low-level board functions can be used to create such a
routine.
Group V functions are used when the GPIB-PC is not CIC. An example
is a system where the computer in which the board is installed performs
as an instrument, but is controlled by another device on the GPIB.
Group V functions are as follows:
•IBRSV,
•IBLOC,
•IBPPC,
•IBIST, and
•IBWAIT.
These functions are used to:
•Request service from the CIC.
•Simulate a front panel "return to local" switch.
•Reconfigure a board or device for a parallel poll.
•Locally configure for parallel polls and change the parallel poll
flag.
•Wait for the CIC to execute certain actions.
IBRSV (bd,v)
IBRSV requests service from the CIC and to set the status byte that is
sent when the board is serially polled by the controller.
IBLOC (bd)
IBLOC sends a return to local message to the board. The message
clears an internal remote status condition if it is set and the internal
lockout status condition is not set. These conditions can be checked
with the IBWAIT function. How the application program interprets this
action is system dependent.
IBPPC locally configures or unconfigures the board for parallel polls.
IBIST (bd,v)
IBIST sets or clears the board's parallel poll flag (also known as the
individual status bit).
IBWAIT (bd,mask)
This function is described in Group IV. It is included here to describe
the additional events associated with noncontroller operations that the
function can detect. These include being triggered (DTAS) or cleared
(DCAS) by the controller, being placed in remote programming mode
(REM) by the controller, or being placed in a lockout state (LOK) by
the controller.
Group VI functions are used only when the default values of the
configuration parameters set during software installation need to be
changed dynamically or temporarily during execution of the application
program. Group VI functions are as follows:
•IBEOT,
•IBEOS,
•IBBNA,
•IBDMA,
•IBPAD,
•IBSAD,
•IBRSC, and
•IBTMO.
They are used to accomplish the following actions:
•Change the way I/O transmissions are terminated.
•Associate a device with a different access board.
•Change from DMA to programmed I/O.
•Change the GPIB address of a board or device.
•Request or release System Control.
IBEOT (bd,v)
IBEOT enables or disables sending the END message (EOI) with the
last byte written by the board.
IBEOS assigns the end of string (EOS) character to use with subsequent
IBRD and IBWRT operations. This character is compared with incoming
bytes from the device and may be used to terminate a read operation. It
is also compared with outgoing bytes to the device and may be used to
generate the END message (EOI).
IBBNA (bd,"GPIBn")
IBBNA assigns board n to be the access board for device bd.
IBDMA (bd,v)
IBDMA selects DMA or programmed I/O for the board. This function is
only appropriate for boards with DMA capability.
IBPAD (bd,v)
IBPAD sets the primary GPIB address of the device or board.
IBSAD (bd,v)
IBSAD sets the board's or device's secondary GPIB address or disables
secondary addressing.
IBRSC (bd,v)
IBRSC causes the board to request or release System Control authority.
IBTMO (bd,v)
IBTMO sets the time limit in which operations with a device or board
must complete.
Another important feature of the GPIB-PC functions is that they return
status information about the boards and devices in the system. This
information is returned in the form of three global status variables,
IBSTA, IBERR, and IBCNT. The beginning of Section Four fully
describes these variables.
This section consists of Section Four and a BASIC supplement. Section
Four contains a discussion of the important characteristics common to
all programming languages. The BASIC supplement lists the GPIB
functions for BASICA and QuickBASIC languages.
When you order a language other than BASIC, you receive a separate
supplement unless your language is very similar to BASICA. Insert any
new supplements in place of or in addition to Section Four A.
General Programming Information
The following characteristics are common to all programming
languages:
•A Status Word,
•Error Codes,
•A Count Variable,
•Read and Write Termination,
•Device Function Calls, and
•Automatic Serial Polling.
A thorough understanding of the concepts presented here is essential to
the implementation of a GPIB system.
The next several paragraphs explain the status word (IBSTA), the error
variable (IBERR), and the count variable (IBCNT). These variables are
updated with each function call to reflect the status of the most recently
referenced device or board.
All functions return a status word containing information about the state
of the GPIB and the GPIB-PC. You should test for the conditions
reported in the status word to make decisions about continued
processing. The status word is returned in the variable IBSTA.
The status word contains 16 bits, of which 14 are meaningful. A bit
value of 1 indicates the corresponding condition is in effect. A bit value
of zero indicates the condition is not in effect.
Table 4.1 lists the conditions and the bit position to be tested for that
condition. Some bits are set only on device function calls (d); some
bits are set only on board function calls (b); and some bits are set on
either type (db).
Table 4.1 - Status Word Layout
MnemonicsBitHexFunctionDescription
Pos.ValueType
ERR158000dbGPIB error
TIMO144000dbTime limit exceeded
END132000dbEND or EOS detected
SRQI121000bSRQ interrupt received
RQS11800dDevice requesting
service
CMPL8100dbI/O completed
LOK780bLockout State
REM640bRemote State
CIC520bController-In-Charge
ATN410bAttention is asserted
TACS38bTalker
LACS24bListener
DTAS12bDevice Trigger State
DCAS01bDevice Clear State
A description of each status word and its condition follows.
ERR (db)ERR is set in the status word following any call that results
in an error; the particular error may be determined by
examining the IBERR variable. It is cleared following any
call that does not result in an error.
NOTE: Always check for an error condition after each call.
An error made early in your application program may not
become apparent until a later instruction. At that time, the
error can be more difficult to locate.
TIMO (db) TIMO specifies whether a timeout has occurred. It is set in
the status word following a call to IBWAIT if the TIMO bit
of the IBWAIT mask parameter is also set and if the wait
has exceeded the time limit value that is set by the IBTMO
call. It is also set following a call to any of the synchronous
I/O functions (e.g., IBRD, IBWRT, and IBCMD) if a timeout
occurs during a call. TIMO is cleared in the status word in
all other circumstances.
END (db)END specifies whether the END or EOS message has been
received. It is set in the status word following a read
function if the END or EOS message was detected during
the read. While the GPIB-PC is performing a shadow
handshake as a result of the IBGTS function, any other
function call may return a status word with the END bit set
if the END or EOS message occurred before or during that
call. It is cleared in the status word when any I/O operation
is initiated.
SRQI (b)SRQI specifies whether a device is requesting service. It is
set in the status word whenever the GPIB-PC is CIC and
the GPIB SRQ line is asserted. It is cleared whenever the
GPIB-PC ceases to be the CIC, or the GPIB SRQ line is
unasserted. The bit is also cleared when executing board
functions and the GPIB-PC is an active talker, i.e., it is
addressed to talk and ATN is unasserted.
In Revision D software, the SRQI status bit always reflects
the current level of the SRQ line whether or not the GPIBPC is CIC.
RQS (d)RQS appears only in the status word of a device function
call. Indicates that the device is requesting service. It is
set in the status word whenever the hex 40 bit is asserted in
the device's serial poll status byte. The serial poll which
obtains the status byte may be the result of an IBRSP call,
or it may be done automatically by the handler. It is
cleared when the user has called IBRSP to read the serial
poll status byte that caused the RQS. An IBWAIT on RQS
should only be done on devices that respond to serial polls.
CMPL (db) CMPL specifies the condition of outstanding I/O operations.
It is set in the status word whenever I/O is not in progress;
that is, whenever I/O is complete. It is cleared while I/O is
in progress.
LOK (b)LOK specifies whether the board is in a lockout state.
While LOK is set, the function IBLOC is effectively
inoperative for that board. It is set whenever the GPIB-PC
detects the Local Lockout (LLO) message has been sent
either by the GPIB-PC or by another Controller. It is
cleared when the Remote Enable (REN) GPIB line
becomes unasserted either by the GPIB-PC or by another
Controller.
REM (b)REM specifies whether the board is in remote state. It is
set whenever the Remote Enable (REN) GPIB line is
asserted and the GPIB-PC detects its listen address has
been sent either by the GPIB-PC or by another Controller.
It is cleared whenever REN becomes unasserted, or when
the GPIB-PC as a Listener detects the Go to Local (GTL)
command has been sent either by the GPIB-PC or by
another Controller, or when the IBLOC function is called
while the LOK bit is cleared in the status word.
CIC (b)CIC specifies whether the GPIB-PC is the Controller-In-
Charge. It is set whenever the IBSIC function is called
while the GPIB-PC is System Controller, or when another
Controller passes control to the GPIB-PC. It is cleared
whenever the GPIB-PC detects Interface Clear (IFC) from
the System Controller, or when the GPIB-PC passes control
to another device.
ATN (b)ATN specifies the state of the GPIB Attention (ATN) line.
It is set whenever the GPIB ATN line is asserted and
cleared when the ATN line is unasserted.
TACS (b)TACS specifies whether the GPIB-PC has been addressed
as a Talker. It is sent either by the GPIB-PC itself or by
another Controller. It is cleared whenever the GPIB-PC
detects the Untalk (UNT) command, a talk address other
than its own talk address, or Interface Clear (IFC).
LACS (b)LACS specifies whether the GPIB-PC has been addressed
as a Listener. It is set whenever the GPIB-PC detects its
listen address (and secondary address, if enabled) has been
sent either by the GPIB-PC itself or by another Controller.
It is also set whenever the GPIB-PC shadow handshakes as
a result of the IBGTS function. It is cleared whenever the
GPIB-PC detects the Unlisten (UNL) command, its own
talk address, Interface Clear (IFC), or IBGTS is called
without shadow handshake.
DTAS (b)DTAS specifies whether the GPIB-PC has detected a
device trigger command. It is set whenever the GPIB-PC,
as a Listener, detects the Group Execute Trigger (GET)
command has been sent by another Controller. It is cleared
in the status word on any call immediately following an
IBWAIT call if the DTAS bit is set in the IBWAITmask
parameter.
DCAS (b)DCAS specifies whether the GPIB-PC has detected a
device clear command. It is set whenever the GPIB-PC
detects the Device Clear (DCL) command has been sent
by another Controller, or whenever the GPIB-PC as a
Listener detects the Selected Device Clear (SDC)
command has been sent by another Controller. It is cleared
in the status word on any call immediately following an
IBWAIT call if the DCAS bit was set in the IBWAITmask
parameter, or on any call immediately following a read or
write.
In addition to the above, the following situations also affect the status
word bits:
•A call to the function IBONL clears the following bits:
END LOK REM CIC TACS LACS DTAS DCAS
•A call to IBONL affects bits other than those listed here
according to the rules explained above.
In the event that a function call returns an ENEB or EDVR error, all
status word bits except the ERR bit are cleared, since these error codes
indicate that it is not possible to obtain the status of the GPIB-PC.
When the ERR bit is set in the status word, a GPIB error has occurred.
The error code is returned in the variable IBERR.
There are 14 possible error codes. Table 4.2 lists these codes, a
recommended mnemonic to be associated with that type of error, and
the numeric value of the code.
Table 4.2 - GPIB Error Codes
SuggestedDecimalExplanation
MnemonicValue
EDVR0DOS error
ECIC1Function requires GPIB-PC to be CIC
ENOL2N o Listener on write function
EADR3GPIB-PC not addressed correctly
EARG4Invalid argument to function call
ESAC5GPIB-PC not System Controller as required
EABO6I/O operation aborted
ENEB7Non-existent GPIB-PC board
EOIP10I/O started before previous operation
completed
ECAP11No capability for operation
EFSO12File system error
EBUS14Command error during device call
ESTB15Serial Poll status byte lost
ESRQ16SRQ stuck in ON position
A description of each error and some conditions under which it may
occur follows:
EDVR (0)EDVR is returned by the language interface when the
device or board name passed in an IBFIND call is not
configured in the handler. In this case, the variable IBCNT
will contain the DOS error code 2, "Device not found." The
remedy is to replace the argument to IBFIND with a valid
board or device name, or reconfigure the handler using the
IBCONF utility to recognize the name.
It is also returned when an invalid unit descriptor is passed
to any function call. In this case, the variable IBCNT will
contain the DOS error code 6, "Invalid handle." The
remedy is to be sure that IBFIND has been called and that
it returned successfully. Also note that following a call to
IBONL with a second argument of 0, which places bd
"offline," an IBFIND is required before any subsequent
calls with that device or board.
EDVR is also returned when the handler (GPIB.COM) is
not installed. The remedy is to check the CONFIG.SYS
file in the root directory and make sure it contains the line:
DEVICE=GPIB.COM
ECIC (1)ECIC is returned when one of the following board level
calls is made while the board is not CIC of the GPIB:
•IBCMD,
•IBRPP,
•IBCAC, and
•IBGTS.
In cases when the GPIB-PC should always be the CIC, the
remedy is to be sure to call IBSIC to send Interface Clear
before attempting any of these calls, and to avoid sending
the command byte TCT (hex 09, Take Control). In
multiple CIC situations, the remedy is to always be certain
that the CIC bit appears in the status word IBSTA before
attempting these calls. If it is not, it is possible to perform
an IBWAIT (CIC) call to delay further processing until
control is passed to the board.
ENOL (2)ENOL usually occurs when a write operation was attempted
with no listeners addressed. For a device write, this error
indicates that the GPIB address configured for that device
in the handler does not match the GPIB address of any
device connected to the bus. This situation may be
corrected by either attaching the appropriate device to the
GPIB, by modifying the address of an already attached
device, by altering the switches on the device, by calling
IBPAD (and IBSAD if necessary) to make the configured
address match the device switch settings, or by using the
IBCONF configuration utility to reassign the proper GPIB
address to the device in the handler.
For a board write, an IBCMD call is generally necessary to
address devices before an IBWRT. Be sure that the proper
listen address is in the IBCMD argument string and that no
Unlisten (hex 3F) command follows it.
ENOL may occur in situations in which the GPIB-PC is not
the CIC and the Controller asserts ATN before the write
call in progress has ended. The remedy is either to reduce
the write byte count to that which is expected by the
Controller, or to resolve the situation on the Controller's
end.
EADR (3)EADR occurs when the GPIB-PC is CIC and is not
addressing itself before read and write calls are made. This
error is extremely unlikely to occur on a device call. For a
board call the remedy is to be sure to send the appropriate
Talk or Listen address using IBCMD before attempting the
IBWRT or IBRD.
EADR is also returned by the function IBGTS when the
shadow-handshake feature is requested and the GPIB ATN
line is already unasserted. In this case, the shadow
handshake is not possible and the error is returned to notify
you of that fact. IBGTS should almost never be called
except immediately after an IBCMD call. (IBCMD causes
ATN to be asserted.)
EARG (4)EARG results when an invalid argument is passed to a
function call. The following are some examples:
IBTMO called with a value not in the range 0-17.
IBEOS called with meaningless bits set in the high byte of
the second parameter.
IBPAD or IBSAD called with illegal addresses.
IBPPC called with illegal parallel poll configurations.
A board-only call made with a valid device descriptor, or a
device-only call made with a valid board descriptor.
(NOTE: EDVR is returned if the descriptor is invalid.)
ESAC (5)ESAC results when IBSIC or IBSRE is called when the
GPIB-PC does not have System Controller capability. The
remedy is to give the GPIB-PC that capability by calling
IBRSC or by using IBCONF to configure that capability
into the handler.
EABO (6)EABO indicates that I/O has been canceled, usually due to
a timeout condition. Other causes are IBSTOP being
called or the Device Clear message being received from
the CIC.
To remedy a timeout error, if I/O is actually progressing but
times out anyway, lengthen the timeout period with IBTMO.
More frequently, however, the I/O is stuck (the Listener is
not continuing to handshake or the Talker has stopped
talking), or the byte count in the call which timed out was
more than the other device was expecting. Be sure that
both parties to the transfer understand what byte count is
expected; or if possible, have the Talker use the END
message to assist in early termination.
ENEB (7)ENEB occurs when there is no GPIB-PC at the I/O address
specified in the configuration program. This happens when
the board is not physically plugged into the system, when
the I/O address specified during configuration does not
match the actual board setting, or when there is a conflict
in the system with the BASE I/O address. If there is a
mismatch between the actual board setting and the value
specified at configuration time, either reconfigure the
software or change the board switches to match the
configured value.
EOIP (10)EOIP occurs when asynchronous I/O has not completed
before some other call was made. During asynchronous
I/O, until the CMPL bit is set in IBSTA, only IBSTOP and
IBWAIT calls are allowed. EOIP is returned when any
other call is attempted before the I/O completes. The
remedy is to use IBWAIT to wait for the CMPL status and
then attempt the other call.
ECAP (11) ECAP results when a particular capability has been
disabled in the handler, and a call is made which attempts
to make use of that capability. For example, if you use
IBCONF to disable DMA for a board, and then try to call
IBDMA to turn DMA back on, you will get this error. The
remedy is not to deny capabilities which may be needed
later, and to avoid making calls which attempt to alter or
make use of capabilities that are unalterable at runtime.
EFSO (12) EFSO results when an IBRDF or IBWRTF call encounters a
problem performing a file operation. Specifically, this error
indicates the function was unable to open, create, seek,
write, or close the file being accessed. The specific DOS
error code for this condition is contained in IBCNT.
EBUS (14) EBUS results when certain GPIB bus errors occur during
device-level calls. It is necessary in all device calls for the
handler to send command bytes to perform addressing,
serial polls, and to send other bus management information.
Devices are expected to accept these command bytes
within the time limit specified by the configuration program
or by IBTMO. EBUS occurs if a timeout occurred during
the sending of these command bytes. Under normal
operating circumstances, the remedy would be to find out
which GPIB device is accepting commands abnormally
slowly and fix the problem with that device. In situations
in which slow handshaking of the commands is desirable,
lengthen the time limit either with the configuration
program or the IBTMO function.
ESTB (15) ESTB occurs only during the IBRSP call. This indicates
that one or more serial poll status bytes which were
received due to automatic serial polls have been discarded
for lack of room to store them. Several older status bytes
are available; however, the oldest is being returned by the
IBRSP call. If an occasional lost status byte is not
important in your application, you may consider this error
code informative only and ignore it. If your application
cannot tolerate missing even one status byte, the remedy is
to disable Automatic Serial Polling using IBCONF.
ESRQ (16) ESRQ occurs only during the IBWAIT call. This indicates
that a wait for RQS is not possible because the GPIB SRQ
line is stuck on. The usual reason for this situation is that
some device that the handler is unaware of is asserting
SRQ. Since the handler does not know of this device, it
will never be serially polled and SRQ will never go away.
Another reason for the situation would be that a GPIB bus
tester or similar equipment was forcing the SRQ line to be
asserted, or that there is a cable problem involving the
SRQ line. Although the occurrence of ESRQ signals a
definite GPIB problem, it will affect no GPIB operations
whatever except that the RQS bit cannot be depended on
while the condition lasts.
The IBCNT variable is updated after each read, write, or command
function call with the number of bytes actually transferred by the
operation.
Read and Write Termination
The IEEE-488 specification defines two methods of identifying the last
byte of device-dependent (data) messages. The two methods permit a
Talker to send data messages of any length without the Listener(s)
knowing in advance the number of bytes in the transmission. The two
methods are as follows:
•END message. In this method, the Talker asserts the EOI (End
Or Identify) signal simultaneously with transmission of the last
data byte. By design, the Listener stops reading when it detects
a data message accompanied by EOI, regardless of the value of
the byte.
•End-of-string (EOS) character. In this method, the Talker uses
a special character at the end of its data string. By prior
arrangement, the Listener stops receiving data when it detects
that character. Either a 7-bit ASCII character or a full 8-bit
binary byte may be used.
The methods can be used individually or in combination. However, it is
important that the Listener be properly configured to unambiguously
detect the end of a transmission.
The GPIB-PC always terminates IBRD operations on the END message.
Using the configuration program, you can accommodate all permissible
forms of read and write termination. The default configuration settings
for read and write termination can be changed at run time using the
IBEOS and IBEOT functions, if necessary.
Device functions are those functions in which the unit descriptor
identifies a device rather than an interface board. There are some
activities common to all device functions that should be understood
thoroughly.
In a single board configuration in which there is only one GPIB-PC in
use, when the first device function of the program is executed, the GPIB
is initialized by its controlling access board with the Interface Clear
(IFC) command. The Remote Enable (REN) line on that GPIB is also
asserted. If selected in the configuration program, the Local Lockout
(LLO) command is also sent to all devices on the GPIB to place them
in a lockout state. Furthermore, the device may be addressed to listen
and then unaddressed before certain functions are executed. This is to
ensure that the device is in remote program mode.
In a multiboard configuration in which there is more than one GPIB-PC,
the process is the same as previously described, with the exception that
each GPIB is initialized by its access board when the first device on
that GPIB is accessed by a device function call.
The previous descriptions assume that the GPIB-PC is the System
Controller of its GPIB, which is the usual configuration. If the GPIB-PC
is not the System Controller, it must be passed CIC authority from the
System Controller to execute device functions. If the access board is
not CIC when a device function is called, the board requests service
from the current CIC by asserting the Service Request (SRQ) line and
passing the status response byte hex 41 when serially polled by the CIC.
The handler then waits indefinitely for control to be passed to the access
board. The computer system hangs if there is not another CIC that will
pass control. This might happen, for example, if the access board is
supposed to be System Controller, but it was not configured as such
during software installation.
In Revision D software, if the access board is not CIC when the device
call is made, the ECIC error is returned.
Also in Revision D software, because of multitasking, board-level
reconfiguration functions must not be called during device-level calls.
If this feature is enabled, the handler automatically conducts serial polls
when SRQ is asserted. The handler polls all active devices and stores
each positive response, i.e., those responses that have the Request
Service (RQS) or hex 40 bit set in the device status byte, in a queue
associated with each device. Queues are necessary because some
devices can send multiple positive status bytes back-to-back. When a
positive response from a device is received, the RQS bit of its status
word (IBSTA) is set. The polling continues until SRQ is unasserted or
an error condition is undetected.
If the handler cannot locate the device requesting service (no known
device responds positively to the poll), or if SRQ becomes stuck on
(due to a faulty instrument or cable), then a GPIB system error exists
which will interfere with the proper evaluation of the RQS bit in the
device's status words. The error (ESRQ) will be reported to you if and
when you issue an IBWAIT call with the RQS bit included in the wait
mask. Should the error condition clear itself up, you will notice this by
calling IBWAIT with the RQS bit set in the mask, where the ESRQ
error will not be reported. Aside from the difficulty caused by this error
in waiting for RQS, the error will have no detrimental effects on other
GPIB operations.
If the serial poll function IBRSP is called and one or more responses
have been received previously via the automatic serial poll feature, then
the first queued response is returned by the IBRSP function in FIFO
(first in-first out) fashion. If the RQS bit of the status word is not set
when IBRSP is called, the function conducts a serial poll and returns
whatever response is received.
If your application requires that requests for service be noticed, you
should examine the RQS bit in the status word and call the IBRSP
function to examine the status byte whenever it appears. It is possible
for a device's serial poll response queue to get clogged with old status
bytes when you neglect to call IBRSP to empty the queue. This error
condition (ESTB) is returned only by IBRSP when it becomes
necessary to report that status bytes have been discarded due to a full
queue. If your application has no interest in SRQ or status bytes, you
may ignore the occurrence of the automatic polls. The polls occur
rarely, and the error conditions described will not occur unless you use
the feature.
If the handler is configured with automatic serial polling enabled, this
feature will be disabled after a board-level I/O function call, and
resumed after a device-level I/O function call. However, if any devicelevel I/O call results in a timeout error, this feature will be disabled
until the next I/O call completes.
NOTE: If the RQS bit of the device status word is still set after IBRSP
is called, the response byte queue has at least one more response byte
remaining. IBRSP should be called until RQS is cleared to gather all
stored response bytes and to guard against queue overflow.
Section Four A BASICA/QuickBASIC GPIB-PC
Function Calls
This section contains information for programming the GPIB-PC in
BASICA and QuickBASIC, Versions 4.0 and earlier. The term
BASICA, as used in this section, refers to Advanced IBM Interpretive
BASIC for the IBM Personal Computer. The term QuickBASIC refers
to Microsoft QuickBASIC.
The programming information in this supplement can be used with all
versions of BASICA and QuickBASIC unless specified otherwise.
When different programming information is required that is specific to a
particular version, this information is separated and identified by a
frame with the respective version number in the upper left corner. An
example of this appears as follows:
If information is required that is specific to two versions, this
information is separated and identified by a frame with the two version
numbers in the upper left corner. An example of this appears as follows:
BASICA/QuickBASIC GPIB-PC Function CallsSection Four A
If information is required that is specific to three versions, this
information is separated and identified by a frame with the three version
numbers in the upper left corner. An example of this appears as follows:
Information that is not located in a frame can be used to program the
GPIB-PC in all versions of BASICA and QuickBASIC (that is, Version
4.0 and earlier).
BASICA Files
The GPIB-PC distribution diskette contains four files relevant to
programming in BASICA:
•DECL.BAS - A file containing required initialization code.
•BIB.M - The BASICA language interface which gives your
application program access to the handler.
•DBSAMP.BAS - A sample program using device calls.
•BBSAMP.BAS - A sample program using board calls.
QuickBASIC Files
The GPIB-PC distribution diskette contains four files relevant to
programming in QuickBASIC. These files were copied to a subdirectory
called GPIB-PC when you ran the installation program IBSTART.BAT.
•QBDECL.BAS - A file containing required initialization code.
Section Four ABASICA/QuickBASIC GPIB-PC Function Calls
•QBIB2.OBJ - Version 2.0 and 3.0 without coprocessor.
•QBIB_87.OBJ - Version 3.0 with coprocessor.
•QBIB_87E.OBJ - Version 3.0 coprocessor emulator mode.
•QBIB4.OBJ - Version 4.0 language interface..
•QBDECL4.BAS - Version 4.0 required initialization code..
The appropriate language interface depends on the version of
QuickBASIC used:
•DQBSAMP.BAS - A sample program using device calls.
•BQBSAMP.BAS - A sample program using board calls.
Programming Preparations for BASICA
A BASICA language code block must be executed before the main body
of your application program.
Place the file DECL.BAS, which contains this code block, at the
beginning of the application program, with appropriate adjustments to
line numbers. Refer to the BASICA MERGE command. DECL.BAS
contains code which loads the file BIB.M into memory. The file
BIB.M contains the BASICA language interface to the GPIB-PC
handler, and must exist in the directory currently in use.
BASICA/QuickBASIC GPIB-PC Function CallsSection Four A
You may change function and variable names defined in the code block
if they conflict with names the application program is using. The
substitution must be done consistently and carefully throughout.
Instructions provided in this section assume that no name substitution is
necessary and that the recommended names are used.
The GPIB status, error, and count information is returned in the
variables IBSTA%, IBERR%, and IBCNT% as described at the beginning
of Section Four.
In accordance with BASICA language protocol, all function arguments
are variables, either integer or string, and their values must be assigned
before the function call is made.
The CLEAR statement in line 1 of DECL.BAS contains a constant which
is used to determine the memory requirements of the BASICA language
interface. For the great majority of users this constant is correct. The
constant may be incorrect, however, if you are using a system with an
extremely small amount of memory. If after BASICA is invoked it
reports that there are fewer than 60000 bytes free, you may need to
adjust the constant to a smaller value.
Programming Preparations for QuickBASIC
Include the following QuickBASIC statement at the beginning of your
application program:
COMMON SHARED IBSTA%, IBERR%, IBCNT%
This statement is included in the file QBDECL.BAS on the distribution
diskette.
The GPIB status, error, and count information is returned in the
variables IBSTA%, IBERR%, and IBCNT% as described at the beginning
of Section Four.
The file QBIB*.OBJ contains the QuickBASIC language interface to
the GPIB-PC handler. Link compiled GPIB application programs
written in QuickBASIC with QBIB*.OBJ to produce an executable file
permitting access to the handler.
In accordance with QuickBASIC language protocol, all function
arguments are variables, either integer or string, and their values must
be assigned before the function call is made.
Section Four ABASICA/QuickBASIC GPIB-PC Function Calls
To run your program from within the QuickBASIC editor use the
QuickBASIC BUILDLIB command to add QBIB*.OBJ to your user
library, and load that library when loading QuickBASIC. For example,
if you are already using a library called USERLIB.EXE, add
QBIB2.OBJ to it by entering:
BUILDLIB USERLIB.OBJ QBIB2.OBJ;
Then to run QuickBASIC enter:
QB /L USERLIB.EXE
To run your program from within the QuickBASIC interactive
environment, use the LINK command to create a QuickLibrary. For
example, to create a QuickLibrary called QBIB4.QLB, enter:
LINK /Q QBIB4.OBJ,,,BQLB40.LIB;
Then to run QuickBASIC enter:
QB /L QBIB4.QLB
To run your program from MS DOS, follow the instructions in the
QuickBASIC User's Manual which pertain to compiling and linking
programs. Use the file QBIB4.OBJ for linking purposes.
BASICA/QuickBASIC GPIB-PC I/O Functions
The most commonly needed I/O functions are IBRD and IBWRT. In
BASICA, these functions read and write from a character string that
may be up to 255 bytes long.
In addition, integer I/O functions (IBRDI and IBWRTI) are provided for
users whose data strings are longer than 255 bytes, or who need to
BASICA/QuickBASIC GPIB-PC Function CallsSection Four A
perform arithmetic operations on the data and want to avoid the
overhead of converting the character bytes of IBRD and IBWRT into
integer format and back again.
IBRDI and IBWRTI are passed data in the form of an integer array,
instead of a character string whose maximum length is limited to 255
bytes. Using these functions, you may store more than 255 bytes in a
single buffer and do not have to convert each pair of data bytes to an
integer before doing arithmetic operations on the data. Internally, the
IBWRTI function sends each integer to the GPIB in low-byte, high-byte
order. The IBRDI function reads a series of data bytes from the GPIB
and stores them into the integer array in low-byte, high-byte order.
In addition to IBRDI and IBWRTI, the asynchronous functions IBRDIA
and IBWRTIA are provided to perform asynchronous integer reads and
writes.
The functions are listed alphabetically by function name in this section.
Table 4A.1 provides a summary of the BASICA GPIB-PC functions and
Table 4A.2 provides a summary of the QuickBASIC GPIB-PC functions.
BASICA/QuickBASIC "ON SRQ" Capability
BASICA programs may be interrupted on the occurrence of the GPIB
SRQ signal. When the interrupt occurs, a branch can be taken to a
service routine which determines the cause of the SRQ and takes the
appropriate action.
National Instruments uses this statement to intercept SRQ interrupt and
make them available to user programs. For more complete information
regarding the operation of "ON PEN", refer to the IBM BASICA User's
Manual and Microsoft QuickBASIC under the "ON PEN Statement."
All the information in that section applies to both the light pen and to
the GPIB SRQ signal.
Statements such as "ON PEN" which intercept interrupts are a special
feature of some versions of BASIC, including BASICA and
QuickBASIC. These statements, however, are not usually a feature of
non-BASIC languages and are not necessarily supported in other
National Instruments language interfaces. To determine if this feature is
supported in languages other than BASICA and QuickBASIC, refer to
the manual supplement that comes with that language.
Section Four ABASICA/QuickBASIC GPIB-PC Function Calls
Table 4A.1 - BASICA GPIB-PC Functions
DescriptionCALL Function Syntax
Change access board of deviceIBBNA (BD%,BNAME$)
Become Active ControllerIBCAC (BD%,V%)
Clear specified deviceIBCLR (BD%)
Send commands from stringIBCMD (BD%,CMD$)
Send commands asynchronously from
stringIBCMDA (BD%,CMD$)
Enable/disable DMAIBDMA (BD%,V%)
Change/disable EOS modeIBEOS (BD%,V%)
Enable/disable END messageIBEOT (BD%,V%)
Open device and return unit descriptor IBFIND (BDNAME$,BD%)
Go from Active Controller to standbyIBGTS (BD%,V%)
Set/clear istIBIST (BD%,V%)
Go to localIBLOC (BD%)
Place device online/offlineIBONL (BD%,V%)
Change primary addressIBPAD (BD%,V%)
Pass controlIBPCT (BD%)
Parallel poll configureIBPPC (BD%,V%)
Read data to stringIBRD (BD%,RD$)
Read data asynchronously to stringIBRDA (BD%,RD$)
Read data to fileIBRDF (BD%,FLNAME$)
Read data to integer arrayIBRDI
(BD%,IARR%(0),CNT%)
Read data asynch to integer array IBRDIA
(BD%,IARR%(0),CNT%)
Conduct a parallel pollIBRPP (BD%,PPR%)
Request/release system control IBRSC (BD%,V%)
Return serial poll byteIBRSP (BD%,SPR%)
Request serviceIBRSV (BD%,V%)
Change secondary addressIBSAD (BD%,V%)
Send interface clearIBSIC (BD%)
Set/clear remote enable lineIBSRE (BD%,V%)
Abort asynchronous operation IBSTOP (BD%)
Change/disable time limitIBTMO (BD%,V%)
Configure applications monitorIBTRAP (MASK%,V%)
Trigger selected deviceIBTRG (BD%)
BASICA/QuickBASIC GPIB-PC Function CallsSection Four A
Table 4A.1 - BASICA GPIB-PC Functions (continued)
DescriptionCALL Function Syntax
Wait for selected eventIBWAIT (BD%,MASK%)
Write data from stringIBWRT (BD%,WRT$)
Write data asynchronously from string IBWRTA (BD%,WRT$)
Write data from fileIBWRTF (BD%,FLNAME$)
Write data from integer arrayIBWRTI
(BD%,IARR%(0),CNT%)
Write data asynch from integer arrayIBWRTIA
(BD%,IARR%(0),CNT%)
The first argument of all function calls except IBFIND is the integer
variable BD%, which serves as a unit descriptor. Refer to the IBFIND
function description and Section Three for additional information on the
use of this unit descriptor.
Table 4A.2 contains a complete list of the QuickBASIC GPIB calls,
their parameters, and a short description of each.
Table 4A.2 - QuickBASIC GPIB-PC Calls
DescriptionCALL Function Syntax
Change access board of deviceIBBNA (BD%,BNAME$)
Become Active ControllerIBCAC (BD%,V%)
Clear specified deviceIBCLR (BD%)
Send commands from stringIBCMD (BD%,CMD$)
Send commands asynchronously from
stringIBCMDA (BD%,CMD$)
Enable/disable DMAIBDMA (BD%,V%)
Change/disable EOS modeIBEOS (BD%,V%)
Enable/disable END messageIBEOT (BD%,V%)
Open device and return unit descriptor IBFIND (BDNAME$,BD%)
Go from Active Controller to standbyIBGTS (BD%,V%)
Set/clear istIBIST (BD%,V%)
Go to localIBLOC (BD%)
Place device online/offlineIBONL (BD%,V%)
Change primary addressIBPAD (BD%,V%)
Section Four ABASICA/QuickBASIC GPIB-PC Function Calls
Table 4A.2 - QuickBASIC GPIB-PC Calls (cont.)
DescriptionCALL Function Syntax
Pass controlIBPCT (BD%)
Parallel poll configureIBPPC (BD%,V%)
Read data to stringIBRD (BD%,RD$)
Read data asynchronously to stringIBRDA (BD%,RD$)
Read data to fileIBRDF (BD%,FLNAME$)
Read data to integer arrayIBRDI (BD%,VARPTR
(IARR%(0)),CNT%)
Read data asynch to integer array IBRDIA (BD%,VARPTR
(IARR%(0)),CNT%
Conduct a parallel pollIBRPP (BD%,PPR%)
Request/release system control IBRSC (BD%,V%)
Return serial poll byteIBRSP (BD%,SPR%)
Request serviceIBRSV (BD%,V%)
Change secondary addressIBSAD (BD%,V%)
Send interface clearIBSIC (BD%)
Set/clear remote enable lineIBSRE (BD%,V%)
Abort asynchronous operation IBSTOP (BD%)
Change/disable time limitIBTMO (BD%,V%)
Configure applications monitorIBTRAP (MASK%,V%)
Trigger selected deviceIBTRG (BD%)
Wait for selected eventIBWAIT (BD%,MASK%)
Write data from stringIBWRT (BD%,WRT$)
Write data asynchronously from string IBWRTA (BD%,WRT$)
Write data from fileIBWRTF (BD%,FLNAME$)
Write data from integer arrayIBWRTI (BD%,VARPTR
(IARR%(0)),CNT%
Write data asynch from integer arrayIBWRTIA (BD%,VARPTR
BASICA/QuickBASIC GPIB-PC Function CallsSection Four A
Table 4A.3 - QuickBASIC GPIB-PC Calls
DescriptionCALL Function Syntax
Change access board of deviceIBBNA (BD%,BNAME$)
Become Active ControllerIBCAC (BD%,V%)
Clear specified deviceIBCLR (BD%)
Send commands from stringIBCMD (BD%,CMD$)
Send commands asynchronously from
stringIBCMDA (BD%,CMD$)
Enable/disable DMAIBDMA (BD%,V%)
Change/disable EOS modeIBEOS (BD%,V%)
Enable/disable END messageIBEOT (BD%,V%)
Open device and return unit descriptor IBFIND (BDNAME$,BD%)
Go from Active Controller to Standby IBGTS (BD%,V%)
Set/clear istIBIST (BD%,V%)
Go to localIBLOC (BD%)
Place device online/offlineIBONL (BD%,V%)
Change primary addressIBPAD (BD%,V%)
Pass controlIBPCT (BD%)
Parallel poll configureIBPPC (BD%,V%)
Read data to stringIBRD (BD%,RD$)
Read data asynchronously to stringIBRDA (BD%,RD$)
Read data to fileIBRDF (BD%,FLNAME$)
Read data to integer arrayIBRDI
(BD%,IARR%(),CNT%)
Read data asynch to integer array IBRDIA
(BD%,IARR%(),CNT%
Conduct a parallel pollIBRPP (BD%,PPR%)
Request/release system control IBRSC (BD%,V%)
Return serial poll byteIBRSP (BD%,SPR%)
Request serviceIBRSV (BD%,V%)
Change secondary addressIBSAD (BD%,V%)
Send interface clearIBSIC (BD%)
Set/clear remote enable lineIBSRE (BD%,V%)
Abort asynchronous operation IBSTOP (BD%)
Section Four ABASICA/QuickBASIC GPIB-PC Function Calls
Table 4A.3 - QuickBASIC GPIB-PC Calls (continued)
DescriptionCALL Function Syntax
Change/disable time limitIBTMO (BD%,V%)
Configure applications monitorIBTRAP (MASK%,V%)
Trigger selected deviceIBTRG (BD%)
Wait for selected eventIBWAIT (BD%,MASK%)
Write data from stringIBWRT (BD%,WRT$)
Write data asynchronously from string IBWRTA (BD%,WRT$)
Write data from fileIBWRTF (BD%,FLNAME$)
Write data from integer arrayIBWRTI
BASICA/QuickBASIC GPIB-PC Function CallsSection Four A
New GPIB-PC Functions
Since QuickBASIC Version 4.0 now supports true functions, the
language interface has been expanded to include function versions of
the existing GPIB calls. Here are some important points to be aware of:
•All existing subroutines are still available via the CALL
statement, and existing applications do not require any
changes.
•The names of the new functions are identical to the existing
subroutines, except that the second letter of each name has
been changed from B to L. For example, the subroutine IBSIC
is now also available as the function ILSIC.
•GPIB subroutine and function calls may be freely mixed
throughout a program.
•The include file QBDECL4.BAS contains a complete list of
both subroutine and function declarations, complete with
parameter list specifications to aid in type checking at compile
time. You must include this file in all application programs
using GPIB calls.
•In general, the functions behave identically to the subroutines
with the few exceptions noted in the following paragraph. The
description of each subroutine found in the GPIB-PC User Manual can be applied to the new functions, except for the
syntax-specific information.
BASICA/QuickBASIC GPIB-PC Function CallsSection Four A
Table 4A.4 - QuickBASIC Version 4.0 GPIB-PC Functions
DescriptionFunction Syntax
Change access board of deviceILBNA (BD%,BNAME$)
Become Active ControllerILCAC (BD%,V%)
Clear specified deviceILCLR (BD%)
Send commands from stringILCMD (BD%,CMD$,CNT%)
Send commands asynchronously from
stringILCMDA (BD%,CMD$,CNT%)
Enable/disable DMAILDMA (BD%,V%)
Change/disable EOS modeILEOS (BD%,V%)
Enable/disable END messageILEOT (BD%,V%)
Open device and return unit descriptor ILFIND (BDNAME$,BD%)
Go from Active Controller to standbyILGTS (BD%,V%)
Set/clear istILIST (BD%,V%)
Go to localILLOC (BD%)
Place device online/offlineILONL (BD%,V%)
Change primary addressILPAD (BD%,V%)
Pass controlILPCT (BD%)
Parallel poll configureILPPC (BD%,V%)
Read data to stringILRD (BD%,RD$,CNT%)
Read data asynchronously to stringILRDA (BD%,RD$,CNT%)
Read data to fileILRDF (BD%,FLNAME$)
Read data to integer arrayILRDI
(BD%,IARR%(),CNT%)
Read data asynch to integer array ILRDIA
(BD%,IARR%(),CNT%)
Conduct a parallel pollILRPP (BD%,PPR%)
Request/release system control ILRSC (BD%,V%)
Return serial poll byteILRSP (BD%,SPR%)
Request serviceILRSV (BD%,V%)
Change secondary addressILSAD (BD%,V%)
Send interface clearILSIC (BD%)
Set/clear remote enable lineILSRE (BD%,V%)
Abort asynchronous operation ILSTOP (BD%)
Change/disable time limitILTMO (BD%,V%)
Trigger selected deviceILTRG (BD%)
Section Four ABASICA/QuickBASIC GPIB-PC Function Calls
Table 4A.4 - QuickBASIC Version 4.0 GPIB-PC Functions
(continued)
DescriptionFunction Syntax
Configure applications monitorILTRAP (MASK%,V%)
Wait for selected eventILWAIT (BD%,MASK%)
Write data from stringILWRT (BD%,WRT$,CNT%)
Write data asynchronously from string ILWRTA (BD%,WRT$,CNT%)
Write data from fileILWRTF (BD%,FLNAME$)
Write data from integer arrayILWRTI
(BD%,IARR%(),CNT%)
Write data asynch from integer arrayILWRTIA
(BD%,IARR%(),CNT%)
GPIB-PC Function Descriptions
The remainder of this section provides a detailed description of each
GPIB-PC function.
BASICA/QuickBASIC GPIB-PC Function CallsSection Four A
BASICA/QuickBASICBASICA/QuickBASIC
IBBNAIBBNA
Purpose:Change access board of device
Format:CALL IBBNA (BD%,BNAME$)
Remarks:BD% specifies a device. BNAME$ specifies the new access
board to be used in all device calls to that device. IBBNA
is needed only to alter the board assignment from its
configuration setting.
The IBBNA function identifies the board that will be used
in subsequent device functions to access the specified
device. IBBNA permits you to alter the association of
devices and interface boards from the settings originally
configured with the configuration program.
The assignment made by this function remains in effect
until IBBNA is called again, the IBONL or IBFIND
function is called, or the system is rebooted. The original
configuration established with the configuration program is
not permanently changed.
Refer also to Table 2.1.
Device Example:
1.Associate the device DVM% with the interface board "GPIB0".
100 REM DVM is a name assigned using
110 REM IBCONF.
120 REM (GPIB0 is a factory default board
130 REM name which cannot be changed).
140 BDNAME$ = "DVM"
150 CALL IBFIND (BDNAME$,DVM%)
160 REM This call to IBBNA establishes
170 REM GPIB0 as the access board for the
180 REM device DVM%.
190 BNAME$ = "GPIB0"
200 CALL IBBNA (DVM%,BNAME$)
Section Four ABASICA/QuickBASIC GPIB-PC Function Calls
BASICA/QuickBASICBASICA/QuickBASIC
IBCACIBCAC
Purpose:Become Active Controller
Format:CALL IBCAC (BD%,V%)
Remarks:BD% specifies an interface board. If V% is non-zero, the
GPIB-PC takes control synchronously with respect to data
transfer operations; otherwise, the GPIB-PC takes control
immediately (and possibly asynchronously).
To take control synchronously, the GPIB-PC asserts the
ATN signal in such a way as to ensure that data being
transferred on the GPIB is not corrupted. If a data
handshake is in progress, the take control action is
postponed until the handshake is complete; if a handshake
is not in progress, the take control action is done
immediately. Synchronous take control is not guaranteed if
an IBRD or IBWRT operation completed with a timeout or
error.
Asynchronous take control should be used in situations
where it appears to be impossible to gain control
synchronously (e.g., after a timeout error).
It is generally not necessary to use the IBCAC function in
most applications. Functions such as IBCMD and IBRPP,
which require that the GPIB-PC take control, do so
automatically.
The ECIC error results if the GPIB-PC is not CIC.
Board Examples:
1.Take control immediately without regard to any data handshake
in progress.
100 V% = 0
110 CALL IBCAC (BRD0%,V%)
120 REM IBSTA% should show that the
130 REM interface board is now CAC, i.e.,
140 REM CIC with ATN asserted.
BASICA/QuickBASIC GPIB-PC Function CallsSection Four A
BASICA/QuickBASICBASICA/QuickBASIC
IBCMDIBCMD
Purpose:Send commands from string
Format:CALL IBCMD (BD%,CMD$)
Remarks:BD% specifies an interface board. CMD$ contains the
commands to be sent over the GPIB.
The IBCMD function is used to transmit interface messages
(commands) over the GPIB. These commands, which are
listed in Appendix A, include device talk and listen
addresses, secondary addresses, serial and parallel poll
configuration messages, and device clear and trigger
instructions. The IBCMD function is also used to pass GPIB
control to another device. This function is NOT used to
transmit programming instructions to devices.
Programming instructions and other device-dependent
information are transmitted with the read and write
functions.
The IBCMD operation terminates on any of the following
events:
•All commands are successfully transferred;
•Error is detected;
•Time limit is exceeded;
•Take Control (TCT) command is sent; or
•Interface Clear (IFC) message is received from the
System Controller (not the GPIB-PC).
After termination, the IBCNT% variable contains the
number of commands sent. A short count can occur on any
event but the first.
An ECIC error results if the GPIB-PC is not CIC. If it is not
Active Controller, it takes control and asserts ATN prior to
sending the command bytes. It remains Active Controller
afterward.
Section Four ABASICA/QuickBASIC GPIB-PC Function Calls
In the examples that follow, GPIB commands and
addresses are coded as printable ASCII characters. When
the values to be sent over the GPIB correspond to printable
ASCII characters, this is the simplest means of specifying
the values. Refer to Appendix A for conversions of numeric
values to ASCII characters.
Board Examples:
1.Unaddress all Listeners with the Unlisten (UNL or ASCII ?)
command and address a Talker at &H46 (ASCII F) and a
Listener at &H31 (ASCII 1).
4.Clear two devices with listen addresses of &H21 (ASCII !) and
&H28 (ASCII ( (left parenthesis)) with the Selected Device
Clear (SDC or &H04) command.
BASICA/QuickBASIC GPIB-PC Function CallsSection Four A
6.Unaddress all Listeners and serially poll a device at talk
address &H52 (ASCII R) using the Serial Poll Enable (SPE or
&H18) and Serial Poll Disable (SPD or &H19) commands (the
GPIB-PC listen address is &H20 or ASCII space).
100 CMD$ ="?R " + CHR$(&H18)'UNL TAD MLA SPE
110 CALL IBCMD (BRD0%,CMD$)
120 RD$ = SPACE$(1)' Declare RD buffer.
130 CALL IBRD (BRD0%,RD$)
140 REM After checking the status byte in
150 REM RD$, disable this device and
160 REM unaddress it with the Untalk.
160 REM (UNT or ASCII _) command before
170 REM polling the next one.
180 CMD$ = CHR$(&H19) + "_"' SPD UNT
190 CALL IBCMD (BRD0%,CMD$)
Section Four ABASICA/QuickBASIC GPIB-PC Function Calls
BASICA/QuickBASICBASICA/QuickBASIC
IBCMDAIBCMDA
Purpose:Send commands asynchronously from string
Format:CALL IBCMDA (BD%,CMD$)
Remarks:BD% specifies an interface board. CMD$ contains the
commands to be sent over the GPIB.
The IBCMDA function is used to transmit interface
messages (commands) over the GPIB. These commands,
which are listed in Appendix A, include device talk and
listen addresses, secondary addresses, serial and parallel
poll configuration messages, and device clear and trigger
instructions. The IBCMDA function is also used to pass
GPIB control to another device. This function is NOT used
to transmit programming instructions to devices.
Programming instructions and other device-dependent
information are transmitted with the write and read
functions.
IBCMDA is used in place of IBCMD when the application
program must perform other functions while processing the
GPIB I/O operation. IBCMDA returns after starting the I/O
operation. If the number of bytes to send is small and the
bytes are accepted quickly by the GPIB device(s), the
operation may complete on the initial call. In this case,
the CMPL bit will be set in IBSTA%. If the operation does
not complete on the initial call, you should monitor the
IBSTA% variable after subsequent calls (usually IBWAIT
calls) to know that the I/O is completed. When CMPL
becomes set in IBSTA%, indicating that the I/O is
complete, the number of bytes sent is reported in the
IBCNT% variable.
Between the issuing of the IBCMDA call and the
corresponding CMPL, other GPIB function calls to this
board will return the error EOIP, with the following
exceptions:
BASICA/QuickBASIC GPIB-PC Function CallsSection Four A
•IBONL-to cancel the I/O and reset the interface.
The asynchronous I/O started by IBCMDA terminates for the
same reasons IBCMD terminates.
An ECIC error results if the GPIB-PC is not CIC. If it is not
Active Controller, the GPIB-PC takes control and asserts
ATN prior to sending the command bytes. It remains
Active Controller afterward. The ENOL error does NOT
occur if there are no Listeners.
Board Example:
1.Address several devices for a broadcast message to follow
while testing for a high priority event to occur.
100 REM The interface board BRD0% at talk
110 REM address &H40 (ASCII @), addresses
120 REM nine Listeners at addresses &H31130 REM &H39 (ASCII 1-9) to receive the
140 REM broadcast message.
150 CMD$ = "?@123456789" ' UNL MTA
160' LAD1...LAD9
170 CALL IBCMDA (BRD0%,CMD$)
180 MASK% = $4100' Wait for timeout or
190' I/O completion.
200 CALL EVENTTST' Unspecified routine
210' to test and process
220' a high priority
230' event.
240 CALL IBWAIT (BRD0%,MASK%)
250 REM Loop until complete while no error
260 REM has occurred.
270 IF (IBSTA% AND &H100) = 0 GOTO 180
Section Four ABASICA/QuickBASIC GPIB-PC Function Calls
BASICA/QuickBASICBASICA/QuickBASIC
IBDMAIBDMA
Purpose:Enable or disable DMA
Format:CALL IBDMA (BD%,V%)
Remarks:BD% specifies an interface board. If V% is non-zero, DMA
transfers between the GPIB-PC and memory are used for
read and write operations. If V% is zero, programmed I/O is
used in place of DMA I/O.
If you enabled DMA at configuration time, assigning DMA
channel 1, 2, or 3, this function can be used to switch
between programmed I/O and DMA using the selected
channel. If you disabled DMA at configuration time,
calling this function with V% equal to a non-zero value
results in an ECAP error.
The assignment made by this function remains in effect
until IBDMA is called again, the IBONL or IBFIND
function is called, or the system is rebooted.
When IBDMA is called and an error does not occur, the
previous value of V% is stored in IBERR%.
On machines without DMA capability, calling this function
with V% = 0 has no effect, and calling it with a non-zero V%
results in an ECAP error.
Refer also to Table 2.1.
Board Examples:
1.Enable DMA transfers using the previously configured channel.
100 V% = 1 ' Any non-zero value will do.
110 CALL IBDMA (BRD0%,V%)
2.Disable DMAs and use programmed I/O exclusively.