Agilent IO Libraries Suite E2094S Agilent VISA User’s Guide for IO Libraries Suite 15.
Notices © Agilent Technologies, Inc. 71995-1996, 1998, 2000-2009 No part of this manual may be reproduced in any form or by any means (including electronic storage and retrieval or translation into a foreign language) without prior agreement and written consent from Agilent Technologies, Inc. as governed by United States and international copyright laws. Manual Part Number E2094-90013 Edition First edition, October 2009 Agilent Technologies, Inc.
Agilent VISA User’s Guide 1 Introduction What’s in This Guide? 8 VISA Overview 9 Using VISA, VISA COM, and SICL VISA Support 10 VISA Documentation 10 Contacting Agilent 2 9 12 Building a VISA Application in Windows Building a VISA Program (C/C++) 14 Compiling and Linking VISA Programs (C/C++) Sample VISA Program (C/C++) 15 14 Building a VISA Program (Visual Basic) 18 Visual Basic Programming Considerations 18 Sample VISA Program (Visual Basic) 20 Logging Error Messages 25 Using the Event Viewer 25 U
Closing a Session 37 Searching for Resources Sending I/O Commands 40 Types of I/O 40 Using Non-Formatted I/O 37 44 Using Events and Handlers 46 Events and Attributes 46 Using the Callback Method 54 Using the Queuing Method 62 Trapping Errors 68 Trapping Errors 68 Exception Events 69 Using Locks 74 Lock Functions 74 viLock/viUnlock Functions VISA Lock Types 75 4 74 Programming via GPIB and VXI GPIB and VXI Interfaces Overview 80 General Interface Information 80 GPIB Interfaces Overview 81 VXI Interfaces
Using Low-Level viPeek/viPoke 100 Using High-Level viIn/viOut 101 Using High-Level viMoveIn/viMoveOut Using the Memory Access Resource Memory I/O Services 106 MEMACC Attribute Descriptions Using VXI-Specific Attributes 113 Using the Map Address as a Pointer Setting the VXI Trigger Line 114 5 101 106 109 113 Programming via LAN LAN and Remote Interfaces Overview 118 Direct LAN Connection versus Remote IO Server/Client Connection 118 Remote IO Server/Client Architecture 118 Addressing LAN-Connected Devices
Agilent VISA User’s Guide
Agilent IO Libraries Suite Agilent VISA User’s Guide 1 Introduction This Agilent VISA User’s Guide describes the Agilent Virtual Instrument Software Architecture (VISA) library and shows how to use it to develop I/O applications and instrument drivers on Windows PCs. NOT E Before you can use VISA, you must install and configure VISA on your computer. See the Agilent IO Libraries Suite Connectivity Guide with Getting Started for installation on Windows systems.
1 Introduction What’s in This Guide? This guide shows VISA programming techniques using C/C++ and Visual Basic. This chapter provides an overview of VISA and shows how to contact Agilent Technologies. Subsequent chapters in this guide address the following topics: • Chapter 2 - Building a VISA Application in Windows describes how to build a VISA application in a Windows environment. A sample program is provided to help you get started programming with VISA.
Introduction 1 VISA Overview VISA is an application programming interface (API) for instrument control. It allows you to programmatically send commands and receive data from instruments and other test and measurement devices (such as sources and switches). VISA is a part of the Agilent IO Libraries Suite product.
1 Introduction VISA Support This 32-bit version of VISA is supported on Microsoft Windows 2000, Windows XP and Windows Vista. (For information on support of older operating systems, see the Agilent IO Libraries Suite Online Help.) C, C++, and Visual Basic are supported on these Windows versions. C# and Visual Basic .NET are also supported via the visa32.cs and visa32.vb header files that are included with the Agilent VISA library.
Introduction Table 1 Agilent VISA Documentation VXIbus Consortium specifications (when using VISA over LAN) Agilent VISA User’s Guide 1 TCP/IP Instrument Protocol Specification - VXI-11, Rev. 1.0 TCP/IP-VXIbus Interface Specification VXI-11.1, Rev. 1.0 TCP/IP-IEEE 488.1 Interface Specification - VXI-11.2, Rev. 1.0 TCP/IP-IEEE 488.2 Instrument Interface Specification - VXI-11.3, Rev. 1.
1 Introduction Contacting Agilent • In the USA, you can reach Agilent Technologies by telephone at: USA: 1-800-829-4444 • Outside the USA, 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 • The Agilent Developer Network (ADN), http://www.agilent.
Agilent IO Libraries Suite Agilent VISA User’s Guide 2 Building a VISA Application in Windows This chapter provides guidelines for building a VISA application in a Windows environment. The chapter contains the following sections: • Building a VISA Program (C/C++) • Building a VISA Program (Visual Basic) • Logging Error Messages For information on building a VISA application in Visual Studio .NET, see the VISA Online Help.
2 Building a VISA Application in Windows Building a VISA Program (C/C++) This section provides guidelines for building VISA programs using the C/C++ language, including: • Compiling and Linking VISA Programs (C/C++) • Sample VISA Program (C/C++) Compiling and Linking VISA Programs (C/C++) This section provides a summary of important compiler-specific considerations when developing Win32 applications.
2 Building a VISA Application in Windows • Click at the bottom of the list box and type: C:\Program Files\IVIfoundation\IVI\VISA\ winnt\include (This assumes that you used the default installation location for VISA. If VISA had been installed previously, it may be in a different location.) • Select Library Files from the Show Directories For list box. • Click at the bottom of the list box and type: C:\VXIPNP\WinNT\lib\msc (This assumes that you used the default installation location for VISA.
2 Building a VISA Application in Windows AGILENT TECHNOLOGIES,54622A,987654312,A.01.50 If the program does not run, see the Event Viewer for a list of run-time errors. /*idn.c This example program queries a GPIB device for an identification string and prints the results. Note that you must change the address. */ #include #include
2 Building a VISA Application in Windows C/C++ Sample Program Contents A summary of the VISA function calls used in the preceding sample C/C++ program follows. For a more detailed explanation of VISA functionality, see Chapter 3, “Programming with VISA.” See the VISA Online Help for more detailed information on these VISA function calls. Table 2 Summary of VISA Function Calls Used in the C/C++ Sample Function(s) Description visa.
2 Building a VISA Application in Windows Building a VISA Program (Visual Basic) This section provides guidelines for building a VISA program in the Microsoft Visual Basic (VB) language, including: • Visual Basic Programming Considerations • Sample VISA Program (Visual Basic) Visual Basic Programming Considerations Some considerations for programming in Visual Basic follow. This information applies to Microsoft Visual Basic version 6.
Building a VISA Application in Windows 2 VISA cannot call back to a VB function. Thus, you can only use the VI_QUEUE mechanism in viEnableEvent. There is no way to install a VISA event handler in VB. VISA functions that take a variable number of parameters (viPrintf, viScanf, viQueryf) are not callable from VB. Use the corresponding viVPrintf, viVScanf and viVQueryf functions instead. You cannot pass variables of type Variant to VISA functions.
2 Building a VISA Application in Windows Strings When reading in a string value with viVScanf or viVQueryf, you must pass a fixed length string as the params parameter. To declare a fixed length string, instead of using the normal variable length declaration: Dim strVal as String use the following declaration, where 40 is the fixed length.
Building a VISA Application in Windows 2 Libraries Suite\ProgrammingSamples\VB6\VISA\ idn. 5 Select the file idn.bas and click Open. Since the Main() subroutine is executed when the program is run without requiring user interaction with a Form, you may delete Form1 if desired. To do this, right-click Form1 in the Project Explorer window and select Remove Form1. 6 VISA applications in Visual Basic require the VISA Visual Basic (VB) declaration file visa32.bas in your VB project.
2 Building a VISA Application in Windows If the program does not run, see the Event Viewer for a list of run-time errors. The source file idn.bas follows. Option Explicit '''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''' ' idn.bas ' This example program queries a GPIB device for ' an identification string and prints the ' results. Note that you may have to change the ' VISA Interface Name and address for your ' device from "GPIB0" and "22",respectively.
2 Building a VISA Application in Windows Call viOpen(defrm, "GPIB0::22::INSTR", 0, 0, vi) ' Initialize device Call viVPrintf(vi, "*RST" + Chr$(10), 0) ' Ask for the device's *IDN string. Call viVPrintf(vi, "*IDN?" + Chr$(10), 0) ' Read the results as a string.
2 Building a VISA Application in Windows Table 3 24 Summary of VISA Function Calls in Visual Basic Sample viOpen This function establishes a communication channel with the device specified. A session identifier (vi) that can be used with other VISA functions is returned. This call must be made for each device you will be using. viVPrintf and viVScanf These are the VISA formatted I/O functions. The viVPrintf call sends the IEEE 488.
Building a VISA Application in Windows 2 Logging Error Messages When developing or debugging your VISA application, you may want to view internal VISA messages while your application is running. You can do this by using the Event Viewer utility or the Debug Window. There are three choices for VISA logging: • Off (default) for best performance • Event Viewer • Debug Window Using the Event Viewer The Event Viewer utility provides a way to view internal VISA error messages during application execution.
2 Building a VISA Application in Windows program using an application such as Microsoft Visual Studio. In this case, VISA messages will appear in the Visual Studio output window. The process for using the Debug Window is: 1 Enable VISA logging from the Agilent IO Control by clicking the blue IO icon on the taskbar and then clicking Agilent VISA Options > VISA Logging > Debug Window. 2 Run your VISA program from Microsoft Visual Studio (or equivalent application).
Agilent IO Libraries Suite Agilent VISA User’s Guide 3 Programming with VISA This chapter describes how to program with VISA. The basics of VISA are described, including formatted I/O, events and handlers, attributes, and locking. Example programs are also provided and can be found in the ProgrammingSamples subdirectory (C:\Program Files\Agilent\IO Libraries Suite\ ProgrammingSamples in a default installation).
3 Programming with VISA VISA Resources and Attributes This section introduces VISA resources and attributes, including: • VISA Resources • VISA Attributes VISA Resources In VISA, a resource is defined as any device (such as a voltmeter) with which VISA can provide communication. VISA defines six resource classes that a complete VISA system, fully compliant with the VXIplug&play Systems Alliance specification, can implement.
Programming with VISA Table 4 3 Resource Classes Supported by Agilent VISA (continued) Memory Access (MEMACC) Generic, GPIB-VXI, VXI Address space of a memory-mapped bus such as the VXIbus. VXI Mainframe Backplane (BACKPLANE) Generic, GPIB-VXI, VXI (GPIB-VXI BACKPLANE not supported) VXI-defined operations and properties of each backplane in a VXIbus system. TCPIP Socket (SOCKET) Generic, TCPIP Operations and properties of a raw network socket connection using TCPIP.
3 Programming with VISA Using Sessions This section shows how to use VISA sessions, including: • Including the VISA Declarations File (C/C++) • Adding the visa32.bas File (Visual Basic) • Opening a Session to a Resource • Addressing a Session • Closing a Session • Searching for Resources Including the VISA Declarations File (C/C++) For C and C++ programs, you must include the visa.h header file at the beginning of every file that contains VISA function calls: #include "visa.
Programming with VISA 3 Opening a Session A session is a channel of communication. Sessions must first be opened on the default resource manager, and then for each resource you will be using. • A resource manager session is used to initialize the VISA system. It is a parent session that knows about all the opened sessions. A resource manager session must be opened before any other session can be opened. • A resource session is used to communicate with a resource on an interface.
3 Programming with VISA Your program may have several sessions open at the same time after creating multiple session identifiers by calling the viOpen function multiple times. The following table summarizes the parameters in the previous function calls. Table 5 Parameters Used in Function Calls Parameter Description sesn A session returned from the viOpenDefaultRM function that identifies the resource manager session. rsrcName A unique symbolic name of the resource (resource address).
Programming with VISA 3 The example again uses the session returned from the resource manager, with another VISA address, to open a session with the GPIB-VXI device at primary address 9 and VXI logical address (secondary address) 24. You will now identify this session as scanner when calling other VISA functions. See the following section, “Addressing a Session”, for information on addressing particular devices. ViSession defaultRM, dmm, scanner; .
3 Programming with VISA Table 6 The Format of the rsrcName (VISA Address) for Different Interface Types Interface Typical Syntax ASRL ASRL[board][::INSTR] GPIB GPIB[board]::primary address[::secondary address][::INSTR] GPIB GPIB[board]::INTFC GPIB-VXI GPIB-VXI[board]::VXI logical address[::INSTR] GPIB-VXI GPIB-VXI[board]::MEMACC GPIB-VXI GPIB-VXI[board][::VXI logical address]::BACKPLANE TCPIP TCPIP[board]::host address[::LAN device name]::INSTR TCPIP TCPIP[board]::host address::port::SOCK
Programming with VISA Table 7 3 Description of Parameters (continued) manufacturer ID Manufacturer’s ID for a USB Test & Measurement class device model code Model code of a USB device. port The port number to use for a TCP/IP Socket connection. primary address The primary address of the GPIB device. secondary address This optional parameter is the secondary address of the GPIB device. If no secondary address is specified, none is assumed. serial number Serial number of a USB device.
3 Programming with VISA Table 8 Examples of Valid VISA Addresses (continued) GPIB2::INTFC Interface or raw resource for GPIB interface 2. VXI::1::BACKPLANE Mainframe resource for chassis 1 on the default VXI system, which is interface 0. GPIB-VXI2:: BACKPLANE Mainframe resource for default chassis on GPIB-VXI interface 2. GPIB1::SERVANT Servant/device-side resource for GPIB interface 1. VXI0::SERVANT Servant/device-side resource for VXI interface 0. TCPIP0::1.2.3.
Programming with VISA 3 Closing a Session You must use the viClose function to close each session. Closing the specific resource session frees all data structures that had been allocated for the session. If you close the default resource manager session, all sessions opened using that resource manager session will close. Since system resources are also used when searching for resources (viFindRsrc), the viClose function needs to be called to free up find lists.
3 Programming with VISA The parameters are defined as follows. Table 9 Parameter Definitions of Parameters Description sesn The resource manager session. expr The expression that identifies what to search (Table 10). findList A handle that identifies this search. This handle will then be used as an input to the viFindNext function when finding the next match. retcnt A pointer to the number of matches found. instrDesc A pointer to a string identifying the location of the match.
Programming with VISA 3 Example: Searching the VXI Interface for Resources This code sample searches the VXI interface for resources. The number of matches found is returned in nmatches, and matches points to the string that contains the matches found. The first call returns the first match found, the second call returns the second match found, etc. VI_FIND_BUFLEN is defined in the visa.h declarations file. ViChar buffer [VI_FIND_BUFLEN]; ViRsrc matches=buffer; ViUInt32 nmatches; ViFindList list; . .
3 Programming with VISA Sending I/O Commands This section provides guidelines for sending I/O commands, including: • Types of I/O • Using Formatted I/O • Using Non-Formatted I/O Types of I/O Once you have established a communications session with a device, you can start communicating with that device using VISA's I/O routines. VISA provides both formatted and non-formatted I/O routines. • Formatted I/O converts mixed types of data under the control of a format string.
3 Programming with VISA Using Formatted I/O As noted, the VISA formatted I/O functions are viPrintf, viQueryf, and viScanf. • viPrintf formats data according to the format string (writeFmt) and sends the data to a device. viPrintf sends separate arg parameters, while the viVPrintf function sends a list of parameters in params: viPrintf(vi, writeFmt[, arg1][, arg2][, ...]); viVPrintf(vi, writeFmt, params); • viScanf receives and converts data from a device according to the format string (readFmt).
3 Programming with VISA Formatted I/O Buffers The VISA software maintains both a read and write buffer for formatted I/O operations. Occasionally, you may want to control the actions of these buffers. You can modify the size of the buffer using the viSetBuf function. See the VISA Online Help for more information on this function. The write buffer is maintained by the viPrintf or viQueryf (writeFmt) functions.
3 Programming with VISA Example: Sending and Receiving Formatted I/O The following C sample program demonstrates sending and receiving formatted I/O. The program opens a session with a GPIB device and sends a comma operator to send a comma-separated list. This program shows specific VISA functionality and does not include error trapping. This example program is installed on your system in the ProgrammingSamples subdirectory. /*formatio.
3 Programming with VISA Using Non-Formatted I/O There are two non-buffered, non-formatted I/O functions that synchronously transfer data called viRead and viWrite. Also, there are two non-formatted I/O functions that asynchronously transfer data called viReadAsync and viWriteAsync. These are raw I/O functions and do not intermix with the formatted I/O functions. Non-Formatted I/O Functions The non-formatted I/O functions follow.
3 Programming with VISA /*nonfmtio.c This example program measures the AC voltage on a multimeter and prints the results. You may need to change the device address. */ #include #include
3 Programming with VISA Using Events and Handlers This section provides guidelines to using events and handlers, including: • Events and Attributes • Using the Callback Method • Using the Queuing Method Events and Attributes Events are special occurrences that require attention from your application. Event types include Service Requests (SRQs), interrupts, and hardware triggers. Events will not be delivered unless the appropriate events are enabled.
3 Programming with VISA The queuing and callback mechanisms are suitable for different programming styles. The queuing mechanism is generally useful for non-critical events that do not need immediate servicing. The callback mechanism is useful when immediate responses are needed. These mechanisms work independently of each other, so both can be enabled at the same time. By default, a session is not enabled to receive any events by either mechanism.
3 Programming with VISA Table 11 Instrument Control (INSTR) Resource Events (continued) Event Attribute Description A P Data Type Range VI_ATTR_EVENT_TYPE Unique logical identifier of the event. R O ViEventTy pe VI_EVENT_VXI_STOP VI_ATTR_SIGP_STATUS _ID The 16-bit Status/ID value retrieved during the IACK cycle or from the Signal register. R O ViUInt16 0 to FFFFh VI_EVENT_TRIG Notification that a trigger interrupt was received from the device.
Programming with VISA 3 Table 11 Instrument Control (INSTR) Resource Events (continued) VI_ATTR_RET_COUNT Actual number of elements that were asynchronously transferred. VI_ATTR_OPER_NAME Name of the operation generating the event. R O ViUInt32 0 to FFFFFFFFh ViString N/A VI_EVENT_USB_INTR Notification that a vendor-specific USB interrupt was received from the device. Event Attribute Description A P Data Type Range VI_ATTR_EVENT_TYPE Unique logical identifier of the event.
3 Programming with VISA Table 12 Memory Access (MEMACC) Resource Event VI_EVENT_IO_COMPLETION Notification that an asynchronous operation has completed Event Attribute Description A P Data Type Range VI_ATTR_EVENT_TYPE Unique logical identifier of the event. R O ViEventTy pe VI_EVENT_IO_COMPLE TION VI_ATTR_STATUS Return code of the asynchronous I/O operation that has completed. R O ViStatus N/A VI_ATTR_JOB_ID Job ID of the asynchronous operation that has completed.
Programming with VISA 3 Table 13 GPIB Bus Interface (INTFC) Resource Events (continued) Event Attribute VI_ATTR_EVENT_TYPE Description Unique logical identifier of the event. A P R O Data Type ViEventTy pe Range VI_EVENT_GPIB_TAL K VI_EVENT_GPIB_LISTEN Notification that the GPIB controller has been addressed to listen. Event Attribute VI_ATTR_EVENT_TYPE Description Unique logical identifier of the event.
3 Programming with VISA Table 13 GPIB Bus Interface (INTFC) Resource Events (continued) Event Attribute Description A P Data Type Range VI_ATTR_EVENT_TYPE Unique logical identifier of the event. R O ViEventTy pe VI_EVENT_IO_ COMPLETION VI_ATTR_STATUS Return code of the asynchronous I/O operation that has completed. R O ViStatus N/A VI_ATTR_JOB_ID Job ID of the asynchronous operation that has completed. R O ViJobId N/A VI_ATTR_BUFFER Address of buffer used in an asynchronous operation.
Programming with VISA 3 Table 14 VXI Mainframe Backplane (BACKPLANE) Resource Events (continued) VI_ATTR_EVENT_TYPE Unique logical identifier of the event. R O ViEventTy pe VI_EVENT_VXI_VME_ SYSFAIL VI_EVENT_VXI_VME_SYSRESET Notification that the VXI/VME SYSRESET* line has been reset Event Attributes VI_ATTR_EVENT_TYPE Description Unique logical identifier of the event.
3 Programming with VISA Example: Reading Event Attributes Once you have decided which attribute to check, you can read the attribute using the viGetAttribute function. The following example shows one way you could check which trigger line fired when the VI_EVENT_TRIG event was delivered. Note that the context parameter is either the event context passed to your event handler, or the outcontext specified when doing a wait on event.
Programming with VISA 3 . . viInstallHandler(vi, VI_EVENT_SERVICE_REQ, my_handler, addr); viEnableEvent(vi, VI_EVENT_SERVICE_REQ, VI_HNDLR, VI_NULL); . /* your code here */ . viDisableEvent(vi, VI_EVENT_SERVICE_REQ, VI_HNDLR); viUninstallHandler(vi, VI_EVENT_SERVICE_REQ, my_handler, addr); . } Installing Handlers VISA allows applications to install multiple handlers for an event type on the same session.
3 Programming with VISA The userHandle parameter allows you to assign a value to be used with the handler on the specified session. Thus, you can install the same handler for the same event type on several sessions with different userHandle values. The same handler is called for the specified event type. However, the value passed to userHandle is different. Therefore the handlers are uniquely identified by the combination of the handler and the userHandle.
3 Programming with VISA Using VI_QUEUE in the mechanism parameter specifies a queuing method for the events to be handled. If you use both VI_QUEUE and one of the mechanisms listed above, notification of events will be sent to both locations. See the next subsection for information on the queuing method. Table 17 Description of Parameters Used to Install a Handler Parameter Description vi The session on which the handler will be installed. eventType The type of event to enable.
3 Programming with VISA Example: Trigger Callback This sample program installs an event handler and enables the trigger event. When the event occurs, the installed event handler is called. This program is intended to show specific VISA functionality and does not include error trapping. Error trapping, however, is good programming practice and is recommended in your VISA applications. See “Trapping Errors” in this chapter for more information.
Programming with VISA 3 printf("TTL0"); break; default: printf("", trigId); break; } printf("\n"); return VI_SUCCESS; } void main(){ ViSession defaultRM,vi; /* open session to VXI device */ viOpenDefaultRM(&defaultRM); viOpen(defaultRM, "VXI0::24::INSTR", VI_NULL, VI_NULL, &vi); /* select trigger line TTL0 */ viSetAttribute(vi, VI_ATTR_TRIG_ID, VI_TRIG_TTL0); /* install the handler and enable it */ viInstallHandler(vi, VI_EVENT_TRIG, myHdlr, (ViAddr)10); viEnableEvent(vi, VI_EVENT_TRIG, VI_HND
3 Programming with VISA Example: SRQ Callback This program installs an event handler and enables an SRQ event. When the event occurs, the installed event handler is called. This sample program is intended to show specific VISA functionality and does not include error trapping. Error trapping, however, is good programming practice and is recommended in your VISA applications. See “Trapping Errors” in this chapter for more information.
Programming with VISA 3 printf( "\nStray event of type 0x%lx\n", eventType ); return VI_SUCCESS; } /* print the event information */ printf("\nSRQ Event Occurred!\n"); printf("...Original Device Session = %ld\n", vi); /* get the status byte */ viReadSTB(vi, &statusByte); printf("...
3 Programming with VISA /* Send a bogus command to the message-based device to cause an SRQ. Note: 'IDN' causes the error -- 'IDN?' is the correct syntax */ viPrintf( vi, "IDN\n" ); /* Wait a while for the SRQ to be generated and for the handler to be called. Print something while we wait */ printf("Waiting for an SRQ to be generated."); for (count = 0 ; (count < 10) && (srqOccurred == 0);count++) { long count2 = 0; printf( ".
Programming with VISA 3 • When ready to query, use the viWaitOnEvent function to check for queued events. If the specified event has occurred, the event information is retrieved and the program returns immediately. If the specified event has not occurred, the program suspends execution until a specified event occurs or until the specified timeout period is reached. Example: Using the Queuing Method This example program shows one way you can use the queuing method.
3 Programming with VISA Table 18 Descriptions of Parameters Used to Enable Events Parameter Description vi The session the handler will be installed on. eventType The type of event to enable. mechanism The mechanism by which the event will be enabled. Specify VI_QUEUE to use the queuing method. context Not used in VISA 1.0. Use VI_NULL. When you use VI_QUEUE in the mechanism parameter, you are specifying that the events will be put into a queue.
Programming with VISA 3 Example: Wait on Event for SRQ This example shows how to install a wait on event for service requests. viEnableEvent(vi, VI_EVENT_SERVICE_REQ, VI_QUEUE, VI_NULL); viWaitOnEvent(vi, VI_EVENT_SERVICE_REQ, VI_TMO_INFINITE, &eventType, &event); . . viDisableEvent(vi, VI_EVENT_SERVICE_REQ, VI_QUEUE); Every time a wait on event is invoked, an event context object is created.
3 Programming with VISA void main(){ ViSession defaultRM,vi; ViEventType eventType; ViEvent eventVi; ViStatus err; ViInt16 trigId; /* open session to VXI device */ viOpenDefaultRM(&defaultRM); viOpen(defaultRM, "VXI0::24::INSTR", VI_NULL, VI_NULL, &vi); /* select trigger line TTL0 */ viSetAttribute(vi, VI_ATTR_TRIG_ID, VI_TRIG_TTL0); /* enable the event */ viEnableEvent(vi, VI_EVENT_TRIG, VI_QUEUE, VI_NULL); /* fire trigger line, twice */ viAssertTrigger(vi, VI_TRIG_PROT_SYNC); viAssertTrigger(vi, VI_TRIG
Programming with VISA 3 printf("TTL0"); break; default: printf("",trigId); break; } printf("\n"); /* close the context before continuing */ viClose(eventVi); /* get second event */ err=viWaitOnEvent(vi, VI_EVENT_TRIG, 10000, &eventType, &eventVi); if(err==VI_ERROR_TMO){ printf("Timeout Occurred! Event not received.
3 Programming with VISA Trapping Errors This section provides guidelines for trapping errors, including: • Trapping Errors • Exception Events Trapping Errors The example programs in this guide show specific VISA functionality and do not include error trapping. Error trapping, however, is good programming practice and is recommended in all your VISA application programs. To trap VISA errors you must check for VI_SUCCESS after each VISA function call.
3 Programming with VISA char err_msg[1024]={0}; viStatusDesc (vi, err, err_msg); printf ("ERROR = %s\n", err_msg); return; } Example: Checking Instrument Errors When programming instruments, it is good practice to check the instrument to ensure there are no instrument errors after each instrument function. This example uses a SCPI command to check a specific instrument for errors.
3 Programming with VISA Exception Handling Model The exception-handling model follows the event-handling model for callbacks, and it uses the same operations as those used for general event handling. For example, an application calls viInstallHandler and viEnableEvent to enable exception events. The exception event is like any other event in VISA, except that the queueing and suspended handler mechanisms are not allowed.
Programming with VISA 3 3 Code in any operation (after calling an exception handler) may not be called if the handler does not return. For example, local allocations must be freed before invoking the exception handler, rather than after it. One situation in which an exception event will not be generated is in the case of asynchronous operations. If the error is detected after the operation is posted (i.e.
3 Programming with VISA handler must be installed and exception events enabled on all sessions where the exception handler is used.*/ #include #include
3 Programming with VISA status = viOpenDefaultRM( &drm ); if ( status < VI_SUCCESS ) { printf( "ERROR: viOpenDefaultRM failed with error = 0x%lx\n", status ); return; } /* Install the exception handler and enable events for it */ status = viInstallHandler(drm, VI_EVENT_EXCEPTION, myExceptionHandler, myUserHandle); if ( status < VI_SUCCESS ) { printf( "ERROR: viInstallHandler failed with error 0x%lx\n", status ); } status = viEnableEvent(drm, VI_EVENT_EXCEPTION, VI_HNDLR, VI_NULL); if ( status < VI_SUCCESS
3 Programming with VISA Using Locks In VISA, applications can open multiple sessions to a VISA resource simultaneously. Applications can, therefore, access a VISA resource concurrently through different sessions. However, in certain cases, applications accessing a VISA resource may want to restrict other applications from accessing that resource.
3 Programming with VISA VISA Lock Types VISA defines two different types of locks: Exclusive Lock and Shared Lock. Exclusive Lock - A session can lock a VISA resource using the lock type VI_EXCLUSIVE_LOCK to get exclusive access privileges to the resource. This exclusive lock type excludes access to the resource from all other sessions. If a session has an exclusive lock, other sessions cannot modify global attributes or invoke operations on the resource.
3 Programming with VISA See the VISA Online Help for function descriptions to determine which are applicable for locking and which are not restricted by locking. Example: Exclusive Lock This example shows a session gaining an exclusive lock to perform the viPrintf and viScanf VISA operations on a GPIB device. It then releases the lock via the viUnlock function. /* lockexcl.c This example program queries a GPIB device for an identification string and prints the results.
3 Programming with VISA /* Print results */ printf ("Instrument identification string: %s\n", buf); /* Close session */ viClose (vi); viClose (defaultRM);} Example: Shared Lock This example shows a session gaining a shared lock with the accessKey called lockkey. Other sessions can now use this accessKey in the requestedKey parameter of the viLock function to share access on the locked resource. This example then shows the original session acquiring an exclusive lock while maintaining its shared lock.
3 Programming with VISA /* at this time, we can make 'lockkey' available to other processes that we know about. This can be done with shared memory or other inter-process communication methods. These other processes can then call "viLock(vi,VI_SHARED_LOCK, 2000, lockkey, lockkey)" and they will also have access to this resource.
Agilent IO Libraries Suite Agilent VISA User’s Guide 4 Programming via GPIB and VXI VISA supports three interfaces you can use to access GPIB (General Purpose Interface Bus) and VXI (VME eXtension for Instrumentation) instruments: GPIB, VXI, and GPIB-VXI.
4 Programming via GPIB and VXI GPIB and VXI Interfaces Overview This section provides an overview of the GPIB, GPIB-VXI, and VXI interfaces, including: • General Interface Information • GPIB Interfaces Overview • VXI Interfaces Overview General Interface Information VISA supports three interfaces you can use to access instruments or devices: GPIB, VXI, and GPIB-VXI. The GPIB interface can be used to access VXI instruments via a Command Module.
Programming via GPIB and VXI 4 message-based device interprets the SCPI command. In this case you can use the VISA formatted I/O or non-formatted I/O functions and program the message-based device as you would a GPIB device. However, if the message-based device has shared memory, you can access the device's shared memory by doing register peeks and pokes. VISA provides two different methods you can use to program directly to the registers: high-level memory functions or low-level memory functions.
4 Programming via GPIB and VXI GPIB Interface (82350 PCI GPIB Cards) Windows PC GPIB Cable GPIB Instruments 5 82350 GPIB Card #1 82350 GPIB Card #2 3 3 Example: GPIB (82350) Interface The GPIB interface system in the following figure consists of a Windows PC with two 82350 GPIB cards connected to three GPIB instruments via GPIB cables. For this system, Agilent Connection Expert has been used to assign GPIB card #1 a VISA name of GPIB0 and to assign GPIB card #2 a VISA name of GPIB1.
Programming via GPIB and VXI 4 GPIB Interface (82350 PCI GPIB Cards) Windows PC Interface VISA Names GPIB Cable GPIB Instruments 5 VISA Name "GPIB0" 82350 GPIB Card #1 "GPIB1" 82350 GPIB Card #2 3 3 VISA Addressing viOpen (... "GPIB0::5::INSTR"...) viOpen (... "GPIB0::3::INSTR"...) viOpen (... "GPIB1::3::INSTR"...
4 Programming via GPIB and VXI VXI Interfaces Overview As shown in the following figure, a typical VXI (E8491) interface consists of an E8491 PC Card in a Windows PC that is connected to an E8491B IEEE-1394 Module in a VXI mainframe via an IEEE-1394 to VXI cable. The VXI mainframe also includes one or more VXI instruments. VXI (E8491) Interfaces Windows PC E8491 PC Card VXI Mainframe IEEE-1394 to VXI E 8 4 9 1 B V X I V X I I n s t r . . I. n s t r V X I ..
Programming via GPIB and VXI 4 VXI Interface (E8491B IEEE-1394 to VXI Module) Interface VISA Name Windows PC IEEE-1394 to VXI VISA Name "VXI0" E8491 PC Card VXI Mainframe E 8 4 9 1 B V X I I n s t r LA 8 V X I V X I I . .n. s t r LA 24 .. I n s t r LA 16 VISA Addressing viOpen (... "VXI0::24::INSTR"...
4 Programming via GPIB and VXI NOT E For a GPIB-VXI interface, VISA uses a DLL supplied by the Command Module vendor to translate the VISA VXI calls to Command Module commands that are vendor-specific. The DLL required for Agilent Command Modules is installed by the Agilent IO Libraries Suite installer. This DLL is installed by default when Agilent VISA is installed. GPIB-VXI (E1406A) Interfaces Windows PC GPIB Card GPIB VXI Mainframe E 1 4 0 6 A V X I V X I I n s t r . . I. n s t r V X I ..
Programming via GPIB and VXI 4 The Connection Expert utility has been used to assign the GPIB-VXI driver a VISA name of GPIB-VXI0 and to assign the 82350 GPIB card a VISA name of GPIB0. VISA addressing is as shown in the figure. For information on the E1406A Command Module, see the Agilent E1406A Command Module User’s Guide. For information on VXI instruments, see the applicable instrument’s User’s Guide.
4 Programming via GPIB and VXI Using High-Level Memory Functions High-level memory functions allow you to access memory on the interface through simple function calls. There is no need to map memory to a window. Instead, when high-level memory functions are used, memory mapping and direct register access are automatically done. The trade-off, however, is speed. High-level memory functions are easier to use.
Programming via GPIB and VXI 4 Table 20 Summary of High-Level Memory Functions viOut16(vi, space, offset, val16); Writes 16 bits of data to the specified offset. viOut32(vi, space, offset, val32); Writes 32 bits of data to the specified offset. viMoveIn8(vi, space, offset, length, buf8); Moves an 8-bit block of data from the specified offset to local memory. viMoveIn16(vi, space, offset, length, buf16); Moves a 16-bit block of data from the specified offset to local memory.
4 Programming via GPIB and VXI The val32 parameter is a pointer to where the data read will be stored. If instead you write to the registers via the viOut32 function, the val32 parameter is a pointer to the data to write to the specified registers. If the device specified by vi does not have memory in the specified address space, an error is returned. The following code sample uses viIn16. ViSession defaultRM, vi; ViUInt16 value; .
4 Programming via GPIB and VXI The first program uses the VXI interface; the second program accesses the backplane with the GPIB-VXI interface. These two programs are identical except for the string passed to viOpen. Sample: Using VXI Interface (High-Level) Memory Functions This program uses high-level memory functions and the VXI interface to read the ID and Device Type registers of a device at VXI0::24. /* vxihl.
4 Programming via GPIB and VXI /* Close sessions */ viClose(dmm); viClose(defaultRM); } Sample: Using GPIB-VXI Interface (High-Level) Memory Functions This program uses high-level memory functions and the GPIB-VXI interface to read the ID and Device Type registers of a device at GPIB-VXI0::24. /*gpibvxih.c This example functions to registers of this address contents are program uses the high-level memory read the id and device type the device at GPIB-VXI0::24. Change if necessary.
Programming via GPIB and VXI 4 /* Print results */ printf ("ID Register = 0x%4X\n", id_reg); printf ("Device Type Register = 0x%4X\n", devtype_reg); /* Close sessions */ viClose(dmm); viClose(defaultRM); } Agilent VISA User’s Guide 93
4 Programming via GPIB and VXI Using Low-Level Memory Functions Low-level memory functions allow direct access to memory on the interface just as do high-level memory functions. However, with low-level memory function calls, you must map a range of addresses and directly access the registers with low-level memory functions, such as viPeek32 and viPoke32. There is more programming effort required when using low-level memory functions. However, the program execution speed can increase.
4 Programming via GPIB and VXI Table 21 Summary of Low-Level Memory Functions (continued) viPeek16(vi, addr, val16); Reads 16 bits of data from address specified. viPeek32(vi, addr, val32); Reads 32 bits of data from address specified. viPoke8(vi, addr, val8); Writes 8 bits of data to address specified. viPoke16(vi, addr, val16); Writes 16 bits of data to address specified. viPoke32(vi, addr, val32); Writes 32 bits of data to address specified.
4 Programming via GPIB and VXI /* Maps to A24 address space */ viMapAddress(vi, VI_A24_SPACE, 0x00, 0x80, VI_FALSE, VI_NULL,&address); Reading and Writing to Device Registers When you have mapped the memory space, use the VISA low-level memory functions to access the device's registers. First, determine which device register you need to access. Then, you need to know the register's offset. See the applicable instrument’s user manual for a description of the registers and register locations.
Programming via GPIB and VXI 4 Low-Level Memory Functions: Code Samples Two sample programs follow that use the low-level memory functions to read the ID and Device Type registers of the device at VXI logical address 24. The contents of the registers are then printed out. The first program uses the VXI interface and the second program uses the GPIB-VXI interface to access the VXI backplane. These two programs are identical except for the string passed to viOpen.
4 Programming via GPIB and VXI /* Read device type register contents */ /* ViAddr is defined as a void so we must cast /* it to something else to do pointer arithmetic */ viPeek16(dmm, (ViAddr)((ViUInt16 *)address + 0x01), &devtype_reg); /* Unmap memory space */ viUnmapAddress(dmm); /* Print results */ printf ("ID Register = 0x%4X\n", id_reg); printf ("Device Type Register = 0x%4X\n", devtype_reg); /* Close sessions */ viClose(dmm); viClose(defaultRM); } Sample: Using the GPIB-VXI Interface (Low-Level) M
4 Programming via GPIB and VXI /* Open session to VXI device at address 24 */ viOpenDefaultRM(&defaultRM); viOpen(defaultRM, "GPIB-VXI0::24::INSTR", VI_NULL, VI_NULL,&dmm); /* Map into memory space */ viMapAddress(dmm, VI_A16_SPACE, 0x00, 0x10, VI_FALSE, VI_NULL, &address); /* Read instrument id register contents */ viPeek16(dmm, address, &id_reg); /* Read device type register contents */ /* ViAddr is defined as a void so we must cast it to something else to do pointer arithmetic */ viPeek16(dmm, (ViAddr)
4 Programming via GPIB and VXI Using Low/High-Level Memory I/O Methods VISA supports three different memory I/O methods for accessing memory on the VXI backplane, as shown. All three of these access methods can be used to read and write VXI memory in the A16, A24, and A32 address spaces. The best method to use depends on the VISA program characteristics.
4 Programming via GPIB and VXI • Only one active viMapAddress is allowed per vi session. • There may be a limit to the number of simultaneous active viMapAddress calls per process or system. Using High-Level viIn/viOut High-level viIn/viOut calls are best in situations where a few widely scattered memory accesses are required and speed is not a major consideration. The advantages of high-level viIn/viOut are: • It is the simplest method to implement. • There is no limit on the number of active maps.
4 Programming via GPIB and VXI The disadvantage of viMoveIn/viMoveOut calls is that they have higher initial overhead than viPeek/viPoke. Sample: Using VXI Memory I/O This program demonstrates using various types of VXI memory I/O. /* memio.c This example program demonstrates the use of various memory I/O methods in VISA. */ #include #include #include
4 Programming via GPIB and VXI /* ================================================ = Using viPeek ================================================ */ Read instrument id register contents */ viPeek16 (vi, address, &id_reg); /* Read device type register contents ViAddr is defined as a (void *) so we must cast it to something else in order to do pointer arithmetic.
4 Programming via GPIB and VXI /* Unmap memory space */ viUnmapAddress (vi); /*============================================== High Level memory I/O = viIn16 ==============================================*/ /* Read instrument id register contents */ viIn16 (vi, VI_A16_SPACE, 0x00, &&id_reg); /* Read device type register contents */ viIn16 (vi, VI_A16_SPACE, 0x02,&devtype_reg); /* Print results */ printf (" viIn16: ID Register = 0x%4X\n", id_reg); printf (" viIn16: Device Type Register = 0x%4X\n", devtype_r
4 Programming via GPIB and VXI /* Demonstrate block read. Read instrument id register and device type register into an array.*/ viMoveIn16 (vi, VI_A16_SPACE, 0x00, 2, memArray); /* Print results */ printf (" viMoveIn16: ID Register = 0x%4X\n", memArray[0]); printf (" viMoveIn16: Device Type Register = 0x%4X\n", memArray[1]); /* Demonstrate FIFO read. First set the source increment to 0 so we will repetitively read from the same memory location.
4 Programming via GPIB and VXI Using the Memory Access Resource For VISA 1.1 and later, the Memory Access (MEMACC) resource type has been added to VXI and GPIB-VXI. VXI::MEMACC and GPIB-VXI::MEMACC allow access to all of the A16, A24, and A32 memory by providing the controller with access to arbitrary registers or memory addresses on memory-mapped buses. The MEMACC resource, like any other resource, starts with the basic operations and attributes of other VISA resources.
4 Programming via GPIB and VXI Although the resource handles the allocation and operation of the window, the programmer must free the window via viUnMapAddress when finished. This makes the window available for the system to reallocate. Sample: MEMACC Resource Program This program demonstrates one way to use the MEMACC resource to open the entire VXI A16 memory and then calculate an offset to address a specific device. /* peek16.c */ #include #include #include
4 Programming via GPIB and VXI ViUInt16*addr16; ViStatusstatus; ViUInt16offset; status = viOpenDefaultRM ( &drm ); checkError( 0, status, "viOpenDefaultRM", EXIT ); /* Open a session to the VXI MEMACC Resource*/ status = viOpen( drm, "vxi0::memacc", VI_NULL, VI_NULL, &vi ); checkError (0, status, "viOpen", EXIT ); /* Calculate the A16 offset of the VXI REgisters for the device at VXI logical address 8. */ offset = 0xc000 + 64 * 8; /* Open a map to all of A16 memory space.
4 Programming via GPIB and VXI /* Print the results. */ printf( "inData16 : 0x%04hx\n", inData16 ); printf( "peekData16: ox%04hx\n", peekData16 ); viClose( vi ); viClose (drm ); } MEMACC Attribute Descriptions Generic MEMACC Attributes The following read-only attributes (VI_ATTR_TMO_VALUE is read/write) provide general interface information.
4 Programming via GPIB and VXI VXI and GPIB-VXI Specific MEMACC Attributes The following attributes, most of which are read/write, provide memory window control information. Table 23 Attributes That Provide Memory Window Control Information Attribute Description VI_ATTR_VXI_LA Logical address of the local controller. VI_ATTR_SRC_INCREMENT Used in viMoveInxx operation to specify how much the source offset is to be incremented after every transfer.
4 Programming via GPIB and VXI Table 23 Attributes That Provide Memory Window Control Information VI_ATTR_SRC_BYTE_ORDE R Specifies the byte order used in high-level access operations, such as viInxx and viMoveInxx, when reading from the source. VI_ATTR_DEST_BYTE_ORD ER Specifies the byte order used in high level access operations, such as viOutxx and viMoveOutxx, when writing to the destination.
4 Programming via GPIB and VXI Table 24 Attributes that Provide Specific Address Information VI_ATTR_GPIB_PRIMARY_ADD R Primary address of the GPIB-VXI controller used by the session. VI_ATTR_GPIB_SECONDARY_A DDR Secondary address of the GPIB-VXI controller used by the session. MEMACC Resource Event Attribute The following read-only events provide notification that an asynchronous operation has completed.
4 Programming via GPIB and VXI Using VXI-Specific Attributes VXI-specific attributes can be useful to determine the state of your VXI system. Attributes are read-only and read/write. Read-only attributes specify things such as the logical address of the VXI device and information about where your VXI device is mapped. This section shows how you might use some of the VXI-specific attributes. See VISA Resource Classes in the VISA Online Help for information on VISA attributes.
4 Programming via GPIB and VXI Sample: Determining Window Mapping ViAddr address; Vi UInt16 access; ViUInt16 value; . . . viMapAddress(vi, VI_A16_SPACE, 0x00, 0x04, VI_FALSE, VI_NULL, &address); viGetAttribute(vi, VI_ATTR_WIN_ACCESS, &access); . . If(access==VI_USE_OPERS) { viPeek16(vi, (ViAddr)(((ViUInt16 *)address) + 4/sizeof(ViUInt16)), &value) }else if (access==VI_DEREF_ADDR){ value=*((ViUInt16 *)address+4/sizeof(ViUInt16)); }else if (access==VI_NMAPPED){ return error; } . .
Programming via GPIB and VXI 4 The above function sets the VXI trigger line to TTL trigger line 0 (VI_TRIG_TTL0). The following are valid VXI trigger lines. (Panel In is an Agilent extension of the VISA specification.
4 116 Programming via GPIB and VXI Agilent VISA User’s Guide
Agilent IO Libraries Suite Agilent VISA User’s Guide 5 Programming via LAN This chapter provides guidelines for programming via a LAN (Local Area Network). A LAN allows you to extend the control of instrumentation beyond the limits of typical instrument interfaces.
5 Programming via LAN LAN and Remote Interfaces Overview This section provides an overview of LAN (Local Area Network) interfaces. A LAN is a way to extend the control of instrumentation beyond the limits of typical instrument interfaces. To communicate with instruments over the LAN, you must first configure a LAN interface or a remote GPIB, USB, or serial interface, using the Agilent Connection Expert.
Programming via LAN 5 As shown in the following figure, a remote I/O client (a Windows PC) makes VISA requests over the network to a remote I/O server (such as a Windows PC, an E5810 LAN/GPIB Gateway, or a Series 700 HP-UX workstation). Gateway Operation The remote I/O server is connected to the instrumentation or devices to be controlled. Once the remote I/O server has completed the requested operation on the instrument or device, the remote I/O server sends a reply to the client.
5 Programming via LAN Windows PCs Client LAN E5810 LAN/GPIB Gateway Remote I/O Server Series 700 workstation or Windows PC GPIB Instrument 120 GPIB bus GPIB bus (or other) LAN Instruments (VXI-11.2 GPIB Emulation or VXI-11.
Programming via LAN 5 Addressing LAN-Connected Devices VISA can communicate with LAN-connected devices in one of two ways: • TCPIP interface type • Remote interface type (available only with Agilent IO Libraries Suite) Using the TCPIP Interface Type for LAN Access VISA provides the TCPIP interface type to communicate with LAN-connected devices.
5 Programming via LAN Some examples of TCPIP resource strings follow. Table 28 Example TCPIP Resource Strings String Description TCPIP0::testMachine@agilent.com::gpib0,2::INST R A VXI-11.2 GPIB device at hostname testMachine@agilent.com. TCPIP0::123.456.0.21::gpib0,2::INSTR A VXI-11.2 GPIB device at a machine whose IP address is 123.456.0.21. TCPIP0::myMachine::inst0::INSTR A VXI-11.3 LAN instrument at hostname myMachine. TCPIP::myMachine A VXI-11.3 LAN instrument at hostname myMachine.
5 Programming via LAN Table 28 Example TCPIP Resource Strings String Description TCPIP0::myMachine::usb0[2391::1031::SN_00123 ::0]::INSTR A USB device with: Manufacture ID = 2391 Model Code = 1031 Serial Number = 'SN_00123' USBTMC Intfc # = 0 connected to a LAN server at hostname myMachine. This device must use SICL-LAN protocol since USB devices are not supported by the VXI-11 protocol.
5 Programming via LAN viClose(defaultRM); Using a Remote Interface for LAN Access Agilent VISA provides three types of VISA LAN Client interfaces, implemented in Agilent IO Libraries Suite as remote interfaces: • Remote serial interface (ASRL VISA LAN Client) • Remote GPIB interface (GPIB VISA LAN Client) • Remote USB interface (USB VISA LAN Client) Remote interfaces are configured using Connection Expert; they provide virtual GPIB, serial, or USB interfaces.
5 Programming via LAN Remote USB Interface (USB VISA LAN Client) A remote USB interface can use only the SICL-LAN protocol. It can communicate with USB devices attached to a remote PC running the Remote IO Server software. Note that if you have defined a VISA alias for a USB device on the remote I/O server, you must either define the same (or another) alias for the remote USB device on the client PC, or use the full USB resource string.
5 126 Programming via LAN Agilent VISA User’s Guide
Agilent IO Libraries Suite Agilent VISA User’s Guide 6 Programming via USB This chapter provides guidelines for VISA programming of USB instruments that conform to USBTMC (Universal Serial Bus Test and Measurement Class) and/or USBTMC-USB488 (Universal Serial Bus Test and Measurement Class, Subclass USB488 Specification).
6 Programming via USB USB Interfaces Overview USBTMC/USBTMC-USB488 instruments are detected and automatically configured by Agilent VISA when they are plugged into the computer. The Agilent IO Libraries Suite Online Help describes the USB instrument configuration process in more detail. NOT E Do not confuse the Agilent 82357 USB/GPIB Interface with a USBTMC device. The 82357 is automatically configured as a GPIB interface, not as a USBTMC device, when it is plugged into the computer.
6 Programming via USB Communicating with a USB Instrument Using VISA To establish communications with a USB device using VISA, you can either use the full VISA resource string for the device or use the alias provided by VISA. Using the alias is recommended, for reasons described below. Using the full VISA resource string, a viOpen call would look something like this: viOpen( . . ., "USB0::2391::1031::0000000123::0::INSTR", . . . ); Following is a summary of the components of this call.
6 Programming via USB Although the case of a VISA alias is preserved, case is ignored when the alias is used in place of the full resource string in a viOpen call. For example, UsbDevice1, usbdevice1 and USBDEVICE1 all refer to the same device. Using the alias, a viOpen call would look something like this: viOpen( . . ., "UsbDevice1", . . . ); As you can see, this is much simpler than having to use the full resource string for a USB device. Using the alias in a program also makes it more portable.
Agilent IO Libraries Suite Agilent VISA User’s Guide Glossary access board The GPIB interface to which a particular device is connected. Active Controller See "Controller in Charge". address A string (or other language construct) that uniquely locates and identifies a resource. VISA defines an ASCII-based grammar that associates address strings with particular physical devices or interfaces and VISA resources.
Glossary attribute In VISA and SICL, a value that indicates the operational state of a resource. Some attributes can be changed; others are read-only. board A GPIB interface. It may be a physical board, an adapter (such as the 82357 USB/GPIB adapter), or a remote GPIB interface. board descriptor A handle, returned from ibfind, that uniquely identifies a GPIB interface (board) in Agilent 488 original API calls. Also called an interface descriptor or board unit descriptor.
Glossary commander In test-system architectures, a device that has the ability to control another device. In a specialized case, a commander may also be the device that has sole control over another device (as with the VXI Commander/Servant hierarchy). commander session A session that communicates to the interface’s commander. Commander sessions are used when an interface is in a non-Controller role. communication channel A communication path between a software element and a resource.
Glossary device A unit that receives commands from a Controller. A device is typically an instrument, but can also be a computer acting in a non-Controller role or another peripheral such as a printer or plotter. In VISA, a device is logically represented by the association of several VISA resources. device descriptor A handle, returned from ibdev or ibfind, that uniquely identifies a device in Agilent 488 original API calls. Also called a device unit descriptor.
Glossary explorer view The tree view within the Connection Expert window that shows all devices connected to a test system. handler A software routine that responds to an asynchronous event such as an SRQ or an interrupt. instrument A device that accepts commands and performs a test and measurement function. instrument driver Software that runs on a computer to allow an application to control a particular instrument.
Glossary interface messages GPIB commands encoded as individual bytes. Also called GPIB commands or command bytes. interface session A session that communicates and controls parameters affecting an entire interface. interrupt An asynchronous event that requires attention and actions that are out of the normal flow of control of a program. IO Control The icon in the Windows notification area (usually the lower right corner of your screen).
Glossary logical unit A number associated with an interface. A logical unit, in SICL and Agilent VEE, uniquely identifies an interface. Each interface on the controller must have a unique logical unit. mapping An operation that returns a reference to a specified section of an address space and makes the specified range of addresses accessible to the requester. This function is independent of memory allocation.
Glossary programming alias See VISA alias. refresh In Connection Expert, the action that invokes the discovery mechanism for detecting interfaces and instruments connected to your computer. The explorer view is then refreshed to show the current, discovered state of your test system. register An address location that contains a value that represents the state of hardware, or that can be written into to cause hardware to perform a specified action or to enter a specified state.
Glossary secondary VISA A VISA installation that does not install visa32.dll in the standard VISA location. The secondary VISA installation names its VISA DLL with a different name (agvisa32.dll) so that it can be accessed programmatically. The primary VISA will be used by default in VISA applications. See also primary VISA. session VISA term for a communication channel. An instance of a communications path between a software element and a resource. Every communication channel in VISA is unique.
Glossary status byte A byte of information returned from a remote device that shows the current state and status of the device. If the device follows IEEE-488 (GPIB) conventions, bit 6 of the status byte indicates whether the device is currently requesting service. symbolic name A name corresponding to a single interface. This name uniquely identifies the interface on this Controller or gateway.
Glossary test system An entire test setup including a controller (often a PC), instruments, interfaces, software, and any remote controllers, instruments, and interfaces that are configured to be used as part of the system. thread An operating system object that consists of a flow of control within a process. A single process may have multiple threads, each having access to the same data space within the process.
Glossary VISA alias A string that can be used instead of a resource descriptor in VISA programs. Using VISA aliases rather than hard-coded resource descriptors makes your programs more portable. You can define VISA aliases for your instruments in Connection Expert. VISA COM The VXIplug&play specification for a COM-compliant VISA I/O library and its implementation. Agilent VISA COM is part of the Agilent IO Libraries Suite.
Glossary Windows notification area See notification area.
Glossary 144 Agilent VISA User’s Guide
Index A addressing addressing device sessions, 33 devices, 33 Agilent 488, 131 Agilent web site, 12 attributes setting VXI trigger lines, 114 VXI, 113 B buffers formatted I/O, 42 C callbacks and events, 46, 54 closing device sessions, 37 conversion, formatted I/O, 41 D declarations file, 30 default resource manager, 31 device sessions addressing, 33 closing, 37 opening, 31 E enable events for callback, 56 enable events for queuing, 63 event handler, 56 events callback, 46, 54 enable for callback, 56 ena
Index L LAN hardware architecture, 118 interfaces overview, 118 locking, 32, 74 locks using, 74 low-level memory functions, 94 low-level memory functions for VXI, 94 M MEMACC attribute descriptions, 109 memory functions, high-level, 88 memory functions, low-level, 94 N NI-488, 131 non-formatted I/O mixing with formatted I/O, 44 See also examples searching for resources, 37 sessions device, 31 opening, 31 resource manager, 31 SRQs, 46 starting the resource manager, 31 T timeout, 32, 65 trigger lines, 11