Documentation Center

  • Trial Software
  • Product Updates

Measure Generator's Frequency Using Instrument Control Toolbox


To illustrate how to use some of the Instrument Control Toolbox™ elements in the SystemTest™ software, this section provides a step-by-step example.

In this example a SystemTest element configures a signal generator to produce signals of various frequencies, which are measured by an oscilloscope configured by other SystemTest elements.

The signal generator is a Hewlett-Packard 33120A at GPIB address 5, and the oscilloscope is a Tektronix TDS 210 at GPIB address 4. For this example, the generator output is fed directly to the scope input. The generator will be programmed to generate signals of 1500, 5000, and 7500 Hz, while the oscilloscope will measure each signal's frequency.

The following sections explain the steps in this example.

Setting Up the Signal Generator

The first element in the test programs the generator to output signals of various frequencies. To test at three frequencies, the test be comprised of three test cases, i.e., three iterations. This is a one-way communication to the generator, so you use a To Instrument element.

  1. Open the SystemTest software from MATLAB® by typing systemtest at the MATLAB command line.

  2. No setup is required in the Pre Test, so the elements of this test are all in the main test, so click Main Test in the Test Browser.

  3. Add an element by clicking New Test Element > Instrument Control > To Instrument.

    The element appears in the browser as To Instrument.

  4. Double-click To Instrument, rename it Set Generator, and press Enter.

  5. From the Properties pane's Select an instrument resource list, select New Instrument Resource. The instrument resource is the communication channel between MATLAB and your instrument, in this case the generator at GPIB address 5.

  6. In the Edit: Instrument1 dialog box, enter Generator in the Name field.

  7. Click Create to create an instrument resource.

  8. In the New Object Creation dialog box, select GPIB in the Instrument object type list. Select the appropriate Vendor (in this example, ni for National Instruments), Board index (0), and instrument Primary address (in this example, 5).

  9. Click OK to return to the Edit: Instrument1 dialog box, where the instrument object is now filled in and selected for this resource (GPIB0-5).

  10. Click OK to apply this resource and return to the Properties pane in the SystemTest desktop.

  11. In the Command text field, enter frequency followed by a space to separate the text from the variable that will follow. This is the command to set the frequency of the 33120A generator, as described in the instrument's reference manual proved by the vendor.

  12. Click Data source and select New Test Vector. The name of the vector you create for setting the generated frequencies is called genfreq. In the Insert Test Vector dialog box, enter that text in the Name field, and set the Expression field to [1500 5000 7500], including the brackets.

  13. Click OK to return to the SystemTest desktop.

    Notice that the Main Test node in the tree now says (3 Iterations). Because you entered three values in the test vector, the test is comprised of three iterations, one for each frequency value in the test vector.

  14. Keep the Send variable data as setting as String. The generator is expecting string values for its commands.

  15. Set a pause value of 2 seconds. This allows the generator to settle before you measure its output.

    The element should now resemble the following figure:

Setting Up the Oscilloscope

You use a To Instrument element, which provides a one-way communication to the oscilloscope, to program the scope to measure frequency.

  1. Add an element by clicking New Test Element > Instrument Control > To Instrument.

  2. Double-click To Instrument in the tree, rename it Set Scope, and press Enter.

  3. As before, create a new instrument resource, but this time call it Scope. Create a new instrument object for it using Board index 0, and GPIB primary address 4.

  4. For the command text, enter measurement:immed:type frequency. This puts the scope in the frequency measurement mode, as described in the instrument's reference manual provided by the vendor.

    There is no test variable or pause required for this element, so the element looks like the following figure:

    To see the resources you created for communications with your two instruments, click the Resources tab at the bottom of the SystemTest window. You can see the Generator and Scope resources, along with their GPIB settings.

Taking the Measurement

With the generator and scope set up, you can take the measurement with the scope using a Query Instrument element, which sends the command to the scope for taking the measurement.

  1. Add an element by clicking New Test Element > Instrument Control > Query Instrument.

  2. Double-click Query Instrument in the tree, rename it Measure with Scope, and press Enter.

  3. Use the existing instrument resource called Scope, by selecting it in the Instrument resource list.

  4. Enter the command to query for a measurement by typing measurement:immed:value? in the Instrument query command field.

  5. Select Store complete response, and select the Empty input buffer after read check box.

  6. From the Interpret data as list, select String (this scope returns ASCII strings), and select the Convert string value to a numeric result check box.

  7. From the Assign data to list, select New Test Variable. For the oscilloscope's frequency measurement, name the test variable scopefreq. It needs no initial value.

    The element now looks like the following figure:

Saving Test Results

To view the results of your test, you must first specify the test variables you want to save as test results. This is done in the Save Results Properties pane.

  1. Click Save Results in the test browser tree.

  2. In the Properties pane, click New Mapping.

  3. From the Test Variable list, select scopefreq. This test variable contains the frequency measurements provided by the oscilloscope during each Main Test iteration, as shown in the following figure:

Running the Test and Viewing Test Results

Now that the test elements are all created, you can run the test.

  1. Run your test.

  2. When the test is complete, click on the link in the Run Status pane to display your test results.

  3. To see the measurement results, at the MATLAB prompt type

    format short g
    scopefreq =

This verifies that the signal generator is producing the expected signal frequencies.

Was this topic helpful?