In External Mode, the model runs on the target (generated application on Desktop in Simulink Desktop Real-Time, and on Speedgoat Target Computer in Simulink Real-Time). Therefore all the block output signals are computed on the target and not transferred to the host, hence not reflected in RunTimeObject of the block. Because time is always transferred from the target to host, time is available with RumTimeObject (rto.CurrentTime).
An important exception to the above rule are blocks that act as external mode viewers (aka SimViewingDevice). These are Scope, Display, To Workspace, etc. These blocks are receiving the data from target via external mode communication channel, are able to display them (store to workspace, etc.), and, also, their RunTimeObject is able to return the data.
To solve this issue with RunTimeObjects in External Mode, we suggest to connect any SimViewingDevice to the signal you want to watch and use the RunTimeObject of this SimViewingDevice to get the value of the signal.
Beware, the signal will be present on the InputPort of the SimViewingDevice RunTimeObject, but *NOT* on the OutputPort of the RunTimeObject of the block connected to it. The connection between the connected block and the SimViewingDevice is the place where the data transfer happens, so the data are not present on the source side (output port), but they are present on the destination side (input port).
Hope this makes sense. Here is a simple example.
Open “sldrtex_dashboard” example model and add blocks (Display and Scope).
>> rtoScope = get_param('sldrtex_dashboard/Tank dynamics/Scope','RuntimeObject')
>> rtoDisplay = get_param('sldrtex_dashboard/Tank dynamics/Display','RuntimeObject')
>> rtoScope.InputPort(1).Data
>> rtoDisplay.InputPort(1).Data
rtoScope =
Simulink.RunTimeBlock
rtoDisplay =
Simulink.RunTimeBlock
ans =
21.7285
ans =
46.6138