View Signal Waveforms with Scope Instrument

In this example, create an instrument panel for the xpcosc model that contains the following instruments:

  • Slider — To tune the input signal amplitude (Signal Generator/Amplitude).

  • Slider — To tune the oscillator feedback damping parameter (Gain1/Gain).

  • Scope — To display the input signal (Signal Generator) and the oscillator output (Integrator1).

Start by building and downloading the real-time application to the target computer, running Simulink® Real-Time™ Explorer, and connecting Explorer to the target computer.

Create Instrument Panel

Create and save an instrument panel for the xpcosc model.

  1. In the Panels pane, right-click the Instrument Panels node, and then click Add New.

  2. Type a name for the instrument panel in the Name text box. Give the panel a name like xpcosc_scope_instr_freerun.slrtip. Type a folder location in the Location text box, and then press Enter

  3. Click the Save button .

Configure Slider Instrument for Parameter Tuning

Select and configure an instrument to tune two parameters in the xpcosc model. You must have previously created the xpcosc_scope_instr_freerun.slrtip instrument panel.

The parameter characteristics are listed in this table.

NameTypeRangePurpose

Amplitude

Numeric

0–10 units

Represents the amplitude of the input signal Signal Generator. You do not have to set it to an exact value.

Gain1

Numeric

0–1000 units

Represents the damping of the oscillator feedback signal Gain1. You do not have to set it to an exact value.

The Slider instrument meets the requirement for Amplitude and Gain1. To set exact numeric values, use, for example, a NumericEntry instrument.

To select and configure the instrument:

  1. Load the instrument panel.

    In the Panels pane, right-click the Instrument Panels node and select Existing. From the list, select xpcosc_scope_instr_freerun.slrtip.

  2. Select the instrument.

    From the Palette pane, drag a Slider instrument to the xpcosc_scope_instr_freerun.slrtip instrument panel.

  3. Bind the parameter to the instrument.

    To bind the Amplitude parameter to the Slider instrument, open the Parameter workspace for model xpcosc ( on the toolbar). Drag the Parameter icon  next to parameter Amplitude to the Slider instrument.

    A small copy of the Parameter icon appears next to the Slider instrument.

  4. Set the instrument range.

    Click the Slider instrument, and then click the Tasks button  in the top, right corner.

  5. In the Slider Tasks dialog box, set property Min to 0 and property Span to 10.

  6. Select and configure a label.

    From the Palette pane, drag a Label layout item under the Slider instrument.

  7. Click the Label element.

  8. In the Properties pane, scroll down to the Appearance node. Set the Text property to Amplitude, and then press Enter.

  9. Scroll down to the TextAlign property. Click the down arrow and click the center of the nine blocks presented.

    The TextAlign property becomes MiddleCenter.

  10. Repeat steps 2–9 for parameter Gain1.

    Set the property Min to 0 and property Span to 1000.

    Set the Text property to Gain1.

  11. Click the Save button .

At the end of this task, Simulink Real-Time Explorer looks like this figure.

Configure Scope Instrument with Default Triggering

Add a Scope instrument and configure it with the default triggering, which is a TriggerMode of SINGLESHOT and a TriggerSource of FREERUN. You must have previously created the xpcosc_scope_instr_freerun.slrtip instrument panel.

The signal characteristics are listed in this table.

NameTypeRangePurpose

Signal Generator

Numeric

−25:25 units

Represents the time-varying value of the signal generator input.

Integrator1

Numeric

−25:25 units

Represents the time-varying value of the oscillator output.

To select and configure the Scope instrument:

  1. Load the instrument panel.

    In the Panels pane, right-click the Instrument Panels node and select Existing. From the list, select xpcosc_scope_instr_freerun.slrtip.

  2. Select the instrument.

    From the Palette pane, drag a Scope instrument to the xpcosc_scope_instr_freerun.slrtip instrument panel.

  3. Bind the signals to the instrument.

    To bind the Signal Generator signal to the Scope instrument, open the Signal workspace for model xpcosc ( on the toolbar). Click the Signal icon  next to signal Signal Generator and drag the icon to the Scope instrument.

    The name Signal Generator:1 appears in the Scope instrument legend.

  4. In a similar manner to step 3, bind the Integrator1 signal to the Scope instrument

  5. Set the instrument range.

    Select the Scope instrument, and then click the YAxesLimits node in the Properties list.

  6. Set property Max to 25 and Min to −25.

  7. Click the Save button .

Run Instrumented Model

Run the instrumented xpcosc model, tune the parameters, and view the output waveform. You must have previously built and downloaded the xpcosc model and configured the xpcosc_scope_instr_freerun.slrtip instrument panel.

  1. Load the instrument panel.

    In the Panels pane, right-click the Instrument Panels node and select Existing. From the list, select xpcosc_scope_instr_freerun.slrtip.

  2. Set property Stop time to inf in the Applications pane ( on the toolbar).

  3. To start the instrument, in the xpcosc_scope_instr_freerun.slrtip instrument panel, click the Run Instrument button .

  4. To start execution, in the Applications pane, click the real-time application, and then click the Start button  on the toolbar.

    The Scope instrument displays one set of captured waveforms, and then stops.

  5. To change the amplitude and damping value, use the Amplitude and Gain1 instruments.

    For example, to increase the amplitude and reduce the oscillator damping, set Amplitude to 6 and Gain1 to 200.

  6. To view the result of the parameter changes, click the Start Acquisition button  on the Scope toolbar.

  7. To stop execution, in the Applications pane, click the real-time application, and then click the Stop button  on the toolbar.

  8. To stop the instruments, in the xpcosc_scope_instr_freerun.slrtip instrument panel, click the Stop Instrument button .

See Also

|

Related Topics