| 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… |
|---|
Signal Tracing with xPC Target Explorer Signal Tracing with the MATLAB Interface Signal Tracing with xPC Target Scope Blocks |
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 differs from signal logging. With signal logging you can only look at signals after a run is finished and the log of the entire run is available. For information on signal logging, see Signal Logging.
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.
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.
In xPC Target Explorer, ensure that your xpcosc application is still running.
To get the list of signals in the target application, expand the Model Hierarchy node under the target application.
The model hierarchy expands to show the elements in the Simulink model.

To get the list of scope types you can have in the target application, expand the xPC Scopes node below the application node.
The xPC Scopes node expands to show the possible scope types a target application can have.

To create a scope to display on the target PC, right-click the Target Scopes node under the xPC Scopes node.
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.

A scope node appears under Target Scopes. In this example, the new scope is labeled Scope 1.

You can add other scopes, including those of type host and file. Note, you can add as many file and host scopes as you want. as long as your target PC resources can support them.
To create a scope to be displayed on the host PC, right-click the Host Scopes node under the xPC Scopes node.
A context menu appears. This lists the actions you can perform on host PC scopes. For example, within the current context, you can create a host PC scope.

A scope node appears under Host Scopes. In this example, the new scope is labeled as Scope 2.
To visualize the host scope on the host PC, right-click Host Scopes from the xPC Scopes node.
A drop-down list appears.

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.

To list the properties of the scope object Scope 2, click the xPC Target Explorer tab to return to that window, and left-click Scope 2. (Note that you can configure the docking view using the MATLAB docking feature.)
The scope properties are shown in the rightmost pane.
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 File Scopes. In this example, the new scope is labeled Scope 3.

By default, the software creates a file in the target PC C:\ folder. The name of the file typically consists of the scope object name, ScopeId, and the beginning letters of the first signal added to the scope.
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 top of the pane.

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.
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.
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. From the Add to Scopes list, select Scope 1. (Note that you can also drag the signal to the scope to add the signal to that scope.)
The Scope 1 node is shown with a plus sign.

The Scope 1 signals are displayed.

If one of the signals has been labeled. you can hover over the signal to display the signal label. For example,

Start the scope. For example, to start Scope 1, right-click it and select Start.

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.

Add signals to the host PC scope. For example, to add signals Integrator1 and Signal Generator, right-click each signal and select Add to Scopes. From the Add to Scopes list, select Scope 2. (Note that you can also drag a signal from one scope to another to add that signal to another scope.)
The Scope 2 node is shown with a plus sign.
The Scope 2 signals are displayed.

Start the scope. For example, to start the scope Scope 2, right-click Scope 2 in the Host Scopes node of the xPC Target Explorer and select Start.
The xPC Target Host Scope Viewer 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.

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. From the Add 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.
The Scope 3 signals are displayed.

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 specify a filename, then after you start the scope, the software assigns a name for the target PC file to acquire the signal data. This name typically consists of the scope object name, ScopeId, and the beginning letters of the first signal added to the scope.
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.
Stop the scopes. For example, to stop Scope 1, right-click it and select Stop.
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'
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.405500
Note that if you stop the target application before stopping the scope, the scope stops, too.
If you have file scopes, you can copy the file that contains the signal data from the target PC to the host PC. See Copying Files to the Host PC.
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) and that you have added signals to that scope (see Adding Signals to Scopes).
In the xPC Target Explorer window, select the scope that you want to trigger by software. For example, select Scope 1.
The properties pane for that scope is displayed.
From the Trigger mode list, select Software. Click Apply.

