Chapter 3 Developing Your Application
© National Instruments Corp. 3-9 NI-488.2 User Manual for Windows
Step 3. Configure the Device
After you open and clear the device, it is ready to receive commands. To configure the
instrument, you send device-specific commands using the ibwrt function. Refer to the
instrument user manual for the command bytes that work with your instrument.
ibwrt(ud, "*RST; VAC; AUTO; TRIGGER 2; *SRE 16", 35L);
if (ibsta & ERR) {
gpiberr("ibwrt error");
}
The programming instruction in this example resets the multimeter (*RST). The meter is
instructed to measure the volts alternating current (VAC) using auto-ranging (AUTO ), to
wait for a trigger from the GPIB interface board before starting a measurement
(TRIGGER 2), and to assert the SRQ line when the measurement completes and the
multimeter is ready to send the result (*SRE 16).
Step 4. Trigger the Device
If you configure the device to wait for a trigger, you must send a trigger command to the
device before reading the measurement value. Then instruct the device to send the next
triggered reading to its GPIB output buffer.
ibtrg(ud);
if (ibsta & (ERR 1 TIMO)) {
gpiberr("ibtrg error");
}
ibwrt(ud,"VAL1?", 5L);
if (ibsta & ERR) {
gpiberr("ibwrt error");
}
Step 5. Wait for the Measurement
After you trigger the device, the RQS bit is set when the device is ready to send the
measurement. You can detect RQS by using the ibwait function. The second
parameter indicates what you are waiting for. Notice that the ibwait function also
returns when the I/O timeout value is exceeded.
printf("Waiting for RQS...\n");
ibwait (ud, TIMO| RQS);
if (ibsta & (ERR | TIMO)) {
gpiberr("ibwait error");
}
When SRQ has been detected, serial poll the instrument to determine if the measured data
is valid or if a fault condition exists. For IEEE 488.2 instruments, you can find out by
checking the message available (MAV) bit, bit 4 in the status byte that you receive from
the instrument.