National Instruments NI-488.2 Time Clock User Manual


 
Developing Your Application Chapter 3
NI-488.2 User Manual for Windows 3-10 © National Instruments Corp.
ibrsp (ud, &StatusByte);
if (ibsta & ERR) {
gpiberr("ibrsp error");
}
if ( !(StatusByte & MAVbit)) {
gpiberr("Improper Status Byte");
printf(" Status Byte = 0x%x\n", StatusByte);
}
Step 6. Read the Measurement
If the data is valid, read the measurement from the instrument. (AsciiToFloat is a
function that takes a null-terminated string as input and outputs the floating point number
it represents.)
ibrd (ud, rdbuf, 10L);
if (ibsta & ERR) {
gpiberr("ibrd error");
}
rdbuf[ibcntl] = '\0';
printf("Read: %s\n", rdbuf);
/* Output ==> Read: +10.98E-3 */
sum += AsciiToFloat(rdbuf);
Step 7. Process the Data
Repeat steps 4 through 6 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.0);
Step 8. Place the Device Offline
As a final step, take the device offline using the ibonl function.
ibonl (ud, 0);