using r&s signal, spectrum with matlab

10
Using R&S Signal, Spectrum and Network Analyzers with MATLAB ® Application Note Products: | R&S FSQ / FSG | R&S FSU | R&S FSV / FSP | R&S ZVA | R&S ZVB | R&S ESCI | R&S ESPI | R&S ESL | R&S ESU | R&S FSL | R&S FSMR | R&S FSUP | R&S ZVL | R&S ZVM | R&S ZVT This Application Note describes how to use the Rohde & Schwarz Signal, Spectrum and Network Analyzers within the MathWorks MATLAB ® programming environment. A collection of m-files is presented which provides functions like sending standard SCPI commands and receiving binary data. All interfaces to the instrument (GPIB and LAN) are supported. Application Note M. Weiss / J. Pliquett 05.2009-1EF51_0E

Upload: starlink1

Post on 28-Nov-2015

251 views

Category:

Documents


9 download

DESCRIPTION

e

TRANSCRIPT

Page 1: Using R&S Signal, Spectrum With MATLAB

Using R&S Signal, Spectrum and Network Analyzers with MATLAB®

Application Note

Products: | R&SFSQ / FSG| R&SFSU | R&SFSV / FSP | R&SZVA | R&SZVB

| R&SESCI | R&SESPI | R&SESL | R&SESU | R&SFSL | R&SFSMR | R&SFSUP | R&SZVL | R&SZVM | R&SZVT

This Application Note describes how to use the Rohde & Schwarz Signal, Spectrum and Network Analyzers within the MathWorks MATLAB® programming environment. A collection of m-files is presented which provides functions like sending standard SCPI commands and receiving binary data. All interfaces to the instrument (GPIB and LAN) are supported.

Appli

catio

nNo

te

M.W

eiss/

J.Pl

iquett

05.20

09-1

EF51

_0E

Page 2: Using R&S Signal, Spectrum With MATLAB

Overview

Table of Contents 1 Overview.............................................................................................. 3

2 Software Features............................................................................... 3

3 Hardware and Software Requirements ............................................. 5

4 Connecting the Computer and the Instrument................................. 5

5 Installing the Software........................................................................ 6

6 Using the Software – First Example.................................................. 7

7 Description of Commands ................................................................. 8

8 Additional Information........................................................................ 9

Page 3: Using R&S Signal, Spectrum With MATLAB

Overview

1 Overview This application note provides a MATLAB® toolbox for remote control of R&S instruments, such as a spectrum analyzer, via a LAN (or GPIB) interface. MATLAB® is a high-level technical computing language and interactive environment for algorithm development, data visualization, data analysis and numeric computation, which facilitates the rapid solution to many technical computing problems. The ability to couple the development environment with remote control of measurement systems, enables the engineer to easily combine data acquisition and analysis tasks. For example, to perform RF measurements using specialized instruments and to then evaluate the results on a PC.

Notes The Signal Analyzer R&S® FSQ is abbreviated to FSQ for the remainder of this Application Note. In the following "FSQ" will be used as a synonym for all signal spectrum and network analyzers listed on the cover page of this application note.

Trademarks MATLAB® is a trademark of The MathWorks, Inc..Other product and company names mentioned herein are trademarks or trade names of their respective companies.

2 Software Features The provided software package consists of several MATLAB® files and the RSIB DLL (rsib32.dll) with the corresponding MEXRSIB DLL (mexrsib.dll). RSIB (Rohde & Schwarz Interface Bus) is a network protocol introduced by Rohde & Schwarz before any standard network protocol (e.g. VXI-11) was widely used. RSIB is implemented in any up-to-date R&S spectrum, signal or network analyzer and can be used without additional requirements by simply using the RSIB.DLL file on a PC. The MEXRSIB DLL enables MATLAB® to access the RSIB functionality. In addition, the AJO class provides overloaded functions for the commands used to access the instrument (fopen, fwrite, fread, fclose, etc.). This makes it very easy to use the provided solution in parallel to other remote control channels like VISA (Virtual Instrument Software Architecture) or GPIB (General Purpose Interface Bus). The flowchart below illustrates the usage of measurement instruments together with the MATLAB® development environment; the usage of the provided solution is indicated by the yellow shaded region.

Page 4: Using R&S Signal, Spectrum With MATLAB

Software Features

Advantages of the provided solution include: ● Access via fast LAN connection. ● All required DLLs included; no registration required. ● Same commands (fscanf, fprintf) as for all other input and output pipes (file, etc.). ● No additional installations (VISA / RSIB Passport for VISA) necessary. To remote control the instrument via GPIB or VISA, the MALTAB® Instrument Toolbox must be installed (Not required to control the instrument via LAN).

Page 5: Using R&S Signal, Spectrum With MATLAB

Hardware and Software Requirements

3 Hardware and Software Requirements PC Hardware Requirements

Minimum Recommended

