xPC Target    

Control with MATLAB Commands

You run your target application in real time to observe the behavior of your model with generated code.

After xPC Target downloads your target application to the target PC, you can run the target application. 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. The default name of the target object is tg.

  1. In the MATLAB Command Window, type
  1. The target application starts running on the target PC. In the MATLAB window, the status of the target object changes from stopped to running.

    On the target PC screen, the Simulation line changes from stopped to running and the AverageTET line periodically updates with a new value.

  1. In the MATLAB Command Window, type
  1. The target application stops running.

    xPC Target allows you to change many properties and parameters without rebuilding your target application. Two of these properties are StopTime and SampleTime.

  1. Change the stop time. For example, to change the stop time to 1000 seconds, type either
  2. Change the sample time. For example, to change the sample time to 0.01 seconds, type either

Although you can change the sample time in between different runs, you can only change the sample time without rebuilding the target application under certain circumstances.

If you choose a sample time that is too small, a CPU overload can occur. If a CPU overload occurs, the target object property CPUOverload changes to detected. In that case, change the Fixed step size in the Solver pane to a larger value and rebuild the model.


  Control with xPC Target Remote Control Tool Control with Simulink External Mode