Main Content

Basic App Designer App for Real-Time Application Interface

This example shows a basic App Designer app that provides an interface to a real-time application.

Open Model and Build Real-Time Application

Open the model slrt_ex_waves and build the real-time application.

open_system(fullfile(matlabroot,'toolbox','slrealtime','examples','slrt_ex_sine_waves'));
model='slrt_ex_sine_waves';
evalc('slbuild(model)');

Open Real-Time Application Interface App

Open the real-time application interface app slrt_sine_waves_App.

Control Run Real-Time Application

Use the App Designer app controls to:

  • Select the target computer by using the target selector list.

  • Toggle from Disconnected to Connected by using the connect button.

  • Load the real-time application by using the load button.

  • Start the real-time application by using the start button.

When done, stop the application by using the stop button.

Examing Code View for Interface App

In App Designer, click the Code View tab to view the code that connects the real-time application to the App Designer app. This code that executes after the app creates components uses a small number of Simulink® Real-Time™ functions to:

  • Create and configure the tuner component

  • Create and configure the instrument component

  • Start the instrument manager for the app

function startupFcn(app)
  % Add Parameter Tuner Component
  Tuner = slrealtime.ui.tool.ParameterTuner(app.UIFigure);
  Tuner.Component = app.AmplitudeKnob;
  Tuner.BlockPath = 'slrt_ex_sine_waves/Sine Wave';
  Tuner.ParameterName = 'Amplitude';
  % Add Instrument Component
  Instrument = slrealtime.Instrument;
  Instrument.connectLine(app.UIAxes,'slrt_ex_sine_waves/Sine Wave',1);
  Instrument.AxesTimeSpan = 1;
  InstrumentManager = slrealtime.ui.tool.InstrumentManager(app.UIFigure);
  InstrumentManager.Instruments = Instrument;
end

Close All Open Files

bdclose('all');