Main Content

Using the Test & Measurement Tool

Overview of the Examples

These examples illustrates a typical session using the Test & Measurement Tool for instrument control. The session entails communicating with a Tektronix®TDS 210 oscilloscope via a GPIB interface.

To start the tool, on the MATLAB®Command window, type:

tmtool

Hardware

When the tool displays, expand (click the+) theInstrument Control Toolboxnode in the tree. Next, expand theHardware节点。The tree now looks like this.

Selecting the Interface and Scanning for GPIB Boards

Next, scan for installed GPIB boards by selecting theGPIB节点。右边的面板中更改Installed GPIB Boardlist. ClickScanto see what boards are installed. The following figure shows the scan result from a system with one Capital Equipment Corp and one Keithley®GPIB board.

Scanning for Instruments Connected to GPIB Boards

After determining what GPIB boards are installed, you must determine what instruments are connected to those boards. Expand theGPIBnode and select a board.

右边的面板中更改GPIB Instrumentslist. ClickScanto see what instruments are connected to this board. The following figure shows the scan result from a system with a Tektronix TDS 210 connected at primary address 8ˋ.

Configuring the Interface

You can change the configuration of the interface by clicking theConfiguretab. This pane displays properties you can set to configure the instrument communication settings. In the following view of theConfigurepane, theTimeoutproperty value has been set to10seconds.

Establishing the Connection

Expand theni-Board-0node and select the instrument at primary address 4:PAD-8 (TEKTRONIX,TDS 210...). The right pane changes to the control pane you use for writing and reading data to and from that instrument.

ClickConnectto establish communication with the instrument. The tool creates an interface object representing the communication channel to the instrument.

写作和再保险ading Data

Selecting theCommunicatetab displays the pane you use to write and read data. You can write and read data separately using theWriteandRead按钮,或者您可以使用查询button to write and read in a single operation.

The following figure shows the pane after a brief session involving the following steps:

  1. Open communication with the instrument.

  2. Enter*IDN?asData to Write, and click查询(write/read). This executes the identify command.

  3. EnterCURVE?asData to Write, and click查询. This retrieves the waveform data from the scope.

Exporting Instrument Data

You can export the data acquired from instruments to any of the following:

  • MATLAB workspace as a variable

  • Figure window as a plot

  • MAT-file for storage in a file

  • The MATLAB Variables editor for modification

To export data, selectFile>Export>Instrument Response(s)from the menu bar. When the Data Exporter dialog box opens, choose the variables to export. The following figure shows the Data Exporter set to export the curve data to the MATLAB workspace as the variabledata2.

Note

If you repeatedly generate a large amount of data in the Test and Measurement tool, you must delete the data object after you export it to MATLAB. This will allow the tool to return resources to MATLAB correctly and will prevent MATLAB from failing to respond the next time you acquire data.

Exporting the GPIB Object

When you open a connection to an instrument, the Test & Measurement Tool creates an instrument object automatically. You can export the GPIB instrument object created in this example as any of the following:

  • MATLAB workspace object that you can use as an argument in instrument control commands

  • File containing the call to the GPIB constructor and the commands to set object properties

  • MAT-file for storage in a file

To export the object, selectFile>Export>Instrument Objectfrom the menu bar. When the Object Exporter dialog box opens, choose the object to export. The following figure shows the Object Exporter set to export the object to a file. (When you run that file, it creates a new object with the equivalent settings.)

Saving Your Instrument Control Session.TheSession Logtab displays the code equivalent of your instrument control session. You can save this code to a file so that you can execute the same commands programmatically.

SelectFile>Save Session Logfrom the menu bar or clickSave Session. From this dialog box you can specify a file name and directory location for the file.

Instrument Objects

Interface Objects

The Test & Measurement Tool creates interface objects automatically when you open a communication channel to an instrument by clicking theCommunication Statusbutton. To explicitly create and configure an interface object:

  1. Expand theInstrument Objectsnode in the tree, and selectInterface Objects. TheInterface Objectspane appears on the right.

  2. ClickNew Object新开的Object Creation dialog box.

  3. Specify the object parameters and clickOKto create the new object.

Device Objects

To create and configure a device object:

  1. Expand theInstrument Objectsnode in the tree, and selectDevice Objects. TheDevice Objectspane appears on the right.

  2. ClickNew Object新开的Object Creation dialog box. In this case, theInstrument object typeis already set fordevice.

  3. Specify or browse for the instrument driver you want to use; then choose from among the available interface objects, or create one if necessary.

  4. ClickOKto create the new device object.

Setting Instrument Object Properties

Whether the instrument objects are created automatically, created through the New Object Creation dialog box, or created on the MATLAB Command window, the Test & Measurement Tool enables you to set the properties of these objects. To change object properties in the Test & Measurement Tool:

  1. Expand theInstrument Objectsnode in the tree, then eitherInterface ObjectsorDevice Objects, and select the object whose properties you want to set.

  2. Click theConfiguretab in the right pane.

  3. Set properties displayed in this pane, as shown in the following figures.

    Configuring Interface Object Properties

    Configuring Device Object Properties

Communicating with Your Instrument

Using an Interface Object.When communicating with your instrument using an interface object, you send data to instrument in the form of raw instrument commands. In the following figure, the Test & Measurement Tool sends the*RSTstring to the TDS 210 oscilloscope via an interface object.*RSTis the oscilloscope's reset command.

Communicating via an Interface Object

Using a Device Object.When communicating with your instrument using a device object, instead of employing instrument commands, you invoke device object methods (functions) or you set device object properties as provided by the MATLAB instrument driver for that instrument.

In the following figure, the Test & Measurement Tool resets a TDS 210 oscilloscope by issuing a call to thedeviceresetfunction of the instrument driver. Communicating this way, you don't need to know what the actual oscilloscope reset command is.

Communicating via a Device Object

Instrument Drivers

The Test & Measurement Tool enables you to scan for installed drivers, and to use those drivers when creating device objects.

MATLABInstrument Drivers

MATLAB instrument drivers include

  • MATLAB interface drivers

  • MATLAB VXIplug&playdrivers

  • MATLAB IVI®drivers

Select theMATLAB Instrument Driversnode in the tree. Then clickScanto get an updated display of all the installed MATLAB instrument drivers found on the MATLAB software path.

When the Test & Measurement Tool scans for drivers, it makes them available as nodes under the driver type node. Expand theMATLAB software Instrument Driversnode to reveal the installed drivers. Select one of them to see the driver's details.

You can choose to see the driver's properties or functions. When you select the particular property or function, the tool displays that item's description.

VXIplug&playDrivers

For an example of scanning for installed VXIplug&playdrivers with the Test & Measurement Tool, seeVXIplug&play Drivers.

IVIDrivers

For an example of scanning for installed IVI-C drivers with the Test & Measurement Tool, see. For using the Test & Measurement Tool to examine or configure an IVI configuration store, seeConfiguring IVI Configuration Store.