Main Content

Using Generic Driver with Test & Measurement Tool

Note

The Test and Measurement Tool app will be removed in a future release. Use the TCP/IP Explorer, UDP Explorer, Serial Explorer, or VISA Explorer app instead.

Creating and Connecting the Device Object

With the Test & Measurement Tool you can scan for your driver, create a device object that uses that driver, set and get properties of the object, and execute functions.

This example illustrates how to use the generic driver you created in Writing a Generic Driver.

  1. If your driver is not in the matlabroot\toolbox\instrument\instrument\drivers directory, in the MATLAB® Command Window, make sure that the directory containing your driver is on the MATLAB path.

    path

    If you do not see the directory in the path listing, and the driver is not in the matlabroot\toolbox\instrument\instrument\drivers directory, add the directory to the path with the command

    addpath directory

    where directory is the pathname to the directory containing your driver.

  2. Open the Test & Measurement Tool.

    tmtool

  3. In the Test & Measurement Tool tree, expand the Instrument Drivers node.

  4. Select the MATLAB Instrument Drivers node.

  5. Your driver might not be listed yet, so click Scan in the lower-right corner of the tool. If the tool found your driver, it is listed in the tree as ie_drv.mdd.

  6. Select the ie_drv.mdd node in the tree.

  7. Right-click the ie_drv.mdd node in the tree, and select Create Device Object Using Driver. The following dialog box appears.

  8. Select the Select the created device object in the tree on dialog close check box. The device object in this example does not need a resource, so keep that field empty.

  9. Click OK.

    When the Test & Measurement Tool creates the device object, an entry for the object appears as a node in the tree. The Browser-ie_drv node should already be selected in the tree. This refers to the device object you just created.

  10. Click Connect in the upper-right corner of the Test & Measurement Tool. This establishes a communication channel between the tool and the IE browser window, and an empty IE window appears on your screen. Remember that the Create code for your driver creates an object for the IE browser, and the Connect code and makes its window visible.

Accessing Properties

The driver you created allows you to specify where the browser window appears on your screen and how large it is.

  1. Click the Properties tab, and then select Top in the Device object properties list.

    The first value displayed for setting this property is 0.0.

  2. Click Set. The IE browser window shifts upward to the top edge of your screen.

  3. With the mouse, grab the IE window, and drag it down some distance from the top of the screen.

  4. Now return to the Test & Measurement Tool window, and click Get for the Top property. Notice in the Response pane how many pixels down you have moved the window.

Use your driver Vsize property to change the size of the browser window.

  1. Select Vsize in the Device object properties list.

  2. Enter a property value of 200, and click Set. Notice the IE window size.

  3. Enter a property value of 400 and click Set. Notice the IE window size.

  4. Try resizing the IE browser window directly with the mouse. Then in the Test & Measurement Tool, click Get for the Vsize property. Notice the value returned to the Response pane.

Using Functions

Use the goTo function of your generic driver to control the Web page that the browser displays.

  1. In the Test & Measurement Tool, click the Functions tab for your device object.

  2. Select goTo in the list of Device object functions.

  3. In the Input argument(s) field, enter 'www.mathworks.com'. Be sure to include the single quotes.

  4. Click Execute. Observe the IE browser and see that it displays the MathWorks Web site.

  5. Experiment freely. When you are finished, right-click the Browser-ie_drv node in the tree and select Delete Object. Close the Test & Measurement Tool, and close the IE browser window you created in this example.