User manual

Table Of Contents
Part 5: IEEE 488.2 Programming Reference
Taking Instrument Polls
You can regularly monitor state transitions within the oscilloscope by polling selected internal status
registers.
Four basic polling methods are used to detect the occurrence of a given event: continuous, serial, parallel,
and *IST. The simplest of these is continuous polling while the others are appropriate only when interrupt-
service routines (servicing the SRQ line) are supported, or multiple devices on GPIB require constant
monitoring.
The following examples accomplish the same goal (determining whether a new acquisition has taken
place) in order to emphasize the differences between the polling methods. The examples use board-level
GPIB function calls. It is assumed that the controller (board) and the oscilloscope (device) are located at
addresses 0 and 4, respectively.
The listener and talker addresses for the controller and the oscilloscope are:
Logic Device Listener Address Talker Address
External Controller 32 (ASCII<space>) 64 (ASCII @)
Oscilloscope 32 + 4 = 36 (ASCII $) 64 + 4 = 68 (ASCII D)
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, or value 1) is non-zero, indicating
a new waveform has been acquired. Reading INR clears this at the same time, so there is no need for an
additional clearing action after a non-zero value is detected. The CHDR OFF command instructs the
oscilloscope to omit any command headers when responding to a query, simplifying the decoding of the
response. The oscilloscope then sends "1" instead of "INR 1" as follows:
Example: Continuous Polling
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%
5-11