| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → xPC Target |
| Contents | Index |
| Learn more about xPC Target |
| On this page… |
|---|
Accessing Help for Target Objects Displaying Target Object Properties Setting Target Object Properties from the Host PC |
See Function Reference and Functions for a reference of the target object functions.
The target application object methods allow you to control a target application on the target PC from the host PC. You enter target application object methods in the MATLAB window on the host PC or use M-file scripts. To access the M-file help for these methods, use the syntax
help xpctarget.xpc/method_name
If you want to control the target application from the target PC, use target PC commands. See Using the Target PC Command-Line Interface.
To create a target object, perform the following
Build a target application. the xPC Target software creates a target object during the build process.
To create a single target object, or to create multiple target objects in your system, use the target object constructor function xpc (see xpctarget.xpc) as follows. For example, the following creates a target object connected to the host through an RS-232 connection. In the MATLAB Command Window, type
tg = xpctarget.xpc('rs232', 'COM1', '115200')The resulting target object is tg.
To check a connection between a host and a target, use the target function targetping. For example,
tg.targetping
To create a single target object, or to create the first of many targets in your system, use the target object constructor function xpctarget.xpc as follows. In the MATLAB Command Window, type
tg = xpctarget.xpc
The resulting target object is tg.
Note If you choose to use this syntax to create a target object, you should use the xPC Target software Explorer to configure your target PC. This ensures that command-line interactions know the correct target PC to work with. |
To delete a target object, use the target object destructor function delete . In the MATLAB window, type
tg.delete
If there are any scopes, file system, or FTP objects still associated with the target, this function removes all those scope objects as well.
You might want to list the target object properties to monitor a target application. The properties include the execution time and the average task execution time.
After you build a target application and target object from a Simulink model, you can list the target object properties. This procedure uses the default target object name tg as an example.
tg
The current target application properties are uploaded to the host PC, and MATLAB displays a list of the target object properties with the updated values.
Note that the target object properties for TimeLog, StateLog, OutputLog, and TETLog are not updated at this time.
+tg
The Status property changes from stopped to running, and the log properties change to Acquiring.
For a list of target object properties with a description, see the target object function get (target application object).
You can change a target object property by using the xPC Target software set method or the dot notation on the host PC. (See User Interaction in the xPC Target Getting Started Guide guide for limitations on target property changes to sample times.)
With the xPC Target software you can use either a function syntax or an object property syntax to change the target object properties. The syntax set(target_object, property_name,new_property_value) can be replaced by
target_object.property_name = new_property_value
For example, to change the stop time mode for the target object tg,
In the MATLAB window, type
tg.stoptime = 1000
Alternatively, you can type
set(tg, 'stoptime', 1000)
When you change a target object property, the new property value is downloaded to the target PC. The xPC Target kernel then receives the information and changes the behavior of the target application.
To get a list of the writable properties, type set(target_object). The build process assigns the default name of the target object to tg.
You can list a property value in the MATLAB window or assign that value to a MATLAB variable. With the xPC Target software you can use either a function syntax or an object property syntax.
The syntax get(target_object, property_name) can be replaced by
target_object.property_name
For example, to access the stop time,
In the MATLAB window, type
endrun = tg.stoptime
Alternatively, you can type
endrun = get(tg,'stoptime') or tg.get('stoptime')To get a list of readable properties, type target_object. Without assignment to a variable, the property values are listed in the MATLAB window.
Signals are not target object properties. To get the value of the Integrator1 signal from the model xpcosc,
In the MATLAB window, type
outputvalue = getsignal (tg,0)
where 0 is the signal index.
Alternatively, you can type
tg.getsignal(0)
Note Method names are case sensitive. You must type the entire name. Property names are not case sensitive. You do not need to type the entire name as long as the characters you do type are unique for the property. |
Use the method syntax to run a target object method. The syntax method_name(target_object, argument_list) can be replaced with
target_object.method_name(argument_list)
Unlike properties, for which partial but unambiguous names are permitted, you must enter method names in full, and in lowercase. For example, to add a scope of type target with a scope index of 1,
In the MATLAB window, type
tg.addscope('target',1) Alternatively, you can type
addscope(tg, 'target', 1)
![]() | Targets and Scopes in the MATLAB Interface | Working with Scope Objects | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |