Specifications

Chapter 6 131
Read and Write Measurement Data
Example Programs for Reading Internal Data Arrays
6. Read and Write
Measurement Data
Example program using macro (E4991A VBA)
The program shown in Example 6-2 is saved under the filename asc_read.bas on the
sample programs disk. Below is an explanation of the program’s details.
Lines 60 - 70 Substitutes variables for the trace number and number of measurement
points.
Line 110 Resets the E4991A.
Lines 130 - 140 Turns on Trace 1 and sets the measurement point.
Lines 160 - 180 Sets the trigger source to the internal trigger and turns off the
continuous activation of the trigger system. Then, it resets the trigger
system and sets the trigger sequence to the idle state.
Lines 200 - 210 Resets the sweep averaging when sweep averaging function is set to
on.
Line 230 Starts the sweeps and substitutes a variable of “bool” for sweep
completion.
Lines 250 - 260 Displays a message of “Sweep Aborted” when sweep is aborted
(bool=0) during the measurement.
Line 270 Describes the program routine below this line when sweep is
completed without problem (bool=1).
Line 280 Executes auto-scale adjustment of the trace.
Line 300 Sets the data transfer format to ASCII transfer format.
Lines 320 - 350 Reads the data trace array and stimulus array.
Lines 340 - 570 Stops execution of the macro.
Example 6-2 Read of the data trace array
10 Sub Main()
20 Dim meas_data As Variant, swp_prm As Variant
30 Dim trc1 As Integer, nop As Integer
40 Dim swp_bool As Integer, bool As Integer
50
60 trc1 = 1
70 nop = 201
80
90 ' E4991A settings
100
110 SCPI.Output "SYST:PRES"
120
130 SCPI.Output "DISP:TRAC" & CStr(trc1) & " ON"
140 SCPI.Output "SWE:POIN " & CStr(nop)
150
160 SCPI.Output "TRIG:SOUR INT"
170 SCPI.Output "INIT:CONT OFF"
180 SCPI.Output "ABOR"
190
200 swp_bool = SCPI.Query("CALC:AVER?")
210 If swp_bool = 1 Then SCPI.Output "CALC:AVER:CLE"
220
230 bool = SingleMeasure
240