Home
NI-488.2M User Manual for Windows 95 and Windows NT
Contents
1. 3 2 NI 488 Device FUNCtiOns cc eeseeeceseeeeeeceeeeeneeneeees 3 3 NI 488 Board Functions 00 cceeecesseseceseseeeeceseeeeeseeneeeee 3 3 Using NI 488 2 Routines Multiple Boards and or Multiple Devices xi sscssscoestes se ee ee ap NEEE Ea RVOE SAIET hereon 3 3 Checking Status with Global Variables ccc eessecssececesecseeeeeseceeeseceseecaseeeeessaeeess 3 4 Status WOrd 1bStan ci cise ecseeseh sates tent a a e e rE AE KAE whe 3 4 Error Variable Aber icenen aeeiio i aira en E is E 3 5 Count Variables ibent and ibentl 0 eee ee eceseeeeeseeseeeeesecneeeeeeeeeceaeeaeeess 3 6 NI 488 2M User Manual for Windows 95 Windows NT vi National Instruments Corporation Table of Contents Using Win32 Interactive Control to Communicate with Devices 0 ce eeeeeseeeeeeeee 3 6 Programming Model for NI 488 Applications cee ceeeeeseeeceseceeecesecaeesecneeeeenaeeees 3 7 tems t dJnel de 25s sie cones rere ne Ne ae eas cp cb cubed chiens Oink eee E de binds E 3 7 NI 488 Program Shell irssi tniii rers e a a aa 3 8 NI 488 General Program Steps and Examples sseeeseeessseeerssreersersrrsreersee 3 9 Step ls Opena DEVICE correa se arie tEn ESE Eies 3 9 Step 2 Clear the Device pecenie i on e a e et 3 9 Step 3 Communicate with the Device 3 9 Step 4 Place the Device Offline Before Exiting Your Applications nie aea eea raea oeat a aE E 3 10 Programming Model for NI 488 2 Applications
2. GPIB NI 488 2M User Manual for Windows 95 and Windows NT December 1996 Edition Part Number 321037C 01 Copyright 1995 1996 National Instruments Corporation All Rights Reserved Internet Support support natinst com E mail info natinst com FTP Site ftp natinst com Web Address http www natinst com Bulletin Board Support BBS United States 512 794 5422 BBS United Kingdom 01635 551422 BBS France 01 48 65 15 59 Fax on Demand Support 512 418 1111 Telephone Support U S Tel 512 795 8248 Fax 512 794 5678 C A CO SOO 20 International Offices Australia 02 9874 4100 Austria 0662 45 79 90 0 Belgium 02 757 00 20 Canada Ontario 905 785 0085 Canada Qu bec 514 694 8521 Denmark 45 76 26 00 Finland 09 527 2321 France 01 48 14 24 24 Germany 089 741 31 30 Hong Kong 2645 3186 Israel 03 5734815 Italy 02 413091 Japan 03 5472 2970 Korea 02 596 7456 Mexico 5 520 2635 Netherlands 0348 433466 Norway 32 84 84 00 Singapore 2265886 Spain 91 640 0085 Sweden 08 730 49 70 Switzerland 056 200 51 51 Taiwan 02 377 1200 U K 01635 523545 National Instruments Corporate Headquarters 6504 Bridge Point Parkway Austin TX 78730 5039 Tel 512 794 0100 Important Information Warranty Copyright Trademarks The media on which you receive National Instruments software are warranted not to fail to execute programming instructions due to defects in materials and workmanshi
3. sesseeeeeeeeeesesrseereresrsrsrerrerereseseeese 3 11 Items to mdude oprit en p e e a E a iest 3 11 NI 488 2 Program Shell niinc ee eee ceeceseceseceseceseceaeceeesaecsaecseecaeesaeseaseaeeeas 3 12 NI 488 2 General Program Steps and Examples ec eeceeeeeeeeeereeeeeees 3 13 Step 1 Imitialization eci e rea a E E EEEE 3 13 Step 2 Determine the GPIB Address of Your Device 3 13 Step 3 Initialize the Device oo eee ceeeseeseceeeeeceeeecneeeeceaeneeseeees 3 14 Step 4 Communicate with the Device 3 14 Step 5 Place the Device Offline Before Exiting Your Application aaee r eee Baul eh aaa aie 3 15 Language Specific Programming Instructions sc eecesecseeseeseceeeseceeeeeeeeeeeeeseeeeeees 3 15 Microsoft Visual C C Version 2 0 or Higher cceceeseesesceeseeeneeeeeees 3 15 Borland C C Version 4 0 or Higher 0 ceccesseesseeseceeeeneeeseeeeeeeeeeereeeeees 3 15 Visual Basic Version 4 0 or Higher ccccscecsceessesceceeeeseeeseeeeeeeeeeeeeeneees 3 16 Dir ct Entry with Corsico waver cide be ehon Gude edi desea nate soaks 3 16 g pib 32 I EX Ports ootte teoer ea Triana rao EEEE EEA ERTE EEREN 3 16 Directly Accessing the gpib 32 dll Exports 0 0 cee ceeeeeseeeeeneeeeee 3 17 Windows 95 Running Existing GPIB Applications ce eeceeseeecneeeeeeeeeeeeseeneeees 3 19 Running Existing Win16 GPIB Applications cee eeeeeeesseeeeeceeeneeeeenees 3 19 Running Existing DOS GPIB Applications
4. char GetSerialPollResponse int DeviceHandle char SerialPollResponse 0 ibwait DeviceHandle TIMO RQS if ibsta amp ROS J 4 printf Device asserted SRQ n Use ibrsp to retrieve the serial poll response ibrsp DeviceHandle amp SerialPollResponse return SerialPollResponse NI 488 2M User Manual for Windows 95 Windows NT 7 14 National Instruments Corporation Chapter 7 GPIB Programming Techniques SRQ and Serial Polling with NI 488 2 Routines cP Note The NI 488 2M software includes a set of NI 488 2 routines that you can use to conduct SRQ servicing and serial polling Routines pertinent to SRQ servicing and serial polling are A11Spo11 FindRQS ReadStatusByte TestSRQ and WaitSROQ AllsSpo11 can serial poll multiple devices with a single call It places the status bytes from each polled instrument into a predefined array Then you must check the RQS bit of each status byte to determine whether that device requested service ReadStatusByte is similar to All Spol1 except that it only serial polls a single device It is also analogous to the device level NI 488 ibrsp function FindRQS serial polls a list of devices until it finds a device that is requesting service or until it has polled all of the devices on the list The routine returns the index and status byte value of the device requesting service TestSRQ determines whether the SRQ line is asserted or unasserted and
5. Easo e Wo operon aboned neu koma s pma o o NI 488 2M User Manual for Windows 95 Windows NT 4 2 National Instruments Corporation Chapter 4 Debugging Your Application Table 4 1 GPIB Error Codes Continued Error iberr Mnemonic Value Meaning EBUS fepus 14 GPIBbusertor o GPIB bus error ESTB Serial poll status byte queue overflow ESRQ SRQ stuck in ON position ETAB Table problem Configuration Errors Several applications require customized configuration of the GPIB driver For example you might want to terminate reads on a special end of string character or you might require secondary addressing In these cases you can either permanently reconfigure the driver using the NI 488 2M software configuration utility or temporarily reconfigure the driver while your application is running using the ibconfig function LF Note National Instruments recommends using ibconfig to modify the NI 488 2M driver configuration dynamically If your application uses dynamic configuration it will always work regardless of the previous configuration of the driver Refer to the description of ibconfig in the online help or the NJ 488 2M Function Reference Manual for Win32 for more information Timing Errors If your application fails but the same calls issued in the Win32 interactive control utility are successful your program might be issuing the NI 488 2 calls too quickly for your device to process and respond to them Thi
6. National Instruments Corporation 6 9 NI 488 2M User Manual for Windows 95 Windows NT Chapter 6 Win32 Interactive Control Utility Status Word In Win32 Interactive Control all NI 488 functions except ibfind and ibdev and NI 488 2 routines return the status word ibsta in two forms a hex value in square brackets and a list of mnemonics in parentheses In the following example the status word is on the second line showing that the write operation completed successfully dOs ibwrt f2t3x 0100 cmpl count 5 ud0 For more information about the status word refer to Chapter 3 Developing Your Application Error Information If an NI 488 function or NI 488 2 routine completes with an error Win32 Interactive Control displays the relevant error mnemonic In the following example an error condition EBUS has occurred during a data transfer ud0 ibwrt f2t3x 8100 err cmpl error EBUS count 1 ud0 In this example the addressing command bytes could not be transmitted to the device This indicates that either the device udo represents is powered off or the GPIB cable is disconnected For a detailed list of the error codes and their meanings refer to Chapter 4 Debugging Your Application Count Information When an I O function completes Win32 Interactive Control displays the actual number of bytes sent or received regardless of the existence of an error condition NI 488 2M User Manual for Windows 95 W
7. Appendix B Error Codes and Solutions ESTB 15 ESRQ 16 Solutions e Verify that the instrument is operating correctly e Check for loose or faulty cabling or several powered off instruments on the GPIB e Ifthe timeout period is too short for the driver to send command bytes increase the timeout period ESTB is reported only by the ibrsp function ESTB indicates that one or more serial poll status bytes received from automatic serial polls have been discarded because of a lack of storage space Several older status bytes are available however the oldest is being returned by the ibrsp call Solutions e Call ibrsp more frequently to empty the queue e Disable autopolling with the ibconfig function option IbcAUTOPOLL or the GPIB configuration utility ESRQ can only be returned by a device level ibwait call with RQS set in the mask ESRQ indicates that a wait for RQS is not possible because the GPIB SRQ line is stuck on This situation can be caused by the following events e Usually a device unknown to the software is asserting SRQ Because the software does not know of this device it can never serial poll the device and unassert SRQ e A GPIB bus tester or similar equipment might be forcing the SRQ line to be asserted e A cable problem might exist involving the SRQ line Although the occurrence of ESRQ warns you of a definite GPIB problem it does not affect GPIB operations except that you cannot depend on
8. END dev brd END indicates either that the GPIB EOI line has been asserted or that the EOS byte has been received if the software is configured to terminate a read on an EOS byte If the GPIB board is performing a shadow handshake as a result of the ibgts function any other function can return a status word with the END bit set if the END condition occurs before or during that call END is cleared when any I O operation is initiated Some applications might need to know the exact I O read termination mode of a read operation EOI by itself the EOS character by itself or EOI plus the EOS character You can use the ibconfig function option IbcEndBit IsNormal to enable a mode in which the END bit is set only when EOI is asserted In this mode if the I O operation completes because of the EOS character by itself END is not set The application should check the last byte of the received buffer to see if it is the EOS character NI 488 2M User Manual for Windows 95 Windows NT A 2 National Instruments Corporation SRQI brd RQS dev Appendix A Status Word Conditions SRQI indicates that a GPIB device is requesting service SRQI is set whenever the GPIB board is CIC the GPIB SRQ line is asserted and the automatic serial poll capability is disabled SRQI is cleared either when the GPIB board ceases to be the CIC or when the GPIB SRQ line is unasserted RQS appears in the status word only after a device level call and indic
9. If the wait for the service request succeeded get the device s serial poll response byte and verify that it indicates that the device obtained a good measurement using the ibrsp function Step 3e Read the measurement from the device using the ibra function and record it in a list of device measurements Repeat steps 3b through 3e for each measurement you want to acquire NI 488 2M User Manual for Windows 95 Windows NT 3 10 National Instruments Corporation Chapter 3 Developing Your Application Step 4 Place the Device Offline Before Exiting Your Application Once you are finished accessing the GPIB device take it offline using the ibon1 function before you exit your application Programming Model for NI 488 2 Applications Items to Include National Instruments Corporation This section discusses items you should include in an application that uses NI 488 2 routines general program steps and an NI 488 2 example In a C application include the header files windows h and decl 32 h windows h the standard Windows header file contains definitions used by decl 32 h and decl 32 h contains prototypes for the GPIB routines and constants that you can use in your application Check for errors after each NI 488 2 routine call Declare and define a function to handle GPIB errors This function takes the device offline and closes the application If the function is declared as void gpiberr char msg function
10. SerialPollResponse return Example 2 Using AllSpoll This example illustrates the use of Al1Spo11 to serial poll three devices with a single call void GetAllSerialPollResponses Addr4882_t AddrList short ResponseList int WaitResult WaitSRO 0 amp WaitResult if WaitResult printf SRQ is asserted n AllSpoll 0 AddrList ResponseList if ibsta amp ERR for i 0 AddrList i NOADDR i printf Device at pad x returned byte x n AddrList i ResponseList i return NI 488 2M User Manual for Windows 95 Windows NT 7 16 National Instruments Corporation Chapter 7 GPIB Programming Techniques 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 The advantage of parallel polling is that a single parallel poll can easily check up to eight individual devices at once In comparison eight separate serial polls would be required to check eight devices for their serial poll response bytes The value of the individual status bit ist determines the parallel poll response Implementing a Parallel Poll You can implement parallel polling with either NI 488 functions or NI 488 2 routines If you use NI 488 2 routines to execute parallel polls you do not need extensive knowledge of the parallel polling messages However you should use the NI 488 functions for parallel
11. 16 Bit Windows Support Files ec ceeeceseeeesseceeeeeceeeseceeeeeeeeens 1 7 DOS Support Filesi 3 5 c tesa saa i hates Rian hha 1 7 Microsoft C C Language Interface Files cee eeeeeeeeeeeeeeee 1 7 Borland C C Language Interface Files eee eseeeseeeeeeeeneeeeeee 1 8 Microsoft Visual Basic Language Interface Files sees 1 8 Sample Application Files cece ceesecseeeecneeeeceseneeeeceaeeeessesseeeeen 1 8 How the NI 488 2M Software Works with Windows 95 essees 1 8 National Instruments Corporation v NI 488 2M User Manual for Windows 95 Windows NT Table of Contents Uninstalling the GPIB Hardware from Windows 95 1 9 Uninstalling the GPIB Software for Windows 95 00 ceeeseecesecneeeecneeeeeeeene 1 11 The NI 488 2M Software for Windows NT ue eecseecceceseceseeeceeceaeceeesecaeeseenereeeeeens 1 13 NI 488 2M Software for Windows NT Components sesseseeeseeeeeeeeee 1 13 NI 488 2M Driver and Driver Utilities 0 0 0 cee eeeeeeseeeeeeeeeeee 1 13 DOS and 16 Bit Windows Support Files 0 0 0 ec eeeeeseeeeectecreeeeeee 1 13 Microsoft C C Language Interface Files tee eeeeeeseeeeeeeee 1 14 Borland C C Language Interface Files 0 0 eeeseeeeseeeeeeeeee 1 14 Microsoft Visual Basic Language Interface Files ee 1 14 Sample Application Files cc ceseeeseeceseeeceseceeeeessecaeeseeseseeeeaees 1 14 How the NI 488 2M Software Works with Windows NT ceeeeeeeeeees 1 15 Un
12. Items to Include National Instruments Corporation In a C application include the header files windows h and decl 32 h windows h the standard Windows header file contains definitions used by dec1 32 h and decl 32 h contains prototypes for the GPIB functions and constants that you can use in your application Check for errors after each NI 488 function call Declare and define a function to handle GPIB errors This function takes the device offline and closes the application If the function is declared as void gpiberr char msg function prototype then your application invokes it as follows if ibsta amp ERR gpiberr GPIB error 3 7 NI 488 2M User Manual for Windows 95 Windows NT Chapter 3 Developing Your Application NI 488 Program Shell Figure 3 1 is a flowchart of the steps to create your application using NI 488 functions The flowchart is for device level calls SA START Open Device ibdev Are All Devices Open Make a Device Level Call e Send Data to Device ibwrt e Receive Data From Device ibrd e Clear Device ibclr e Serial Poll Device ibrsp and so on Finished GPIB Programming Yes Close Device ibon1 Closed All Devices Figure 3 1 General Program Shell Using NI 488 Device Functions NI 488 2M User Manual for Windows 95 Windows NT 3 8 National Instruments Corporation Chapter 3 Developing Your Applicati
13. National Instruments Corporation Chapter 1 Introduction The following sections describe the NI 488 2M software which controls the flow of communication on the GPIB The NI 488 2M Software for Windows 95 NI 488 2M Software for Windows 95 Components The following section highlights important components of the NI 488 2M software for Windows 95 and describes the function of each component NI 488 2M Driver and Driver Utilities The distribution disk contains the following driver and utility files National Instruments Corporation A documentation file readme t xt that contains important information about the NI 488 2M software and a description of any new features Before you use the software read this file for the most recent information Native 32 bit NI 488 2M driver components A collection of dynamically loadable Plug and Play aware and multitasking aware virtual device drivers and dynamic link libraries They are installed into the Windows System directory A Win32 dynamic link library goib 32 d11 that acts as the interface between all Windows 95 GPIB applications and the NI 488 2M driver components Win32 Interactive Control is a utility that you use to communicate with the GPIB devices interactively using NI 488 2 functions and routines It helps you to learn the NI 488 2 routines and to program your instrument or other GPIB devices GPIB Spy is the GPIB application monitor program It is a debugging tool
14. SRQ and Serial Polling with NI 488 2 Routines cece eeecseeeecneeeeeeeeee 7 15 Example 1 Using FindRQS occ ceceeescsseseeeeceseeeeeseceeesecnesneeeeene 7 16 Example 2 Using AlSpoll oct eeeeseeceseseeesecreeeeceeseeseceeeeesaees 7 16 Parallel Poin Aa cicc s esseet sales E S Gia aia tdeavee sh attitt cseesanzaes 7 17 Implementing a Parallel Poll ceceecesccesecseeeeceeeecseecaeeeneeeseeeeeeseeeeeeneees 7 17 Parallel Polling with NI 488 Functions n se 7 17 Parallel Polling with NI 488 2 Routines 0 0 ceseeeceeeecereeeeeeeeeeee 7 18 Chapter 8 GPIB Configuration Utility COVELVIEW sisi ERATARA 8 1 Windows 95 Configuring the NI 488 2M Software ccecescsescseceeeeeetecneeeeenes 8 2 Windows NT Configuring the NI 488 2M Software 0 ceeeessesecssesseeseeecneeeeenees 8 4 Appendix A Status Word Conditions ERR dev brd sss 4 sc0i anans Rite Abts a iach bv ate AREE Sue hala A 2 TMO dev brd arrinin ia i hdc eileen G Ryerss eceoa teased anes A 2 END devs ibtd AAE EE Bod Piss E sient ceded Seater a Mira tie dates ore A 2 SROM brd hitch ac e a e wea Rae Re hae A 3 ROS GEV 55 fesisisiesns acute eect n r leivatesiel a a A oe E hh tebe A 3 CMPE dev Br saris is eines Ai iiss ied Ai ee Be ag nee sith A 3 LOK Pid e enim nth tha pitie ape ied rete panel eel eters A 3 REM brdis tesa pases iri Ae aoe ee i ee A 4 CIC 1d isis te tonessestiverensosensth etter a nit gui witha ideas deg thew tetes A 4 ATN bt sch
15. d114882 c The NI 488 2M software also includes a sample program written in Visual Basic samp4882 frm 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 typically 0 for GPIBO Step 2 Determine the GPIB Address of Your Device If you do not know the address of your device you can use the FindLstn routine to find all the devices attached to the GPIB The FindLstn routine requires the following parameters e Interface board number typically set to 0 because your board is GPIBO e A list of primary addresses terminated with the NOADDR constant e A list of GPIB addresses of devices found listening on the GPIB e Limit which is the number of the GPIB addresses to report The FindLstn routine tests for the presence of all of the primary addresses that are passed to it If a device is present at a particular primary address then the primary address is stored in the GPIB addresses list Otherwise all secondary addresses of the given primary address are tested and the GPIB address of any devices found are stored in the GPIB addresses list Once you have the list of GPIB addresses you can determine which one corresponds to your instrument and use it for subsequent NI 488 2 calls Alternately if you already know your GPIB device s primary and secondary address you
16. it takes a reading from that strain gauge 6 If the reading matches the desired consistency a dialog window appears on the computer screen and prompts the mixer operator to remove the mixture and start a new batch Otherwise a dialog window prompts the operator to service the mixer in some other way Steps 3 through 6 are repeated as long as the mixers are in operation 7 After the last batch of syrup has been processed the application returns the interface board to its original state by taking it offline NI 488 2M User Manual for Windows 95 Windows NT 2 16 National Instruments Corporation Chapter 2 Application Examples GPIB Cable GPIB Cable GPIB Cable a DA NE 4 Computer Strain Gauge 1 Strain Gauge 2 Strain Gauge 3 m J SendList Configure Strain Gauges to Request n iiir Service When They Sheen Have a Reading gt WaitSRQ Wait For 1 Or More i Strain Gauges to Request Service Request Service Finaros Serial Poll Each Strain Gauge Until One Requesting Service Did You Request Is Located Service 4 Receive Get a Reading From R sbo s Strain Gauge lt 4 a p i Does the Gauge Need Service y N Provide Whatever i Q Service Is Required Mixture Is Ready Display Remove Mixture Message Done For the Day 4 Yes 7 CLEAN UP Figure 2 7 Program Flowchart for Example 7 National Instruments Corporation 2 17 NI 4
17. table 6 9 help for GPIB Spy 5 2 Help option function Win32 Interactive utility 6 9 high speed data transfers HS488 7 2 to 7 3 enabling HS488 7 2 to 7 3 setting cable length 7 2 system configuration effects 7 3 HS488 See high speed data transfers HS488 HSS488 configuration message 7 3 ibask function 7 3 ibclr function clearing devices 3 9 using in Win32 Interactive Control example 6 3 ibcnt and ibcntl variables 3 6 ibconfig function configuring GPIB board as CIC 7 2 configuring GPIB driver 4 3 determining assertion of EOI line 7 2 enabling autopolling 7 13 National Instruments Corporation l 7 Index enabling high speed data transfers 7 2 to 7 3 modifying NI 488 2M driver configuration dynamically note 4 3 ibdev function opening devices 3 9 using in Win32 Interactive Control example 6 2 ibeos function 7 1 ibeot function 7 1 iberr error variable 3 5 to 3 6 ibnotify function asynchronous event notification in Win32 GPIB applications example 7 6 to 7 9 calling 7 4 to 7 5 ibonl function placing device offline 3 10 3 15 using in Win32 Interactive Control example 6 4 ibppc function conducting parallel polls 7 17 to 7 18 unconfiguring device for parallel polling 7 18 ibrd function reading measurement from device 3 10 using in Win32 Interactive Control example 6 3 ibrpp function 7 18 ibrsp function automatic serial polling 7 13 SRQ and serial polling 7 14 i
18. 3 15 triggering instruments 3 14 waiting for measurements 3 14 NI 488 2 routines choosing between NI 488 functions and NI 488 2 routines 3 2 to 3 4 NI 488 2M User Manual for Windows 95 Windows NT l 2 using with multiple boards or devices 3 3 to 3 4 Win32 Interactive Control for communicating with devices 3 6 applications existing See existing applications running asynchronous event notification in Win32 applications 7 4 to 7 9 calling ibnotify function 7 4 to 7 5 ibnotify programming example 7 6 to 7 9 asynchronous I O application example 2 6 to 2 7 ATN attention line table 1 3 ATN status word condition bit position hex value and type table 3 5 description A 4 automatic serial polling See serial polling auxiliary functions Win32 Interactive Control 6 9 board functions See NI 488 functions Borland C C language interface files NI 488 2M for Windows 95 1 8 NI 488 2M for Windows NT 1 14 programming instructions 3 15 borlandc_gpib 32 obj file 1 8 1 14 buffer option function Win32 Interactive Control 6 9 bulletin board support E 1 C C language direct entry for application development 3 16 to 3 19 directly accessing gpib 32 dll exports 3 17 to 3 19 gpib 32 dll exports 3 16 to 3 17 National Instruments Corporation cable length for high speed data transfers 7 2 7 3 CIC See Controller in Charge CIC CIC Protocol 7 11 CIC status word condition bit position hex value an
19. 61 through 6F are valid If the cable length was configured properly in the GPIB Configuration Utility you can determine how many meters of cable are in your system by calling ibask option IbaHSCableLength in your application For CFE and CFGn messages refer to the online help or Appendix A Multiline Interface Messages in the NI 488 2M Function Reference Manual for Win32 System Configuration Effects on HS488 Maximum HS488 data transfer rates can be limited by your host computer and GPIB system setup For example when using a PC compatible computer with PCI bus the maximum obtainable trasfer rate is 8 Mbytes s but when using a PC compatible computer with ISA bus the maximum transfer rate obtainable is only 2 Mbytes s The same IEEE 488 cabling constraints for a 350 ns T1 delay apply to HS488 As you increase the amount of cable in your GPIB configuration the maximum data transfer rate using HS488 decreases For example two HS488 devices connected by two meters of cable can transfer data faster than four HS488 devices connected by four meters of cable National Instruments Corporation 7 3 NI 488 2M User Manual for Windows 95 Windows NT Chapter 7 GPIB Programming Techniques Waiting for GPIB Conditions Asynchronous Applications You can use the ibwait function to obtain the current ibsta value or to suspend your application until a specified condition occurs on the GPIB If you use ibwait with a parameter of zero it immedia
20. ANSI IEEE Standard 488 1 1987 and the ANSI TEEE Standard 488 2 1992 respectively which define the GPIB The Glossary lists abbreviations acronyms metric prefixes mnemonics symbols and terms Related Documentation The following document contains information that you may find helpful as you read this manual e ANSI TEEE Standard 488 1 1987 IEEE Standard Digital Interface for Programmable Instrumentation e ANSI IEEE Standard 488 2 1992 IEEE Standard Codes Formats Protocols and Common Commands e Microsoft Windows 95 Online Help e Microsoft Windows NT Online Help e Microsoft Win32 Software Development Kit for Microsoft Windows Customer Communication National Instruments wants to receive your comments on our products and manuals We are interested in the applications you develop with our products and we want to help if you have problems with them To make it easy for you to contact us this manual contains comment and configuration forms for you to complete These forms are in Appendix E Customer Communication at the end of this manual NI 488 2M User Manual for Windows 95 Windows NT xvi National Instruments Corporation Chapter Introduction This chapter gives an overview of GPIB and the NI 488 2M 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 v
21. Win32 Interactive Control Utility Table 6 2 Syntax for Board Level NI 488 Functions in Win32 Interactive Control ibask option Return configuration information where option is a mnemonic for a configuration parameter Become active Controller ibomd_cndbut ibcmda cmdbuf Send commands asynchronously ibconfig option Alter configurable parameters where opt ion is mnemonic for a value configuration parameter Change disable EOS message Enable disable END message ibfind udname Return unit descriptor where udname is the symbolic name of board for example gpib0 Request release system control continues National Instruments Corporation 6 7 NI 488 2M User Manual for Windows 95 Windows NT Chapter 6 Win32 Interactive Control Utility Table 6 2 Syntax for Board Level NI 488 Functions in Win32 Interactive Control Continued ibwait mask Wait for selected event where mask is a hex or decimal integer or a list of mask bit mnemonics such as ibwait TIMO CMPL ibwrt wrtbuf Write data ibwrta wrtbuf Write data asynchronously ibwrtf flname Write data from a file where f1name is pathname of file to write Table 6 3 Syntax for NI 488 2 Routines in Win32 Interactive Control Serial poll multiple devices DevClear address Clear a device Find device asserting SRQ PPollConfig address dataline Configure device for parallel poll lineSense Put devices in local lockout continues NI 488 2M User Manual for Window
22. and MTA and perhaps a secondary address MSA The GPIB board has both a GPIB address and an I O address Refers to the National Instruments family of GPIB interface boards Go To Local It is the GPIB command used to place an addressed Listener in local front panel control mode 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 NI 488 2M User Manual for Windows 95 Windows NT Glossary hex high level function HS488 Hz ibent iberr ibsta IEEE interface message TO T O address NI 488 2M User Manual for Windows 95 Windows NT G 4 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 Hexadecimal a number represented in base 16 For example decimal 16 hex 10 See device level function 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 Hertz After each NI 488 I O function this global variable contains the actual number of bytes transmitted A global variable that contains the specific error code associated with a function call that failed At the
23. and a mask of RQS CMPL END or TIMO If you are using board level calls you call ibnotify with a board handle for ud and a mask of any values except RQS or ERR Note that the NI 488 2M User Manual for Windows 95 Windows NT 7 4 National Instruments Corporation Chapter 7 GPIB Programming Techniques ibnotify mask bits are identical to the ibwait mask bits In the example of waiting for your GPIB device to request service you might choose to pass ibnotify a mask with RQS for device level or SRQI for board level The Callback function that you register with the ibnotify call is invoked by the GPIB driver when one or more of the mask bits passed to ibnotify is TRUE The function prototype of the callback is as follows int _ stdcall Callback int ud unit descriptor int ibsta ibsta value int iberr iberr value long ibcentl ibcntl value void RefData user defined reference data The callback function is passed a unit descriptor the current values of the GPIB global variables and the user defined reference data that was passed to the original ibnotify call The GPIB driver interprets the return value for the callback as a mask value that is used to automatically rearm the callback if it is non zero For a complete description of ibnotify refer to the online help or NJ 488 2M Function Reference Manual for Win32 CF Note The ibnotify Callback is executed in a separate thread of execution from the rest
24. and ibwrt fW You can use either the Unicode or ASCII versions of these functions with Windows NT but only the ASCII versions with Windows 95 In addition to pointers to the status variables and a handle to the loaded gpib 32 d11 you must define the direct entry prototypes for the functions you use in your application The prototypes for each function exported by gpib 32 d11 can be found in the N 488 2M Function Reference Manual for Win32 The NI 488 2M direct entry sample programs illustrate how to use direct entry to access gpib 32 d11 For more information on direct entry refer to the Win32 SDK Software Development Kit online help Directly Accessing the gpib 32 dll Exports Make sure that the following lines are included at the beginning of your application ifdef _ cplusplus extern C endif include lt windows h gt include decl 32 h ifdef _ cplusplus endif In your Win32 application you first need to load gpib 32 d11 The following code fragment illustrates how to call the LoadLibrary function and check for an error HINSTANCE Gpib32Lib NULL Gpib32Lib LoadLibrary GPIB 32 DLL if Gpib32Lib NULL return FALSE Next your Win32 application needs to use Get ProcAddress to get the addresses of the global status variables and functions your application needs to use The following code fragment illustrates how to get the addresses of the pointers to the status variables and a
25. application Examine the value of ibsta after each NI 488 or NI 488 2 call If a call fails the ERR bit of ibsta is set and an error code is stored in iberr For more information about global status variables refer to Chapter 3 Developing Your Application Why does the uninstall program leave some components installed The uninstall program removes only items that the installation program installed If you add anything to a directory that was created by the installation program the uninstall program does not delete that directory National Instruments Corporation C 5 NI 488 2M User Manual for Windows 95 Windows NT Appendix C Windows 95 Troubleshooting and Common Questions because the directory is not empty after the uninstallation You can remove the remaining components yourself What information should I have before I call National Instruments When you call National Instruments you should have the results of the diagnostic test Also make sure you have filled out the Technical Support Form in Appendix E Customer Communication NI 488 2M User Manual for Windows 95 Windows NT C 6 National Instruments Corporation Windows NT Appendix Troubleshooting and Common Questions This appendix describes how to troubleshoot problems and lists some common questions for Windows NT users Using Windows NT Diagnostic Tools There are many reasons why the NI 488 2M driver might not load If the software is not properl
26. are sending data or commands the count variables reflect the number of bytes sent In your application you can use the count variables to null terminate an ASCII string of data received from an instrument For example if data is received in an array of characters you can use ibcnt1 to null terminate the array and print the measurement on the screen as follows char rdbuf 512 iord aud rdbuft 20L if ibsta amp ERR rdbuf ibcntl 0 printf Read s n rdbuf else error Using Win32 Interactive Control to Communicate with Devices Before you begin writing your application you might want to use the Win32 Interactive Control utility With Win32 Interactive Control you communicate with your instruments from the keyboard rather than from an application You can use Win32 Interactive Control to learn to communicate with your instruments using the NI 488 functions or NI 488 2 routines For specific device communication instructions refer to the user manual that came with your instrument For information about using Win32 Interactive Control and for detailed examples refer to Chapter 6 Win32 Interactive Control Utility NI 488 2M User Manual for Windows 95 Windows NT 3 6 National Instruments Corporation Chapter 3 Developing Your Application Programming Model for NI 488 Applications This section discusses items you should include in your application general program steps and an NI 488 example
27. 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 2M software on the host computer and is familiar with the programming instructions for the film recorder as described in the user manual provided by the manufacturer She places a fresh roll of film in the camera and launches a simple application she has written using high level GPIB commands With the aid of the application she records a few images on film The following steps correspond to the program flowchart in Figure 2 5 1 The application initializes the GPIB by bringing the interface board in the computer online 2 The application brings the film recorder to a ready state by issuing a device clear instruction The film recorder is now set up for operation using its default values The graphic arts designer has previously established that the default values for the film recorder are appropriate for the type of film she is using 3 The application advances the new roll of film into position so the first image can be exposed on the first frame of film This is done by sending the appropriate instructions as described in the film recorder programming guide 4 The application waits for the film recorder to signify that it is done loading
28. by clicking on the question mark button and then clicking on any area of the screen Locating Errors with GPIB Spy All GPIB calls returned with an error are displayed in red within the main GPIB Spy window Viewing Properties for Recorded Calls You can view the detailed properties of any call recorded in the main GPIB Spy window by double clicking on the call The Call Properties window contains general input output and buffer information Figure 5 2 shows the Buffer tab for a device level ibwrt call NI 488 2M User Manual for Windows 95 Windows NT 5 2 National Instruments Corporation Chapter 5 GPIB Spy Utility GPIB Spy Call Properties ibwrt 21x General Input Dutput m Input Buffer Brief 00000000 63 6F 6E 66 34 64 63 20 conf dc 00000008 6D 61 78 3B nax Previous Next Close Figure 5 2 GPIB Spy Buffer Tab for Device Level ibwrt Exiting GPIB Spy When you exit GPIB Spy its current configuration is saved and used to configure GPIB Spy when you start it again Note that unless you explicitly save the data captured in GPIB Spy before you exit that information is lost Performance Considerations GPIB Spy can slow down the performance of your GPIB application and certain configurations of GPIB Spy have a larger impact on performance than others For example configuring GPIB Spy to record calls to an output file or to use full buffers might have a significant impact on the per
29. function n times function Win32 Interactive Control 6 9 n execute function n times function Win32 Interactive Control 6 9 NDAC not data accepted line table 1 3 NI 488 applications programming See also application development acquiring measurement 3 10 clearing devices 3 9 flowchart of programming with device level functions 3 8 general steps and examples 3 9 to 3 10 items to include 3 7 opening devices 3 9 placing device offline 3 10 program shell illustration 3 8 reading measurement 3 10 triggering devices 3 10 waiting for measurement 3 10 NI 488 functions parallel polling 7 17 to 7 18 programming considerations advantages of using 3 2 board level functions 3 3 choosing between functions and routines 3 2 to 3 4 device level functions 3 3 when to use functions 3 2 serial polling 7 14 using in Win32 Interactive Control examples 6 2 to 6 4 syntax 6 6 to 6 7 NI 488 2 applications programming communicating with devices 3 14 to 3 15 determining GPIB address of device 3 13 to 14 flowchart of programming with routines 3 12 general steps and examples 3 13 to 3 15 initialization 3 13 National Instruments Corporation initializing devices 3 14 items to include 3 11 placing board offline 3 15 program shell illustration 3 12 reading measurement 3 14 to 3 15 triggering instruments 3 14 waiting for measurement 3 14 NI 488 2 routines parallel polling 7 18 to 7 19 programm
30. global values and that thread always just adds information increases the count or adds another reading to the array of floats int __stdcall MyCallback int ud int LocalIbsta int Locallberr long LocallIbcntl void RefData int ReadingsTaken 0 float Readings 1000 BOOL DeviceError FALSE int main int ud Assign a unique identifier to the device and store it in the variable ud ibdev opens an available device and assigns it to access GPIBO with a primary address of 1 a secondary address of 0 a timeout of 10 seconds the END messag nabled and the EOS mode disabled If ud is less than zero then print an error message that the call failed and exit the program ud ibdev 0 connect board 1 primary address of GPIB device 0 secondary address of GPIB device T10s 10 second I O timeout 1 EOT mode turned on 0 EOS mode disabled if ud lt 0 printf ibdev failed n return 0 Issue a request to the device to send the data If the ERR bit is set in ibsta then print an error message that the call failed and exit the program ibwrt ud SEND DATA 9L if ibsta amp ERR printf unable to write to device n return 0 NI 488 2M User Manual for Windows 95 Windows NT 7 6 National Instruments Corporation Chapter 7 GPIB Programming Techniques set up the asynchronous event notification on RQS ibnotify
31. gt is your Windows NT directory for example c windows As long as gpib d11 is in that directory it is automatically accessed whenever you launch a Win16 GPIB application National Instruments Corporation 3 21 NI 488 2M User Manual for Windows 95 Windows NT Debugging Your Application Chapter This chapter describes several ways to debug your application Debugging with GPIB Spy You can use the GPIB Spy utility to monitor all of the GPIB calls that are made by GPIB applications Because all applications go through gpib 32 d11 the GPIB calls made by Win32 Win16 and DOS applications are all recorded by GPIB Spy For more information about GPIB Spy refer to the online help available through the application or to Chapter 5 GPIB Spy Utility Debugging with the Global Status Variables After each function call to your NI 488 2M driver ibsta iberr ibcnt and ibcnt1 are updated before the call returns to your application You should check for an error after each GPIB call Refer to Chapter 3 Developing Your Application for more information about how to use these variables within your program to automatically check for errors After you determine which GPIB call is failing and note the corresponding values of the global variables refer to Appendix A Status Word Conditions and Appendix B Error Codes and Solutions These appendixes can help you interpret the state of the driver Debugging with Win32 Interactive C
32. how you might use Win32 Interactive Control to test a sequence of GPIB calls National Instruments Corporation 6 1 NI 488 2M User Manual for Windows 95 Windows NT Chapter 6 Win32 Interactive Control Utility Run the Win32 Interactive Control utility e Windows 95 Select the Win32 Interactive Control item under Start Programs NI 488 2M Software for Windows 95 e Windows NT 3 51 Double click on the Win32 Interactive Control icon in the NI 488 2M Software for Windows NT group of the Program Manager e Windows NT 4 0 and later Select the Win32 Interactive Control item under Start Programs NI 488 2M Software for Windows NT When the Win32 Interactive Control utility first starts it displays the following banner message Win32 Interactive Control Copyright 1996 National Instruments Corporation All rights reserved Type help for help or q to quit The first step is to open either a board handle or device handle to use for further GPIB calls Use ibdev to open a device handle use ibfind to open a board handle or use the set 488 2 command to switch to a 488 2 prompt For help on any Win32 Interactive Control command type in help followed by the command for example help ibdev or help set If you want to use device level calls open a device handle using ibdev The following example shows how you can use ibdev to open a device assign it to access board gpib0 choose a primary address of 6 with no secondary addre
33. installed Run the Diagnostic utility To run the utility select the Diagnostic item under Start Programs NI 488 2M Software for Windows 95 A banner at the bottom of the Diagnostic utility window displays the version of the GPIB software that is installed How many GPIB interfaces can I configure for use with my NI 488 2M software for Windows 95 The NI 488 2M software for Windows 95 can be configured to communicate with up to 100 GPIB interfaces How many devices can I configure for use with my NI 488 2M software for Windows 95 The NI 488 2M software for Windows 95 provides a total of 1 024 logical devices for applications to use The default number of devices is 32 The maximum number of physical devices you should connect to a single GPIB interface is 14 or fewer depending on your system configuration Are interrupts and DMA required with the NI 488 2M software for Windows 95 Neither interrupts nor DMA are required unless you are using a PCMCIA GPIB or GPIB hardware that has analyzer capability in which case at least one interrupt level is required How can I determine if my GPIB hardware and software are correctly installed Run the Diagnostic utility To run the utility select the Diagnostic item under Start Programs NI 488 2M Software for Windows 95 Use the Diagnostic online help to troubleshoot problems NI 488 2M User Manual for Windows 95 Windows NT C 4 National Instruments Corporation Appendix C Win
34. it is disabled the EOI line is not asserted with the last byte of a write You can use the ibeos function to enable disable or configure the EOS modes EOS mode configuration includes the following information e A7 bit or 8 bit EOS byte e EOS comparison method This indicates whether the EOS byte has seven or eight significant bits For a 7 bit EOS byte the eighth bit of the EOS byte is ignored e EOS write method If this is enabled the NI 488 2M driver automatically asserts the GPIB EOI line when the EOS byte is written to the GPIB If the buffer passed into an ibwrt call contains five occurrences of the EOS byte the EOI line is asserted as each of the five EOS bytes are written to the GPIB If an ibwrt buffer does not contain an occurrence of the EOS byte the EOI line is not National Instruments Corporation 7 1 NI 488 2M User Manual for Windows 95 Windows NT Chapter 7 GPIB Programming Techniques asserted unless the EOT mode is enabled in which case the EOI line is asserted with the last byte of the write e EOS read method TIf this is enabled the NI 488 2M driver terminates ibrd ibrda and ibrdf calls when the EOS byte is detected on the GPIB or when the GPIB EOI line is asserted or when the specified count is reached If the EOS read method is disabled ibrd ibrda and ibrdf calls terminate only when the GPIB EOI line is asserted or the specified count has been read You can use the ibconfig function to configure t
35. of your application If your application might be performing other GPIB operations while it is using ibnotify you should use the per thread GPIB globals that are provided by the ThreadIbsta ThreadIberr ThreadIbcnt and ThreadIbcnt1 functions that are described in the Writing Multithreaded Win32 GPIB Applications section of this chapter In addition if your application needs to share global variables with the Callback you should use a synchronization primitive for example semaphore to protect access to any globals For more information on the use of synchronization primitives refer to the documentation on using Win32 synchronization objects that came with your development tools ibnotify Programming Example The following code is an example of how you might use ibnotify in your application Assume that your GPIB device is a multimeter that you program to acquire a reading by sending it SEND DATA The National Instruments Corporation 7 5 NI 488 2M User Manual for Windows 95 Windows NT Chapter 7 GPIB Programming Techniques multimeter requests service when it has a reading ready and each reading is a floating point value In this example globals are shared by the Callback thread and the main thread and the access of the globals is not protected by synchronization In this case synchronization of access to these globals is not necessary because of the way they are used in the application only a single thread is writing the
36. polling when the GPIB board is not the Controller and must configure itself for a parallel poll and set its own individual status bit ist Parallel Polling with NI 488 Functions Follow these steps to implement parallel polling using NI 488 functions Each step contains example code 1 Configure the device for parallel polling using the ibppc function unless the device can configure itself for parallel polling ibppc requires an 8 bit value to designate the data line number the ist sense and whether or not the function configures or unconfigures the device for the parallel poll The bit pattern is as follows 0 1 1 E S D2 D1 DO E is 1 to disable parallel polling and 0 to enable parallel polling for that particular device 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 DO 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 In this example the ibdev command is used to open a device that has a primary address of 3 has no secondary address has a timeout National Instruments Corporation 7 17 NI 488 2M User Manual for Windows 95 Windows NT Chapter 7 GPIB Programming Techniques o
37. returns to the program immediately WaitSRQ is similar to Test SRO except that Wait SRO suspends the application until either SRQ is asserted or the timeout period is exceeded The following examples use NI 488 2 routines 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 The first example uses FindROQS to determine which device is requesting service and the second example uses Al1Spo11 to serial poll all three devices Both examples use WaitSRQ to wait for the GPIB SRQ line to be asserted Automatic serial polling is not used in these examples because you cannot use it with NI 488 2 routines National Instruments Corporation 7 15 NI 488 2M User Manual for Windows 95 Windows NT Chapter 7 GPIB Programming Techniques Example 1 Using FindRQS This example illustrates the use of FindRQS to find the first device that is requesting service void GetASerialPollResponse char DevicePad char DeviceResponse char SerialPollResponse 0 int WaitResult Addr4882_t Addrlist 4 3 4 5 NOADDR WaitSRQ 0 amp WaitResult if WaitResult printf SRQ is asserted n FindRQOS 0 AddrList amp SerialPollResponse j if ibsta amp ERR printf Device at pad x returned byte Sx n AddrList ibcnt int SerialPollResponse DevicePad AddrList ibcnt DeviceResponse
38. the ibsta RQS bit while the condition lasts NI 488 2M User Manual for Windows 95 Windows NT B 8 National Instruments Corporation Appendix B Error Codes and Solutions 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 and FindRQS functions ETAB indicates that there was some problem with a table used by these functions e Inthe case of FindLstn ETAB means that the given table did not have enough room to hold all the addresses of the Listeners found e Inthe case of FindROS ETAB means that none of the devices in the given table were requesting service Solutions In the case of FindLstn increase the size of result arrays In the case of FindRQs check to see if other devices not used by your application are asserting SRQ Disconnect them from the GPIB if necessary National Instruments Corporation B 9 NI 488 2M User Manual for Windows 95 Windows NT Windows 95 Appendix Troubleshooting and Common Questions This appendix describes how to troubleshoot problems and lists some common questions for Windows 95 users Troubleshooting EDVR Error Conditions In some cases calls to NI 488 functions or NI 488 2 routines may return with the ERR bit set in ibsta and the value EDVR in iberr The value stored in ibcnt 1 is useful in troubleshooting the error condition EDVR Error with ib
39. ud RQS MyCallback NULL if ibsta amp ERR printf ibnotify call failed n return 0 while ReadingsTaken lt 1000 amp amp DeviceError Your application does useful work here For example it might process the device readings or do any other useful work disable notification ibnotify ud 0 NULL NULL Call the ibonl function to disable the hardware and software ibonl ud 0 return 1 int __stdcall MyCallback int LocalUd int LocalIbsta int LocallIberr long LocalIbcntl void RefData char SpollByte char ReadBuffer 40 If the ERR bit is set in LocalIbsta then print an error message and return if LocallIbsta amp ERR printf GPIB error d has occurred No more callbacks n Locallberr DeviceError TRUE return 0 Read the serial poll byte from the device If the ERR bit is set in ibsta then print an error message and return Locallbsta ibrsp LocalUd amp SpollByte if LocallIbsta amp ERR printf ibrsp failed No more callbacks n DeviceError TRUE return 0 If the returned status byte equals th xpected response then the device has valid data to send otherwise it has a fault condition to report National Instruments Corporation 7 7 NI 488 2M User Manual for Windows 95 Windows NT Chapter 7 GPIB Programming Techniques if spr expectedResponse printf Device returned i
40. word condition bit position hex value and type table 3 5 NI 488 2M User Manual for Windows 95 Windows NT 1 10 description A 3 running existing applications See existing applications running S sample application files NI 488 2M for Windows 95 1 8 NI 488 2M for Windows NT 1 14 secondary GPIB address 1 2 Send routine 3 14 SendIFC routine 3 13 serial polling 7 12 to 7 16 application example using NI 488 2 routines 2 16 to 2 17 automatic serial polling 7 13 to 7 14 autopolling and interrupts 7 14 stuck SRQ state 7 13 to 7 14 service requests from IEFE 488 devices 7 12 from IEFE 488 2 devices 7 12 to 7 13 SRQ and serial polling with NI 488 device functions 7 14 with NI 488 2 routines 7 15 to 7 16 service requests application examples 2 10 to 2 13 serial polling IEEE 488 devices 7 12 IEEE 488 2 devices 7 12 to 7 13 stuck SRQ state 7 13 to 7 14 Set 488 2 v function Win32 Interactive Control utility 6 9 Set udname function Win32 Interactive Control utility 6 9 setting up your system See configuration software See NI 488 2M software SRQ service request line application examples 2 10 to 2 13 purpose table 1 3 National Instruments Corporation serial polling automatic serial polling 7 13 to 7 14 using NI 488 device functions 7 14 using NI 488 2 routines 7 15 to 7 16 stuck SRQ state 7 13 to 7 14 SRQI status word condition bit position hex value and type table 3 5 desc
41. zero and x for example OxD NI 488 2M User Manual for Windows 95 Windows NT 6 4 National Instruments Corporation String Syntax Address Syntax Chapter 6 Win32 Interactive Control Utility Decimal numbers Enter the number only You can enter strings as an ASCII character sequence hex bytes or special symbols ASCII character sequence Y ou must enclose the entire sequence in quotation marks Hex byte You must use a backslash character and an x followed by the hex value For example hex 40 is represented by x40 Special Symbols Some instruments require special termination or end of string EOS characters that indicate to the device that a transmission has ended The two most common EOS characters are r and n r represents a carriage return character and n represents a linefeed character You can use these special characters to insert the carriage return and linefeed characters into a string as in F3R5T1 r n Many of the NI 488 2 routines have an address or address list parameter An address is a 16 bit representation of the GPIB address of a device The primary address is stored in the low byte and the secondary address if any is stored in the high byte For example a device at primary address 6 and secondary address 0x67 has an address of 0x6706 A NULL address is represented as Oxffff An address list is represented by a comma separated list of addresses such as 1 2 3 Win32 Interactive Control Comm
42. 0 if Pibsta amp ERR printf Call failed NI 488 2M User Manual for Windows 95 Windows NT 3 18 National Instruments Corporation Chapter 3 Developing Your Application Before exiting your application you need to free gpib 32 d11 with the following command FreeLibrary Gpib32Lib For more examples of directly accessing gpib 32 d11 refer to the NI 488 2M direct entry sample programs dlldev c and d114882 c that are installed with the GPIB software For more information on direct entry refer to the Win32 SDK Software Development Kit online help Windows 95 Running Existing GPIB Applications Running Existing Win16 GPIB Applications You can run existing Win16 GPIB applications under Windows 95 by using the pair of 16 to 32 bit thunking DLLs gpib d1l1 and gpib32ft d11 which are installed with your NI 488 2M software To run 16 bit Windows GPIB applications the system uses the special GPIB dynamic link library gpib d11 When you install the NI 488 2M software gpib dll and gpib32ft d11 are copied into the Windows System directory These DLLs are automatically accessed whenever you execute a Win16 GPIB application Running Existing DOS GPIB Applications With the NI 488 2M software properly configured you can run your existing DOS GPIB applications along with your Win16 and Win32 GPIB applications No DOS device driver is required In fact be sure that no older version of the GPIB DOS device driver is being
43. 0 0 0 0 eeeeeeeeeesecreeeecneeseeeeenees 3 19 Windows NT Running Existing GPIB Applications ecesesecesecseeeeeteeeeeseeneeees 3 20 Chapter 4 Debugging Your Application Debugeing with GPIB SPY ceser eyna E e aE SE danse oy ape ence 4 1 Debugging with the Global Status Variables cee ceeecesseeeceeceseeeceseceeeseceeeeeseenees 4 1 Debugging with Win32 Interactive Control 0 0 eee eceeseeeceseeeeeseceeeeecnecaeeseeneeeeesaees 4 1 GPIB Error Codes sorier ese csaciedscasusab etic chance Seoteus E E E EO OEE S 4 2 Configuration Error Sasih aeea E soe E E pte tame setae 4 3 PTI BIOL a e a a nad a a a Ais e a a a e e A e oa Vat 4 3 National Instruments Corporation vij NI 488 2M User Manual for Windows 95 Windows NT Table of Contents Communication Errors s cccccss secigeseshesedhbeg a EE Ar E E ove bepeeveke 4 4 Repeat Addressing vesceseiest E E T A 4 4 Termination Method ccccccccsccccesssecesssceceenseeeceesaeeecnsseceesseeeceesaeesenssseeensee 4 4 Othe Errors tsescaschicelte E sentient ee AE 4 4 Chapter 5 GPIB Spy Utility OVEIVIEW anin vin Ai tiie tusk athens halen E a Geb naib Atesivees ead e eass 5 1 Starting GPIB S py sssssstesehssedscd tii agencies Sich a sais sb EE EI euekantantietas esoiddstveseeess 5 1 Starting GPIB Spy Under Windows 95 0 cceessssesecsecseesecneeeecseeecaeceseeeens 5 1 Starting GPIB Spy Under Windows NT ceeceeeceeeecsseeeeeeceaeeeeeseeneeeeens 5 1 Using the Online
44. 30 34 37 45 2b 30 004 Oa Oa National Instruments Corporation 6 3 NI 488 2M User Manual for Windows 95 Windows NT Chapter 6 Win32 Interactive Control Utility or equivalently ud0 ibrd 18 0100 cmpl count 18 4e 44 43 56 20 30 30 30 NDCV 000 2e 30 30 34 37 45 2b 30 004 Oa Oa When you are finished communicating with the device make sure you put it offline using the ibon1 command as follows ud0 ibonl 0 0100 cmp1 This properly closes the device handle and the ud0 prompt is no longer present Win32 Interactive Control Syntax Number Syntax The following special rules apply to making calls from the interactive control utility e The ud or BoardId parameter is implied by the Interactive Control prompt therefore it is never included in the call e The count parameter to functions is unnecessary because buffer lengths are automatically determined by the interactive control utility e Function return values are handled automatically by the interactive control utility In addition to printing out the return ibsta value for the function it also prints other return values e If you do not know what parameters are appropriate to pass to a given function call type in the function name and press lt Enter gt and the interactive control utility automatically prompts you for each required parameter You can enter numbers as hexadecimal or decimal integer Hexadecimal numbers Y ou must precede hex numbers by
45. 32 dll Exports gpib 32 d11 exports pointers to the global variables and all of the NI 488 2 functions and subroutines Pointers to the global variables ibsta iberr ibcnt and ibcnt1 are accessible through these exported variables int user_ibsta int user_iberr int user_ibcnt long user_ibcntl Except for the functions ibbna ibfind ibrdf and ibwrtf all of the NI 488 2 function and subroutine names are exported from gpib 32 d11 What this means is that to use direct entry to access a particular function all you need to do to get a pointer to the exported function is to call Get ProcAddress passing the name of the function as a parameter The parameters that you use when you invoke the function are identical to those described in the online help and NI 488 2M Function Reference Manual for Win32 These functions all require an argument that is a name ibbna requires a board name ibfind requires a board or device name and ibrdf and ibwrtf take a file name Because Windows NT supports both normal 8 bit and Unicode 16 bit characters gpib 32 d11 exports both normal and Unicode versions of these functions Because Windows 95 NI 488 2M User Manual for Windows 95 Windows NT 3 16 National Instruments Corporation Chapter 3 Developing Your Application does not support 16 bit wide characters use only the 8 bit ASCII versions named ibbnaA ibfindA ibrdfA and ibwrt A The Unicode versions are named ibbnaW ibfindW ibrdfw
46. 6 26 02 Finland 09 527 2321 09 502 2930 France 01 48 14 24 24 01 48 14 24 14 Germany 089 741 31 30 089 714 60 35 Hong Kong 2645 3186 2686 8505 Israel 03 5734815 03 5734816 Italy 02 413091 02 41309215 Japan 03 5472 2970 03 5472 2977 Korea 02 596 7456 02 596 7455 Mexico 5 520 2635 5 520 3282 Netherlands 0348 433466 0348 430673 Norway 32 84 84 00 32 84 86 00 Singapore 2265886 2265887 Spain 91 640 0085 91 640 0533 Sweden 08 730 49 70 08 730 43 70 Switzerland 056 200 51 51 056 200 51 55 Taiwan 02 377 1200 02 737 4644 U K 01635 523545 01635 523154 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 If you are using any National Instruments hardware or software products related to this problem include the configuration forms from their user manuals Include additional pages if necessary Name Title Company Address Fax Phone Computer brand Model Processor Operating system include version number Clock Speed MHz RAM MB Display adapter Mouse __ yes __s ino Other adapters installed Hard disk capacity MB Brand Instruments used National Instruments hardwa
47. 600 baud 8 data bits 1 stop bit no parity FTP Support To access our FTP site log on to our Internet host ftp natinst com as anonymous and use your Internet address such as joesmith anywhere com as your password The support files and documents are located in the support directories National Instruments Corporation E 1 NI 488 2M User Manual for Windows 95 Windows NT Fax on Demand Support Fax on Demand is a 24 hour information retrieval system containing a library of documents on a wide range of technical information You can access Fax on Demand from a touch tone telephone at 512 418 1111 E Mail Support currently U S only You can submit technical support questions to the applications engineering team through e mail at the Internet address listed below Remember to include your name address and phone number so we can contact you with solutions and suggestions support natinst com Telephone and Fax Support National Instruments has branch offices all over the world Use the list below to find the technical support number for your country If there is no National Instruments office in your country contact the source from which you purchased your software to obtain support Y Telephone Fax Australia 02 9874 4100 02 9874 4455 Austria 0662 45 79 90 0 0662 45 79 90 19 Belgium 02 757 00 20 02 757 03 11 Canada Ontario 905 785 0085 905 785 0086 Canada Quebec 514 694 8521 514 694 4399 Denmark 45 76 26 00 45 7
48. 8 2 Routines 0 0 0 eeeeeeeeeeees 3 13 Figure 5 1 GPIB Spy Main Window 0 00 ceeecsssecsseeeeeeceseeeceaeceeeseseeeeeeaesneeeeens 5 2 Figure 5 2 GPIB Spy Input Tab for Device Level ibwrt esseere 5 3 Figure 5 3 GPIB Spy Output Tab for Device Level ibrd woe ee eeeeeneeeeeeenees 5 3 Figure 8 1 NI 488 2M Settings Tab for the AT GPIB TNT PnP 8 3 Figure 8 2 Device Templates Tab for the Logical Device Templates 8 4 Figure 8 3 Main Dialog Box in the GPIB Configuration Utility for Windows NTU cceeeccccceceesssceseecsessssssssccecsessessescsesesssessecsesesesseseecs 8 5 National Instruments Corporation xi NI 488 2M User Manual for Windows 95 Windows NT Table of Contents Tables Table 1 1 GPIB Handshake Lines csceeessessssecseesecseeeeceseeecssesaseeesseeaeeseenees 1 3 Table 1 2 GPIB Interface Management Lines 0 000 eeeeeceeceeeeeneeeeeeeeeeees 1 3 Table 3 1 Stats Word Layout iise ores oesie r ee Ees EEOAE E EEES y 3 5 Table 4 1 GPIB Error Codes cirin e etree E 4 3 Table 6 1 Syntax for Device Level NI 488 Functions in Win32 Interactive Control eoe eee ee E EE E RA 6 6 Table 6 2 Syntax for Board Level NI 488 Functions in Win32 Interactive Control secsi n en ana ai a e aia 6 7 Table 6 3 Syntax for NI 488 2 Routines in Win32 Interactive Control 6 8 Table 6 4 Auxiliary Functions in Win32 Interactive Control 000 ceeeeeeeereeee 6 9 NI 488 2M User Manual for Windows 95
49. 8 2M installation D 1 to D 2 turn OFF display function Win32 Interactive Control 6 9 turn ON display function Win32 Interactive Control 6 9 U uninstalling GPIB hardware from Windows 95 1 9 uninstalling GPIB software from Windows 95 1 11 to 1 12 NI 488 2M User Manual for Windows 95 Windows NT Index unloading NI 488 2M driver for Windows NT 1 16 to 1 17 V vbib 32 bas file 1 14 Visual Basic See Microsoft Visual Basic W wait function See ibwait function WaitSRQ routine conducting serial polls 7 15 waiting for measurement 3 14 Win32 Interactive Control utility auxiliary functions table 6 9 communicating with devices 3 6 count 6 10 debugging applications 4 1 to 4 2 error information 6 10 getting started 6 1 to 6 4 NI 488 function examples 6 2 to 6 4 overview 6 1 programming considerations 3 6 status word 6 9 syntax 6 4 to 6 9 addresses 6 5 board level functions table 6 7 device level functions table 6 6 NI 488 functions table 6 6 to 6 7 NI 488 2 routines 6 8 numbers 6 4 strings 6 4 to 6 5 NI 488 2M User Manual for Windows 95 Windows NT I 12 National Instruments Corporation
50. 88 2M User Manual for Windows 95 Windows NT Chapter 2 Application Examples 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 The monitoring unit consists of a GPIB temperature transducer and a GPIB power supply The temperature transducer is used to probe the temperature of each metal The power supply is used to start a motor to pour the metal into the mold when it reaches a predefined temperature The three monitoring units are connected to the IEEE 488 2 interface board of a computer that has the NI 488 2M software installed An application using NI 488 2 routines operates the three monitoring units The application will obtain information from the multiple units by conducting a parallel poll and will then determine when to pour the metals into the mixture tank The following steps correspond to the program flowchart in Figure 2 8 1 The application initializes the GPIB by bringing the interface board in the computer online 2 The application configures the temperature transducer in the first monitoring unit by choosing which of the eig
51. AN UP Figure 2 3 Program Flowchart for Example 3 National Instruments Corporation 2 7 NI 488 2M User Manual for Windows 95 Windows NT Chapter 2 Application Examples 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 He is using an application written by an intern in the department who has read the scanner s instruction manual and is familiar with the scanner s programming requirements The following steps correspond to the program flowchart in Figure 2 4 1 The application initializes the GPIB by bringing the interface board in the computer online 2 The application sends a GPIB clear message to the scanner initializing it to its power on defaults 3 The scanner needs to detect a delimiter indicating the end of a command In this case the scanner expects the commands to be terminated with lt CR gt lt LF gt carriage return r and linefeed n The application sets its end of string EOS byte to lt LF gt The linefeed code indicates to the scanner that no more data is coming and is called the end of string byte It flags an end of string condition for this particular GPIB scanner The same effect could be accomplished by asserting the EOI line when the c
52. B Spy records all GPIB calls made to the NI 488 2M driver Figure 5 1 shows the main GPIB Spy window with several calls recorded in it Starting GPIB Spy Under Windows 95 Start GPIB Spy by choosing the GPIB Spy item under Start Programs NI 488 2M Software for Windows 95 Starting GPIB Spy Under Windows NT In Windows NT 3 51 start GPIB Spy by double clicking on the GPIB Spy icon in the NI 488 2M Software for Windows NT group of the Program Manager In Windows NT 4 0 or later start GPIB Spy by choosing the GPIB Spy item under Start Programs NI 488 2M Software for Windows NT National Instruments Corporation 5 1 NI 488 2M User Manual for Windows 95 Windows NT Chapter 5 GPIB Spy Utility GPIB Spy capture on Ioj x File View Spy Help AE x es e GPIB Calls ibsta il Time ibdev 0 1 0 0x0 T10s 13 1 0x0000 00100 11 37 37 070 ibclr UD0 00100 11 37 40 360 ibwrt UDO IDN 5 0x5 00100 11 37 59 970 ibrdi UDO National Inst 100 0x64 0x2100 0 20 0x141 11 38 18 530 ibwrt UDO conf de 12 0xC 00100 12 0C 11 38 35 560 ibrd UDO 7 5E 02 100 0x64 02100 7 Ox 11 38 59 010 For Help press F1 Call count 6 h Figure 5 1 GPIB Spy Main Window Using the Online GPIB Spy Help The GPIB Spy utility has built in context sensitive online help You can access it through GPIB Spy s Help menu to view descriptions of all GPIB Spy features You can also access the GPIB Spy context sensitive help
53. Conventions Used in This Manual ccccccccsccccesssccecssscececseeecessseceenseeecessseeesseseeees XV Related Documentation c ccccccccccesssscecssceceessececesssececnseseceseeecessseeecesseecestseecessaeees xvi Customer Communication cccccccccccccsesessscecececeessaececececseseseaececesessaaeceeeeeceesesteaeees xvi Chapter 1 Introduction GPIB ONUA RATA E EE E 1 1 Talkers Listeners and Controllers ccccccccesssececssceceessececessseeeenseeeeenaes 1 1 Controller In Charge and System Controller eee eee ese ceeeereeeeeeeeees 1 1 GPIB Addressitio 2 cccscsscevouscss cele iiss tiesteet fits Aas bestia oa aaa 1 2 Sending Messages across the GPIB cscessscsessesecseeseceseeeeesecaeeeeeaesaeeeeens 1 2 Data Lines sins dain ioh cielo Sia ea Be Si 1 2 Handshake Lines 3s esssiiiioearase ain onanianne apne 1 3 Interface Management Lines ce eeeeseeseeeeeseceeeeeceeeeceseneeeeeeaees 1 3 Setting up and Configuring Your System cece sceeeceseeeeeseceeeeecneeeeeeeene 1 4 Controlling More Than One Board ceesceseeeeesesseeeeesecneeeeee 1 5 Configuration Requirements sssecssecsescesecreesecnesseceaeeeseeeeaees 1 5 The NI 488 2M Software for Windows 95 00 seecsesceseecceecsseeeeesecseesecneeeeceesneeeeeeaees 1 6 NI 488 2M Software for Windows 95 Component eccsseseescseeeeeeeees 1 6 NI 488 2M Driver and Driver Utilities 0 0 eee eseeeecneeeeeeene 1 6
54. GPIB Spy Help ner eeii ieee easa E a 5 2 Locating Errors with GPIB Spy eescsescsesecssececeecsseceeesecueesecsaseeceesaeeeeeaeceeeseenees 5 2 Viewing Properties for Recorded Calls cc ceeessescsseeceeceseeecsseceeesecneeseesecnesereeaeeees 5 2 Exiting GPIB Spy oyaa an E atin aa E E A sia 5 4 Performance Considerations snio nan a neei a a REE ER EEE Ee 5 4 Chapter 6 Win32 Interactive Control Utility ORAA E EE E E E S A 6 1 Getting Started with Win32 Interactive Control eseeseseeseeeeesesssesirreeressrrreererserseseees 6 1 Win32 Interactive Control Syntax cee eeeeesecseseecseeeeceeeeceecseeeecaeeeessecaeeseenesaeeeeenees 6 4 Number Syntax oaren e a panties aitenneotues EA n E a 6 4 Sting Syiitax eane hen ie Re o ee dae Selec ite 6 4 Address Sy Dtaxiis seein sorte enn e Bese Series eek setts eee EEES Rea 6 5 Win32 Interactive Control Commands ccceeceesseeceesceescesceeeceeeceeeeeeeeseeeeeeeeneenaes 6 5 Status WOTd seb svcscorsveesttevsnecberecestedeeiverdevuhtavskataneeseushcenteveenaesdieveuitanseediacdeaneceaneeedieveuteey 6 9 Error Information sererai i ae air e Uensteea cee udesadenceeea E eiet EEE 6 10 Count INFOrmation cesses err eeraa na e E e eee aE OENE siete sh OER ESPE Ep orak e ieii rors 6 10 Chapter 7 GPIB Programming Techniques Termination of Data Transfers sseeseseeseeeeseerstsrerteretsrerrerstesesesteretsrsrerreteensesesreerens 7 1 High Speed Data Transfers HS488 seesessees
55. IC Protocol enabled the following sequence occurs The GPIB interface board asserts the SRQ line The current CIC serial polls the board The interface board returns a response byte of hex 42 The current CIC passes control to the GPIB board FeO LS If the current CIC does not pass control the NI 488 2M driver returns the ECIC error code to your application This error can occur if the current CIC does not understand the CIC Protocol If this happens you could send a device specific command requesting control for the GPIB board Then use a board level ibwait command to wait for CIC Talker Listener Applications Although designed for Controller In Charge applications you can also use the NI 488 2M software in most non Controller situations These situations are known as Talker Listener applications because the interface board is not the GPIB Controller A Talker Listener application typically uses ibwait with a mask of 0 to monitor the status of the interface board Then based on the status bits set in ibsta the application takes whatever action is appropriate For example the application could monitor the status bits TACS Talker Active State and LACS Listener Active State to determine when to send data to or receive data from the Controller The application could also monitor the DCAS Device Clear Active State and DTAS Device Trigger Active State bits to determine if the Controller has sent the device clear DCL or SDC o
56. If you choose not to use process global variables you can access per thread copies of the GPIB global variables using a special set of GPIB calls Whenever a thread makes a GPIB call the driver keeps a private copy of the GPIB globals for that thread The driver keeps a separate private copy for each thread The following code shows the set of functions you can use to access these per thread GPIB global variables int ThreadIbsta return thread specific ibsta int ThreadIberr return thread specific iberr int ThreadIbcnt return thread specific ibcnt long ThreadIbcntl return thread specific ibcntl In your application instead of accessing the per process GPIB globals substitute a call to get the corresponding per thread GPIB global For example the line of code National Instruments Corporation 7 9 NI 488 2M User Manual for Windows 95 Windows NT Chapter 7 GPIB Programming Techniques if ibsta amp ERR could be replaced by if ThreadIbsta amp ERR A quick way to convert your application to use per thread GPIB globals is to add the following define lines at the top of your C file define ibsta ThreadIbsta define iberr ThreadIberr define ibcnt ThreadIbent define ibcntl ThreadIbcnt1 CF Note Ifyou are using ibnotify in your application see the Asynchronous Event Notification in Win32 GPIB Applications section of this chapter the ibnotify callback is executed ina separat
57. Multiboard System Setup cceceesecsseeceesecneeeeeeeeneeees 1 5 Figure 1 4 How the NI 488 2M Software Works with Windows 95 00 1 9 Figure 1 5 Selecting an Interface to Remove from Windows 95 esseeeeees 1 10 Figure 1 6 Add Remove Programs Properties Dialog Box in Windows 95 1 11 Figure 1 7 Uninstallation Results in Windows 95 eeeeceseeeceeceseeeeeseteeeenees 1 12 Figure 1 8 How the NI 488 2M Software Works with Windows NT 0 1 16 Figure 2 1 Program Flowchart for Example 1 0 0 0 eeeeeeeccsseeeeeceeeeeseceeeeenees 2 3 Figure 2 2 Program Flowchart for Example 2 0 0 csscsesccssseeceseceeeeeeseceeseenees 2 5 Figure 2 3 Program Flowchart for Example 3 0 00 ecscseescceseeeeeseceeeeeeseteeeseenees 2 7 Figure 2 4 Program Flowchart for Example 4 000 0 eceeeeeceseceseeeeeeseeeseenaes 2 9 Figure 2 5 Program Flowchart for Example 5 0 0 0 eceeeeseceseeeceseceeeeesecaeeseenees 2 12 Figure 2 6 Program Flowchart for Example 6 0 0 0 cscsesceseeeceseceeeeeseceeeeeenees 2 15 Figure 2 7 Program Flowchart for Example 7 c ccceccesscessceesceeeceeeeeeeeeeeeseenees 2 17 Figure 2 8 Program Flowchart for Example 8 ccssescesscssseeceseceeeeeesesseeseenees 2 20 Figure 2 9 Program Flowchart for Example 9 ou ceeceescsseeeceseceeeeeseteeeseenees 2 22 Figure 3 1 General Program Shell Using NI 488 Device Functions 3 8 Figure 3 2 General Program Shell Using NI 48
58. Status Codes section in Appendix C Windows 95 Troubleshooting and Common Questions to resolve your problem before you continue The Resources tab provides information about the hardware resources assigned to the GPIB interface and the NI 488 2M Settings tab provides information about the software configuration for the GPIB interface Use the Interface Name drop down box to select a logical name GPIBO GPIB1 and so on for the GPIB interface Repeat this process for each interface you need to configure Figure 8 1 shows the NI 488 2M Settings tab for an AT GPIB TNT PnP National Instruments Corporation Chapter8 GPIB Configuration Utility AT GPIB TNT Plug and Play Properties mi E E e Figure 8 1 NI 488 2M Settings Tab for the AT GPIB TNT PnP If you want to examine or modify the logical device templates for the GPIB software select the National Instruments GPIB Interfaces icon from the Device Manager tab and click on the Properties button Select the Device Templates tab to view the logical device templates as shown in Figure 8 2 National Instruments Corporation 8 3 NI 488 2M User Manual for Windows 95 Windows NT Chapter 8 GPIB Configuration Utility National Instruments GPIB Interfaces Properties 2 x General Device Templates y National Instruments GPIB Interfaces DEY1 Attributes Interface m Termination Methods Timeouts EE I Send EO atendot write E I Terminate Read
59. TO RECOVER DAMAGES CAUSED BY FAULT OR NEGLIGENCE ON THE PART OF NATIONAL INSTRUMENTS SHALL BE LIMITED TO THE AMOUNT THERETOFORE PAID BY THE CUSTOMER NATIONAL INSTRUMENTS WILL NOT BE LIABLE FOR DAMAGES RESULTING FROM LOSS OF DATA PROFITS USE OF PRODUCTS OR INCIDENTAL OR CONSEQUENTIAL DAMAGES EVEN IF ADVISED OF THE POSSIBILITY THEREOF This limitation of the liability of National Instruments will apply regardless of the form of action whether in contract or tort including negligence Any action against National Instruments must be brought within one year after the cause of action accrues National Instruments shall not be liable for any delay in performance due to causes beyond its reasonable control The warranty provided herein does not cover damages defects malfunctions or service failures caused by owner s failure to follow the National Instruments installation operation or maintenance instructions owner s modification of the product owner s abuse misuse or negligent acts and power failure or surges fire flood accident actions of third parties or other events outside reasonable control 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 NI 488 NI 488 2 NI 488 2M an
60. Windows NT xii National Instruments Corporation About This Manual This manual describes the features and functions of the NI 488 2M software for both Windows 95 and Windows NT The NI 488 2M software for Windows 95 is meant to be used with the Microsoft Windows 95 operating system The NI 488 2M software for Windows NT is meant to be used with the Microsoft Windows NT version 3 5 1 and later operating system This manual assumes that you are already familiar with the appropriate Microsoft operating system How to Use the Manual Set Getting Started Manual Installation and Configuration Experienced Users SZ Se SS NI 488 2M Function Reference Manual for Win32 NI 488 2M User Application Manual for Development Windows 95 and Examples and Windows NT Function and Routine Descriptions National Instruments Corporation xiij NI 488 2M User Manual for Windows 95 Windows NT About This Manual Use the getting started manual to install and configure your GPIB hardware and software for Windows 95 or Windows NT Use this NI 488 2M User Manual for Windows 95 and Windows NT to learn the basics of GPIB and how to develop an application program The user manual also contains debugging information and detailed examples Use the NI 488 2M Function Reference Manual for Win32 for specific NI 488 func
61. a device responding to a serial poll Megabytes Resident in RAM My Listen Address A GPIB command used to address a device to be a Listener It can be any one of the 31 primary addresses My Secondary Address The GPIB command used to address a device to be a Listener or a Talker when extended two byte addressing is used The complete address is a MLA or MTA address followed by an MSA address There are 31 secondary addresses for a total of 961 distinct listen or talk addresses for devices NI 488 2M User Manual for Windows 95 Windows NT Glossary MTA multitasking NDAC NRFD P parallel poll PIO PPC PPD PPE PPU programmed I O NI 488 2M User Manual for Windows 95 Windows NT G 6 My Talk Address A GPIB command used to address a device to be a Talker It can be any one of the 31 primary addresses The concurrent processing of more than one program or task Not Data Accepted One of the three GPIB handshake lines See handshake Not Ready For Data One of the three GPIB handshake lines See handshake The process of polling all configured devices at once and reading a composite poll response See serial poll See programmed I O Parallel Poll Configure It is the GPIB command used to configure an addressed Listener to participate in polls Parallel Poll Disable It is the GPIB command used to disable a configured device from participating in polls There are 16 PPD commands Parallel Po
62. an application she wrote using high level GPIB commands The following steps correspond to the program flowchart in Figure 2 3 1 The application initializes the GPIB by bringing the interface board in the computer online 2 An image is scanned in 3 The application sends the GPIB printer a command to print the new image and immediately returns without waiting for the I O operation to be completed 4 The application saves the image obtained to a file The application inquires as to whether the printing operation has completed by issuing a GPIB wait command If the status reported by the wait command indicates completion CMPL is in the status returned and more scans need to be acquired Steps 2 through 5 are repeated until the scans have all been acquired If the status reported by the wait command in Step 5 does not indicate that printing is finished statistical computations are performed on the scan obtained and Step 5 is repeated 6 Asacleanup step before exiting the application returns the interface board to its original state by taking it offline NI 488 2M User Manual for Windows 95 Windows NT 2 6 National Instruments Corporation Chapter 2 Application Examples GPIB Cable Computer Color Printer wn al Image Scan i ibwrta Print Image Asynchronously Print Image Non GPIB Activity Save to Disk ibwait Non GPIB Activity Is GPIB Printin E Compute Statistics y No 8 CLE
63. an instruction setting it up to take voltage measurements in autorange mode The application sends the multimeter an instruction to take a voltage measurement The application tells the multimeter to transmit the data it has acquired to the computer The process of requesting a measurement and reading from the multimeter Steps 3 and 4 is repeated as long as there are readings to be obtained As a cleanup step before exiting the application returns the interface board to its original state by taking it offline NI 488 2M User Manual for Windows 95 Windows NT 2 2 National Instruments Corporation National Instruments Corporation Chapter 2 Application Examples GPIB Cable Computer ibwrt Tell Multimeter to Take Measurements i ibrd Finished Getting Measurements y Yes Multimeter y ibwrt Set Up Multimeter to Take Voltages gt VOLTS DC AUTO From Multimeter 5 CLEAN UP Figure 2 1 Program Flowchart for Example 1 2 3 NI 488 2M User Manual for Windows 95 Windows NT Chapter 2 Application Examples 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 2M software on a personal computer and connected their GPIB board to a GPIB digital oscilloscope Their current lab assignment
64. ands Tables 6 1 and 6 2 summarize the syntax of NI 488 functions in Win32 Interactive Control Table 6 3 summarizes the syntax of NI 488 2 routines in Win32 Interactive Control Table 6 4 summarizes the auxiliary functions that you can use in Win32 Interactive Control For more information about the function parameters use the online help feature If you enter only the function name the Win32 Interactive Control utility prompts you for parameters National Instruments Corporation 6 5 NI 488 2M User Manual for Windows 95 Windows NT Chapter 6 Win32 Interactive Control Utility Table 6 1 Syntax for Device Level NI 488 Functions in Win32 Interactive Control Syntax Description ibask option Return configuration information where opt ion is a mnemonic for a configuration parameter Change access board of device where bname is symbolic name of new board ibconfig option Alter configurable parameters where opt ion is mnemonic for a value configuration parameter ibdev BdIndx pad Open an unused device ibdev parameters are BdIndx pad sad tmo sad tmo eot eos eot eos Read data where count is the bytes to read ibrda count Read data asynchronously where count is the bytes to read Change secondary address Abort asynchronous operation mask bit mnemonics such as ibwait TIMO CMPL Write data from a file where f1name is pathname of file to write NI 488 2M User Manual for Windows 95 Windows NT 6 6 National Instruments Corporation Chapter 6
65. arious 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 using a 3 wire handshake The bus supports one System Controller usually a computer and up to 14 additional instruments The ANSI IEEE Standard 488 2 1992 extends IEEE 488 1 by defining a bus communication protocol a common set of data codes and formats and a generic set of common device commands Talkers Listeners and Controllers GPIB devices can be Talkers Listeners or Controllers A Talker sends out data messages Listeners receive data messages The Controller usually a computer manages the flow of information on the bus It defines the communication links and sends GPIB commands to devices Some devices are capable of playing more than one role A digital voltmeter for example can be a Talker and a Listener If your personal computer has a National Instruments GPIB interface board and NI 488 2M software installed it can function as a Talker Listener and Controller National Instruments Corporation 1 1 NI 488 2M User Manual for Windows 95 Windows NT Chapter 1 Introduction Controller In Charge and System Controller You can have multiple Controllers on the GPIB but only one Controller at a time can be the active Controller or Controller In Charge CIC The CIC can either be active or inactive Standby Con
66. ates that the device is requesting service RQS is set whenever one or more positive serial poll response bytes have been received from the device A positive serial poll response byte always has bit 6 asserted Automatic serial polling must be enabled it is enabled by default for RQS to automatically appear in ibsta You can also wait for a device to request service regardless of the state of automatic serial polling by calling ibwait with a mask that contains RQS Do not issue an ibwait call on RQS for a device that does not respond to serial polls Use ibrsp to acquire the serial poll response byte that was received RQS is cleared when all of the stored serial poll response bytes have been reported to you through the ibrsp function CMPL dev brd LOK brd CMPL indicates the condition of I O operations It is set whenever an I O operation is complete CMPL is cleared while the I O operation is in progress LOK indicates whether the board is in a lockout state While LOK is set the EnableLocal routine or ibloc function is inoperative for that board LOK is set whenever the GPIB board detects that the Local Lockout LLO message has been sent either by the GPIB board or by another Controller LOK is cleared when the System Controller unasserts the Remote Enable REN GPIB line National Instruments Corporation A 3 NI 488 2M User Manual for Windows 95 Windows NT Appendix A Status Word Conditions REM brd CIC brd ATN
67. blems If the problem persists contact National Instruments e Code 27 Windows 95 was unable to assign the GPIB interface any resources To solve this problem free up system resources by disabling other unnecessary hardware so that enough resources are available for the GPIB interface Common Questions What do I do if my GPIB hardware is listed in the Windows 95 Device Manager with an exclamation point or an X next to it Refer to the Troubleshooting Windows 95 Device Manager Device Status Codes section of this appendix for specific information about what might cause this problem If you have already completed the troubleshooting steps fill out the forms in Appendix E Customer Communication and contact National Instruments How can I determine which type of GPIB hardware I have installed Run the GPIB Configuration utility To run the utility select Start Settings Control Panel System Select the Device Manager tab in the System Properties dialog box Click on the View devices by type National Instruments Corporation C 3 NI 488 2M User Manual for Windows 95 Windows NT Appendix C Windows 95 Troubleshooting and Common Questions radio button at the top of the page If any GPIB hardware is correctly installed a National Instruments GPIB Interfaces icon appears in the list of device types Double click on this icon to see a list of installed GPIB hardware How can I determine which version of the NI 488 2M software I have
68. brd TACS 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 REM is cleared in the following situations e When REN becomes unasserted e When the GPIB board as a Listener detects that the Go to Local GTL command has been sent either by the GPIB board or by another Controller e When the ibloc function is called while the LOK bit is cleared in the status word CIC indicates whether the GPIB board is the Controller In Charge CIC is set when the SendIFC routine or ibsic function is executed either while the GPIB board is System Controller or when another Controller passes control to the GPIB board CIC is cleared either when the GPIB board detects Interface Clear IFC from the System Controller or when the GPIB board passes control to another device ATN indicates the state of the GPIB Attention ATN line ATN is set whenever the GPIB ATN line is asserted and it is cleared when the ATN line is unasserted TACS indicates whether the GPIB board is addressed as a Talker TACS is set whenever the GPIB board detects that its talk address and secondary address if enabled has been sent either by the GPIB board itself or by another Controller TACS is cleared whenever the GPIB board detects the Untalk UNT command its own listen address a
69. bsta See status word ibsta ibtrg function triggering devices 3 10 using in Win32 Interactive Control example 6 3 ibwait function Talker Listener applications 7 11 terminating stuck SRQ state 7 13 to 7 14 waiting for GPIB conditions 7 4 waiting for measurement 3 10 NI 488 2M User Manual for Windows 95 Windows NT Index ibwrt function acquiring measurement 3 10 using in Win32 Interactive Control example 6 3 IFC interface clear line 1 3 interface management lines 1 3 interrupts and autopolling 7 14 L LACS status word condition bit position hex value and type table 3 5 description A 5 Talker Listener applications 7 12 listen address setting 1 2 Listeners 1 1 See also Talker Listener applications LOK status word condition bit position hex value and type table 3 5 description A 3 manual See documentation Message Available MAV bit 7 12 to 7 13 messages sending across GPIB 1 2 to 1 3 data lines 1 2 handshake lines 1 3 interface management lines 1 3 Microsoft C C language interface files NI 488 2M for Windows 95 1 7 NI 488 2M for Windows NT 1 14 Microsoft Visual Basic language interface files NI 488 2M for Windows 95 1 8 NI 488 2M for Windows NT 1 14 programming instructions 3 16 Microsoft Visual C C programming instructions 3 15 multithread Win32 GPIB applications writing 7 9 to 7 10 NI 488 2M User Manual for Windows 95 Windows NT l 8 n execute previous
70. cable length In addition to using ibconfig to configure your GPIB board for HS488 the Controller In Charge must send out GPIB command bytes interface messages to configure other devices for HS488 transfers NI 488 2M User Manual for Windows 95 Windows NT 7 2 National Instruments Corporation Chapter 7 GPIB Programming Techniques If you are using device level calls the NI 488 2M software automatically sends the HS488 configuration message to devices If you enabled the HS488 protocol in the GPIB Configuration Utility the NI 488 2M software sends out the HS488 configuration message when you use ibdev to bring a device online If you call ibconfig to change the GPIB cable length the NI 488 2M software sends out the HS488 message again the next time you call a device level function If you are using board level functions or NI 488 2 routines and you want to configure devices for high speed you must send the HS488 configuration messages using ibcmd or Sendcmds The HS488 configuration message is made up of two GPIB command bytes The first byte the Configure Enable CFE message hex 1F places all HS488 devices into their configuration mode Non HS488 devices should ignore this message The second byte is a GPIB secondary command that indicates the number of meters of 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
71. can create an appropriate GPIB address to use in subsequent NI 488 2 calls as follows a GPIB address is a 16 bit value that contains the primary address in the low byte and the secondary address in the high byte If you are not using secondary addressing the National Instruments Corporation 3 13 NI 488 2M User Manual for Windows 95 Windows NT Chapter 3 Developing Your Application secondary address is 0 For example if the primary address is 1 then the word 0x01 otherwise if the primary address is and the secondary address is 0x67 then the word 0x6701 Step 3 Initialize the Device After you find the device use the DevClear routine to clear it The first argument is the GPIB board number The second argument is the GPIB address as determined in Step 2 Step 4 Communicate with the Device After initialization your GPIB instrument is ready to receive instructions If you want to acquire readings from your device you do so in several ways Each GPIB device has its own specific instructions You should refer to the documentation that came with your GPIB device to learn how to properly communicate with it For this example assume that the GPIB device can be programmed to acquire readings whenever it is triggered Furthermore assume that the GPIB device requests service when it has acquired a reading Given that the following steps are necessary Step 4a Program the GPIB device to acquire a reading whenever it receive
72. cation Examples GPIB Cable Computer Oscilloscope ii ibclr Clear Oscilloscope H Clear Command ibwrt Define Task to Be Done When Oscilloscope WAV TRIG Is Triggered gt 4 ibtrg Trigger Oscilloscope to Get Reading Trigger Command t ibwrt Request Data CURV From Oscilloscope Y ibrd Read Data From Oscilloscope Y Display Waveform Finished Reading i Yes 8 CLEAN UP Figure 2 2 Program Flowchart for Example 2 2 5 NI 488 2M User Manual for Windows 95 Windows NT Chapter 2 Application Examples Example 3 Asynchronous 1 0 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 T 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 accurate CAT scans of a lab animal s liver She will print out a color copy of each scan as it is acquired The entire operation is computer controlled The CAT scan machine sends the images it acquires to a computer that has the NI 488 2M software installed and is connected to a GPIB color printer The biologist is familiar with the command set of her color printer as described in the user manual provided by the manufacturer She acquires and prints images with the aid of
73. ck on the Properties button to view the General properties page for the interface In the Device Status section look for the status description and status code number Use these status code descriptions NI 488 2M User Manual for Windows 95 Windows NT C 2 National Instruments Corporation Appendix C Windows 95 Troubleshooting and Common Questions and numbers to troubleshoot your problem The following paragraphs describe the status codes e Code 8 The GPIB software was incompletely installed You might encounter this problem if you have installed an AT GPIB TNT but not installed the GPIB Analyzer software To solve this problem reinstall the GPIB software for Windows 95 e Code 9 Windows 95 had a problem reading information from the GPIB interface This problem can occur if you are using an older revision of the AT GPIB TNT or AT GPIB TNT PnP interface Contact National Instruments to upgrade your GPIB interface e Code 22 The GPIB interface is disabled To enable the GPIB interface check the appropriate configuration checkbox in the Device Usage section of the General tab e Code 24 The GPIB interface is not present or the Device Manager is unaware that the GPIB interface is present To solve this problem select the interface in the Device Manager and click on the Remove button Next click on the Refresh button At this point the system rescans the installed hardware and the GPIB interface should show up without any pro
74. cntl Set to OxE028002C 534249428 If a call is made with a board number that is within the range of allowed board numbers typically 0 to 3 but which has not been assigned to a GPIB interface an EDVR error condition occurs with ibcnt1 set to 0OxE028002C You can assign a board number to a GPIB interface by configuring the NI 488 2M software and selecting an interface name Refer to the getting started manual for information on how to configure the NI 488 2M software EDVR Error with ibcntl Set to 0xE0140025 535560155 If a call is made with a board number that is not within the range of allowed board numbers typically 0 to 3 an EDVR error condition occurs with ibcnt1 set to OxE0140025 EDVR Error with ibcntl Set to 0xE0140035 535560139 If a call is made with a device name that is not listed in the logical device templates that are part of the NI 488 2M software configuration utility an EDVR error condition occurs with ibcnt1 set to OxE0140035 National Instruments Corporation C 1 NI 488 2M User Manual for Windows 95 Windows NT Appendix C Windows 95 Troubleshooting and Common Questions EDVR Error with ibent Set to 0xE0320029 533594071 or OxE1050029 519765975 If a call is made with a board number that is assigned to a GPIB interface that is unusable because of a resource conflict an EDVR error condition occurs with ibcnt1 set to 0OxE0320029 or OxE1050029 Refer to the troubleshooting instructions in the getting
75. d Serial Poll Enable The GPIB command used to enable a specific device to be polled That device must also be addressed to talk See SPD Service Request The GPIB line that a device asserts to notify the CIC that the device needs servicing The IEEE 488 2 defined data byte sent by a device when it is serially polled See ibsta Refers to the relationship between the NI 488 2M driver functions and a process when executing driver functions is predictable the process is blocked until the driver completes the function NI 488 2M User Manual for Windows 95 Windows NT Glossary System Controller T TAD Talker TCT timeout TLC The single designated Controller that can assert control become CIC of the GPIB by sending the Interface Clear IFC message Other devices can become CIC only by having control passed to them Talk Address See MTA 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 A feature of the NI 488 2M driver that prevents I O functions from hanging indefinitely when there is a problem on the GPIB An integrated circuit that implements most of the GPIB Talker Listener and Controller functions in hardware ud Unit descriptor A variable name and first argument of each function call that contains the unit descriptor of the GPIB interface board or other GPIB device that is the objec
76. d TNT4882C are trademarks of National Instruments Corporation Product and company names listed are trademarks or trade names of their respective companies WARNING REGARDING MEDICAL AND CLINICAL USE OF NATIONAL INSTRUMENTS PRODUCTS National Instruments products are not designed with components and testing intended to ensure a level of reliability suitable for use in treatment and diagnosis of humans Applications of National Instruments products involving medical or clinical treatment can create a potential for accidental injury caused by product failure or by errors on the part of the user or application designer Any use or application of National Instruments products for or involving medical or clinical treatment must be performed by properly trained and qualified medical personnel and all traditional medical safeguards equipment and procedures that are appropriate in the particular situation to prevent serious injury or death should always continue to be used when National Instruments products are being used National Instruments products are NOT intended to be a substitute for any form of established process procedure or equipment used to monitor or safeguard human health and safety in medical or clinical treatment Table of Contents About This Manual How to Use the Manual Set renr iA E E RN xiii Organization of This Manual eeseseeeeeeeeeeeseseeseesesrsesesrerssesrsrerrerssssesestenrsesesrrerseseese xiv
77. d in your computer that is properly configured both in hardware and software using a valid base I O address National Instruments Corporation B 5 NI 488 2M User Manual for Windows 95 Windows NT Appendix B Error Codes and Solutions EDMA 8 EDMA occurs if a system DMA error is encountered when the NI 488 2M software attempts to transfer data over the GPIB using DMA Solutions e You can correct the EDMA problem in the hardware by using the GPIB configuration utility to reconfigure the hardware to not use a DMA resource e You can correct the EDMA problem in the software by using ibdma to disable DMA EOIP 10 EOIP occurs when an asynchronous I O operation has not finished before some other call is made During asynchronous I O you can only use ibstop ibnotify ibwait and ibon1 or perform other non GPIB operations If any other call is attempted EOIP is returned Solutions Resynchronize the driver and the application before making any further GPIB calls Resynchronization is accomplished by using one of the following four functions ibnotify Ifthe ibsta value passed to the ibnotify callback contains CMPL the driver and application are resynchronized 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 resynchron
78. d type table 3 5 description A 4 clearing and triggering devices example 2 4 to 2 5 CMPL status word condition bit position hex value and type table 3 5 description A 3 common questions See troubleshooting and common questions communication application examples basic communication 2 2 to 2 3 with IEEE 488 2 compliant devices 2 14 to 2 15 communication errors 4 4 repeat addressing 4 4 termination method 4 4 configuration 1 4 to 1 6 See also GPIB configuration utility Win32 Interactive Control utility controlling more than one board 1 5 linear and star system configuration illustration 1 4 requirements 1 5 to 1 6 system configuration effects on HS488 7 3 configuration errors 4 3 Configure CFGn message 7 3 Configure Enable CFE message 7 3 Controller in Charge CIC active Controller as CIC 1 1 making GPIB board CIC 7 11 System Controller as 1 2 Controllers definition 1 1 emulation of non controller GPIB example 2 20 to 2 21 National Instruments Corporation l 3 Index idle Controller 1 2 monitoring by Talker Listener applications 7 11 to 7 12 System Controller 1 2 count in Win32 Interactive Control 6 10 count variables ibcnt and ibcntl 3 6 customer communication xvi E 1 to E 2 D data lines 1 2 data transfers high speed HS488 7 2 to 7 3 enabling 7 2 to 7 3 system configuration effects 7 3 terminating 7 1 to 7 2 DAV data valid line table 1 3 DCAS statu
79. dows 95 Troubleshooting and Common Questions When should I use the Win32 Interactive Control utility You can use the Win32 Interactive Control utility to test and verify instrument communication troubleshoot problems and develop your application For more information refer to Chapter 6 Win32 Interactive Control Utility How do I use an NI 488 2M language interface For information about using NI 488 2M language interfaces refer to Chapter 3 Developing Your Application What do I do if the Diagnostic utility fails with an error Use the Diagnostic online help or refer to the getting started manual to troubleshoot specific problems If you have already completed the troubleshooting steps fill out the support forms in Appendix E Customer Communication and contact National Instruments How do I communicate with my instrument over the GPIB Refer to the documentation that came from the instrument manufacturer The command sequences you use are totally dependent on the specific instrument The documentation for each instrument should include the GPIB commands you need to communicate with it In most cases NI 488 device level calls are sufficient for communicating with instruments Refer to Chapter 3 Developing Your Application for more information Can I use the NI 488 and NI 488 2 calls together in the same application Yes you can mix NI 488 functions and NI 488 2 routines What can I do to check for errors in my GPIB
80. e thread that is created by the GPIB driver Therefore if your application makes GPIB calls from the ibnotify callback function and makes GPIB calls from other places you must use the ThreadIbsta ThreadIberr ThreadIbent and ThreadIbent1l functions described in this section instead of the per process GPIB globals Device Level Calls and Bus Management The NI 488 device level calls are designed to perform all of the GPIB management for your application However the NI 488 2M driver can handle bus management only when the GPIB interface board is CIC Controller In Charge Only the CIC is able to send command bytes to the devices on the bus to perform device addressing or other bus management activities NI 488 2M User Manual for Windows 95 Windows NT 7 10 National Instruments Corporation Chapter 7 GPIB Programming Techniques Use one of the following methods to make your GPIB board the CIC e If your GPIB board is configured as the System Controller default it automatically makes itself the CIC by asserting the IFC line the first time you make a device level call e 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 GPIB Configuration Utility to activate the CIC protocol If the interface board is not CIC and you make a device level call with the C
81. eeccsseecesseceeeecneeeeesecneseecsaeeeeeaeeaees C 1 EDVR Error with ibcntl Set to OXEO28002C 00 ee eeceseeseeseceeceeeeceeeeeneeeees C 1 EDVR Error with ibcntl Set to OXEO140025 uo ee eeeeeseeeceeceeeeeceeeeeeenees C 1 EDVR Error with ibcntl Set to OXE0140035 oo eee eeeeeeeeeeeeeeeeeeeeeees C 1 EDVR Error with ibentl Set to 0xE0320029 or OXE1050029 uu eee C 2 EDVR Error with ibcntl Set to OXEO140004 0 eee eeeseeeceseeeesecneeeeeeenees C 2 EDVR Error with ibcntl Set to OXE1030043 oo ecesecseeeceseeeeeeeceeeeeneenees C 2 Troubleshooting Windows 95 Device Manager Status Codes 000 0 cceeeesecseeeeeeeeees C 2 Common QuEStIONS seriea r eien ie ea E Ee E dead edd oad EEEE EEKE EEE ES ir ironia ae C 3 Appendix D Windows NT Troubleshooting and Common Questions Using Windows NT Diagnostic Tools eeeescsssscsseeeeeseceeeeessecaeesecneeecsaeneseeeeaees D 1 Examining NT Devices to Verify the NI 488 2M Installation D 1 Examining the NT System Log Using the Event Viewer sesso D 2 Common QuestiONs noenee ea EEE ease e EE eee EEEE E e SEENE EEE aE a i e i Teniak D 2 NI 488 2M User Manual for Windows 95 Windows NT X National Instruments Corporation Table of Contents Appendix E Customer Communication Glossary Index Figures Figure 1 1 GPIB Address Bits aicina hance Siti cee a ee Sete ates 1 2 Figure 1 2 Linear and Star System Configuration eeesesecseeeecsecneeeeeeeeeees 1 4 Figure 1 3 Example of
82. eiotiia atin declan cit bial elie uid ala E R R A 4 EACS Br AA apse E EEE ere odes te tron hea ope eee A 4 LACS brid sani ieee iin cia nee ees A 5 DTAS rdja aner a r r E ets lee RE N R A 5 DCAS brd meisie nee a a eh BGR Ree E E iR A 5 National Instruments Corporation ix NI 488 2M User Manual for Windows 95 Windows NT Table of Contents Appendix B Error Codes and Solutions BDV R O ovaries Boasts Ea E ones date EEE E hoes B 2 CIC IJ ae iae fesse to ea Gas eth eae des eco ashe oe E PEE ea Bese B 2 EN OU 2 ENE EE sds cevbusneds huss sbasayseltessusastycohidsSaas teseucatssssboeate st stasvuestouses B 3 BADR 3 ain oid eae ale SR Ai Re B 4 EARG Aiei oun a demniat damnit Mie ae oy aban A A AA B 4 ESAG 6 ciancnevina Ween ee Hae Ai ahd Rta eae B 5 JENN LO AC E EATA cists tel diet re aaa ees idiu ech atansast oeeaabtsstdsties eases B 5 ENEB Q h p EEEE E E E A eee petioles B 5 EDMA 8 or t a E A I EEEE E E e T EA A B 6 EOIP lO zentas ieh o ei Eii bails bene iss EN A EEEE ia B 6 ECAR LD DEEE ERA EA EAE B 7 OE A E E shud oh deean co ubbogdud buh disaemsenanetnanou dees B 7 EBUS 14 ironion a ou dimataniainitit Gedney annie a sani admits B 7 ESTB 15 s nist niire Gia Manes RASA Ana AM Rao a Mes deena B 8 BSRO CLO custisssiees ste bases ih cbetyshes tas hestes E B 8 ETAB 20 upton ie ats ticle ei A ee ed R aa B 9 Appendix C Windows 95 Troubleshooting and Common Questions Troubleshooting EDVR Error Conditions 0 eeec
83. en NI 488 functions and NI 488 2 routines 3 2 to 3 4 global variables for checking status 3 4 to 3 6 count variables ibcnt and ibentl 3 6 error variable iberr 3 5 to 3 6 status word ibsta 3 4 to 3 5 language specific instructions 3 15 to 3 19 Borland C C 3 15 direct entry with C 3 16 to 3 19 directly accessing gpib 32 dll exports 3 17 to 3 19 gpib 32 dll exports 3 16 to 3 17 Microsoft Visual Basic 3 16 Microsoft Visual C C 3 15 NI 488 2M User Manual for Windows 95 Windows NT NI 488 applications clearing devices 3 9 communicating with devices 3 9 to 3 10 flowchart of programming with device level functions 3 8 general steps and examples 3 9 to 3 10 items to include 3 7 opening devices 3 9 placing device offline 3 10 program shell illustration 3 8 reading measurement 3 10 triggering devices 3 10 waiting for measurement 3 10 NI 488 functions 3 2 to 3 3 advantages 3 2 board level functions 3 3 choosing between NI 488 functions and NI 488 2 routines 3 2 to 3 4 device level functions 3 3 one device per board 3 2 to 3 3 NI 488 2 applications communicating with devices 3 14 to 3 15 determining GPIB address of device 3 13 to 14 flowchart of programming with routines 3 12 general steps and examples 3 13 to 3 15 initialization 3 13 initializing devices 3 14 items to include 3 11 placing device offline 3 15 program shell illustration 3 12 reading measurements 3 14 to
84. end of each function call this global variable status word contains status information Institute of Electrical and Electronic Engineers A broadcast message sent from the Controller to all devices and used to manage the GPIB Input Output In the context of this manual the transmission of commands or messages between the computer via the GPIB board and other devices on the GPIB The address of the GPIB board from the point of view of the CPU as opposed to the GPIB address of the GPIB board Also called port address or board address National Instruments Corporation KB L LAD language interface Listener LLO low level function MAV MB memory resident MLA MSA National Instruments Corporation G 5 Glossary An Individual Status bit of the status byte used in the Parallel Poll Configure function Kilobytes Listen address See MLA Code that enables an application program that uses NI 488 functions or NI 488 2 routines to access the driver A GPIB device that receives data messages from a Talker Local Lockout The GPIB command used to tell all devices that they may or should ignore remote GPIB data messages or local front panel controls depending on whether the device is in local or remote program mode A rudimentary board or device function that performs a single operation Meters The Message Available bit is part of the IEEE 488 2 defined status byte which is received from
85. ents Corporation l 9 See troubleshooting and common questions unloading NI 488 2M driver 1 16 to 1 17 niglobal bas file 1 14 NRFD not ready for data line table 1 3 number syntax in Win32 Interactive Control 6 4 0 online help for GPIB Spy 5 2 P parallel polling 7 17 to 7 18 application example 2 18 to 2 19 implementing 7 17 to 7 18 using NI 488 functions 7 17 to 7 18 NI 488 2M User Manual for Windows 95 Windows NT Index using NI 488 2 routines 7 18 to 7 19 PPoll routine 7 19 PPollConfig routine 7 19 PPollUnconfig routine 7 19 primary GPIB address 1 2 problem solving See debugging troubleshooting and common questions programming See application development debugging GPIB programming techniques Q q function Win32 Interactive Control 6 9 R readme txt file Borland C C language interface files 1 8 1 14 Microsoft C C language interface files 1 7 1 14 Microsoft Visual Basic language interface files 1 8 1 14 NI 488 2M driver and driver utilities 1 6 1 13 ReadStatusByte routine 3 14 7 15 Receive routine 3 15 reloading NI 488 2M driver for Windows NT 1 16 to 1 17 REM status word condition bit position hex value and type table 3 5 description A 4 REN remote enable line table 1 3 repeat addressing 4 4 repeat previous function function Win32 Interactive Control 6 9 requesting service See service requests routines See NI 488 2 routines RQS status
86. equired but DMA is not How can I determine if my GPIB hardware and software are correctly installed Run the Diagnostic utility In Windows NT version 3 51 start the Diagnostic by double clicking on the Diagnostic icon in the NI 488 2M Software for Windows NT group of the Program Manager In Windows NT version 4 0 or later start the Diagnostic by choosing the Diagnostic item under Start Programs NI 488 2M Software for Windows NT A banner at the bottom of the Diagnostic utility window displays the version of the GPIB software that is installed When should I use the Win32 Interactive Control utility You can use the Win32 Interactive Control utility to test and verify instrument communication troubleshoot problems and develop your application For more information refer to Chapter 6 Win32 Interactive Control Utility National Instruments Corporation D 3 NI 488 2M User Manual for Windows 95 Windows NT Appendix D Windows NT Troubleshooting and Common Questions How do I use an NI 488 2M language interface For information about using NI 488 2M language interfaces refer to Chapter 3 Developing Your Application What do I do if the Diagnostic utility fails with an error Use the Diagnostic online help or refer to the getting started manual to troubleshoot specific problems If you have already completed the troubleshooting steps fill out the support forms in Appendix E Customer Communication and contact National Inst
87. er Listener applications 7 12 waiting for messages from Controller 7 12 dynamic link library GPIB See NI 488 2M DLL E EABO error code definition table 4 2 description B 5 EADR error code definition table 4 2 description B 4 NI 488 2M User Manual for Windows 95 Windows NT l 4 EARG error code definition table 4 2 description B 4 EBUS error code definition table 4 2 description B 7 to B 8 ECAP error code definition table 4 2 description B 7 ECIC error code definition table 4 2 description B 2 to B 3 EDMA error code definition table 4 2 description B 6 EDVR error code definition table 4 2 description B 2 troubleshooting C 1 to C 2 EFSO error code definition table 4 2 description B 7 electronic support services E 1 to E 2 e mail support E 2 END status word condition bit position hex value and type table 3 5 description A 2 end of string character See EOS ENEB error code definition table 4 2 description B 5 to B 6 ENOL error code definition table 4 2 description B 3 EOI end or identify line purpose table 1 3 termination of data transfers 7 1 EOIP error code definition table 4 2 description B 6 National Instruments Corporation EOS configuring EOS mode 7 1 end of string mode application example 2 8 to 2 9 EOS comparison method 7 1 EOS read method 7 2 EOS write method 7 1 to 7 2 ERR status word condition bit position hex value a
88. ervice These steps are repeated three times once for each color pass ibrsp Read Response From the Film Recorder Advance Film 4 ibwait Wait For the Film Recorder to Request Service Y Reached End of Film y Yes 10 CLEAN UP Figure 2 5 Program Flowchart for Example 5 Continued National Instruments Corporation 2 13 NI 488 2M User Manual for Windows 95 Windows NT Chapter 2 Application Examples Example 6 Basic Communication with IEEE 488 2 Compliant Devices This example provides 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 find out 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 These machines are fairly voluminous and it is difficult for the engineer to reach the address switches of each machine For the purposes of his future work with these tensile testers he needs to determine what GPIB addresses they have been set to He can do so with the aid of a simple application he has written The following steps correspond to the program flowchart in Figure 2 6 1 The application initializes the GPIB by bringing the interface board in the computer online 2 The application issues a command to detect the presence of listening devices on t
89. es Standard program files Program folders v Y y Folder items v VY Program directories Y Program registry entries Se aee eee eee ee Uninstall successfully completed Figure 1 7 Uninstallation Results in Windows 95 If you have interfaces other than PCMCIA cards and you have not physically removed them from your computer you should shut down Windows 95 power off your computer and remove the interfaces now You may remove PCMCIA cards without powering off your computer If you want to reinstall the hardware and software refer to the getting started manual The NI 488 2M Software for Windows NT NI 488 2M Software for Windows NT Components The following section highlights important elements of the NI 488 2M software for Windows NT and describes the function of each element National Instruments Corporation 1 13 NI 488 2M User Manual for Windows 95 Windows NT Chapter 1 Introduction NI 488 2M Driver and Driver Utilities The distribution disk contains the following driver and utility files e A documentation file readme txt that contains important information about the NI 488 2M software and a description of any new features Before you use the software read this file for the most recent information e Native Windows NT kernel driver components e A Win32 dynamic link library goib 32 d11 that acts as the interface between all applications and the kernel mode GPIB d
90. es ATN true when it sends commands and false when it sends data messages System Controller drives the IFC line to initialize oi clear the bus and make itself CIC System Controller drives the REN line to place a enable devices in remote or local program mode SRQ Any device can drive the SRQ line to service request asynchronously request service from the Controller EOI Talker uses the EOI line to mark the end of a data end or identify message Controller uses the EOI line when it conducts a parallel poll 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 NI 488 2M User Manual for Windows 95 Windows NT 1 4 National Instruments Corporation Chapter 1 Introduction Device A Device A Device D Device B E C pe E Device B Device C Device C a Linear Configuration b Star Configuration Figure 1 2 Linear and Star System Configuration Controlling More Than One Board Figure 1 3 shows an example of a multiboard system configuration gpib0 is the access b
91. escription of the sample application files refer to Chapter 2 Application Examples How the NI 488 2M Software Works with Windows 95 The NI 488 2M software for Windows 95 includes a multi layered device driver that consists of DLL pieces that run in user mode and VxD pieces that run in kernel mode User applications access this device driver from user mode through gpib 32 d11 a 32 bit Windows 95 dynamic link library GPIB applications access the NI 488 2M software through gpib 32 d11 as follows e A Win32 application can either link with the language interface or directly access the functions exported by the DLL e A Win16 application uses the 16 bit thunking DLL gpib d11 and 32 bit thunking DLL gpib32ft d11 to access the GPIB driver e A DOS application uses the DOS support VxD and application to access the GPIB driver Figure 1 4 shows the interaction between various types of GPIB applications shaded sections and the NI 488 2M software components National Instruments Corporation 1 9 NI 488 2M User Manual for Windows 95 Windows NT Chapter 1 Introduction Win16 Application gpib dll Win32 Application pib32ft dll a Application DOS Application ngr dll User Mode Kernal Mode DOS Support VxD Figure 1 4 How the NI 488 2M Software Works with Windows 95 Uninstalling the GPIB Hardware from Windows 95 Before physically removing the GPIB hardware from the computer you must remove the hardware info
92. esseesesreeterserreresrerssesrsrerrersrsrerrereseeseseee 7 2 Enabling HS48 Sori iiaea a cite Wi E EEEE ea ae 7 2 System Configuration Effects on HS488 eeeseseeeesesesesrrrerrsrsrrrrerereersesreee 7 3 Waiting for GPIB Conditions 0 0 ee eeesecsecneesecneeeeceseeeceaeceeeecsaecaeesecneseeenaenesnenaeeees 7 4 Asynchronous Event Notification in Win32 GPIB Applications cc eeeeeeeeenees 7 4 Calling the ibnotify FUN ction ee ceeeecseeeeceseeeeeeceseceeesecseeseesaeeerseesaeeees 7 4 ibnotify Programming Example ecesesecsecseeseceeceeeeeseceeeseeaeceeeeeeaeeeeeees 7 6 NI 488 2M User Manual for Windows 95 Windows NT viii National Instruments Corporation Table of Contents Writing Multithreaded Win32 GPIB Applications eee eesecsseereesecneeeecneeseeseenees 7 9 Device Level Calls and Bus Management eceeeesseseceeceseeeceseeeeeseceeeeeenecaeeseeners 7 11 Talker Listener Application Sienen e aeea oe en E ETEEN N EEEREN oi 7 11 Serial Poline se arire E a Mets E EE EEKE EAE E 7 12 Service Requests from IEEE 488 Devices eseseeeeesesesrersrerrereerrrrrererrererre 7 12 Service Requests from IEEE 488 2 Devices sseeseesersreerereerersrrreerereere 7 12 Automatic Serial Polling nyser onnieke eo a 7 13 Stuck SRO Sf E ssc E a r ade a A E E 7 13 Autopolling and Interrupts cccceeeesceesceesceeeceeceseceeeeseeeaeenneeaes 7 14 SRQ and Serial Polling with NI 488 Device Functions eeceseeeeeeee 7 14
93. f 3 s asserts EOI with the last byte of a write operation and has EOS characters disabled The following call configures the device to respond to the poll on DIO7 and to assert the line in the case when its ist is 0 Pass the binary bit pattern 0110 0110 or hex 66 to ibppc include decl 32 h char ppr dev ibdev 0 3 0 T3s 1 0 ibppc dev 0x66 If the GPIB interface board configures itself for a parallel poll you should still use the ibppc function Pass the board index or a board unit descriptor value as the first argument in ibppc In addition if the individual status bit ist of the board needs to be changed use the ibist function In the following example the GPIB board is to configure itself to participate in a parallel poll It asserts DIOS when ist 1 if a parallel poll is conducted ibppc 0 Ox6C ibist 0 1 Conduct the parallel poll using ibrpp and check the response for a certain value The following example code performs the parallel poll and compares the response to hex 10 which corresponds to DIOS If that bit is set the ist of the device is 1 ibrpp dev amp ppr if ppr amp 0x10 printf ist 1 n Unconfigure the device for parallel polling with ibppc Notice that any value having the parallel poll disable bit set bit 4 in the bit pattern disables the configuration so you can use any value between hex 70 and 7E ibppc dev 0x70 Parallel Polling with NI 488 2 Routines Foll
94. f not refer to the next section Examining the NT System Log Using the Event Viewer At least one of the GPIB Port Drivers listed by the Devices applet should have a status of Started If not refer to the next section Examining the NT System Log Using the Event Viewer If the GPIB Class Driver lines are not present or at least one GPIB Port Driver line is not present the NI 488 2M software is not installed properly You must reinstall the NI 488 2M software Examining the NT System Log Using the Event Viewer Windows NT maintains a system log If the NI 488 2M driver is unable to start it records entries in the system log explaining why it failed to start You can examine the system log by running the Event Viewer utility In Windows NT 3 51 double click on the Event Viewer icon in the Administrative Tools group of the Program Manager In Windows NT 4 0 or higher select Start Programs Administrative Tools Event Viewer Events that might appear in the system log include the following e The system is unable to locate the device file for one or more of the devices that make up the NI 488 2M driver and an event is logged that The system cannot find the file specified In this case the NI 488 2M software is incorrectly installed You should reinstall the software e A conflict exists between the GPIB hardware and the other hardware in the system If this is the case an event is logged that indicates the nature of the resource confl
95. for your application Clearing the device resets its internal functions to a default state National Instruments Corporation 3 9 NI 488 2M User Manual for Windows 95 Windows NT Chapter 3 Developing Your Application Step 3 Communicate with the Device After you open and clear the device your GPIB instrument is ready to receive instructions If you want to acquire readings from your device you can do so in several ways Each GPIB device has its own specific instructions You should refer to the documentation that came with your GPIB device to learn how to properly communicate with it For this example assume that the GPIB device can be programmed to acquire readings whenever it is triggered Furthermore assume that the GPIB device requests service when it has acquired a reading Given these assumptions the following steps are necessary Step 3a Program the GPIB device to acquire a reading whenever it receives a GPIB trigger using the ibwrt function The buffer that you pass to ibwrt is the command message that programs the device to behave properly Step 3b Trigger the device using the ibtrg function Step 3c Wait for the device to acquire the reading using the ibwait function with a mask value of RQS TIMO because the event of interest is the device s ReQuest for Service RQS If the ibwait function times out before the RQS event occurs the timeout bit TIMO is set in the ibsta value for the call Step 3d
96. formance of both your application and the system For this reason use GPIB Spy only while you are debugging your application or in situations where performance is not critical National Instruments Corporation 5 3 NI 488 2M User Manual for Windows 95 Windows NT Chapter Win32 Interactive Control Utility This chapter introduces you to Win32 Interactive Control the interactive control utility that you can use to communicate with GPIB devices interactively Overview With the Win32 Interactive Control utility 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 You can use Win32 Interactive Control to practice communication with the instrument troubleshoot problems and develop your application One way Win32 Interactive Control helps you to learn about your instrument and to troubleshoot problems is by displaying the following information on your screen whenever you enter a command e The results of the status word ibsta in hexadecimal notation e The mnemonic constant of each bit set in ibsta e The mnemonic value of the error variable iberr if an error exists the ERR bit is set in ibsta e The count value for each read write or command function e The data received from your instrument Getting Started with Win32 Interactive Control This section shows
97. functions update a global status word ibsta which contains information about the state of the GPIB and the GPIB hardware The value stored in ibsta is the return value of all of the NI 488 functions except ibfind and ibdev You can examine various status bits in ibsta and use that information to make decisions about continued processing If you check for possible errors after each call using the ibsta ERR bit debugging your application is much easier ibsta is a 16 bit value A bit value of one 1 indicates that a certain condition is in effect A bit value of zero 0 indicates that the condition is not in effect Each bit in ibsta can be set for NI 488 device calls dev NI 488 board calls brd and NI 488 2 calls or all dev brd Table 3 1 shows the condition that each bit position represents the bit mnemonics and the type of calls for which the bit can be set For a detailed explanation of each of the status conditions refer to Appendix A Status Word Conditions NI 488 2M User Manual for Windows 95 Windows NT 3 4 National Instruments Corporation Chapter 3 Developing Your Application Table 3 1 Status Word Layout Bit Hex Mnemonic Pos Value Type Description emer fe 100 aeva vO compiea tos f so wa Lockout ae fem fe 40 ora Remote sae joc sa fo font Attention is asserted rracs 38 Yost tacs fa a ora frise peas fo 1 ora Device Crear sue The language header file included on your distribution d
98. g 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 The application waits for any of three events to occur the device to become listen addressed become talk addressed or receive a GPIB clear message 3 As soon as one of the events occurs the application takes an action based upon the event that occurred If the device was cleared the application resets the internal state of the device to default values If the device was talk addressed it writes data back to the Controller If the device was listen addressed it reads in new data from the Controller NI 488 2M User Manual for Windows 95 Windows NT 2 20 National Instruments Corporation Chapter 2 Application Examples Device Controller 1 INIT ibwait Wait To Be Talk Addressed Listen Addressed Or Cleared 3 Reset Internal Yes Is This the State lt Clear Event Is This the Talk Addressed Event Yes ibwrt Write Out New Data ibrd Read In New Data Figure 2 9 Program Flowchart for Example 9 National Instruments Corporation 2 21 NI 488 2M User Manual for Windows 95 Windows NT Chapter Developing Your Application This chapter explains how to develop a GPIB application using NI 488 functions and NI 488 2 routines Choosing Your Programming Methodology Based on y
99. he GPIB and compiles a list of the addresses of all such devices 3 The application sends an identification query IDN all of the devices detected on the GPIB in Step 2 4 The application reads the identification information returned by each of the devices as it responds to the query in Step 3 5 Asacleanup step before exiting the application returns the interface board to its original state by taking it offline NI 488 2M User Manual for Windows 95 Windows NT 2 14 National Instruments Corporation GPIB Cable Chapter 2 Application Examples GPIB Cable GPIB Cable Computer mo J FindLstn Get a List of Devices Present on GPIB DA DA D Tensile Tester 1 Tensile Tester 2 Tensile Tester 3 Device 3 Is Here Y Send Tell Device 1 to Identify Itself 4 Receive Read Response From Device 1 Y Send Tell Device 2 to Identify Itself y Receive Read Response lt 4 From Device 2 Y Send Tell Device 3 to Identify Itself y Receive IDN MUTT 10528 Read Response From Device 3 lt CLEAN UP National Instruments Corporation Figure 2 6 Program Flowchart for Example 6 2 15 NI 488 2M User Manual for Windows 95 Windows NT Chapter 2 Application Examples 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
100. he software to inform you whether or not the GPIB EOI line was asserted when the EOS byte was read in 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 2M driver reports END in ibsta when either the EOS byte is read in or the EOI line is asserted during a read High Speed Data Transfers HS488 Enabling 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 HS488 is a superset of the IEEE 488 standard thus you can mix TEEE 488 1 IEEE 488 2 and HS488 devices in the same system If HS488 is enabled the TNT4882C hardware implements high speed transfers automatically when communicating with HS488 instruments If you attempt to enable HS488 on a GPIB board that does not have the TNT4882C hardware the error ECAP is returned To enable HS488 for your GPIB board use the ibconfig function option IbcHSCableLength The value passed to ibconfig should specify the number of meters of cable in your GPIB configuration If you specify a cable length that is much smaller than what you actually use the transferred data could become corrupted If you specify a cable length longer than what you actually use the data is transferred successfully but more slowly than if you specified the correct
101. ht GPIB data lines the transducer uses to respond when a parallel poll is conducted The application also sets the temperature threshold The transducer manufacturer has defined the individual status ist bit to be true when the temperature threshold is reached and the configured status mode of the transducer is assert the data line When a parallel poll is conducted the transducer asserts its data line if the temperature has exceeded the threshold 3 The application configures the temperature transducer in the second monitoring unit for parallel polls 4 The application configures the temperature transducer in the third monitoring unit for parallel polls 5 The application conducts non GPIB activity while the metals are heated 6 The application conducts a parallel poll of all three temperature transducers to determine whether the metals have reached the NI 488 2M User Manual for Windows 95 Windows NT 2 18 National Instruments Corporation Chapter 2 Application Examples appropriate temperature Each transducer asserts its data line during the configuration step if its temperature threshold has been reached 7 If the response to the poll indicates that all three metals are at the appropriate temperature the application sends a command to each of the three power supplies directing them to power on Then the motors start and the metals pour into the mold If only one or two of the metals is at the appropriate temperature S
102. 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 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 ENOL can occur in situations where the GPIB board is not the CIC and the Controller asserts ATN before the write call in progress has ended Solutions National Instruments Corporation Make sure that the GPIB address of your device matches the GPIB address of the device to which you want to write data Use the appropriate hex code in ibcmd to address your device Check your cable connections and make sure at least two thirds of your devices are powered on Call ibpad or ibsad if necessary to match the configured address to the device switch settings Reduce the write byte count to that which is expected by the Controller B 3 NI 488 2M User Manual for Windows 95 Windows NT Appendix B Error Codes and Solutions EADR 3 EARG 4 EADR occurs when the GPIB b
103. ict To correct this conflict reconfigure the GPIB hardware and NI 488 2M software Refer to the getting started manual for configuration information Common Questions How can I determine which type of GPIB hardware I have installed Run the GPIB Configuration utility To run the utility open your Windows NT Control Panel and select the National Instruments eagle icon NI 488 2M User Manual for Windows 95 Windows NT D 2 National Instruments Corporation Appendix D Windows NT Troubleshooting and Common Questions How can I determine which version of the NI 488 2M software I have installed Run the Diagnostic utility In Windows NT version 3 51 start the Diagnostic by double clicking on the Diagnostic icon in the NI 488 2M Software for Windows NT group of the Program Manager In Windows NT version 4 0 or later start the Diagnostic by choosing the Diagnostic item under Start Programs NI 488 2M Software for Windows NT How many GPIB interfaces can I configure for use with my NI 488 2M Software for Windows NT The NI 488 2M Software for Windows NT can be configured to communicate with up to 4 GPIB interfaces How many devices can I configure for use with my NI 488 2M Software for Windows NT The NI 488 2M Software for Windows NT provides a total of 100 logical devices for applications to use The default number of devices is 32 Are interrupts and DMA required with the NI 488 2M Software for Windows NT Interrupts are r
104. indows NT 6 10 National Instruments Corporation Chapter 6 Win32 Interactive Control Utility If one of the addresses in an address list of an NI 488 2 routine is invalid then the error is EARG and Win32 Interactive Control displays the index of the invalid address as the count The count has a different meaning depending on which NI 488 function or NI 488 2 routine is called Refer to the function descriptions in the online help or NI 488 2M Function Reference Manual for Win32 for the correct interpretation of the count return National Instruments Corporation 6 11 NI 488 2M User Manual for Windows 95 Windows NT Chapter GPIB Programming Techniques This chapter describes techniques for using some NI 488 functions and NI 488 2 routines in your application For more detailed information about each function or routine refer to the online help or NI 488 2M Function Reference Manual for Win32 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 By default the NI 488 2M driver asserts EOI with the last byte of writes and the EOS modes are disabled You can use the ibeot function to enable or disable the end of transmission EOT mode If EOT mode is enabled the NI 488 2M driver asserts the GPIB EOI line when the last byte of a write is sent out on the GPIB If
105. ing considerations choosing between functions and routines 3 2 to 3 4 using with multiple boards or devices 3 3 to 3 4 serial polling 7 15 to 7 16 serial polling examples AllSpoll 7 16 FindRQS 7 16 Win32 Interactive Control syntax 6 8 NI 488 2M DLL choosing access method 3 1 Index troubleshooting See troubleshooting and common questions uninstalling GPIB hardware 1 9 to 1 10 uninstalling GPIB software 1 11 to 1 12 Windows NT Borland C C language interface files 1 14 DOS and 16 bit Windows support files 1 13 to 1 14 how NI 488 2M software works with Windows NT 1 15 to 1 16 Microsoft C C language interface files 1 14 Microsoft Visual Basic language interface files 1 14 NI 488 2M driver and driver utilities 1 13 reloading NI 488 2M driver 1 16 to direct entry access 3 1 1 17 NI 488 2M software 1 6 to 1 12 See also sample application files 1 14 application development NI 488 troubleshooting functions NI 488 2 routines Windows 95 16 bit Windows support files 1 7 Borland C C language interface files 1 8 C language interface files 1 7 to 1 8 DOS support files 1 7 driver and driver utility files 1 6 to 1 7 how NI 488 2M software works with Windows 95 1 8 to 1 9 Microsoft C C language interface files 1 7 Microsoft Visual Basic language interface files 1 8 NI 488 2M driver and driver utilities 1 6 to 1 7 sample application files 1 8 National Instrum
106. ing your software Termination Method Other Errors You should be aware of the data termination method that your device uses By default your NI 488 2M software is configured to send EOI on writes and terminate reads on EOI or a specific byte count If you send a command string to your device and it does not respond it might be because it does not recognize the end of the command You might need to send a termination message such as lt CR gt lt LF gt after a write command as follows ibwrt dev COMMAND x0A x0D 9 If you experience other errors in your application refer to Appendix C Windows 95 Troubleshooting and Common Questions or Appendix D Windows NT Troubleshooting and Common Questions depending on which operating system you are using NI 488 2M User Manual for Windows 95 Windows NT 4 4 National Instruments Corporation GPIB Spy Utility Overview Chapter This chapter introduces you to GPIB Spy the application monitor you can use to monitor NI 488 and NI 488 2 calls GPIB Spy monitors records and displays the NI 488 and NI 488 2 calls made to the NI 488 2M driver GPIB Spy monitors Win32 Win16 and DOS GPIB applications It is a useful tool for troubleshooting errors in your application and for verifying that the communication with your GPIB instrument is correct Starting GPIB Spy When you launch GPIB Spy it displays the main GPIB Spy window By default Spy capture is on and GPI
107. inue to use the traditional GPIB global variables without some form of synchronization for example a semaphore To understand why this is true take a look at the following example Assume that a process has two separate threads that make GPIB calls thread 1 and thread 2 Just as thread 1 is about to examine one of the GPIB globals it gets preempted and thread 2 is allowed to run Thread 2 proceeds to make several GPIB calls that automatically update the GPIB globals Later when thread 1 is allowed to run the GPIB global that it is ready to examine is no longer in a known state and its value is no longer reliable This example illustrates a well known multithreading problem It is unsafe to access process global variables from multiple threads of execution You can avoid this problem in two ways e Use synchronization to protect access to process global variables e Do not use process global variables If you choose to implement the synchronization solution you must ensure that code that makes GPIB calls and examines the GPIB globals modified by a GPIB call is protected by a synchronization primitive For example each thread might acquire a semaphore before making a GPIB call and then release the semaphore after examining the GPIB globals modified by the call For more information on the use of synchronization primitives refer to the documentation on using Win32 synchronization objects that came with your development tools
108. ional Instruments Corporation Chapter 1 Introduction Microsoft C C Language Interface Files e A documentation file readme txt that contains information about the C language interface e A 32 bit include file decl 32 h that contains NI 488 function and NI 488 2 routine prototypes and various predefined constants e A 32 bit C language interface file gpib 32 obj that an application links with in order to access the 32 bit DLL Borland C C Language Interface Files e A documentation file readme txt that contains information about the C language interface e A 32 bit include file decl 32 h that contains NI 488 function and NI 488 2 routine prototypes and various predefined constants e A 32 bit C language interface file borlandc_gpib 32 obj that an application links with in order to access the 32 bit DLL Microsoft Visual Basic Language Interface Files e A documentation file readme txt that contains information about the Visual Basic language interface e A Visual Basic global module niglobal bas that contains certain predefined constant declarations e A Visual Basic source file vbib 32 bas that contains NI 488 2 routine and NI 488 function prototypes Sample Application Files The NI 488 2M software includes nine sample applications along with source code for each language supported by the NI 488 2M software For a detailed description of the sample application files refer to Chapter 2 Applicati
109. is to write a small application to practice using the oscilloscope and its command set using high level GPIB commands The following steps correspond to the program flowchart in Figure 2 2 1 The application initializes the GPIB by bringing the interface board in the computer online The application sends a GPIB clear command to the oscilloscope This command clears the internal registers of the oscilloscope reinitializing it to default values and settings The application sends a command to the oscilloscope telling it to read a waveform each time it is triggered Predefining the task in this way decreases the execution time required Each trigger of the oscilloscope is now sufficient to get a new run The application sends a GPIB trigger command to the oscilloscope which causes it to acquire data The application queries the oscilloscope for the acquired data The oscilloscope sends the data The application reads the data from the oscilloscope The application calls an external graphics routine to display the acquired waveform Steps 4 5 6 and 7 are repeated until all of the desired data has been acquired by the oscilloscope and received by the computer 8 As a cleanup step before exiting the application returns the interface board to its original state by taking it offline NI 488 2M User Manual for Windows 95 Windows NT 2 4 National Instruments Corporation National Instruments Corporation Chapter 2 Appli
110. isk defines each of the ibsta status bits You can test for an ibsta status bit being set using the bitwise and operator amp in C C For example the ibsta ERR bit is bit 15 of ibsta To check for a GPIB error use the following statement after each GPIB call as shown if ibsta amp ERR printf GPIB error encountered Error Variable iberr If the ERR bit is set in ibsta a GPIB error has occurred When an error occurs the error type is specified by iberr To check for a GPIB error use the following statement after each GPIB call if ibsta amp ERR printf GPIB error d encountered iberr CF Note The value in iberr is meaningful as an error type only when the ERR bit is set in ibsta indicating that an error has occurred National Instruments Corporation 3 5 NI 488 2M User Manual for Windows 95 Windows NT Chapter 3 Developing Your Application For more information on error codes and solutions refer to Chapter 4 Debugging Your Application or Appendix B Error Codes and Solutions Count Variables ibent and ibentl The count variables are updated after each read write or command function In Win32 applications ibcnt and ibcnt1 are 32 bit integers On some systems like MS DOS ibcnt is a 16 bit integer and ibcnt1 is a 32 bit integer For cross platform compatibility all applications should use ibcnt1 If you are reading data the count variables indicate the number of bytes read If you
111. it calls that address the standard 32 bit dynamic link library gpib 32 d11 Microsoft C C Language Interface Files A documentation file readme txt that contains information about the C language interface A 32 bit include file decl 32 h that contains NI 488 function and NI 488 2 routine prototypes and various predefined constants A 32 bit C language interface file gpib 32 obj that an application links with in order to access the 32 bit DLL Borland C C Language Interface Files A documentation file readme txt that contains information about the C language interface A 32 bit include file dec1 32 h that contains NI 488 function and NI 488 2 routine prototypes and various predefined constants A 32 bit C language interface file borlandc_gpib 32 ob4 that an application links with in order to access the 32 bit DLL National Instruments Corporation Chapter 1 Introduction Microsoft Visual Basic Language Interface Files e A documentation file readme txt that contains information about the Visual Basic language interface e A Visual Basic global module niglobal bas that contains certain predefined constant declarations e A Visual Basic source file vbib 32 bas that contains NI 488 2 routine and NI 488 function prototypes Sample Application Files The NI 488 2M software includes nine sample applications along with source code for each language supported by the NI 488 2M software For a detailed d
112. ized NI 488 2M User Manual for Windows 95 Windows NT B 6 National Instruments Corporation Appendix B Error Codes and Solutions ECAP 11 ECAP results when your GPIB board lacks the ability to carry out an operation or when a particular capability has been disabled in the software and a call is made that requires the capability Solutions Check the validity of the call or make sure your GPIB interface board and the driver both have the needed capability EFSO 12 EFSO results when an ibrdf or ibwrtf call encounters a problem performing a file operation Specifically this error indicates that the function is unable to open create seek write or close the file being accessed The specific operating system error code for this condition is contained in ibcnt1 Solutions e Make sure the filename path and drive that you specified are correct e Make sure that the access mode of the file is correct e Make sure there is enough room on the disk to hold the file 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 National Instruments Corporation B 7 NI 488 2M User Manual for Windows 95 Windows NT
113. l for Windows 95 Windows NT l 6 system configuration effects 7 3 parallel polling 7 17 to 7 18 implementing 7 17 to 7 18 using NI 488 functions 7 17 to 7 18 using NI 488 2 routines 7 18 to 7 19 serial polling 7 12 to 7 16 automatic serial polling 7 13 to 7 14 autopolling and interrupts 7 14 stuck SRQ state 7 13 to 7 14 service requests from IEEE 488 devices 7 12 from IEEE 488 2 devices 7 12 to 7 13 SRQ and serial polling with NI 488 device functions 7 14 with NI 488 2 routines 7 15 to 7 16 Talker Listener applications 7 11 to 7 12 termination of data transfers 7 1 to 7 2 waiting for GPIB conditions 7 4 writing multithread Win32 GPIB applications 7 9 to 7 10 GPIB Spy utility debugging applications 4 1 exiting 5 4 locating errors 5 2 main window illustration 5 2 online help 5 2 overview 5 1 performance considerations 5 4 starting 5 1 to 5 2 under Windows 95 5 1 under Windows NT 5 1 viewing properties for recorded calls 5 2 to 5 3 gpib dll file See also NI 488 2M DLL Windows 95 1 7 National Instruments Corporation Windows NT 1 14 gpib 32 dll exports accessing directly 3 17 to 3 19 direct entry with C 3 16 to 3 17 gpib 32 dll file 1 6 1 13 gpib32ft dll file 1 7 gpib 32 obj file 1 7 1 14 gpibdos exe file 1 7 gpibdosk vxd file 1 7 gpib nt com file 1 14 gpib vdd dll file 1 13 H handshake lines 1 3 Help display Win32 Interactive utility online help function
114. le In this example the NOADDR constant must appear at the end of the array to signal the end of the address list If NOADDR is the only value in the array all devices receive the parallel poll disable message AddressList 0 3 AddressList 1 NOADDR PPollUnconfig 0 AddressList National Instruments Corporation 7 19 NI 488 2M User Manual for Windows 95 Windows NT GPIB Configuration Utility Overview Chapter This chapter contains a description of the GPIB Configuration utility you can use to configure your NI 488 2M software The Windows 95 GPIB Configuration utility is integrated into the Windows 95 Device Manager The Windows NT GPIB Configuration utility is integrated into the Windows NT Control Panel You can use the GPIB Configuration utility to view or modify the configuration of your GPIB interface boards You can also use it to view or modify the GPIB device templates which provide compatibility with older applications The online help includes all of the information that you need to properly configure the NI 488 2M software In most cases you should use the GPIB Configuration utility only to change the hardware configuration of your GPIB interface boards To change the GPIB characteristics of your boards and the configuration of the device templates use the ibconfig function in your application If your application uses ibconfig whenever it needs to modify a configuration option it is able to run o
115. le Support for DOS GPIB Applications and then click on the OK button 6 Restart your computer Now you can run your existing DOS GPIB applications Windows NT Running Existing GPIB Applications You can run existing DOS and Windows GPIB applications under Windows NT by using the GPIB Virtual Device Driver gpib vdd d1ll which is included with your NI 488 2M software To run DOS GPIB applications load the special GPIB device driver gpib nt com instead of gpib com which you normally use with DOS When you install the NI 488 2M software gpib nt com is copied into a new subdirectory called doswinl6 To use gpib nt com you must modify your config nt file to load gpib nt com whenever a DOS application is executed The config nt file is located in your lt winnt gt system32 directory where lt winnt gt is your Windows NT directory for example c windows To load gpib nt com add the following line to your config nt file device lt path gt doswinl6 gpib nt com where lt path gt is the directory where you installed the GPIB software the default installation directory is c gpib nt NI 488 2M User Manual for Windows 95 Windows NT 3 20 National Instruments Corporation Chapter 3 Developing Your Application To run Win16 GPIB applications the system uses the special GPIB dynamic link library gpib d11 When you install the NI 488 2M software gpib d1l1 is copied into the lt winnt gt system32 directory where lt winnt
116. lications Win32 Application gpib vdd dll Protected Win32 Subsystem Subsystem User Mode Kernel Mode System Services N I O Manager NT Executive gpibclsd sys Kernel gpibclsb sys gpibxxxx sys Hardware Abstraction Layer HAL GPIB Hardware j Figure 1 8 How the NI 488 2M Software Works with Windows NT National Instruments Corporation 1 17 NI 488 2M User Manual for Windows 95 Windows NT Chapter 1 Introduction Unloading and Reloading the NI 488 2M Driver for Windows NT You can unload and restart the NI 488 2M driver using the GPIB Configuration utility To run this utility in Windows NT 3 51 double click on the GPIB icon in the Control Panel which is located in the Main group of the Program Manager To run this utility in Windows NT 4 0 or later select Start Settings Control Panel and double click on the GPIB icon The main window has an Unload button and a Restart button If you click on the Unload button the NI 488 2M driver is unloaded If you click on the Restart button the NI 488 2M driver is automatically unloaded and then reloaded Refer to Chapter 8 GPIB Configuration Utility for a more complete description NI 488 2M User Manual for Windows 95 Windows NT 1 18 National Instruments Corporation Chapter Application Examples This chapter contains nine sample applications designed to illustrate specific GPIB concepts and techniques that can help you
117. ll Enable It is the GPIB command used to enable a configured device to participate in polls and to assign a DIO response line There are 16 PPE commands Parallel Poll Unconfigure It is the GPIB command used to disable any device from participating in polls Low speed data transfer between the GPIB board and memory in which the CPU moves each data byte according to program instructions See DMA Random access memory National Instruments Corporation resynchronize RQS SDC semaphore serial poll service request source handshake SPD SPE SRQ status byte status word synchronous National Instruments Corporation G 7 Glossary The NI 488 2M software and the user application must resynchronize after asynchronous I O operations have completed Request Service Seconds Selected Device Clear The GPIB command used to reset internal or device functions of an addressed Listener See DCL An object that maintains a count between zero and some maximum value limiting the number of threads that are simultaneously accessing a shared resource The process of polling and reading the status byte of one device at a time See parallel poll See SRQ 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 Serial Poll Disable The GPIB command used to cancel an SPE comman
118. loaded from your config sys file a file located on the boot drive of your computer The older GPIB DOS device driver is loaded with a command line of the form device lt path gt gpib com where lt path gt is the drive and directory where gpib com is located Delete this line to ensure that the older GPIB DOS driver is not being loaded To run DOS GPIB applications the system uses a Virtual Device Driver VxD gpibdosk vxd and a Win32 executable gpibdos exe When you install the NI 488 2M software gpibdosk vxd and gpibdos exe are copied into the Windows System directory These files are loaded when you restart your computer if the NI 488 2M software has been properly configured to run your existing DOS GPIB applications National Instruments Corporation 3 19 NI 488 2M User Manual for Windows 95 Windows NT Chapter 3 Developing Your Application To configure the NI 488 2M software to run your existing DOS GPIB applications follow these steps after you have installed the NI 488 2M software and your GPIB hardware 1 Select Start Settings Control Panel and double click on the System icon The System Properties dialog box appears 2 Select the Device Manager tab 3 Click on the View devices by type button at the top of the page and click on the National Instruments GPIB Interfaces icon 4 Click on the Properties button to display the General property page for the NI 488 2M software 5 Select the checkbox labeled Enab
119. loading and Reloading the NI 488 2M Driver for Windows NT 1 16 Chapter 2 Application Examples Example 1 Basic COMMUNICATION ee eee eeeeteeseeeceseceeeseceeeseeneeseceecnersecsaeeeeeaeeaeeees 2 2 Example 2 Clearing and Triggering Devices se eeeecseesceseeeceseeeeeseceeeeeeseeneeseenees 2 4 Example 3 Asynchronous W O ecceeceeeeceeeceeeeeseceseeseeeseceseceaeceaecsaecaecsaessaeeneeeas 2 6 Example 4 End of String Mode ce ecesesesscesecsseseceeseceseseeeceaeeeesaecaeeseeneeaeeseenees 2 8 Example 5 Service Requests sccscescsersesesesonesstvesescnsnseesncsotcesevevssessesesesensevevenes 2 10 Example 6 Basic Communication with IEEE 488 2 Compliant Devices 2 14 Example 7 Serial Polls Using NI 488 2 Routines ceesssecsseereesecneeeecneeeeeeeenees 2 16 Example 8 Parallel Polls sics ssc2 5 iss sesscstptien css sassecsivs ieasestatiasap thasesgeoes EE EE SES 2 18 Example 9 Non Controller Example 00 0 0 ee ceecesecsecseesseceeeceeeseeeeeeeeeeeeseneeeeeeeeees 2 20 Chapter 3 Developing Your Application Choosing Your Programming Methodology ceccssesscssecssseceecseesecnereecesesereeeaeeees 3 1 Choosing a Method to Access the NI 488 2M Driver 3 1 NI 488 2M Language Interfaces 000 eeecseeeceseeeeeseceeeeeesecneeeeens 3 1 Direct Entry ACESS nieren ea Ea 3 1 Choosing between NI 488 Functions and NI 488 2 Routines eee 3 2 Using NI 488 Functions One Device for Each Board
120. n the status word ibsta For information about how to use ibsta in your application program refer to Chapter 3 Developing Your Application Each bit in ibsta can be set for device calls dev board calls brd or both dev brd The following table shows the status word layout Bit Hex Mnemonic Pos Value Type Description Temp e 100 Tav bra VO completed Cio 7 so w Lockout State Trem 6 40 wa Remote Suite Can fa f o poe fenon sees a Talker tors fester Ford Device Trigger Ste Fora Device Clear Sate National Instruments Corporation A 1 NI 488 2M User Manual for Windows 95 Windows NT Appendix A 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 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 TIMO is set in the status word following an ibwait or ibnotify call if the TIMO bit of the mask parameter is set and the time limit expires TIMO is also set following any synchronous I O functions for example ibcmd ibrd ibwrt Receive Send and SendCmds if a timeout occurs during one of these calls TIMO is cleared in all other circumstances
121. n any computer with the appropriate NI 488 2M software regardless of the configuration of that computer Windows 95 Configuring the NI 488 2M Software You do not need to configure the NI 488 2M software unless you are using more than one GPIB interface in your system If you are using more than one interface you should configure the NI 488 2M software to associate a logical name gpib0 gpib1 and so on with each physical GPIB interface National Instruments Corporation 8 1 NI 488 2M User Manual for Windows 95 Windows NT Chapter 8 NI 488 2M User Manual for Windows 95 Windows NT 8 2 GPIB Configuration Utility Note GPIB Analyzer software settings are available through the GPIB Analyzer application To configure the NI 488 2M software follow these steps 1 Double click on the System icon in the Control Panel which can be opened from the Settings selection of the Start menu Select the Device Manager tab in the System Properties dialog box that appears Click on the View devices by type button at the top of the Device Manager tab and double click on the National Instruments GPIB Interfaces icon Double click on the particular interface type you want to configure in the list of installed interfaces immediately below National Instruments GPIB Interfaces If an exclamation point or an X appears next to the interface there is a problem and you should refer to the Troubleshooting Windows 95 Device Manager Device
122. n named cprog ina DOS shell type the following on the command line cl cprog c gpib 32 o0bj Borland C C Version 4 0 or Higher Before you compile your Win32 C application make sure that the following lines are included at the beginning of your program include lt windows h gt include decl 32 h To compile and link a Win32 console application named cprog ina DOS shell type the following on the command line bec32 w32 cprog c borlandc_gpib 32 obj National Instruments Corporation 3 15 NI 488 2M User Manual for Windows 95 Windows NT Chapter 3 Developing Your Application Visual Basic Version 4 0 or Higher With Visual Basic you can access the NI 488 functions as subroutines using the BASIC keyword CALL followed by the NI 488 function name or you can access the NI 488 functions using the i1 set of functions With some of the NI 488 functions and NI 488 2 subroutines for example ibrd or Receive the length of the string buffer is automatically calculated within the actual function or subroutine which eliminates the need to pass in the length as an extra parameter Refer to the online help or NJ 488 2M Function Reference Manual for Win32 for more information about function syntax for Visual Basic Before you run your Visual Basic application include the files niglobal bas and vbib 32 bas in your application project file Direct Entry with C The following sections describe how to use direct entry with C gpib
123. nd type table 3 5 description A 2 error codes and solutions EABO B 5 EADR B 4 EARG B 4 EBUS B 7 to B 8 ECAP B 7 ECIC B 2 to B 3 EDMA B 6 EDVR B 2 EFSO B 7 ENEB B 5 to B 6 ENOL B 3 EOIP B 6 ESAC B 5 ESRQ B 8 to B 9 ESTB B 8 ETAB B 9 GPIB error codes table 4 2 B 1 error conditions communication errors 4 4 repeat addressing 4 4 termination method 4 4 configuration errors 4 3 timing errors 4 3 Win32 Interactive Control error information 6 10 error variable iberr 3 5 to 3 6 ESAC error code definition table 4 2 description B 5 National Instruments Corporation l 5 Index ESRQ error code definition table 4 2 description B 8 to B 9 ESTB error code definition table 4 2 description B 8 ETAB error code definition table 4 2 description B 9 event notification See asynchronous event notification in Win32 applications Event Status bit ESB 7 12 to 7 13 execute function n times n function Win32 Interactive Control 6 9 execute indirect file function Win32 Interactive Control 6 9 execute previous function n times n function Win32 Interactive Control 6 9 existing applications running Windows 95 DOS GPIB applications 3 19 to 3 20 Win16 GPIB applications 3 19 Windows NT 3 20 to 3 21 F fax and telephone technical support E 1 FaxBack support E 2 FindLstn routine 3 13 FindRQS routine 7 15 7 16 FTP support E 1 f
124. nless the end of film is reached The application waits for RQS which completes when the film recorder asserts the SRQ line to signal it is done advancing the film As soon as the application s wait for RQS completes the application serial polls the film recorder to see if it requested service as in Step 5 The returned serial poll status byte indicates either of two conditions the film recorder finished advancing the film as requested or the end of film was reached and it can no longer advance Steps 6 through 9 are repeated as long as film is in the camera and more images need to be recorded As a cleanup step before exiting the application returns the interface board to its original state by taking it offline 2 11 NI 488 2M User Manual for Windows 95 Windows NT Chapter 2 Application Examples GPIB Cable Computer Digital Film Recorder ibclr Clear Film Recorder Clear Command y ibwrt Advance Film FRM y ibwait Wait For the Film Recorder to Request Service i ibrsp Read Response From the Film Recorder Finished Loading Film Exit Application and Repair Film Recorder continues Figure 2 5 Program Flowchart for Example 5 NI 488 2M User Manual for Windows 95 Windows NT 2 12 National Instruments Corporation Chapter 2 Application Examples Computer Digital Film Recorder e Create a Single Pass Image i ibwait Wait For the Film 6 6b Recorder to Request S
125. ns are sufficient You should use the NI 488 2 routines if you have a complex configuration with one or more interface boards and multiple devices Regardless of which option you choose the driver automatically addresses devices and performs other bus management operations necessary for device communication The following sections discuss some differences between NI 488 functions and NI 488 2 routines 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 e 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 e NI 488 functions include built in file transfer functions ibrdf and ibwrtf e With NI 488 functions you can control the bus in non typical ways or communicate with non compliant devices The NI 488 functions consist of high level or device functions that hide much of the GPIB management operations and low level or board functions that offer you more control over the GPIB than NI 488 2 routines The following sections describe these different function types NI 488 2M User Manual for Windows 95 Windows NT 3 2 National Instruments Corporation Chapter 3 Developing Your Application NI 488 Device Le
126. nvalid response Status byte 0x x n spr DeviceError TRUE return 0 Read the data from the device If the ERR bit is set in ibsta then print an error message and return LocallIbsta ibrd LocalUd ReadBuffer 40L if LocallIbsta amp ERR printf ibrd failed No more callbacks n DeviceError TRUE return 0 Convert the data into a numeric value sscanf ReadBuffer Sf amp Readings ReadingsTaken ReadingsTaken 1 if ReadingsTaken gt 1000 return 0 else Issue a request to the device to send the data and rearm callback on RQS LocallIbsta ibwrt LocalUd SEND DATA 9L if LocallIbsta amp ERR printf ibwrt failed No more callbacks n DeviceError TRUE return 0 else return RQS Writing Multithreaded Win32 GPIB Applications If you are writing a multithreaded GPIB application and you plan to make all of your GPIB calls from a single thread you can safely continue to use the traditional GPIB global variables ibsta iberr ibcnt ibcnt1 The GPIB global variables are defined on a per process basis so each process accesses its own copy of the GPIB globals NI 488 2M User Manual for Windows 95 Windows NT 7 8 National Instruments Corporation Chapter 7 GPIB Programming Techniques If you are writing a multithreaded GPIB application and you plan to make GPIB calls from more than a single thread you cannot safely cont
127. ny functions it needs to use National Instruments Corporation 3 17 NI 488 2M User Manual for Windows 95 Windows NT Chapter 3 Developing Your Application Pointers to NI 488 2 global status variables int Pibsta int Piberr long Pibcntl static int __stdcall Pibdev int ud int pad int sad int tmo int eot int eos static int __stdcall Pibonl int ud int v Pibsta int GetProcAddress Gpib32Lib LPCSTR user_ibsta Piberr int GetProcAddress Gpib32Lib LPCSTR user_iberr Pibcntl long GetProcAddress Gpib32Lib LPCSTR user_ibcnt Pibdev int __stdcall int int int int int int GetProcAddress Gpib32Lib LPCSTR ibdev Pibonl int __stdcall int int GetProcAddress Gpib32Lib LPCSTR ibonl If GetProcAddress fails it returns a NULL pointer The following code fragment illustrates how to verify that none of the calls to GetProcAddress failed if Pibsta NULL Piberr NULL Pibcntl NULL Pibdev NULL Pibonl NULL Free the GPIB library FreeLibrary Gpib32Lib printf GetProcAddress failed Your Win32 application needs to dereference the pointer to access either the status variables or function The following code illustrates how to call a function and access the status variable from within your application dvm Pibdev 0 1 0 T10s 1
128. oard 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 National Instruments Corporation 1 5 NI 488 2M User Manual for Windows 95 Windows NT Chapter 1 Introduction Another GPIB salin OO00IS Printer Figure 1 3 Example of Multiboard System Setup Configuration Requirements To achieve the high data transfer rate that the GPIB was designed for you must limit the physical distance between devices and the number of devices on the bus The following restrictions are typical e A maximum separation of four meters between any two devices and an average separation of two meters over the entire bus e A maximun total cable length of 20 m e A maximum of 15 devices connected to each bus with at least two thirds powered on For high speed operation the following restrictions apply e All devices in the system must be powered on e Cable lengths as short as possible up to a maximum of 15 m of cable for each system e With 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 NI 488 2M User Manual for Windows 95 Windows NT 1 6
129. oard is CIC and is not properly addressing itself before read and write functions This error is usually associated with board level functions EADR is also returned by the function ibgts when the shadow handshake feature is requested and the GPIB ATN line is already unasserted In this case the shadow handshake is not possible and the error is returned to notify you of that fact Solutions e Make sure that the GPIB board is addressed correctly before calling ibrd ibwrt RcvRespMsg or SendDataBytes e Avoid calling ibgts except immediately after an ibcmd call ibcmd causes ATN to be asserted EARG results when an invalid argument is passed to a function call The following are some examples e ibtmo called with a value not in the range 0 through 17 e ibeos called with meaningless bits set in the high byte of the second parameter e ibpador ibsad called with invalid addresses e ibppc called with invalid parallel poll configurations e A board level NI 488 call made with a valid device descriptor or a device level NI 488 call made with a board descriptor e AnNI 488 2 routine called with an invalid address e PPolliConfig called with an invalid data line or sense bit Solutions e Make sure that the parameters passed to the NI 488 function or NI 488 2 routine are valid e Do not use a device descriptor in a board function or vice versa NI 488 2M User Manual for Windows 95 Windows NT B 4 National Instruments Corpo
130. ommand is sent 4 With the exception of the scan resolution all the default settings are appropriate for the task at hand The application changes the scan resolution by writing the appropriate command to the scanner 5 The scanner sends back information describing the status of the change resolution command This is a string of bytes terminated by the end of string character to tell the application it is done changing the resolution 6 The application starts the scan by writing the scan command to the scanner 7 The application reads the scan data into the computer As a cleanup step before exiting the application returns the interface board to its original state by taking it offline NI 488 2M User Manual for Windows 95 Windows NT 2 8 National Instruments Corporation Chapter 2 Application Examples GPIB Cable Computer Scanner y ibclr Reset Internal State Clear Command y ibeos Set EOS Mode y ibwrt Change Scan RES 3 r n Resolution y ibrd y ibwrt Start Scan scan r n ibrd Read Data Scanned Data y CLEAN UP Figure 2 4 Program Flowchart for Example 4 National Instruments Corporation 2 9 NI 488 2M User Manual for Windows 95 Windows NT Chapter 2 Application Examples 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
131. on NI 488 General Program Steps and Examples The following steps demonstrate how to use the NI 488 device functions in your application The NI 488 2M software includes the source code for an example written in C devsamp c and the source code for the example written to use direct entry to access the gpib 32 d11 dlldev c The NI 488 2M software also includes a sample program written in Visual Basic devsamp frm Step 1 Open a Device Your first NI 488 function call should be a call to ibdev to open a device The ibdev function requires the following parameters e Connect board index typically set to 0 because your board is GPIBO e Primary address for the GPIB instrument refer to the GPIB instrument manual e Secondary address for the GPIB instrument 0 if the GPIB instrument does not use secondary addressing e Timeout period typically set to T10s which is 10 seconds e End of transfer mode typically 1 so that EOI is asserted with the last byte of writes e EOS detection mode 0 if the GPIB instrument does not use EOS characters When you call ibdev the driver automatically initializes the GPIB by sending an Interface Clear IFC message and placing the device in remote programming state A successful ibdev call returns a unit descriptor handle ua that is used for all NI 488 calls that communicate with the GPIB instrument Step 2 Clear the Device Use ibclr to clear the device before you configure the device
132. on EOS 10sec GPIB Address Serial Poll Primary T Set EO with EOS on Write lsec bi I 8 bit EOS Compare Secondary NONE F fo EOS Byte I Readdress Figure 8 2 Device Templates Tab for the Logical Device Templates Windows NT Configuring the NI 488 2M Software When you install the NI 488 2M software for Windows NT the installation program places the GPIB Configuration utility into your Control Panel To start the GPIB Configuration utility simply open your Windows NT Control Panel and select the eagle icon Because you can use the GPIB Configuration utility to modify the configuration of the NI 488 2M kernel drivers you must be logged on to Windows NT as the Administrator to make any changes with the GPIB Configuration utility If you start the GPIB Configuration utility without Administrator privileges it runs in read only mode you can view the settings but you cannot make changes NI 488 2M User Manual for Windows 95 Windows NT 8 4 National Instruments Corporation Chapter 8 GPIB Configuration Utility The main GPIB Configuration dialog box appears containing a list of the GPIB boards and device templates as shown in Figure 8 3 GPIB Configuration GPIB Board Device Template Board Tyyia Figure 8 3 Main Dialog Box in the GPIB Configuration Utility If at any point you need more help click on the Help button or press the lt F1 gt key Either of these actions b
133. on Examples National Instruments Corporation 1 15 NI 488 2M User Manual for Windows 95 Windows NT Chapter 1 Introduction How the NI 488 2M Software Works with Windows NT The main components of the NI 488 2M software are a dynamic link library that runs in user mode and a layered NT device driver that runs in kernel mode The layered NT device driver consists of three drivers a device class driver that handles device level calls a board class driver that handles board level calls and a GPIB port driver that uses the Hardware Abstraction Layer HAL to communicate with the GPIB hardware The top two layers of the layered NT device driver are accessed from user mode by gpib 32 d11 a 32 bit Windows NT dynamic link library GPIB applications access the NI 488 2M software through gpib 32 d11 as follows e A Win32 application can either link with the language interface or directly access the functions exported by the DLL e A Win16 application uses the 16 bit DLL gpib d11 to access the GPIB virtual device driver gpib vdd dl1 e ADOS application uses the DOS device driver gpib nt com to access the GPIB virtual device driver Figure 1 8 shows the interaction between various types of GPIB applications and the NI 488 2M software components NI 488 2M User Manual for Windows 95 Windows NT 1 16 National Instruments Corporation Chapter 1 Introduction Win16 Application DOS Application y gpib nt com App
134. ontrol If your application does not automatically check for and display errors you can locate an error by using the Win32 Interactive Control utility Simply issue the same functions or routines one at a time as they appear National Instruments Corporation 4 1 NI 488 2M User Manual for Windows 95 Windows NT Chapter 4 Debugging Your Application in your application Because Win32 Interactive Control returns the status values and error codes after each call you should be able to determine which GPIB call is failing For more information about Win32 Interactive Control refer to the online help or Chapter 6 Win32 Interactive Control Utility After you determine which GPIB call is failing and note the corresponding values of the global variables refer to Appendix A Status Word Conditions and Appendix B Error Codes and Solutions These appendixes can help you interpret the state of the driver GPIB Error Codes Table 4 1 lists the GPIB error codes Remember that the error variable is meaningful only when the ERR bit in the status variable is set For a detailed description of each error and possible solutions refer to Appendix B Error Codes and Solutions Table 4 1 GPIB Error Codes Error iberr Mnemonic Value Meaning ECIC Function requires GPIB board to be CIC ENOL No Listeners on the GPIB EADR GPIB board not addressed correctly EARG Invalid argument to function call ESAC 5 GPIB board not System Controller as required
135. or Information Interchange An action or event that occurs at an unpredictable time with respect to the execution of a program Autopolling A feature of the NI 488 2M software in which serial polls are executed automatically by the driver whenever a device asserts the GPIB SRQ line National Instruments Corporation G 1 NI 488 2M User Manual for Windows 95 Windows NT Glossary base I O address BIOS board level function C CFE CFGn CIC CPU D DAV DCL device level function DIO1 through DIO8 See I O address Basic Input Output System A rudimentary function that performs a single operation Configuration Enable The GPIB command which precedes CFGn and is used to place devices into their configuration mode 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 Controller In Charge The device that manages the GPIB by sending interface messages to other devices Central processing unit Data Valid One of the three GPIB handshake lines See handshake Device Clear The GPIB command used to reset the device or internal functions of all devices See SDC A function that combines several rudimentary board operations into one function so that the user does not have to be concerned with bus management or other GPIB protocol matters The GPIB lines that are used to tran
136. our development environment you can select a method for accessing the driver and based on your GPIB programming needs you can choose between the NI 488 functions and NI 488 2 routines Choosing a Method to Access the NI 488 2M Driver Applications can access the NI 488 2M dynamic link library gpib 32 d11 either by using an NI 488 2M language interface or by direct access NI 488 2M Language Interfaces You can use a language interface if your program is written in Microsoft Visual C C 2 0 or higher Borland C C 4 0 or higher or Microsoft Visual Basic 4 0 or higher Otherwise you must access the gpib 32 d11 directly Direct Entry Access You can directly access the DLL from any programming environment that allows you to request addresses of variables and functions that a DLL exports The gpib 32 d11 exports pointers to each of the global variables and all of the NI 488 and NI 488 2 calls National Instruments Corporation 3 1 NI 488 2M User Manual for Windows 95 Windows NT Chapter 3 Developing Your Application Choosing between NI 488 Functions and NI 488 2 Routines The NI 488 2M software includes two distinct sets of subroutines to meet your application needs Both of these sets the NI 488 functions and the NI 488 2 routines are compatible across computer platforms and operating systems so you can port programs to other platforms with little or no source code modification For most applications the NI 488 functio
137. ow these steps to implement parallel polling using NI 488 2 routines Each step contains example code 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 NI 488 2M User Manual for Windows 95 Windows NT 7 18 National Instruments Corporation Chapter 7 GPIB Programming Techniques include decl 32 h char response Addr4882_t AddressList 2 The following command clears the GPIB xf SendIFC 0 The value of sense is compared with the ist bit of the device and determines whether the data line is asserted XY PPollConfig 0 3 5 1 2 Conduct the parallel poll using PPo11 store the response and check the response for a certain value In the following example because DIOS is asserted by the device if ist 1 the program checks bit 4 hex 10 in the response to determine the value of ist PPoll 0 amp response If response has bit 4 hex 10 set the ist bit of the device at that time is equal to 1 If it does not appear the ist bit is equal to 0 Check the bit in the following statement if response amp 0x10 printf The ist equals 1 n else printf The ist equals 0 n 3 Unconfigure the device for parallel polling using the PPollUnconfig routine as shown in the following examp
138. p 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 National Instruments does not warrant that the operation of the software shall be uninterrupted or error free A Return Material Authorization RMA number must be obtained from the factory and clearly marked on the outside of the package before any equipment will be accepted for warranty work National Instruments will pay the shipping costs of returning to the owner parts which are covered by warranty National Instruments believes that the information in this manual is accurate The document has been carefully reviewed for technical accuracy In the event that technical or typographical errors exist National Instruments reserves the right to make changes to subsequent editions of this document without prior notice to holders of this edition The reader should consult National Instruments if errors are suspected In no event shall National Instruments be liable for any damages arising out of or related to this document or the information contained in it EXCEPT AS SPECIFIED HEREIN NATIONAL INSTRUMENTS MAKES NO WARRANTIES EXPRESS OR IMPLIED AND SPECIFICALLY DISCLAIMS ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE CUSTOMER S RIGHT
139. prototype Then your application invokes it as follows if ibsta amp ERR gpiberr GPIB error 3 11 NI 488 2M User Manual for Windows 95 Windows NT Chapter 3 Developing Your Application NI 488 2 Program Shell Figure 3 2 is a flowchart of the steps to create your application using NI 488 2 routines Initialize Specified GPIB Interface SendIFC Are All Boards Initialized Low Level aking High Leve High Level or Low Level Call Make a Low Level Call Make a High Level Call e Address Devices to Listen SendSet up e Send Data to Device Send Send Data to Addressed Listener e Receive Data From Device Receive SendDataBytes e Clear Device DevClear e Address Device to Talk ReceiveSetup e Serial Poll Device ReadStatusByte e Receive Data From Addressed Talker and so on RcvRespMsg and so on Finished GPIB Programming Yes Close Board ibon1 Are All Boards Closed Figure 3 2 General Program Shell Using NI 488 2 Routines NI 488 2M User Manual for Windows 95 Windows NT 3 12 National Instruments Corporation Chapter 3 Developing Your Application NI 488 2 General Program Steps and Examples The following steps demonstrate how to use the NI 488 2 routines in your application The NI 488 2M software includes the source code for an example written in C samp4882 c and the source code for the example written to use direct entry to access the gpib 32 d11
140. puter Uninstalling the GPIB Software for Windows 95 Before uninstalling the software you should remove all GPIB interface information from the Windows 95 Device Manager as described in the previous section You do not need to shut down Windows 95 before uninstalling the software National Instruments Corporation 1 11 NI 488 2M User Manual for Windows 95 Windows NT Chapter 1 Introduction Complete the following steps to remove the GPIB software 1 Run the Add Remove Programs applet from the Control Panel which can be opened from the Settings selection of the Start menu A dialog box similar to the one in Figure 1 6 appears This dialog box lists the software available for removal Add Remove Programs Properties USB Supplement to OSR2 Figure 1 6 Add Remove Programs Properties Dialog Box in Windows 95 2 Select the GPIB software you want to remove and click on the Add Remove button The uninstall program runs and removes all folders programs VxDs DLLs and registry entries associated with the GPIB software Figure 1 7 shows the results of a successful uninstallation NI 488 2M User Manual for Windows 95 Windows NT 1 12 National Instruments Corporation Chapter 1 Introduction Remove Programs From Your Computer x unlnstallShield will remove the software NI 488 2M Software for Windows 95 1 20 from your computer Please wait while each of the following components is removed Shared program fil
141. queue associated with the device that sent it The RQS bit of the device status word ibsta is set 4 The polling continues until SRQ is unasserted or an error condition is detected 5 To empty the queue use the ibrsp function ibrsp returns the first queued response Other responses are read in first in first out FIFO fashion If the RQS bit of the status word is not set when ibrsp is called a serial poll is conducted and returns whatever response is received You should empty the queue as soon as an automatic serial poll occurs because responses might be discarded if the queue is full 6 If the RQS bit of the status word is still set after ibrsp is called the response byte queue contains at least one more response byte If this happens you should continue to call ibrsp until RQS is cleared Stuck SRQ State If autopolling is enabled and the GPIB interface board detects an SRQ the driver serial polls all open devices connected to that board 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 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 attempt
142. r trigger GET messages to the interface board If the application detects a device clear from the Controller it National Instruments Corporation 7 11 NI 488 2M User Manual for Windows 95 Windows NT Chapter 7 GPIB Programming Techniques might reset the internal state of message buffers If it detects a trigger message from the Controller the application might begin an operation such as taking a voltage reading if the application is actually acting as a voltmeter Serial Polling You can use serial polling to obtain specific information from GPIB devices when they request service When the GPIB SRQ line is asserted it signals the Controller that a service request is pending The Controller must then determine which device asserted the SRQ line and respond accordingly The most common method for SRQ detection and servicing is the serial poll This section describes how you can set up your application to detect and respond to service requests from GPIB devices Service Requests from IEEE 488 Devices IEEE 488 devices request service from the GPIB Controller by asserting the GPIB SRQ line When the Controller acknowledges the SRQ it serial polls each open device on the bus to determine which device requested service Any device requesting service returns a status byte with bit 6 set and then unasserts the SRQ line Devices not requesting service return a status byte with bit 6 cleared Manufacturers of IEEE 488 devices use lower order bi
143. ration Appendix B Error Codes and Solutions ESAC 5 ESAC results when ibsic ibsre SendIFC or EnableRemote Is called when the GPIB board does not have System Controller capability Solutions Give the GPIB board System Controller capability by calling ibrsc 1 or by using the GPIB configuration utility to configure that capability into the software EABO 6 EABO indicates that an I O operation has been canceled usually due to a timeout condition Other causes 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 Solutions e Use the correct byte count in input functions or have the Talker use the END message to signify the end of the transfer e Lengthen the timeout period for the I O operation using ibtmo e Make sure that you have configured your device to send data before you request data ENEB 7 ENEB occurs when no GPIB board exists at the I O address specified in the configuration program This problem happens when the board is not physically plugged into the system the I O address specified during configuration does not match the actual board setting or there is a system conflict with the base I O address Solutions Make sure there is a GPIB boar
144. re product model Revision Configuration 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 N 488 2M User Manual for Windows 95 and Windows NT Edition Date December 1996 Part Number 321037C 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 Name Title Company Address Phone Mail to Technical Publications Fax to Technical Publications National Instruments Corporation National Instruments Corporation 6504 Bridge Point Parkway 512 794 5678 Austin TX 78730 5039 Glossary A acceptor handshake access board ANSI ASCII asynchronous automatic serial polling Listeners use this GPIB interface function to receive data and all devices use it to receive commands See source handshake and handshake The GPIB board that controls and communicates with the devices on the bus that are attached to it American National Standards Institute American Standard Code f
145. rings up the help screen which gives you more information about the current dialog box After you have finished configuring your GPIB boards and device templates click on the OK button to save the changes and exit Click on the Cancel button to exit without saving any of the changes you made After you click on the OK button the GPIB Configuration utility asks whether or not you want the changes to take effect immediately If you answer No you must restart your system before the new settings can be used If you answer Yes the GPIB Configuration utility attempts to unload and reload the NI 488 2M software so that the software uses your new settings If the GPIB Configuration utility cannot unload the software because it is being used by another application it instructs you to restart your computer If you need to unload the NI 488 2M software and prevent it from reloading when you restart your computer click on the Unload button If the GPIB Configuration utility cannot unload the NI 488 2M software it instructs you either to exit all GPIB related applications or to shut down and restart your computer If you want to use the software again after unloading it run the GPIB Configuration utility again and then click on the OK button National Instruments Corporation 8 5 NI 488 2M User Manual for Windows 95 Windows NT Appendix Status Word Conditions This appendix gives a detailed description of the conditions reported i
146. ription A 3 status word ibsta 3 4 to 3 5 ATN A 4 CIC A 4 CMPL A 3 DCAS 7 12 A 5 DTAS 7 12 A 5 END A 2 ERR A 2 LACS 7 12 A 5 LOK A 3 programming considerations 3 4 to 3 5 REM A 4 RQS A 3 SRQI A 3 status word layout table 3 5 A 1 TACS 7 11 to 7 12 A 4 TIMO A 2 Win32 Interactive Control example 6 9 string syntax in Win32 Interactive Control 6 4 to 6 5 stuck SRQ state 7 13 to 7 14 System Controller as Controller in Charge 1 2 T TACS status word condition bit position hex value and type table 3 5 description A 4 National Instruments Corporation l 11 Index Talker Listener applications 7 11 to 7 12 talk address setting 1 2 Talker Listener applications 7 11 to 7 12 Talkers 1 1 technical support E 1 to E 2C 1 termination methods errors caused by 4 4 termination of data transfers 7 1 to 7 2 TestSRQ routine 7 15 timing errors 4 3 TIMO status word condition bit position hex value and type table 3 5 description A 2 Trigger routine 3 14 triggering devices example 2 4 to 2 5 troubleshooting and common questions See also debugging GPIB Spy utility Win32 Interactive Control utility Windows 95 C 1 to C 6 common questions C 3 to C 6 Device Manager device status code C 2 to C 3 EDVR error conditions C 1 to C 2 Windows NT D 1 to D 4 common questions D 2 to D 4 examining NT system log using Event Viewer D 2 using diagnostic tools D 1 to D 2 verifying NI 48
147. river e Win32 Interactive Control utility that you use to communicate with the GPIB devices interactively using NI 488 2 functions and routines It helps you to learn the NI 488 2 routines and to program your instrument or other GPIB devices e GPIB Spy is the GPIB application monitor program It is a debugging tool that you can use to monitor the NI 488 2 calls your GPIB applications make e The GPIB Configuration utility a control panel application that you use to modify the software configuration parameters of the NI 488 2M software e Diagnostic is a utility you can use to verify that the GPIB hardware and software have been installed properly DOS and 16 Bit Windows Support Files e A documentation file readme txt that contains information about using existing DOS and 16 bit Windows applications under Windows NT e A Virtual device driver gpib vdd d11 that allows existing NI 488 2 for DOS and 16 bit Windows applications to access the NI 488 2M software e ADOS device driver gpib nt com When you run an existing NI 488 2 application for DOS in the Windows NT environment this file replaces the gpib com driver that you used in the DOS environment e A Windows dynamic link library goib d11 When you run an existing NI 488 2 application for Windows in the Windows NT environment this file replaces the GPIB DLL that you used in the Windows 16 bit environment NI 488 2M User Manual for Windows 95 Windows NT 1 14 Nat
148. rmation from the Windows 95 Device Manager To remove the hardware information from Windows 95 double click on the System icon in the Control Panel which can be opened from the Settings selection of the Start menu Select the Device Manager tab in the System Properties dialog box that appears click on the View devices by type button at the top of the Device Manager tab and double click on the National Instruments GPIB Interfaces icon To remove an interface select it from the list of interfaces under National Instruments GPIB Interfaces as shown in Figure 1 5 and click on the Remove button NI 488 2M User Manual for Windows 95 Windows NT 1 10 National Instruments Corporation Chapter 1 Introduction System Properties 21x General Device Manager Hardware Profiles Performance View devices by type C View devices by connection m Computer amp Disk drives Display adapters 3 Floppy disk controllers SS Hard disk controllers Keyboard z Monitor A Mouse W National Instruments GPIB Interfaces W AT GPIB TNT SF Network adapters a7 Ports COM amp LPT System devices Ue Lae ef ee Properties Refresh iui Print cea Figure 1 5 Selecting an Interface to Remove from Windows 95 After you remove the appropriate interface information from the Device Manager you should physically remove the interface from your com
149. ruments How do I communicate with my instrument over the GPIB Refer to the documentation that came from the instrument manufacturer The command sequences you use are totally dependent on the specific instrument The documentation for each instrument should include the GPIB commands you need to communicate with it In most cases NI 488 device level calls are sufficient for communicating with instruments Refer to Chapter 3 Developing Your Application for more information Can I use the NI 488 and NI 488 2 calls together in the same application Yes you can mix NI 488 functions and NI 488 2 routines What can I do to check for errors in my GPIB application Examine the value of ibsta after each NI 488 or NI 488 2 call If a call fails the ERR bit of ibsta is set and an error code is stored in iberr For more information about global status variables refer to Chapter 3 Developing 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 test Also make sure you have filled out the Technical Support Form in Appendix E Customer Communication NI 488 2M User Manual for Windows 95 Windows NT D 4 National Instruments Corporation Appendix Customer Communication For your convenience this appendix contains forms to help you gather the information necessary to help us solve technical problems and a form yo
150. s 95 Windows NT 6 8 National Instruments Corporation Chapter 6 Win32 Interactive Control Utility Table 6 3 Syntax for NI 488 2 Routines in Win32 Interactive Control Continued Routine Syntax Description SetRWLS addrlist Put devices in remote with lockout state TestSRQ Test for service request TestSys addrlist Cause multiple devices to perform self tests Trigger address Trigger a device TriggerList addrlist Trigger multiple devices WaitSRQ Wait for service request Table 6 4 Auxiliary Functions in Win32 Interactive Control 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 Enter 488 2 mode for board v Display Win32 interactive utility online help help option Display help information on option where option is any NI 488 NI 488 2 or auxiliary call for example help ibwrt or help set Repeat previous function Turn OFF display Turn ON display n function Execute function n times where function represents the correct Win32 Interactive Control function syntax Execute previous function n times filename Execute indirect file where filename is the pathname of a file that contains Win32 Interactive Control functions to be executed buffer option Set type of display used for buffers Valid options are full brief ascii and off Default is full
151. s a GPIB trigger using the Send command The buffer that you pass to Send is the command message that programs the device to behave properly Step 4b Trigger the device using the Trigger routine Step 4c Wait for the device to acquire the reading using the Wait SRQ routine Step 4d If the wait for the service request succeeded read the serial poll status byte and verify that it indicates that the device obtained a good measurement using the ReadStatusByte routine NI 488 2M User Manual for Windows 95 Windows NT 3 14 National Instruments Corporation Chapter 3 Developing Your Application Step 4e Read the measurement from the device using the Receive routine and record it in a list of device measurements Steps 4b through 4e should be repeated for each measurement you want to acquire Step 5 Place the Device Offline Before Exiting Your Application Once you are finished accessing the GPIB device take it offline using the ibon1 function before you exit your application Language Specific Programming Instructions The following sections describe how to develop compile and link your Win32 GPIB applications using various programming languages Microsoft Visual C C Version 2 0 or Higher Before you compile your Win32 C application make sure that the following lines are included at the beginning of your program include lt windows h gt include decl 32 h To compile and link a Win32 console applicatio
152. s a new set of serial polls National Instruments Corporation 7 13 NI 488 2M User Manual for Windows 95 Windows NT Chapter 7 GPIB Programming Techniques Autopolling and Interrupts If autopolling and interrupts are both enabled the NI 488 2M software can perform autopolling after any device level NI 488 call as long as no GPIB I O is currently in progress In this case an automatic serial poll can occur even when your application is not making any calls to the NI 488 2M software Autopolling can also occur when a device level ibwait for RQS is in progress Autopolling is not allowed whenever an application calls a board level NI 488 function or any NI 488 2 routine or the stuck SRQ ESRQ condition occurs CF Note The NI 488 2M software for Windows 95 and Windows NT does not function properly if interrupts are disabled SRQ and Serial Polling with NI 488 Device Functions You can use the device level NI 488 function ibrsp to conduct a serial poll ibrsp conducts a single serial poll and returns the serial poll response byte to the application If automatic serial polling is enabled the application can use ibwait to suspend program execution until RQS appears in the status word ibsta The program can then call ibrsp to obtain the serial poll response byte The following example illustrates the use of the ibwait and ibrsp functions in a typical SRQ servicing situation when automatic serial polling is enabled include decl 32 h
153. s problem can also result in corrupted or incomplete data A well behaved IEEE 488 device should hold off handshaking and set the appropriate transfer rate If your device is not well behaved you can test for and resolve the timing error by single stepping through your program and inserting finite delays between each GPIB call One way to do this is to have your device communicate its status whenever possible Although this method is not possible with many devices it is usually the National Instruments Corporation 4 3 NI 488 2M User Manual for Windows 95 Windows NT Chapter 4 Debugging Your Application best option Your delays will be controlled by the device and your application can adjust itself and work independently on any platform Other delay mechanisms will probably cause varying delay times on different platforms Communication Errors Repeat Addressing Devices adhering to the IEEE 488 2 standard should remain in their current state until specific commands are sent across the GPIB to change their state However some devices require GPIB addressing before any GPIB activity Therefore you might need to configure your NI 488 2M driver to perform repeat addressing if your device does not remain in its currently addressed state Refer to Chapter 8 GPIB Configuration Utility or to the description of ibconfig option IbcREADDR in the online help or NI 488 2M Function Reference Manual for Win32 for more information about reconfigur
154. s word condition bit position hex value and type table 3 5 description A 5 Talker Listener applications 7 12 waiting for messages from Controller 7 12 debugging See also GPIB Spy utility troubleshooting and common questions Win32 Interactive Control utility communication errors 4 4 repeat addressing 4 4 termination method 4 4 configuration errors 4 3 global status variables 4 1 GPIB error codes table 4 2 B 1 GPIB Spy 4 1 See also GPIB Spy utility other errors 4 4 timing errors 4 3 Win32 Interactive Control utility 4 1 to 4 2 decl 32 h file Borland C C language interface file 1 8 1 14 NI 488 2M User Manual for Windows 95 Windows NT Index Microsoft C C language interface file 1 7 1 14 DevClear routine 3 14 device functions See NI 488 functions Device Manager device status codes troubleshooting C 2 to C 3 device level calls and bus management 7 11 direct access to NI 488 2 dynamic link library 3 1 documentation conventions used in manual xv xvi how to use manual set xiii xiv organization of manual xiv xv related documentation xvi DOS applications running under Windows 95 3 19 to 3 20 under Windows NT 3 20 to 3 21 DOS support files NI 488 2M for Windows 95 1 7 NI 488 2M for Windows NT 1 13 drivers configuring 4 3 driver and driver utilities for NI 488 2M software 1 6 to 1 7 DTAS status word condition bit position hex value and type table 3 5 description A 5 Talk
155. 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 This is measured by strain gauges that monitor the amount of pressure used to move the mixer arms When a certain consistency is reached the mixture is removed and a new batch of syrup is poured in the mixer The GPIB strain gauges are connected to a computer with an IEEE 488 2 interface board and the NI 488 2M software installed The process is controlled by an application that uses NI 488 2 routines to communicate with the IEEE 488 2 compliant strain gauges The following steps correspond to the program flowchart in Figure 2 7 1 The application initializes the GPIB by bringing the interface board in the computer online 2 The application configures the strain gauges to request service when they have a significant pressure reading or a mechanical failure occurs They signal their request for service by asserting the SRQ line 3 The application waits for one or more of the strain gauges to indicate that they have a significant pressure reading This wait event ends as soon as the SRQ line is asserted 4 The application serial polls each of the strain gauges to see if it requested service 5 Once the application has determined which one of the strain gauges requires service
156. smit command or data bytes from one device to another DLL Dynamic link library DMA Direct memory access High speed data transfer between the GPIB board and memory that is not handled directly by the CPU Not available on some systems See programmed I O driver Device driver software installed within the operating system NI 488 2M User Manual for Windows 95 Windows NT G 2 National Instruments Corporation E END or END Message EOI EOS or EOS Byte EOT ESB GET GPIB GPIB address GPIB board GTL H handshake National Instruments Corporation G 3 Glossary A message that signals the end of a data string END is sent by asserting the GPIB End or Identify EOD line with the last data byte A GPIB line that is used to signal either the last byte of a data message END or the parallel poll Identify IDY message A 7 or 8 bit end of string character that is sent as the last byte of a data message End of transmission The Event Status bit is part of the IEEE 488 2 defined status byte which is received from a device responding to a serial poll Group Execute Trigger It is the GPIB command used to trigger a device or internal function of an addressed Listener General Purpose Interface Bus is the common name for the communications interface system defined in ANSI IEEE Standard 488 1 1987 and ANSI IEEE Standard 488 2 1987 The address of a device on the GPIB composed of a primary address MLA
157. ss set a timeout of 10 seconds enable the END message and disable the EOS mode ibdev enter board index 0 enter primary address 6 enter secondary address 0 enter timeout T10s enter EOI on last byte flag 1 enter end of string mode byte 0 udo NI 488 2M User Manual for Windows 95 Windows NT 6 2 National Instruments Corporation Chapter 6 Win32 Interactive Control Utility If you enter a command and no parameters you are automatically prompted for the necessary arguments If you already know the required arguments you can enter them from the command line as follows ibdev 0 6 0 T10s 1 0 udo The new prompt ud0 represents a device level handle that can be used for further GPIB calls To clear the device use ibc1r as follows ud0 ibclr 0100 cmpl To write data to the device use ibwrt Make sure that you refer to the instrument user manual that came with your GPIB instrument for specific command messages ud0 ibwrt enter string RST VAC AUTO TRIGGER 2 SRE 16 0100 cmpl count 35 or equivalently ud0 ibwrt RST VAC AUTO TRIGGER 2 SRE 16 0100 cmpl count 35 To send a trigger use ibt rg as follows ud0 ibtrg 0100 cmpl To read data from your device use ibrd The data that is read from the instrument is displayed For example to read 18 bytes ud0 ibrd enter byte count 18 0100 cmpl count 18 4e 44 43 56 20 30 30 30 NDCV 000 2e 30
158. started manual This error is also returned if you remove a PCMCIA GPIB or PCMCIA GPIB while the driver is accessing it This error is also returned if you try to access a PCMCIA GPIB when 32 bit PCMCIA drivers are not enabled Refer to the Install the PCMCIA GPIB or PCMCIA GPIB section in your getting started manual for more information about enabling 32 bit PCMCIA drivers EDVR Error with ibcntl Set to 0xE0140004 535560188 This error may occur if the GPIB interface has not been correctly installed and detected by Windows 95 Refer to the Installation and Configuration chapter in your getting started manual for details on how to install the GPIB hardware If you have already followed those instructions and still receive this error Windows 95 might have configured the GPIB interface as an other device Refer to your getting started manual for information on how to force Windows 95 to detect the GPIB hardware EDVR Error Condition with ibentl set to 0xE1030043 519897021 This error occurs if you have enabled DOS GPIB support and attempted to run an existing GPIB DOS application that was compiled with an older unsupported DOS language interface Troubleshooting Windows 95 Device Manager Device Status Codes If you are having trouble with your GPIB interface check to see if the interface listing in the Windows 95 Device Manager appears with an exclamation point or X by it If it does click on the interface listing and then cli
159. t might occur and possible solutions NI 488 2M User Manual for Windows 95 Windows NT xiv National Instruments Corporation About This Manual e Appendix C Windows 95 Troubleshooting and Common Questions describes how to troubleshoot problems and lists some common questions for Windows 95 users e Appendix D Windows NT Troubleshooting and Common Questions describes how to troubleshoot problems and lists some common questions for Windows NT users e Appendix E Customer Communication contains forms you can use to request help from National Instruments or to comment on our products and manuals e The Glossary contains an alphabetical list and description of terms used in this manual including abbreviations acronyms metric prefixes mnemonics and symbols e The Index contains an alphabetical list of key terms and topics in this manual including the page where you can find each one Conventions Used in This Manual The following conventions are used in this manual lt gt Angle brackets enclose the name of a key on the keyboard for example lt Esc gt A hyphen between two or more key names enclosed in angle brackets denotes that you should simultaneously press the named keys for example lt Ctrl Alt Delete gt The symbol leads you through nested menu items and dialog box options to a final action The sequence File Page Setup Options Substitute Fonts directs you to pull down the File menu selec
160. t of the function UNL Unlisten The GPIB command used to unaddress any active Listeners UNT Untalk The GPIB command used to unaddress an active Talker NI 488 2M User Manual for Windows 95 Windows NT G 8 National Instruments Corporation Numbers Symbols repeat previous function function Win32 Interactive Control 6 9 filename execute indirect file function Win32 Interactive Control 6 9 turn ON display function Win32 Interactive Control 6 9 turn OFF display function Win32 Interactive Control 6 9 16 bit Windows applications running under Windows 95 3 19 under Windows NT 3 20 to 3 21 16 bit Windows support files NI 488 2M for Windows 95 1 7 32 bit NI 488 2M driver components 1 6 A active Controller See Controller in Charge CIC addresses See GPIB addresses AllSpoll routine 7 15 7 16 application development See also debugging GPIB programming techniques accessing NI 488 2M DLL 3 1 application examples asynchronous I O 2 6 to 2 7 basic communication 2 2 to 2 3 National Instruments Corporation l 1 Index basic communication with IEEE 488 2 compliant devices 2 14 to 2 15 clearing and triggering devices 2 4 to 2 5 end of string mode 2 8 to 2 9 non controller example 2 20 to 2 21 parallel polls 2 18 to 2 19 serial polls using NI 488 2 routines 2 16 to 2 17 service requests 2 10 to 2 13 source code files 2 1 to 2 2 choosing betwe
161. t the Page Setup item select Options and finally select the Substitute Fonts options from the last dialog box bold Bold text denotes the names of menus menu items parameters dialog boxes dialog box buttons or options icons windows Windows 95 tabs or LEDs bold italic Bold italic text denotes a note caution or warning bold Bold text in this font denotes the messages and responses that the monospace computer automatically prints to the screen This font also emphasizes lines of code that are different from the other examples National Instruments Corporation XV NI 488 2M User Manual for Windows 95 Windows NT About This Manual italic italic monospace monospace TEEE 488 and TEEE 488 2 Italic text denotes emphasis a cross reference or an introduction to a key concept This font also denotes text for which you supply the appropriate word or value as in Windows 3 x Italic text in this font denotes that you must supply the appropriate words or values in the place of these items Text in this font denotes text or characters that you should literally enter from the keyboard sections of code programming examples and syntax examples This font is also used for the proper names of disk drives paths directories programs subprograms subroutines device names functions operations variables filenames and extensions and for statements and comments taken from programs IEEE 488 and IEEE 488 2 refer to the
162. talk address other than its own talk address or Interface Clear IFC NI 488 2M User Manual for Windows 95 Windows NT A 4 National Instruments Corporation Appendix A Status Word Conditions LACS brd LACS indicates whether the GPIB board is addressed as a Listener LACS is set whenever the GPIB board detects that its listen address and secondary address if enabled has been sent either by the GPIB board itself or by another Controller LACS is also set whenever the GPIB board shadow handshakes as a result of the ibgts function LACS is cleared whenever the GPIB board detects the Unlisten UNL command its own talk address Interface Clear IFC or that the ibgts function has been called without shadow handshake 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 DCAS is set whenever the GPIB board detects that the Device Clear DCL command has been sent by another Controller or whenever the GPIB board as a Listener detects that the Selected Device Clear SDC command has been sent by another Controller If you use the ibwait or ibnotify function
163. tely updates ibsta and returns If you want to use ibwait to wait for one or more events to occur then pass a wait mask to the function The wait mask should always include the TIMO event otherwise your application is suspended indefinitely until one of the wait mask events occurs Event Notification in Win32 GPIB Win32 GPIB applications can asynchronously receive event notifications using the ibnotify function This function is useful if you want your application to be notified asynchronously about the occurrence of one or more GPIB events For example you might choose to use ibnotify if your application only needs to interact with your GPIB device when it is requesting service After calling ibnotify your application does not need to check the status of your GPIB device Then when your GPIB device requests service the GPIB driver automatically notifies your application that the event has occurred by invoking a callback function The callback function is registered with the GPIB driver when the ibnotify call is made Calling the ibnotify Function ibnotify has the following function prototype ibnotify int ud unit descriptor int mask bit mask of GPIB events GpibNotifyCallback_t Callback callback function void RefData user defined reference data Both board level and device level ibnotify calls are supported by the GPIB driver If you are using device level calls you call ibnotify with a device handle for ud
164. teps 5 and 6 are repeated until the metals can be successfully mixed 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 GPIB Cable GPIB Cable GPIB Cable GPIB Cable GPIB Cable GPIB Cable A NO NO NO NO NO Computer UNIT 1 UNIT 2 UNIT 3 Temperature Power Temperature Power Temperature Power INIT Transducer Supply Transducer Supply Transducer y PPollConfig Configure Transducer 1 Parallel Poll For Parallel Ports Enable Y PPollConfig Configure Transducer 2 Parallel Poll For Parallel Ports x Enable Yy PPollConfig Configure Transducer 3 Parallel Poll For Parallel Ports H i i Enable m o o Vv Non GPIB Activity PPoll Are All Metals Ready SendList Start Power Supplies Howxon ON y PPollUnconfig Parallel Poll Disable PPoll Unconfigure y CLEAN UP j Figure 2 8 Program Flowchart for Example 8 National Instruments Corporation 2 19 NI 488 2M User Manual for Windows 95 Windows NT Chapter 2 Application Examples Example 9 Non Controller Example This example illustrates how you can use the NI 488 2M 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 testin
165. that you can use to monitor the NI 488 2 calls your GPIB applications make The GPIB Configuration utility is integrated into the Windows 95 Device Manager You use this utility to modify the configuration parameters of the NI 488 2M software Diagnostic is a utility that you use to verify that the GPIB hardware and software have been installed properly 1 7 NI 488 2M User Manual for Windows 95 Windows NT Chapter 1 NI 488 2M User Manual for Windows 95 Windows NT 1 8 Introduction 16 Bit Windows Support Files A 16 bit Windows dynamic link library goib d11 used when you run an existing NI 488 2 application for Windows in the Windows 95 environment This file replaces the GPIB DLL that you used in the Windows 3 environment for Win16 applications A 32 bit Windows dynamic link library gpib32ft d11 that helps gpib dii thunk 16 bit GPIB calls to 32 bit GPIB calls that address the standard 32 bit dynamic link library gpib 32 d11 DOS Support Files A Virtual Device Driver VxD gpibdosk vxd that serves as the DOS device driver to trap NI 488 function calls and NI 488 2 routine calls made by DOS applications and route them to the standard 32 bit dynamic link library gpib 32 d11 This file replaces the real mode DOS device driver that would be loaded from your config sys file if you were using the DOS environment for DOS GPIB applications A Win32 executable gpibdos exe that helps gpibdosk vxd thunk DOS GPIB calls to 32 b
166. the film by waiting for RQS request for service The film recorder asserts the GPIB SRQ line when it has finished loading the film 5 As soon as the film recorder asserts the GPIB SRQ line the application s wait for the RQS event completes The application conducts a serial poll by sending a special command message to the film recorder that directs it to return a response in the form of a serial poll status byte This byte contains information indicating what kind of service the film recorder is requesting or what condition it is flagging In this example it indicates the completion of a command NI 488 2M User Manual for Windows 95 Windows NT 2 10 National Instruments Corporation 10 National Instruments Corporation Chapter 2 Application Examples A color image transfers to the digital film recorder in three consecutive passes one pass each for the red green and blue components of the image Sub steps 6a 6b and 6c are repeated for each of the passes 6a The application sends a command to the film recorder directing it to accept data to create a single pass image The film recorder asserts the SRQ line as soon as a pass is completed 6b The application waits for RQS 6c When the SRQ line is asserted the application serial polls the film recorder to see if it requested service as in Step 5 The application issues a command to the film recorder to advance the film by one frame The advance occurs successfully u
167. tion 2 1 NI 488 2M User Manual for Windows 95 Windows NT Chapter 2 Application Examples rqs4882 c is the source code file for Example 7 It uses NI 488 2 routines to communicate with GPIB devices that use the GPIB SRQ line to request service ppoll c is the source code file for Example 8 It uses NI 488 2 routines to conduct parallel polls non_cic c is the source code file for Example 9 It illustrates how you can use the NI 488 2M driver in a non Controller application 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 2M 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 This list of commands is specific to his multimeter and is available from the multimeter manufacturer He sets up the computer to direct the multimeter to take measurements and record each measurement as it occurs To do this he has written an application that uses some simple high level GPIB commands The following steps correspond to the program flowchart in Figure 2 1 1 The application initializes the GPIB by bringing the interface board in the computer online The application sends the multimeter
168. tion and NI 488 2 routine information such as format parameters and possible errors Organization of This Manual This manual is organized as follows Chapter 1 Introduction gives an overview of GPIB and the NI 488 2M 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 Chapter 3 Developing Your Application explains how to develop a GPIB application using NI 488 functions and NI 488 2 routines Chapter 4 Debugging Your Application describes several ways to debug your application Chapter 5 GPIB Spy Utility introduces you to GPIB Spy the application monitor you can use to monitor NI 488 and NI 488 2 calls Chapter 6 Win32 Interactive Control Utility introduces you to Win32 Interactive Control the interactive control utility that you can use to communicate with GPIB devices interactively Chapter 7 GPIB Programming Techniques describes techniques for using some NI 488 functions and NI 488 2 routines in your application Chapter 8 GPIB Configuration Utility contains a description of the GPIB Configuration utility you can use to configure your NI 488 2M software Appendix A Status Word Conditions gives a detailed description of the conditions reported in the status word ibsta Appendix B Error Codes and Solutions lists a description of each error some conditions under which i
169. to wait for DCAS and the wait is completed DCAS is cleared from ibsta after the next GPIB call The same is true of reads and writes If you call a read or write function such as ibwrt or Send and DCAS is set in ibsta the I O operation is aborted DCAS is cleared from ibsta after the next GPIB call National Instruments Corporation A 5 NI 488 2M User Manual for Windows 95 Windows NT Appendix 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 Error iberr Mnemonic Value Meaning ECIC Function requires GPIB board to be CIC ENOL No Listeners on the GPIB EADR GPIB board not addressed correctly EARG Invalid argument to function call ESAC 5 GPIB board not System Controller as required EABO 6 T O operation aborted timeout ENEB Nonexistent GPIB board EOIP Asynchronous I O in progress ECAP No capability for operation EBUS GPIB bus error ESTB Serial poll status byte queue overflow ESRQ SRQ stuck in ON position ETAB Table problem National Instruments Corporation B 1 NI 488 2M User Manual for Windows 95 Windows NT Appendix B Error Codes and Solutions EDVR 0 ECIC 1 EDVR is returned when the board or device name passed to ibfind or the board index passed to ibdev cannot be accessed The global variable ibcnt1 contains an error code This error occurs
170. troller Control can pass from the current CIC to an idle Controller but only the System Controller usually a GPIB interface board can make itself the CIC 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 A listen address is formed by setting bit 5 the LA Listen Active bit of the GPIB address For example if a device is at address 1 the Controller sends hex 41 address 1 with bit 6 set to make the device a Talker Because the Controller is usually at primary address 0 it sends hex 20 address 0 with bit 5 set to make itself a Listener Figure 1 1 shows the configuration of the GPIB address bits Postion eee ea le ed Meaning 0 TA LA GPIB Primary Address range 0 30 Figure 1 1 GPIB Address Bits With some devices you can use secondary addressing A secondary address is a number in the range hex 60 to hex 7E When secondary addressing is in use the Controller sends the primary talk or listen address of the device followed by the secondary address of the device Sending Messages across the GPIB Devices on the bus comm
171. ts to communicate the reason for the service request or to summarize the state of the device 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 These events include power on user request command error execution error device dependent error query error request control and operation complete The device can assert SRQ when ESB or MAV are set or when a manufacturer defined condition occurs NI 488 2M User Manual for Windows 95 Windows NT 7 12 National Instruments Corporation Chapter 7 GPIB Programming Techniques Automatic Serial Polling You can enable automatic serial polling if you want your application to conduct a serial poll automatically any time the SRQ line is asserted The autopolling procedure occurs as follows 1 To enable autopolling use the GPIB Configuration Utility or the configuration function ibconfig with option IbcAUTOPOLL Autopolling is enabled by default 2 When the SRQ line is asserted the driver automatically serial polls the open devices 3 Each positive serial poll response bit 6 or hex 40 is set is stored in a
172. u can use to comment on the product documentation When you contact us we need the information on the Technical Support Form and the configuration form if your manual contains one about your system configuration to answer your questions as quickly as possible National Instruments has technical assistance through electronic fax and telephone systems to quickly provide the information you need Our electronic services include a bulletin board service an FTP site a Fax on Demand system and e mail support If you have a hardware or software problem first try the electronic support systems If the information available on these systems does not answer your questions we offer fax and telephone support through our technical support centers which are staffed by application engineers Electronic Services Bulletin Board Support National Instruments has BBS and FTP sites dedicated for 24 hour support with a collection of files and documents to answer most common customer questions From these sites you can also download the latest instrument drivers updates and example programs For recorded instructions on how to use the bulletin board and FTP services and for BBS automated information call 512 795 6990 You can access these services at United States 512 794 5422 Up to 14 400 baud 8 data bits 1 stop bit no parity United Kingdom 01635 551422 Up to 9 600 baud 8 data bits 1 stop bit no parity France 01 48 65 15 59 Up to 9
173. unctions See auxiliary functions Win32 Interactive Control NI 488 functions G General Purpose Interface Bus See GPIB global variables 3 4 to 3 6 count variables ibcnt and ibcntl 3 6 debugging applications 4 1 error variable iberr 3 5 to 3 6 status word ibsta 3 4 to 3 5 NI 488 2M User Manual for Windows 95 Windows NT Index writing multithread Win32 GPIB applications 7 9 to 7 10 GPIB configuration 1 4 to 1 6 See also GPIB configuration utility Win32 Interactive Control utility controlling more than one board 1 5 linear and star system configuration illustration 1 4 requirements 1 5 to 1 6 definition 1 1 overview 1 1 sending messages across 1 2 to 1 3 data lines 1 2 handshake lines 1 3 interface management lines 1 3 Talkers Listeners and Controllers 1 1 GPIB addresses address bit configuration table 1 2 listen address 1 2 primary 1 2 purpose 1 2 repeat addressing 4 4 secondary 1 2 syntax in Win32 Interactive Control 6 6 talk address 1 2 GPIB configuration utility overview 8 1 Windows 95 8 2 to 8 4 Windows NT 8 4 to 8 5 GPIB programming techniques See also application development asynchronous event notification in Win32 applications 7 4 to 7 9 calling ibnotify function 7 4 to 7 5 ibnotify programming example 7 6 to 7 9 device level calls and bus management 7 11 high speed data transfers 7 2 to 7 3 enabling HS488 7 2 to 7 3 NI 488 2M User Manua
174. unicate by sending messages Signals and lines transfer these messages across the GPIB interface which consists of 16 signal lines and eight ground return shield drain lines The 16 signal lines are discussed in the following sections NI 488 2M User Manual for Windows 95 Windows NT 1 2 National Instruments Corporation Chapter 1 Introduction Data Lines Eight data lines DIO1 through DIO8 carry both data and command messages 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 NRFD Listening device is ready not ready to receive a not ready for data message byte Also used by the Talker to signal high speed GPIB transfers NDAC Listening device has has not accepted a aos data accepted message byte Talking device indicates signals on data lines a valid are stable valid data National Instruments Corporation 1 3 NI 488 2M User Manual for Windows 95 Windows NT Chapter 1 Introduction Interface Management Lines Five GPIB hardware lines manage the flow of information across the bus Table 1 2 summarizes the GPIB interface management lines Table 1 2 GPIB Interface Management Lines ATN Controller driv
175. using NI 488 2 routines only Using NI 488 2 Routines Multiple Boards and or Multiple Devices When your system includes a board that must access multiple devices use the NI 488 2 routines NI 488 2 routines can perform the following tasks with a single call e Find all of the Listeners on the bus e Find a device requesting service e Determine the state of the SRQ line or wait for SRQ to be asserted e Address multiple devices to listen National Instruments Corporation 3 3 NI 488 2M User Manual for Windows 95 Windows NT Chapter 3 Developing Your Application You can mix board level NI 488 functions with the NI 488 2 routines to have access to all of the NI 488 2 functionality Checking Status with Global Variables er Note Each NI 488 function and NI 488 2 routine updates four global variables to reflect the status of the device or board that you are using These global status variables are the status word ibsta the error variable iberr and the count variables ibcnt and ibcnt1 They contain useful information about the performance of your application Your application should check these variables after each GPIB call The following sections describe each of these global variables and how you can use them in your application If your application is a multithreaded application refer to the Writing Multithreaded Win32 GPIB Applications section in Chapter 7 GPIB Programming Techniques Status Word ibsta All
176. vel Functions Device functions are high level functions that automatically execute commands to handle bus management operations such as reading from and writing to devices or polling them for status If you use device functions you do not need to understand GPIB protocol or bus management For information about device level calls and how they manage the GPIB refer to the Device Level Calls and Bus Management section in Chapter 7 GPIB Programming Techniques NI 488 Board Level Functions Board functions are low level functions that perform rudimentary GPIB operations Board functions access the interface board directly and require you to handle the addressing and bus management protocol In cases when the high level device functions might not meet your needs low level board functions give you the flexibility and control to handle situations such as the following e Communicating with non compliant non IEEE 488 2 devices e Altering various low level board configurations e Managing the bus in non typical ways 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
177. when you try to access a board or device that is not installed or configured properly EDVR is also returned if an invalid unit descriptor is passed to any NI 488 function call Solutions Use ibdev to open a device without specifying its symbolic name Use only device or board names that are configured in the GPIB configuration utility as parameters to the ibfind function Use the GPIB Configuration utility to ensure that each board you want to access is configured properly Use the unit descriptor returned from ibdev or ibfind as the first parameter in subsequent NI 488 functions Examine the variable before the failing function to make sure its value has not been corrupted For Windows 95 refer to the Troubleshooting EDVR Error Conditions section in Appendix C Windows 95 Troubleshooting and Common Questions for more information ECIC is returned when one of the following board functions or routines is called while the board is not CIC Any device level NI 488 functions that affect the GPIB Any board level NI 488 functions that issue GPIB command bytes ibemd ibcmda ibln and ibrpp ibcac and ibgts Any of the NI 488 2 routines that issue GPIB command bytes SendCmds PPoll Send and Receive NI 488 2M User Manual for Windows 95 Windows NT B 2 National Instruments Corporation Appendix B Error Codes and Solutions Solutions ENOL 2 Use ibsic or SendIFC to make the GPIB board become CIC on the GPIB Use
178. 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 2M software which includes the C and Visual Basic source code for each of the nine examples The programs are listed in order of increasing complexity If you are new to GPIB programming you might want to study the contents and concepts of the first sample simple c before moving on to more complex examples The following example programs are included with your NI 488 2 software e simple c is the source code file for Example 1 It illustrates how you can establish communication between a host computer and a GPIB device e clr_trg cis the source code file for Example 2 It illustrates how you can clear and trigger GPIB devices e asynch c is the source code file for Example 3 It illustrates how you can perform non GPIB tasks while data is being transferred over the GPIB e eos c is the source code file for Example 4 It illustrates the concept of the end of string EOS character e rqs cis the source code file for Example 5 It illustrates how you can communicate with GPIB devices that use the GPIB SRQ line to request service This sample is written using NI 488 functions e easy4882 c is the source code file for Example 6 It is an introduction to NI 488 2 routines National Instruments Corpora
179. y installed or if there is a conflict between the GPIB hardware and the other hardware in the system the NI 488 2M driver fails to start Two Windows NT utilities are useful in determining the source of the problem the Devices applet in the Control Panel and the Event Viewer The information available through each utility is described in the following sections Examining NT Devices to Verify the NI 488 2M Installation To verify whether the NI 488 2M devices are installed correctly that is that the devices are started run the Devices applet in the Control Panel In Windows NT 3 51 open the GPIB Control Panel in the Main group of the Program Manager In Windows NT 4 0 or later select Start Settings Control Panel This utility lists all of the devices Windows NT detects Each device has a status associated with it If the NI 488 2M driver is installed correctly the following lines appear in the list of NT devices Device Status Started GPIB Board Class Driver Started Automatic GPIB Device Class Driver Started Automatic You should also see one or more lines similar to the following Device Status Started GPIB Port Driver AT GPIB kK System GPIB Port Driver PCI GPIB eK System National Instruments Corporation D 1 NI 488 2M User Manual for Windows 95 Windows NT Appendix D Windows NT Troubleshooting and Common Questions The GPIB Board Class Driver and the GPIB Device Class Driver should both have a status of Started I
Download Pdf Manuals
Related Search
Related Contents
Rexel T70640 folder Quantum 7100 Operator's Guide MODE D`EMPLOI TOPCELT 1 Mise en place de l Bedienungsanleitung HGST Ultrastar He6 6TB SATA 20 Pack 570KB 製品仕様書 FC-412 Management Protocol Converter Chassis User Manual Copyright © All rights reserved.
Failed to retrieve file