Agilent Technologies E2094S User Manual

For io libraries suite 15.5
Table of Contents

Advertisement

Agilent IO Libraries Suite
E2094S
Agilent VISA
User's Guide for IO
Libraries Suite 15.5
Agilent Technologies

Advertisement

Table of Contents
loading

Summary of Contents for Agilent Technologies E2094S

  • Page 1 Agilent IO Libraries Suite E2094S Agilent VISA User’s Guide for IO Libraries Suite 15.5 Agilent Technologies...
  • Page 2: Safety Notices

    815 14th Street SW formed or adhered to, could result Should Agilent and the user have a Loveland, CO 80537 USA in damage to the product or loss separate written agreement with warranty terms covering the mate- of important data.
  • Page 3: Table Of Contents

    Agilent VISA User’s Guide Introduction What’s in This Guide? VISA Overview Using VISA, VISA COM, and SICL VISA Support VISA Documentation Contacting Agilent Building a VISA Application in Windows Building a VISA Program (C/C++) Compiling and Linking VISA Programs (C/C++)
  • Page 4: Table Of Contents

    GPIB Interfaces Overview VXI Interfaces Overview GPIB-VXI Interfaces Overview Using High-Level Memory Functions Programming the Registers High-Level Memory Functions: Sample Programs Using Low-Level Memory Functions Programming the Registers Low-Level Memory Functions: Code Samples Using Low/High-Level Memory I/O Methods Agilent VISA User’s Guide...
  • Page 5: Table Of Contents

    Remote IO Server/Client Architecture Addressing LAN-Connected Devices Using the TCPIP Interface Type for LAN Access Using a Remote Interface for LAN Access Programming via USB USB Interfaces Overview Communicating with a USB Instrument Using VISA Glossary Agilent VISA User’s Guide...
  • Page 6 Agilent VISA User’s Guide...
  • Page 7 Agilent IO Libraries Suite Agilent VISA User’s Guide 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. Before you can use VISA, you must install and configure VISA on your NOT E computer.
  • Page 8: 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.
  • Page 9: Visa Overview

    (such as sources and switches). VISA is a part of the Agilent IO Libraries Suite product. The Agilent IO Libraries Suite includes three libraries: Agilent Virtual Instrument Software Architecture (VISA), VISA for the Common Object Model (VISA COM), and Agilent Standard Instrument Control Library (SICL).
  • Page 10: 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...
  • Page 11 TCP/IP Instrument Protocol specifications (when using VISA Specification - VXI-11, Rev. 1.0 over LAN) 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.0 Agilent VISA User’s Guide...
  • Page 12: Contacting Agilent

    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...
  • Page 13 Agilent IO Libraries Suite Agilent VISA User’s Guide 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) •...
  • Page 14: Building A Visa Program (C/C++)

    5 You may want to add the include files and library files search paths. They are set as follows: • Select Tools > Options from the menu. • Click the Directories tab to set the include file path. • Select Include Files from the Show Directories For list box. Agilent VISA User’s Guide...
  • Page 15: Sample Visa Program (C/C++)

    This sample assumes a Win32 console application using Microsoft Visual Studio® on Windows. The idn sample files are in the ProgrammingSamples directory under the Agilent IO Libraries Suite installation directory. By default, the sample files are in C:\Program Files\Agilent\IO Libraries Suite\ ProgrammingSamples\C\VISA.
  • Page 16 /* Initialize device */ viPrintf(vi, "*RST\n"); /* Send an *IDN? string to the device */ viPrintf(vi, "*IDN?\n"); /* Read results */ viScanf(vi, "%t", buf); /* Print results */ printf("Instrument identification string: %s\n", buf); /* Close session */ viClose(vi); viClose(defaultRM);} Agilent VISA User’s Guide...
  • Page 17 When you close the default manager session, all sessions opened using that default manager session will be closed. Agilent VISA User’s Guide...
  • Page 18: Building A Visa Program (Visual Basic)

    The VB Error variable is not set by any VISA function. Thus, you cannot use the ON ERROR construct in VB or the value of the VB Error variable to catch VISA function errors. Agilent VISA User’s Guide...
  • Page 19 For example, the following code declares an array of 50 floating point numbers and then calls viVPrintf to write from the array. Dim flt_array(50) As Double status = viVPrintf(id, "%,50f", dbl_array(0)) Agilent VISA User’s Guide...
  • Page 20: Sample Visa Program (Visual Basic)

    Project1, with a blank Form, Form1. 4 From the menu, select Project > Add Module, select the Existing tab, and browse to the idn directory. If you used default installation paths, this directory is C:\Program Files\Agilent\IO Agilent VISA User’s Guide...
  • Page 21 An explanation of the various function calls in the sample is provided after this program listing. If the program runs correctly, the following is an example of the output that appears in a message box if your PC is connected to a 54601A oscilloscope. HEWLETT-PACKARD,54601A,0,1.7 Agilent VISA User’s Guide...
  • Page 22 ' Change this name to what you have defined ' for your VISA Interface. ' "GPIB0::22::INSTR" is the address string ' for the device. ' this address will be the same as seen in: ' Connection Expert) Agilent VISA User’s Guide...
  • Page 23 Function(s) Description viOpenDefaultRM You must first open a session with the default resource manager with the viOpenDefaultRM function. This function will initialize the default resource manager and return a pointer (defrm) to that resource manager session. Agilent VISA User’s Guide...
  • Page 24 When you close a device session, all data structures that had been allocated for the session will be deallocated. When you close the default manager session, all sessions opened using that default manager session will be closed. Agilent VISA User’s Guide...
  • Page 25: Logging Error Messages

    VISA. The process for using the Event Viewer is: • 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 > Event Viewer.
  • Page 26 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 >...
  • Page 27 Agilent IO Libraries Suite Agilent VISA User’s Guide 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...
  • Page 28: Visa Resources And Attributes

    • Events for communication with applications. • Operations (functions) that can be used for the resource class. Table 4describes each resource class supported by Agilent VISA. See VISA Resource Classes in the VISA Online Help for a description of the attributes, events, and operations for each resource class.
  • Page 29: Visa Attributes

    Programming with VISA Table 4 Resource Classes Supported by Agilent VISA (continued) Memory Access Generic, GPIB-VXI, Address space of a (MEMACC) memory-mapped bus such as the VXIbus. VXI Mainframe Generic, GPIB-VXI, VXI-defined operations and Backplane VXI (GPIB-VXI properties of each backplane...
  • Page 30: Using Sessions

    Adding the visa32.bas File (Visual Basic) You must add the visa32.bas Basic module file to your Visual Basic project. The visa32.bas file contains the VISA function prototypes and definitions for all VISA constants and error codes. Agilent VISA User’s Guide...
  • Page 31: Opening A Session

    The viOpen function then uses that session and the resource address specified in the rsrcName parameter to open a resource session. The vi parameter in viOpen returns a session identifier that can be used with other VISA functions. Agilent VISA User’s Guide...
  • Page 32 The example then uses the session returned from the resource manager, and a VISA address, to open a session with the GPIB device at address 22. You can now identify that session as dmm when you call other VISA functions. Agilent VISA User’s Guide...
  • Page 33: Addressing A Session

    This parameter consists of the VISA interface ID and the resource address. The interface ID is determined when you run the Agilent Connection Expert utility. The interface ID is usually the VISA interface type followed by a number.
  • Page 34 LAN device name The assigned name for a LAN device. Device Name depends on LAN Host Device (see documentaiton that came with your LAN Host device such as E5810A). The default is inst(). Agilent VISA User’s Guide...
  • Page 35 A GPIB device at primary address 1 and secondary address 0 in GPIB interface 0. ASRL1::INSTR A serial device located on port 1. VXI::MEMACC Board-level register access to the VXI interface. GPIB-VXI1::MEMACC Board-level register access to GPIB-VXI interface number 1. Agilent VISA User’s Guide...
  • Page 36 0. Example: Opening a Session This sample shows one way to open a VISA session with the GPIB device at primary address 23. ViSession defaultRM, vi; viOpenDefaultRM(&defaultRM); viOpen(defaultRM, "GPIB0::23::INSTR", VI_NULL, VI_NULL,&vi); viClose(vi); viClose(defaultRM); Agilent VISA User’s Guide...
  • Page 37: Closing A Session

    If there are more matches, use the viFindNext function with the handle returned from viFindRsrc to get the next match: viFindRsrc(sesn, expr, findList, retcnt, instrDesc); viFindNext(findList, instrDesc); viClose (findList); Agilent VISA User’s Guide...
  • Page 38 GPIB?*INSTR applies to both GPIB and GPIB-VXI devices. Table 10 Determining What to Use for the expr Parameter Interface expr Parameter GPIB GPIB[0-9]*::?*INSTR VXI?*INSTR GPIB-VXI GPIB-VXI?*INSTR GPIB and GPIB-VXI GPIB?*INSTR All VXI ?*VXI[0-9]*::?*INSTR ASRL ASRL[0-9]*::?*INSTR ?*INSTR Agilent VISA User’s Guide...
  • Page 39 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; viFindRsrc(defaultRM, "VXI?*INSTR", &list, &nmatches, matches); viFindNext(list, matches); viClose(list); Agilent VISA User’s Guide...
  • Page 40: Sending I/O Commands

    These are raw I/O functions and do not intermix with the formatted I/O functions. See “Using Non-Formatted I/O” in this chapter for details. Refer to the VISA Online Help for more information on how data is converted under the control of the format string. Agilent VISA User’s Guide...
  • Page 41 Both readFmt and writeFmt have the form: %[modifier]formatCode Example: Receiving Data From a Session The following example uses viScanf to receive data from the session specified by the vi parameter and converts the data to a string. char data[180]; viScanf(vi, "%t", data); Agilent VISA User’s Guide...
  • Page 42 Flushing the read buffer also includes reading all pending response data from a device. If the device is still sending data, the flush process will continue to read data from the device until it receives an END indicator from the device. Agilent VISA User’s Guide...
  • Page 43 "*RST\n"); /* Set-up device,send comma-separated list */ viPrintf(vi, "CALC:DBM:REF 50\n"); viPrintf(vi, "MEAS:VOLT:AC? %,2f\n", list); /* Read results */ viScanf(vi, "%lf", &res); /* Print results */ printf("Measurement Results: %lf\n", res); /* Close session */ viClose(vi); viClose(defaultRM); Agilent VISA User’s Guide...
  • Page 44: Using Non-Formatted I/O

    Only one synchronous write operation can occur at any one time. viWrite(vi, buf, count, retCount); Refer to the Agilent VISA help file for specific infomraiton on these and other VISA functions such as viReadAsync viWriteAsync...
  • Page 45 &actual); viWrite(vi, (ViBuf)"MEAS:VOLT:AC? 1, 0.001\n", 23, &actual); /* Read results */ viRead(vi, (ViBuf)strres, 20, &actual); /* NULL terminate the string */ strres[actual]=0; /* Print results */ printf("Measurement Results: %s\n", strres); /* Close session */ viClose(vi); viClose(defaultRM); Agilent VISA User’s Guide...
  • Page 46: Using Events And Handlers

    • Enable one or several events with viEnableEvent and call the viWaitOnEvent function. The viWaitOnEvent function will suspend the program execution until the specified event occurs or the specified timeout period is reached. This is called queuing. Agilent VISA User’s Guide...
  • Page 47 VISA for each resource class, where AP = Access Privilege, RO - Read Only, and RW = Read/Write. Note that some resource classes/events, such as the SERVANT class, are not implemented by Agilent VISA and are not listed in the following tables.
  • Page 48 VI_TRIG_TTL0 to mechanism on which the VI_TRIG_TTL7; specified trigger event was VI_TRIG_ECL0 to received. VI_TRIG_ECL1* * Agilent VISA can also return VI_TRIG_PANEL_IN (exception to the VISA Specification) VI_EVENT_IO_COMPLETION Notification that an asynchronous operation has completed. Event Attribute Description Data Type Range...
  • Page 49 VI_ATTR_STATUS Specifies the status of the read ViStatus operation from the USB interrupt-IN pipe. If the device sent more data than the user specified in VI_ATTR_USB_MAX_INTR_S IZE, then this attribute value will contain an error code. Agilent VISA User’s Guide...
  • Page 50 Notification that the GPIB controller has gained or lost CIC (controller in charge) status Event Attribute Description Data Type Range VI_ATTR_EVENT_TYPE Unique logical identifier of the ViEventTy VI_EVENT_GPIB_CIC event. VI_ATTR_GPIB_RECV_CIC_ Controller has become ViBoolean VI_TRUE STATE controller-in-charge. VI_FALSE VI_EVENT_GPIB_TALK Notification that the GPIB controller has been addressed to talk Agilent VISA User’s Guide...
  • Page 51 Data Type Range VI_ATTR_EVENT_TYPE Unique logical identifier of the ViEventTy VI_EVENT_TRIG event. VI_ATTR_RECV_TRIG_ID The identifier of the triggering ViInt16 VI_TRIG_SW mechanism on which the specified trigger event was received. VI_EVENT_IO_COMPLETION Notification that an asynchronous operation has completed. Agilent VISA User’s Guide...
  • Page 52 Unique logical identifier of the ViEventTy VI_EVENT_TRIG event. VI_ATTR_RECV_TRIG_I The identifier of the triggering ViInt16 VI_TRIG_TTL0 to mechanism on which the VI_TRIG_TTL7; specified trigger event was VI_TRIG_ECL0 to received. VI_TRIG_ECL1 VI_EVENT_VXI_VME_SYSFAIL Notification that the VXI/VME SYSFAIL* line has been asserted. Agilent VISA User’s Guide...
  • Page 53 VI_ATTR_BUFFER Address of a buffer that was used ViBuf in an asynchronous operation. VI_ATTR_RET_COUNT Actual number of elements that ViUInt32 0 to FFFFFFFF were asynchronously transferred. VI_ATTR_OPER_NAME Name of the operation generating ViString the event. Agilent VISA User’s Guide...
  • Page 54: Using The Callback Method

    This example shows one way you can use the callback method. ViStatus _VI_FUNCH my_handler (ViSession vi, ViEventType eventType, ViEvent context, ViAddr usrHandle) { /* your event handling code here */ return VI_SUCCESS; main(){ ViSession vi; ViAddr addr=0; Agilent VISA User’s Guide...
  • Page 55 The session on which the handler will be installed. eventType The event type that will activate the handler. handler The name of the handler to be called. userHandle A user value that uniquely identifies the handler for the specified event type. Agilent VISA User’s Guide...
  • Page 56 Before an event can be delivered, it must be enabled using the viEnableEvent function. This function causes the application to be notified when the enabled event has occurred, where the parameters are: viEnableEvent(vi, eventType, mechanism, context); Agilent VISA User’s Guide...
  • Page 57 If you specify VI_ALL_ENABLE_EVENTS in the eventType parameter, all events that have previously been enabled on the specified session will be enabled for the mechanism specified in this function call. Use the viDisableEvent function to stop servicing the event specified. Agilent VISA User’s Guide...
  • Page 58 /* Stray event, so ignore */ return VI_SUCCESS; /* print the event information */ printf("Trigger Event Occurred!\n"); printf("...Original Device Session = %ld\n", vi); /* get the trigger that fired */ viGetAttribute(ctx, VI_ATTR_RECV_TRIG_ID, &trigId); printf("Trigger that fired: "); switch(trigId){ case VI_TRIG_TTL0: Agilent VISA User’s Guide...
  • Page 59 (ViAddr)10); viEnableEvent(vi, VI_EVENT_TRIG, VI_HNDLR, VI_NULL); /* fire trigger line, twice */ viAssertTrigger(vi, VI_TRIG_PROT_SYNC); viAssertTrigger(vi, VI_TRIG_PROT_SYNC); /* unenable and uninstall the handler */ viDisableEvent(vi, VI_EVENT_TRIG, VI_HNDLR); viUninstallHandler(vi, VI_EVENT_TRIG, myHdlr, (ViAddr)10); /* close the sessions */ viClose(vi); viClose(defaultRM); Agilent VISA User’s Guide...
  • Page 60 #endif int srqOccurred; /* trigger event handler */ ViStatus _VI_FUNCH mySrqHdlr(ViSession vi, ViEventType eventType, ViEvent ctx, ViAddr userHdlr){ ViUInt16 statusByte; /* make sure it is an SRQ event */ if(eventType!=VI_EVENT_SERVICE_REQ){ /* Stray event, so ignore */ Agilent VISA User’s Guide...
  • Page 61 /* Enable command error events */ viPrintf( vi, "*ESE 32\n" ); /* Enable event register interrupts */ viPrintf( vi, "*SRE 32\n" ); /* install the handler and enable it */ viInstallHandler(vi, VI_EVENT_SERVICE_REQ, mySrqHdlr, (ViAddr)10); viEnableEvent(vi, VI_EVENT_SERVICE_REQ, VI_HNDLR, VI_NULL); srqOccurred = 0; Agilent VISA User’s Guide...
  • Page 62: Using The Queuing Method

    The queuing method is generally used when an immediate response from your application is not needed. To use the queuing method for receiving notification that an event has occurred, you must do the following: • Enable one or several events with the viEnableEvent function. Agilent VISA User’s Guide...
  • Page 63 VI_QUEUE, VI_NULL); viWaitOnEvent(vi, VI_EVENT_SERVICE_REQ, VI_TMO_INFINITE, &eventType, &event); viClose(event); viDisableEvent(vi, VI_EVENT_SERVICE_REQ, VI_QUEUE); Enabling Events Before an event can be delivered, it must be enabled using the viEnableEvent function: viEnableEvent(vi, eventType, mechanism, context); These parameters are defined as follows: Agilent VISA User’s Guide...
  • Page 64 When using the viWaitOnEvent function, specify the session, the event type to wait for, and the timeout period to wait: viWaitOnEvent(vi, inEventType, timeout, outEventType, outContext); The event must have previously been enabled with VI_QUEUE specified as the mechanism parameter. Agilent VISA User’s Guide...
  • Page 65 ProgrammingSamples subdirectory. See the IO Libraries Suite Online Help for locations of example programs. /* evntqueu.c This sample program illustrates enabling an event queue using viWaitOnEvent. Note that you must change the device address. */ #include <visa.h> #include <stdio.h> Agilent VISA User’s Guide...
  • Page 66 Occurred! Event not received.\n"); return; /* print the event information */ printf("Trigger Event Occurred!\n"); printf("...Original Device Session = %ld\n", vi); /* get trigger that fired */ viGetAttribute(eventVi, VI_ATTR_RECV_TRIG_ID, &trigId); printf("Trigger that fired: "); switch(trigId){ case VI_TRIG_TTL0: Agilent VISA User’s Guide...
  • Page 67 VI_EVENT_TRIG, 10000, &eventType, &eventVi); if(err==VI_ERROR_TMO){ printf("Timeout Occurred! Event not received.\n"); return; printf("Got second event\n"); /* close the context before continuing */ viClose(eventVi); /* disable event */ viDisableEvent(vi, VI_EVENT_TRIG, VI_QUEUE); /* close the sessions */ viClose(vi); viClose(defaultRM); Agilent VISA User’s Guide...
  • Page 68: Trapping Errors

    VISA function call. ViStatus err; err=viPrintf(vi, "*RST\n"); if (err < VI_SUCCESS) err_handler(vi, err); Example: Printing Error Code The following error handler prints a user-readable string describing the error code passed to the function: void err_handler(ViSession vi, ViStatus err){ Agilent VISA User’s Guide...
  • Page 69: Exception Events

    VISA call is to use the VISA exception event. On sessions where an exception event handler is installed and VI_EVENT_EXCEPTION is enabled, the exception event handler is called whenever an error occurs while executing an operation. Agilent VISA User’s Guide...
  • Page 70 C++ exception is used. In this case, the application should delete the exception context as soon as the application has no more use for the context, before terminating the session. An application should use the viClose operation to delete the exception context. Agilent VISA User’s Guide...
  • Page 71 Access Privilege Data Type Range Default VI_ATTR_EVENT_TYPE Global ViEventType VI_EVENT_EXCEPTIO VI_ATTR_STATUS Global ViStatus VI_ATTR_OPER_NAME Global ViString Example: Exception Events /* This is an example of how to use exception events to trap VISA errors. An exception event Agilent VISA User’s Guide...
  • Page 72 = 0; viStatusDesc( vi, exceptionErrNbr, errStrBuffer ); printf("ERROR: Exception Handler reports\n" "(%s)\n","VISA function '%s' failed with error 0x%lx\n", "functionName, exceptionErrNbr, errStrBuffer ); return VI_SUCCESS; void main(){ ViStatus status; ViSession drm; ViSession vi; ViAddr myUserHandle = 0; Agilent VISA User’s Guide...
  • Page 73 */ status = viOpen( drm, "badVisaName", NULL, NULL, &vi ); if ( status < VI_SUCCESS ) { printf("ERROR: viOpen failed with error 0x%lx\n" "Exception Handler should have been called\n" "before this message was printed.\n",status Agilent VISA User’s Guide...
  • Page 74: Using Locks

    VI_NO_LOCK, VI_EXCLUSIVE_LOCK, or VI_SHARED_LOCK. The VISA viUnlock function is then used to release the lock on a resource. If a resource is locked and the current session does not have the lock, the error VI_ERROR_RSRC_LOCKED is returned. Agilent VISA User’s Guide...
  • Page 75: Visa Lock Types

    These exceptions, when applicable, are mentioned in the descriptions of the individual VISA functions and attributes. Agilent VISA User’s Guide...
  • Page 76 VI_NULL); /* Send an *IDN? string to the device */ viPrintf (vi, "*IDN?\n"); /* Read results */ viScanf (vi, "%t", &buf); /* Unlock this session so other processes and threads can use it */ viUnlock (vi); Agilent VISA User’s Guide...
  • Page 77 /* Open session to GPIB device at address 22 */ viOpenDefaultRM (&defaultRM); viOpen (defaultRM, "GPIB0::22::INSTR", VI_NULL,VI_NULL,&vi); /* acquire a shared lock so only this process and processes that we know about can access this resource */ viLock (vi, VI_SHARED_LOCK, 2000, VI_NULL, lockkey); Agilent VISA User’s Guide...
  • Page 78 /* unlock this session so other processes and threads can use it */ viUnlock (vi); /* Print results */ printf ("Instrument identification string: %s\n", buf); /* release the shared lock also*/ viUnlock (vi); /* Close session */ viClose (vi); viClose (defaultRM); Agilent VISA User’s Guide...
  • Page 79 Agilent IO Libraries Suite Agilent VISA User’s Guide 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. This chapter provides information to program GPIB and VXI devices via the GPIB, VXI or GPIB-VXI interfaces, including: •...
  • Page 80: Gpib And Vxi Interfaces Overview

    Connection Expert assigns a VISA interface name to the interface hardware, and other necessary configuration values for an interface when the interface is configured. See the Agilent IO Libraries Suite Online Help for details. VXI Device Types When using GPIB-VXI or VXI interfaces to directly access the VXI...
  • Page 81: Gpib Interfaces Overview

    PC, and one or more GPIB instruments connected to the GPIB cards via GPIB cable. I/O communication between the PC and the instruments is via the GPIB cards and the GPIB cable. The following figure shows GPIB instruments at addresses 3 and 5. Agilent VISA User’s Guide...
  • Page 82 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.
  • Page 83 Open IO path to GPIB instrument at address 5 using 82350 Card #1 viOpen (... "GPIB0::5::INSTR"...) Open IO path to GPIB instrument at address 3 using 82350 Card #1 viOpen (... "GPIB0::3::INSTR"...) Open IO path to GPIB instrument at address 3 using 82350 Card #2 viOpen (... "GPIB1::3::INSTR"...) Agilent VISA User’s Guide...
  • Page 84: Vxi Interfaces Overview

    Connection Expert utility has been used to assign the E8491 PC card a VISA name of VXI0. VISA addressing is as shown in the figure. For information on the E8491B module, see the Agilent E8491B User’s Guide. For information on VXI instruments, see the applicable VXI instrument User’s Guide.
  • Page 85: Gpib-Vxi Interfaces Overview

    GPIB card (82350 or equivalent) in a Windows PC that is connected via a GPIB cable to an E1406A Command Module. The E1406A sends commands to the VXI instruments in a VXI mainframe. There is no direct access to the VXI backplane from the PC. Agilent VISA User’s Guide...
  • Page 86 Example: GPIB-VXI (E1406A) Interface The GPIB-VXI interface system in the following figure consists of a Windows PC with an Agilent 82350 GPIB card that connects to an E1406A command module in a VXI mainframe. The VXI mainframe includes one or more VXI instruments.
  • Page 87 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.
  • Page 88: Using High-Level Memory Functions

    Reads 16 bits of data from the specified offset. viIn32 vi, space, offset, val32) Reads 32 bits of data from the specified offset. viOut8 vi, space, offset, val8) Writes 8 bits of data to the specified offset. Agilent VISA User’s Guide...
  • Page 89 Valid space values are: • VI_A16_SPACE - Maps in VXI/MXI A16 address space • VI_A24_SPACE - Maps in VXI/MXI A24 address space • VI_A32_SPACE - Maps in VXI/MXI A32 address space Agilent VISA User’s Guide...
  • Page 90: High-Level Memory Functions: Sample Programs

    Two sample programs follow that use the high-level memory functions to read the ID and Device Type registers of a device at the VXI logical address 24. The contents of the registers are then printed out. Agilent VISA User’s Guide...
  • Page 91 /* Read instrument id register contents */ viIn16(dmm, VI_A16_SPACE, 0x00, &id_reg); /* Read device type register contents */ viIn16(dmm, VI_A16_SPACE, 0x02, &devtype_reg); /* Print results */ printf ("ID Register = 0x%4X\n", id_reg); printf ("Device Type Register = 0x%4X\n", devtype_reg); Agilent VISA User’s Guide...
  • Page 92 /* Open session to VXI device at address 24 */ viOpenDefaultRM(&defaultRM); viOpen(defaultRM, "GPIB-VXI0::24::INSTR", VI_NULL,VI_NULL, &dmm); /* Read instrument id register contents */ viIn16(dmm, VI_A16_SPACE, 0x00, &id_reg); /* Read device type register contents */ viIn16(dmm, VI_A16_SPACE, 0x02, &devtype_reg); Agilent VISA User’s Guide...
  • Page 93 Programming via GPIB and VXI /* 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...
  • Page 94: Using Low-Level Memory Functions

    32-bit transfers. This table summarizes the low-level memory functions. Table 21 Summary of Low-Level Memory Functions Function Description viMapAddress(vi, Maps the specified memory space. mapSpace, mapBase, mapSize, access, suggested, address); viPeek8(vi, addr, val8); Reads 8 bits of data from address specified. Agilent VISA User’s Guide...
  • Page 95 If the device specified by vi does not have memory in the specified address space, an error is returned. Some sample viMapAddress function calls follow. /* Maps to A32 address space */ viMapAddress(vi, VI_A32_SPACE, 0x000, 0x100, VI_FALSE, VI_NULL,&address); Agilent VISA User’s Guide...
  • Page 96 &value) Unmapping Memory Space Make sure you use the viUnmapAddress function to unmap the memory space when it is no longer needed. Unmapping memory space makes the window available for the system to reallocate. Agilent VISA User’s Guide...
  • Page 97: Low-Level Memory Functions: Code Samples

    /* Open session to VXI device at address 24 */ viOpenDefaultRM(&defaultRM); viOpen(defaultRM, "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); Agilent VISA User’s Guide...
  • Page 98 GPIB-VXI0::24. Change this address if necessary. Register contents are then displayed.*/ #include <visa.h> #include <stdlib.h> #include <stdio.h> void main () { ViSession defaultRM, dmm; ViAddr address; unsigned short id_reg, devtype_reg; Agilent VISA User’s Guide...
  • Page 99 */ 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); Agilent VISA User’s Guide...
  • Page 100: Using Low/High-Level Memory I/O Methods

    • Memory pointers may be directly de-referenced in some cases for the lowest possible overhead. The disadvantages of low-level viPeek/viPoke are: • A viMapAddress call is required to set up mapping before viPeek/viPoke can be used. • viPeek/viPoke calls do not return status codes. Agilent VISA User’s Guide...
  • Page 101: Using High-Level Viin/Viout

    • There is no limit on number of active maps. • A16, A24, and A32 memory access can be mixed in a single vi session. • They provide the best performance when transferring large blocks of data. • They support both block and FIFO mode. Agilent VISA User’s Guide...
  • Page 102 (&defaultRM); viOpen defaultRM, VXI_INST, VI_NULL,VI_NULL, &vi); ================================================ Low level memory I/O = viPeek16 = direct memory dereference (when allowed) ================================================ /* Map into memory space */ viMapAddress (vi, VI_A16_SPACE, 0x00, 0x10, VI_FALSE,VI_NULL, &address); Agilent VISA User’s Guide...
  • Page 103 */ memPtr16 = (unsigned short *)address; /* do the actual memory reads */ id_reg = *memPtr16; devtype_reg = *(memPtr16+1); /* Print results */ printf ("dereference: ID Register = 0x%4X\n",id_reg); printf ("dereference: Device Type Register =0x%4X\n", devtype_reg); Agilent VISA User’s Guide...
  • Page 104 VI_ATTR_SRC_INCREMENT is 0, viMoveIn does a FIFO read. If the value of VI_ATTR_DEST_INCREMENT is 1 (the default),viMoveOut does a block write. If the value of VI_ATTR_DEST_INCREMENT is 0, viMoveOut does a FIFO write. ============================================= */ Agilent VISA User’s Guide...
  • Page 105 (vi, VI_A16_SPACE, 0x00, 2, memArray); /* Print results */ printf (" viMoveIn16: 1 ID Register = 0x%4X\n", memArray[0]); printf (" viMoveIn16: 2 ID Register = 0x%4X\n", memArray[1]); /* Close sessions */ viClose (vi); viClose (defaultRM); } Agilent VISA User’s Guide...
  • Page 106: Using The Memory Access Resource

    Low-level memory I/O services also allow register-level access to the interfaces that support direct memory access. Before an application can use the low-level service on the interface bus, it must map a range of addresses using the operation viMapAddress. Agilent VISA User’s Guide...
  • Page 107 ); printf( "ERROR 0x%lx (%s)\n ’%s’\n", status, errStr, buf ); if ( doexit == EXIT ) exit ( 1 ); void main() ViSession drm; ViSession vi; ViUInt16inData16 = 0; ViUInt16peekData16 = 0; ViUInt8*addr; Agilent VISA User’s Guide...
  • Page 108 */ viPeek16( vi, addr16, &peekData16 ); /* Now use viIn16 and read the contents of the same register */ status = viIn16(vi, VI_A16_SPACE, ViBusAddress)offset, &inData16 ); checkError(vi, status, "viIn16", NO_EXIT ); Agilent VISA User’s Guide...
  • Page 109: Memacc Attribute Descriptions

    A timeout value of VI_TMO_INFINITE disables the timeout mechanism. VI_ATTR_INTF_INST_NA Human-readable text describing the given interface. VI_ATTR_DMA_ALLOW_ Specifies whether I/O accesses should use DMA (VI_TRUE) or Programmed I/O (VI_FALSE). Agilent VISA User’s Guide...
  • Page 110 VI_ATTR_WIN_BASE_ADD Base address of the interface bus to which this window is mapped. VI_ATTR_WIN_SIZE Size of the region mapped to this window. Agilent VISA User’s Guide...
  • Page 111 GPIB-VXI Specific MEMACC Attributes The following read-only attributes provide specific address information about GPIB hardware. Table 24 Attributes that Provide Specific Address Information Attribute Description VI_ATTR_INTF_PARENT_NUM Board number of the GPIB board to which the GPIB-VXI is attached. Agilent VISA User’s Guide...
  • Page 112 Return code of the asynchronous I/O operation that has completed. VI_ATTR_JOB_ID Job ID of the asynchronous I/O operation that has completed. VI_ATTR_BUFFER Address of a buffer used in an asynchronous operation. VI_ATTR_RET_COU Actual number of elements that were asynchronously transferred. Agilent VISA User’s Guide...
  • Page 113: Using Vxi-Specific Attributes

    Specifies that the window is mapped and has a de-referenced address. In this case you can use the low-level memory functions to access the data, or you can use a C pointer. Using a de-referenced C pointer will allow faster access to data. Agilent VISA User’s Guide...
  • Page 114: Setting The Vxi Trigger Line

    The VI_ATTR_TRIG_ID attribute is used to set the VXI trigger line. This attribute is listed under generic attributes and defaults to VI_TRIG_SW (software trigger). To set one of the VXI trigger lines, set the VI_ATTR_TRIG_ID attribute as follows: viSetAttribute(vi, VI_ATTR_TRIG_ID, VI_TRIG_TTL0); Agilent VISA User’s Guide...
  • Page 115 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.) Table 27 VXI Trigger Lines and Values VXI Trigger...
  • Page 116 Programming via GPIB and VXI Agilent VISA User’s Guide...
  • Page 117 GPIB, serial (ASRL), or USB interface on the local machine to communicate with a LAN-connected device. See the Agilent IO Libraries Suite Online Help for information on how to start and stop the Remote IO Server software, and on how to create and configure LAN interfaces and remote GPIB/USB/serial interfaces.
  • Page 118: Lan And Remote Interfaces Overview

    With the Agilent IO Libraries Suite, you can connect to instruments across the LAN even if they do not have direct LAN capability, if they are connected to gateways (such as the Agilent E5810A) or to another PC running the Remote IO Server software.
  • Page 119 This reply contains the requested data and status information that indicates whether or not the operation was successful. The remote I/O server acts as a gateway between the LAN software that the client system supports and the instrument-specific interface that the device supports. Agilent VISA User’s Guide...
  • Page 120 Programming via LAN Windows PCs Client E5810 LAN/GPIB Gateway Remote Server GPIB Series 700 GPIB bus workstation or (or other) Windows PC GPIB GPIB LAN Instruments Instruments Instrument (VXI-11.2 GPIB Emulation VXI-11.3 LAN Instruments) Agilent VISA User’s Guide...
  • Page 121: Addressing Lan-Connected Devices

    LAN-connected devices. These can be devices connected directly to the LAN, or they can be connected to the LAN through a LAN gateway such as the Agilent E5810 LAN/GPIB gateway or through Remote IO Server software running on a remote computer with instruments connected to it.
  • Page 122 Although the SICL and VISA alias names are normally the same, if they are not, you must be sure to use the SICL alias and not the VISA alias. This device must use the SICL-LAN protocol since USB devices are not supported by the VXI-11 protocol. Agilent VISA User’s Guide...
  • Page 123 23 on a remote PC that is running a LAN server. The hostname of the remote PC is myMachine. See Chapter 3, “Programming with VISA”, for more information on addressing device sessions. ViSession defaultRM, vi;. viOpenDefaultRM(&defaultRM); viOpen(defaultRM, "TCPIP0::myMachine::gpib0,23::INSTR", VI_NULL, VI_NULL, &vi); viClose(vi); Agilent VISA User’s Guide...
  • Page 124: Using A Remote Interface For Lan Access

    A remote serial interface can use only the SICL-LAN protocol. A remote serial interface can be configured to use the serial port on the Agilent E5810 LAN/GPIB gateway or the serial ports on a PC running the Remote IO Server software.
  • Page 125 Remote IO Server software. A remote GPIB interface has been configured at GPIB2 to communicate with that machine. See Chapter 3, “Programming with VISA”, for more information on addressing device sessions. ViSession defaultRM, vi;. viOpenDefaultRM(&defaultRM); viOpen(defaultRM, "GPIB2::23::INSTR", VI_NULL, VI_NULL, &vi); viClose(vi); viClose(defaultRM); Agilent VISA User’s Guide...
  • Page 126 Programming via LAN Agilent VISA User’s Guide...
  • Page 127 Agilent IO Libraries Suite Agilent VISA User’s Guide 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).
  • Page 128: 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. Do not confuse the Agilent 82357 USB/GPIB Interface with a NOT E USBTMC device.
  • Page 129: Communicating With A Usb Instrument Using Visa

    To simplify the way a USB device is identified, Agilent VISA also provides an alias which can be used in place of this resource string. The first USB device that is plugged in is assigned a default alias of UsbDevice1.
  • Page 130 By using the alias in the program, however, you can use the same program in both test systems. All you need to do is make sure the same alias is used for the function generator in both systems. Agilent VISA User’s Guide...
  • Page 131 VISA resources. Agilent 488 An I/O library provided in Agilent IO Libraries Suite for compatibility with existing test & measurement programs that were developed using National Instruments’ NI-488 or other similar libraries.
  • Page 132 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. board-level Refers to Agilent 488 functions that operate on an interface (board), rather than on a device.
  • Page 133 In VISA, “communication channel” is synonymous with “session.” Every communication channel in VISA is unique. Connection Expert An Agilent software utility that helps you quickly establish connections between your instruments and your PC. It also helps you troubleshoot connectivity problems. Connection Expert is part of the Agilent IO Libraries Suite product.
  • Page 134 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. device driver Software code that communicates with a device: for example, a printer driver that communicates with a printer from a PC.
  • Page 135 A handle, returned from ibfind, that uniquely identifies a GPIB interface (board) in Agilent 488 original API calls. Also called a board descriptor or board unit descriptor. interface driver Software that communicates with an interface. The interface driver also handles commands used to perform communications on an interface.
  • Page 136 IO Control The icon in the Windows notification area (usually the lower right corner of your screen). The IO Control gives you access to Agilent I/O utilities such as Connection Expert, Agilent I/O documentation, and VISA options.
  • Page 137 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.
  • Page 138 A string, such as a VISA resource descriptor, that specifies the I/O address of a device. SCPI Standard Commands for Programmable Instrumentation: a standard set of commands, defined by the SCPI Consortium, to control programmable test and measurement devices in instrumentation systems. Agilent VISA User’s Guide...
  • Page 139 Every communication channel in VISA is unique. SICL Standard Instrument Control Library. SICL is an Agilent-defined API for instrument I/O. Agilent SICL is one of the IO Libraries installed with Agilent IO Libraries Suite. side-by-side A side-by-side installation allows two vendors' implementations of VISA to be used on the same computer.
  • Page 140 The information and logic represented in the left pane of the Connection Expert window. The task guide provides links to actions and information that help guide you through the most common I/O configuration tasks. taskbar notification area See notification area. Agilent VISA User’s Guide...
  • Page 141 VISA Virtual Instrument Software Architecture. VISA is a standard I/O library that allows software from different vendors to run together on the same platform. Agilent VISA is part of the Agilent IO Libraries Suite. VISA address A resource descriptor that can be used to open a VISA session.
  • Page 142 VISA resource template. VXI Resource Manager A software utility that initializes and prepares a VXI system for use. The VXI Resource Manager is part of the Agilent IO Libraries Suite. Agilent VISA User’s Guide...
  • Page 143 Glossary Windows notification area See notification area. Agilent VISA User’s Guide...
  • Page 144 Glossary Agilent VISA User’s Guide...
  • Page 145 (Low-Level) Memory VXI, 88, event handler, Functions, events Using the Queuing Method, callback, 46, Using the VXI Interface enable for callback, (High-Level) Memory installing handlers, enable for queuing, Functions, interrupts and events, handlers, hardware triggers, Agilent VISA User’s Guide...
  • Page 146 88, queuing and events, 46, setting trigger lines, raw I/O, wait on event, register programming web site, Agilent, high-level memory functions, low-level memory functions, resource manager, resource manager session, resources finding, locking, sample code Agilent VISA User’s Guide...

Table of Contents