5700A/5720A Series II
Operators Manual
5-66
5-53. Using *OPC?, *OPC, and *WAI
The *OPC?, *OPC, and *WAI commands let you maintain control of the order of
execution of commands that could otherwise be passed up by subsequent commands.
If you had sent an OUT command, you can check if the output has settled by sending the
query *OPC?. As soon as the OUT command has completed (output settled), a 1 appears
in the output buffer. You should always follow a *OPC? command with a read command
(for example, in BASIC, “INPUT @4, A”). The read command causes program execution
to pause until the addressed instrument responds. The following sample program shows
how you can use *OPC?
1Ø PRINT @4, “OUT 1ØØV,1KHZ;OPER; *OPC?” ! 57ØØA ADDRESS IS 4
2Ø INPUT @4, A ! READ THE “1” FROM THE 57ØØA
3Ø !PROGRAM HALTS HERE UNTIL A “1” IS PUT INTO THE OUTPUT BUFFER
4Ø PRINT “OUTPUT SETTLED”
The *OPC command is similar in operation to the *OPC? query, except that it sets bit 0
(OPC for “Operation Complete”) in the Event Status Register to 1 rather than sending a
“1” to the output buffer. One simple use for *OPC is to include it in a program in order
for it to generate an SRQ (Service Request). Then an SRQ handler written into the
program can detect the operation complete condition and respond appropriately. You can
use *OPC similarly to *OPC?, except your program must read the ESR to detect the
completion of all operations. The following sample program shows how you can use
*OPC.
1Ø REMOTE
2Ø PRINT @4, “OUT 1ØØV,1ØHZ;*OPC” ! 57ØØA ADDRESS IS 4
3Ø PRINT @4, “*ESR?” ! PUT THE ESR BYTE IN BUFFER
4Ø INPUT @4, A% ! READ THE ESR BYTE
5Ø IF (A% AND 1%) = Ø% GOTO 3Ø ! TRY AGAIN IF NO OPC
6Ø PRINT “OUTPUT SETTLED”
7Ø END
The *WAI command causes the calibrator to wait until any prior commands have been
completed before continuing on to the next command, and takes no other action. Using
*WAI is a convenient way to halt operation until the command or commands preceding it
have completed. The following sample program shows how you can use *WAI.
1Ø REMOTE
2Ø PRINT @4, “OUT 1ØØV,1ØHZ;*WAI” ! 57ØØA ADDRESS IS 4
3Ø PRINT @4, “OUT?” ! READ THE OUTPUT VALUE
4Ø INPUT @4, A$,B$,C$ ! A$ CONTAINS THE OUTPUT VALUE
5Ø PRINT “OUTPUT SETTLED”
6Ø PRINT “OUTPUT IS: “;A$;B$;” at “;C$
7Ø END