This Programming Manual contains information on remote control over pair of
PLANAR R54 Vector Reflectometer and its data communication by means of user
programs written with COM/DCOM technology.
COM technology is used when a user program runs together with an external
measurement instrument program on one PC. DCOM technology is used when a user
program runs on a PC connected with the measurement instrument by LAN.
Methods and techniques for writing of user programs are same for the both
technologies. The only difference between the technologies is that the DCOM
technology requires additional LAN setting performed by the LAN administrator.
Before reading this Manual, familiarize yourself with PLANAR R54 Operating Manual.
6
PLANAR R54x2 COM/DCOM Programming manual
1 COM Technology Overview
COM stands for Component Object Model. This programming technology was
developed by Microsoft for two purposes:
the model provides the specification for interaction of binary
modules created in different programming languages;
the model defines the interfacing between a client application and a
server application running either on the same PC or on two different
PCs. In the latter case, the technology has DCOM abbreviation –
Distributed COM.
2 Automation Server
The PlanarR54x2.exe application contains a built-in COM server that enables other
programs to access its functionality. The PlanarR54x2.exe application COM server was
developed in conformity with the COM automation specification. COM automation is a
technology allowing control over the COM server by the programs written in both
traditional compiling programming languages and interpreting programming languages,
such as VBScript. This enables the server applications to make their functionality
accessible to many more clients.
To register the COM-server of PlanarR54x2.exe application in the system registry, start
the PlanarR54x2.exe application with /regserver key in command line during
installation. You can also register the COM-server in the similar manner manually.
To delete the COM-server registration from the system registry, start the
PlanarR54x2.exe application with /unregserver key in command line.
3 Automation Controllers
Automationcontrollers are client programs, which use internal functionality of COM
servers. Automation controller programs are developed by users for writing their own
add-ons for the system.
User programs can be written in different languages:
programming languages with built-in COM support, such as Visual
Basic®, Delphi, Java;
universal programming languages, such as C, C++;
Microsoft Excel and Word office applications as they include built-in
programming language Visual Basic for Applications®;
program generators, such as National Instruments LabView®, or
HP–VEE.
7
PLANAR R54x2 COM/DCOM Programming manual
Examples represented in this Manual are written in Visual Basic (VB). Appendix 3
contains examples written in VB, and C++ languages.
Examples\COM\VBA folder contains source codes for examples written in Visual Basic
for Applications® (Microsoft Excel files).
Examples\COM\CPP folder contains source codes for the C++ language examples.
4 Local and Remote Server
PlanarR54x2.exe application can function either as a local server or as a remote server
of COM automation.
Localserver runs on the same PC with the automation controller and each of the
programs is executed as an individual application in a separate window. COM
technology is used in this case (Figure 1).
Remote server and the automation controller run on different PCs connected by LAN.
DCOM (Distributed COM) technology is used in this case (Figure 2). When using
DCOM it is necessary to configure the local network by means of DCOM Windows
tools.
COM technology is normally used to control pair of PLANAR R54.
The same automation controller is used for the both COM and DCOM technology.
Some changes to the user program may be required in operators, which establish
connection with the server. Moreover, DCOM technology requires additional settings of
the LAN performed by the LAN administrator.
8
PLANAR R54x2 COM/DCOM Programming manual
COM
USB
Planar
R54X2
.exe
DCOM
Planar
R54X2
.exe
LAN
USB
User
Program
Planar R54
Planar R54
Figure 1. COM technology
Planar R54
Planar R54
Figure 2. DCOM technology
User Program
9
PLANAR R54x2 COM/DCOM Programming manual
5 Structure of COM Objects
COM server contains several objects, which provide different functionality of the
server. The COM objects of the PlanarR54x2.exe application are organized in a
hierarchical structure. Figure 3 shows the main COM objects, which comprise the first
three levels of the hierarchical structure of the PlanarR54x2.exe application COM
objects. COM objects provide various methods and properties, which allow access to
the server functions; besides, they allow access to the objects of the lower levels, which
are not shown in Figure 3.
Application
CALCulate
SCPI
DISPlay
SENSe
TRIGer
OUTPut HCOPy SERVice
Figure 3. The structure of COM objects
INITiate IEEE4882
SOURce MMEMory
SYSTem
The Object Application of the PlanarR54x2.exe application is in the top of the
hierarchy. Access to the lower level objects is implemented via higher level objects.
10
PLANAR R54x2 COM/DCOM Programming manual
Note
The hierarchy of COM objects is organized in accordance with
the standard and syntax of the SCPI programming language.
Operators in SCPI have hierarchical chain structure, for
example:
SCPI:CALCulate:SELected:FORMat SWR
The same COM command written in VB programming
language is as follows:
app.SCPI.CALCulate.SELected.FORMat = "SWR"
6 Accessing the Application Object
To establish connection with the COM server application, create an object reference in
the client program. In COM programming the object reference needs to be acquired
preliminarily, to be used later to access the object functionality. To define an object in
Visual Basic perform the following:
1) Declare a variable as an object.
2) Assign the object to this variable.
To declare a variable, use Dim operator or other declaration statement (Public, Private
or Static). The variables used for references should of the types Variant,Object, or a
type of a specific object. For example, the following three operators declare app
variable:
Dim app
Dim app as Object
Dim app as R54x2.Application
Use Set operator and CreateObject (ObjectName, HostName) function to assign a
specific object to a variable.
ObjectName Automation object name is always equal to “R54x2.Applcation”
HostName Network name of the PC hosting the PlanarR54x2 COM server. This
parameter is not specified in case of a local server.
11
PLANAR R54x2 COM/DCOM Programming manual
For example, the following operators create Application object and assign it to app
variable:
Set app = CreateObject("R54x2.Applcation")
Set app = CreateObject("R54x2.Applcation", "Network_Name")
Note
The first form of the operator is used to create the reference to
the local COM server, the second one is used to create the
reference to the remote DCOM server.
To allow access to the objects of a lower level of the hierarchy, these objects are
specified after the reference to the higher level object and separated from it by a dot. For
example:
Dim SystObj
Set SystObj = app.SCPI.SYSTem
COM objects can have indices. For example, CALCulate, INITiate, SENSe, SOURce
objects represent various aspects of the 4 measurement channels of the Analyzer.
Therefore, it is necessary to write the channel index from 1 to 4 to acquire the data of
these objects. For example:
Set SensObj1 = app.SCPI.SENSe(1)
Set SensObj2 = app.SCPI.SENSe(2)
Visual Basic allows omitting of such indices; in this case the indices are considered as
equal to 1. For example, the following VB operators are equivalent:
Set SensObj = app.SCPI.SENSe(1)
Set SensObj = app.SCPI.SENSe
12
PLANAR R54x2 COM/DCOM Programming manual
7 Object Methods
Objects have methods. Methods are actions that can be applied to objects. The object
methods are specified after the object name and separated from it by a dot.
The following example shows the PRESet method of SYSTem object. This method
performs setting of the Analyzer to the preset condition:
app.SCPI.SYSTem.PRESet
8 Object Properties
Along with methods, objects have properties. Properties are object characteristics that
can be set or read out. The object properties are specified after the object name and
separated from it by a dot.
To modify an object characteristic, write the value of the corresponding property. To
define an object characteristic, read out the value of its property. The following example
show the setting of the POINts property of SWEep object, i.e. the number of sweep
points:
app.SCPI.SENSe.SWEp.POINts = 201
Note
Some object properties cannot be written, and some object
properties cannot be read. In such cases, the properties are
indicated as “read only” or “write only”.
13
PLANAR R54x2 COM/DCOM Programming manual
9 Error Handling
You can use different approaches to error handling in VB program:
check the value of Err.Number variable after execution of VB
operator, which contains the call to R54x2 object;
use On Error goto VB operator.
These approaches are represented in the examples below. The following operator causes
an error in VB program as "S13" value of the DEFine property is incorrect.
app.SCPI.PARameter.DEFine = "S13"
In the first example, the value of the Err.Number variable is checked after execution of
the VB operator, which contains the call to R54x2 object. On Error Resume Next
directive instructs VB not to interrupt the program execution when the error is detected
but to pass control to the next operator in natural order.
Dim app
Public Sub HandleError1()
Set app = CreateObject("R54x2.Application")
On Error Resume Next
app.SCPI.PARameter.DEFine = "S13"
If Err.Number <> 0 Then
Msg = "Error # " & Str(Err.Number) & " was generated by " &_
Err.Source & Chr(13) & Err.Description
MsgBox Msg,,"Error"
End If
...
End Sub
14
PLANAR R54x2 COM/DCOM Programming manual
In the second example, On Error GoTo ErrHandler directive instructs VB to interrupt
the program execution when the error is detected and to pass control to ErrHandler
label.
Dim app
Public Sub HandleError2()
Set app = CreateObject("R54x2.Applcation")
On Error GoTo ErrHandler
app.SCPI.PARameter.DEFine = "S13"
...
Exit Sub
ErrHandler:
Msg = "Error # " & Str(Err.Number) & " was generated by " &_
Err.Source & Chr(13) & Err.Description
MsgBox Msg,,"Error"
End Sub
15
PLANAR R54x2 COM/DCOM Programming manual
precision floating point, value range from
10 COM Automation Data Types
In COM automation, there are the following data types, which can be used for client-toserver communication:
Long
Double
Boolean
String
Variant
32-bit signed integer, value range from –2147483648 to 2147483647
64-bit double–1.79769313486232E308 to –4.94065645841247E–324 for negative
values, and from 4.94065645841247E–324 to 1.79769313486232E308
for positive values
16-bit integer, two values 0 – False, 1 – True
Variable-length string
Can be either a value of arbitrary type or an array of values of arbitrary
type. In this case, the term “arbitrary type” means any allowed type of
COM automation. A variable contains information about its type and
array size (if it is an array). It is used for communication of data arrays
between a client and a server.
16
PLANAR R54x2 COM/DCOM Programming manual
11 Measurement Data Arrays
Measurement data can be either complex values or real values. This depends on the
format selected by the user. For example, the data is real in logarithmic magnitude
format and the data is complex in polar format.
The measurement data is transferred in a Variant type variable, which represents an
array of Double type. To transfer one complex measurement, two adjacent array cells
are used. To transfer one real measurement two adjacent array cells are used as well but
the second cell is always equal to 0. Thus, measurement data array size is a double
number of the measurement points.
Measurement 1 Measurement 2
Real Imag Real Imag
Figure 4. Array of complex measurements
Measurement 1 Measurement 2
Value 0 Value 0
Figure 5. Array of real measurements
…
…
Measurement N
Real Imag
Measurement N
Value 0
17
PLANAR R54x2 COM/DCOM Programming manual
12 COM Server Commands
NAME
Object Type
Data Type
Description
Range
Syntax
Equivalent Softkeys
Property (read only)
String
Instrument information string. String format: manufacturer, model, serial
number, number of firmware version and number of software version.
up to 40 characters
Dim ID As String
ID = app.NAME
None
18
PLANAR R54x2 COM/DCOM Programming manual
Ready(Pt)
Object Type
Data Type
Target
Description
Syntax
Equivalent Softkeys
Property (read only)
Boolean
Port Pt: port number 1-2 (see Table 2 on page 22)
Ready state of the instruments. Reads out the True value after successful
completion of the boot process (about 10 sec). The pair of PLANAR R54
must be connected to PC by a USB cable.
Dim State as Boolean
State = app.Ready(2)
None
19
PLANAR R54x2 COM/DCOM Programming manual
SCPI.ABORt
Object Type
Description
Syntax
Equivalent Softkeys
Method
Aborts the sweep. Switches trigger mode from Single to Hold, or from
Continuous to waiting for a trigger. If the trigger source is set to Internal,
starts a new sweep.
Ch: channel number 1–4 (see Table 1 on page 22)
Pt: port number 1-2 (see Table 2 on page 22)
De-embedding function file name (*.s2p). The file contains the circuit S–
parameters in Touchstone format.
up to 256 characters
""
Dim File As String
File =
app.SCPI.CALCulate(Ch).FSIMulator.SENDed.DEEMbed.PORT(Pt).USER.FILename
app.SCPI.CALCulate(Ch).FSIMulator.SENDed.DEEMbed.PORT(Pt).USER.FILename
=
"network.s2p"
Notes
Equivalent Softkeys
If the full path to the file is not specified, the \FixtureSim subdirectory of the
main directory will be searched for the file.
Ch: channel number 1–4 (see Table 1 on page 22)
Pt: port number 1-2 (see Table 2 on page 22)
Embedding function file name (*.s2p). The file contains the circuit S–
parameters in Touchstone format.
up to 256 characters
""
Dim File As String
File =
app.SCPI.CALCulate(Ch).FSIMulator.SENDed.PMCircuit.PORT(Pt).USER.FILename
app.SCPI.CALCulate(Ch).FSIMulator.SENDed.PMCircuit.PORT(Pt).USER.FILename
=
"network.s2p"
Notes
Equivalent Softkeys
If the full path to the file is not specified, the \FixtureSim subdirectory of the
main directory will be searched for the file.