Controlling VBA Externally

Other topics about Controlling E5052B

Overview

This section describes how to control the E5052B's VBA externally.

Executing VBA Using External Controller

You can execute VBA from an external PC by running either macros or the user menu.

Running Macro

To start VBA from an external PC, use the following command:

   SCPI.MMEMory.LOAD.PROGram

   SCPI.PROGram.COM.EVENt

   SCPI.PROGram.SELected.STATe

Running User Menu

To execute the user menu from an external PC, use the following command:This command executes the first of the menu.

To execute the user menu, you must execute the user menu function in advance. For more information, refer to Running User Menu and   SCPI.PROGram.SKEY.Item(1).IMMediate

Receiving Termination of VBA Using External Controller

To allow the external controller to receive the termination of VBA from the E5052B, you may either confirm the operational status of VBA or use the user-defined register.

Confirming VBA’s Operational Status

To confirm the operational status of VBA, use the following command:

   SCPI.PROGram.SELected.STATe

Using User-defined Register

To use the user-defined register, use the following command:For more information, refer to Using User-defined Register.

   SCPI.STATus.OPERation.BIT12.CLEar

   SCPI.STATus.OPERation.BIT12.CONDition

   SCPI.STATus.OPERation.BIT12.ENABle

   SCPI.STATus.OPERation.BIT12.EVENt

   SCPI.STATus.OPERation.BIT12.NTRansition

   SCPI.STATus.OPERation.BIT12.PTRansition

   SCPI.STATus.OPERation.BIT12.SET

Using User-defined Register

The E5052B does not control the individual status flag of the user-defined register. In order to start the E5052B VBA using the external controller to obtain the end bit, the user must make the user-defined register to be controlled within the program.

The user can assign any register number to the user-defined register which he/she wants to use. Available register numbers are 1 to 15 (0 to 14 bit).

If you use the user-defined register, you must specify the same register number for both the external controller side and the E5052B’s program side.

 Reference of User-defined Register

The following is a sample program which:

  1. Clears the first condition register to be used (bit 0).

  2. These lines configure the instrument so that the operation use-defined status event register's bit 0 is set to 1, when the operation use-defined condition register's bit 0 is changed from 0 to 1 (i.e. positive transition).

  3. Executes the user menu.

  4. Repeats until the termination of VBA is detected.

A Sample Program to Control User-defined Register (On the Controller Side

Lines 30 to 90

An event occurs when the softkey is pressed from the user menu.

 Lines 50 to 60

E5052B will be reset to the initial setting, when the first softkey is pressed.

 Lines 70 to 80

The message box will appear, when the second softkey is pressed.

Lines 100 to 110

An event will occur when the triggered sweep ends.

Line 110

A message box will appear when the sweep ends.

Line 130

Sets a flag to the first of the user-defined register (bit 0).

Line 140

This procedure terminates the program.

A Sample Program to Control User-defined Register (On the E5052B Side)

10|Private Sub app_OnEvent(ByVal ReasonStr As String, ByVal OptionStr As String)

20| Select Case ReasonStr

30| Case "UserLabel"

40| Select Case OptionStr

50| Case 1

60| SCPI.SYSTem.PRESet

70| Case 2

80| MsgBox "Program ended"

90| End Select

100| Case "SweepEnd"

110| MsgBox "Sweep ended"

120| End Select

130| SCPI.STATus.OPERation.BIT12.SET = 0

140| End

150|End Sub

 

Using User-defined Variables

The E5052B has an area for which the users may set any value. The areas are divided for each data type.

An area can be used up to 10 (1 to 10) for each command.

The values set by a command cannot be removed by executing preset.

   SCPI.PROGram.VARiable.ARRay(1-10).DATA

   SCPI.PROGram.VARiable.ARRay(1-10).POINts

   SCPI.PROGram.VARiable.DOUBle(1-10)

   SCPI.PROGram.VARiable.INTeger(1-10)

   SCPI.PROGram.VARiable.STRing(1-10)

The following is a sample program for configuration, which demonstrates how to use the floating-point-formatted user-defined array.

Line 30 to 50

Define the variables.

Line 70

Assign values to the variables.

Line 90

Call the function to trigger the instrument.

Line 110

Configure marker X for frequency measurement (trace 1).

Line 120

Read out marker Y for frequency measurement (trace 1).

Line 130

Configure marker X for power measurement (trace 2).

Line 140

Read out marker Y for power measurement (trace 2).

Line 160

Set the value of marker Y for frequency measurement at the beginning of the user-defined array.

Line 170

Set the value of marker Y for power measurement to that of the 2nd dimension of the user-defined array.

Example of using floating point formatted user-defined array

10| Sub Main()

20|

30| Dim Vcc1 As Double

40| Dim FP_Freq As Double

50| Dim FP_Power As Double

60|

70| Vcc1 = 0.5

80|

90| Call FP_SingleSweep

100|

110| SCPI.CALCulate.FP.Trace(1).MARKer(1).X = Vcc1

120| FP_Freq = SCPI.CALCulate.FP.Trace(1).MARKer(1).Y

130| SCPI.CALCulate.FP.Trace(2).MARKer(1).X = Vcc1

140| FP_Power = SCPI.CALCulate.FP.Trace(2).MARKer(1).Y

150|

160| SCPI.PROGram.VARiable.DOUBle(1) = FP_Freq

170| SCPI.PROGram.VARiable.DOUBle(2) = FP_Power

180| End Sub

 

The following sample program demonstrates how to use the array-formatted user-defined array.

Line 30 to 50

Define the variables.

Line 70

Call the function to trigger the instrument.

Line 90

Read out the number of points and set it to the variable.

Line 100 to 110

Redefine the array (variable).

Line 130

Read out the trace data and set it to the variable.

Line 140

Read out the X-axis data and set them to the variable.

Line 160

Specify the number of data points at the beginning of the user-defined array.

Line 170

Specify the trace data at the beginning of the user-defined array.

Line 190

Specify the number of data points to that of the 2nd dimension of the user-defined array.

Line 200

Specify the X-axis data to that of the 2nd dimension of the user-defined array.

Example of using array formatted user-defined array

10| Sub Main()

20|

30| Dim PN_Nop As Long

40| Dim PN_Trace() As Double

50| Dim PN_Freq() As Double

60|

70| Call PN_SingleSweep

80|

90| PN_Nop = SCPI.SENSe.PN.SWEep.POINts

100| ReDim PN_Trace(PN_Nop - 1)

110| ReDim PN_Freq(PN_Nop - 1)

120|

130| PN_Trace = SCPI.CALCulate.PN.Trace.DATA.FDATa

140| PN_Freq = SCPI.CALCulate.PN.DATA.XDATa

150|

160| SCPI.PROGram.VARiable. Array (1).POINts = PN_Nop

170| SCPI.PROGram.VARiable.Array(1).DATA = PN_Trace

180|

190| SCPI.PROGram.VARiable.Array(2).POINts = PN_Nop

200| SCPI.PROGram.VARiable.Array(2).DATA = PN_Freq

210|

220| End Sub