Index ...................................................................................................... 419
5
6
Notice
The information contained in this document is subject to change without
notice.
Agilent Technologies shall not be liable for any errors contained in this
document.
regard to this document, whether express or implied. Agilent Technologies
specifically disclaims the implied warranties of merchantability and fitness
for a particular purpose.
direct, indirect, special, incidental, or consequential damages, whether
based on contract, tort, or any other legal theory, in connection with the
furnishing of this document or the use of the information in this document.
Agilent Technologies makes no warranties of any kind with
Agilent Technologies shall not be liable for any
Warranty Information
A copy of the specific warranty terms applicable to your Agilent T echnologies
product and replacement parts can be obtained from Agilent Technologies,
Inc.
U.S. Government Restricted Rights
The Software and Documentation have been developed entirely at private
expense. They are delivered and licensed as "commercial computer
software" as defined in DFARS 252.227- 7013 (Oct 1988), DFARS 252.2117015 (May 1991) or DFARS 252.227-7014 (Jun 1995), as a "commercial
item" as defined in FAR 2.101(a), or as "Restricted computer software" as
defined in FAR 52.227-19 (Jun 1987)(or any equivalent agency regulation or
contract clause), whichever is applicable. You have only those rights
provided for such Software and Documentation by the applicable FAR or
DFARS clause or the Agilent standard software agreement for the product
involved.
7
Trademark Information
Microsoft®, Windows ® 95, Windows ® 98, Windows ® 2000, and
Windows NT® are U.S. registered trademarks of Microsoft Corporation.
All other brand and product names are trademarks or registered trademarks
of their respective companies.
Printing History
Edition 1 - April 1994
Edition 2 - September 1995
Edition 3 - May 1996
Edition 4 - October 1996
Edition 5 - July 2000
Copyright Information
Agilent Technologies Standard Instrument Control Library
Agilent Standard Instrument Control Libraries (SICL) User’s Guide
for Windows
applications on Microsoft Windows 95, Windows 98, Windows NT 4.0,
and Windows 2000. A getting started chapter is provided to help you write
and run your first SICL program. Then, this guide explains how to build and
program SICL applications. Later chapters are interface-specific, describing
how to use SICL with GPIB, GPIO, VXI, RS-232, and LAN interfaces.
NOTE
Before you can use SICL, you must install and configure SICL on your
computer. See the
Guide for Windows
otherwise indicated, Windows NT refers to Windows NT 4.0.
If You Need Help:
n In the USA and Canada, you can reach Agilent Technologies at
describes Agilent SICL and how to use it to develop I/O
Agilent IO Libraries Installation and Configuration
for installation on Windows systems. Unless
these telephone numbers:
USA: 1-800-452-4844
Canada: 1-877-894-4414
n Outside the USA and Canada, contact your country’s Agilent support
organization. A list of contact information for other countries is
available on the Agilent web site:
http://www.agilent.com/find/assist
10Chapter 1
Introduction
What’s in This Guide?
What’s in This Guide?
This chapter provides an overview of SICL. In addition, this guide contains
the following chapters:
n
Chapter 2 - Getting Started with SICL
an example program in C/C++ and Visual BASIC.
n
Chapter 3 - Programming with SICL
application in a Windows environment and provides information on
communications sessions, addressing, error handling, locking, etc..
n
Chapter 4 - Using SICL with GPIB
the GPIB interface.
n
Chapter 5 - Using SICL with GPIO
the GPIO interface.
n
Chapter 6 - Using SICL with VXI
the VXIbus interface.
shows how to build and run
shows how to build a SICL
shows how to communicate over
shows how to communicate over
shows how to communicate over
n
Chapter 7 - Using SICL with RS-232
over the RS-232 interface.
n
Chapter 8 - Using SICL with LAN
a Local Area Network (LAN).
n
Chapter 9 - Troubleshooting SICL Programs
common SICL programming problems and provides troubleshooting
procedures.
n
Chapter 10 - More SICL Example Programs
example programs to help you develop SICL applications.
n
Chapter 11 - SICL Language Reference
and description for each SICL function.
n
Appendix A - SICL System Information
SICL software files and system interaction.
Chapter 111
shows how to communicate
shows how to communicate over
describes some
contains additional
provides function syntax
provides information on
Introduction
What’s in This Guide?
n
Appendix B - Porting to Visual Basic
applications from earlier versions of Visual Basic (such as version
3.0) to Visual Basic version 4.0 and above.
n
Appendix C - SICL Error Codes
error strings along with a brief description of each error.
n
Appendix D - SICL Function Summary
features for each SICL function.
n
Appendix E - RS-232 Cables
diagrams for several RS-232 cables.
n
Glossary
includes major terms and definitions used in this guide.
explains how to move SICL
provides a list of error codes and
summarizes supported
lists part numbers and shows wiring
12 Chapter 1
Introduction
SICL Overview
SICL Overview
SICL is part of the Agilent IO Libraries. The Agilent IO Libraries consists of
two libraries:
Agilent Standard Instrument Control Library (SICL).
Introducing VISA and SICL
n Agilent Virtual Instrument Software Architecture (VISA) is an I/O
library designed according to the VXI
allows software developed from different vendors to run on the same
system.
plug&play
System Allian c e t h at
and
n Use VISA if y ou wa nt t o use VXI
applications, or if you want the I/O applications or instrument drivers
that you develop to be compliant with VXI
are using new instruments or are developing new I/O applications or
instrument drivers, we recommend you use Agilent VISA.
plug&play
instrument drivers in your
plug&play
standards. If you
n Agilent Standard Instrument Control Library (SICL) is an I/O library
developed by Hewlett-Packard and Agilent that is portable across
many I/O interfaces and systems.
n You can use Agilent SICL if you have been using SICL and want to
remain compatible with software currently implemented in SICL.
NOTE
Since VISA and SICL are different libraries, using VISA functions and
SICL functions in the same I/O application is not supported.
SICL Description
Agilent Standard Instrument Control Library (SICL) is an I/O library
developed by Hewlett-Packard and Agilent that is portable across many
I/O interfaces and systems. SICL is a modular instrument communications
library that works with a variety of computer architectures, I/O interfaces,
and operating systems. Applications written in C/C++ or Visual BASIC using
this library can be ported at the source code level from one system to
another with no (or very few) changes.
Chapter 113
Introduction
SICL Overview
SICL uses standard, commonly used functions to communicate over a wide
variety of interfaces. For example, a program written to communicate with a
particular instrument on a given interface can also communicate with an
equivalent instrument on a different type of interfac e.
6,&/6XSSRUWThe 32-bit version of SICL is supported on this version of the Agilent IO
Libraries for Windows 95, Windows 98, Wi ndo ws NT, and Windows 2000.
Support for the 16-bit version of SICL was removed in version H.01.00.
However, versions through G.02.02 support 16-bit SICL. C, C++, and Visual
BASIC are supported on all these Windows versions. SICL is supported on
the GPIB, GPIO, VXI, RS-232, and LAN interfaces.
6,&/8VHUVSICL is intended for instrument I/O and C/C++ or Visual BASIC
programmers who are familiar with Windows 95, Windows 98, Windows
2000, or Windows NT. To perform SICL installation and configuration on
Windows NT, you must have system administrator privileges on the
Windows NT system.
6,&/
'RFXPHQWDWLRQ
This table shows associated documentation you can use when programming
with Agilent SICL.
DocumentDescription
Agilent SICL User’s Guide for
Windows
SICL Online Help
SICL Example Programs
VXIbus Consortium specifications
(when using VISA over LAN)
Agilent SICL Documentation
Shows how to use Agilent SICL and provides the SICL
language reference.
Information is provided in the form of Windows Help.
Example programs are provided online to help you develop
SICL applications. SICL ex ample programs are provided in the
C\SAMPLES (for C/C++) subdirectory and in the VB\SAMPLES
subdirectory (for Visual BASIC) under the base directory where
SICL is installed. For example, under the C:\SICL95 or
C:\SICLNT base directory if the default installation directory was
used.
This chapter gives guidelines to help you to get started programming with
SICL using the C/C++ language. This chapter provides example programs in
C/C++ and in Visual Basic to help you verify your configuration and
introduce you to some of SICL’s basic features. The chapter contents are:
n Getting Started Using C
n Getting Started Using Visual Basic
NOTE
This chapter is divided into two sections: the first section is for C
programmers and the second section is for Visual BASIC programmers.
See “Getting Started Using C” if you want to use SICL with the
C/C++ programming language. See “Getting Started Using Visual Basic”
if you want to use SICL with the Visual BASIC programming language.
You may want to see
familiarize yourself with SICL functions. This reference information is also
available as online help. To see the reference information online, doubleclick the Help icon in the
16Chapter 2
Chapter 11 - SICL Language Reference
Agilent IO Libraries program group.
to
Getting Started with SICL
Getting Started Using C
Getting Started Using C
This section describes an example program called IDN that queries a
GPIB instrument for its identification string. This example builds a console
application for WIN32 programs (32-bit SICL programs on Windows 95,
Windows 98, Windows 2000, or Windows NT) using the C programming
language.
C Program Example Code
All files used to develop SICL applications in C or C++ are located in the
C subdirectory of the base IO Libraries directory. Sample C/C++
programs are located in the C\SAMPLES subdirectory of the base IO
Libraries directory.
Each sample program subdirectory contains makefiles or project files that
you can use to build each sample C program. You must first compile the
sample C/C++ programs before you can execute them.
The IDN example files are located in the C\SAMPLES\IDN subdirectory
under the base IO Libraries directory. This subdirectory contains the
source program, IDN.C. The source file IDN.C is listed on the following
pages. An explanation of the function calls in the example follows the
program listing.
/* This program uses the Standard Instrument Control Library to
query a GPIB instrument for an identification string and then
prints the result. This program is to be built as a WIN32 console
application on Windows 95, Windows 98, Windows 2000, or Windows NT.
Edit the DEVICE_ADDRESS line to specify the address of the applicable
device. For example:
hpib7,0: refers to a GPIB device at bus address 0 connected to
an interface named “hpib7” by the IO Config utility.
hpib7,9,0: refers to a GPIB device at bus address 9, secondary
address 0, connected to an interface named “hpib7”
by the IO Config utility. */
#include <stdio.h>/* for printf() */
#include “sicl.h”/* SICL routines */
#define DEVICE_ADDRESS “hpib7,0” /* Modify to match your setup */
_InitEasyWin();// required for Borland EasyWin programs.
#endif
/* Install a default SICL error handler that logs an error message and exits.
On Windows 95 or Windows 98, view messages with the SICL Message Viewer,
and on Windows 2000 or Windows NT use the Event Viewer. */
ionerror(I_ERROR_EXIT);
/* Open a device session using the DEVICE_ADDRESS */
id = iopen(DEVICE_ADDRESS);
/* Set the I/O timeout value for this session to 1 second */
itimeout(id, 1000);
/* Write the *RST string (and send an EOI indicator) to put the instrument
into a known state. */
iprintf(id, “*RST\n”);
/* Write the *IDN? string and send an EOI indicator, then read the response
into buf.
ipromptf(id, “*IDN?\n”, “%t”, buf);
printf(“%s\n”, buf);
iclose(id);
/* This call is a no-op for WIN32 programs.*/
_siclcleanup();
}
18 Chapter 2
Getting Started with SICL
Getting Started Using C
C Example Code Description
sicl.h. The sicl.h file is included at the beginning of the file to provide the
function prototypes and constants defined by SICL.
id
INST. Notice the declaration of INST
INST is defined by SICL and is used to represent a unique identifier that will
describe the specific device or interface that you are communicating with.
The
id
is set by the return value of the SICL iopen call and will be set to 0
if iopen fails for any reason.
ionerror. The first SICL call, ionerror, installs a default error handling
routine that is automatically called if any of the subsequent SICL calls result
in an error. I_ERROR_EXIT specifies a built-in error handler that will print
out a message about the error and then exit the program. If desired, a
custom error handling routine could be specified instead.
NOTE
at the beginning of main. The type
On Windows 95, Windows 98, and Windows 2000, error messages may
be viewed by executing the Message Viewer utility in the Agilent IO Libraries program group. On Windows NT, these messages may
be viewed with the Event Viewer utility in the Agilent IO Libraries Control on the taskbar.
iopen. When an iopen call is made, the parameter string ”hpib7,0”
passed to iopen specifies the GPIB interface followed by the bus address
of the instrument. The interface name, ”hpib7”, is the name given to the
interface during execution of the IO Config utility. The bus (primary)
address of the instrument follows (”0” in this case) and is typically set
with switches on the instrument or from the front panel of the instrument.
NOTE
To modify the program to set the interface name and instrument address
to those applicable for your setup, see
SICL
for information on using SICL’s addressing capabilities.
Chapter 219
Chapter 3 - Programming with
Getting Started with SICL
Getting Started Using C
itimeout. itimeout is called to set the length of time (in milliseconds) that
SICL will wait for an instrument to respond. The specified value will depend
on the needs of your configuration. Different timeout values can be set for
different sessions as needed.
iprintf and ipromptf. SICL provides formatted I/O functions that are
patterned after those used in the C programming language. These SICL
functions support the standard ANSI C format strings, plus additional
formats defined specifically for instrument I/O.
The SICL iprintf call sends the Standard Commands for Programmable
Instruments (SCPI) command *RST to the instrument that puts it in a known
state. Then, ipromptf queries the instrument for its identification string.
The string is read back into buf and then printed to the screen. (Separate
iprintf and iscanf calls could have been used to perform this
operation.)
The %t read format string specifies that an ASCII string is to be read back,
with end indicator termination. SICL automatically handles all addressing
and GPIB bus management necessary to perform these reads and writes to
instrument.
iclose and _siclcleanup. The iclose function closes the device session
to this instrument (
Windows 95, Windows 98, Windows 2000, or Windows NT do not require
the _siclcleanup call.
NOTE
See
Chapter 11 - SICL Language Reference
more information on these SICL function calls.
20 Chapter 2
id
is no longer valid after this point). WIN32 programs on
or the SICL online Help for
Getting Started with SICL
Getting Started Using C
Compiling the C Example Program
The C\SAMPLES\IDN subdirectory contains a number of files you can use
to build the example with specific compilers. You will have a subset of the
following files, depending on the Windows environment you are using.
IDN.CExample program source file.
IDN.DEFModule definition file for the IDN example program.
MSCIDN.MAKWindows 3.1 makefile for Microsoft C and Microsoft
SDK compilers.
VCIDN.MAKWindows 3.1 project file for Microsoft Visual C++.
VCIDN32.MAKWindows 95 or Windows NT (32-bit) project file for
Microsoft Visual C++.
VCIDN16.MAKWindows 95 (16-bit) project file for Microsoft Vi sual
C++.
QCIDN.MAKWindows 3.1 project file for Microsoft QuickC for
Windows.
BCIDN.IDEWindows 3.1 project file for Borland C Integrated
Development Environment.
BCIDN32.IDEWindows 95 or Windows NT (32-bit) project file for
Borland C Integrated Development Environment.
BCIDN16.IDEWindows 95 (16-bit) project file for Borland C Integra ted
Development Environment.
Steps to compile the IDN example program follow.
1. Connect an instrument to a GPIB interface that is compatible with
IEEE 488.2.
2. Change directories to the location of the example.
3. The program assumes the GPIB interface name is hpib7 (s e t
using IO Config) and the instrument is at bus address 0. If
necessary, modify the interface name and instrument address on
the DEVICE_ADDRESS definition line in the IDN.C source file.
Chapter 221
Getting Started with SICL
Getting Started Using C
4. Select and load the appropriate project or make file. Then, compile
the program as follows:
q For Borland compilers, use Project | Open Project.
Then, select Project | Build All.
q For Microsoft compilers, use Project | Open. Next, set
the include file path by selecting Options | Directories.
Then, in the Include File Path box, enter the full path to the C
subdirectory. Finally, select Project | Re-build All.
Running the C Example Program
To run the IDN example program, execute the program from a console
command prompt.
n For Borland, select Run | Run
n For Microsoft, select Project | Execute or Run | Go
If the program runs correctly, an example of the output if connected to a
54601A oscilloscope is
HEWLETT-PACKARD,54601A,0,1.7
If the program does not run, see the message logger for a list of run-time
errors, and see
correct the problem.
Chapter 9 - Troubleshooting SICL Programs
for guidelines to
Where to Go Next
Go to
Chapter 3 - Programming with SICL
chapter(s) that describe how to use SICL with your specific interface(s):
n
Chapter 4 - Using SICL with GPIB
n
Chapter 5 - Using SICL with GPIO
n
Chapter 6 - Using SICL with VXI
n
Chapter 7 - Using SICL with RS-232
n
Chapter 8 - Using SICL with LAN
You may also want to familiarize yourself with SICL functions, defined in
Chapter 11 - SICL Language Reference
provided in SICL online Help. If you have any problems, see
Troubleshooting SICL Programs
22 Chapter 2
.
. In addition, you should see the
and in the reference information
Chapter 9 -
Getting Started with SICL
Getting Started Using Visual Basic
Getting Started Using Visual Basic
There is a collection of Visual Basic sample programs in the VB\SAMPLES
subdirectory of the base IO Libraries directory. See these programs as
examples of using SICL with Visual Basic.
Be sure to include the sicl4.bas file (in the VB directory) in your Visual Basic
project. This file contains the necessary SICL definitions, function
prototypes, and support procedures to allow you to call SICL functions from
Visual Basic.
Where to Go Next
Go to
Chapter 3 - Programming with SICL
chapter(s) that describe how to use SICL with your specific interface(s):
n
Chapter 4 - Using SICL with GPIB
n
Chapter 5 - Using SICL with GPIO
n
Chapter 6 - Using SICL with VXI
n
Chapter 7 - Using SICL with RS-232
n
Chapter 8 - Using SICL with LAN
. In addition, you should see the
You may also want to familiarize yourself with SICL functions, defined in
Chapter 11 - SICL Language Reference
provided in SICL online Help. If you have any problems, see
Troubleshooting SICL Programs
Chapter 223
.
and in the reference information
Chapter 9 -
Notes:
Getting Started with SICL
Getting Started Using Visual Basic
24 Chapter 2
3
Programming with SICL
25
Programming with SICL
This chapter describes how to build a SICL application and then describes
SICL programming techniques. Example programs are also provided to help
you develop SICL applications. The chapter includes:
n Building a SICL Application
n Opening a Communications Session
n Sending I/O Commands
n Handling Asynchronous Events
n Handling Errors
n Using Locks
NOTE
Copies of the example programs are located in the C\SAMPLES\MISC
subdirectory (for C/C++) or in the VB\SAMPLES\MISC subdirectory (for
Visual Basic) under the base IO Libraries directory. For details on
SICL functions, see
online Help.
Chapter 11 - SICL Language Reference
or SICL
26Chapter 3
Programming with SICL
Building a SICL Application
Building a SICL Application
This section gives guidelines to build a SICL application in a Windows
environment.
Including the SICL Declaration File
For C and C++ programs, you must include the sicl.h header file at the
beginning of every file that contains SICL function calls. This header file
contains the SICL function prototypes and the definitions for all SICL
constants and error codes.
#include “sicl.h”
For Visual Basic version 3.0 or earlier programs, you must add the
SICL.BAS file to each project that calls SICL. For Visual Basic version 4.0
or later programs, you must add the SICL4.BAS file to each project that
calls SICL.
Libraries for C Applications and DLLs
All WIN32 applications and DLLs that use SICL must link to the
SICL32.LIB import library. (Borland compilers use BCSICL32.DLL.)
The SICL libraries are located in the C directory under the IO Libraries
base directory (for example, C:\Program Files\Agilent\IO Libraries\C if you installed SICL in the default location). You may
want to add this directory to the library file path used by your language tools.
Use the DLL version of the C run-time libraries, because the run-time
libraries contain global variables that must be shared between your
application and the SICL DLL.
If you use the static version of the C run-time libraries, these global variables
will not be shared and unpredictable results could occur. For example, if you
use isscanf with the %F format, an application error will occur. The
following sections describe how to use the DLL versions of the run-time
libraries.
Chapter 327
Programming with SICL
Building a SICL Application
Compiling and Linking C Applications
A summary of important compiler-specific considerations follows for several
C/C++ compiler products when developing WIN32 applications.
NOTE
If you are using a version of the Microsoft or Borland compilers other than
those listed in this subsection, the menu structure and selections may be
different than indicated here. However, the equivalent functionality exists
for your specific version.
0LFURVRIW9LVXDO
&&RPSLOHUV
1.Select Project | Settings or Build | Settings from
the menu (depending on the version of your compiler).
2.Click the C/C++ button. Then, select Code Generation from
the Category list box and select Multithreaded Using DLL
from the Use Run-Time Library list box. Click OK to close the
dialog box.
3.Select Project | Settings or Build | Settings from
the menu. Click the Link button. Then, add sicl32.lib to the
Object/Library Modules list box. Click OK to close the
dialog box.
4.You may want to add the SICL C directory (for example,
C:\Program Files\Agilent\IO Libraries\C to the include
file and library file search paths. To do this, select Tools | Options from the menu and click the Directories button.
Then:
q To set the include file path, select Include Files from
the Show Directories for: list box. Next, click the Add
button and type in C:\Program Files\Agilent\IO Libraries\C. Then, click OK.
q To set the library file path, select Library Files from the
Show Directories for: list box. Next, click the Add button and type in C:\Program Files\Agilent\IO
Libraries\C. Then, click OK.
28 Chapter 3
Programming with SICL
Building a SICL Application
%RUODQG&
9HUVLRQ
&RPSLOHUV
1.Link your programs with BCSICL32.LIB,
BCSICL32.LIB is located in the C subdirectory under the SICL base directory (for example, C:\Program Files\Agilent\
IO Libraries\C if SICL is installed in the default location).
2.Edit the BCC32.CFG and TLINK32.CFG files, which are located in
the BIN subdirectory of the Borland C installation directory.
not
SICL32.LIB.
q Add the following line to BCC32.CFG so the compi le r can find
the sicl.h file:
where
-IC:\
IO_base_dir
IO_base_dir
is the IO Libraries base directory.
\C
q Add the following line to both files so the compiler and linker
can find BCSICL32.LIB:
where
IO_base_dir
-LC:\
IO_base_dir
is the IO Libraries base directory.
\C
q For example, to create MYPROG.EXE from MYPROG.C, type:
BCC32 MYPROG.C BCSICL32.LIB
Loading and Running Visual Basic Applications
To load and run an existing Visual Basic application, first run Visual Basic.
Then, open the project file for the program you want to run by selecting
File | Open Project from the Visual Basic menu. Visual Basic project
files have a .MAK file extension. After you haved opened the application’s
project file, you can run the application by pressing
the Visual Basic Toolbar.
You can create a standalone executable (.EXE) version of this program by
selecting File | Make EXE File from the Visual Basic menu. Once this
is done, the application can be run stand-alone (just like any other .EXE file)
without having to run Visual Basic.
Chapter 329
F5 or the Run button on
Programming with SICL
Building a SICL Application
Thread Support for 32-bit Windows Applications
SICL can be used in multi-threaded designs and SICL calls can be made
from multiple threads, in WIN32 applications. However, there are some
important points:
n SICL error handlers (installed with ionerror) are
(not per thread) but are called in the context of the thread that
caused the error to occur. Calling ionerror from one thread will
overwrite any error handler presently installed by another thread.
per process
n The igeterrno is per thread and returns the last SICL error that
occurred in the current thread.
n You may want to make use of the SICL session locking functions
(ilock and iunlock) to help coordinate common instrument
accesses from more than one thread.
n See
Chapter 8 - Using SICL with LAN
using SICL with LAN.
for thread information when
30 Chapter 3
Loading...
+ 394 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.