National Instruments NI-488.2 NI-488.2 User Manual

National Instruments NI-488.2 NI-488.2 User Manual

National instruments network hardware - networking hardware user manual
Hide thumbs Also See for NI-488.2 NI-488.2:
Table of Contents

Advertisement

NI-488.2
TM
NI-488.2 User Manual
NI-488.2 User Manual
January 2007
370428F-01

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the NI-488.2 NI-488.2 and is the answer not in the manual?

Questions and answers

Summary of Contents for National Instruments NI-488.2 NI-488.2

  • Page 1 NI-488.2 NI-488.2 User Manual NI-488.2 User Manual January 2007 370428F-01...
  • Page 2 For further support information, see the Technical Support and Professional Services appendix. To comment on National Instruments documentation, refer to the National Instruments Web site at ni.com/info and enter the info code feedback. © 2002–2007 National Instruments Corporation. All rights reserved.
  • Page 3: Important Information

    Instruments Corporation. National Instruments respects the intellectual property of others, and we ask our users to do the same. NI software is protected by copyright and other intellectual property laws. Where NI software may be used to reproduce software or other materials belonging to others, you may use NI software only to reproduce materials that you may reproduce in accordance with the terms of any applicable license or other legal restriction.
  • Page 4: Table Of Contents

    Change GPIB Device Templates ...2-12 Enable/Disable NI-488.2 DOS Support...2-13 Access Additional Help and Resources ...2-13 NI-488.2 Online Help...2-13 National Instruments GPIB Web Site...2-13 View or Change GPIB-ENET/100 Network Settings...2-14 Device Configuration ...2-14 Update GPIB-ENET/100 Firmware ...2-14 © National Instruments Corporation...
  • Page 5 View or Change GPIB Interface Settings... 3-6 Access Additional Help and Resources... 3-8 NI-488.2 Online Help ... 3-8 National Instruments GPIB Web Site ... 3-8 View or Change GPIB-ENET/100 Network Settings ... 3-8 Device Configuration ... 3-9 Update GPIB-ENET/100 Firmware... 3-9 Chapter 4 Developing Your NI-488.2 Application...
  • Page 6 Exiting NI Spy ...6-3 Performance Considerations ...6-3 Chapter 7 Interactive Control Utility Overview...7-1 Getting Started with Interactive Control...7-1 Interactive Control Syntax ...7-4 Number Syntax...7-4 String Syntax ...7-5 Address Syntax...7-5 Interactive Control Commands ...7-5 © National Instruments Corporation Contents NI-488.2 User Manual...
  • Page 7 Contents Status Word ... 7-11 Error Information... 7-11 Count Information ... 7-12 Chapter 8 NI-488.2 Programming Techniques Termination of Data Transfers ... 8-1 High-Speed Data Transfers (HS488)... 8-2 Enabling HS488 ... 8-2 System Configuration Effects on HS488 ... 8-3 Waiting for GPIB Conditions... 8-4 Asynchronous Event Notification in NI-488.2 Applications ...
  • Page 8 Contents Appendix D Common Questions Appendix E Technical Support and Professional Services Glossary Index © National Instruments Corporation NI-488.2 User Manual...
  • Page 9: About This Manual

    To view these documents online, insert your NI-488.2 software distribution CD and browse to the documents at © National Instruments Corporation The Getting Started/Installation Guide briefly describes how to install the NI-488.2 software and your GPIB hardware. This manual describes the features and functionality of the NI-488.2 software.
  • Page 10: Accessing The Ni-488.2 Online Help

    Accessing the NI-488.2 Online Help The NI-488.2 Help addresses questions you might have about NI-488.2 and includes a function reference and troubleshooting information. Windows Select Start»Programs»National Instruments»Measurement & Automation. Select Help»Help Topics»NI-488.2. Mac OS X Select Applications»National Instruments»NI-488.2» Explore GPIB. Select Help»Help Topics»NI-488.2.
  • Page 11: Related Documentation

    The following documents contain information that you may find helpful as you read this manual: • • © National Instruments Corporation ANSI/IEEE Standard 488.1-2003, IEEE Standard Digital Interface for Programmable Instrumentation ANSI/IEEE Standard 488.2-1992, IEEE Standard Codes, Formats, Protocols, and Common Commands...
  • Page 12: Introduction

    With this design, you can link devices in a linear configuration, a star configuration, or a combination of the two configurations. Figure 1-1 shows the linear and star configurations. © National Instruments Corporation Device A Device B Device C a.
  • Page 13: Controlling More Than One Interface

    Chapter 1 Introduction Controlling More Than One Interface Figure 1-2 shows an example of a multi-interface system configuration. gpib0 is a GPIB-ENET/100 and is the access interface for the plotter and printer. GPIB Digital Voltometer Plotter Another GPIB Printer Configuration Requirements To achieve the high data transfer rate that the GPIB was designed for, you must limit the number of devices on the bus and the physical distance between devices.
  • Page 14 You can order bus extenders and expanders from National Instruments. © National Instruments Corporation All devices in the system must be powered on. Cable lengths must be as short as possible with up to a maximum of 15 m of cable for each system.
  • Page 15: Measurement & Automation Explorer (Windows)

    • • • • • • © National Instruments Corporation Linux). Establish basic communication with your GPIB instruments. Scan for instruments connected to your GPIB interface. Launch the NI-488.2 Troubleshooting Utility to troubleshoot GPIB and NI-488.2 problems. Launch NI Spy to monitor NI-488.2 or VISA API calls to GPIB interfaces.
  • Page 16: Starting Measurement & Automation Explorer

    Measurement & Automation Explorer (Windows) Starting Measurement & Automation Explorer To start Measurement & Automation Explorer, select Start»Programs» National Instruments»Measurement & Automation. Figure 2-1 shows Measurement & Automation Explorer. Note When starting Measurement & Automation Explorer in Windows Vista, you must choose to run as Adminstrator to allow changes to GPIB Interface Settings.
  • Page 17: Troubleshoot Ni-488.2 Problems

    Troubleshoot NI-488.2 Problems To troubleshoot NI-488.2 problems, run the NI-488.2 Troubleshooting Utility, as follows: © National Instruments Corporation Chapter 2 Start Measurement & Automation Explorer as described in the Starting Measurement & Automation Explorer Select Help»Troubleshooting»NI-488.2 Troubleshooting Utility. The Troubleshooting Utility tests your GPIB interface and displays the results, as shown in Figure 2-2.
  • Page 18: Add A New Gpib Interface

    Chapter 2 Measurement & Automation Explorer (Windows) Add a New GPIB Interface For plug-and-play interfaces (such as PCI or USB), the system automatically detects and installs the hardware. To add a new GPIB-ENET/100 to your system, complete the following steps: Remove a GPIB Interface To remove a Plug and Play interface from your computer, disconnect it, making sure to turn off the computer if the interface requires it.
  • Page 19: Scan For Gpib Instruments

    If Measurement & Automation Explorer reports that it found too many Listeners on the GPIB, refer to the following possible solutions: • • © National Instruments Corporation Chapter 2 Make sure that your instrument is powered on and connected to your GPIB interface.
  • Page 20: Communicate With Your Instrument

    Chapter 2 Measurement & Automation Explorer (Windows) Communicate with Your Instrument To establish basic or advanced communication with your instruments, refer to the following sections. For more information about instrument communication and a list of the commands that your instrument understands, refer to the documentation that came with your GPIB instrument.
  • Page 21 To view sample C/C++ code that performs a simple query of a GPIB instrument, click the Show Sample button. © National Instruments Corporation Chapter 2 Figure 2-3. NI-488.2 Communicator Type a command in the Send String field and do one of the following: •...
  • Page 22: Advanced Communication

    Chapter 2 Measurement & Automation Explorer (Windows) Advanced Communication For advanced interactive communication with GPIB instruments, use the Interactive Control utility, as follows: To view the online help for Interactive Control, type Control command prompt. For more information on using this utility, refer to Chapter 7, View NI-488.2 Software Version To view the NI-488.2 software version, complete the following steps:...
  • Page 23: Monitor, Record, And Display Ni-488.2 Calls

    To monitor NI-488.2 calls, use NI Spy, as follows: For more information about using NI Spy, select Help»Help Topics in NI Spy or refer to Chapter 6, © National Instruments Corporation Chapter 2 Start Measurement & Automation Explorer as described in the Starting Measurement &...
  • Page 24: View Or Change Gpib Interface Settings

    Chapter 2 Measurement & Automation Explorer (Windows) View or Change GPIB Interface Settings To view or change your interface settings, complete the following steps: Note When starting Measurement & Automation Explorer in Windows Vista, you must choose to run as Adminstrator to allow changes to GPIB Interface Settings. To do this, right-click on the Measurement &...
  • Page 25 Chapter 2 Measurement & Automation Explorer (Windows) Figure 2-5. GPIB Interface Properties in Measurement & Automation Explorer (Optional) Change the settings for your interface and click Save to apply the settings. © National Instruments Corporation 2-11 NI-488.2 User Manual...
  • Page 26: View Gpib Instrumentation Information

    Chapter 2 Measurement & Automation Explorer (Windows) View GPIB Instrumentation Information To view information about your GPIB instruments, complete the following steps: Change GPIB Device Templates For older NI-488.2 applications, you might need to modify one of the device templates to find a given GPIB instrument by name, for example, ibfind("fluke45") preferred ibfind...
  • Page 27: Enable/Disable Ni-488.2 Dos Support

    You can access the NI-488.2 online help as follows: National Instruments GPIB Web Site You can access the National Instruments GPIB Web site as follows: © National Instruments Corporation Chapter 2 Rename the template as described in your application documentation.
  • Page 28: View Or Change Gpib-Enet/100 Network Settings

    Chapter 2 Measurement & Automation Explorer (Windows) View or Change GPIB-ENET/100 Network Settings To view or change the network settings of your GPIB-ENET/100, refer to the following sections. For more information about your GPIB-ENET/100 network settings, refer to the GPIB-ENET/100 information in the GPIB Hardware Guide.
  • Page 29: Gpib Explorer (Mac Os X And Linux)

    You can perform the following GPIB-related tasks in GPIB Explorer: • • • • • © National Instruments Corporation Add or remove GPIB interfaces. Reconfigure GPIB interface settings. Launch the NI-488.2 Troubleshooting Wizard to troubleshoot GPIB and NI-488.2 problems. Launch NI Spy to monitor NI-488.2 calls to GPIB interfaces.
  • Page 30: Starting Gpib Explorer

    GPIB Explorer (Mac OS X and Linux) Starting GPIB Explorer Mac OS X To start GPIB Explorer from the Finder, double-click on Applications» National Instruments»NI-488.2»Explore GPIB. Figure 3-1 shows GPIB Explorer in Mac OS X. NI-488.2 User Manual Figure 3-1. GPIB Explorer (Mac OS X)
  • Page 31: Linux

    Linux To start GPIB Explorer, enter the following command: /usr/local/natinst/ni4882/bin/gpibexplorer Figure 3-2 shows GPIB Explorer in Linux. © National Instruments Corporation Chapter 3 GPIB Explorer (Mac OS X and Linux) Figure 3-2. GPIB Explorer (Linux) NI-488.2 User Manual...
  • Page 32: Add A New Gpib Interface

    Acrobat Reader, which you can download from www.adobe.com Mac OS X The GPIB Hardware Guide is installed with NI-488.2. To access this document, double-click Applications»National Instruments» NI-488.2»Documentation. Linux The GPIB Hardware Guide is installed with NI-488.2. It is in the...
  • Page 33: Delete A Gpib Interface

    Acrobat Reader, which you can download from www.adobe.com Mac OS X The GPIB Hardware Guide is installed with NI-488.2. To access this document, double-click Applications»National Instruments» NI-488.2»Documentation. Linux The GPIB Hardware Guide is installed with NI-488.2. It is in the...
  • Page 34: View Or Change Gpib Interface Settings

    Chapter 3 GPIB Explorer (Mac OS X and Linux) View or Change GPIB Interface Settings To view or change your interface settings, complete the following steps: NI-488.2 User Manual Start GPIB Explorer as described in the section. Click on your GPIB interface and click Properties. The Properties dialog box appears.
  • Page 35 GPIB Explorer (Mac OS X and Linux) Linux Figure 3-4 shows the Properties dialog box for a GPIB-ENET/100 for Linux. Figure 3-4. Properties Dialog Box (Linux) (Optional) Change the settings for your interface, then click the OK button. © National Instruments Corporation NI-488.2 User Manual...
  • Page 36: Access Additional Help And Resources

    Select Help»Help Topics»NI-488.2 from the menu bar. Start GPIB Explorer as described in the section. Select Help»National Instruments on the Web»GPIB Home Page from the menu bar to access the National Instruments Web site for GPIB. Starting GPIB Explorer Starting GPIB Explorer www.adobe.com...
  • Page 37: Device Configuration

    Device Configuration Mac OS X To run the NI Ethernet Device Configuration utility from the Finder, double-click on Applications»National Instruments»NI-488.2» EthernetConfig. Linux To run the NI Ethernet Device Configuration utility, enter the following command: /usr/local/natinst/ni4882/bin/ethernetconfig For more information about the NI Ethernet Device Configuration utility, refer to the GPIB-ENET/100 information in the GPIB Hardware Guide.
  • Page 38: Interactive Instrument Control

    Utility. To view the online help for Interactive Control, type Interactive Control command prompt. Windows Mac OS X © National Instruments Corporation Select Start»Programs»National Instruments»Measurement & Automation to start Measurement & Automation Explorer. Select Tools»NI-488.2»Interactive Control. At the command prompt, type NI-488.2 API calls to communicate interactively with your instrument.
  • Page 39: Choosing Your Programming Methodology

    Chapter 4 Developing Your NI-488.2 Application Linux Choosing Your Programming Methodology Based on your development environment, you can select a method for accessing the driver, and based on your NI-488.2 programming needs, you can choose how to use the NI-488.2 API. Choosing a Method to Access the NI-488.2 Driver Applications gain access to the NI-488.2 API using an NI-488.2 language interface.
  • Page 40: Choosing How To Use The Ni-488.2 Api

    GPIB functions. If you use these functions, you need to understand GPIB management details such as how to address talkers and listeners. Refer to Appendix A, © National Instruments Corporation Chapter 4 —a dynamic library you can use from your libgpibapi.so...
  • Page 41: Using Multiple Interfaces And/Or Multiple Devices

    Chapter 4 Developing Your NI-488.2 Application The set of low-level functions are called board-level functions. They access the interface directly and require you to handle the addressing and bus management protocol. These functions give you the flexibility and control to handle situations such as the following: •...
  • Page 42: Status Word (Ibsta)

    Conditions. Mnemonic TIMO SRQI CMPL TACS LACS © National Instruments Corporation Chapter 4 is the return value of all the traditional NI-488.2 calls, ibsta . You can examine various status bits in ibfind ibdev is a 16-bit value. A bit value of one (1) indicates that a certain...
  • Page 43: Error Variable (Iberr)

    Chapter 4 Developing Your NI-488.2 Application Mnemonic DTAS DCAS The language header file defines each of the test for an in C/C++). For example, the & To check for an NI-488.2 error, use the following statement after each NI-488.2 call: if (ibsta &...
  • Page 44: Using Interactive Control To Communicate With Devices

    Include the following items in your application: • • • © National Instruments Corporation Chapter 4 Header files—In a C application, include the header file which contains prototypes for the NI-488.2 calls and constants that you can use in your application.
  • Page 45: General Program Steps And Examples

    Chapter 4 Developing Your NI-488.2 Application General Program Steps and Examples The following steps show you how to use the traditional NI-488.2 device-level calls in your application. The NI-488.2 software includes the devquery Initialization Step 1. Open a Device following parameters: •...
  • Page 46: Applications That Use Multiple Interfaces Or Communicate With Multiple Gpib Devices

    The following steps show you how to use the multi-device NI-488.2 calls in your application. The NI-488.2 software includes the code examples to demonstrate these principles. © National Instruments Corporation Chapter 4 to send the query command to the device.
  • Page 47 Chapter 4 Developing Your NI-488.2 Application Initialization Step 1. Become Controller-In-Charge (CIC) interface is Controller-In-Charge (CIC). The only argument of the GPIB interface number, typically 0 for Step 2. Determine the GPIB Address of Your Device function requires the following parameters: •...
  • Page 48: Language-Specific Programming Instructions For Windows

    #include <windows.h> #include "ni488.h" To compile and link a Win32 console application named in a DOS shell, type the following on the command line: cl cprog.c gpib-32.obj © National Instruments Corporation Chapter 4 to send the SendList "*IDN?" is the command message to the device.
  • Page 49: Borland C/C++ (Version 4.0 Or Later)

    Chapter 4 Developing Your NI-488.2 Application Borland C/C++ (Version 4.0 or Later) Before you compile your Win32 C application, make sure that the following lines are included at the beginning of your program: #include <windows.h> #include "ni488.h" To compile and link a Win32 console application named in a DOS shell, type the following on the command line: bcc32 -w32 cprog.c borlandc_gpib-32.obj Visual Basic (Version 4.0 or Later)
  • Page 50: Directly Accessing The Gpib-32.Dll Exports

    #ifdef __cplusplus extern "C"{ #endif #include <windows.h> #include "ni488.h" #ifdef __cplusplus #endif © National Instruments Corporation Chapter 4 passing the name of the function as a parameter. For Using the NI-488.2 Documentation Manual. ibfind ibrdf requires an interface or device name and ibfind require a file name.
  • Page 51 Chapter 4 Developing Your NI-488.2 Application In your Win32 application, you need to load accessing the you how to call the check for an error: HINSTANCE Gpib32Lib = NULL; Gpib32Lib=LoadLibrary("GPIB-32.DLL"); if (Gpib32Lib == NULL) { For the prototypes for each function, refer to the NI-488.2 online help. For instructions on accessing the online help, refer to the NI-488.2 Documentation For functions that return an integer value, like...
  • Page 52 = (*Pibdev) (0, 1, 0, T10s, 1, 0); if (*Pibsta & ERR) { © National Instruments Corporation Chapter 4 (int ud, int pad, int sad, int tmo, int eot, int eos);...
  • Page 53: Language-Specific Programming Instructions For Mac Os X

    Chapter 4 Developing Your NI-488.2 Application Before exiting your application, you need to free following command: FreeLibrary(Gpib32Lib); For more examples of directly accessing entry sample programs with the NI-488.2 software. For more information about direct entry, refer to the online help for your development environment. Language-Specific Programming Instructions for Mac OS X The following information describes how to develop, compile, and link...
  • Page 54 The advantage of the latter way of compiling and linking your application is that it allows your application to run regardless of whether the NI-488.2 software is installed, as long as it does not make any NI-488.2 calls. © National Instruments Corporation 4-17 NI-488.2 User Manual...
  • Page 55: Debugging Your Application

    About This NI-488.2 Error Codes The error variable, status variable, possible solutions, refer to Appendix C, © National Instruments Corporation NI Spy , and ) are updated. If you are developing an ibcnt ibcntl contains a value that defines the error. In some iberr contains even more error information.
  • Page 56: Configuration Errors

    In these cases, you can either reconfigure from your application using the ibconfig Note National Instruments recommends using If your application uses previous configuration. For more information about using refer to the description of...
  • Page 57: Communication Errors

    You can either reconfigure from your application using ibconfig Note National Instruments recommends using If your application uses previous configuration. For more information about the description of...
  • Page 58: Ni Spy Utility

    NI Spy Utility This chapter introduces you to NI Spy, a utility that monitors and records multiple National Instruments APIs (for example, NI-488.2 and NI-VISA). Overview NI Spy monitors, records, and displays the NI-488.2 calls made from NI-488.2 applications. You can use it to troubleshoot errors in your application and to verify the communication with your GPIB instrument.
  • Page 59: Monitoring Api Calls With Ni Spy

    Chapter 6 NI Spy Utility Monitoring API Calls with NI Spy To display NI-488.2 API calls as they are made, do the following: Using the NI Spy Online Help To view the built-in, context-sensitive online help for the NI Spy utility, select Help»Help Topics in NI Spy.
  • Page 60: Debugging Existing Applications

    For this reason, use NI Spy only while you are debugging your application or in situations where performance is not critical. © National Instruments Corporation Conditions, and Appendix C, Using the NI-488.2 Documentation Manual.
  • Page 61: Interactive Control Utility

    This section shows you how to use the Interactive Control utility to test a sequence of NI-488.2 calls. For help on any Interactive Control command, type command. For example, type © National Instruments Corporation Results of the status word ( ibsta Mnemonic constant of each bit set in...
  • Page 62 Chapter 7 Interactive Control Utility To start the Interactive Control utility, complete the following steps: Windows Mac OS X Double-click on Applications»National Instruments»NI-488.2» Interactive Control. Linux Enter the following command: <InstallDir> /natinst/ni4882/bin/gpibintctrl where NI-488.2 software. The default is To use the Interactive Control utility to test a sequence of NI-488.2 calls, complete the following steps: NI-488.2 User Manual...
  • Page 63 (0–99) to which you have connected your device. Then use command to discover the address of your device. For help using FindLstn enter help findlstn © National Instruments Corporation at the command prompt. After you successfully complete The new prompt, , represents a device-level handle that you can use for further NI-488.2 calls.
  • Page 64: Interactive Control Syntax

    Chapter 7 Interactive Control Utility Interactive Control Syntax The following special rules apply to making calls from the Interactive Control utility: • • • • Number Syntax You can enter numbers in either hexadecimal or decimal format. Hexadecimal numbers—You must prefix hexadecimal numbers with For example, (22 decimal).
  • Page 65: String Syntax

    Interactive Control utility. For more information about the function parameters, use the online help, available by typing in name, the Interactive Control utility prompts you for parameters. © National Instruments Corporation represents a carriage return character and 1,0xb706,3 Chapter 7...
  • Page 66 Chapter 7 Interactive Control Utility Table 7-1. Syntax for Device-Level Traditional NI-488.2 Calls in Interactive Control Syntax Return configuration information where ibask option a configuration parameter. Clear specified device. ibclr Alter configurable parameters where ibconfig option a configuration parameter. value Open an unused device;...
  • Page 67 Check for presence of device on the GPIB at ibln pad sad Go to local. ibloc © National Instruments Corporation Description is a hex or decimal integer or a list mask ibwait TIMO CMPL is pathname of file to write.
  • Page 68 Chapter 7 Interactive Control Utility Table 7-2. Syntax for Board-Level Traditional NI-488.2 Calls in Interactive Control (Continued) Syntax Start an asynchronous wait for selected events where mask is a hex or ibnotify mask decimal integer or a list of mask bit mnemonics (for example, TIMO CMPL Place device online or offline.
  • Page 69 SendCmds buffer SendDataBytes buffer eotmode SendIFC SendList addrlist buffer eotmode SendLLO SendSetup addrlist SetRWLS addrlist TestSRQ © National Instruments Corporation Chapter 7 Description Serial poll multiple devices. Clear a device. Clear multiple devices. Enable local control. Enable remote control. Find all Listeners.
  • Page 70 Chapter 7 Interactive Control Utility Table 7-3. Syntax for Multi-Device NI-488.2 Calls in Interactive Control (Continued) Syntax TestSys addrlist Trigger address TriggerList addrlist WaitSRQ Table 7-4. Auxiliary Functions in Interactive Control Function Select active device or interface where set udname new device or interface (for example, initially to open each device or interface.
  • Page 71: Status Word

    This indicates that either the GPIB device is powered off or the GPIB cable is disconnected. For a detailed list of the error codes and possible solutions, refer to Appendix C, © National Instruments Corporation ) return the status word ibsta , refer to Appendix B,...
  • Page 72: Count Information

    Chapter 7 Interactive Control Utility Count Information When an I/O function completes, the Interactive Control utility displays the actual number of bytes sent or received, regardless of the existence of an error condition. If one of the addresses in an address list to a multi-device NI-488.2 call is invalid, then the error is EARG and the Interactive Control utility displays the index of the invalid address as the count.
  • Page 73: Ni-488.2 Programming Techniques

    You can use the modes. EOS mode configuration includes the following information: • • • © National Instruments Corporation section in function to enable or disable the end of transmission ibeot function to enable, disable, or configure the EOS ibeos A 7-bit or 8-bit EOS byte.
  • Page 74: High-Speed Data Transfers (Hs488)

    High-Speed Data Transfers (HS488) National Instruments has designed a high-speed data transfer protocol for IEEE 488 called HS488. This protocol increases performance for GPIB reads and writes up to 8 Mbytes/s, depending on your system.
  • Page 75: System Configuration Effects On Hs488

    HS488 decreases. For example, two HS488 devices connected by two meters of cable can transfer data faster than four HS488 devices connected by 4 m of cable. © National Instruments Corporation Chapter 8 NI-488.2 Programming Techniques...
  • Page 76: Asynchronous Event Notification In Ni-488.2 Applications

    Chapter 8 NI-488.2 Programming Techniques Waiting for GPIB Conditions You can use the suspend your application until a specified condition occurs on the GPIB. If you use and returns. If you want to use occur, pass a wait mask to the function. The wait mask should always include the TIMO event;...
  • Page 77 (for example, a semaphore) to protect access to any globals. For more information about the use of synchronization primitives, refer to the documentation about using operating system synchronization objects that came with your development tools. © National Instruments Corporation Chapter 8 ibnotify...
  • Page 78: Ibnotify Programming Example

    Chapter 8 NI-488.2 Programming Techniques ibnotify Programming Example The following code is an example of how you can use application. Assume that your GPIB device is a multimeter that you program it to acquire a reading by sending " requests service when it has a reading ready, and each reading is a floating point value.
  • Page 79 // Call the ibonl function to disable the hardware and software. ibonl (ud, 0); return 1; int __stdcall MyCallback (int LocalUd, int LocalIbsta, int LocalIberr, long LocalIbcntl, void *RefData) char SpollByte; char ReadBuffer[40]; © National Instruments Corporation // EOS mode disabled Chapter 8 NI-488.2 Programming Techniques NI-488.2 User Manual...
  • Page 80 Chapter 8 NI-488.2 Programming Techniques // If the ERR bit is set in LocalIbsta, then print an error // message and return. if (LocalIbsta & ERR) printf ("GPIB error %d has occurred. No more callbacks.\n", DeviceError = TRUE; return 0; // Read the serial poll byte from the device.
  • Page 81: Writing Multithreaded Ni-488.2 Applications

    NI-488.2 global variables without some form of synchronization (for example, semaphores, mutexes, critical sections). To understand why, refer to the following example. © National Instruments Corporation Chapter 8 printf ("ibwrt failed. No more callbacks.\n"); DeviceError = TRUE;...
  • Page 82 Chapter 8 NI-488.2 Programming Techniques Assume that a process has two separate threads that make NI-488.2 calls, thread 1 and thread 2. Just as thread 1 is about to examine one of the NI-488.2 globals, it gets preempted and thread 2 is allowed to run. Thread 2 proceeds to make several NI-488.2 calls that automatically update the NI-488.2 globals.
  • Page 83: Device-Level Calls And Bus Management

    If the current CIC does not pass control, the NI-488.2 driver returns the ECIC error code to your application. If this happens, you could send a device-specific command requesting control for the GPIB interface. Then, use a board-level © National Instruments Corporation lines at the top of your C file: #define ThreadIbsta()
  • Page 84: Talker/Listener Applications

    Chapter 8 NI-488.2 Programming Techniques Talker/Listener Applications Although designed for Controller-In-Charge applications, you can also use the NI-488.2 software in most non-Controller situations. These situations are known as Talker/Listener applications because the interface is not the GPIB Controller. A Talker/Listener application typically uses monitor the status of the interface.
  • Page 85: Service Requests From Ieee 488 Devices

    If you want your application to conduct a serial poll automatically when the SRQ line is asserted, you can enable automatic serial polling. The autopolling procedure occurs as follows: © National Instruments Corporation To enable autopolling, use the board-level configuration function, , with option...
  • Page 86: Stuck Srq State

    Chapter 8 NI-488.2 Programming Techniques Stuck SRQ State If autopolling is enabled and the GPIB interface detects an SRQ, the driver serial polls all open devices connected to that interface. The serial poll continues until either SRQ unasserts or all the devices have been polled. If no device responds positively to the serial poll, or if SRQ remains in effect because of a faulty instrument or cable, a stuck SRQ state is in effect.
  • Page 87: Srq And Serial Polling With Device-Level Traditional Ni-488.2 Calls

    SRQ servicing and serial polling are FindRQS the calls: • • © National Instruments Corporation conducts a single serial poll and returns the serial poll ibrsp to suspend program execution until RQS ibwait . The program can then call ibsta printf ( "Device asserted SRQ.\n"...
  • Page 88: Example 1: Using Findrqs

    Chapter 8 NI-488.2 Programming Techniques • • • The following examples use these calls to detect SRQ and then determine which device requested service. In these examples, three devices are present on the GPIB at addresses 3, 4, and 5, and the GPIB interface is designated as bus index 0.
  • Page 89: Example 2: Using Allspoll

    GPIB interface is not the Controller, and the interface must configure itself for a parallel poll and set its own individual status bit ( © National Instruments Corporation int WaitResult; WaitSRQ (0, &WaitResult); if ( WaitResult ) { printf ( "SRQ is asserted.\n"...
  • Page 90: Parallel Polling With Traditional Ni-488.2 Calls

    Chapter 8 NI-488.2 Programming Techniques Parallel Polling with Traditional NI-488.2 Calls Complete the following steps to implement parallel polling using traditional NI-488.2 calls. Each step contains example code. NI-488.2 User Manual Configure the device for parallel polling using the unless the device can configure itself for parallel polling. requires an 8-bit value to designate the data line number, ibppc sense, and whether the function configures the device for...
  • Page 91: Parallel Polling With Multi-Device Ni-488.2 Calls

    Complete the following steps to implement parallel polling using multi-device NI-488.2 calls. Each step contains example code. © National Instruments Corporation In the following example, the GPIB interface is to configure itself to participate in a parallel poll. It asserts DIO5 when poll is conducted.
  • Page 92 Chapter 8 NI-488.2 Programming Techniques NI-488.2 User Manual Conduct the parallel poll using the response for a certain value. In the following example, because DIO5 is asserted by the device if bit 4 (hex 10) in the response to determine the value of PPoll(0, &response);...
  • Page 93: Gpib Basics

    Some devices are capable of playing more than one role. A digital voltmeter, for example, can be a Talker and a Listener. If your system has a National Instruments GPIB interface and software installed, it can function as a Talker, Listener, and Controller.
  • Page 94: Gpib Addressing

    Appendix A GPIB Basics GPIB Addressing All GPIB devices and interfaces must be assigned a unique GPIB address. A GPIB address is made up of two parts: a primary address and an optional secondary address. The primary address is a number in the range 0 to 30. The Controller uses this address to form a talk or listen address that is sent over the GPIB when communicating with a device.
  • Page 95: Data Lines

    Table A-2 summarizes the GPIB interface management lines. (attention) (interface clear) (remote enable) © National Instruments Corporation Table A-1. GPIB Handshake Lines Line Listening device is ready/not ready to receive a message byte. Also used by the Talker to signal high-speed (HS488) GPIB transfers.
  • Page 96 Appendix A GPIB Basics (service request) (end or identify) NI-488.2 User Manual Table A-2. GPIB Interface Management Lines (Continued) Line Any device can drive the SRQ line to asynchronously request service from the Controller. Talker uses the EOI line to mark the end of a data message.
  • Page 97: Appendix B Status Word Conditions

    Mnemonic Bit Pos TIMO SRQI CMPL TACS LACS DTAS DCAS © National Instruments Corporation ibsta ibsta Using the NI-488.2 Documentation can be set for device calls (dev), board calls (brd), ibsta Table B-1. Status Word Layout Hex Value Type 8000...
  • Page 98 Appendix B Status Word Conditions ERR (dev, brd) ERR is set in the status word following any call that results in an error. You can determine the particular error by examining the error variable iberr that are recorded in following any call that does not result in an error. TIMO (dev, brd) TIMO indicates that the timeout period has expired.
  • Page 99 GPIB interface or by another Controller. LOK is cleared when the System Controller unasserts the Remote Enable (REN) GPIB line. © National Instruments Corporation . You can also wait for a device to request ibsta call is inoperative for that interface.
  • Page 100 Appendix B Status Word Conditions REM (brd) REM indicates whether the interface is in the remote state. REM is set whenever the Remote Enable (REN) GPIB line is asserted and the GPIB interface detects that its listen address has been sent either by the GPIB interface or by another Controller.
  • Page 101 The same is true of reads and writes. If you call a read or write function such as aborted. DCAS is cleared from © National Instruments Corporation call, if the DTAS bit is set in the function to wait for DCAS and the...
  • Page 102: Error Codes And Solutions

    Error Codes and Solutions This appendix lists a description of each error, some conditions under which it might occur, and possible solutions. Table C-1 lists the GPIB error codes. Mnemonic © National Instruments Corporation Table C-1. GPIB Error Codes Error iberr Value...
  • Page 103: Appendix C Error Codes And Solutions

    EDVR is also returned if there is an internal driver error. Solutions Possible solutions for this error are as follows: • • • Windows Mac OS X Run Applications»National Instruments»NI-488.2»Troubleshoot. NI-488.2 User Manual Table C-1. GPIB Error Codes (Continued) Error iberr Mnemonic Value EHDL...
  • Page 104 Solutions Possible solutions for this error are as follows: • • • © National Instruments Corporation is the directory where you chose to install NI-488.2. <InstallDir> /usr/local Use the unit descriptor returned from parameter in subsequent traditional NI-488.2 calls. Examine the variable before the failing function to make sure its value has not been corrupted.
  • Page 105 Appendix C Error Codes and Solutions ENOL (2) ENOL usually occurs when a write operation is attempted with no Listeners addressed. For a device write, ENOL indicates that the GPIB address configured for that device in the software does not match the GPIB address of any device connected to the bus, that the GPIB cable is not connected to the device, or that the device is not powered on.
  • Page 106 Talker has stopped talking), or the byte count in the call which timed out was more than the other device was expecting. © National Instruments Corporation called with a value not in the range 0 through 17.
  • Page 107 Make sure there is a GPIB interface in your computer that is properly configured both in hardware and software using a valid base I/O address by running the NI-488.2 Troubleshooting Utility, as follows: Windows Mac OS X Run Applications»National Instruments»NI-488.2»Troubleshoot. Linux Enter the following command: <InstallDir> /natinst/ni4882/bin/gpibtsw where NI-488.2 software.
  • Page 108 Solutions Check the validity of the call, or make sure your GPIB interface and the driver both have the needed capability. © National Instruments Corporation , and ibnotify ibwait ibonl...
  • Page 109 Appendix C Error Codes and Solutions EFSO (12) EFSO results when an performing a file operation. Specifically, this error indicates that the function is unable to open, create, seek, write, or close the file being accessed. Solutions Possible solutions for this error are as follows: •...
  • Page 110 In the case of FindRQS asserting SRQ. Disconnect them from the GPIB if necessary. © National Instruments Corporation Usually, a device unknown to the software is asserting SRQ. Because the software does not know of this device, it can never serial poll the device and unassert SRQ.
  • Page 111 Appendix C Error Codes and Solutions ELCK (21) ELCK indicates that the requested operation could not be performed because of an existing lock by another process accessing the same interface. ELCK is also returned when a process attempts to unlock an interface for which it currently has no lock.
  • Page 112 ERST results when an event notification was cancelled due to a reset of the interface. situations: • • situations: • © National Instruments Corporation outside the range of 0–99 is passed in to a traditional boardID NI-488 board-level function or NI-488.2 routine. is called with a device unit descriptor and ibconfig ibask a board-only configuration option, or with a board unit descriptor and a device-only configuration option.
  • Page 113 Appendix C Error Codes and Solutions Solutions Do not call Prevent other applications from calling with EPWR (28) EPWR results when an interface loses power. This often results when the system goes to and returns from a standby state. Solutions Take all handles offline and reinitialize the application.
  • Page 114: Common Questions

    In most cases, device-level traditional NI-488.2 calls are sufficient for communicating with instruments. For more information, refer to Chapter 4, © National Instruments Corporation Interactive Control Developing Your NI-488.2 Application. Developing Your NI-488.2 Application.
  • Page 115 NI-488.2 software. The default is What information should I have before I call National Instruments? Before you call National Instruments, record the results of the NI-488.2 Troubleshooting Utility. How can I determine if my GPIB hardware and the NI-488.2 software are installed properly? Run the NI-488.2 Troubleshooting Utility as described previously on this...
  • Page 116 Refer to the Troubleshooting topics in the NI-488.2 Online Help for information about what might cause this problem. If you cannot resolve the problem, contact National Instruments. How can I determine which type of GPIB hardware I have installed? Select Start»Programs»National Instruments»Measurement &...
  • Page 117: Technical Support And Professional Services

    Technical Support and Professional Services Visit the following sections of the National Instruments Web site at ni.com • • • If you searched your local office or NI corporate headquarters. Phone numbers for our worldwide offices are listed at the front of this manual. You also can visit...
  • Page 118 GPIB SRQ line. Also called autopolling. base I/O address BIOS Basic Input/Output System. board-level function A rudimentary function that performs a single operation. © National Instruments Corporation Value –9 –3 address. source handshake and handshake.
  • Page 119 Glossary Configuration Enable—The GPIB command which precedes CFGn and is used to place devices into their configuration mode. CFGn These GPIB commands (CFG1 through CFG15) follow CFE and are used to configure all devices for the number of meters of cable in the system so HS488 transfers occur without errors.
  • Page 120 (MLA and MTA) and perhaps a secondary address (MSA). The GPIB board has both a GPIB address and an I/O address. GPIB board Refers to the National Instruments family of GPIB interfaces. Go To Local—The GPIB command used to place an addressed Listener in local (front panel) control mode.
  • Page 121 Glossary Hexadecimal—A number represented in base 16. For example, decimal 16 is hex 10. high-level function HS488 A high-speed data transfer protocol for IEEE 488. This protocol increases performance for GPIB reads and writes up to 8 Mbytes/s, depending on your system.
  • Page 122 My Talk Address—A GPIB command used to address a device to be a Talker. It can be any one of the 31 primary addresses. multitasking The concurrent processing of more than one program or task. © National Instruments Corporation Glossary NI-488.2 User Manual...
  • Page 123 Glossary NDAC Not Data Accepted—One of the three GPIB handshake lines. See also handshake. NRFD Not Ready For Data—One of the three GPIB handshake lines. See also handshake. parallel poll The process of polling all configured devices at once and reading a composite poll response.
  • Page 124 The single designated Controller that can assert control (become CIC of the GPIB) by sending the Interface Clear (IFC) message. Other devices can become CIC only by having control passed to them. © National Instruments Corporation parallel poll. acceptor handshake and handshake.
  • Page 125 Glossary Talk Address. See also MTA. Talker A GPIB device that sends data messages to Listeners. Take Control—The GPIB command used to pass control of the bus from the current Controller to an addressed Talker. timeout A feature of the GPIB driver that prevents I/O functions from hanging indefinitely when there is a problem on the GPIB.
  • Page 126 Interactive Control utility, 4-1 using NI-488.2 Communicator, 2-6 general program steps and examples multiple-interface or multiple-device applications, 4-9 single-device applications, 4-8 © National Instruments Corporation items to include multiple-interface or multiple-device applications, 4-9 single-device applications, 4-7 talker/listener applications, 8-12 asynchronous event notification in NI-488.2...
  • Page 127 Index using Measurement & Automation Explorer, 2-6 using NI-488.2 Communicator, 2-6 communication errors repeat addressing, 5-3 termination method, 5-3 configuration See also Interactive Control utility controlling more than one interface, 1-1, 1-2 linear and star system configuration (figure), 1-1 multiboard system example (figure), 1-2 requirements, 1-2 system configuration effects on HS488, 1-3...
  • Page 128 EPWR, C-12 ERST, C-11 ESAC, C-5 ESRQ, C-9 ETAB, C-9 EWIP, C-11 GPIB error codes (table), C-1 © National Instruments Corporation error conditions communication errors repeat addressing, 5-3 termination method, 5-3 configuration errors, 5-2 Interactive Control utility, 7-11 timing errors, 5-2...
  • Page 129 Index global variables count variables (ibcnt and ibcntl), 4-6 debugging applications, 5-1 error variable (iberr), 4-6 status word (ibsta), 4-5 writing multithreaded NI-488.2 applications, 8-9 GPIB configuration controlling more than one interface, 1-2 linear and star system configuration (figure), 1-1 requirements, 1-2 interface management lines, A-3 overview, A-1...
  • Page 130 Interactive Control utility (example), 7-3 ibrpp function, 8-19 ibrsp function automatic serial polling, 8-14 conducting single serial poll, 8-15 © National Instruments Corporation ibsta bit layout definitions, 4-5, B-1 return value information, 4-5 ibwait function causing autopolling, 8-14...
  • Page 131 * ! (execute function n times) function, Interactive Control utility, 7-10 n * (execute previous function n times) function, Interactive Control utility, 7-10 National Instruments GPIB web site, 2-13, 3-8 support and services, E-1 NDAC (not data accepted) line (table), A-3...
  • Page 132 Mac OS X, 4-16 Microsoft Visual C/C++, 4-11 Visual Basic, 4-12 NI-488.2 Troubleshooting Utility, 2-3 example (figure), 2-3 NRFD (not ready for data) line (table), A-3 © National Instruments Corporation online help accessing, 2-13, 3-8 Linux, xii Mac OS X, xii Windows, xii NI Spy online help, 2-9, 6-2 NI-488.2 online help, 2-13, 3-8...
  • Page 133 Index ReadStatusByte routine, 8-15 Receive function, 4-11 recording calls in NI Spy, 6-3 related documentation, xiii REM status word condition, 4-5, B-1, B-4 removing GPIB interface in Measurement & Automation Explorer, 2-4 REN (remote enable) line (table), A-3 repeat addressing, 5-3 repeat previous function (!) function, Interactive Control utility, 7-10 RQS status word condition, 4-5, B-1, B-3...
  • Page 134 Measurement & Automation Explorer, 2-3 using NI-488.2 Troubleshooting Utility, 2-3 troubleshooting (NI resources), E-1 © National Instruments Corporation turn OFF display (-) function, Interactive Control utility, 7-10 turn ON display (+) function, Interactive Control utility, 7-10 variables. See global variables.

Table of Contents