Operating instructions

R&S ESCI More Complex Programming Examples
1166.6004.12 7.37 E-1
Reading Trace Data
In the following example, the trace data recorded together at the default setting is read out and
displayed on the screen in the form of a list. Reading is performed consecutively in the binary format
and in the ASCII format, at span > 0 and also at span = 0.
In the binary format the message header is evaluated with the length information and used to calculate
the x axis values.
In the ASCII format only the list of level values is output.
The binary data is read out in 3 steps:
1. Reading the number of digits of the length information
2. Reading the length information
3. Reading trace data
This procedure is necessary with programming languages that support only structures with similar data
types (arrays) (such as Visual Basic) since the data types of header and data differ in binary data.
Note: The trace data arrays are dimensioned in such a way that they can accommodate the trace
data of the FSU (625 points).
REM ************************************************************************
Public Sub ReadTrace()
'--------- Define variables -----------------------------------------------
Dim traceData(1250) As Single 'Buffer for floating point
'binary data
Dim digits As Byte 'Number of digits of
'length information
Dim traceBytes As Integer 'Length of trace data in bytes
Dim traceValues As Integer 'Number of values in buffer
asciiResult$ = Space$(25000) 'Buffer for ASCII trace data
result$ = Space$(100) 'Buffer for simple results
startFreq$ = Space$(100) 'Buffer for start frequency
span$ = Space$(100) 'Buffer for span
'--------- R&S ESCI default setting ----------------------------------------
---
CALL SetupInstrument 'Default setting
CALL IBWRT(receiver%,"INIT:CONT OFF") 'Single sweep
CALL IBWRT(receiver%,"INIT;*WAI") 'Perform sweep with sync
'--------- Define span for read out --------------------------------------
Call ibwrt(receiver%,"FREQ:STARt?") 'Read out start frequency
Call ibrd(receiver%,startFreq$)
startFreq = Val(startFreq$)
Call ibwrt(receiver%,"FREQ:SPAN?") 'Read out span
Call ibrd(receiver%,span$)
span = Val(span$)