CPU CPU 1 GHz CPU 2 GHz or higher

RAM 128 MByte 256 MByte

Hard disc 10 MByte free space 50 MByte free hard disc space

Monitor SVGA monitor (800x600) XGA color monitor(1024 x 768) or better

LAN 10 MBit LAN 100 MBit LAN

GPIB GPIB interface1 -

PC Software Requirements Minimum Recommended

OS Windows 2000 / XP / Vista Windows XP

Other SW MATLAB® Version 7.0.4 or higher MATLAB® Version 7.0.4 or higher

MATLAB® Instrument Control Toolbox2

-

4 Connecting the Computer and the Instrument

The data communication between the instrument and the PC can be established using a GPIB or LAN connection.

Connecting the Instruments In order to use the software, connect the instrument and the PC via a GPIB or a LAN connection (crossover cable or connection via a network) and note the GPIB or IP address of the instrument. If the instrument shall be connected via the LAN interface using VISA with the RSIB protocol, please download the latest RSIB Passport driver from the following location: http://www.rohde-schwarz.com/appnote/1EF47

1 Required to access the instrument via GPIB or VISA/GPIB. 2 Required to access the instrument via GPIB or VISA.

Page 6: Using R&S Signal, Spectrum With MATLAB

Installing the Software

5 Installing the Software The software is delivered as a ZIP archive which is named FSx_MATLAB_Toolbox_<Version>.zip, where <Version> is the software version number. In order to install the software, the ZIP file should be extracted to a desired location on the hard disc. A file structure as illustrated below should be created:

Please make sure that the "@ajo" directory is created as shown in the screenshot above. Some ZIP tools may extract all files into a single directory, which will prevent correct use of the software.

Page 7: Using R&S Signal, Spectrum With MATLAB

Using the Software – First Example

6 Using the Software – First Example The following sequence provides an introduction to the toolbox using a provided example file. It is assumed the ZIP file was extracted to: C:\FSx_MATLAB_Toolbox 1. Start MATLAB®.2. Change into the directory where the ZIP file was extracted by entering

the following at the MATLAB® command prompt: >> cd 'C:\FSx_MATLAB_Toolbox'

3. Setup the correct IP address. This can be done by editing the file: "example_capture_FSQ_RF_via_LAN.m". The file can be edited using the command: >> edit example_capture_FSQ_RF_via_LAN.m The IP address should be changed to that of the instrument being used: e.g. IP_address = '89.10.84.31' Either an absolute IP address can be used, or a computer name which has been assigned to the instrument (e.g. "FSQ3-100123"). Save the m-file.

4. Start the example. This can be done with the command: >> example_capture_FSQ_RF_via_LAN

5. The MATLAB® command line should produce a report as follows:

In addition, a figure similar to the one below should appear:

Page 8: Using R&S Signal, Spectrum With MATLAB

Description of Commands

7 Description of Commands The following commands are available for communicating with the instrument. For more information on the input and output parameters, please refer to the corresponding m-file which contains all the information commented in the header of the source code.

Main AJO Class Methods ajo AJO class constructor. fopen Connects an AJO object to a Rohde & Schwarz instrument. fprintf Sends formatted command strings to the instrument. fscanf Reads data from an instrument and performs text parsing. fclose Disconnects an AJO object from a Rohde & Schwarz instrument.

"High-Level Commands" rs_sa_connect Initializes and opens a connection to an instrument. rs_sa_getID Gets the ID string from a connected instrument. rs_sa_capture_rf Captures data from the RF branch into the instrument's memory. rs_sa_capture_bb Captures data from the baseband inputs into the instrument's memory. rs_sa_readdata Retrieves the data from the instrument's memory (which has been captured using rs_sa_capture_bb or rs_sa_capture_rf). rs_sa_disconnect Closes an open connection to an instrument.

Page 9: Using R&S Signal, Spectrum With MATLAB

Additional Information

8 Additional Information This application note and the associated software are updated from time to time. Please visit the website http://www.rohde-schwarz.com/appnote/1EF51 in order to download the latest version. After installation, the current program information can be found in the file history.txt in the installation directory. Please contact [email protected] for comments and further suggestions.

Page 10: Using R&S Signal, Spectrum With MATLAB

About Rohde & Schwarz Rohde & Schwarz is an independent group of companies specializing in electronics. It is a leading supplier of solutions in the fields of test and measurement, broadcasting, radiomonitoring and radiolocation, as well as secure communications. Established 75 years ago, Rohde & Schwarz has a global presence and a dedicated service network in over 70 countries. Company headquarters are in Munich, Germany.

Regional contact Europe, Africa, Middle East +49 1805 12 42 42* or +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]

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.

Rohde & Schwarz GmbH & Co. KG Mühldorfstraße 15 | D - 81671 München Phone + 49 89 4129 - 0 | Fax + 49 89 4129 – 13777 www.rohde-schwarz.com