Right-click the scope to be triggered. For example, select Scope 1.
You can customize your host scope viewer. This section assumes that you have added a host scope to your target application, started the host scope viewer, and added signals Integrator1 and Signal Generator (see Creating Scopes and Adding Signals to Scopes). 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 — Select Graphical for a graphical display of the data. Select Numerical for a numeric representation of the data.
Legends — Select and deselect 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.
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 application_name_scn_data, and the default name for the time variable is application_name_scn_time where n is the scope number. Select Export Scope Data to export scope data to the MATLAB interface.
You can acquire signal data into multiple, dynamically named files on the target PC. For example, you can acquire data into multiple files to examine one file while the scope continues to acquire data into other files. To acquire data in multiple files, add a scope of type file to the application. After you build an application and download it to the target PC, you can add a scope 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 scope to your target application (see Creating Scopes). It also assumes that you have added signals to that scope (see Adding Signals to Scopes).
In xPC Target Explorer, expand the target PC node associated with the target PC file system you want to access. For example, expand TargetPC1.
Under TargetPC1, expand the target application node and navigate to the File Scope(s) node.
Right-click this node and add a file scope.
![]()
Add one or more scopes to that file scope. For example, add Integrator1 and Signal Generator to the scope.
Right-click the scope you just added (for example, Scope:1). The scope property pane for this scope is displayed.

To enable the file scope to create multiple log files with the same name pattern, in the File name box, enter a name like file_<%>.dat.
This sequence directs the software to create up to nine log files, file_1.dat to file_9.dat, on the target PC file system.
Select the Enable auto restart check box. The Enable file auto increment check box is enabled.
Select the Enable file auto increment check box.
In the Max file size box, enter a value to limit the size of the signal log files. For example, to limit each log file size to 4096 bytes, enter 4096.
This value must be a multiple of the Write size value.
Click Apply. The saved values appear as follows:

Right-click the new file scope and select Start.
Start the associated target application.
The software creates a log file named file_1.dat and writes data to that 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_2.dat for writing until its size reaches 4096 bytes. The software repeats this sequence until it fills the last log file, file_9.dat. If the target application continues to run and collect data after 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.
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 description in the get (target application object) for a details about this specifier.
From xPC Target Explorer, you can download target PC files from the target PC to the host PC.
In xPC Target Explorer, expand the target PC node associated with the target PC file system you want to access. For example, expand TargetPC1.
Under TargetPC1, expand the File System node.
Nodes representing the drives on the target PC are displayed.

Expand the node of the drive that contains the file you want. For example, local disk: c:\.
Select the folder 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.
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.

A browser dialog box is displayed.
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 the selected folder.
You can examine the contents of the signal data file. See Retrieving a File from the Target PC to the Host PC in Working with Target PC Files and File Systems.
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 created a scope of type file that contains signal data (see Adding Signals to Scopes).
In xPC Target Explorer, expand the target PC node associated with the target PC file system you want to access. For example, expand TargetPC1.
Under TargetPC1, find the target application and ensure that it is not running.
Under TargetPC1, expand the xPC Scopes node.
All the scopes you have added are displayed.
Right-click on the scope of type file for which you want to export the signal data and select Export to workspace.

The Export to workspace dialog box is displayed.

Enter a variable name for the workspace data. For example, enter sig_integ. Click OK.
In the MATLAB desktop, the Workspace pane displays the new variable name.

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 Target PC to the Host PC in Working with Target PC Files and File Systems.
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 session,
Ensure that xPC Target Explorer is connected to a target PC.
In xPC Target Explorer, load a target application on the target PC.
In xPC Target Explorer, right-click the target PC you are interested in and select Save Session. For example,

A Save Target Session as dialog box is displayed.
As necessary, browse to the desired folder and enter a unique name. For example, xpcsession1.mat.
To restore a session,
Ensure that xPC Target Explorer is connected to a target PC.
In xPC Target Explorer, load a target application on the target PC. This target application must be the same target application for which the session was saved.
In xPC Target Explorer, right-click the target PC you are interested in and select Load Session. For example,

