Developing Your Application
Chapter 3
NI-488.2M UM for Windows NT
3-16
© National Instruments Corp.
After you have detected SRQ, use the
ReadStatusByte
routine to poll the meter and
determine its status. The first argument is the GPIB board number, the second argument
is the GPIB address of the instrument, and the last argument is a variable that
ReadStatusByte
uses to store the status byte of the instrument.
ReadStatusByte(0, fluke, &statusByte);
if (ibsta & ERR) {
gpiberr("ReadStatusByte error");
}
After you have obtained the status byte, you must check to see if the meter has a message
to send. You can do this by checking the message available (MAV) bit, bit 4, in the
status byte.
if (!(statusByte & MAVbit) {
gpiberr("Improper Status Byte");
printf("Status Byte = 0x%x\n", statusByte);
}
Step 8. Read the Measurement
Use the
Receive
function to read the measurement over the GPIB. The first argument
is the GPIB interface board number, and the second argument is the GPIB address of the
multimeter. The third argument is a string into which the
Receive
function places the
data bytes from the multimeter. The fourth argument represents the number of bytes to
be received. The last argument indicates that the
Receive
message terminates upon
receiving a byte accompanied with the END message.
Receive(0, fluke, buffer, 10L, STOPend);
if (ibsta & ERR) {
gpiberr("Receive error");
}
buffer[ibcntl] = '\0';
printf (Reading : %s\n", buffer);
sum += AsciiToFloat(buffer);
} /* end of loop started in Step 5 */
Step 9. Process the Data
Repeat Steps 5 through 8 in a loop until 10 measurements have been read. Then print the
average of the readings as shown:
printf
("The
average
of
the
10
readings
is
:
%f\n",
sum/10);