Manual

C
HAPTER
T
WO
:
Control by GPIB
WM-RCM-E Rev D ISSUED: February 2005
23
Take Instrument Polls
You can regularly monitor state transitions within the oscilloscope by polling selected internal status registers.
There are four basic polling methods you can use to detect the occurrence of a given event: continuous, serial,
parallel, and *IST. By far the simplest of these is continuous polling. The others are appropriate only when
interrupt-service routines (servicing the SRQ line) are supported, or multiple devices on GPIB require constant
monitoring. To emphasize the differences between the methods, described below, the same example
(determining whether a new acquisition has taken place) is used in each case.
DO CONTINUOUS POLLING
A status register is continuously monitored until a transition is observed. This is the most straightforward
method for detecting state changes, but may not be practical in certain situations, especially with multiple
device configurations.
In the following example, the event “new signal acquired” is observed by continuously polling the INternal
state change Register (INR) until the corresponding bit (in this case bit 0, i.e., value 1) is non-zero, indicating
that a new waveform has been acquired. Reading INR clears this at the same time, so that there is no need for
an additional clearing action after a non-zero value has been detected. The command CHDR OFF instructs the
oscilloscope to omit any command headers when responding to a query, simplifying the decoding of the
response. The oscilloscope will then send “1” instead of “INR 1”:
CMD$ = “CHDR OFF”
CALL IBWRT (SCOPE%, CMD$)
MASK% = 1 ‘ New Signal Bit has value 1
DO
CMD$ = “INR?”
CALL IBWRT (SCOPE%, CMD$)
CALL IBRD (SCOPE%, RD$)
NEWSIG% = VAL (RD$) AND MASK%
LOOP UNTIL NEWSIG% = MASK%