Model 2701 User’s Manual Status Structure 11-21
While measuring and storing readings, the status byte is continuously read to detect when
the BHF bit sets. This example also shows how to use *OPC (operation complete) to
determine when the measure-measure process is finished.
*RST ' Put 2701 in “one-shot” mode.
*CLS ' Clears measurement event register.
STAT:PRES ' Clears measurement event enable register.
STAT:MEAS:ENAB 256 ' Enables BHF bit B8 of the measurement event register.
*ESE 1 ' Enables OPC bit B0 of the standard event register.
TRAC:POIN 500 ' Sets buffer size to 500 readings.
TRAC:FEED SENS ' Sets to store raw readings.
TRIG:COUN 500 ' Sets 2701 to perform 500 measurements.
TRAC:FEED:CONT NEXT ' Enables buffer.
INIT ' Starts measurement and storage process.
*OPC ' Sets OPC bit B0 of standard event register after the
' measure-store process is finished.
While readings are being triggered and stored in the buffer, the following command
(*STB?) can be put into a program loop to continuously read the status byte.
*STB? ' Read status register.
By masking the status byte with binary 00000001 (decimal 1), only B0 will be read by
*STB?. The AND’ed result of the mask and the *STB? response will be either “0” (BHF
clear) or “1” (BHF set).
In the above command sequence, *ESE 1 enables the OPC bit. After *OPC is sent, the
OPC bit will set when the measure-store process is finished. After the BHF bit sets, you
can then continuously read the status byte to determine when the OPC bit sets. When OPC
sets, bit B5 (ESB) in the status byte sets. Since this time you only want to read bit B5, a
different mask will be needed:
B7 B6 B5 B4 B3 B2 B1 B0
0 0 1 0 0 0 0 0 Mask to read B5 (decimal 32)
When a returned value for *STB? is AND’ed with the above mask, it will read “0” (OPC
clear) or “32” (OPC set).
NOTE More information on *OPC is provided in Section 12.