2 - 8 GETTING STARTED WITH SCPI PROGRAMMING
2.4.2 How to acquire repetitive traces
In the program example, 5 trace acquisitions of 512 16-bit samples are done via
a probe connected to channel 2. The trace sample bytes are read from the GPIB
as string characters and written to the file TRACE5.DAT on the hard disk.
PREPARATIONS:
•
Connect a probe from the Probe Adjust signal to channel 2.
PROGRAM EXAMPLE:
’
*****
’Acquire 5 sequential traces and store in file TRACE5.DAT:
’
*****
DIM tracebuf AS STRING
*
1050
CALL Send(0, 8, "
*
RST", 1) ’
Resets the instrument
’
’After
*
RST a trace acquisition is defined at 512 samples of 16 bits
’(2 bytes).
’
CALL Send(0, 8, "CONFigure:AC (@2)", 1) ’
Configures channel 2
CALL Send(0, 8, "SENSe:FUNCtion ’XTIMe:VOLTage2’", 1)’
Switches channel 2 on
OPEN "O",#1,"TRACE5.DAT" ’
Opens file TRACE5.DAT
FOR i=1 TO 5
CALL Send(0, 8, "INITiate", 1) ’
Single initiation
CALL Send(0, 8, "
*
WAI;TRACe? CH2", 1) ’
Queries for channel 2 trace
’
’
Notice the
*
WAI; before TRACe?. The
*
WAI command takes care that the TRACe? CH2 command is
’
executed when the INITiate command is finished.
’
CALL Receive(0, 8, tracebuf$, 256) ’
Reads channel 2 trace
PRINT #1, "Trace buffer:"; i ’
Writes trace header to file
PRINT #1, LEFT$(tracebuf$, IBCNT%) ’
Writes trace buffer to file
NEXT i
CLOSE ’
Closes file TRACE5.DAT
Note: Refer to section 3.4.3 "Conversion of trace data" about how to convert
this string data.