With Monitor & Tune (External Mode), you can log signals and tune parameters while the model is running on the target hardware in real time. When you change parameter values from within Simulink, the modified parameter values are communicated to the target hardware immediately. Also, you can monitor the effects of the parameters tuning activity by viewing the algorithm signals on the scopes.
You can run your model on the external mode via two communication interfaces, serial or CAN.
For external mode with serial communication, you have a ready-to-use COM port on the USB drive if your target hardware supports it or the COM1 port on your computer with RS–232 cable. For more information on how to set up serial communication, see Set Up Serial Communication with Target Hardware. You can configure the external mode for different baud rates that your communication interface supports.
To run your model in external mode with CAN Calibration Protocol(CCP), use the CAN Calibration Protocol block and a Vector CAN case hardware. External mode uses the eCAN module to run external mode. You can configure the external mode with any available eCAN module. For more information, see Set Up CAN Communication with Target Hardware. You can configure the baud for eCAN.
The external mode with ‘ert.tlc’ downloads the executable, runs the model, and establishes external mode connection in a single step.
Monitor and Tune (External Mode) over Serial Communication can be done using either of the two available protocols:
Classic External Mode
In this method, you will setup Serial communication between Simulink® and Texas Instruments™ C2000 board to tune the parameters and monitor the signal of an algorithm running on the board.
External Mode over Universal Measurement and Calibration (XCP)
Simulink provides these additional features for the targets that support XCP:
Running External mode over XCP has a few limitations. For a detailed list, see External Mode Simulation with XCP Communication(Simulink Coder)
Based on the maximum and the minimum baud that the SCI_A module supports, you can run your model in external mode over different baud rates.
To prepare your model for external mode with serial communication:
In the Configuration Parameters dialog box, select Model Configuration Parameters > Hardware Implementation .
Select a C2000 processor from the Hardware Implementation > Hardware board drop-down list.
Under Target Hardware Resources, select External mode(Classic)/External Mode over Universal Measurement and Calibration (XCP).
In Communication interface drop-down list, select
Specify the corresponding COM port that the target hardware uses.
For the COM port on your computer, select Start > Control Panel > Device Manager > Ports (COM & LPT)
Make sure that the Verbose check box is selected to view the external mode execution progress and updates in the Diagnostic Viewer or in the Command Window.
To execute your model with a specific baud:
Under Target Hardware Resources, select the SCI_A pane and then specify the desired baud in Desired baud rate in bits/sec parameter.
The default baud is 115200 bits/sec. For better performance, you may increase the baud to a value that your hardware board permits.
Your model is now ready to perform Monitor and Tune action (External Mode) over serial communication.
To perform the Monitor and Tune action :
Open the Model.
Go to theHardware tab and click Monitor & Tune.
For more information, see Parameter Tuning and Signal Logging with Serial Communication
For targets with small RAM such as F28027, the code has to be booted from flash. To boot the code from flash, select TI Piccolo F2802x (boot from flash) in Hardware Implementation > Hardware board drop-down list
Parameter tuning and signal logging for 8-bit data type is not supported in external mode over serial
You can tune parameters and log signals (External Mode) using Simulink external mode with CCP. For signal logging and parameter tuning with a third-party calibration tool, see CAN Calibration Protocol with Third Party Tools.
The external mode is supported using the CAN Calibration Protocol block and ASAP2 interface. The ASAP2 interface is used to get information about where a parameter or signal exists in the target memory. The CAN Calibration Protocol block is used to communicate with the target, download parameter updates, and upload signal information.
To prepare your model for external mode over CCP, perform these tasks:
For more information, see:
Add a CCP driver block to your model from the Simulink Block Library.
Identify signals that you want to tune. Associate them with
ExportedGlobal storage class. Set the data type and value of
the object. See Using Supported Objects and Data Types.
Identify signals you want to log. Associate them with
canlib.Signal objects. Set the data type of the
canlib.Signal. See Using Supported Objects and Data Types.
For information about visualizing logged signal data, see Viewing and Storing Signal Data.
objects into the base workspace.
Select Simulation > Model Configuration Parameters.
In the Configuration Parameters dialog box, select Optimization > Signals and Parameters pane.
Select Default parameter behavior > Inlined and click Configure.
In the Model Parameter Configuration dialog box that opens, define the (global) tunable parameters for your models.
In the Configuration Parameters dialog box, select Code Generation > Interface pane.
Set the Interface parameter to
To perform Monitor & Tune action :
Open the Model.
Go to the Hardware tab and click Monitor & Tune.
Your model now runs in the external mode over CCP.
For external mode, the host-side CAN connection must use the
1' application channel. To configure the application channel that the Vector
CAN drivers use, in the Command
If you try to connect using an application channel other than
1', you see the following warning:
Warning: It was not possible to connect to the target using CCP. An error occurred when issuing the CONNECT command.
If you have not already installed the Vector CAN drivers, you get the following error message in the command window:
??? Error using ==> TargetsComms_VectorApplicationChannel.TargetsComms_VectorApplicationChannel> TargetsComms_VectorApplicationChannel.configureApplicationChannels at 40 Unable to launch the application channel configuration utility. The "vcanconf" utility was not found on the Windows System Path. To fix this error, make sure the required CAN drivers are installed on this computer; refer to the product documentation for details.
vcand32.dll, is placed in the Windows®
Supported objects are:
canlib.Signal for signal logging
Supported data types are:
Define data objects for the signals and parameters of interest for ASAP 2 file generation. For ease of use, create a MATLAB® file to define the data objects so that you only have to set up the objects only once.
To set up tunable parameters and signal logging:
Associate the parameters that you want to tune with
with ExportedGlobal storage class. It is important to set the data type and value of
the parameter object. For an example of how to create such a Simulink.Parameter object
for tuning, see the following
stepSize = Simulink.Parameter; stepSize.DataType = 'uint8'; stepSize.CoderInfo.StorageClass = 'ExportedGlobal'; stepSize.Value = 1;
Associate the signals that you want to log with canlib.Signal objects.Set the data type of the canlib.Signal. The following code example shows how to declare such a canlib.Signal object for logging.
counter = canlib.Signal; counter.DataType = 'uint8';
Associate the data objects that you defined in the MATLAB file with parameters or signals in the model. For the previous code
examples, you can set the Constant value in a Source block to
stepSize, and set a Signal name to
counter in the Signal Properties dialog box.
counter are the data objects
defined in the code.
In the workspace, set
while the model is
running in external mode. For example, to tune the parameter
stepSize (that is, to change its value) from 1 to 2, at the
command line, enter:
stepSize.value = 2
stepSize = Parameter with properties: Value: 2 CoderInfo: [1×1 Simulink.CoderInfo] Description: '' DataType: 'uint8' Min:  Max:  Unit: '' Complexity: 'real' Dimensions: [1 1]
Update the model (press Ctrl+D) to apply the changed parameter.
To view the logged signals, attach a supported scope type to the signal.
To customize the signals that are logged:
In the Simulink Editor, select Code > External Mode Control Panel.
In External Mode Control Panel, click Signal & Triggering.
In External Signal & Triggering box, clear the check boxes for scope data that you do not want to log.
Storing signal data for further analysis. You can further analyze the logged data in MATLAB.
To use the data archiving in external mode, in the External Mode Control Panel, click Data Archiving.
In the Enable Data Archiving dialog box, select the check box Enable archiving.
Edit the Directory and File fields. Review the other settings.
Click Apply and close the dialog box.
Open the Scope parameters by clicking the scope parameters icon in the scope window toolbar.
Select the check box Save data to workspace.
In the Variable name field, edit the variable name. The data that is displayed in the scope at the end of the external mode session is available in the workspace with this variable name.
The data that was previously displayed in the scope is stored in
For example, at the end of an external mode session, the following variable and files are available in the workspace and the current folder:
ScopeData5 with the data currently displayed on
ScopeData5 ScopeData5 = time: [56x1 double] signals: [1x1 struct] blockName: 'c28x_ccp_ert/Scope1'
In the current folder, .mat files for the three previous durations of scope data:
ExternalMode_0.mat ExternalMode_2.mat ExternalMode_1.mat
Multiple signal sinks (for instance, scopes) are not supported.
Only the following kinds of scopes are supported with external mode logging:
Simulink Scope block
Simulink Display block
Viewer type: scope — To use this option in your model, right-click a signal in the model, and select Create & Connect Viewer > Simulink > Scope. The other scope types listed are not supported (for instance, floating scope).
Before connecting to external mode, right-click the signal and select Signal Properties. In the dialog box, select the Test point check box, and click OK.
GRT is supported only for parameter tuning.
You cannot log signals with sample rates more than 10 kHz.
Top-level builds are supported for external mode. Subsystem builds are not supported for external mode.
Logging and tuning of nonscalars is not supported. It is possible to log nonscalar signals by breaking down the signal into its scalar components. For an example of how to do this signal deconstruction, see the CCP example models, which use a Demux and Signal Conversion block with contiguous copy.
Logging and tuning of complex numbers is not supported. It is possible to work with complex numbers by breaking down the complex number into its real and imaginary components. You can perform this breakdown using the following blocks in the Simulink Math Operations library: Complex to Real-Imag, Real-Imag to Complex, Magnitude-Angle to Complex, and Complex to Magnitude-Angle.