Specifications
11 6 Chapter 5
Measurement Start and Detection of Measurement End
Example Programs for Detecting Measurement End
Example program using macro (E4991A VBA)
You are not able to use an SRQ in the macro program (E4991A VBA), which uses the
SingleMeasure method instead of an SRQ. Example 5-2 shows an example program
for detecting measurement end by using the SingleMeasure method. After setting the
number of sweep averaging to 4, start a sweep by executing SingleMeasure method.
SingleMeasure method waits until sweep has been completed. Then, when the sweep
is completed, a message of completion is displayed, and the program ends. This program is
saved under the filename sweep.bas on the sample programs disk. Below is an explanation
of the details of the program.
Lines 50 - 60 Substitutes variables for the trace number and the number of sweep
averaging.
Lines 100 - 130 Turns on Trace 1 and activates the sweep averaging function.
Lines 150 - 170 Sets the trigger source for the internal trigger and turns off the
continuous activation of the trigger system. Then, resets the trigger
system and sets the trigger sequence to the idle state.
Lines 190 - 200 Resets sweep averaging when the sweep averaging function is set to
on.
Line 220 Starts the sweep and substitutes a variable of “bool” for sweep
completion.
NOTE When the sweep averaging function is set on, the measurement end is detected upon
completion of the specified number of averaging.
Line 230 Displays a message of “Sweep Aborted” when sweep is aborted
(bool=0) during the measurement.
Line 250 Stops the execution of the macro.
Example 5-2 Detection of measurement end using the SingleMeasure method
10 Sub Sweep()
20 Dim trc As Integer
30 Dim swp_count As Integer, swp_bool As Integer, bool As
Integer
40
50 trc = 1
60 swp_count = 4
70
80 ' E4991A settings
90
100 SCPI.Output "*CLS"
110 SCPI.Output "DISP:TRAC" & CStr(trc) & " ON"
120 SCPI.Output "CALC:AVER:COUN " & CStr(swp_count)
130 SCPI.Output "CALC:AVER ON"
140
150 SCPI.Output "TRIG:SOUR INT"
160 SCPI.Output "INIT:CONT OFF"
170 SCPI.Output "ABOR"
180
190 swp_bool = SCPI.Query("CALC:AVER?")
200 If swp_bool = 1 Then SCPI.Output "CALC:AVER:CLE"
210