Trace Data Transfers
Querying the Measurement Trace Using BASIC
Querying the Measurement Trace Using
BASIC
After making a measurement, you can read the resultant measurement trace out of the analyzer using the SCPI query:
"TRACE:DATA?
CH1FDATA"
The BASIC program segment below shows how to read the trace from the analyzer into an array in your program.
10
20
30
40
50
60
70
REAL Trace(1:201)
ASSIGN @Hp8711 TO 716
! Take sweep here
OUTPUT @Hp8711;"FORM:DATA ASCII,5"
OUTPUT @Hp8711;"TRACE:DATA? CH1FDATA"
ENTER @Hp8711;Trace(*)
DISP Trace(1),Trace(2),Trace(3),". . . ."
In this program, the TRACE:DATA?
query returns all of the measurement points as a single block. The analyzer computes the value for each point using the measurement format selected by the [FORMAT] menu ( CALC:FORM SCPI command), and returns a block of data called the formatted data array. The values of each point correspond to the values displayed on the screen, or those shown in the marker readouts.
The frequency stimulus value (X-axis) of each point is not returned by the TRACE:DATA?
query; only the measurement response (Y-axis) values are returned.
When transferring the block of trace data, you may select either binary or ASCII data encoding. This is explained in
Chapter 4, “Data Types and
Encoding,” in the section titled
“Data Encoding for Large Data
Transfers” on page 4-6
. Notice that the terms "encoding format" and
"measurement format" are not the same. The encoding format determines how the numbers are represented as bytes, while the measurement format corresponds to the meaning of the value of the numbers.
The easiest way to transfer a measurement data trace is to use ASCII data encoding.
Programmer’s Guide 6-3
Trace Data Transfers
Querying the Measurement Trace Using BASIC
In the previous BASIC program segment, the array Trace(1:201) contains 201 real (floating point) numbers. The SCPI command
"FORM:DATA ASCII,5" specifies ASCII data encoding, with 5 significant digits. The command "TRACE:DATA? CH1FDATA" instructs the analyzer to send the measurement trace. The ENTER statement reads the measurement data sent by the analyzer into the Trace(1:201) array.
It is important to make sure that the Trace array declared in your program is the same size as the measurement trace on the analyzer, or an error will occur. The ENTER statement attempts to read data from the analyzer until it completely fills the Trace array, at which point it expects to receive an end-of-data terminator from the analyzer. To be safe, your program should use the "SENS:SWE:POIN" SCPI command to set the number of measurement data points to the desired value.
Refer to the example program ASCDATA in the Example Programs
Guide for a complete example.
10
20
30
40
50
60
70
2)
Smith Chart and Polar Formats
Each measurement point is represented by a single floating point number. This is the case for all of the analyzer's measurement formats except Smith Chart and Polar. When Smith Chart or Polar format is selected, each point is represented by two numbers, the first one being the real portion and the second being the imaginary portion of the complex measurement value.
Below is a modified example program that will work when using Smith
Chart or Polar formats.
REAL Trace(1:201,1:2)
ASSIGN @Hp8711 TO 716
! Take sweep here
OUTPUT @Hp8711;"FORM:DATA ASCII,5"
OUTPUT @Hp8711;"TRACE:DATA? CH1FDATA"
ENTER @Hp8711;Trace(*)
DISP Trace(1,1),Trace(1,2),". . . .",Trace(201,1),Trace(201,
6-4 Programmer’s Guide