USING THE COMBISCOPE INSTRUMENTS 3 - 75
3.15.3.2 Program example using a service request (SRQ)
PROGRAM EXAMPLE:
In this example the "Service Request" mechanism is used to detect whether or
not a "CONFigure:AC" + "INITiate" operation is completed. If completed, an SRQ
is generated to continue with fetching and printing the AC-RMS value.
SRQ.detected = 0
ON PEN GOSUB ServReq ’
Defines SRQ-routine
PEN ON ’
Enables SRQ-routine
CALL IBTMO(0, 13) ’
Timeout at 10 seconds
CALL Send(0, 8, "
*
RST", 1) ’
Resets the instrument
CALL Send(0, 8, "
*
ESE 1", 1) ’
Sets OPC-bit in ESR
’"
OPeration Completed" is reported in bit 5 (ESB) of STB after sending
*
OPC
.
’
CALL Send(0, 8, "
*
SRE 32", 1) ’
Sets ESB-bit in SRE-register
’
SRQ generation after "OPeration Completed" is enabled
.
’
CALL Send(0, 8, "CONFigure:AC", 1) ’
Automatic configuration
CALL Send(0, 8, "INITiate", 1) ’
Single initiation
CALL Send(0, 8, "
*
OPC", 1)
’
This command forces the instrument to set the OPC bit in the STB
’
when all pending operations have been finished
.
’
WHILE SRQ.detected = 0
’
Do something else while waiting for SRQ; continue when SRQ.detected = 1
.
WEND
CALL Send(0, 8, "FETCh:AC?", 1) ’
Fetches AC-RMS value
result$ = SPACE$(30)
CALL Receive(0, 8, result$, 256) ’
Reads AC-RMS value
PRINT "AC-RMS value = "; result$ ’
Prints AC-RMS value
END
’
ServReq:
PRINT "Service request generated because of Operation Completed."
CALL ReadStatusByte(0, 8, sbyte%)
’
Serial polls for the status byte to reset the SRQ-mechanism
.
’
PRINT "STB byte ="; sbyte%
CALL Send(0, 8, "
*
ESR?", 1)
’
Queries for the contents of the Event Status Register to clear the OPC-bit
.
’
resp$ = " "
CALL Receive(0, 8, resp$, 256)
PRINT "ESR byte = "; resp$
SRQ.detected = 1
RETURN