A Load Target Session as dialog box is displayed.
As necessary, browse to the desired folder and select the session you are interested in. For example, xpcsession1.mat.
A dialog box is displayed asking you to confirm that you want to load a new session.
xPC Target Explorer loads the saved settings.
From xPC Target Explorer on the host PC, you can delete the scope data file on the target PC file system. Use the same procedure as described in Copying Files to the Host PC, but select Delete instead of Save to Host PC. xPC Target Explorer removes the selected file from the target PC file system.
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 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 for a description of with target scopes)
File scopes (see Signal Tracing with the MATLAB Interface and File Scopes)
You must stop the scope before adding or removing signals from the scope.
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.
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 time: 0.0000250)
To get a list of signals, type either
set(tg, 'ShowSignals', 'on')
or
tg.ShowSignals='on'
The MATLAB window displays a list of the target object properties for the available signals. For example, the signals for the model xpcosc.mdl are as follows:
ShowSignals = on
Signals = INDEX VALUE BLOCK NAME LABEL
0 0.000000 Integrator1
1 0.000000 Signal Generator
2 0.000000 Gain
3 0.000000 Integrator
4 0.000000 Gain1
5 0.000000 Gain2
6 0.000000 Sum For more information, see Signal Monitoring with the MATLAB Interface.
Create a scope to be displayed on the target PC. For example, to create a scope with an identifier of 1 and a scope object name of sc1, type
sc1=tg.addscope('target', 1)or
sc1=addscope(tg, 'target', 1)
List the properties of the scope object. For example, to list the properties of the scope object sc1, type
sc1
The MATLAB window displays a list of the scope object properties. Notice that the scope properties Time and Data are not accessible with a scope of type target.
xPC Scope Object Application = xpcosc ScopeId = 1 Status = Interrupted Type = Target 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
Add signals to the scope object. For example, to add Integrator1 and Signal Generator, type
sc1.addsignal ([0,1])
or
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.
Start the scope. For example, to start the scope sc1, type either
+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.
-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.
Scope: 1, set to state 'interrupted'
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.789000 maximal TET: 0.000034 at time 407.956000
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. This topic describes how to trace signals with file scopes .
Note The signal data file can quickly increase in size. You should examine the file size between runs to gauge the growth rate of the file. If the signal data file grows beyond the available space on the disk, the signal data might be corrupted. |
Create an xPC Target application that works with file scopes. Type
tg=xpctarget.xpc('rs232', 'COM1', '115200')To get a list of signals, type either
set(tg, 'ShowSignals', 'on')
or
tg.ShowSignals='on'
The MATLAB window displays a list of the target object properties for the available signals. For example, the signals for the model xpcosc.mdl are shown below.
ShowSignals = on
Signals = INDEX VALUE BLOCK NAME LABEL
0 0.000000 Integrator1
1 0.000000 Signal Generator
2 0.000000 Gain
3 0.000000 Integrator
4 0.000000 Gain1
5 0.000000 Gain2
6 0.000000 Sum For more information, see Signal Monitoring with the MATLAB Interface.
Start running your target application. Type
+tg
or
tg.start
or
start(tg)
The target PC displays the following message:
System: execution started (sample time: 0.0000250)
Create a scope to be displayed on the target PC. For example, to create a scope with an identifier of 2 and a scope object name of sc2, type
sc2=tg.addscope('file', 2) or
sc2=addscope(tg, 'file', 2)
List the properties of the scope object. For example, to list the properties of the scope object sc2, type
sc2
The MATLAB window displays a list of the scope object properties. Notice that the scope properties Time and Data are not accessible with a scope of type target.
xPC Scope Object Application = xpcosc ScopeId = 2 Status = Interrupted Type = File NumSamples = 250 NumPrePostSamples = 0 Decimation = 1 TriggerMode = FreeRun 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. After you start the scope, xPC Target assigns a name for the file to acquire the signal data. This name typically consists of the scope object name, ScopeId, and the beginning letters of the first signal added to the scope.
Add signals to the scope object. For example, to add Integrator1 and Signal Generator, type
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.
Start the scope. For example, to start the scope sc2, type
+sc2
or
sc2.start
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 signal data for the scope of type file. This name typically consists of the scope object name, ScopeId, and the beginning letters of the first signal added to the scope.
Application = xpcosc
ScopeId = 2
Status = Pre-Acquiring
Type = File
NumSamples = 250
NumPrePostSamples = 0
Decimation = 1
TriggerMode = FreeRun
TriggerScope = 2
TriggerSample = 0
TriggerSignal = 4
TriggerLevel = 0.000000
TriggerSlope = Either
ShowSignals = on
Signals = 4 : Integrator1
5 : Signal Generator
FileName = c:\sc7Integ.dat
Mode = Lazy
WriteSize = 512
AutoRestart = off
DynamicFileName = off
MaxWriteFileSize = 536870912-sc2
or
sc2.stop
or
stop(sc2)
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 time 0.004250 maximal TET: 0.000037 at time 14.255250
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) from the 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 Working with Target PC Files and File Systems.
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 target can contain up to 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. |
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. |
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.
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 sc.Data. The scope then stops and waits for you to manually restart the scope.
The number of samples N to log after triggering an event is equal to the value you entered in the Number of Samples parameter.
Select the type of event in the Block Parameters: Scope (xPC Target) dialog box by setting Trigger Mode to Signal Triggering, Software Triggering, or Scope Triggering.
For a scope of type target, logged data (sc.Data and sc.Time) is not accessible over the command-line interface on the host PC. This is because the scope object status (sc.Status) is never set to Finished. Once the scope completes one data cycle (time to collect the number of samples), the scope engine automatically restarts the scope.
If you create a scope object, for example, sc = getscopes(tg,1) for a scope 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.
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'.
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. The scope acquires the first N samples into the memory buffer. This memory buffer is 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 N to log after triggering an event is equal to the value you entered in the Number of Samples parameter. If you stop, then start the scope again, the data in the file is overwritten with the new data.
Select the type of event in the Block Parameters: Scope (xPC Target) dialog box by setting Trigger Mode to Signal Triggering, Software Triggering, or Scope Triggering.
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 User's Guide.
Note Do not use Simulink external mode while xPC Target Explorer is running. Use only one interface or the other. |
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 1. If the signal is a wide signal, enter a value from 1 to 10. Do not enter Last or Any in this field when uploading xPC Target signals to Simulink scopes.
The Direction:Holdoff field has no effect for the xPC Target signal uploading feature.
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.
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.
In the MATLAB window, type
xpcosc
In the Simulink window, and from the Tools menu, select External Mode Control Panel.
The External Mode Control Panel dialog box opens.
Click the Signal & Triggering button.
The External Signal & Triggering dialog box opens.
Ensure that the Source parameter is set to manual.
Set the Mode parameter to normal. This ensures that the scope acquires data continuously.
Select the Arm when connecting to target check box.
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.

