National Instruments NI-488.2 Time Clock User Manual


 
Chapter 3 Developing Your Application
© National Instruments Corp. 3-13 NI-488.2 User Manual for Windows
General Program Steps and Examples
The following steps demonstrate how to use the NI-488.2 routines in your program. This
example configures a digital multimeter, reads 10 voltage measurements, and computes
the average of these measurements.
Step 1. Initialization
Use the SendIFC routine to initialize the bus and the GPIB interface board so that the
GPIB board is Controller-In-Charge (CIC). The only argument of SendIFC is the GPIB
interface board number.
SendIFC(0);
if (ibsta & ERR) {
gpiberr("SendIFC error");
}
Step 2. Find All Listeners
Use the FindLstn routine to create an array of all of the instruments attached to the
GPIB. The first argument is the interface board number, the second argument is the list
of instruments that was created, the third argument is a list of instrument addresses that
the procedure actually found, and the last argument is the maximum number of devices
that the procedure can find (that is, it must stop if it reaches the limit). The end of the list
of addresses must be marked with the NOADDR constant, which is defined in the header
file that you included at the beginning of the program.
for (loop = 0; loop <=30; loop++){
instruments[loop] = loop;
}
instruments[31] = NOADDR;
printf("Finding all Listeners on the bus...\n");
Findlstn(0, instruments, result, 30);
if (ibsta & ERR) {
gpiberr("FindLstn error");
}
Step 3. Identify the Instrument
Send an identification query to each device for identification. For this example, assume
that all of the instruments are IEEE 488.2-compatible and can accept the identification
query, *IDN? . In addition, assume that FindLstn found the GPIB interface board at
primary address 0 (default) and, therefore, you can skip the first entry in the result
array.