Matlab Toolkit For R&S Signal Generators PDF
Matlab Toolkit For R&S Signal Generators PDF
Application Note
T. Röder, C. Tröster
24.4.2013
Notices
Table of Contents
1. Notices .................................................................................... 3
2. Overview ................................................................................. 4
3. Features .................................................................................. 4
5. Windows XP Installation........................................................ 6
1.4 Unpacking The Files ....................................................................................6
1.5 Setting The Path In MATLAB.......................................................................6
6. Linux Installation.................................................................... 8
1.6 Prerequisites.................................................................................................8
1.7 Unpacking The Files ....................................................................................8
1.8 VISA Installation ...........................................................................................8
1.9 USB Support .................................................................................................9
1.Notices
The following abbreviations are used throughout this application note.
® ® ®
The R&S MATLAB Toolkit for R&S Signal Generators is referred to as MATLAB
Toolkit or toolkit.
®
The R&S SMW200A Vector Signal Generator is referred to as SMW.
®
The R&S SMU200A Vector Signal Generator is referred to as SMU.
®
The R&S SMJ100A Vector Signal Generator is referred to as SMJ.
®
The R&S SMATE200A Vector Signal Generator is referred to as SMATE.
®
The R&S SMBV100A Vector Signal Generator is referred to as SMBV.
®
The R&S AFQ100A I/Q Modulation Generator is referred to as AFQ.
®
The R&S AFQ100B UWB Signal and I/Q Modulation Generator is referred to as
AFQ.
®
The R&S AMU200A Baseband Signal Generator and Fading Simulator is referred
to as AMU.
® ® ® ® ®
Microsoft , Windows , MS Windows , Windows NT , and MS-DOS are U.S.
registered trademarks of Microsoft Corporation.
®
MATLAB is a U.S. registered trademark of The Math Works, Inc.
® ®
Agilent and Agilent Eesof ADS are registered trademarks of Agilent Technologies.
®
Rohde & Schwarz is a registered trademark of Rohde & Schwarz GmbH & Co. KG
2.Overview
MATLAB is widely used for the simulation of communication systems and the creation
or analysis of custom signals. This toolkit provides functions that simplify the remote
control of Rohde & Schwarz instruments from MATLAB scripts. These functions cover
the most common tasks, such as sending SCPI commands to the instrument and
reading responses back from it. Additional functions convert I/Q data into R&S
waveform files and transfer these files to the instrument’s ARB. A set of example
scripts demonstrate the use of the toolkit functions in various applications. The toolkit
supports remote control via GPIB hardware, raw TCP/IP socket connections, or the
VISA (Virtual Instrument Software Architecture) interface.
3.Features
The toolkit provides the following functionality.
4.System Requirements
1.2 Hardware
The MATLAB requirements (CPU, memory, hard drive)
For the instrument remote control (depending on instrument)
– 100MBit LAN
– GPIB hardware
– USB interface
1.3 Software
The MATLAB Toolkit can be used on Microsoft Windows XP or Linux operating
systems. The following configuration was tested by Rohde & Schwarz.
5.Windows XP Installation
‘RS_MATLAB_Toolkit_<version number>.zip
First, create a new folder under your MATLAB toolbox directory, e.g.
C:\Program Files\MATLAB\R2007a\toolbox\RsMatlabToolkit
The contents of the archive should now be unpacked into this directory.
Note: When using MATLAB 7.0 (R14) it is required to remove unused instrument
drivers. This is a confirmed problem in MATLAB 7.0 (R14) in the way that MATLAB
interfaces with GPIB cards.
\toolbox\instrument\instrumentadaptors\win32
in the MATLAB directory, create a new directory called backup and move every dll
except mwnigpib.dll and mwnivisa.dll to the backup directory.
6.Linux Installation
Starting with version R2009a MATLAB provides the Instrument Control Toolbox on
Linux installation. Using these toolbox scripts is recommended for all instrument
communication because it allows writing platform independent code and simplifies
instrument access greatly.
1.6 Prerequisites
Linux distribution with kernel sources and symbols installed
VISA installation package, e.g. from National Instruments
# md /opt/matlab2009/toolbox/RsMatlabToolkit
# unzip <archive.zip> \
-d /opt/matlab2006/toolbox/RsMatlabToolkit
After the files are unpacked follow the Step ‘Set the path to the toolkit in MATLAB’ from
the Windows installation procedure.
# cd /usr/src/linux
# make cloneconfig
# make prepare
# mkdir /media/visa
# mount –t iso9660 –o loop,ro <imagefile> /media/visa
# cd /media/visa
Run the National Instruments installer and make sure to add the ‘development’ option.
# ./INSTALL
You should now have a working VISA installation. Verify your installation by invoking
the NIvisaic or visaconf tools.
# NIvisaic
# visaconf
# /usr/local/vxipnp/linux/NIvisa/USB/
AddUsbRawPermissions.sh
Enter the vendor ID 0x0AAD for Rohde & Schwarz and the product of your instrument.
A list of all product IDs can be found in the next chapter.
The vendor ID for all Rohde & Schwarz devices is 0x0AAD. The product ID depends
on the instrument and can be taken from the list below.
Instrument Device ID
SMW200A 0x92
AFQ100A 0x4B
AFQ100B 0x66
AMU200A 0x55
SMATE200A 0x46
SMBV100A 0x5F
SMF100A 0x47
SMA100A 0x48
SMB100A 0x54
SMC100A 0x6E
The list represents all R&S Signal Generators that support USB remote control at the
time of writing.
Function Overview
The next paragraph explains the syntax and use of these functions.
1.10 rs_connect.m
The function rs_connect() sets up the instrument connection and tests the link. It
returns a handle to the remote controlled instrument. The connection can be
established using the GPIB or VISA interface as well as via a raw TCP/IP socket
connection. The recommended interface type is VISA.
GPIB parameters
<board number> GPIB board number (usually 0)
<primary address> GPIB bus address of the instrument
<secondary address> The secondary GPIB bus address
of the instrument (optional)
VISA parameters
<VISA resource string> The VISA resource string describes the
device as well as the interface type.
TCP/IP parameters
<hostname> The instrument host name or the IP address
Return values
<status > 1 if successful
<object > The handle to the instrument
The GPIB and VISA functions require an identifier for the installed hard- or software
interface. The function call for opening device number 28 connected to the first
National Instruments GPIB card is
VISA offers more flexibility over direct GPIB connections as it allows the use of
different interface types. Please consult your Rohde & Schwarz instrument manual or
data sheet for details about which remote control interface is supported by your
instrument.
Please see the documentation of your VISA installation for details about the VISA
resource strings.
Note:
LAN based remote control requires that the instrument’s firewall is disabled. This, for
example, applies to the Microsoft Windows based instruments SMU, SMJ, and
SMATE. The Linux based instruments, such as the SMBV do not have an internal
firewall.
1.11 rs_check_instrument_errors.m
The function rs_check_instrument_errors() sends SYST:ERR? queries to the
instrument until the error queue is entirely cleared.
Parameters
<object> The instrument object returned by rs_connect()
Return value
<status> 1 if successful
Example code
>> [err, instrObj] = rs_connect( 'gpib', 'ni', 0, 28 );
>> err = rs_send_command( instrObj, 'XXX' );
>> err = rs_check_instrument_errors( instrObj );
-113,"Undefined header;XXX"
1.12 rs_send_comand.m
The function rs_send_command() sends a single SCPI command to a previously
connected instrument.
Parameters
<object> The instrument object returned by rs_connect()
<command> SCPI command, e.g. ‘FREQ 1.2GHz’
Return value
<status> 1 if successful
Example code
>> [err, instrObj] = rs_connect( 'gpib', 'ni', 0, 28 );
>> err = rs_send_command( instrObj, '*RST' );
1.13 rs_send_query.m
The function rs_send_query() works similar to rs_send_command() with the exception
that an answer from the instrument is expected after the command has been sent.
Parameters
Return values
<status> 1 if successful
<answer> Contains the answer from the instrument
Example code
>> [err, instrObj] = rs_connect( 'gpib', 'ni', 0, 28 );
>> [err, answer] = rs_send_query( instrObj, '*IDN?' );
1.14 rs_batch_interpret.m
This function processes a series of SCPI commands or queries from a text file.
Parameters
<object> The instrument object returned by rs_connect()
<batch-file> Path and name of the batch-file
Return values
<status> 1 if successful
<answer> Contains the queries results in a structure
answer(x).text, where x is a consecutive number
of the queries, starting with the index one.
The highest number is the total number of queries.
Example code
>> [err, answer] = rs_batch_interpret( instrObj, \
'scpi.txt' );
1.15 rs_generate_wave.m
This function builds a waveform file from an I/Q vector. It also sends the generated file
to the instrument’s mass memory system and optionally starts the ARB in path A or B.
Parameters
<object > The instrument object returned by rs_connect()
If this number is set to 0 the waveform is only
stored locally and not sent to the instrument.
<struct> I/Q data and waveform parameters
<playback> 0 = ARB is not started after transfer
1 = waveform is activated in path A
2 = waveform is activated in path B
<save_local> 0 = waveform is not stored on local PC
1 = waveform is stored on local PC (current directory)
Return value
<status> 1 if successful
Markers are digital output signals that are generated synchronous to the signal output.
These signals can be used for synchronization of other devices. For more information
please see the instrument’s user manual.
1.16 rs_visualize.m
This function plots the I/Q values.
Parameters
<FSample> The sample rate in Hz
<I_data> 1D array with I values
<Q_data> 1D array with Q values
Return value
<status> 1 if successful
9.Example Scripts
The example scripts demonstrate the use of the toolkit functions. The following list
provides a brief overview of the examples.
Script Overview
1.17 Installation
On Microsoft Windows systems ADS only requires that the PATH environment variable
is set to the \bin\win32 sub directory of the MATLAB installation.
PATH=<matlabroot>\bin\win32;%PATH%
Additionally, it must be ensured that all toolkit scripts can be found from MATLAB.
1.18 Usage
The first step is to place a Matlab_M object into your schematic. This object directly
runs a MATLAB .m script during a simulation.
Next, a BusMerge5 object is required to combine the input parameters for the R&S
Matlab_M object.
Connect the two objects as shown below and edit the Matlab_M properties according
to the list below.
Script Directory =
MatlabSetUp =
MatlabFunction = output#1=rs_ADS_IQSink( input#1, input#2,
input#3, input#4, input#5,
'GPIB0::28::INSTR', 'D:/', 'test.wv',
'comment', 'copyright')
MatlabWrapUp =
The property MatlabFunction defines the call to MATLAB as well as all input and return
parameters. The placeholder input# is used for one of the parameters passed to the
BusMerge5 object. In the example above the VISA resource string is set to a device
connected to the primary GPIB board and set to address 28. The MATLAB routine
creates a waveform file locally and copies it to the specified location under the given
name (D:\test.wv in the example above).
Finally, the input values need to be provided to the BusMerge5 block as indicated in
the following picture. Const objects may be used for this purpose.
It is also required to pack the input data stream into a vector. This can be done by
using the PackCx_M object from ADS.
The example above uses QPSK encoded data and thus the length of the vector is set
to DefaultNumericStop/4 (no oversampling used, DefaultNumericStop sets number of
input bits).
The list below outlines the input parameters to the BusMerge block.
The MATLAB script rs_ADS_IQSink() performs the following actions when called with
the above parameters.
The function uses the National Instruments VISA interface by default. The MATLAB
code needs to be changed if other interfaces are used.
Environmental commitment
Energy-efficient products
Continuous improvement in
environmental sustainability
ISO 14001-certified environmental
management system
Regional contact
Europe, Africa, Middle East
+49 89 4129 137 74
[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]
www.rohde-schwarz.com