Application Note: Introduction To Attribute Based Instrument Drivers
Application Note: Introduction To Attribute Based Instrument Drivers
Instrument Drivers
Application Note
Products:
| R&SFSW | R&SCMW | R&SETL
| R&SFSV | R&SRTM | R&SETH
| R&SFSVR | R&SRTO | R&SSFC
| R&SFSQ | R&SZNC | R&SSFE
| R&SFSP | R&SZNB | R&SSFU
| R&SFSU | R&SZVL | R&SCLG
| R&SFSMR | R&SZVH | R&SDVSG
| R&SFSUP | R&SPR100
| R&SFSL | R&SEM100
| R&SESL
| R&SFSC
| R&SFSH4/8
Table of Contents
1 VXIplug&play Instrument Drivers ......................................... 3
1.1 Preface ...........................................................................................................3
1.2 The Definition of Instrument Drivers ..........................................................4
4 Related Documents.............................................................. 23
5 References ............................................................................ 24
1.1 Preface
The task of programming instruments in a test system has always been a concern for
end users and a major cost for the overall system development. Many users know that
programming can often be the most time-consuming part of developing a system. The
developer spends much valuable time learning the specific programming requirements
of each instrument in the system. Almost all instruments are designed for interactive
use through a physical front panel and also offer remote control capability via a
communication port on the backside of the instrument. The details for how to program
the instrument remotely are usually documented in the instrument manual in the form
of ASCII command sets that cause the instrument to perform the desired operation.
Documenting an instrument command set in the user manual, along with some
example program listings, has traditionally been the standard method for an instrument
vendor to assist the end user in programming the instrument. These documentation
methods have served the industry well for many years, but this approach still places
the responsibility for writing the program code on the user, many of whom may end up
writing very similar application programs.
If the same command works for multiple instruments, regardless of the manufacturer,
users can interchange or upgrade instruments and reduce the amount of changes to
their application programs. In particular, many of the installed base of users who had
substantial investments in their software environments, that did not easily lend
themselves to software modularity, lobbied for this approach. Through the mid to late
1980s, many standard organizations, including the IEEE, worked on this objective with
little progress. The IEEE 488.2 specification [ANSI/IEEE Std 488.1-1987], completed in
1987, more carefully defined the operation of instruments like the program message
exchange protocol, but did not address the issue of standard command sets.
1
In 1990, the SCPI Consortium [The SCPI Consortium] was formed, which became
part of IVI Foundation in 2002. This organization approved a specification for
standardized commands for message-based programmable instruments. The SCPI
Consortium is not active anymore and the last updated document was published in
1999 [The SCPI Standard]. While more and more companies continue to endorse the
SCPI standard and use it in their new instrument designs, still instruments available
today do not use this standard command set. In addition, while many users of SCPI
instruments appreciated the progress and have experienced improvement in
productivity once they learn the standard command set, instrument interchangeability
is still not a reality because most instruments have different, often unique functionality
and therefore a command set different to the SCPI standard command set. Moreover
syntactically equal SCPI commands are a necessary, but not a sufficient condition for
instrument interchangeability.
While the SCPI standard is certainly recognized by the entire industry as a step
forward, the lack of progress on this issue encouraged both users and vendors to
explore other approaches before SCPI was completed.
1
Standard Commands for Programmable Instruments
2
For details on WiMAX please visit http://www.rohde-
schwarz.com/appnote/1MA96.html
3
For details on LTE please visit http://www.rohde-schwarz.com/appnote/1MA111.html
4
For details on National Instrument LabVIEW please visit http://www.ni.com/labview/
Figure 1: Architecture of Rohde & Schwarz attribute based instrument drivers: Example of
instrument hardware configuration setting, e.g. a)-aa) frequency setting or b) reading trace data
5
The rsspecan instrument driver is available at http://www.rohde-schwarz.com/drivers.
This instrument driver contains high-level functions that set most of the instrument
attributes. It is best to use the high-level driver functions as much as possible, because
they handle order dependencies.
6
prefix stands for a corresponding attribute based instrument driver, e.g.
prefix_SetAttributeBoolean(…) stands for rsspecan_SetAttributeBoolean(…) in case of
the rsspecan attribute based instrument driver.
7
Five type safe functions are available for following data types: ViBoolean,
ViInt32, ViReal64, ViString and ViSession.
8
For details on National Instrument LabWindows/CVI please visit
http://www.ni.com/lwcvi/
2.6 Events
Events are basically attributes with no data. This is different to IVI driver specification
which does not allow implementation of events via attribute engine. Events in Rohde &
Schwarz drivers are realized using prefix_SetAttributeViString with VI_NULL or an
empty string in place of the string argument.
Please use the Driver Attribute Help chm file. This help file is accessible via the
Instrument Driver Help file (e.g. rsspecan_vxi.chm).
The rsspecan.sub file has to be added to the project. This file is mandatory for
browsing attributes.
To select an attribute, use the provided function panels, which are included in the
instrument driver package. These instrument driver function panels can be found in:
Instruments=>ROHDE & SCHWARZ SpecAn=>Configuration=>Set/Get/Check
Attribute/Repeated Capabilities
To open the function panel, double-click on the desired function. Fig. 9 shows the
function panel of "rsspecan_SetAttributeViReal64". Clicking on the "Attribute ID" text
box opens the "Select Attribute Constant" window.
Now you can select the desired attribute from the tree structured list. Each attribute
can have a different access type (read only, write only or read/write). Proper read/write
operation can be selected by the proper function panel, either Set Attribute, Get
Attribute or Check Attribute.
Repeated capabilities are set by using identifier or identifier names within the function
panel called rsspecan_GetAttributeRepeatedCapabilityId[s|Names].
For example, in Basic Operation use the Set Frequency Start value:
1. Please select the desired attribute. To find the designated attribute easily the
rsspecan.chm help file can be used to look for it. Be aware of the fact that the tree
structures in the help file and the Express VI are the same.
2. Fill the Repeated Capabilities text box according to the documentation, e.g. “Win0”.
3. Type the desired frequency value in the Attribute Value text box, e.g. "1e+9".
4. Enter a valid instrument handle in the Instrument Handle text box.
5. It is strongly recommended to evaluate the return value of your function, if you type
the name of a declared integer variable in the Status text box.
6. To include the function into your source code, you can copy the created function
string out of the window on the button of the function panel and insert it into the
source code.
The attribute and its features can be changed at any time later by right-clicking the
function and recalling the function panel. See Fig. 11:
Repeated capability instances are specified by a string parameter for each property.
They can also be specified by a function which selects the active instance.
To define the usage of particular capability, enter the proper value in the Repeated
Capability text box in the function panel. If more than one repeated capability is
required for one attribute, separate them with a comma.
The attribute and its features can be changed at any time later by recalling the function
panel, which recalls the shown panel.
Figure 7: Example how to create a dynamic repeated capability using a high level function
This example outlines how to use dynamic repeated capabilities, here “MyTrace2”, in
combination with an high level function as well as using it with a front panel.
Furthermore the default channel setup of the Rohde & Schwarz ZNB network analyzer
is required.
For the following example the dynamic repeated capability is fed into the driver
attribute access function via a constant string parameter.
Figure 8: Example how to use a dynamic repeated capability using the attribute-access
functions
After running this sequence a new channel and trace has been added on the
instrument and is stored in the instrument driver for future use. To access this new
trace the dynamic repeated capability “MyTrace2” has to be used. In this case the new
trace can be addressed by other high level functions, as well as using the attribute-
access functions directly. This attribute-access function is deleting the trace. The
showed sequence is deleting the repeated capability “MyTrace2” again.
9
The rsspecan.cs (or the rsspecan64.cs ) file has to be added to the project. This file
comes together with the VXIplug&play driver and is a prerequisite for using the driver
in C#. Please note, that for the instruments that in the meantime have a IVI.NET – a
native .NET instrument driver available, the *.cs C# wrapper file is no more available in
the VXIplug&play driver installation. We encourage the user to switch to the native
.NET instrument driver.
To control an instrument via an attribute, use one of the provided get and set functions
of the C# wrapper. The available functions can be found in the following list:
● SetInt32 (rsspecan_SetAttributeViInt32)
● GetInt32 (rsspecan_GetAttributeViInt32)
● SetDouble (rsspecan_SetAttributeViReal64)
● GetDouble (rsspecan_GetAttributeViReal64)
● SetBoolean (rsspecan_SetAttributeViBoolean)
● GetBoolean (rsspecan_GetAttributeViBoolean)
● SetString (rsspecan_SetAttributeViString)
● GetString (rsspecan_SetAttributeViString)
● SetSession (rsspecan_SetAttributeViSession)
● GetSession (rsspecan_GetAttributeViSession)
The respective functions and their documentation can be found in the Instrument
Driver Help file in Instrument Driver Tree Structure=>Configuration=>Set/Get/Check
Attribute/Repeated Capabilities referring to listed function names in the brackets
above.
This example shows how to use attributes without repeated capabilities. The use of
repeated capabilities is described in section 3.3.1.
To find the proper attributes for specific configurations, the rsspecan_vxi.chm help file
can be used. All available attributes are listed in the Instrument Driver Help chapter
under Driver Attribute Help; see figure below.
9
It is important to distinguish between 32-bit and 64-bit remote control software
applications. These files are wrapper files for bitness dependent dynamically loaded
libraries. Please always configure your Microsoft Visual Studio project to be 32-bit or
64-bit as target. The default setup “Any CPU” must not be enabled. For further
information please refer to Application Note 1MA153, available on
http://www.rohde-schwarz.com/appnote/1MA153.
using InstrumentDrivers;
namespace rsspecan_Application_Example
{
class Program
{
static void Main(string[] args)
{
string resourceName = "TCPIP::FSP7-100894::INSTR";
bool idQuery = true;
bool resetDevice = true;
Repeated capability instances are specified by a string parameter for each property.
They can also be specified by a function which selects the active instance.
To define the usage of particular capability, the following overloaded functions are
provided by the C# wrapper file, for example the rsspecan.cs:
● SetInt32 (rsspecan_SetAttributeViInt32)
● GetInt32 (rsspecan_GetAttributeViInt32)
● SetDouble (rsspecan_SetAttributeViReal64)
● GetDouble (rsspecan_GetAttributeViReal64)
● SetBoolean (rsspecan_SetAttributeViBoolean)
● GetBoolean (rsspecan_GetAttributeViBoolean)
● SetString (rsspecan_SetAttributeViString)
● GetString (rsspecan_SetAttributeViString)
The following figure outlines the “Supported Repeated Capabilities” of the attribute
rsspecanProperties.MarkerPosition (called RSSPECAN_ATTR_MARKER_POSITION
in the rsspecan.chm help file).
This example outlines how to use dynamic repeated capabilities, here “MyTrace2”, in
combination with high level function. To get this line of code executed, the default
channel setup of the Rohde & Schwarz ZNB network analyzer is required.
For the following example the dynamic repeated capability is fed into the driver
attribute access function via a string parameter.
After running this code a new channel and trace has been added on the instrument
and is stored in the instrument driver for future use. To access this new trace the
dynamic repeated capability “MyTrace2” has to be used. In this case the new trace can
be addressed by other high level functions, as well as using the attribute-access
functions directly. This attribute-access function is deleting the trace. The showed
sequence is deleting the repeated capability “MyTrace2” again.
If instrument status checking is enabled, the driver automatically checks the status of
the instrument after most operations. If the instrument indicates an error condition, the
driver returns a special error code. The user then calls the error query function to
retrieve the instrument specific error code from the instrument.
Instrument status checking is most useful during debugging. Once application
development is complete, this feature can be disabled to maximize performance.
The driver core of the attribute-based instrument drivers is dynamically linked to any
executed VI during runtime. This cannot be recognized by the LabVIEW application
builder. The LabVIEW application builder follows all static dependencies and includes
them in the distributed package when building an executable.
If option checking is enabled, the driver checks first, if the following command is
supported by the connected instrument. While the initialization of the driver the “ID
Query” has to be enabled to correctly identify the connected instrument. Based on the
installed instrument options, the driver is generating the error “Instrument version not
valid” if the command is not supported by the instrument.
For extended debugging the option checking functionality can be disabled using the
function/VI “Option Checking” and set the input variable to “False”. This can be found
in the “Utility Functions” folder of the driver documentation
If range checking is enabled, the driver checks if the input parameters are within the
valid range for the connected instrument. Range checking is most useful during
debugging. After users have validated their programs, they can disable range checking
to maximize performance.
Using the function/VI “Option Checking” and set the input variable to “False”. This can
be found in the “Utility Functions” folder of the driver documentation.
The Rohde & Schwarz attribute-based instrument drivers are by definition divided into
different independent modules. These modules are based on the instrument’s
hardware and software options. Consequently, it is possible to include only the
instrument driver core modules and the other driver modules corresponding to the
instrument options used. This allows you to avoid unused driver modules within your
development project.
LabVIEW driver
To avoid unused VIs in a LabVIEW project, you can simply delete unused folders
inside the instr.lib folder. The folders minimally needed for a correctly operating
instrument driver are shown in the following, using the rsspecan LabVIEW instrument
driver as an example.
In the figure above, the minimal recommended configuration of the rsspecan LabVIEW
instrument driver is highlighted in gray. For example, to have a proper setup for
10
performing measurements on an LTE downlink signal, only the K100- EUTRA LTE
Downlink folder needs to be preserved besides the folders highlighted in gray. The
remaining folders can be easily deleted. The content of the LabVIEW
user.lib\_express\rsspecan folder is mandatory.
This is procedure is also applicable to other attribute-based instrument drivers.
10
UMTS Long Term Evolution (LTE) Technology Introduction
11
UMTS Long Term Evolution (LTE) Technology Introduction
4 Related Documents
Application Note 1MA153: Development Hints and Best Practices for Using
Instrument Drivers http://www.rohde-schwarz.com/appnote/1MA153.html
IEEE Std 488.2-1992 IEEE Standard Codes, Formats, Protocols, and Common
Commands for Use With IEEE Std 488.1-1987, IEEE Standard Digital Interface for
Programmable Instrumentation
http://standards.ieee.org/reading/ieee/std_public/description/im/488.2-
1992_desc.html
5 References
[1] ANSI/IEEE Std 488.1-1987 IEEE Standard Digital Interface for Programmable
Instrumentation
http://standards.ieee.org/reading/ieee/std_public/description/im/488.1-
1987_desc.html
Regional contact
Europe, Africa, Middle East
+49 89 4129 12345
[email protected]
North America
1-888-TEST-RSA (1-888-837-8772)
[email protected]
Latin America
+1-410-910-7988
[email protected]
Asia/Pacific
+65 65 13 04 88
[email protected]
China
+86-800-810-8228 /+86-400-650-5896
[email protected]
www.rohde-schwarz.com