GETTING STARTED WITH SCPI PROGRAMMING 2 - 7
2.4.1 How to acquire a single shot trace
In the program example, a single shot trace acquisition of 8192 8-bit samples is
done with a probe connected to input channel 1. The trace sample bytes are read
from the GPIB as string characters. The number of response bytes and the
number of samples are printed.
The TRIGger:SOURce command is used to specify input channel 1 as a trigger
source. The TRIGger:LEVel command is used to reset the trigger level to e.g., 0.1
volts.
PREPARATIONS:
•
Connect a probe to channel 1. After start up of the program you will be asked
to trigger the acquisition with the open end of the probe, i.e., touch the probe
or strike the probe on the table.
PROGRAM EXAMPLE:
’
*****
’Acquire a single shot trace:
’
*****
DIM tracebuf AS STRING
*
16500
CALL Send(0, 8, "FORMat INTeger,8", 1) ’
Formats 8-bits sample
CALL Send(0, 8, "TRACe:POINts CH1,8192", 1) ’
Formats 8192 sample points
CALL Send(0, 8, "TRIGger:SOURce INTernal1", 1) ’
Trigger-source = channel 1
CALL Send(0, 8, "TRIGger:LEVel 0.1", 1) ’
Trigger-level = 0.1
CALL Send(0, 8, "INITiate", 1) ’
Single shot initiation
PRINT "Trigger the CombiScope instrument by touching the probe tip."
PRINT ">>> Press any key when finished."
WHILE INKEY$ = "": WEND
CALL Send(0, 8, "
*
WAI", 1) ’
Waits for previous commands
to finish
CALL Send(0, 8, "TRACe? CH1", 1) ’
Queries for channel 1 trace
CALL Receive(0, 8, tracebuf$, 256) ’
Reads channel 1 trace
’
’
The contents of the tracebuf$ string is as follows:
’
# 4 8194 <8> <byte 1> ... <byte 8192> <sum> <10>
’
nr.of.digits = VAL(MID$(tracebuf$, 2, 1))
nr.of.bytes = VAL(MID$(tracebuf$, 3, nr.of.digits)) - 2
sample.length = ASC(MID$(tracebuf$, 3 + nr.of.digits, 1)) / 8
nr.of.samples = nr.of.bytes / sample.length
PRINT "Number of bytes received ="; IBCNT% ’
IBCNT% = number of bytes
PRINT "Number of trace samples ="; nr.of.samples
Note: Refer to section 3.4.3 "Conversion of trace data" about how to convert
this string data.