The software described in this document is furnished under a license agreement. The software may be used
or copied only under the terms of the license agreement. No part of this manual may be photocopied or
reproduced in any form without prior written consent from The MathW orks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation
by, for, or through the federal government of the United States. By accepting delivery of the Program
or Documentation, the government hereby agrees that this software or documentation qualifies as
commercial computer software or commercial computer software documentation as such terms are used
or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and
conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern
theuse,modification,reproduction,release,performance,display,anddisclosureoftheProgramand
Documentation by the federal government (or other entity acquiring for or through the federal government)
and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the
government’s needs or is inconsistent in any respect with federal procurement law, the government agrees
to return the Program and Docu mentation, unused, to The MathWorks, Inc.
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand
names may be trademarks or registered trademarks of their respective holders.
Patents
The MathWorks products are protected by one or more U.S. patents. Please see
www.mathworks.com/patents for more information.
Revision History
September 1999 First printingNew for Version 1 (Release 11.1)
November 2000Online onlyRevised for Version 1.1 (Release 12)
June 2001Online onlyRevised for Version 1.2 (Release 12.1)
September 2001 Online onlyRevised for Version 1.3 (Release 12.1+)
July 2002Online onlyRevised for Version 2 (Release 13)
June 2004Online onlyRevised for Version 2.5 (Release 14)
August 2004Online onlyRevised for Version 2.6 (Release 14+)
October 2004Online onlyRevised for Version 2.6.1 (Release 14SP1)
November 2004Online onlyRevised for Version 2.7 (Release 14SP1+)
March 2005Online onlyRevised for Version 2.7.2 (Release 14SP2)
September 2005 Online onlyRevised for Version 2.8 (Release 14SP3)
March 2006Online onlyRevised for Version 2.9 (Release 2006a)
May 2006Online onlyRevised for Version 3.0 (Release 2006a+)
September 2006 Online onlyRevised for Version 3.1 (Release 2006b)
March 2007Online onlyRevised for Version 3.2 (Release 2007a)
September 2007 Online onlyRevised for Version 3.3 (Release 2007b)
March 2008Online onlyRevised for Version 3.4 (Release 2008a)
October 2008Online onlyRevised for Version 4.0 (Release 2008b)
March 2009Online onlyRevised for Version 4.1 (Release 2009a)
September 2009 Online onlyRevised for Version 4.2 (Release 2009b)
March 2010Online onlyRevised for Version 4.3 (Release 2010a)
Working with Target Objects .......................2-2
Accessing Help for Target Objects
Creating Target Objects
Deleting Target Objects
Displaying Target Object Properties
Setting Target Object Properties from the Host PC
Getting the Value of a Target Object Property
Using the Method Syntax with Target Objects
Working with Scope Objects
Accessing Help for Scope Objects
Displaying Scope Object Properties for a Single Scope
Displaying Scope Object Properties for All Scopes
Setting the Value of a Scope Property
Getting the Value of a Scope Property
Using the Method Syntax with Scope Objects
Acquiring Signal Data with Scopes of Type File
Acquiring Signal Data into Multiple, Dynamically Named
Files with Scopes of Type File
Advanced Data Acquisition Topics
............................2-2
............................2-3
....................2-2
..................2-4
......2-4
..........2-5
..........2-6
........................2-7
.....................2-7
.......2-8
.................2-9
.................2-10
...........2-11
.........2-11
..................... 2-12
.................... 2-14
....2-7
v
Signals and Parameters
3
Monitoring S ignals................................3-2
Introduction
Signal Monitoring with xPC Target Explorer
Signal Monitoring with the MATLAB Interface
Monitoring Stateflow States
......................................3-2
...........3-2
.........3-9
......................... 3-10
Signal Tracing
Introduction
Signal Tracing with xPC Target Explorer
Signal Tracing with the MATLAB Interface
Signal Tracing with xPC Target Scope Blocks
Signal Tracing with Simulink External Mode
Signal Tracing with a Web Browser
Signal Logging
Introduction
Signal Logging with xPC Target Explorer
Signal Logging in the MATLAB Interface
Signal Logging with a Web Browser
Parameter Tuning and Inlining Parameters
Introduction
Parameter Tuning with xPC Target Explorer
Parameter Tuning with the M ATLAB Interface
Parameter Tuning with Simulink External Mode
Parameter Tuning with a W eb Browser
Saving and Reloading Application Parameters with the
Overview
Accessing Files on a Specific Target PC
Listing the Contents of the Target PC Folder
Retrieving a File from the Target PC to the Host PC
Copying a File from the Host PC to the Target PC
Using xpctarget.fs Objects
Overview
Accessing File Systems from a Specific Target PC
Retrieving the Contents of a File from the Target PC to the
Host PC
Removing a File from the Target PC
Getting a List of Open Files on the Target PC
Getting Information about a File on the Target PC
Getting Information about a Disk on the Target PC
........................................9-5
........................................9-9
....................................... 9-11
.......................9-4
.........................9-5
................9-6
...........9-7
.......9-8
..........................9-9
....... 9-10
.................. 9-14
.......... 9-14
.....9-7
...... 9-15
..... 9-16
ix
10
11
Graphical User Interfaces
xPC Target Interface Blocks to Simulink Models .....10-2
Introduction
Simulink User Interface Model
Creating a Custom Graphical Interface
To xPC Target Block
From xPC Target Block
Creating a Target Application Model
Marking Block Parameters
Marking Block Signals
...................................... 10-2
...................... 10-2
................ 10-3
............................... 10-4
............................ 10-5
.................. 10-6
.......................... 10-7
............................. 10-9
xPC Target Web Browser Interface
Web Browser Interface ............................. 11-2
Introduction
Connecting the Web Interface Through TCP/IP
Connecting the Web Interface Through RS-232
Using the Main Pane
Changing WW W Properties
Viewing Signals with a W eb Browser
Viewing Parameters with a Web Browser
Changing Access Levels to the Web Browser
Introduction
xPC Target Kernel Polling Mode
Interrupt Mode
Polling Mode
Setting the Polling Mode
Restrictions Introduced by Polling Mode
...................................... 12-2
..................... 12-2
................................... 12-3
..................................... 12-5
........................... 12-7
............... 12-10
13
Controlling the Target Application ................... 12-13
Polling Mode Performance
Polling Mode and Multicore Processors
.......................... 12-14
................ 12-15
Incorporating Fortran Code into the xPC Target
Environment
Before You Start ................................... 13-2
Introduction
Simulink Demos Folder
Prerequisites
Steps to Incorporate Fortran in the Simulink Software for
xPC Target
...................................... 13-2
............................ 13-2
..................................... 13-3
.................................... 13-3
14
Step-by-Step Example of Fortran and xPC Target
In This Example
Creating an xPC Target Atmosphere Mo del for Fortran
Compiling Fortran Files
Creating a C-MEX Wrapper S-Function
Compiling and Linking the Wrapper S-Function
Validating the Fortran Code and Wrapper S-Function
Preparing the Model for the xPC Target Application
Build
Building and Running the xPC Target Application
Is Your Host PC MATLAB Interface Halted?
Is Your Target PC Unable to Boot?
Is the Target PC Halted?
Communications
Is There Communication Between Your PCs?
Why Does the xPC Target System Lose Connection with the
Host PC When Downloading Some Models?
How Can I Diagnose Network Problems with the xPC
Target System?
..................................... 15-3
..................................... 15-4
........... 15-4
................... 15-4
........................... 15-5
.................................. 15-6
........... 15-6
.......... 15-7
................................. 15-11
xiiContents
Installation, Configuration, and Build
Troubleshooting
Troubleshooting xpctest Results
Troubleshooting B uild Issues
General xPC Target Troubleshooting
General I/O Troubleshooting Guidelines
Can I View the Contents of the Target PC Display on the
Host PC?
................................. 15-12
..................... 15-12
........................ 15-19
................ 15-21
............... 15-21
...................................... 15-22
Why Do Attempts to Run My Model Cause CPU O verload
Messages on the Target PC?
How Can I Obtain PCI Boa rd Information for My xPC
Target System?
What Sample Time Can I Expect from the xPC Target
Software?
WhyIsMyRequestedxPCTargetSampleTimeDifferent
from the Measured Sample Time?
Why Did I Get Error -10: Invalid File ID on the Target
PC?
........................................... 15-30
Can I Write Custom xPC Target Device Drivers?
Can I Create a Stand-Alone xPC Target Application to
Interact with a Target Application?
Can Signal Outputs from Virtual Blocks Be Tagged?
WhyHastheStopTimeChanged?
Why Do I Get a File System Disabled Error?
Can the Target PC Hard Drive Contain M u l tip le
Partitions?
Why Does the getparamid Function Return Nothing?
How Do I Handle Register Rollover for xPC Target Encoder
Blocks?
Why Do I Get Compile Error When Compiling Models?
........................................ 15-33
................................. 15-27
...................................... 15-28
..................................... 15-33
...................... 15-22
.................. 15-28
........ 15-30
................. 15-31
..... 15-31
.................... 15-32
........... 15-32
.... 15-33
... 15-34
16
Getting Updated xPC Target Releases and Help
How to Get Updated xPC Target Releases
Are You Working with a New xPC Target Release?
Refer to the MathWorks Support Web Site
Refer to the Documentation
......................... 15-36
............. 15-35
............. 15-36
...... 15-35
...... 15-35
Target PC Command-Line Interface Reference
Target PC Commands .............................. 16-2
Introduction
Target Object Methods
Target Object Property Comm ands
Scope Object Methods
Scope Object Property Commands
Aliasing with Variable Commands
Before you can work with xPC Target™ target and scope objects, you should
understand the concept of target and scope objects.
• “Target Objects” on page 1-2
• “Scope Objects” on page 1-3
1
1 Target and Scope Objects
Target Objects
What Is a Target Object?
The xPC Targ et software uses a target object (of class xpctarget.xpc)to
represent the target kernel and y our target application. Use target object
functions to run and control real-time applications on the target PC with
scope objects to collect signal data.
See “Function Reference” and “Functions” for a reference of the target
functions.
An understanding of the target object properties and methods will help you to
control and test your application on the target PC.
A target object on the host PC represents the interface to a target application
and the kernel on the target PC. You use target objects to run and control
the target application.
1-2
When you change a target object property on the host PC, information is
exchanged with the target PC and the target application.
To create a target object,
1 Build a target application. The xPC Target software creates a target object
during the build process.
2 Use the target object constructor function xpc. In the MATLAB
window, type
Target objects are of class
properties and methods specific to that object.
tg = xpctarget.xpc.
xpctarget.xpc. A target object has associated
®
Command
Scope Objects
In this section...
“What Is a Scope Object?” on page 1-3
“Scope Object Types” on page 1-4
What Is a Scope Object?
The xPC Target software uses scope objects to represent scopes on the target
PC. Use scope object functions to view and co llect signal data.
See “Function Reference” and “Functions” for a reference of the scope
functions.
Scope Objects
The xPC Target software uses scopes and scope objects as an alternative to
using Simulink
Simulink model system or outside a model system.
• A scope that is part of a Simulink model system is a scope block. You add
an xPC Target scope block to the model, build an application from that
model, and download that application to the target PC.
• A scope that is outside a model is not a scope block. For example, if you
create a scope with the
model system. You add this scope to the model after the model has been
downloaded and initialized.
This difference affects when and how the scope executes to acquire data.
Scope blocks inherit sample times. A scope block in the root model or a normal
subsystem executes at the sample time of its input signals. A scope block in a
conditionally executed (triggered/ enabled) subsystem executes whenever the
containing subsystem executes. Note that in the latter case, the scope might
acquire samples at irregular intervals.
Ascopethatisnotpartofamodelalwaysexecutesatthebasesampletime
of the model. Thus, it might acquire repeated samples. F or example, if the
model base sample time is 0.001, and you add to the scope a signal whose
®
scopes and external mode. A scope can exist as part of a
addscope method,thatscopeisnotpartofa
1-3
1 Target and Scope Objects
sample time is 0.005, the scope will acquire five identical samples for this
signal,andthenthenextfiveidenticalsamples,andsoon.
Understanding the structure of scope objects will help you to use the MATLAB
command-line interface to view and collect signal data.
Refer to Chapter 1, “Target and Scope Objects” for a description of how to use
these objects, properties, and methods.
A scope object on the host PC represents a scope on the target PC. You use
scope objects to observe the signals from your target application during a
real-time run or analyze the data after the run is finished.
Tocreateascopeobject,
• Add an xPC Target scope block to your Simulink model, build the model to
create a scope, and then use the target object method
scope object.
getscope to create a
• Use the target object method
object, and assign the scope properties to the scope object.
A scope object has associated properties and methods specific to that object.
To read about scope object types, see “Scope Object Types” on page 1-4.
addscope to create a scope, create a scope
ScopeObjectTypes
You can create scopes of type target, host,orfile. Upon creation, The
xPC Target software assigns the appropriate scope object data type for the
scope type:
•
xpctarget.xpcsctg for scopes of type target
• xpctarget.xpcschost for scopes of type host
• xpctarget.xpcfs for scopes of type file
• xpctarget.xpcsc encompasses the object properties common to all the
scope object data types. The xPC Target software creates this object if you
create multiple scopes of different types for one model and combine those
scopes, for ex ample, into a scope vector.
1-4
Each scope object type has a group of object properties particular to that
object type.
Scope Objects
1-5
1 Target and Scope Objects
The xpcsctg scope object of type target has the following object properties:
•
Grid
• Mode
• YLimit
The xpcschost scope object of type host has the following object properties:
•
Data
• Time
The xpcfs scope object of type file has the following object properties:
•
AutoRestart
• Filename
• Mode
1-6
• WriteSize
The xpcsc scope object has the following object properties. The other scope
objects have these properties in common:
•
Application
• Decimation
• NumPrePostSamples
• NumSamples
• ScopeID
• Status
• TriggerLevel
• TriggerMode
• TriggerSample
• TriggerScope
• TriggerSignal
• TriggerSlope
• Type
Scope Objects
See the scope object function
object properties.
get (scope object) for a description of these
1-7
1 Target and Scope Objects
1-8
Targets and Scopes in the
MATLAB Interface
You can work with xPC Target target and scope objects through the MATLAB
interface (MATLAB Command Window ), the target PC command line, a
Web browser, or an xPC Target API. This chapter describes how to use the
MATLAB interface to work with the target and scope objects in the following
sections. See Chapter 8, “Using the Target PC Command-Line Interface” for a
description of the target PC command-line interface.
2
• “Working with Target Objects” on page 2-2
• “Working with Scope Objects” on page 2-7
2 Ta r get s a n d S cop e s i n t he MATL AB
®
Interface
Working with Target Objects
In this section...
“Accessing Help for Target Objects” on page 2-2
“Creating Target Objects” on page 2-2
“Deleting Target Objects” on page 2-3
“Displaying Target Object Properties” on page 2-4
“Setting T arget Object Properties from the Host PC” on page 2-4
“Getting the Value of a Target Object Property” on page 2-5
“Using the Method Syntax with Target Objects” on page 2-6
Accessing Help for Target Objects
See “Function Reference” and “Functions” for a reference of the target object
functions.
2-2
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 M ATLA B window on the host PC or use MATLAB code scripts.
To access the 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 Chapter 8, “Using the Target PC Command-Line Interface”.
Creating Target Objects
To create a target object,performthefollowing
1 Build a target application. the xPC Target software creates a target object
during the build process.
2 To create a single target object, or to create multiple target objects in your
system, u se the target object constructor function
as follows. For example, the following creates a target object connected
xpc (see xpctarget.xpc)
Working with Target Objects
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.
3 To check a connection between a host and a target, use the target function
targetping. For example,
tg.targetping
Note To ensure that you always know which target PC is associated with
your target object, you should always use this method to create target
objects.
4 To create a single target object, or to create the first of many targets in
your s ystem , 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 x PC Target software Explorer to configure your target PC. This ensures
that command-line interactions know the correct target PC to work with.
Deleting Target Objects
To dele te 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.
2-3
2 Ta r get s a n d S cop e s i n t he MATL AB
®
Interface
Displaying Targ
You might want to
application. Th
execution time
After you buil
you can list th
target object
1 In the MATLAB
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
and
TETLog are not updated at this time.
2 Type
+tg
The Status property changes from stopped to running,andthelog
properties change to
e p roperties include the execution time and the average task
.
d a target application and target object from a Simulink model,
e target object properties. This procedure uses the default
name
et Object Properties
list the target object properties to monitor a target
tg as an example.
window, type
TimeLog, StateLog, OutputLog,
Acquiring.
2-4
For a list of target object properties with a description, see the target object
function
get (target application object).
Setting Target Object Properties from the Host PC
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 xPCTarget 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
Working with Target Objects
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
process a ssigns the default name of the target object to
set(target_object).Thebuild
tg.
Getting the Value of a Target Object Property
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
target_object.property_name
Forexample,toaccessthestoptime,
• In the MATLAB window, type
• Alternatively, you can type
To get a list of readable properties, type t arge t_object. Without assignment
to a variable, the property values are listed in the MATLAB window.
get(target_object, property_name) can be replaced by
endrun = tg.stoptime
endrun = get(tg,'stoptime') or tg.get('stoptime')
2-5
2 Ta r get s a n d S cop e s i n t he MATL AB
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.
®
Interface
2-6
Using the Method Syntax with Target Objects
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
• In the MATLAB window, type
tg.addscope('target',1)
• Alternatively, you can type
addscope(tg, 'target', 1)
target with a scope index of 1,
Working with Scope Objects
In this section...
“Accessing Help for Scope Objects” on page 2-7
“Displaying Scope Object Properties for a Single Scope” on page 2-7
“Displaying Sco pe Object Properties for All Scopes” on page 2-8
“Setting the Value of a Scope Property” on page 2-9
“Getting the Value of a Scope Property” on page 2-10
“Using the Method Syntax with Scope Objects” on page 2-11
“Acquiring Signal Data with Scopes of Type File” on page 2-11
“Acquiring Signal Data into Multiple, Dynamically Named Files with
Scopes of Type File” on page 2-12
“Advanced Data Acquisition Topics” on page 2-14
Working with Scope Objects
Accessing Help for Scope Objects
See “Function Reference” and “Functions” for a reference of the scope object
functions.
The scope object me tho ds allow you to control scopes on your target PC.
If you want to control the target application from the target PC, use target PC
commands. See Chapter 8, “Using the Target PC Command-Line Interface”.
Displaying Scope Object Properties for a Single Scope
To list the properties of a single scope object, sc1,
1 In the MATLAB window, type
sc1= getscope(tg,1) or sc1 = tg.getscope(1)
MATLAB creates the scope object sc1 from a previously created scope.
2 Type
2-7
2 Ta r get s a n d S cop e s i n t he MATL AB
sc1
The current scope properties are uploaded to the host PC, and then
MATLAB displays a list of the scope object properties with the updated
values. Because
sc1(1) or sc1([1]).
Note Only scopes with type ho st store data in the properties
scope_object.Time and scope_object.Data.
For a list of target object properties with a description, see the target function
get (target application object).
DisplayingScopeObjectPropertiesforAllScopes
To list the properties of all scope objects associated with the target object tg,
®
Interface
sc1 is a vector with a single element, you could also type
2-8
• In the MATLAB window, type
getscope(tg) or tg.getscope
MATLAB displays a list of all scope objects associated with the target
object.
• Alternatively, type
allscopes = getscope(tg)
or
allscopes = tg.getscope
The current scope properties are uploaded to the host PC, and then
MATLAB displays a list of all the scope object properties with the updated
values. To list some of the scopes, use the vector index. For example, to list
the first and third scopes, type
allscopes([1,3]).
For a list of target object properties with a description, see the target function
get (target application object).
Working with Scope Objects
Setting the Value of a Scope Property
With the xPC Target software you can use either a function syntax or an
object property syntax. The syntax
Note that you cannot u se dot notation to set vector object properties. To assign
properties to a vector of scopes, use the
you have a variable
sc12 for two scopes, 1 and 2.TosettheNumSamples
set method. For example, assume
property of the se scopes to 300,
1 In the MATLAB window, type
set(sc12,'NumSamples',300)
To get a list of the writable properties, type set(scope_object).
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.
2-9
2 Ta r get s a n d S cop e s i n t he MATL AB
Getting the Value of a Scope Property
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.
®
Interface
The syntax
scope_object_vector(index_vector).property_name
get(scope_object_vector, property_name) can be replaced by
For exa mple, to assign the number of samples from the scope object sc1,
• In the MATLAB window, type
numsamples = sc1.NumSamples
• Alternatively, you can type
numsamples = get(sc1,'NumSamples')
or
sc1.get(NumSamples)
Note that you cannot use dot notation to get the v alues of vector object
properties. To get properties of a vector of scopes, use the
example, assume you have two scopes,
To get the value of
get(sc12,'NumSamples')
NumSamples for these scopes, in the MATLAB window, type
1 and 2, assigned to the variable sc12.
get method. For
2-10
You get a result like the following:
ans =
[300]
[300]
To get a list of readable properties, type scope_ob ject. The property values
are listed in the MATLAB window.
Working with Scope Objects
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.
Using the Method Syntax with Scope Objects
Use the method syntax to run a scope object method. The syntax
method_name(scope_object_vector, argument_list) can be replaced
Unlike properties, for which partial but unambiguous names are permitted,
enter method names in full, and in lowercase. For example, to add signals to
the first scope in a vector of all scopes,
• In the MATLAB window, type
allscopes(1).addsignal([0,1])
• Alternatively, you can type
addsignal(allscopes(1), [0,1])
Acquiring Signal Data with Scopes of Type File
You can acqu ire signal data into a file on the target PC. To do so, you add
a scope of type
download it to the target PC, you can add a scope of type
application.
For example, to add a scope of type
to add signal
1 In the MATLAB window, type
sc=tg.addscope('file')
The xPC Target software creates a scope of type file for the application.
file to the application. After you build an application and
file to that
file named sc to the application, and
4 to that scope,
2-11
2 Ta r get s a n d S cop e s i n t he MATL AB
2 Type
sc.addsignal(4)
3 To start the scope, type
+sc
4 To start the target application, type
+tg
ThexPCTargetsoftwareaddssignal4tothescopeoftypefile. Whenyou
start the scope and application, the scope saves the signal data for signal 4 to
afile,bydefaultnamed
See “Scope of Type File” on page 3-50 in Chapter 3, “Signals and Parameters”
for a description of scopes of type
If you want to acquire signal data into multiple files, see “Acquiring Signal
Data into Multiple, Dynamically Named Files with Scopes of Type File” on
page 2-12.
®
Interface
C:\data.dat.
file.
2-12
Acquiring Signal Data into Multiple, Dynamically
Named Files with Scopes of Type File
You can acquire signal data into multiple, dynamically named files on the
target PC. For example, you can acquiredataintomultiplefilestoexamine
onefilewhilethescopecontinuestoacquire data into other files. To acquire
data in multiple files, add a scope of type
build an application and download it to the target PC, you can add a scope
of type
file to that application. You can then con f ig ure that scope to log
signal data to multiple files.
For example, configure a scope of type
the following characteristics:
• Logs signal data into up to nine files whose sizes do not exceed 4096 bytes.
• Creates files whose names contain the string
• Contains signal
4.
file to the application. After you
file named sc to the application with
file_.dat.
Working with Scope Objects
1 In the MATLAB window, type
tg.StopTime=-1;
This parameter directs the target application to run indefinitely.
This sequence directs the software to create up to nine log files, f ile_ 1.dat
to file_9.dat onthetargetPCfilesystem.
7 To add signal 4 to the file scope, type
sc.addsignal(4);
8 To start the scope, type
2-13
2 Ta r get s a n d S cop e s i n t he MATL AB
+sc
9 To start the target application, type
+tg
The software creates a log file named file_1.dat and writes data to
that file. When the size of
MaxWriteFileSize), the software closes the file and creates file_2.dat
for writing until its size reaches 4096 bytes. The software repeats this
sequence until it fills the last log file,
continues to run and collect data after
file_1.dat and continues to log data, overwriting the existing contents. It
cycles through the other log files sequentially. If you do not retrieve the
data from existing files before they are overwritten, the data is lost.
If you want to acquire signal data into a single file, see “Acquiring Signal Data
with Scopes of Type File” on page 2-11.
®
Interface
file_1.dat reaches 4096 bytes (value of
file_9.dat. If the target application
file_9.dat, the software reopens
2-14
Advanced Data Acquisition Topics
The moment that an xPC Target scope begins to acquire data is user
configurable. You can have xPC Target scopes acquire data right away, or
define triggers for scopes such that the xPC Target scopes wait until they
are triggered to acquire data. You can configure xPC Target scopes to start
acquiring data when the following scope trigger conditions are met. These
are known as trigger modes.
•
Freerun — Starts to acquire data as soon as the scope is started (default)
Software — Starts to acquire data in response to a user request. You
•
generate a user request when you call the scope method
scope function
Signal — Starts to acquire data when a particular signal has crossed a
•
xPCScSoftwareTrigger.
preset level
•
Scope — Starts to acquire data based on when another (triggering) scope
starts
trigger or the
Working with Scope Objects
You can use several properties to further refine when a scope acquires data.
For example, if you set a scope to trigger on a signal (
Signal trigger mode),
youcanconfigurethescopetospecifythefollowing:
• The signal to trigger the scope (required)
• The trigger level that the signal must cross to trigger the scope to start
acquiring data
• Whether the scope should trigger on a rising signal, falling signal, or either
one
In the following topics, the trigger point is the sample during w hich the scope
trigger condition is satisfied. For signal triggering, the trigger point is the
sample during which the trigger signal passes through the trigger level. At
the trigger point, the scope acquires the first sample. By default, scopes start
acquiring data from the trigger point onwards. You can m od ify this behavior
using the pre- and posttriggering.
• Pretriggering — Starts to acquire data N moments before a trigger occurs
• Posttriggering — Starts to acquire data N moments after a trigger occurs
The
NumPrePostSamples scope property controls the pre- and posttriggering
operation. This property specifies the number of samples to be collected
before or after a trigger event.
• If
NumPrePostSamples is a negative number, the scope is in pretriggering
mode, where it starts collecting samples before the trigger event.
• If
NumPrePostSamples is a positive number, the scope is in a posttriggering
mode, where it starts collecting samples after the trigger event.
The following topics describe two examples of acquiring data:
— Describes a configuration of one scope to trigger another using the
concept of pre- and posttriggering
• “Acquiring Gap-Free Data Using Two Scopes” on page 2-18 — Describes
howtoapplytheconceptoftriggering one scope with another to acquire
gap-free data
2-15
2 Ta r get s a n d S cop e s i n t he MATL AB
Triggering One Scope with Another Scope to Acquire Data
This section describes the concept of triggering one scope with another to
acquire data. The description uses actual scope objects and properties to
describe triggers.
The ability to have one scope trigger another, and to delay retrieving data
from the second after a trigger event o n the first, is most useful when data
acquisition for the second scope is triggered after data acquisition for the
first scope is complete. In the following explanation, Scope 2 is triggered
by Scope 1.
• Assume two scopes objects are configured as a vector with the command
sc = tg.addscope('host', [1 2]);
• For Scope 1, set the following values:
- sc(1).ScopeI d = 1
- sc(1).NumSam ples = N
®
Interface
2-16
- sc1.NumPrePo stSa mples = P
• For Scope 2, set the following values:
- sc(2).ScopeI d = 2
- sc(2).Trigge rMod e = 'Scope'
- sc(2).Trigge rSco pe =1
- sc(2).Trigge rSam ple = range 0 to (N + P - 1)
In the figures below, TP is the trigger point or sample where a trigger event
occurs. Scope 1 begins acquiring data as described.
In the simplest case, where
P=0, Scope 1 acquires data right away.
Working with Scope Objects
Pretriggering (P<0) on page 2-17 illustrates the behavior if P ,thevalueof
NumPrePostSamples, is negative. In this case, Scope 1 starts acquiring data
|P| samples before TP. Scope 2 begins to acquire data only after TP occurs.
Pretriggering (P<0)
Posttriggering (P>0) on page 2-1 7 illustrates the behavior if P,thevalueof
NumPrePostSamples, is positive. In this case, Scope 1 starts acquiring data
|P| samples after TP occurs.
Posttriggering (P>0)
2-17
2 Ta r get s a n d S cop e s i n t he MATL AB
Scope 1 triggers Scope 2 after the trigger event occurs. The following describes
some of the ways you can trigger Scope 2:
•
sc(2).TriggerSample = 0 — Causes Scope 2 to be triggered when Scope 1
is triggered.
sc(2).TriggerSample = n > 0 —CausesTP for Scope 2 to be n samples
•
after
larger than
will never trigg er, since Scope 1 will never acquire more than
samples after TP.
1)
sc(2).TriggerSample = 0 < n < (N + P) — E nables you to obtain
•
some of the functionality that is available with pre- or posttriggering. For
example, if you have the following Scope 1 and Scope 2 settings,
- Scope 1 has sc(1).NumPrePostSamples = 0 (no pre- or posttriggering)
- Scope 2 has sc(2).TriggerSam ple = 10
- Scope 2 has sc(2).NumPrePostSamp le = 0
®
Interface
TP forbothscopesasatthesamesample.
TP for Scope 1. Note that setting sc(2).TriggerSample to a value
(N+P-1)does not cause an error; it implies that Scope 2
(N + P -
2-18
The behavior displayed by Scope 2 is equivalent to having
sc(2).TriggerSample = 0 and sc(2).NumPrePostSamples = 10.
sc(2).TriggerSample = -1 — Causes Scope 2 to start acquiring data
•
fromthesampleafterScope1stopsacquiring.
Note The difference between setting TriggerSample = (N + P - 1),
where
TriggerSample = -1 is that in the former case, the first sample of Scope 2
willbeatthesametimeasthelastsampleofScope1,whereasinthelatter,
thefirstsampleofScope2willbeonesampleafterthelastsampleofScope1.
This means that in the former case both scopes acquire simultaneously for
one sample, and in the latter they will never simultaneously acquire.
N and P are the parameters of the triggering scope (Scope 1) and
Acquiring Gap-Free Data Using Two Scopes
With two s copes, you can acquire gap-free data. Gap-free data is data that two
scopes acquire consecutively, with no overlap. The first scope acquires data
up to N, then stops. The second scope begins to acquire data at N+1. This is
functionality that you cannot achieve through pre- or posttriggering.
Working with Scope Objects
Acquisition of Gap-Free Data on page 2-1 9 graphically illustrates how scopes
trigger one another. In this example, the
set to
'Software'. This allows Scope 1 to be software triggered to acquire
data when it receives the command
TriggerMode property of Scope 1 is
sc1.trigger.
Acquisition of Gap-Free Data
The following procedure describes how you can programmatically acquire
gap-free data with two scopes.
1 Ensure that you have already built and downloaded the Simulink model
xpcosc.mdl to the target PC.
2 In the MATLAB Command Window, assign tg to the target PC and set the
StopTime property to 1. For example,
tg=xpctarget.xpc
tg.StopTime = 1;
3 Add two scopes of type host to the target application. You can assign the
twoscopestoavector,
sc, s o that you can work with both scopes with one
command.
2-19
2 Ta r get s a n d S cop e s i n t he MATL AB
sc = tg.addscope('host', [1 2]);
4 Add the signals of interest (0 and 1) to both scopes.
addsignal(sc,[0 1]);
5 Set the NumSamples property for both scopes to 500 and the Tri ggerSample
property for both scopes to -1. With this property setting, each scope
triggers the next scope at the end of its 500 sample acquisition.
set(sc, 'NumSamples', 500, 'TriggerSample', -1)
6 Set the TriggerMode property for both scopes to 'Scope'.Setthe
TriggerScope property such that each scopeistriggeredbytheother.
7 Set up storage for time, t,andsignal,data acquisition.
®
Interface
2-20
t=[];
data = zeros(0, 2);
8 Start both scopes and the model.
start(sc);
start(tg);
Note that both scopes receive exactly the same signals, 0 and 1.
9 Trigger scope 1 to start acquiring data.
scNum = 1;
sc(scNum).trigger;
Setting scNum to 1 indicates that scope 1 will acquire data first.
10 Start acquiring data using the two scopes to double buffer the data.
while (1)
% Wait until this scope has finished acquiring 50
% or the model stops (scope is interrupted).
0 samples
while ~(strcmp(sc(scNum).Status, 'Finished') || ...
strcmp(sc(scNum).Status, 'Interrupted')), end
% Stop buffering data w hen the model stops.
if strcmp(tg.Status, 'stopped')
break
end
% Save the data.
t(end + 1 : end + 500)= sc(scNum). Time ;
data(end + 1 : end + 500, :) = sc(scNum).Data;
% Restart this scope.
start(sc(scNum));
% Switch to the next scope.
%Shortcut for if(scNum==1) scNum=2;else scNum=1,end
scNum = 3 - scNum;
end
11 When done, remove the scopes.
% Remove the scopes we added.
remscope(tg,[1 2]);
Working with Scope Objects
The following is a complete code listing for the preceding double-buffering data
acquisition p rocedure. You can copy and paste this code into a MATLAB file
and run it after you download the model (
xpcosc.mdl) to the target PC. This
example assumes that the communication speed between the host and target
PC is fast enough to handle the number of samples and can acquire the full
data set before the next acquisition cycles starts. In a similar way, you can use
more than two scopes to implement a triple- or quadruple-buffering scheme.
% Assumes model xpcosc .mdl has been built and loaded on the target PC.
% Attach to the target PC and set StopTime to 1 sec.
tg = xpctarget.xpc;
tg.StopTime = 1;
% Add two host scopes.
sc = tg.addscope('host', [1 2]);
% [0 1] are the signals of interest. Add to both scopes.
addsignal(sc,[0 1]);
% Each scope triggers next scope at end of a 500 sample acquisition.
set(sc, 'NumSamples', 500, 'TriggerSample', -1);
set(sc, 'TriggerMode', 'Scope');
sc(1).TriggerScope = 2;
2-21
2 Ta r get s a n d S cop e s i n t he MATL AB
sc(2).TriggerScope = 1;
% Initialize time and data log.
t= [];
data = zeros(0, 2);
% Start the scopes and the model.
start(sc);
start(tg);
% Start things off by triggering scope 1.
scNum = 1;
sc(scNum).trigger;
% Use the two scopes as a double buffer to log the data.
while (1)
% Wait until this scope has finished acquiring 500 samples
% or the model stops (scope is interrupted).
while ~(strcmp(sc(scNum).Status, 'Finished') || ...
Changing parameters in your target application while it is running in real
time, and checking the results by viewing signal data, are two important
prototyping tasks. The xPC Target software includes command-line and
graphical user interfaces to complete these tasks. This chapter includes the
following sections:
• “Monitoring Signals” on page 3-2
• “Signal Tracing” on page 3-15
• “Signal Logging” on page 3-56
3
• “Parameter Tuning and Inlining Parameters” on page 3-65
• “Nonobservable Signals and Parameters” on page 3-85
3 Signals and Parameters
Monitoring Signals
In this section...
“Introduction” on page 3-2
“Signal Monitoring with xPC Target Explo rer” on page 3-2
“Signal Monitoring with the MATLAB Interface” on page 3-9
“Monitoring Stateflow States” on page 3-10
Introduction
Signal monitoring is the process for acquiring signal data during a real-time
run w ithout time information. The advantage with signal monitoring is that
there is no additional load on the real-time tasks. Use signal m onito ring to
acquire signal data without creating scopes that run on the target PC.
In addition to signal monitoring, the xPC Target software enables you to
monitor Stateflow
and MATLAB command-line interfaces. You designate data or a state in a
Stateflow diagram as a test point. This makes it observable during execution.
See the Stateflow and Stateflow
can work with Stateflow states as you do with xPC Target signals, such as
monitoring or plotting Stateflow states.
After you start running a target application, you can use signal monitoring to
get signal data.
Note xPC Target Explorer works with multidimensional signals in
column-major format.
®
states as test points through the xPC Target Explorer
®
Coder™ User’s Guide for details. You
Signal Monitoring with xPC Target Explorer
This procedure uses the model xpcosc.mdl as an example, and assumes
you created and downloaded the target application to the target PC. For
meaningful values, the target application should be running.
3-2
Monitoring Signals
1 If xPC Target Explorer is not started, start it now. In xPC Target
Explorer, select the node of the running target application in which you
are interested, for example,
xpcosc.
The target PC Target Application Properties pane a ppears.
2 In the Solver pane, change the Stop time parameter to inf (infinity).
Click Apply.
3 To get the list of signals in the target application, expand the target
application node, then expand the
Model Hierarchy node under the target
application node.
3-3
3 Signals and Parameters
The model hierarchy expands to show the Simulink objects (signals and
parameters) in the Simulink model.
3-4
The Model Hierarchy node can have the following types of nodes:
Monitoring Signals
Icons
Nodes
Subsystems, including their signals and parameter
Referenced models, including their signals set as test points
Parameters
Signals
Stateflow states set as test points
Only xPC Target tunable parameters and signals of the application, as
represented in the Simulink model, appear in the
Model Hierarchy node.
Note This example currently has only parameters and signals. If a block
has a name that consists of only spaces, xPC Target Explorer does not
display a node for that block. To monitor a signal from that block, provide
an alphanumeric name for that block and rebuild and download that block.
If you make changes (such as adding an xPC Target scope) to the model
associated with the downloaded application, then rebuild that model and
download it again to the target PC, you should reconnect to the target PC
to refresh the
Model Hierarchy node.
4 To vie
signa
a Open t
b Righ
the o
c Buil
d Whe
the
Thi
yo
w only labeled signals (the xPC Target software refers to Simulink
l names as signal labels) :
he
xpcosc.mdl file.
t-click a signal line and name that signal. For example, right-click
utput of the Signal Generator block and name it
SignalG.
d and download the updated model.
n the updated model is displayed in xPC Target Explorer, right-click
Model Hierarchy node and select View Only Labeled Signals.
s command assumes that you have labeled one or more signals in
ur model.
3-5
3 Signals and Parameters
e Re-expand the Model Hierarchy no de to see the labeled sign al s .
To view the blo ck path for a labeled signa l, hover over the l abeled signal.
For example,
3-6
To display all the model signals again, right-click the Model Hierarchy
node and select View All Signals. You can still view the signal label by
hovering over the labeled signal. For example,
Note When working with si gn a l labels:
Monitoring Signals
• Signal labels must be unique.
• xPC Target software ignores signal labels in referenced models.
f Return to the model, remove the signal name y ou added, and rebuild and
download the target application. The remaining examples in this section
assume that you do not have any labelled signals in your model.
5 To go to the corresponding Simulink model subsystem, right-click the
application node and select Go to Simulink
6 To get the value of a signal, select the signal in the Model Hierarchy node.
subsystem or block.
3-7
3 Signals and Parameters
The value of the signal is shown in the right pane.
3-8
7 Right-click the target application and select Start.
The application starts running.
8 To change the numeric format display of the signal, right-click the Model
Hierarchy
The D isplay Format String dialog box is displayed.
node and select Edit Signals F ormat String.
Monitoring Signals
9 Enter the signal format. Use one of the following. By default, the format is
%0.25g.
TypeDescri ption
%e or %E
%f
%g
Exponential format using e or E
Floating point
Signed value printed in f or e format depending on
which is smaller
%G
Signed value printed in f or E format depending on
which is smaller
Monitoring Signals from Referenced Models
You can monitor signals from referenced models the same way that you do
any o the r signal, with the exception that you must set the test point for the
signal in the referenced model before you can monitor it. Additionally, the
software ignores signal labels in referenced models.
Signal Monitoring with the MATLAB Interface
This procedure uses the model xpc_osc3.mdl as an example, and assumes
you created and downloaded the target application to the target PC. It also
assumes that you have assigned
1 To get a list of signals, type either
set(tg, 'ShowSignals', 'On')
or
tg.ShowSignals='On'
tg to the appropriate target PC.
3-9
3 Signals and Parameters
ThelattercommandcausestheMATLABwindowtodisplayalistofthe
target object properties for the available signals. For example, the signals
for the model
xpc_osc3.mdl are shown below. Note that the Label column
is em pty because there are no labelled signals in the model. If your signal
has a unique label, its label is displayed in this column. If the label is not
unique, the command returns an error. If the signal label is in a referenced
model, the software ignores it.
ShowSignals = on
Signals = INDEXVALUEBLOCK NAMELABEL
00.000000Signal Generator
10.000000Transfer Fcn
2 To get the value of a signal, use the getsignal method. In the MATLAB
Command Window, type
tg.getsignal(0)
where 0 is the signal index. the MATLAB interface displays the value
of signal
1.
3-10
ans=
3.731
Note The xPC Target software lists referenced model signals with their full
block path. For example,
xpc_osc5/childmodel/gain.
See also “Signal Tracing with the MATLAB Interface” on page 3-39.
Monitoring Stateflow States
This procedure uses the model old_sf_car.mdl as an example. It describes
one way to set Stateflow states as test points for monitoring.
1 In the MATLAB window, type
old_sf_car
2 In the Simulink window, click Simulation > Configuration Parameters.
Monitoring Signals
The Configuration Parameters dialog box is displayed for the model.
3 Click the Real-Time Workshop node.
The Real-Time Workshop pane opens.
4 To build a basic target application, in the Target selection section, click
the Browse button at the System targ et file list. Click
xpctarget.tlc,
then click OK.
5 As necessary, you can click the xPC Target options node and continue to
make changes.
6 When you are done, click OK.
3-11
3 Signals and Parameters
7 In the old_sf_car model, double-click the shift_logic chart.
The
shift_logic chart is displayed .
3-12
8 In the chart, click Tools > Explore.
The Model Explorer is displayed.
9 In the Model Explorer, expand old_sf_car.
10 Expand shift_logic.
11 Expand gear_state, then select first.
12 In the rightmost pane, State first, select the Test point check box. This
creates a test point for the
first state.
Monitoring Signals
13 Click Apply.
14 Build and download the old_sf _car target application to the target PC.
You can now view the states wi th xPC Target Explorer or the MATLAB
interface.
Monitoring Stateflow States with xPC Target Explorer
This topic assumes that you have already set Stateflow states as test points
(see “Monitoring Stateflow States” on page 3-10 if you have not).
1 If the xPC Target Explorer is not yet started, start it now and connect it to
thetargetPCthathasthedownloaded
2 To view the test point in the xPC Target Explore r, expand the
Model Hierarchy node and navigate to shift_logic.Thetestpoint
gear_state.first appears like any other signal in the hierarchy, as
follows:
old_sf_car target application.
3 Choose the state as you do a signal to monitor.
3-13
3 Signals and Parameters
Monitoring Stateflow States with the MATLAB Interface
This topic assumes that you have already set Stateflow states as test points
(see “Monitoring Stateflow States” on page 3-10 if you have not).
1 To get a list of signals in the MATLAB Command Window , type
tg=xpc
2 To display the signals in the target application, type either
set(tg, 'ShowSignals', 'On'); tg
or
tg.ShowSignals='On'
The latter causes the MATLAB window to display a list of the target object
properties for the available signals.
3-14
For Stateflow states that you have set as test points, the state appears
in the
point for the
old_sf_car model, the state of interest is first. This state appears as
BLOCK NAME column like any signal. For example, if you set a test
first state of gear_state in the shift_logic chart of the
follows in the list of signals in the MATLAB interface:
shift_logic:gear_state.first
shift_logic
isthepathtotheStateflowchartandgear_state.first is
thepathtothespecificstate.
Signal Tracing
In this section...
“Introduction” on page 3-15
“Signal Tracing with xPC Target Explorer” on page 3-15
“Signal Tracing with the MATLAB Interface” on page 3-39
“Signal Tracing with xPC Target Scope Blocks” on page 3-48
“Signal Tracing with Simulink External Mode” on page 3-50
“Signal Tracing with a Web Browser” on page 3-54
Introduction
Signal tracing is the process of acquiring and visualizing signals while
running a target application. In its most basic sense, allows you to acquire
signal data and visualize it on the target PC or upload the signal data and
visualize it on the host PC while the target application is running.
Signal Tracing
Signal tracing differs from signal logging. Wi th signal logging you can only
look at signals after a run is finished and the log of the entire run is available.
For i nfo r m ation on signal logging, see “Signal Logging” on page 3-56.
Note xPC Target Explorer works with multidimensional signals in
column-major format.
Signal Tracing with xPC Target Explorer
The procedures in this topic use the model xpcosc.mdl as an example, and
assume you have created, downloaded, and started the target application
on the target PC.
• “Creating Scopes” on page 3-16
• “Adding Signals to Scopes” on page 3-23
• “Stopping Scopes” on page 3-27
3-15
3 Signals and Parameters
• “Software Triggering Scopes” on page 3-28
• “Configuring the Host Scope Viewer” on page 3-30
• “Acquiring Signal Data into Multiple, Dynamically Named Files on the
Target PC” on page 3-30
• “Copying Files to the Host PC” on page 3-34
• “Exporting Data from File Scopes to MATLAB Workspace” on page 3-35
• “Saving and Reloading xPC Target Application Sessions” on page 3-37
• “Deleting Files from the Target PC” on page 3-39
You can add or remove signals from target or host scopes while the scope is
either stopped or running. For file scopes, you must stop the scope first before
adding or removing signals.
Creating Scopes
1 In xPC Target Explorer, ensure that your xpcosc application is still
running.
3-16
2 To get the list of signals in the target application, expand the Model
Hierarchy
node under the target application.
Signal Tracing
The model hierarchy expands to show the elements in the Simulink model.
3 To get the list of scope types yo u can have in the target app lica tion, expand
the
xPC Scopes node below the application node.
The
xPC Scopes node expands to show the possible scope types a target
A context menu appears. This lists the actions you can perform on target
PC scopes. For example, within the current context, you can create a
target PC scope.
5 Select Add Target Scope.
pe node appears under
Asco
pe is labeled
sco
Scope 1.
Target Scopes. In this example, the new
Signal Tracing
You can add oth
can add as many
PC resources c
6 To create a scope to be displayed on the host PC, right-click the Host
Scopes
node under the xPC Scopes node.
er scopes, including those of type
file and host scopes as you want. as long as your target
an support them.
host and file.Note,you
A context menu appears. This lists the actions you can perform on host PC
scopes. For example, within the curre nt context, you can create a host
PC scope.
7 Select Add Host Scope.
A scope node appears under
is labeled as
8 To visualize the host scope on the host PC, right-click Host Scopes from
the
xPC Scopes node.
Scope 2.
Host Scopes. In this example, the new scope
A drop-down list appears.
3-19
3 Signals and Parameters
9 Select View Scopes.
The xPC Target Host Scope Viewer window appears. Note that the signals
you add to the scope will appear at the top right of the viewer.
3-20
10 To list the properties of the scope object Scope 2, click the xPC Target
Explorer tab to return to that window, and left-click
you can configure the docking view using the MATLAB docking feature.)
The scope properties are shown in the rightmost pane.
Scope 2. (Note that
Signal Tracing
11 To create a scope to acquire signal data into a file on the target PC file
system, right-click the
File Scopes node under the xPC Scopes node.
Select Add File Scope.
A scope node appears under
is labeled
Scope 3.
File Scopes. In this example, the new scope
By default, the software creates a file in the target PC C:\ folder. The
nameofthefiletypicallyconsistsofthescopeobjectname,
ScopeId,and
the beginning letters of the first signal added to the scope.
3-21
3 Signals and Parameters
12 If you want to specify a different folder or filename, select the scope.
The scope property pane is displayed. In the File name field, enter the
full pathname for the file. Note that the current folder for the target PC
appears at the to p of the pane.
3-22
Signal Tracing
Your next task is to add signals to the scopes. The following procedure
assumes that you have added scopes to the target PC and host PC.
Adding Signals to Scopes
This topic describes how to add signals using the xPC Target Explorer Add
to Scopes command. If a scope does not exist, you can drag a signal to a
Host Scope, Target Scope, or File Scope icon to create a scope of that type in
xPC Target Explorer.
1 In the xPC Target Explorer window, add signals to the target PC scope,
Scope 1. For example, to add signals Integrator1 and Signal Generator,
right-click each signal and select Add to Scopes.FromtheAdd to
Scopes list, select
scopetoaddthesignaltothatscope.)
The
Scope 1 node is shown with a plus sign.
Scope 1. (Note that you can also drag the signal to the
2 Expand the Scope 1 node.
Scope 1 signals are displayed.
The
If one of the signals has been labeled. you can hover over the signal to
display the signal la bel. For example,
3-23
3 Signals and Parameters
3 Start the scop
Start.
e. For example, to start
Scope 1, right-click it and select
3-24
Signal Tracing
The target screen plots the signals after collecting each data package.
During this time, you can observe the behavior of the signals while the
scope is running.
4 Add si
5 Expand the Scope 2 node.
gnals to the host PC scope. For example, to add signals
and Si
From t
asign
The
The
gnal Generator
he Add to Scopes list, select
al from one scope to another to add that signal to another scope.)
Scope 2 node is shown with a plus sign.
Scope 2 signals are displayed.
, right-click each signal and select Add to Scopes.
Integrator1
Scope 2. (Note that you can also drag
3-25
3 Signals and Parameters
6 Start the scope. For example, to start the scope Sco pe 2, right-click Scope
2 in the
The xPC Target Host Scope V i ew e r window plots the signals after collecting
each data package. During this time, you can observe the behavior of the
signals while the scope is running.
Host Scopes node of the xPC Target Explorer and select Start.
3-26
Signal Tracing
7 Add signals to the scope of type file. For example, to add signals
Integrator1 and Signal Generator, right-click each signal and select
Add to Scopes.FromtheAdd to Scopes list, select
Scope 3. (Note that
you can also drag a signal from one scope to another to add that signal to
another scope.)
The
Scope 3 node is shown with a plus sign.
8 Expand the Scope 3 node.
Scope 3 signals are displayed.
The
9 To specify a filename for the data file, select the scope of type file.In
the right pane, enter a name in the Filename parameter. While in the
parameter field, press Enter to save the filename.
Note that there is no name initially assigned. If you do not s pecify a
filename, then after you start the scope, the software assigns a name for
thetargetPCfiletoacquirethesignaldata. Thisnametypicallyconsists
of the scope object name,
ScopeId, and the beginning letters of the first
signal added to the scope.
10 Start the scope. For example, to start the scope Scope 3, right-click Scope
3 in the
File Scopes node of the xPC Target Explorer and select Start.
For file scopes, the xPC Target software saves data to a file on the target
PC flash disk.
Your next task is to stop the scopes. The following procedure assumes that
you have started scopes.
Stopping Scopes
1 Stopthescopes. Forexample,tostopScope 1, right-click it and select
Stop.
3-27
3 Signals and Parameters
The signals shown on the target PC stop updating while the target
application continues running, and the target PC displays the following
message:
Scope: 1, set to state 'interrupted'
2 Stop the target application. For example, to stop the target application
xpcosc, right-click xpcosc and select Stop.
The target application on the target PC stops running, and the target PC
displays the following messages:
minimal TET: 0.0000006 at time 0.001250
maximal TET: 0.0000013 at time 75.405 500
Note that if you stop the target application before stopping the scope, the
scope stops, too.
Ifyouhavefilescopes,youcancopythefilethatcontainsthesignaldatafrom
the target PC to the host PC. See “Copying Files to the Host PC” on page 3-34.
3-28
Software Triggering Scopes
You can set up a scope such that only a user can trigger the scope. This
section assumes that you have added a scope to your target application (see
“Creating Scopes” on page 3-16) and that you have added signals to that scope
(see “Adding Signals to Scopes” on page 3-23).
1 In the xPC Target Explorer window, select the scope that you want to
trigger by software. For example, select
The properties pane for that scope is displayed.
Scope 1.
2 From the Trigger mode list, select Software.ClickApply.
Signal Tracing
3 Start the scope and target application.
4 Obse
5 Right-click the scope to be triggered. For example, select Scope 1.
6 Select Trigger.
7 Obs
rvethatthescopehasnoplotteddata.
erve that the scope now has plotted data.
3-29
3 Signals and Parameters
Configuring the Host Scope Viewer
You can customize your host sco pe viewer. This section assumes that
you have added a host scope to your target application, started the host
scope viewer, and added signals
“Creating S co pe s” on page 3-16 and “Adding Signals to Scopes” on page 3-23).
These viewer settings are per scope.
In the xPC Target Host Scope Viewer, right-click anywhere in the axis area of
the viewer.
A context menu is displayed. This context menu contains options for the
following:
•
View Mode —SelectGraphical for a graphical display of the data. Select
Numerical for a numeric representation of the data.
Legends — Select and desele ct this option to toggle the display of the
•
signals legend in the top right of the viewer.
•
Grid — Select and deselect this option to toggle the display of grid lines in
the viewer.
Integrator1 and Signal Generator (see
3-30
•
Y-Axis — Enter the desired values. In the Enter Y maximum limit and
Enter Y minimum limit text boxes, enter the range for the y-axis in the
Scope window.
•
Export — Select the data to export. Select Export Variable Names
to export scope data names. In the Data Variable Name and Time
Variable Name text boxes, enter the names of the MATLAB variables to
save data from a trace. Click the OK button. The default name for the data
variable is
variable is
Select Export Scope Data to export scope data to the MATLAB interface.
application_name_scn_data, and the default name for the time
application_name_scn_time where n is the scope number.
Acquiring Signal Data into Multiple, Dynamically Named Files
on the Target PC
You can acquire signal data into multiple, dynamically named files on the
target PC. For example, you can acquiredataintomultiplefilestoexamine
onefilewhilethescopecontinuestoacquire data into other files. To acquire
data in multip l e files, add a scope of type file to the a pplication. After you
build an application and download it to the target PC, you can add a scope
Signal Tracing
of type file to that application. You can then configure that scope to log
signal data to multiple files. This section assumes that you have added a
scopetoyourtargetapplication(see“CreatingScopes”onpage3-16). Italso
assumes that you have added signals to that scope (see “Adding Signals to
Scopes” on page 3-23).
1 In xPC Targe t Explorer, expand the target PC node associated with the
target PC file system you want to access. For example, expand
2 Under TargetPC1, expand the target application node and navigate to the
File Scope(s) node.
3 Right-click this node and add a file scope.
4 Add one or more scopes to that file scope. For example, add Integrator1
TargetPC1.
and Signal Generator to the scope.
5 Right-click the scope you just added (for example, Scope:1). The scope
This sequence directs the software to create up to nine log files,
to file_9.dat, on the target PC file system.
file_<%>.dat.
file_1.dat
7 Select the Enable auto restart check box. The Enable file auto
increment check box is enabled.
8 Select the Enable file auto increment check box.
9 In the Max file size box,enteravaluetolimitthesizeofthesignallog
files. For example, to limit each log file s ize to 4096 bytes, enter
4096.
This value must be a multiple of the Write size value.
10 Click A pply. Thesavedvaluesappearasfollows:
Signal Tracing
11 Right-click the new file scope and select Start.
12 Start the associated target application.
The software creates a log file named
file. When the size of
file_1.dat reaches 4096 bytes (value of Max file
size), the software closes the file. It then creates
file_1.dat and writes data to that
file_2.dat for writing
until its size reaches 40 96 b ytes. The software repeats this s eq uence until it
fills the last log file,
and collect data after
file_9.dat. If the target application continues to run
file_9.dat, the software reopens file_1.dat and
continues to log data, overwriting the existing contents. It cycles through the
other log files sequentially.
3-33
3 Signals and Parameters
You can enable the creation of up to 99999999 files (<%%%%%%%%>.dat). The
length of a file name, including the specifier, cannot exceed eight characters.
See the Filename descriptioninthe
get (target application object) for
a details about this specif ier.
Copying Files to the Host PC
From xPC Target Explorer, you can download target PC files from the target
PC to the host PC.
1 In xPC Targe t Explorer, expand the target PC node associated with the
target PC file system you want to access. For example, expand
2 Under TargetPC1,expandtheFile System node.
Nodes representing the drives on the target PC are displayed.
4 Select the fold er that contains the file you want. For example, select the
node labeled
local disk:c: \.
The contents of that folder are displayed in the right pane.
5 In the right pane, right-click the file you want to copy to the host PC. For
example, right-click
SC3SIGNA.DAT.
A context-sensitive menu is displayed.
6 Select Save to Host PC .
Signal Tracing
A browser dialog box is displayed.
7 Choose the folder to contain the signal data file. If you want, you can also
save the file under a different name or create a new folder for the file.
xPC Target Explorer copies the contents of the selected file,
SC1INTEG.DAT
for example, to t h e selected folder.
You can examine the contents of the signal data file. See “Retrieving a File
fromtheTargetPCtotheHostPC”onpage9-7inChapter9,“Workingwith
Target PC Files and File Systems”.
Exporting Data from File Scopes to MATLAB Workspace
From xPC Target Explorer, you can export data from target PC files from the
target PC to the MATLAB workspace. This topic assumes that you have
3-35
3 Signals and Parameters
created a scope of type file that contains signal data (see “Adding Signals to
Scopes” on page 3-23).
1 In xPC Targe t Explorer, expand the target PC node associated with the
target PC file system you want to access. For example, expand
2 Under TargetPC1, find the target application and ensure that it is not
5 Enter a variable name for the workspace data. For example, enter
sig_integ.ClickOK.
he M ATLAB desktop, the Workspace pane displays the new variable
In t
e.
nam
Signal Tracing
You can examine and otherwise manipulate the data. You can also plot the
data with
plot(sig_integ.data). This is an alternate method to “Retrieving
the Contents of a File from the TargetPCtotheHostPC”onpage9-11in
Chapter 9, “Working with Target PC Files and File Systems”.
Saving and R
eloading xPC Target Application Sessions
Once you have a set of application configurations, you can save the xPC
Target application session, including scope and target PC settings, to a
standard MATLAB MAT-file on the host PC. You can then later reload this
saved session to another xPC Target application session. This feature lets you
save and restore xPC Target application sessions so that you do not have to
reconfigure target PC and target application settings each time you start
xPC Target Explorer.
To save a sessio n,
1 Ensure that xPC Target Explo rer is connected to a target PC.
2 In xPC T
3 In xPC Target Explorer, right-click the target PC you are interested in and
arget Explorer, load a target application on the target PC.
select Save Session. For example,
3-37
3 Signals and Parameters
A Save Targ
4 As necessary, browse to the desired folderandenterauniquename. For
example,
et Session as dialog box i s displayed.
xpcsession1.mat.
To restore a s ession,
1 Ensure that xPC Target Explo rer is connected to a target PC.
2 In xPC Target Explorer, load a target application on the target PC. This
target application must be the same target applic ati on for which the
session was saved.
3 In xPC
selec
Target Explorer, right-click the target PC you are interested in and
t Load Session. For example,
3-38
Signal Tracing
A Load Target Session as dialog box is displayed.
4 As necessary, browse to the desired folder and select the session you are
interested in. For example,
xpcsession1.mat.
Adialog
new sess
5 Click Yes.
xPC Target Explorer loads the saved settings.
Delet
From xPC Target Explorer on the host PC, you can d elete the scope data
fileonthetargetPCfilesystem. Usethesameprocedureasdescribedin
“Copying Files to the Host PC” on page 3-34, but select Delete instead of
Save to Host PC. xPC Target Explorer removes the selected file from the
target PC file system.
box is displayed asking you to confirm that you want to load a
ion.
ing Files from the Target PC
Signal Tracing with the MATLAB Interface
Creating a scope object allows you to select and view signals using the scope
methods. This section describes how to trace signals using xPC Target
3-39
3 Signals and Parameters
functions instead of using the xPC Target graphical user interface. This
procedure assumes that you have assigned
tg to the appropriate target PC.
After you create and download the target application, you can view output
signals.
Using the MATLAB interface, you can trace signals with
• Host or target scopes (see “Signal Tracing with the MATLAB Interface and
Target Scopes” on page 3-40 for a description of with target scopes)
• File scopes (see “Signal Tracing with the MATLAB Interface and File
Scopes” on page 3-44)
You must stop the scope before adding or removing signals from the scope.
Signal Tracing with the MATLAB Interface and Target Scopes
This procedure uses the Simulink model xpcosc.mdl as an example, and
assumes you have built the target application for this model. It describes how
to trace signals with target scopes.
3-40
1 Start running your target application. Type any of
+tg
or
tg.start
or
start(tg)
The target PC displays the following message.
System: execution started (sample tim e: 0.0000250)
2 To get a list of signals, type either
set(tg, 'ShowSignals', 'on')
or
Signal Tracing
tg.ShowSignals='on'
The MATLAB window displays a list of the target object properties for
the a vailable signals. For example, the signals for the model
NumSamples= 250
NumPrePostSamples= 0
Decimation= 1
TriggerMode= FreeRun
TriggerSignal= -1
TriggerLevel= 0.000000
TriggerSlope= Either
TriggerScope= 1
TriggerSample= -1
Mode= Redraw (Graphical)
YLimit= Auto
Grid= On
Signals= no Signals defined
5 Add signals to the scope object. For example, to add Integrator1 and
Signal Generator,type
sc1.addsignal ([0,1])
or
3-42
addsignal(sc1,[0,1])
The target PC displays the following messages.
Scope: 1, signal 0 added
Scope: 1, signal 1 added
After you add signals to a scope object, the signals are not shown on the
target screen until you start the scope.
6 Start the scope. For example, to start the scope sc1,typeeither
+sc1
or
sc1.start
or
start(sc1)
The target screen plots the signals after collecting each data package.
During this time, you can observe the behavior of the signals while the
scope is running.
7 Stop the scope. Type either
-sc1
or
sc1.stop
or
stop(sc1)
The signals shown on the target PC stop updating while the target
application continues running, and the target PC displays the following
message.
Signal Tracing
Scope: 1, set to state 'interrupted'
8 Stop the target application. In the MATLAB window, type either
-tg
or
tg.stop
or
stop(tg)
The target application on the target PC stops running, and the target PC
displays the following messages.
minimal TET: 0.000023 at time 1313.7 8900 0
maximal TET: 0.000034 at t ime 407.956000
3-43
3 Signals and Parameters
Signal Tracing with the MATLAB Interface and File Scopes
This procedure uses the Simulink model xpcosc.mdl as an example, and
assumes you have built the target application for this model. It also assumes
that you have a serial communication connection. Thistopicdescribeshowto
trace signals w ith file scopes .
Note The signal data file can quickly increase in size. You should examine
thefilesizebetweenrunstogaugethegrowthrateofthefile.Ifthesignal
data file grows beyond the available space on the disk, the signal data might
be corrupted.
1 Create an xPC Target application that works with file scopes. Type
tg=xpctarget.xpc('rs232', 'COM1', '115200')
2 To get a list of signals, type either
set(tg, 'ShowSignals', 'on')
3-44
or
tg.ShowSignals='on'
The MATLAB window displays a list of the target object properties for
the a vailable signals. For example, the signals for the model
TriggerScope= 2
TriggerSample= 0
TriggerSignal= -1
TriggerLevel= 0.000000
TriggerSlope= Either
ShowSignals= off
FileName= unset
Mode= Lazy
WriteSize= 512
AutoRestart= off
DynamicFileName= off
MaxWriteFileSize= 536870912
Note that there is no name initially assigned to FileName.Afteryoustart
the scope, xPC Target as signs a name for the file to acquire the signal data.
This name typically consists of the scope object name,
ScopeId,andthe
beginning letters of the first signal added to the scope.
6 Add signals to the scope object. For example, to add Integrator1 and
Signal Generator,type
3-46
sc2.addsignal ([4,5])
or
addsignal(sc2,[4,5])
The target PC displays the following messages.
Scope: 2, signal 4 added
Scope: 2, signal 5 added
After you add signals to a scope object, the scope of type file does not
acquire signals until you start the scope.
7 Start the scope. For example, to start the scope sc2,type
+sc2
or
sc2.start
Signal Tracing
or
start(sc2)
The MATLAB window displays a list of the scope object properties. Notice
that
FileName is assigned a default filename to contain the signa l data for
the scope of type
name,
ScopeId, and the beginning letters of the first signal added to the
file. This name typically consists of the scope object
5: Signal Generator
FileName= c:\sc7Integ.dat
Mode= Lazy
WriteSize= 512
AutoRestart= off
DynamicFileName= off
MaxWriteFileSize= 536870912
8 Stop the scope. Type
-sc2
or
sc2.stop
or
3-47
3 Signals and Parameters
stop(sc2)
9 Stop the target application. In the MATLAB window, type
-tg
or
tg.stop
or
stop(tg)
The target application on the target PC stops running, and the target PC
displays messages similar to the following.
minimal TET: 0.00006 at t ime 0.004250
maximal TET: 0.000037 at t ime 14.255250
3-48
To access the contents of the signal data file that the xPC Target scope of type
file creates, use the xPC Target file system object (xpctarget.fs)fromthe
host PC MATLAB window. To view or examine the signal data, you can use
the
readxpcfile utility with the plot function. For further details on the
xpctarget.fs file system object and the readxpcfile utility, see Chapter 9,
“Working with Target PC Files and File Systems”.
Signal Tracing with xPC Target Scope Blocks
Use host scopes to log signal data triggered by an event while your target
application is running. This topic describes how to use the three scope block
types.
Note xPC Target supports ten target scopes. It can support an infinite
number of host scopes, as long as the target PC resources can support them.
It can support eight file scopes. Each scope of type
10 signals. Each scope of type
file or host can contain an infinite number of
signals, as long as the target PC resources can support them.
target can contain up to
Signal Tracing
Note If your model has the output of a Mux block connected to the input of
an xPC Target Scope block, the signal might not be observable. To ensure that
you can observe the signal, add a unity gain block (a Gain block with a gain of
1) between the Mux block and the xPC Target Scope block.
Using xPC Target Scope Blocks from Referenced Models
You cannot add any type of xPC Target scope to a referenced model. Doing
so causes an error. You can add only an xPC Target scope to the topmost
model. If you want to log signals from referenced models, you can do so with
the logging mechanism in xPC Target Explorer or with the xPC Target scope
objects.
Scope of Type Host
For a scope of type host, the scope acquires the first N samples into a buffer.
You can retrieve this buffer into the scope object property
then stops and waits for you to manually restart the scope.
sc.Data.Thescope
The number of samples
N to log after triggering an event is equal to the value
you entered in the Number of Samples parameter.
SelectthetypeofeventintheBlockParameters: Scope (xPC Target) dialog
boxbysettingTrigger Mode to
or
Scope Triggering.
Signal Triggering, Software Triggering,
ScopeofTypeTarget
For a scope of type target,loggeddata(sc.Data and sc.Time)isnot
accessible over the command-line interface on the host PC. This is because
the scope object status (
completes one data cycle (time to collect the number of samples), the sco pe
engine automatically restarts the scope.
If y ou create a scope object, for example,
of type
target, and then try to get the logged data by typing sc.Data,you
get an error message:
Scope # 1 is of type 'Target'! Property Data is not accessible.
sc.Status)isneversettoFinished. Once the scope
sc = getscopes(tg,1) for a scope
3-49
3 Signals and Parameters
If you want the same data for the same signals on the host PC while the data
is displayed on the target PC, you need to define a second scope object with
type
host. Then you need to synchronize the acquisitions of the two scope
objects by setting TriggerMode for the second scope to
'Scope'.
Scope of Type File
For a scope of type file, the scope acquires data and writes it to the file
named in the FileName parameter in blocks of size WriteSize.Thescope
acquires the first
of length Number of Samples. The memory buffer writes data to the file
in WriteSize chunks. If the AutoRestart check box is selected, the scope
then starts over again, overwriting the memory buffer. The additional data
is appended to the end of the existing file. If the AutoRestart box is not
selected, the scope collects data only up to the number of samples, and then
stops. The number of samples
value you entered in the Number of Samples parameter. If you stop, then
start the scope again, the data in the file is o verwritten with the new data.
SelectthetypeofeventintheBlockParameters: Scope (xPC Target) dialog
boxbysettingTrigger Mode to
or
Scope Triggering.
N samples into the memory buffer. This memory buffer is
N to log after triggering an event is equal to the
Signal Triggering, Software Triggering,
3-50
Signal Tracing with Simulink External Mode
You can use Simulink external mode to establish a communication channel
between your Simulink block diagram and your target application. The block
diagram becomes a graphical user interface to your target application and
Simulink scopes can acquire signal data from the target application. For each
Simulink scope, the xPC Target software adds an xPC Target scope of type
host to the system to upload signals. You can control which signals to upload
through the External Signal & Triggering dialog box (see “Signal Selection” in
the Real-Time Workshop
Note Do not use Simulink external mode while xPC Target Explorer is
running. Use only one interface or the other.
®
User’s Guide.
Signal Tracing
Limitations
The following are limitations of uploading xPC Target signals to Simulink
external mode:
• When setting up signal triggering (Source set to signal), you must explicitly
specify the element number of the signal in the Trigger signal:Element
field. If the signal is a scalar, enter a value of
signal, enter a value from
1 to 10. D o not enter La st or Any in this field
1.Ifthesignalisawide
when uploading xP C Target signals t o Simulink scopes.
• The Direction:Holdoff field has no effect for the xPC Target signal
uploading feature.
Before You Start
The procedures in this topic use the Simulink model xpcosc.mdl,which
already contains a Simulink Scope block, as an example. After you download
your target application to the target PC, you can connect your Simulink model
to the target application.
Signal Tracing with External Mode Example
This procedure assumes that you have downloaded your target application
to the target PC.
Note that this procedure edits the Simulink window External Mode Control
Panel and assumes that you are familiar with that dialog box. See “External
Mode Control Panel” in the Real-Time Workshop User’s Guide for details of
the Simulink external mode dialog box.
1 In the MATLAB window, type
xpcosc
2 In the Simulink window, a nd from the Tools menu, select External Mode
Control Panel.
The External Mode Control Panel dialog box opens.
3 Click the Signal & Triggering
The E xternal Signal & Triggering dialog box opens.
button.
3-51
3 Signals and Parameters
4 Ensure that the Source parameter is set to manual.
5 Set the Mode parameter to normal. This ensures that the scope acquires
data continuously.
6 Select the Armwhenconnectingtotargetcheck box.
7 In the Duration box, enter the number of samples for which external mode
is to log data. The External Signal & Triggering dialog box should look
similar to the figure shown.
3-52
8 Click Apply,thenClose.
9 In the Simulink window, increase the simulation stop time. For example,
enter
50
Signal Tracing
10 From the File menu, select Save As and enter a filename. For example,
enter
my_xpc_osc6.mdl and then click OK.
11 Build and download the target application. In the Simul ink window and
from the Tools menu, select Real-Time Workshop.FromtheReal-Time
Workshop submenu, select Build Model.
The xPC Target software downloads the target application to the default
target PC.
12 In the Simulink window, and from the Simulation menu, select External.
A check mark appears next to the menu item External, and Simulink
external mode is activated.
13 If a Scope window is not displayed for the Scope block, double-click the
Scope block.
A Scope window is displayed.
14 In the Simulink window, and from the Simulation menu, select Connect
to target.
15 From the Simulation menu, select Start Real-Time Code.
The target application begins running on the target PC and the Scope window
displays plotted data.
3-53
3 Signals and Parameters
3-54
Signal Tracing with a Web Browser
The Web brow ser interface allows you to visualize data using a graphical
user interface.
After you connect a Web browser to the target PC, you can use the scopes page
to add, remove, and control scopes on the target PC:
1 In the left frame, click the Scopes button.
The browser loads the Scopes List pane into the right frame.
2 Click the Add Scope button.
Ascopeoftype
Scopes pane displays a list of all the scopes present. You can add a new
target is created and displayed on the target PC. The
Signal Tracing
scope, remove existing scopes, and control all aspects of a scope from this
page.
Tocreateascopeoftype
Scope button to select
3 Click the Edit button.
host, use the drop-down list next to the Add
Host.ThisitemissettoTarget by default.
The scope editing pane opens. From this pane, you can edit the properties
of any scope, and control the scope.
4 Click the Add Signals button.
The browser displays an Add New Signals list.
5 Select the check boxes next to the signal names, and then click the Apply
button.
A Remove Existing Signals list is added above the Add New Signals
list.
You do not have to stop a scope to make changes. If necessary, the Web
interface stops the scope automatically and then restarts it when the changes
are made. It does not restart the scope if the state was originally stopped.
When a host sco pe is stopped (Scope State is set to
one cycle of acquisition (Scope State is set to
Interrupted)orfinishes
Finished), a button called Get
Data appears on the page. If you click this button, the scope data is retrieved
in comma-separated value (CSV) format. The signals in the scope are spread
across columns, and each row corresponds to one sample of acquisition. The
first colum n always corresponds to thetimeeachsamplewasacquired.
Note If Scope State is set to Interrupted, the scope was stopped before it
could complete a full cycle of acquisition. Even in this case, the number of
rows in the CSV data will correspond to a full cycle. The last few rows (for
which data was not acquired) will be set to
0.
3-55
3 Signals and Parameters
Signal Logging
In this section...
“Introduction” on page 3-56
“Signal Logging with xPC Target Explorer” on page 3 - 56
“Signal Logging in the MATLAB Interface” on page 3-59
“Signal Logging with a Web Browser” on page 3-63
Introduction
Signal logging is the process for acquiring signal data during a real-time run,
stopping the target application, a nd then transferring the data to the host
PC for analysis. This is also known as real-time data streaming to the target
PC. You can plot and analyze the data, and later save it to a disk. xPC Target
signal logging samples at the base sample time. If you have a model with
multiple sample rates, add xPC Target scopes to the model to ensure that
signals are sampled at their appropriate sample rates.
3-56
Note The xPC Target software does not support logging data with decimation.
Note xPC Target Explorer works with multidimensional signals in
column-major format.
Signal Logging with xPC Target Explorer
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.
This procedure uses a model named
assumes you have created a target application and downloaded it to the target
PC. The
with the xPC Target Scope block removed.
xpc_osc4.mdl is the same as the my_xpc_osc3.mdl tutorial model
xpc_osc4.mdl as an example and
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.