PRINT “Read: “; Buf$
CALL IBCMD(BRD0%, “?_”): IF IBSTA% <0 THEN GOTO gpiberr
'
'____________ Cleanup and End ____________
'
cleanup:
CALL IBONL(BRD0%, 0): 'Release the board file handle
CALL IBONL(D39XX%, 0): 'Release the instrument file handle
END
GPIBERR:
PRINT “IBSTA%=”; HEX$(IBSTA%); “, IBERR%=”; IBERR%: GOTO cleanup
3.6.2
Example 2 – Borland Turbo C
/*
*
Borland Turbo C Example Program for the Krohn-Hite Model 39XX multichannel
*
filter using the NI-488
*
Should work with Microsoft C also.
*/
*/====================================================================
*
*
This sample program sends and receives data from a Krohn-Hite model 39XX
*
In the Borland IDE, place “MCIB.OBJ” in your project list
*
*
Set the instrument to GPIB address 1:
*
Press [1] [SECOND FUNCTION] [MEGA]
*
Set the instrument for no carriage return or line feed (EOI only):
*
Press [0] [SECOND FUNCTION] [ALL CHAN]
*
*
This program assumes the name of the device at address 1 hasn’t been
*
changed in IBCONFIG (it’s still called DEV1, which is the default).
*
The status variables IBSTA, IBERR, and IBCNT are defined in DECL.H.
*
Each bit of IBSTA and each value of IBERR are defined in DECL.H as
*
a mnemonic constant for easy recognition in application programs. In
*
this example, these mnemonic definitions are logically ANDed with the
*
variable IBSTA to determine if a particular bit has been set. The mnemonic
*
definitions are equated with the variable IBERR to determine the error
*
code.
*
*
The function GPIBERR is called when a NI-488 function fails. The
*
error message is printed along with the status variables IBSTA, IBERR,
*
and IBCNT.
*
The NI-488 function IBONL is called from the main body of the program or
*
from the function GPIBERR. When the second parameter of the function
Section 3 - GPIB Programming
3-12
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com