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 xpcosc.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
.
The target application starts running on the target PC. In the MATLAB window, the status of the target object changes from stopped to running.
xPC Object Connected = Yes Application = xpcosc Application = xpcosc Mode = Real-Time Single-Tasking Status = running
On the target PC screen, the Simulation line changes from stopped to
running and the AverageTET
line periodically updates with a new value.
xPC Target allows you to change many properties and parameters without rebuilding your target application. Two of these properties are stop time and sample time.
After you build a target application, but before you start running the application you can change the sample time. You can change the stop time before you start the target application or while it is running.
tg.StopTime = 1000 or set(tg,'StopTime',1000)
tg.SampleTime = 0.01 or set(tg, 'SampleTime', 0.01)
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 CPU Overload
changes to detected
. In that case, change the Fixed step size in the Solver property sheet to a larger value.
![]() | Controlling the Target Application | Signal Monitoring | ![]() |