xPC Target | ![]() ![]() |
Signal Logging with MATLAB
You plot the outputs and states of your target application to observe the behavior of your model, or to determine the behavior when you vary the input signals and model parameters.
Time, states and outputs -- Logging the output signals is possible only if you add, before the build process, outport blocks to your Simulink model, and in the I/O-Workspace pane select the Save to workspace check boxes. See Entering Parameters for Outport Blocks.
Task execution time -- Plotting the task execution time is possible only if you select the Log Task Execution Time check box in the xPC Target code generation option page. This check box is selected by default. See Adding an xPC Target Scope Block.
A scope of any type copies the last N
samples from the log buffer to the target object logs (tg.TimeLog
, tg.OutputLog
, tg.State
and Log
, tg.TETLog)
. The number of samples N
for a signal is equal to the value you entered in Signal Logging Buffer Size in Doubles and divided by the number of logged signals (1 time, 1 TET, Outputs, States)
After you run a target application, you can plot the state and output signals. This procedure uses the Simulink model xpc_osc3.mdl
as an example, and assumes you have created and downloaded the target application for that model.
tg.StopTime
.
The outputs are the signals connected to Simulink outport blocks. The model xpcosc.mdl
has just one outport block labeled 1 and there are two states. This outport block shows the signals leaving the blocks labeled Integrator1 and Signal Generator.
The plots shown below are the result of a real-time execution. To compare this plot with a plot for a nonreal-time simulation, see Simulating the Model from MATLAB.
getlog
in the xPC Target User Guide documentation.
The plot shown below is the result of a real-time run.
The task execution time (TET) is the time to calculate the signal values for the model during each sample interval. If you have subsystems that run only under certain circumstances, plotting the TET would show when subsystems were executed and the additional CPU time required for those executions.
In the example above, the minimum TET was 13 µs, the maximum TET 18 µs, and the average TET 13µs. This means that the real-time task has taken about 5% of the CPU performance (Average TET of 13 µs / Sample time of 250 µs).
![]() | Signal Logging with xPC Target Remote Control Tool | Signal Logging with a Web Browser | ![]() |