Chapter 3
Developing Your Application
© National Instruments Corp.
3-15
NI-488.2M UM for Windows NT
Step 5. Configure the Instrument
After initialization, the instrument is ready to receive instructions. To configure the
multimeter, use the
Send
routine to send device-specific commands. The first argument
is the number of the access board. The second argument is the GPIB address of the
multimeter. The third argument is a string of bytes to send to the multimeter.
The bytes in this example instruct the meter to measure volts alternating current (
VAC
)
using auto-ranging (
AUTO
), to wait for a trigger from the Controller before starting a
measurement (
TRIGGER 2
), and to assert SRQ when the measurement has been
completed and the meter is ready to send the result (
*SRE 16
). The fourth argument
represents the number of bytes to be sent. The last argument,
NLend
, is a constant
defined in the header file which tells
Send
to append a linefeed character, with EOI
asserted, to the end of the message sent to the multimeter.
Send (0,
fluke,
"VAC; AUTO; TRIGGER 2; *SRE 16",
29L,
NLend);
if (ibsta & ERR) {
gpiberr("Send setup error");
}
Step 6. Trigger the Instrument
In the previous step, the multimeter was instructed to wait for a trigger before conducting
a measurement. Now send a trigger command to the multimeter. You could use the
Trigger
routine to accomplish this, but because the Fluke 45 is IEEE 488.2-
compatible, you can just send it the trigger command,
*TRG.
The
VAL1?
command
instructs the meter to send the next triggered reading to its output buffer.
Send(0, fluke, "*TRG; VAL1?", 11L, NLend);
if (ibsta & ERR) {
gpiberr("Send trigger error");
}
Step 7. Wait for the Measurement
After the meter is triggered, it takes a measurement and displays it on its front panel and
then asserts SRQ. You can detect the assertion of SRQ using either the
TestSRQ
or
WaitSRQ
routine. If you have a process that you want to execute while you are waiting
for the measurement, use
TestSRQ
. For this example, you can use the
WaitSRQ
routine. The first argument in
WaitSRQ
is the GPIB board number. The second
argument is a flag returned by
WaitSRQ
that indicates whether or not SRQ is asserted.
WaitSRQ(0, &SRQasserted);
if (!SRQasserted) {
gpiberr("WaitSRQ error");
}