Click Apply, then Close.
In the Simulink window, increase the simulation stop time. For example, enter
50
From the File menu, select Save As and enter a filename. For example, enter xpc_osc6.mdl and then click OK.
Build and download the target application. In the Simulink window and from the Tools menu, select Real-Time Workshop. From the Real-Time Workshop submenu, select Build Model.
The xPC Target software downloads the target application to the default target PC.
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.
If a Scope window is not displayed for the Scope block, double-click the Scope block.
A Scope window is displayed.
In the Simulink window, and from the Simulation menu, select Connect to target.
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.

The Web browser 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:
In the left frame, click the Scopes button.
The browser loads the Scopes List pane into the right frame.
A scope of type target is created and displayed on the target PC. The Scopes pane displays a list of all the scopes present. You can add a new scope, remove existing scopes, and control all aspects of a scope from this page.
To create a scope of type host, use the drop-down list next to the Add Scope button to select Host. This item is set to Target by default.
The scope editing pane opens. From this pane, you can edit the properties of any scope, and control the scope.
The browser displays an Add New Signals list.
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 scope is stopped (Scope State is set to Interrupted) or finishes one cycle of acquisition (Scope State is set to 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 column always corresponds to the time each sample was acquired.
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. |
![]() | Monitoring Signals | Signal Logging | ![]() |

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 |