
Chapter 5 335
Programming
Monitoring System Operation
In this example, Line 20 indicates that if an interrupt appears (ON
INTR 7), the computer is to go to the subroutine Srq (GOSUB Srq). The
7 specifies the interface select code; in this case, it refers to the General
Purpose Interface Bus (GPIB). Line 30 enables the computer to accept
an interrupt. Here, the 7 again specifies the GPIB select code. The
semicolon is part of the BASIC statement ENABLE INTR. The 2
indicates that the interrupt is specifically a service request interrupt,
which is asserted from the SRQ line of the GPIB. From Line 10, you
know the interrupt will be a service request triggered from a "command
complete" condition.
Now that the spectrum analyzer and computer can assert and accept
service-request interrupts, choose an event that will trigger the service
request and create a subroutine to handle the interrupt. In the example
below, the take sweep command (TS) is used to trigger a command
complete signal. (Because 10 video-averaging sweeps are desired, this
signal does not occur until after the selected number of averages is
complete.) This service request will cause the computer to go to the
subroutine Srq. The subroutine identifies the type of service request
and prints it on the computer screen. See Example 1.
E
XAMPLE 1
10 OUTPUT 718;"IP;SNGLS;CF 300MHZ;SP 20MHZ;TS;"
20 OUTPUT 718;"VAVG 10;RQS 16;"
30 ON INTR 7 GOTO Srq
40 ENABLE INTR 7;2
50 OUTPUT 718;"TS;"
60 Idle: GOTO Idle
70 Srq: Sbyte=SPOLL(718)
80 PRINT Sbyte
90 PRINT "VIDEO AVERAGING IS COMPLETE"
100 OUTPUT 718;"RQS 0;"
110 END
Line 10 sets the desired instrument state. Note that the instrument is
set to single-sweep mode. This allows the video averages to happen only
when the take-sweep command is sent.
Line 20 selects the number of video averages desired. It is not until
after the VAVG (video average) command is sent that the RQS
command is sent. This ensures that no previous commands can
accidentally generate an SRQ.
Line 30 directs that the computer should execute the Srq routine when
an interrupt occurs.
Line 40 enables the computer to accept the interrupt.
Comments to this Manuals