NI-488.2 ™ User Manual for Windows January 1996 Edition Part Number 370902A-01 © Copyright 1993, 1996 National Instruments Corporation. All Rights Reserved.
National Instruments Corporate Headquarters 6504 Bridge Point Parkway Austin, TX 78730-5039 (512) 794-0100 Technical support fax: (800) 328-2203 (512) 794-5678 Branch Offices: Australia 03 9 879 9422, Austria 0662 45 79 90 0, Belgium 02 757 00 20, Canada (Ontario) 519 622 9310, Canada (Québec) 514 694 8521, Denmark 45 76 26 00, Finland 90 527 2321, France 1 48 14 24 24, Germany 089 741 31 30, Hong Kong 2645 3186, Italy 02 48301892, Japan 03 5472 2970, Korea 02 596 7456, Mexico 95 800 010 0793, Netherlands 0
Limited Warranty The media on which you receive National Instruments software are warranted not to fail to execute programming instructions, due to defects in materials and workmanship, for a period of 90 days from date of shipment, as evidenced by receipts or other documentation. National Instruments will, at its option, repair or replace software media that do not execute programming instructions if National Instruments receives notice of such defects during the warranty period.
Copyright Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including photocopying, recording, storing in an information retrieval system, or translating, in whole or in part, without the prior written consent of National Instruments Corporation. Trademarks NI-488 ®, NI-488.2™ , and TNT4882C™ are trademarks of National Instruments Corporation. Product and company names listed are trademarks or trade names of their respective companies.
Contents About This Manual ............................................................................................... xiii How to Use This Manual Set........................................................................... xiii Organization of This Manual........................................................................... xiv Conventions Used in This Manual................................................................... xv Related Documentation ..............................................
Contents Chapter 3 Developing Your Application ............................................................................ 3-1 Choosing How to Access the NI-488.2 DLL................................................... 3-1 Choosing Between NI-488 Functions and NI-488.2 Routines ........................ 3-1 Using NI-488 Functions: One Device for Each Board..................... 3-2 NI-488 Device Functions .................................................... 3-2 NI-488 Board Functions ........................
Contents Method 2. Generate an Import Library Using implib..................................................... 3-20 Method 3. Use LoadLibrary and GetProcAddress............. 3-20 Direct Entry with Visual Basic.......................................................... 3-23 Chapter 4 Debugging Your Application ............................................................................. 4-1 Running wibtest ...............................................................................................
Contents ! (Repeat Previous Function)............................................................. 5-15 - (Turn OFF Display) and + (Turn ON Display)............................... 5-15 n* (Repeat Function n Times) ........................................................... 5-16 $ (Execute Indirect File).................................................................... 5-16 Print (Display the ASCII String) ....................................................... 5-17 Buffer (Set Buffer Display Mode)........
Contents Parallel Polling................................................................................................. 7-10 Implementing a Parallel Poll ............................................................. 7-10 Parallel Polling with NI-488 Functions .............................. 7-10 Parallel Polling with NI-488.2 Routines............................. 7-12 Chapter 8 wibconf–Windows Interface Bus Configuration Utility ......................... 8-1 Overview......................................
Contents Exiting wibconf ............................................................................................... 8-12 Checking for Errors ........................................................................... 8-13 wibconf Batch Mode........................................................................................ 8-13 Appendix A Status Word Conditions ...................................................................................... A-1 Appendix B Error Codes and Solutions ..........
Contents Tables Table 1-1. GPIB Handshake Lines ............................................................................... 1-3 Table 1-2. GPIB Interface Management Lines ............................................................. 1-3 Table 3-1. Status Word (ibsta) Layout .......................................................................... 3-4 Table 4-1. GPIB Error Codes ........................................................................................ 4-5 Table 5-1. Table 5-2. Table 5-3.
About This Manual This manual describes the features and functions of the NI-488.2 software for Windows. The NI-488.2 software is meant to be used with Microsoft Windows version 3.0 or higher. This manual assumes that you are already familiar with Windows. How to Use This Manual Set Getting Started Manual Installation and Configuration Experienced Users Novice Users NI-488.2 User Manual for Windows NI-488.
About This Manual Organization of This Manual This manual is organized as follows: • Chapter 1, Introduction, gives an overview of GPIB and the NI-488.2 software. • Chapter 2, Application Examples, contains nine sample applications designed to illustrate specific GPIB concepts and techniques that can help you write your own applications. The description of each example includes the programmer's task, a program flowchart, and numbered steps which correspond to the numbered blocks on the flowchart.
About This Manual Conventions Used in This Manual The following conventions are used in this manual. bold Text in bold denotes windows, menus, menu options, and dialog box options. bold italic Bold italic text denotes a note, caution, or warning. italic Italic text denotes emphasis, cross references, field names, or an introduction to a key concept. monospace Text in this font denotes text or characters that you enter from the keyboard.
About This Manual Related Documentation The following documents contain information that you may find helpful as you read this manual: • ANSI/IEEE Standard 488.1-1987, IEEE Standard Digital Interface for Programmable Instrumentation • ANSI/IEEE Standard 488.2-1992, IEEE Standard Codes, Formats, Protocols, and Common Commands • Microsoft Windows User’s Guide Customer Communication National Instruments wants to receive your comments on our products and manuals.
Chapter 1 Introduction This chapter gives an overview of GPIB and the NI-488.2 software. GPIB Overview The ANSI/IEEE Standard 488.1-1987, also known as GPIB (General Purpose Interface Bus), describes a standard interface for communication between instruments and controllers from various vendors. It contains information about electrical, mechanical, and functional specifications. The GPIB is a digital, 8-bit parallel communications interface with data transfer rates of 1 Mbytes/s and above.
Introduction Chapter 1 GPIB Addressing All GPIB devices and boards 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 GPIB Controller uses this address to form a talk or listen address that is sent over the GPIB when communicating with a device. A talk address is formed by setting bit 6, the TA (Talk Active) bit of the GPIB address.
Chapter 1 Introduction Handshake Lines Three hardware handshake lines asynchronously control the transfer of message bytes between devices. This process is a three-wire interlocked handshake, and it guarantees that devices send and receive message bytes on the data lines without transmission error. Table 1-1 summarizes the GPIB handshake lines. Table 1-1. GPIB Handshake Lines Line Description NRFD (not ready for data) Listening device is ready/not ready to receive a message byte.
Introduction Chapter 1 Setting Up and Configuring Your System Devices are usually connected with a cable assembly consisting of a shielded 24-conductor cable with both a plug and receptacle connector at each end. With this design, you can link devices in a linear configuration, a star configuration, or a combination of the two. Figure 1-2 shows the linear and star configurations. Linear Configuration Device A Device B Device C Star Configuration Device D Device A Device B Device C Figure 1-2.
Chapter 1 Introduction Controlling More Than One Board Multiboard drivers, such as the NI-488.2 driver for Windows, can control more than one interface board. Figure 1-3 shows an example of a multiboard system configuration. gpib0 is the access board for the voltmeter, and gpib1 is the access board for the plotter and printer. The control functions of the devices automatically access their respective boards. One GPIB Digital Voltmeter gpib0 Plotter Another GPIB gpib1 Printer Figure 1-3.
Introduction Chapter 1 For high-speed operation, the following restrictions apply: • All devices in the system must be powered on. • Cable lengths as short as possible up to a maximum of 15 m of cable for each system. • At least one equivalent device load per meter of cable. If you want to exceed these limitations, you can use bus extenders to increase the cable length or expander to increase the number of device loads. Extenders and expanders are available from National Instruments.
Chapter 1 Introduction • ibdiag.exe is a program that you can use to test the GPIB hardware and ensure that it is functioning properly. • wibtest.exe is the Windows NI-488.2 software installation test. • gpibinfo.exe is a utility you can use to obtain information about your GPIB hardware and software, such as the version of the NI-488.2 software and the type of interface board you are using. • wibic.
Introduction Chapter 1 Win 32s Files • gpib-32.dll is a 32-bit translation dynamic link library that handles the 32-bit to 16-bit translation. • gpib-16.dll is a 16-bit translation dynamic link library. • wibic32.exe is a Win32s version of the wibic application. Sample Application Files The NI-488.2 software includes nine sample applications along with source code for each language supported by the NI-488.2 software.
Chapter 1 Introduction Unloading and Reloading the NI-488.2 Driver The NI-488.2 driver for Windows is a dynamic link library (DLL), which is loaded and unloaded automatically. When a Windows application first accesses the NI–488.2 DLL, it loads the DLL into memory. When the last Windows application using the NI-488.2 DLL has exited, the DLL is unloaded from memory. The NI-488.2 DLL might use the services of the virtual device driver, nivgpibd.386.
Chapter 2 Application Examples This chapter contains nine sample applications designed to illustrate specific GPIB concepts and techniques that can help you write your own applications. The description of each example includes the programmer's task, a program flowchart, and numbered steps which correspond to the numbered blocks on the flowchart. Use this chapter along with your NI-488.2 software, which includes the C and Visual Basic source code for each of the nine examples.
Application Examples Chapter 2 Example 1: Basic Communication This example focuses on the basics of establishing communication between a host computer and a GPIB device. A technician needs to monitor voltage readings using a GPIB multimeter. His computer is equipped with an IEEE 488.2 interface board. The NI-488.2 software is installed, and a GPIB cable runs from the computer to the GPIB port on the multimeter. The technician is familiar with the multimeter remote programming command set.
Chapter 2 Application Examples GPIB Cable Computer 1 INIT 2 Set Up Multimeter to Take Voltages Multimeter ibwrt "VOLTS DC;AUTO" ibwrt Tell Multimeter to Take Measurement 3 "VOLTS?" ibrd Read Measurement from Multimeter 4 No "+ 5 volts" Finished Getting Measurements? Yes 5 CLEAN UP Figure 2-1. Program Flowchart for Example 1 © National Instruments Corp. 2-3 NI-488.
Application Examples Chapter 2 Example 2: Clearing and Triggering Devices This example illustrates how you can clear and trigger GPIB devices. Two freshman physics lab partners are learning how to use a GPIB digital oscilloscope. They have successfully loaded the NI-488.2 software on a personal computer and connected their GPIB board to a GPIB digital oscilloscope.
Chapter 2 Application Examples GPIB Cable Computer 1 INIT 2 Clear Oscilloscope Oscilloscope ibclr Clear Command ibwrt 3 Define Task to Be Done When Oscilloscope is Triggered "WAV=TRIG" ibtrg 4 Trigger Oscilloscope to Get Reading 5 Request Data from Oscilloscope Trigger Command ibwrt "CURV?" ibrd 6 Read Data from Oscilloscope 7 Display Waveform No Data Finished Reading? Yes 8 CLEAN UP Figure 2-2. Program Flowchart for Example 2 © National Instruments Corp. 2-5 NI-488.
Application Examples Chapter 2 Example 3: Asynchronous I/O This example illustrates how an application conducts data transfers with a GPIB device and immediately returns to perform other non-GPIB related tasks while GPIB I/O is occurring in the background. This asynchronous mode of operation is particularly useful when the requested GPIB activity may take some time to complete. In this example, a research biologist is trying to obtain CAT scans of a laboratory animal's liver.
Chapter 2 Application Examples GPIB Cable Computer 1 INIT 2 Image Scan Color Printer ibwrta 3 Print Image Asynchronously 4 Non-GPIB Activity: Save to Disk Print Image ibwait Is GPIB Printing Done? 5 No Non-GPIB Activity: Compute Statistics Yes Yes More Images? No 6 CLEAN UP Figure 2-3. Program Flowchart for Example 3 © National Instruments Corp. 2-7 NI-488.
Application Examples Chapter 2 Example 4: End-of-String Mode This example illustrates how to use the end-of-string modes to detect that the GPIB device has finished sending data. A journalist is using a GPIB scanner to scan some pictures into his personal computer for a news story. A GPIB cable runs between the scanner and the computer.
Chapter 2 Application Examples GPIB Cable Scanner Computer 1 INIT 2 Reset Internal State 3 Set EOS Mode 4 Change Scan Resolution ibclr Clear Command ibeos ibwrt "RES:3 \ r \ n" ibrd 5 Read Status "OK" ibwrt 6 Start Scan 7 Read Data 8 CLEAN UP "scan \ r \ n" ibrd Scanned Data Figure 2-4. Program Flowchart for Example 4 © National Instruments Corp. 2-9 NI-488.
Application Examples Chapter 2 Example 5: Service Requests This example illustrates how an application communicates with a GPIB device that uses the GPIB service request (SRQ) line to indicate that it needs attention. A graphic arts designer is transferring digital images stored on her computer to a roll of color film, using a GPIB digital film recorder. A GPIB cable connects the GPIB port on the film recorder to the IEEE 488.2 interface board installed in her computer. She has installed the NI-488.
Chapter 2 Application Examples 6c. When the SRQ line is asserted, the application serial polls the film recorder to see if it requested service, as in Step 5. 7. The application issues a command to the film recorder to advance the film by one frame. The advance occurs successfully unless the end of film is reached. 8. The application waits for RQS, which completes when the film recorder asserts the SRQ line to signal it is done advancing the film. 9.
Application Examples Chapter 2 GPIB Cable Digital Film Recorder Computer 1 INIT 2 Clear Film Recorder 3 Advance Film ibclr Clear Command ibwrt "FRM+" ibwait Request Service Wait for the Film Recorder to Request Service 4 Did You Request Service ? Yes ibrsp Read Response from the Film Recorder 5 No Exit Application and Repair Film Recorder Response Finished Loading Film? Yes (continues) Figure 2-5. Program Flowchart for Example 5 NI-488.
Chapter 2 Application Examples (Continued) Digital Film Recorder Computer Yes ibwrt 6a Create a Single Pass Image Data for Red, Green, or Blue Pass ibwait 6 Wait for Film Recorder to Request Service 6b Request Service Did You Request Service? These steps are repeated 3 times, once for each color pass Yes ibrsp Read Response From Film Recorder 6c Response ibwrt "ADV" Advance Film ibwait 7 Wait for Film Recorder to Request Service 8 Request Service Did You Request Service? Yes ibrsp 9
Application Examples Chapter 2 Example 6: Basic Communication with IEEE 488.2-Compliant Devices This example is an introduction to communicating with IEEE 488.2-compliant devices. A test engineer in a metal factory is using IEEE 488.2-compliant tensile testers to determine the strength of metal rods as they come out of production. There are several tensile testers and they are all connected to a central computer equipped with an IEEE 488.2 interface board.
Chapter 2 Application Examples GPIB Cable Computer 1 GPIB Cable Tensile Tester 2 Tensile Tester 3 INIT FindLstn 2 GPIB Cable Tensile Tester 1 Get a List of Devices Present on GPIB Who's Listening? Device 1 is Here Device 2 is Here Device 3 is Here Send 3 Tell Device 1 to Identify Itself 4 Read Response from Device 1 3 Tell Device 2 to Identify Itself 4 Read Response from Device 2 3 Tell Device 3 to Identify Itself "*IDN?" Receive "MUTT 10383" Send "*IDN?" Receive "MUTT 10426" S
Application Examples Chapter 2 Example 7: Serial Polls Using NI-488.2 Routines This example illustrates how you can take advantage of the NI-488.2 routines to reduce the complexity of performing serial polls of multiple devices. A candy manufacturer is using GPIB strain gauges to measure the consistency of the syrup used to make candy. The plant has four big mixers containing syrup. The syrup has to reach a certain consistency to make good quality candy.
Chapter 2 Application Examples GPIB Cable GPIB Cable Computer 1 GPIB Cable Strain Gauge 2 Strain Gauge 1 Strain Gauge 3 INIT SendList Configure Strain Gauges to 2 Request Service When They Have a Reading "SRQ=HI" WaitSRQ 3 Wait for 1 or More Strain Gauges to Request Service Request Service FindRQS 4 Serial Poll Each Strain Gauge Until One Requesting Service is Located Did You Request Service? No Did You Request Service? Yes Receive 5 Get a Reading From Strain Gauge Does the Gauge Need Se
Application Examples Chapter 2 Example 8: Parallel Polls This example illustrates how you can use NI-488.2 routines to obtain information from several IEEE 488.2-compliant devices at once using a procedure called parallel polling. The process of manufacturing a particular alloy involves bringing three different metals to specific temperatures before mixing them to form the alloy. Three vats are used, each containing a different metal. Each is monitored by a GPIB ore monitoring unit.
Chapter 2 Application Examples 8. The application unconfigures all of the transducers so that they no longer participate in parallel polls. 9. As a cleanup step before exiting, the application returns the interface board to its original state by taking it offline.
Application Examples Chapter 2 Example 9: Non-Controller Example This example illustrates how you can use the NI-488.2 software to emulate a GPIB device that is not the GPIB Controller. A software engineer has written firmware to emulate a GPIB device for a research project and is testing it using an application that makes simple GPIB calls. The following steps correspond to the program flowchart in Figure 2-9. 1. The application brings the device online. 2.
Chapter 2 Application Examples Device 1 Controller INIT ibwait Wait to be Talk Addressed, Listen Addressed, or Cleared 2 3 Reset Internal State fffffffffff Is This the Clear Event? Yes No No Is This the Talk Addressed Event? Yes ibwrt 3 Write Out New Data Data ibrd 3 Read In New Data Data Figure 2-9. Program Flowchart for Example 9 © National Instruments Corp. 2-21 NI-488.
Chapter 3 Developing Your Application This chapter explains how to develop a GPIB application program using NI-488 functions and NI-488.2 routines. Choosing How to Access the NI-488.2 DLL Applications can access the NI-488.2 dynamic link library (gpib.dll) either by using the NI-488.2 language interfaces for C or Visual Basic, or by directly accessing the gpib.dll. The NI-488.2 language interface is the easiest and fastest method, and it is adequate for most applications. If you want to access the gpib.
Developing Your Application Chapter 3 Using NI-488 Functions: One Device for Each Board If your system has only one device attached to each board, the NI-488 functions are probably sufficient for your programming needs. Some other factors that make the NI-488 functions more convenient include the following: • With NI-488 asynchronous I/O functions (ibcmda, ibrda, and ibwrta), you can initiate an I/O sequence while maintaining control over the CPU for non-GPIB tasks.
Chapter 3 Developing Your Application The NI-488 board functions are compatible with, and can be interspersed within, sequences of NI-488.2 routines. When you use board functions within a sequence of NI -488.2 routines, you do not need a prior call to ibfind to obtain a board descriptor. You simply substitute the board index as the first parameter of the board function call. With this flexibility, you can handle non-standard or unusual situations that you cannot resolve using NI-488.2 routines only.
Developing Your Application Chapter 3 Table 3-1 shows the condition that each bit position represents, the bit mnemonics, and the type of calls for which each bit can be set. For a detailed explanation of each of the status conditions, refer to Appendix A, Status Word Conditions . Mnemonic Bit Pos. Table 3-1.
Chapter 3 Developing Your Application Error Variable – iberr If the ERR bit is set in the status word (ibsta), a GPIB error has occurred. When an error occurs, the error type is specified by the value in iberr. Note: The value in iberr is meaningful as an error type only when the ERR bit is set, indicating that an error has occurred. For more information on error codes and solutions refer to Chapter 4, Debugging Your Application , or Appendix B, Error Codes and Solutions.
Developing Your Application Chapter 3 Writing Your NI-488 Application This section discusses items you should include in your application program, general program steps, and an NI-488 example. In this manual the example code is presented in C. The NI-488.2 software includes the source code for C (devsamp.c), Visual Basic (devsamp.bas ), direct entry functions in C (dlldev.c), and direct entry functions in Visual Basic (dlldev.bas). The NI-488.
Chapter 3 Developing Your Application NI-488 Program Shell Figure 3-1 is a flowchart of the steps to create your application program using devicelevel NI-488 functions. START Open Device (ibdev) Are All Devices Open? No Yes Make a Device-Level Call • Send Data to Device (ibwrt) • Receive Data from Device (ibrd) • Clear Device (ibclr) • Serial Poll Device (ibrsp) and so on Finished GPIB Programming? No Yes Close Device (ibonl) Closed All Devices? No Yes END Figure 3-1.
Developing Your Application Chapter 3 General Program Steps and Examples The following steps demonstrate how to use the NI-488 device functions in your program. This example configures a digital multimeter, reads 10 voltage measurements, and computes the average of these measurements. Step 1. Open a Device Your first NI-488 function call should be to ibdev to open a device.
Chapter 3 Developing Your Application Step 3. Configure the Device After you open and clear the device, it is ready to receive commands. To configure the instrument, you send device-specific commands using the ibwrt function. Refer to the instrument user manual for the command bytes that work with your instrument. ibwrt(ud, "*RST; VAC; AUTO; TRIGGER 2; *SRE 16", 35L); if (ibsta & ERR) { gpiberr("ibwrt error"); } The programming instruction in this example resets the multimeter ( *RST).
Developing Your Application Chapter 3 ibrsp (ud, &StatusByte); if (ibsta & ERR) { gpiberr("ibrsp error"); } if ( !(StatusByte & MAVbit)) { gpiberr("Improper Status Byte"); printf(" Status Byte = 0x%x\n", StatusByte); } Step 6. Read the Measurement If the data is valid, read the measurement from the instrument. (AsciiToFloat is a function that takes a null-terminated string as input and outputs the floating point number it represents.
Chapter 3 Developing Your Application Writing Your NI-488.2 Application This section discusses items you should include in an application program that uses NI -488.2 routines, general program steps, and an NI-488.2 example. In this manual the example code is presented in C. The NI-488.2 software includes the source code for C (samp4882.c), Visual Basic (samp4882.bas), direct entry functions in C (dll4882.c), and direct entry functions in Visual Basic (dll4882.bas). The NI-488.
Developing Your Application Chapter 3 NI-488.2 Program Shell Figure 3-2 is a flowchart of the steps to create your application program using NI-488.2 routines.
Chapter 3 Developing Your Application General Program Steps and Examples The following steps demonstrate how to use the NI-488.2 routines in your program. This example configures a digital multimeter, reads 10 voltage measurements, and computes the average of these measurements. Step 1. Initialization Use the SendIFC routine to initialize the bus and the GPIB interface board so that the GPIB board is Controller-In-Charge (CIC). The only argument of SendIFC is the GPIB interface board number.
Developing Your Application Chapter 3 for (loop = 1; loop <= num_Listeners; loop++) { Send(0, result[loop], "*IDN?", 5L, NLend); if (ibsta & ERR) { gpiberr("Send error"); } Receive(0, result[loop], buffer, 10L, STOPend); if (ibsta & ERR) { gpiberr("Receive error"); } buffer[ibcntl] = '\0'; printf("The instrum ent at address %d is a %s\n", result[loop], buffer); if (strncmp(buffer, "Fluke, 45", 9) == 0) { fluke = result[loop]; printf("**** Found the Fluke ****\n"); break; } } if (loop > num_Listeners) { pr
Chapter 3 Developing Your Application Step 5. Configure the Instrument After initialization, the instrument is ready to receive instructions. To configure the multimeter, use the Send routine to send device-specific commands. The first argument is the number of the access board. The second argument is the GPIB address of the multimeter. The third argument is a string of bytes to send to the multimeter.
Developing Your Application Chapter 3 is the GPIB address of the instrument, and the last argument is a variable that ReadStatusByte uses to store the status byte of the instrument. ReadStatusByte(0, fluke, &statusByte); if (ibsta & ERR) { gpiberr("ReadStatusB yte error"); } After you have obtained the status byte, you must check to see if the meter has a message to send. You can do this by checking the message available (MAV) bit, bit 4 in the status byte.
Chapter 3 Developing Your Application Compiling, Linking, and Running Your Application The following sections describe how to compile, link, and run your application program. To see examples that show how to include specific lines of code in your program, refer to the program examples included with your NI-488.2 software. If you discover errors when you execute the program refer to Chapter 4, Debugging Your Application . If you want to verify the NI-488 and NI-488.
Developing Your Application Chapter 3 Visual Basic With Visual Basic, you access the NI-488 functions as subroutines, using the BASIC keyword CALL followed by the NI-488 function name (for example CALL ibtrg (ud%) ). You can also access the NI-488 functions using another set of functions, the il functions (for example result% = iltrg (ud%) ). If you are using Visual Basic and prefer calling functions instead of subroutines, then you can use the il functions.
Chapter 3 Developing Your Application Sample programs using direct entry are included with the National Instruments driver. The C sample programs are console-type applications. They illustrate how to use the function calls the NI-488.2 driver exports. Since most of the popular compilers support console-type applications as well as GUI applications, you can create console-type applications without knowing Windows GUI programming.
Developing Your Application Chapter 3 Method 2. Generate an Import Library Using implib To use the second method, link the application to an import library generated from the DLL using the implib utility. To generate the import library, type in the following text: implib gpib.lib c:\windows\system\gpib.dll where c:\windows\system\ is the path to your Windows System directory. The file named gpib.lib is the name of the file generated by the implib utility.
Chapter 3 Developing Your Application The prototypes for each function can be found in the NI-488.2 Function Reference Manual for DOS/Windows. For functions that return an integer value, like ibdev, you must cast the pointer to the function as follows: int(_far _pascal *Pname) where *Pname is the name of the pointer to the function. For functions (that is, the NI-488.
Developing Your Application Chapter 3 If GetProcAddress does not return a pointer, you can check to see if an address was assigned or not, as in the following example: if ((Pibdev==NULL)|| (Pibonl==NULL)) { FreeLibrary(GpibLib); GpibLib=NULL; return FALSE; } else return TRUE; The following code shows you how to call functions from within your application program: dvm = (*Pibdev) (0, 1, 0, T10s, 1, 0, &ibsta, &iberr, &ibcntl); (*Pibonl) (dvm, 0, &ibsta, &iberr, &ibcntl); Upon completion of your program,
Chapter 3 Developing Your Application Direct Entry with Visual Basic See the Visual Basic section, earlier in this chapter, for information on calling the NI-488 functions with Visual Basic. Include the file niglobal.bas in your application project file. You must create a file (for example, dllfunc.bas) that contains the direct entry prototypes of the functions used in your application program. Include the direct entry file in your application project file. Refer to the NI-488.
Chapter 4 Debugging Your Application This chapter describes several ways to debug your application program. Running wibtest Before you run your application program, you should run the software diagnostic test, wibtest, that came with your NI-488.2 software. The wibtest program is an NI-488.2 application that makes calls to the driver. If wibtest passes, your GPIB hardware and NI-488.2 software are interacting correctly.
Debugging Your Application Chapter 4 • The board might not be properly installed and configured. Refer to the getting started manual for detailed instructions. • The software and hardware settings do not match. You can run wibconf to check the current configuration of the software.
Chapter 4 Debugging Your Application Hardware Information: GPIB0: an AT-GPIB/TNT board using the TNT4882C chip. It supports both the NI-488 functions and NI-488.2 routines. It supports the HS488 high-speed protocol. It uses base I/O address 0x2C0. It uses interrupt level 11. It uses DMA channel 5. You can also run GPIBInfo by specifying the base I/O address of a GPIB board in your system. If GPIBInfo finds a board at the given address, it displays information about that board.
Debugging Your Application Chapter 4 Debugging with wibic If your application does not automatically check for and display errors, you can locate an error by using wibic . Simply issue the same functions or routines, one at a time as they appear in your application program. Because wibic returns the status values and error codes after each call, you should be able to determine which GPIB call is failing.
Chapter 4 Debugging Your Application Table 4-1.
Debugging Your Application Chapter 4 To test the configuration of your hardware, you can use the ibdiag program as described in your getting started manual. Timing Errors If your application fails, but the same calls issued in wibic are successful, your program might be issuing the NI-488.2 calls too quickly for your device to process and respond to them. This problem can also result in corrupted or incomplete data.
Chapter 4 Debugging Your Application Common Questions Can I have the DOS and Windows drivers installed at the same time? Yes, there is nothing wrong with installing both. However, it is better not to access them at the same time. What do I do if ibdiag or wibtest fail with an error? Refer to the Running wibtest section of this chapter and to the section about ibdiag in your getting started manual for specific information about what might cause these tests to fail.
Debugging Your Application Chapter 4 What should I type into the pop-up window that appears when I start wibconf? This pop-up window is prompting you for the drive and path where the gpib.ini file is located. If Windows is installed in the default directory (c:\windows), just press . If Windows is not installed in the default directory, enter the path and directory where Windows is installed so that wibconf can find the correct gpib.ini file to modify, for example c:\win31\gpib.ini.
Chapter 4 Debugging Your Application What information should I have before I call National Instruments? When you call National Instruments, you should have the results of the diagnostic tests ibdiag and wibtest along with the output from the GPIBInfo utility. Also, make sure you have filled out the technical support form in Appendix C, Customer Communication. © National Instruments Corp. 4-9 NI-488.
Chapter 5 wibic–Windows Interface Bus Interactive Control Utility This chapter introduces you to wibic, the interactive control program that you can use to communicate with GPIB devices interactively. Overview With the wibic program, you communicate with the GPIB devices through functions you enter at the keyboard. For specific information about how to communicate with your particular device, refer to the manual that came with the device.
wibic–Windows Interface Bus Interactive Control Utility 1. Chapter 5 To run wibic, double-click on the wibic icon in the GPIB group in the Program Manager . A window appears with the following information displayed: National Instruments IEEE 488 Interface Bus Interactive Control Program (WIBIC) Copyright (c) 1993 National Instruments Corp. Version 3.0 (Win16) Version Date: May 28 1993 Version Time: 09:42:25 All rights reserved Type 'help' for help or 'q' to quit : 2.
Chapter 5 4. wibic–Windows Interface Bus Interactive Control Utility Write the function, range, and trigger source instructions to your device. Refer to the instrument's user manual for the command bytes that work with your instrument. ud0: ibwrt enter string: "*RST; VAC; AUTO; TRIGGER 2; *SRE 16" [0100] (cmpl) count: 35 or ud0: ibwrt "*RST; VAC; AUTO; TRIGGER 2; *SRE 16" [0100] (cmpl) count: 35 5. Trigger the device as follows: ud0: ibtrg [0100] (cmpl) 6.
wibic–Windows Interface Bus Interactive Control Utility 8. Chapter 5 Use the read command to display the data on the screen both in hex values and their ASCII equivalents. ud0: ibrd enter byte count: 18 [0100] (cmpl) count: 18 4e 44 43 56 20 30 30 30 2e 30 30 34 37 45 2b 30 0a 0a N D C V 0 0 0 . 0 0 4 7 E + 0 . . or ud0: ibrd 18 [0100] (cmpl) count: 18 4e 44 43 56 20 30 30 30 2e 30 30 34 37 45 2b 30 0a 0a 9. N D C V 0 0 0 . 0 0 4 7 E + 0 . .
Chapter 5 wibic–Windows Interface Bus Interactive Control Utility String Syntax You can enter strings in the following formats. ASCII character sequence–You must enclose the entire sequence in quotation marks. Octal bytes–You must use a backslash character followed by the octal value. For example, octal 40 is represented by \40 . Hex bytes–You must use a backslash character and an x followed by the hex value. For example, hex 40 is represented by \x40.
wibic–Windows Interface Bus Interactive Control Utility Chapter 5 Table 5-1.
Chapter 5 wibic–Windows Interface Bus Interactive Control Utility Table 5-2.
wibic–Windows Interface Bus Interactive Control Utility Chapter 5 wibic Syntax for NI-488.2 Routines Table 5-3 summarizes the syntax of NI-488.2 routines in wibic. v represents a number and string represents a string. address represents an address, and addrlist represents a list of addresses separated by commas. For more information about the routine parameters, use the wibic help feature or refer to the NI-488.2 Function Reference Manual for DOS/Windows. Table 5-3. Syntax for NI-488.
Chapter 5 wibic–Windows Interface Bus Interactive Control Utility Table 5-3. Syntax for NI-488.2 Routines in wibic (Continued) Description Routine Syntax SetRWLS addrlist TestSys addrlist TestSRQ Trigger address TriggerList addrlist WaitSRQ Put devices in remote with lockout state Causes multiple devices to perform self tests Test for service request Trigger a device Trigger multiple devices Wait for service request Status Word In wibic , all NI-488 functions (except ibfind and ibdev ) and NI-488.
wibic–Windows Interface Bus Interactive Control Utility Chapter 5 For a detailed list of the error codes and their meanings, refer to Chapter 4, Debugging Your Application. Count When an I/O function completes, wibic 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 of an NI-488.2 routine is invalid, then the error is EARG and wibic displays the index of the invalid address as the count.
Chapter 5 wibic–Windows Interface Bus Interactive Control Utility • Timeout setting • EOT mode • EOS mode The following example shows ibdev opening an available device and assigning it to access gpib0 (board = 0) with a primary address of 6 ( pad = 6), a secondary address of hex 67 (sad = 0x67), a timeout of 10 s (tmo=13), the END message enabled (eot =1), and the EOS mode disabled (eos= 0).
wibic–Windows Interface Bus Interactive Control Utility Chapter 5 • EARG–One of the last five parameters is an invalid value. The ibdev call returns with a new prompt and the EARG error (invalid function argument). If the ibdev call returns with an EARG error, you must identify which parameter is incorrect and use the appropriate command to correct it. In the following example, pad has an invalid value.
Chapter 5 wibic–Windows Interface Bus Interactive Control Utility Common NI-488.2 Routines in wibic Set You must use the set command before you can use NI-488.2 routines in wibic. The syntax for this form of the set command is as follows: set 488.2 n where n represents a board number (for example, n=0 for gpib0). The 488.2 prompt indicates that you are in NI-488.2 mode on board n. The following example shows how to enter into 488.2 mode on board gpib0. set 488.2 0 488.
wibic–Windows Interface Bus Interactive Control Utility Chapter 5 488.2 (0): Receive 5 10 STOPend [2124] (end cmpl cic lacs) count: 5 48 65 6c 6c 6f Hello Auxiliary Functions Table 5-4 summarizes the auxiliary functions that you can use in wibic. Table 5-4. Auxiliary Functions in wibic Function Description set udname Select active device or board where udname is the symbolic name of the new device or board (for example, dev1 or gpib0 ). Call ibfind or ibdev initially to open each device or board.
Chapter 5 wibic–Windows Interface Bus Interactive Control Utility Set (Select Device or Board) You can use the set command to select 488.2 mode or to communicate with a different device. The following example switches communication from using NI-488.2 routines for gpib0 to using a unit descriptor ( ud0) previously acquired by an ibdev call. 488.2 (0): set ud0 ud0: Help (Display Help Information) The help feature displays a menu of topics to choose from.
wibic–Windows Interface Bus Interactive Control Utility Chapter 5 ud0: ibrd 8 ud0: + ud0: ibrd 8 [2100] (end cmpl) count: 8 71 72 73 74 75 76 77 78 q r s t u v w x n* (Repeat Function n Times) The n* function repeats the execution of the specified function n times, where n is an integer. In the following example, the message Hello is sent five times to the device described by ud0. ud0 : 5* ibwrt "Hello" In the following example, the word Hello is sent five times, 20 times, and then 10 more times.
Chapter 5 wibic–Windows Interface Bus Interactive Control Utility Print (Display the ASCII String) You can use the print function to echo a string to the screen. The following example shows how you can use ASCII or hex with the print command. dev1: print "hello" hello dev1: print "and\r\n\x67\x6f\x6f\x64\x62\x79\x65" and goodbye You can also use print to display comments from indirect files. The print string appears even if the display is suppressed with the - function.
Chapter 6 GPIB Spy This chapter explains how to use the GPIB Spy utility to monitor and debug your application program. Overview GPIB Spy is a GPIB application monitor utility for Windows applications. It monitors the NI-488 and NI-488.2 calls made to the NI-488.2 driver for Windows, and records and displays information about the calls. You can use the GPIB Spy application to locate and analyze errors in your application or in the configuration of the NI-488.2 software.
GPIB Spy Chapter 6 Exiting GPIB Spy Exit GPIB Spy by choosing Exit from the Spy menu. Caution: When you exit GPIB Spy, all of the recorded information is lost. See the section in this chapter entitled GPIB Spy Output Options if you want to avoid losing the information. Viewing Call Details To see detailed information about calls recorded in GPIB Spy, use the Call Details window. You can activate the Call Details window in two different ways.
Chapter 6 GPIB Spy GPIB Spy Configuration Options Calls To Highlight You can choose for GPIB Spy to highlight certain calls based on bits set in ibsta. If you want to modify this option then select the Calls to Highlight menu item from the Configure menu. Use the dialog box to select which ibsta bits should cause a recorded call to be highlighted in the main GPIB Spy window. The default configuration of GPIB Spy is to highlight NI-488 and NI-488.2 calls which return with the ERR bit set in ibsta.
GPIB Spy Chapter 6 Store Configuration You can use this option to make the current GPIB Spy configuration the default GPIB Spy configuration. If you want to set the default GPIB Spy configuration, select the Store Configuration menu item from the Configure menu. GPIB Spy Output Options To Screen You can use this option to select the number of NI-488 and NI-488.2 calls that are displayed in GPIB Spy. By default GPIB Spy displays 100 calls.
Chapter 6 GPIB Spy GPIB Spy Help You can access online help for GPIB Spy by selecting the GPIB Spy Help menu item from the Help menu. All of the information covered in this chapter is available through the online help. The online help contains a thorough description of each of the features of GPIB Spy, as well as information to help you develop your Windows GPIB application.
Chapter 7 GPIB Programming Techniques This chapter describes techniques for using some NI-488 functions and NI-488.2 routines in your application program. For more detailed information about each function or routine, refer to the NI-488.2 Function Reference Manual for DOS/Windows . Termination of Data Transfers GPIB data transfers are terminated either when the GPIB EOI line is asserted with the last byte of a transfer or when a preconfigured end-of-string (EOS) character is transmitted.
GPIB Programming Techniques Chapter 7 You can use the ibconfig function to configure the software to inform you whether or not the GPIB EOI line was asserted when the EOS byte was read. Use the IbcEndBitIsNormal option to configure the software to report only the END bit in ibsta when the GPIB EOI line is asserted. By default, the NI-488.2 driver reports END in ibsta when either the EOS byte is read in or the EOI line is asserted during a read.
Chapter 7 GPIB Programming Techniques cable in your system. It is called the Configure (CFGn) message. Because HS488 can operate only with cable lengths of 1 to 15 meters, only CFGn values of 1 through 15 (hex 61 through 6F) are valid. If the cable length was configured correctly in wibconf, you can determine how many meters of cable are in your system by calling ibask (option IbaHSCableLength ) in your application program.
GPIB Programming Techniques Chapter 7 • If your setup includes more than one Controller, or if your GPIB interface board is not configured as the System Controller, use the CIC Protocol method. To use the protocol, issue the ibconfig function (option IbcCICPROT) or use the wibconf configuration utility to activate the CIC protocol. If the interface board is not CIC and you make a device-level call with the CIC Protocol enabled, the following sequence occurs: 1.
Chapter 7 GPIB Programming Techniques Using the Event Queue Some applications need to know the order in which certain messages are sent by the Controller. To monitor the ordering of these messages, your application program must enable the EVENT bit, using ibconfig (option IbcEventQueue). When the EVENT bit is enabled, the DCAS and DTAS bits are no longer activated. Instead, all DCAS and DTAS messages are stored in a queue, in the order that they are received.
GPIB Programming Techniques Chapter 7 Service Requests from IEEE 488.2 Devices The IEEE 488.2 standard refined the bit assignments in the status byte. In addition to setting bit 6 when requesting service, IEEE 488.2 devices also use two other bits to specify their status. Bit 4, the Message Available bit (MAV), is set when the device is ready to send previously queried data. Bit 5, the Event Status bit (ESB), is set if one or more of the enabled IEEE 488.2 events occurs.
Chapter 7 GPIB Programming Techniques 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. If this happens during an ibwait for RQS, the driver reports the ESRQ error. If the stuck SRQ state happens, no further polls are attempted until an ibwait for RQS is made. When ibwait is issued, the stuck SRQ state is terminated and the driver attempts a new set of serial polls.
GPIB Programming Techniques Chapter 7 if ( ibsta & RQS ) { printf ( "Device asserted SRQ.\n" ); /* Use ibrsp to retrieve the serial poll response. */ ibrsp ( DeviceHandle, &SerialPollResponse ); } return SerialPollResponse; } SRQ and Serial Polling with NI-488.2 Routines The NI-488.2 software includes a set of NI-488.2 routines that you can use to conduct SRQ servicing and serial polling.
Chapter 7 GPIB Programming Techniques Example 1: Using FindRQS This example illustrates the use of FindRQS to determine which device is requesting service. void GetASerialPollResponse ( char *DevicePad, char *DeviceResponse ) { char SerialPollResponse = 0; int WaitResult; Addr4882_t Addrlist[4] = {3,4,5,NOADDR}; WaitSRQ (0, &WaitResult); if (WaitResult) { printf ("SRQ is asserted.\n"); /* Use FindRQS to find a device that requested service.
GPIB Programming Techniques Chapter 7 /* Use Allspoll to serial poll all the devices at once. */ AllSpoll ( 0, AddrList, ResponseList ); if (!(ibsta & ERR)) { for ( i = 0; AddrList[i] != NOADDR; i++ ) { printf ("Device at pad %x returned byte %x.\n", AddrList[i], ResponseList[i] ); } } } return; } Parallel Polling Although parallel polling is not widely used, it is a useful method for obtaining the status of more than one device at the same time.
Chapter 7 GPIB Programming Techniques S is 1 if the device is to assert the assigned data line when ist = 1, and 0 if the device is to assert the assigned data line when ist = 0. D2 through D0 determine the number of the assigned data line. The physical line number is the binary line number plus one. For example, DIO3 has a binary bit pattern of 010. The following example code configures a device for parallel polling using NI-488 functions. The device asserts DIO7 if its ist = 0.
GPIB Programming Techniques Chapter 7 Parallel Polling with NI-488.2 Routines Follow these steps to implement parallel polling using NI-488.2 routines. Each step contains example code. 1. Configure the device for parallel polling using the PPollConfig routine, unless the device can configure itself for parallel polling. The following example configures a device at address 3 to assert data line 5 (DIO5) when its ist value is 1. #include "decl.
Chapter 8 wibconf–Windows Interface Bus Configuration Utility This chapter contains a description of wibconf , the software configuration program you can use to configure the NI-488.2 software for Windows. Overview The wibconf utility is a screen-oriented, interactive program you can use to view or modify the configuration parameters of your GPIB interface boards and the GPIB devices connected to them. Usually, you use wibconf to modify the hardware settings of your GPIB interface boards.
wibconf-Windows Interface Bus Configuration Utility Chapter 8 Table 8-1 lists the options you can select when you start wibconf . Table 8-1. Options for Starting wibconf wibconf Option Action driver Configure a specific driver. wibconf configures the given driver configuration file (for example, wibconf d:\win3\gpib.ini). -h Help. This option causes wibconf to display a summary of options. -b filename Batch mode configuration.
Chapter 8 wibconf-Windows Interface Bus Configuration Utility Upper-Level Device Map Figure 8-1 shows the upper level of wibconf. Figure 8-1. Upper Level of wibconf As shown in Figure 8-1, the upper-level screen of wibconf displays the names of all devices controlled by the driver. It also indicates which devices, if any, are accessed through each interface board. You can move around the map by using the cursor control keys or the mouse. The following options are available at the upper level.
wibconf-Windows Interface Bus Configuration Utility Chapter 8 Device Maps of the Boards Use or to toggle between the device maps for the different GPIB interface boards. These boards are referred to as access boards. The maps show which devices are assigned to each board. Help Use the function key to access the comprehensive, online help feature of wibconf . The help information describes the functions and common terms associated with the upper level of wibconf .
Chapter 8 wibconf-Windows Interface Bus Configuration Utility Edit Use the function key or the key to edit or examine the characteristics of a particular board or device. Move to the board or device that you want to edit using the cursor control keys and then press the key. This step puts you in the lower level of wibconf and lists the characteristics for the particular board or device that you want to edit.
wibconf-Windows Interface Bus Configuration Utility Chapter 8 You can access the lower-level screens from the map level of wibconf by selecting a board or device and pressing . You can use the , , , and cursor keys to select a characteristic. For your convenience, cursor control keys and function keys are defined at the bottom of your computer screen.
Chapter 8 wibconf-Windows Interface Bus Configuration Utility Board and Device Configuration Options To view detailed information about each characteristic, position the cursor in the field for that characteristic. For information on characteristics specific to a particular driver, check the getting started manual that came with your interface board. The following paragraphs describe the options available in wibconf for the NI-488.2 software for Windows.
wibconf-Windows Interface Bus Configuration Utility Chapter 8 Serial Poll Timeouts (Device Characteristic Only) This timeout value controls the length of time the driver waits for a serial poll response from a device. The IEEE 488.1 specification does not specify the length of time a Controller should wait for the response byte. The default of 1 s should work for most devices. If you seem to have problems with serial polls, try using a longer timeout value.
Chapter 8 wibconf-Windows Interface Bus Configuration Utility Send EOI at End of Write Some devices, as Listeners, require that the Talker terminate a data message by asserting the EOI line with the last byte. A yes response causes the GPIB board to assert the EOI line on the last data byte. The default option for this characteristic is yes. System Controller (Board Characteristic Only) This field appears on the board characteristics screen only.
wibconf-Windows Interface Bus Configuration Utility Chapter 8 Bus Timing (Board Characteristic Only) This field specifies the T1 delay of the source handshake capability for the board. This delay determines the minimum amount of time, after the data is placed on the bus, that the board may assert DAV during a write or command operation. If the total length of the GPIB cable length in the system is less than 15 m, the value of 350 ns is appropriate.
Chapter 8 wibconf-Windows Interface Bus Configuration Utility DMA Channel (Board Characteristic Only) This field specifies the DMA channel used by the GPIB board. It must be set to the same value as the DMA channel (arbitration level for Micro Channel systems) setting for the GPIB board itself. Setting the DMA channel is explained in the getting started manual that you received with your GPIB interface board. Note : On some systems, you can only enable or disable the use of DMA with the wibconf utility.
wibconf-Windows Interface Bus Configuration Utility Chapter 8 Default Configurations in wibconf This section lists the default configuration values of the NI-488.2 driver. • Thirty-two devices with symbolic names dev1 through dev32 . • Four access boards with symbolic names gpib0, gpib1, gpib2, and gpib3. You cannot change the access board names. • Access board gpib0 is enabled. gpib1, gpib2, and gpib3 are disabled. • The GPIB addresses of the first 16 devices are the same as the device number.
Chapter 8 wibconf-Windows Interface Bus Configuration Utility Checking for Errors Unless you started in expert mode, wibconf checks for possible problems before quitting. It alerts you to situations such as the following: • GPIB addressing conflict between a device and its access board • GPIB boards not present in the host machine at the specified address • Timeouts disabled on a device or board To disable automatic checking when starting wibconf , use the -e option.
wibconf-Windows Interface Bus Configuration Utility Chapter 8 The following example is a sample configuration file followed by an explanation of each entry. find find find find device1 name plotter device2 disconnect device3 connect board1 board0 pad 2 tmo 30sec eos 0x1E sc no bin 8-bit tmng 350nsec This example makes the following changes: 1. Change the name of the first device to plotter . 2. Disconnect the second device. 3. Connect the third device to board 1 (gpib1). 4.
Chapter 8 wibconf-Windows Interface Bus Configuration Utility Table 8-2.
Appendix A Status Word Conditions This appendix gives a detailed description of the conditions reported in the status word, ibsta . For information about how to use ibsta in your application program, refer to Chapter 3, Developing Your Application. If a function call returns an ENEB or EDVR error, all status word bits except the ERR bit are cleared, indicating that it is not possible to obtain the status of the GPIB board.
Status Word Conditions Appendix A 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. Appendix B, Error Codes and Solutions, describes error codes that are recorded in iberr along with possible solutions. ERR is cleared following any call that does not result in an error. TIMO (dev, brd) TIMO indicates that the timeout period has been exceeded.
Appendix A Status Word Conditions An automatic serial poll occurs either as a result of a call to ibwait, or automatically, if automatic serial polling is enabled. If the serial poll response queue is not empty, ibrsp returns the oldest byte stored in the queue. To empty the response queue, call ibrsp repeatedly until RQS is no longer set in the device's status word. SPOLL (brd) Use SPOLL in Talker/Listener applications to determine when the Controller has serial polled the GPIB board.
Status Word Conditions Appendix A REM (brd) REM indicates whether or not the board is in the remote state. REM is set whenever the Remote Enable (REN) GPIB line is asserted and the GPIB board detects that its listen address has been sent either by the GPIB board or by another Controller.
Appendix A Status Word Conditions DTAS (brd) DTAS indicates whether the GPIB board has detected a device trigger command. DTAS is set whenever the GPIB board, as a Listener, detects that the Group Execute Trigger (GET) command has been sent by another Controller. DTAS is cleared on any call immediately following an ibwait call, if the DTAS bit is set in the ibwait mask parameter. DCAS (brd) DCAS indicates whether the GPIB board has detected a device clear command.
Appendix B Error Codes and Solutions This appendix lists a description of each error, some conditions under which it might occur, and possible solutions. The following table lists the GPIB error codes. Table B-1.
Error Codes and Solutions Appendix B • An invalid unit descriptor is passed to any function call. In this case, the variable ibcntl contains the DOS error code 6, Invalid handle. • The driver ( gpib.dll) is not installed. • The driver configuration file gpib.ini is not located in the windows directory. In this case, the variable ibcntl contains the value -1. • The driver file gpib.ini is in the windows directory but not compatible with the driver file gpib.dll that you are using.
Appendix B Error Codes and Solutions Solutions • Use ibsic or SendIFC to make the GPIB board become CIC on the GPIB. • Use ibrsc 1 to make sure your GPIB board is configured as System Controller. • In multiple CIC situations, always be certain that the CIC bit appears in the status word ibsta before attempting these calls. If it does not appear, you can perform an ibwait (for CIC) call to delay further processing until control is passed to the board.
Error Codes and Solutions Appendix B Solutions • Make sure that the GPIB board is addressed correctly before calling ibrd, ibwrt, RcvRespMsg, or SendDataBytes. • Avoid calling ibgts except immediately after an ibcmd call. ibcmd causes ATN to be asserted. EARG (4) EARG results when an invalid argument is passed to a function call.
Appendix B Error Codes and Solutions EABO (6) EABO indicates that an I/O operation has been canceled, usually due to a timeout condition. Other causes for this error are calling ibstop or receiving the Device Clear message from the CIC while performing an I/O operation. Frequently, the I/O is not progressing (the Listener is not continuing to handshake or the Talker has stopped talking), or the byte count in the call which timed out was more than the other device was expecting.
Error Codes and Solutions Appendix B If you are using Windows 3.0 with DMA for data transfers, and you do not have the National Instruments virtual DMA device (nivdmad.386 ) installed, the NI-488.2 software returns EDMA if you try to use DMA to transfer data. Solutions • Install the appropriate virtual device in the system.ini file in the Windows directory in the [386Enh] section. The following line installs the virtual GPIB device: device = drive :\ path \nivgpib.
Appendix B Error Codes and Solutions Solutions Resynchronize the driver and the application before making any further GPIB calls. Resynchronization is accomplished by using one of the following three functions: • ibwait If the returned ibsta contains CMPL then the driver and application are resynchronized. • ibstop The I/O is canceled; the driver and application are resynchronized. • ibonl The I/O is canceled and the interface is reset; the driver and application are resynchronized.
Error Codes and Solutions Appendix B EBUS (14) EBUS results when certain GPIB bus errors occur during device functions. All device functions send command bytes to perform addressing and other bus management. Devices are expected to accept these command bytes within the time limit specified by the default configuration or the ibtmo function. EBUS results if a timeout occurred while sending these command bytes. Solutions • Verify that the instrument is operating correctly.
Appendix B Error Codes and Solutions Although the occurrence of ESRQ warns you of a definite GPIB problem, it does not affect GPIB operations, except that you cannot depend on the RQS bit while the condition lasts. Solutions Check to see if other devices not used by your application are asserting SRQ. Disconnect them from the GPIB if necessary. ETAB (20) ETAB occurs only during the FindLstn, FindRQS , and ibevent functions. ETAB indicates that there was some problem with a table used by these functions.
Appendix C Customer Communication For your convenience, this appendix contains forms to help you gather the information necessary to help us solve technical problems you might have as well as a form you can use to comment on the product documentation. Filling out a copy of the Technical Support Form before contacting National Instruments helps us help you better and faster. National Instruments provides comprehensive technical assistance around the world. In the U.S.
Technical Support Form Photocopy this form and update it each time you make changes to your software or hardware, and use the completed copy of this form as a reference for your current configuration. Completing this form accurately before contacting National Instruments for technical support helps our applications engineers answer your questions more efficiently.
National Instruments software product Version Configuration The problem is List any error messages The following steps will reproduce the problem
Documentation Comment Form National Instruments encourages you to comment on the documentation supplied with our products. This information helps us provide quality products to meet your needs. Title: NI-488.2 ™ User Manual for Windows Edition Date: January 1996 Part Number: 370902A-01 Please comment on the completeness, clarity, and organization of the manual.
If you find errors in the manual, please record the page numbers and describe the errors. Thank you for your help.
Glossary Prefix Meaning Value nanomicromillikilomega- 10-9 10-6 10-3 103 106 nµmkM- A acceptor handshake Listeners use this GPIB interface function to receive data, and all devices use it to receive commands. See source handshake and handshake . access board The GPIB board that controls and communicates with the devices on the bus that are attached to it. ANSI American National Standards Institute. ASCII American Standard Code for Information Interchange.
Glossary C CFE Configuration Enable is 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 that HS488 transfers occur without errors. CIC See Controller-In-Charge. Controller-In-Charge (CIC) The device that manages the GPIB by sending interface messages to other devices. CPU Central processing unit.
Glossary E END or END message A message that signals the end of a data string. END is sent by asserting the GPIB End or Identify (EOI) line with the last data byte. EOI A GPIB line that is used to signal either the last byte of a data message (END) or the parallel poll Identify (IDY) message. EOS or EOS byte A 7- or 8-bit end-of-string character that is sent as the last byte of a data message. EOT End of transmission. ESB The Event Status bit is part of the IEEE 488.
Glossary H handshake The mechanism used to transfer bytes from the Source Handshake function of one device to the Acceptor Handshake function of another device. The three GPIB lines DAV, NRFD, and NDAC are used in an interlocked fashion to signal the phases of the transfer, so that bytes can be sent asynchronously (for example, without a clock) at the speed of the slowest device. For more information about handshaking, refer to the ANSI/IEEE Standard 488.1-1987.
Glossary K KB Kilobytes. L LAD (Listen Address) See MLA. language interface Code that enables an application program that uses NI-488 functions or NI-488.2 routines to access the driver. listen address See MLA. Listener A GPIB device that receives data messages from a Talker. low-level function See board-level function. M m Meters. MAV The Message Available bit is part of the IEEE 488.2-defined status byte which is received from a device responding to a serial poll. MB Megabytes of memory.
Glossary N NDAC (Not Data Accepted) One of the three GPIB handshake lines. See handshake . NRFD (Not Ready For Data) One of the three GPIB handshake lines. See handshake . P parallel poll The process of polling all configured devices at once and reading a composite poll response. See serial poll. PIO See programmed I/O. PPC Parallel Poll Configure is the GPIB command (Parallel Poll Configure) used to configure an addressed Listener to participate in polls.
Glossary S s Seconds. SDC Selected Device Clear is the GPIB command used to reset internal or device functions of an addressed Listener. See DCL and IFC. serial poll The process of polling and reading the status byte of one device at a time. See parallel poll . Service Request See SRQ. source handshake The GPIB interface function that transmits data and commands. Talkers use this function to send data, and the Controller uses it to send commands. See acceptor handshake and handshake .
Glossary T TAD (Talk Address) See MTA. Talker A GPIB device that sends data messages to Listeners. TCT Take Control is the GPIB command used to pass control of the bus from the current Controller to an addressed Talker. timeout A feature of the NI-488.2 driver that prevents I/O functions from hanging indefinitely when there is a problem on the GPIB. TLC An integrated circuit that implements most of the GPIB Talker, Listener, and Controller functions in hardware.
Index Symbols ! (repeat previous function) function, wibic, 5-15 $ (execute indirect file) function, wibic, 5-16 + (turn display on) function, wibic, 5-15 - (turn display off) function, wibic, 5-15 A Active Controller. See Controller-in-Charge (CIC). addresses. See GPIB addresses. AllSpoll routine, 7-8, 7-9 to 7-10 ANSI/IEEE Standard 488.1-1987. See GPIB. application development. See also debugging. accessing NI-488.
Index opening devices, 3-8 placing device offline, 3-10 processing of data, 3-10 program shell (illustration), 3-7 reading measurement, 3-10 triggering devices, 3-9 waiting for measurement, 3-9 to 3-10 NI-488 functions, 3-2 to 3-3 advantages, 3-2 board functions, 3-2 to 3-3 device functions, 3-2 one device per board, 3-2 to 3-3 NI-488.
Index B base I/O address, setting, 8-10 batch mode for wibconf utility, 8-13 to 8-15 command pairs (table), 8-15 configuration file, 8-13 to 8-14 board configuration. See wibconf utility. board functions. See NI-488 functions. boards disabling access to GPIB board, 8-10 testing with wibtest, 4-1 to 4-2 Borland C++. See C language.
Index compiling, linking, and running applications Borland C++, 3-17 direct entry with C, 3-18 to 3-22 direct entry with Visual Basic, 3-23 Microsoft C, 3-17 Visual Basic, 3-18 configuration, 1-4 to 1-6. See also GPIB Spy utility; wibconf utility.
Index global status variables, 4-3 GPIB error codes (table), 4-4 to 4-5 GPIB Spy utility, 4-4 GPIBInfo utility, 4-2 to 4-3 timing errors, 4-6 wibic utility, 4-4 wibtest diagnostics, 4-1 to 4-2 cable connections, 4-2 presence of board, 4-1 to 4-2 presence of driver, 4-1 default configurations in wibconf, 8-12 DevClear routine, 3-14 device configuration. See wibconf utility. device functions. See NI-488 functions. device-level calls and bus management, 7-3 to 7-4 direct access to NI-488.
Index EBUS error code definition (table), 4-5 description, B-8 ECAP error code definition (table), 4-5 description, B-7 ECIC error code definition (table), 4-5 description, B-2 to B-3 EDMA error code definition (table), 4-5 description, B-5 to B-6 EDVR error code definition (table), 4-5 description, B-1 to B-2 wibic example, 5-11 EFSO error code definition (table), 4-5 description, B-7 end-of-string character. See EOS.
Index error codes and solutions EABO, B-5 EADR, B-3 to B-4 EARG, B-4 EBUS, B-8 ECAP, B-7 ECIC, B-2 to B-3 EDMA, B-5 to B-6 EDVR, B-1 to B-2 EFSO, B-7 ENEB, B-5 ENOL, B-3 EOIP, B-6 to B-7 ESAC, B-4 to B-5 ESRQ, B-8 to B-9 ESTB, B-8 ETAB, B-9 table of codes, 4-5 error conditions checking for errors before exiting wibconf, 8-13 communication errors, 4-6 repeat addressing, 4-6 termination method, 4-6 configuration errors, 4-5 to 4-6 timing errors, 4-6 wibic error information, 5-9 to 5-10 error variable - iberr,
Index F fax technical support, C-1 FindLstn routine, 3-13 FindRQS routine, 7-8, 7-9 functions. See auxiliary functions, wibic; NI-488 functions. G General Purpose Interface Bus. See GPIB. global variables, 3-3 to 3-5 count variables - ibcnt and ibcntl, 3-5 debugging applications, 4-3 error variable - iberr, 3-5 status word - ibsta, 3-3 to 3-4, A-1 to A-5 GPIB configuration, 1-4 to 1-6. See also wibconf utility.
Index serial polling, 7-5 to 7-10 automatic serial polling, 7-6 to 7-7 autopolling and interrupts, 7-7 stuck SRQ state, 7-6 to 7-7 service requests from IEEE 488 devices, 7-5 from IEEE 488.2 devices, 7-6 SRQ and serial polling with NI-488 device functions, 7-7 to 7-8 with NI-488.
Index high-speed data transfers (HS488), 7-2 to 7-3 enabling HS488, 7-2 to 7-3 setting cable length, 8-10 system configuration effects, 7-3 highlight color, setting, 6-3 I ibask function, 7-3 ibclr function clearing devices, 3-8 using in wibic, example, 5-2 ibcmd function, 7-2 ibcnt and ibcntl variables. See count variables - ibcnt and ibcntl.
Index ibrsp function conducting serial polls, 7-6, 7-7 to 7-8 using in wibic, example, 5-3 ibsta. See status word - ibsta.
Index messages, sending across GPIB, 1-2 to 1-3 data lines, 1-2 handshake lines, 1-3 interface management lines, 1-3 Microsoft C. See C language.
Index placing board offline, 3-16 processing of data, 3-16 program shell (illustration), 3-12 reading measurement, 3-16 triggering instruments, 3-15 waiting for measurement, 3-15 to 3-16 NI-488.2 DLL choosing how to access, 3-1 requirements for direct access, 3-1 unloading or reloading NI-488.2 driver, 1-9 NI-488.2 routines. See also NI-488.2 applications, programming.
Index P parallel polling, 7-10 to 7-12 application example, 2-18 to 2-19 implementing, 7-10 to 7-12 setting duration of, 8-10 using NI-488 functions, 7-10 to 7-11 using NI-488.2 routines, 7-12 PPoll routine, 7-12 PPollConfig routine, 7-12 PPollUnconfig routine, 7-12 primary GPIB address definition, 1-2 purpose, 8-7 setting, 8-7 print (display the ASCII string) function, wibic, 5-17 problem solving. See debugging. programming. See application development; debugging; GPIB programming techniques. R readme.
Index S secondary GPIB address definition, 1-2 setting, 8-7 Send routine configuring instruments, 3-15 using in wibic, 5-13 SendCmds function, 7-2 SendIFC routine, 3-13 SendList routine, 5-12 serial polling, 7-5 to 7-10 application example using NI-488.2 routines, 2-16 to 2-17 automatic serial polling, 7-6 to 7-7 autopolling and interrupts, 7-7 enabling, 8-9 stuck SRQ state, 7-6 to 7-7 service requests from IEEE 488 devices, 7-5 from IEEE 488.
Index status word - ibsta, 3-3 to 3-4 ATN, A-4 CIC, A-4 CMPL, A-3 DCAS, 7-4, A-5 DTAS, 7-4, A-5 END, A-2 ERR, A-2 EVENT, A-3 LACS, 7-4, A-4 layout (table), 3-4 LOK, A-3 programming considerations, 3-3 to 3-4 purpose and use, 3-3 to 3-4 REM, A-4 RQS, A-2 to A-3 SPOLL, A-3 SRQI, A-2 TACS, 7-4, A-4 TIMO, A-2 wibic example, 5-9 string syntax in wibic, 5-5 stuck SRQ state, 7-6 to 7-7 System Controller as Controller-in-Charge, 1-1 configuring, 8-9 T TACS status word condition bit position, hex value, and type (t
Index TIMO status word condition bit position, hex value, and type (table), 3-4 description, A-2 TNT4882C hardware, 7-2 *TRG command, 3-15 triggering devices, example, 2-4 to 2-5 troubleshooting. See debugging; wibic utility. turn display off (-) function, wibic, 5-15 turn display on (+) function, wibic, 5-15 V Visual Basic compiling, linking, and running applications, 3-18 direct entry, 3-23 files available with NI-488.2 software, 1-7 W wait function. See ibwait function.
Index terminate read on EOS, 8-8 timeout setting, 8-7 type of compare on EOS, 8-8 use this GPIB interface, 8-10 default configurations, 8-12 exiting ( or ), 8-12 to 8-13 checking for errors, 8-13 lower level device/board characteristics, 8-5 to 8-6 changing board or device ( and ), 8-6 changing characteristics (, , , or ), 8-6 Help option (), 8-6 Reset Value (), 8-6 Return to Map ( of ), 8-6 screen illustration, 8
Index NI-488 functions examples, 5-1 to 5-4 ibdev, 5-10 to 5-12 ibfind, 5-10 ibrd, 5-12 ibwrt, 5-12 NI-488.2 routines issuing set command before using, 5-13 Receive, 5-13 to 5-14 Send, 5-13 SendList, 5-13 overview, 5-1 programming considerations, 3-5 purpose, 1-7 status word, 5-9 syntax, 5-4 to 5-9 addresses, 5-5 board-level functions (table), 5-7 device-level functions (table), 5-6 NI-488 functions, 5-5 to 5-7 NI-488.