1MA228 4e LabVIEW Drivers
1MA228 4e LabVIEW Drivers
1MA228 4e LabVIEW Drivers
Note:
Please find the most up-to-date Application Note on our homepage:
www.rohde-schwarz.com/appnote/1MA228
Application Note
Miloslav Macko
Contents
Contents
1 Introduction............................................................................................ 3
2 About LabVIEW drivers......................................................................... 4
3 Getting started with using attribute-based drivers.............................9
4 Quick Drop Plugins..............................................................................14
5 Driver Express VI................................................................................. 20
6 Performance comparison....................................................................39
7 Tips and Tricks.....................................................................................43
8 Additional Information.........................................................................51
9 Rohde & Schwarz.................................................................................52
Introduction
Required Software
1 Introduction
Rohde & Schwarz provides a range of free Instrument Drivers (further referred to as
'drivers') (follow the link Rohde & Schwarz drivers) to simplify the development process of instrument remote control applications. Among them are LabVIEW attributebased drivers. These drivers utilize the Express VI technology which internally takes
advantage of VI scripting - programmatically creating and modifying VIs. In all new
Rohde & Schwarz drivers releases we introduce the Fast Read and the Fast Write
possibility. This feature removes one common disadvantage that has discouraged
users from using drivers - speed of execution. More about this topic is discussed in
chapter 5, "Driver Express VI", on page 20 and chapter 6, "Performance comparison", on page 39.
For demonstration purposes the Rohde & Schwarz LabVIEW driver for Spectrum Analyzers (rsspecan) is used in this Application Note. However, the presented procedure
is applicable to all Rohde & Schwarz drivers. The Spectrum Analyzer driver is chosen
because it represents the most comprehensive application when communicating with
any other instrument settings, waiting for the measurement result, reading the results
either in strings or arrays of numbers.
Microsoft and Windows are U.S. registered trademarks of the Microsoft Corporation.
R&S is a registered trademark of Rohde & Schwarz GmbH & Co. KG.
National Instruments are U.S. registered trademarks of National Instruments.
LabVIEWTM is a trademark of National Instruments.
The configuration used in for this Application Note: Windows 7 64-bit, LabVIEW 2010
32-bit, NI VISA 5.4.0, used driver in all examples is rsspecan LabVIEW driver version
3.3.1, R&S Instrument driver toolbox (rsidr_toolbox) version 4.2.0
1MA153: Development Hints and Best Practices for Using Instrument Drivers
functionality cannot be performed by attributes (for example reading the analyzer trace,
setting/reading a property that contains a cluster of parameters).
Installation: Copy both folders instr.lib and user.lib to
c:\Program Files (x86)\National Instruments\LabVIEW 2010\
Folder instr.lib contains the driver Hi-level functions, user.lib contains the driver's attribute Express VI. It also contains the Crosslinks.bin file which is an indexing file used by Quick Drop SCPI command searcher plugin. Refer to chapter 4.1,
"SCPI command searcher plugin", on page 15 for more details.
Example of an attribute-based driver Hi-level function for setting center frequency and
span using two Express VI instances (enclosed by red rectangle):
Fig. 2-3: Example of attribute-based rsspecan driver Hi-level function VI for setting center frequency
and span using two Express VI instances.
After restarting LabVIEW, the driver functions are accessible through palette menu:
Fig. 2-4: Rohde & Schwarz Spectrum Analyzer driver in LabVIEW palette view under Instrument I/O ->
Instrument Drivers -> Rohde & Schwarz Spectrum Analyzer.
Palette menu node pictures (e.g. Configuration) are stored in dir.mnu files in every
driver folder and sub-folders. The tree-structure in the palette corresponds to the help
file (Microsoft compressed html file format *.chm) provided for every Rohde & Schwarz
driver:
Fig. 2-5: Rohde & Schwarz Spectrum Analyzer driver help file rsspecan.chm
2.1.3.1
Project-based drivers have no <driver_name> prefix for the VIs, because the
driver prefix is the name of the project they are members of. They contain 2 folders:
Private and Public. Private is reserved only for internal driver use, Public
is the root folder for the user.
Non-Project drivers have <driver_name> prefix for all VIs and there are no
restrictions to the availability of VIs. <driver_name> folder is the root folder for
the user.
The following files can be found in the user root folder (VI names mentioned here are
without <driver_name> prefix):
Microsoft CHM file that gives an overview of the driver structure: Hi-level functions,
attributes (by linking the driver's attribute help file mentioned below), additional
driver information.
Microsoft CHM file that shows the attribute tree structure which is used by the
Express VI Tree control to access the desired attribute.
Initialize.vi
This is a basic VI that opens a session to the instrument based on the input VISA
resource name. Output VISA session is then used throughout the driver as a handle for communication with that specific instrument. VISA session is compatible
with all VISA palette VIs, including VISA Read.vi and VISA Write.vi.
Important!: Don't use VISA Open.vi from LabVIEW palette to initialize a session, because Initialize.vi also creates additional data for the session
that are needed later on.
Optional parameters are Reset (defines whether to send *RST to the instrument
after initialization) and ID Query (checks based on the instrument response to
*IDN? query whether it is among the listed supported devices for this driver). In
special occasions you might want to disable ID Query if you are sure that the
driver can handle your instrument. Disable Reset if your instrument already has a
setting that you don't want to lose.
Close.vi
This VI closes the instrument session and frees all additional session data.
Important!: Don't use VISA Close.vi from LabVIEW palette to close a session, because Close.vi also clears all additional session data that the
Initialize.vi has created.
Utility folder (don't mix with _utility) is outlined in the next chapter.
10
This folder contains VIs that change the driver's behavior, error handling VIs, instrument reset and self-test VIs, etc... The following chapters will describe the ones most
commonly used.
3.1.1.1
Error Message.vi
This VI is a wrapper over the generic LabVIEW General Error Handler.vi that
also translates the driver error codes to human readable form. Use this VI instead of
the General Error Handler.vi to confortably handle the driver errors.
3.1.1.2
This VI changes the session based parameter ErrorChecking which is set to ON during initialization. When ON, the driver calls the VI _check_error.vi (see below) that
11
sends the SCPI query *STB? after each command/query, checks the bit 2 of the Status register (Error Queue not empty) and reports an eventual errors to the error cluster.
Set this parameter to OFF for sections of your code that require fast execution speed.
Refer to chapter 6, "Performance comparison", on page 39.
3.1.1.3
Option Checking.vi
This VI combines the settings of both previous VIs, plus the RangeChecking settings
which is set to ON during initialization. Switch the RangeChecking off in special cases
when you are sure your instrument accepts the values outside the range allowed by
the driver.
3.1.1.5
_check_error.vi
This VI is used to detect whether an instrument has any message in its error queue.
First, the VI sends SCPI query *STB? and checks the bit 2 (Error Queue not empty). If
this bit is set to 1, SYST:ERR? reads and deletes the 1st entry from instrument error
queue. If you used Instrument Status Checking.vi to set the ErrorChecking
to OFF, there might be more than 1 errors in the queue. Therefore, in order to delete
all the error messages, you must call this VI in a loop until it reports no error in error
out cluster.
Note: LabVIEW doesn't put VIs whose names start with underscore to palettes. Therefore you will not find _check_error.vi in Utilities LabVIEW palette. You have to use
your file explorer or Quick Drop (CTRL+Space) to access it.
12
3.1.1.6
These VIs get/set session based parameter OPCtimeout - waiting for the operation to
be completed (e.g. measurement sweep). The driver synchronizes with the instrument
by sending *OPC (not *OPC?) at the end of the command and then periodically polling
the Status register bit 6 (OPC).
Important!: Because of this synchronization mechanism, the VISA Timeout
parameter has no effect on the driver's measurement timeout. You need to
change this custom session based parameter to prevent long measurement
timeout errors.
3.1.1.7
Revision Query.vi
Reset.vi
This VI sends *RST to the instrument, waits for the reset to be completed and applies a
default instrument setup, same as during the initialization.
3.1.1.9
Instrument IO folder
This folder contains VIs for direct SCPI queries and VIs for transferring files between
the PC and the instrument. Direct SCPI command writing can be performed with
VISA Write.vi from the LabVIEW VISA palette.
13
If a desired shortcut is already occupied, you will have to change it directly in the
C:\Program Files (x86)\National Instruments\LabVIEW 2010\
LabVIEW.ini file, key name QuickDropKeyboardShortcutMappings.
14
If you select the driver Express VI on you Block Diagram and invoke SCPI command searcher, it will automatically select the proper driver and search for the elements that are related to the Express VI instance attribute. In the picture below the
attribute RSSPECAN_ATTR_SWEEP_MODE_CONTINUOUS shows that is used in e.g.
Configure Aquisition.vi function and sends the INIT:CONT SCPI command:
15
Fig. 4-2: SCPI command searcher invoked with selected driver Express VI function.
If you select the driver Hi-level function on your Block Diagram and invoke SCPI
command searcher, it will automatically select the proper driver and search for the
elements that are related to the Hi-level function. In the picture below the Hi-level
function Configure Acquisition.vi uses two attributes and 2 SCPI commands (two for each attribute - one form is used in the instrument manual, the 2nd
is actually sent by the driver):
Fig. 4-3: SCPI command searcher invoked with selected driver Hi-level function.
Clipboard monitoring is a useful when you browse the device user manual - copying the SCPI command will immediately trigger the search and displays the result.
Also, browsing the driver help file and copying the function / attribute name will
help you to immediately drag it to your Block Diagram instead of searching the
palette or your disk folders. See the short video attached to this application note
showing how you can quickly compose your program in combination with an instrument user manual.
16
Diagram and aligns them into a chain by moving them and making horizontal space.
Here are the main features that of this plugin:
The connection and alignment works not only on the driver VIs, but on all nodes
with error in/out terminals. VISA terminals are optional.
If a node doesn't have a VISA terminal, the plugin tries to find a next node or terminal of the VISA type (see the example pictures below).
By default, the Y-alignment is done according the most-left object in the selection.
Using CTRL+SHIFT+A changes that to the most-right selected object.
The plugin also works without any nodes - just on tunnels and/or control terminals.
Wiring through tunnels is done in a smart way - if a tunnel is in your selection, it will
be reused instead of creating a new one which would lead to a parallel tunnel that
is hard to spot.
If a Case Structure Selector is in the selection, the error cluster will be rewired
through it, and all existing connections inside all case diagrams will be maintained.
The same rule applies for Shift Registers.
Here are some before and after pictures showing the plugin capabilities. First, you
need to perform a selection either by area or selecting individual objects. Then invoke
the Quick Drop by CTRL+F, and run the plugin by CTRL+A:
Connecting terminals with the driver VIs. The left-most node, error terminal or error
tunnel is used as for Y-alignment:
Selecting the new nodes and the error / VISA wires that start left to the selection
and end right to the selection will insert the nodes into the chain:
17
Adding a VI in the middle of an existing chain by selecting also left and right node.
All the nodes on the right are shifted to make required space:
Connecting through a Case Structure with its case selector terminal included in the
selection. The error cluster is wired through the case selector terminal. Notice the
VISA tunnels being reused and thus maintaining the other cases of the Case Structure properly connected. The Property node without a VISA terminal is still connected to the error wire. Direct cmd in/out terminals of Express VIs with are interconnected as well:
18
Connecting through a Loop structure with Shift Register included in the selection.
resulting in connecting it to the error wire. No unnecessary new tunnels are created
through the loop structure and the tunnels auto-indexing is disabled. All the terminals have labels shifted to left or right to make the diagram more compact.
19
Driver Express VI
General principle of LabVIEW Express VI
5 Driver Express VI
This chapter describes the driver Express VI used for setting the driver attributes. This
Express VI is a part of a rsidr_toolbox library and will be commonly used by all installed Rohde & Schwarz drivers. The rsidr_toolbox library is installed with the first use of
Express VI Configuration panel, or you can install it manually - refer to chapter 4,
"Quick Drop Plugins", on page 14.
Why should you use Attributes Express VI? There are several reasons to do so:
Performance: The driver even with ErrorChecking switched OFF (chapter 3.1.1.2, "Instrument Status Checking.vi", on page 11) still has an overhead
which in certain applications may prove too high. For these cases Express VI offers
Fast Write and Fast Read operations that compose most of the SCPI command
during the configuration phase. If you use fixed input parameter value, the entire
SCPI command string is prepared just to perform VISA Write operation during the
execution. Also, rather than sending SCPI commands one by one they can be
composed into one string and then sent all at once to the instrument. Read more in
chapter 5.2, "Express VI in drivers", on page 22 and chapter 6, "Performance
comparison", on page 39.
Setting just one attribute (parameter) separately: The driver Hi-level functions
are very often programmed with certain logic inside - they group setting of several
attributes together. If you just wish to set one attribute, you have to use Express VI.
Non-availability of Hi-level function: To minimize the size, the new Rohde &
Schwarz drivers are missing Hi-level functions that set just one attribute. There are
some exceptions to this for legacy reasons, or IVI specification requirements. If you
cannot find a Hi-level function using the attribute you need, you can always access
it by Express VI.
Execution Code VI - VI with the actual execution code during the run-time.
Source Express VI - this is the VI we refer to as Express VI. If you place the
Express VI into your code, you create anExpress VI instance (Source Express VI
with a certain configuration) and this is what you see in your code. In principle, it's
a wrapper over the Execution Code VI with configurable content (inputs, outputs,
20
Driver Express VI
General principle of LabVIEW Express VI
constants, setting default values for controls...). Compared to a normal VI, the
Express VI instance has 2 special properties:
it is not saved as a separate VI, but directly inside a parent VI. Every Express
VI instance is unique, therefore the more of them you have, the bigger your
parent VI gets.
it is reconfigurable by Configuration VI. Configuration starts when you doubleclick on its icon or select Context Menu Properties. If you want to see the
content of your Express VI instance, you have to convert it to a standard VI by
context menu item Open Front Panel. However, you cannot reconfigure it
again, and you have to save it separately as a standard VI. The Source
Express VI is visually distinguished from standard VI by light-blue frame around
it:
The following picture shows the example of a simple Express VI that can be configured
to perform a math operation between 2 numbers. On a picture below, the Express VI
instance is configured to give a result of A+B. Configuration VI can also take care of
connecting the terminals to the Source Express VI connector and by doing so changing
their accessibility to the user. To find out more on the topic of Express VI, enter "LabVIEW Express VI Development Toolkit User Guide" into your search engine. For the
purposes of this document we will refer to the Configuration VI as the Configuration
panel.
Fig. 5-1: Basic structure of Express VI. An instance of Express VI is visible in your code.
21
Driver Express VI
Express VI in drivers
Using Quick Drop SCPI command searcher: (refer to chapter 4.1, "SCPI command searcher plugin", on page 15 on how to install it). On the Block Diagram
press CTRL+Space and then CTRL+F:
Fig. 5-2: The Express VI instance can be placed in the Block Diagram by Functions palette ->
User Libraries -> Express User Libraries -> rsspecan -> rsspecan Expr VI
Copying from existing code: Use the driver Hi-level function e.g. figure 2-3 to
copy the instances of Express VI from. Copying the Express VI instance also copies its configuration. Rich-text VI title will be replaced by plain text, because Lab-
22
Driver Express VI
Express VI in drivers
VIEW will add an index number at the end of the title to distinguish between the
instances. You have to run the Configuration panel to get it back to rich-text title.
Using Palettes or Quick Drop will immediately invoke Configuration panel linked to
Express VI. To disable this, go to Menu -> Tools ->Options -> Block Diagram and
uncheck the checkbox Configure Express VIs immediately.
LabVIEW places the Express VI instance on your Block Diagram in full view:
23
Driver Express VI
Express VI Configuration panel
Right-click context menu item View As Icon switches to standard Icon view:
After placing / reconfiguring the Express VI instance you can simply make copies of it
in your Block Diagram by CTRL+C/V or CTRL+Dragging (making a copy) or CTRL
+SHIFT+Dragging (making a copy with vertical or horizontal alignment). The Express
VI instance configuration is copied as well. Configuration panel also generates quick
help content. You can view it in Context Help window (shortcut CTRL+H). As an example see figure 5-13.
24
Driver Express VI
Express VI Configuration panel
3 - Flatten the Attribute tree: If checked, all Select Attribute control nodes are
removed and the entire content is shown as a list.
4 - Filter: If ON, only the attributes fulfilling the Filter criteria (defined in 7c) and
Main Nodes (defined in 7d) will be visible.
5 - Find All: If ON, only the attributes fulfilling the Find criteria (defined in 7b) will
be visible. You can combine Filter and Find criteria to perform logical AND operation between them.
7a .. 7h: Refer to chapter 5.3.2, "7a .. 7f tab control tabs", on page 28.
25
Driver Express VI
Express VI Configuration panel
10 - RepCaps string control: This string contains values for repeated capabilities
defined in SCPI command by information in curly brackets. Repeated capabilities
are case sensitive, separated by comma (if there are more than one), no spaces
are allowed. Actual values depend on attribute definition and can be found in attribute help under Supported Repeated Capabilities. If the selected attribute has 1
or more Repeated capabilities defined, this control is enabled for editing. Invalid
repeated capabilities string will be marked with red label and will disable OK button
(14). Repeated capabilities string is allowed to be empty for standard Read/Write
operation (if no variable RepCaps are selected), for all others it must be valid. Editing options besides free writing:
Right-click context menu Fill with 1st options will set the first valid Repeated
capabilities string.
Double-click on empty RepCaps string control will do the same as Fill with 1st
options, or in case the attribute has no definition for Repeated capabilities,
RepCaps string control will be cleared.
11 - Input value: Input value for Write operations. Type of the control depends on
attribute Data type. If range checking is defined to the selected attribute, you can
see the allowed range in its label. In case of Read operation this value is disabled
and ignored. For data type Enum listbox item names depend on settings defined in
7e - Enum Embedding.
13 - SCPI Command indicator: This indicator is showing a command that with the
current settings will be sent to the instrument. Black text is fixed content, light blue
text shows Repeated capabilities portions, red text shows Repeated capabilities
portions when the RepCaps string is not valid. Purple portions are the parameters.
In case of the Read operation, parameter is the questionmark.
14 - OK button: This button finishes the configuration and the Express VI instance
is modified according the settings. In case of configuration error or conflict, OK button is disabled. Hovering over it with the mouse will bring up the error description
text.
15 - Cancel button: Discards all the configuration changes and closes the configuration panel.
26
Driver Express VI
Express VI Configuration panel
16 - Help button: Opens the rsspecan_attr.chm file page with the current
attribute. Optionally, you can have this automatically done with every change of
attribute by checking Auto Help update checkbox.
If Error Checking is ON, icon has a bubble with 'E?' in left bottom corner. *OPC? synchronisation is shown as a small red vertical strip on the right edge. *WAI synchronisation is signaled as a longer blue vertical strip on the right edge:
Fig. 5-8: Fast Write icons: with Error Checking / with OPC? synchronisation / with *WAI synchronisation.
Listed below are all possible attribute operations with their icons. Stated in brackets are
the names of Operation variable used in VI Title composing (see chapter 5.3.2.1, "7a Title composer tab", on page 28) :
Read (Get) - Standard driver read method. All Read functions in driver are programmed using this operation.
27
Driver Express VI
Express VI Configuration panel
Write (Set) - Standard driver write method. All write functions in driver are programmed using this operation.
Fast Read (GetFast) - Fast read operation, command is prepared during configuration. Run-time action is limited to writing prepared string to instrument, reading the
response from instrument and converting the response to defined attribute type.
You can use Error Checking with this operation.
Fast Write (SetFast/SetFix) with Send To Instrument checked. Fast write operation to the instrument. If you don't need to change the attribute input parameter during run-time, check Fixed input parameter checkbox. Available post-operations:
*WAI, OPC? and Error Checking.
5.3.2.1
28
Driver Express VI
Express VI Configuration panel
to use the composer window or modify it directly. VI title preview shows how the result
VI title will look like for the current configuration. You can also change the Background
color of the title - this is useful to e.g. distinguish between the different instruments by
setting a unique title background color. Limiting the title width prevents the long
description names causing the big horizontal space taken by the Express VI instance
on the Block Diagram. You also have a possibility to change the default title position.
Below is the list of available variables and formatting pair-tags:
Table 5-1: Title compose string variables
Variable Name (case sensitive)
Description
DescriptiveName
Identifier
IdentifierNoPrefix
Operation
DataType
DataTypeRaw
Value
ValueHRform
ValueHRform3
ValueIFfixed
Same as Value, if it cannot be changed during runtime (checkbox Fixed Input Parameter is checked).
Otherwise empty string
RepCap
(RepCapNE)
RawCmd
ResultCmdNoParam
Result command that is sent to the instrument without parameter e.g. CALC:MARK1
ResultCmd
29
Driver Express VI
Express VI Configuration panel
ReadWrite
Sync
5.3.2.2
Description
Pair tags for colors <red>, <blue>, <green>, <yellow>, <pink>, <purple>, <orange>, <white>
7b - Find tab
Find tab allows you to find an attribute based on Find Specification control. Searching of the next item fulfilling the criteria can be done with Find Next button or F3, or
ENTER button when focused on one of the string fields. You can see all positive
search results in Select Attribute control when checking 5 - Find All checkbox (figure 5-6). Use the shortcuts e.g. CTRL+G, CTRL+H, CTRL+F,to quickly focus on the
string fields.
String fields Descriptive Name, Attribute ID, and <Variable field> (depending on
Select Attribute columns) allow for full text searching in attribute fields. All non-empty
30
Driver Express VI
Express VI Configuration panel
strings must fulfill the attribute specification, otherwise they will not be positively
matched.
The text field SCPI command uses a special search method that is the same as in
Quick Drop SCPI command searcher plugin to ensure the best results when searching for a SCPI command.
If Case Sensitive checkbox is checked, all non-empty strings (except SCPI command) are evaluated with case sensitivity.
If Regular Expr checkbox is checked, all non-empty strings (except SCPI command)
are considered LabVIEW regular expressions.
Data type checkbox switches search based on attribute value data type. Multiple items
selection is possible with CTRL or SHIFT.
3-state checkbox RepCaps - search based on the attribute property Repeated Capabilities. If checked, only the attributes with at least one RepCap defined are shown.
3-state checkbox Range Check - search based on the attribute property of value
range checking. If checked, only the attributes that have a defined range for their value
will be shown.
3-state checkbox Hi-Level Fncs - search based on the usage of attribute in a Hi-level
function. If checked, only the attributes that are used in at least one Hi-level function
will be shown.
3-state check boxes Write Access / Read Access - search based on attribute property of access. If checked, only the attributes which are writable / readable will be
shown.
3-state checkbox Write Callback / Read Callback - search based on attribute property of special function for writing or reading. Some attributes cannot use standard
value data types of I32 / Double / Boolean / String, therefore they need special function
- called Callback. As a consequence, Fast Write/Read operations cannot be used
with such attributes. If this checkbox is checked, only the attributes for which Write/
Read callback is defined will be shown.
5.3.2.3
7c - Filter tab
Filter tab allows to only see the attributes in Select Attribute control that fulfill the Filter
Specification. Main filter switch is the control 4 - Filter (figure 5-6). It will be automatically checked on when the Filter Specification changes from its default value. Filter
specification control is the same as in 7b - Find Tab.
5.3.2.4
31
Driver Express VI
Express VI Configuration panel
5.3.2.5
7e - Embedding tab
This tab contains the setting for Express VI instance embedment into the Parent VI.
32
Driver Express VI
Express VI Configuration panel
Connect Attribute ID terminal: This setting has only effect for Standard Read/Write
operations. For Fast Read/Write operations the Attribute ID terminal is never connected, because it cannot be changed during the run-time.
Always connect Direct cmd out: If you chose the Attribute operation that sends the
data to instrument (command or query), you can still access the command through this
terminal by checking this checkbox (e.g. if you want to log the communication with your
instrument).
Use buffered instr. handle: Check this only if you are using one instrument. With
every use of the Express VI the instrument handle is stored in its internal buffer. All the
subsequent Express VIs that have this checkbox set will not have the input instrument
handle available and will use the buffered instrument handle. The instrument handle
out is always valid.
Input Value Terminal Placement: You can decide where can the input value terminal
be placed. The default is Left.
Input Value Terminal Label: This string control can use the same variables as Title
compose string (table 5-1) without rich-text capabilities. Double click to compose the
settings. The result name will be used as a label for variable input value terminal.
Output Value Terminal Label: This string control can use the same variables as Title
compose string (table 5-1) without rich-text capabilities. Double click to compose the
settings. The result name will be used as a label for output value terminal.
Enum Embedding - Terminal Type: You can decide how to embed Enum Data types:
as I32 number, I32 Ring or Enum terminal. This settings is common for input and output value terminals.
Enum Embedding - Show RSxxx_VAL_ prefix: If you use embedding of Enum Data
Types as I32 Ring or Enum, you can decide whether to have item names with
RSxxx_VAL_ prefixes. Sometimes the names are too long, so cutting this part out
makes the items more compact.
Enum Embedding - Show numeric value: If checked, the item names start with their
integer value in round brackets.
Enum Embedding - Show SCPI parameter: If checked, the item names end with
actual SCPI parameter in square brackets. Changing Show RSxxx_VAL_ prefix,
Show numeric value or Show SCPI parameter when you have the attribute with
Enum Data Type selected will immediately alter 11 - Input Value Ring items. This way
you can see how item names will look in your code.
As an embedding example, open the attached file
LabVIEW_programs\Example_EmbeddingSetTrace.vi. It shows the Express VI
instance with the attribute RSSPECAN_ATTR_TRACE_TYPE and the following Embedding options:
Control Name
Value
Variable RepCap
True
RepCaps string
TR4
View VI as Icon
True
33
Driver Express VI
Express VI Configuration panel
True
True
Conditional Terminal
False
Ring
False
True
Open the context help (CTRL+H) and hover the mouse over the Express VI to see its
configuration and short help for the selected attribute:
34
Driver Express VI
Express VI Configuration panel
5.3.2.6
7f - About
This tab shows the Express VI version info and the contact information.
5.3.2.7
7g - Hi-Level Functions
If the actual attribute is used in a Hi-level function(s), these will be displayed here. For
example the attribute RSSPECAN_ATTR_MARKER_POSITION is used in the following three Hi-level Functions:
35
Driver Express VI
Express VI Configuration panel
5.3.2.8
7h - Info
The various information about the selected attribute. An example for RSSPECAN_ATTR_MARKER_POSITION:
Attribute name: "Marker Amplitude"
Attribute path: "Marker\Marker Amplitude"
Data type: Double
Access: Read / Write
Attribute ID: "RSSPECAN_ATTR_MARKER_AMPLITUDE"
SCPI command: "CALC:MARK{Marker}:Y"
SCPI command from help: "CALCulate<1|2>:MARKer<1 to 4>:Y"
Supported Instruments: ""
Repeated Capabilities: "Marker"
36
Driver Express VI
Example of LabVIEW Express VI code
Fig. 5-15: SCPI command string building with two Fast Compose operations, and one Fast Write
operation at the end.
Sending the commands with the driver standard Write (Set) operation. Commands are
sent directly and Error Checking is performed after every operation. There is no difference between standard Write operation Express VIs and using the driver VIs, because
the entire driver is programmed with Express VIs configured to standard Write or
standard Read operations.
37
Driver Express VI
Example of LabVIEW Express VI code
Fig. 5-16: Standard Write VIs that you can find in all driver functions.
Similarly to the previous part SCPI command string is built by using Fast Compose
(BuildFast/BuildFix), and the end using Fast Read (GetFast) to retrieve a response
from the instrument. As you can see SCPI command string can be built by using different methods, in our case with shift register over the for loop creating settings for multiple traces. Compared to sending separate command for every attribute this approach
takes only a fraction of that time. In this example, the last Express VI sending SCPI
command string also checks for instrument errors. This way you can isolate groups of
SCPI commands that have caused an error. The following string (also available in
Direct cmd out 2) is sent to the instrument:
DISP:WIND:TRAC1:MODE MAXH;:DISP:WIND:TRAC2:MODE MINH;:SENS:FREQ:
CENT 254000000.000000000000;:SENS:FREQ:CENT:STEP:LINK RBW;:SENS:
FREQ:SPAN 12000000.000000000000;:SENS:FREQ:CENT:STEP:LINK?
Fig. 5-17: SCPI command string building with several Fast Compose operations, and one Fast Read
operation at the end, together with Error Checking.
38
Performance comparison
6 Performance comparison
Attached files:
LabVIEW_programs\Performance_comparison_Standard_Fast_Raw.vi
Scripts\Spyder_PlainVISA_WriteRead.py
VS_programs\PlainVISA_WriteRead\PlainVISA_WriteRead.sln
*IDN? loop time measurement - 10000 cycles of sending *IDN? query and reading the response from instrument. This task is not performed when using the LabVIEW driver, since this feature is not available.
Measurement - 10000 cycles of triggering the short sweep (50s) in zero span,
waiting for the sweep to finish, reading the RMS marker, reading marker X and Y
coordinates.
All used programs and scripts are available in attachment of this Application Note. All
measurements are performed using VXI-11 and HiSLIP protocols. The following
approaches were chosen for comparison:
Spyder Python script with raw VISA communication using PyVisa component.
Test setup:
39
Performance comparison
Results using VXI-11 protocol
Configuration time in
seconds
Measurement time in
seconds
N.A.
0.07
64.07
LabVIEW driver
Express VIs Standard
operations
N.A.
0.04
49.73
LabVIEW driver
Express VIs Fast operations
N.A.
0.03
24.97
9.59
0.04
24.26
9.26
0.03
23.51
10.51
0.04
27.04
Below, the last column Measurement time in seconds represented in graph, sorted
by speed from the slowest to the fastest:
40
Performance comparison
Results using HiSLIP protocol
Configuration time in
seconds
Measurement time in
seconds
N.A.
0.07
41.27
LabVIEW driver
Express VIs Standard
operations
N.A.
0.03
31.47
LabVIEW driver
Express VIs Fast operations
N.A.
0.03
20.92
2.03
0.03
20.75
2.03
0.02
20.45
2.48
0.07
22.62
Below, the last column Measurement time in seconds represented in graph, sorted
by speed from the slowest to the fastest:
41
Performance comparison
Conclusion
6.3 Conclusion
When using the LabVIEW driver, switching OFF the Error Checking can significantly
reduce the measurement time (over 30% in VXI-11, over 20% in HiSLIP in our measurement task). The absolute time spent on one error checking task is in our setup cca.
1.9ms (VXI-11) resp. 1ms (HiSLIP). The downside of Error Checking switched OFF is,
that you cannot react on an error occurred in the instrument which can lead to although
fast, but inaccurate or invalid measurement results. The best approach is to do the
'Smart' Error Checking:
Keep Error Checking ON for sections of your program that are not performed in
multiple loops.
Keep Error Checking ON for multiple measurement loops where the instrument
measurement times are relatively long (long sweep times, averaging results, etc.).
The longer measurement time you have, the less significant is the Error Checking
time. By sweep times in range of seconds the Error Checking time is negligible.
Switch Error Checking OFF for critical portions of your measurement with multiple
loops, do the error check before and right after them.
The difference between the LabVIEW driver Standard configuration (1st column)
and LabVIEW driver Express VIs standard operations (2nd column) is caused by
Initiate.vi which is doing additional operations besides sending INIT;*WAI SCPI
command string (clearing the instrument error queue, temporarily changing the session
based measurement timeout). When you use Express VI with RSSPECAN_ATTR_INIT
instead, you will achieve the same measurement times in both cases.
In HiSLIP LabVIEW driver Express VIs Standard operations with Error Checking
OFF are only cca. 5% slower than Visual Studio 2012 C#. In VXI-11 this difference
grows to cca. 28%.
It is safe to say that when it comes to communicating with instruments over VISA, LabVIEW in raw write/read mode is as fast as other programming languages. When using
the Rohde & Schwarz LabVIEW drivers, Express VI with Fast Operations can bring
the performance very close to raw write/read mode.
Of course the communication with instruments is only one part of measurement application, comparing the overall performance including user interfaces, graph and data
handling is the topic beyond the scope of this Application Note. It is also fair to mention, that the performance comparison was done on relatively powerful PC. The results
can differ depending on the used computer. Therefore we encourage the user to do the
comparisons on his setup using attached programs and scripts.
42
43
Fig. 7-1: Building an executable requires adding entire callbacks folder to Always Included set of VIs
or folders.
44
instrument locally and observing measurement results visually is in this aspect very different from operating it remotely. While in local operation user's eye serves as a flag to
distinguish between already valid result and measurement still in progress, remote
control application must rely on instrument's build-in synchronization mechanisms.
Although the measurement synchronisation is mostly related to analyzer-class instruments (spectrum analyzers, oscilloscopes, audio analyzers, multimeters), the same
principles can be used also for other instrument types.
Keep in mind, that in order for synchronization to be working properly your
instrument must be in single sweep / single measurement mode. Below, there are
three basic synchronization methods you can use with Rohde & Schwarz instruments.
45
Fig. 7-2: Instrument status reporting system showing ESR, ESE and STB registers.
Sending *OPC at the end of the command makes the instrument generating the Operation Complete event in ESR after all pending commands have been processed. The
occurrence of this event can be then read from STB register bit 5-ESB. The reason for
reading the STB register instead of direct reading of the ESR register bit 0 is, that VISA
provides viReadSTB function which doesn't query the instrument at all (as opposed to
*ESR? or *STB? queries), but only reads the session internal STB register on the controller (PC). The STB content synchronization between the controller and the instrument is handled by the instrument session automatically, and therefore it optimizes the
traffic and the speed on the controller-instrument interface.
The advantage compared to *OPC? synchronization method is, that your application
can perform other operations while waiting for the instrument to report the operation
complete. This method of synchronization is used internally by the driver in function
Wait For OPC.vi. As shown in the example, you need to use the timeout different
from VISA timeout to prevent a dead-lock. The Express VI doesn't provide this synchronization option.
46
47
LabVIEW will compile all VIs in the selected folder and all sub-folders to the actual version. It also compiles all VIs in llb libraries.
All the new drivers released later than 12.2014 have the automatic mass-compilation of
the user.lib folder. If your driver is of older date, repeat the same procedure for the
folder user.lib\_express\rsspecan. This is especially significant for Express VI
Configuration panels, because LabVIEW will never do it automatically and that leads to
a silent compilation of this code every time you configure you Express VIs.
48
Fig. 7-4: Differentiation between different instruments by selecting different caption background colors. With Conditional terminals you can avoid using Case Structures.
49
50
Additional Information
8 Additional Information
Please send your comments and suggestions regarding this Application Note or Attribute Express VI to:
TM-Applications@rohde-schwarz.com
Using tag [1MA228] in the mail subject will help us to quickly identify the topic and
speed up the response process.
51
ISO 9001
ISO 14001
Regional contact
North America
Phone 1-888-TEST-RSA (1-888-837-8772)
customer.support@rsa.rohde-schwarz.com
Latin America
Phone +1-410-910-7988
customersupport.la@rohde-schwarz.com
Asia/Pacific
Phone +65 65 13 04 88
customersupport.asia@rohde-schwarz.com
China
Phone +86-800-810-8228 / +86-400-650-5896
customersupport.china@rohde-schwarz.com
Headquarters
Rohde & Schwarz GmbH & Co. KG
Mhldorfstrae 15 | D - 81671 Mnchen
+ 49 89 4129 - 0 | Fax + 49 89 4129 13777
www.rohde-schwarz.com
This application note and the supplied programs may only be used subject to the conditions of use set forth
in the download area of the Rohde & Schwarz website.
R&S is a registered trademark of Rohde & Schwarz GmbH & Co. KG. Trade names are trademarks of the
owners.
52