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.
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.
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.
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.
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.
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.
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:...
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 &...
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...
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.
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)
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...
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...
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.
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...
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.
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.
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: •...
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 &...
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 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: •...
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 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...
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...
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...
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...
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.
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 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...
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 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 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 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.
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.
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.
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;...
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 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 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.
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.
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.
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.
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 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);...
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.
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 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 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 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.
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 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 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 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 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 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 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 &...
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 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 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 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 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 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 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 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...
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