Main Content

addInstrument

Add instrument object to target object

Description

example

addInstrument(target_object,instrument_object) adds an instrument object to the target object. Make sure that you add a signal to the instrument object before you add the instrument to the target object or no signal is streamed.

When the addInstrument() function binds the instrument to a real-time application, Simulink® Real-Time™ validates the signal names in the instrument. To reduce the time it takes to validate an instrument, add the instrument once to the target computer and run the real-time application as many times as needed. The instrument remains added to the target computer even after the real-time application stops and is reloaded.

Alternatively, you can add the instrument each time the real-time application runs. If using this approach, remove the instrument when the real-time application closes. For example, if adding code to an App Designer app, in the CloseRequestFcn, you could add a removeInstrument(hInst) function.

example

addInstrument(target_object,instrument_object,'updateWhileRunning') adds an instrument object to the target object and updates the target connection, even if the real-time application is running. Make sure that you add a signal to the instrument object before you add the instrument to the target object or no signal is streamed.

Examples

collapse all

Create a target object. Build the real-time application. Create the instrument object. Add a signal to the instrument object. Load the real-time application. Add an instrument object to the target object. Start real-time application.

tg = slrealtime('TargetPC1');
slbuild('slrt_ex_tank');
hInst = slrealtime.Instrument('slrt_ex_tank');
hInst.addSignal('slrt_ex_tank/Controller',1)
load(tg,'slrt_ex_tank');
addInstrument(tg,hInst);
start(tg);

Input Arguments

collapse all

Provides access to methods that manipulate the target computer properties.

Example: tg

To create the instrument object, use the Instrument function.

Example: hInst

Introduced in R2020b