Signal Monitoring and Parameter Tuning over XCP on TCP/IP
You can use Monitor and Tune (External Mode) action to tune parameters and monitor a Simulink® model running on your TI ARM® Cortex®-M core hardware.
Monitor and Tune enables you to tune model parameters and evaluate the effects of different parameter values on model results in real-time. When you change parameter values in a model, the modified parameter values are communicated to the target hardware immediately. You can monitor the effects of different parameter values by viewing the output signals on Sink (Simulink) blocks or in Simulation Data Inspector (SDI) (Simulink). Doing so helps you find the optimal values for performance. This process is called parameter tuning.
Monitor and Tune accelerates parameter tuning. You do not have to rerun the model each time you change parameters. You can also use Monitor and Tune to develop and validate your model using the actual data and hardware for which it is designed. This software-hardware interaction is not available solely by simulating a model.
The support package supports Monitor and Tune simulation over
TCP/IP communication interface.
In Universal Measurement and Calibration Protocol (XCP)-based External mode simulation over TCP/IP connections, you can use:
Dashboard (Simulink) blocks: In addition to Sources (Simulink) and Sink (Simulink) blocks, you can use Dashboard (Simulink) blocks to change parameter values and to monitor the effects of parameter tuning. The Dashboard library contains set of blocks using which you can interactively control and visualize the model.
Simulation Data Inspector (SDI) (Simulink): You can inspect and compare data from multiple simulations to validate model designs using Simulation Data Inspector.
Prepare a Simulink Model for External Mode
This section explains how to prepare a Simulink model to run in External mode.
Configure the hardware network as described in Install Support for Texas Instruments C2000 Processors.
Create or open a Simulink model.
Set the Simulation stop time parameter, located to the left of Simulation mode.
Configure the Model Configuration Parameters for the hardware as described in Model Configuration Parameters for Texas Instruments F2838x (ARM Cortex-M4). In External mode, set the Communication interface parameter based on the type of External mode simulation to run on the model.
When you set the Communication interface to an XCP-based External mode, the Set logging buffer size automatically parameter becomes available. Select this parameter to automatically set the number of bytes to preallocate for the buffer in the hardware during simulation. By default, the Set logging buffer size automatically parameter is selected. If you clear this parameter, Logging buffer size (in bytes) parameter becomes available, where you can manually specify the memory buffer size for XCP-based External mode simulation.
You can send multiple contiguous samples in same packet to enhance signal logging performance in models containing signals of high sample rates. To do so, click Hardware tab, in the Prepare gallery, select Control Panel and then click Signal & Triggering. In the External & Signal Triggering dialog box, select Send multiple contiguous samples in same packet. For more information, see Signal Logging and Parameter Tuning in XCP External Mode with Packed Mode.
You might experience data drops in Packed mode, when data inside interrupt service routine (ISR) is logged.
In the Configuration Parameters screen, enter a value for Maximum number of contiguous samples parameter. This parameter dictates the maximum number of samples that can be filled in a single packet and the memory is allocated accordingly.
Go to Ethernet and specify the host addresses.
Enable DHCP for local IP address assignment - Select this parameter to configure the board to get an IP address from the local DHCP server on the network.
Local IP Address - Select this parameter to set the IP address of the board.
Subnet mask - Specify the subnet mask for the board. The subnet mask is a mask that designates a logical subdivision of a network.
Gateway - Set the serial gateway to the gateway required to access the target computer.
MAC Address - Specify the media access control (MAC) address, the physical network address of the board.
For more information on Ethernet parameter configurations, refer ARM Cortex-M4 - Ethernet.
Signal Monitoring and Parameter Tuning of Simulink Model
XCP-Based External Mode Simulation over TCP/IP Connection
This section applies only when you set the communication interface to XCP on TCP/IP.
Before you begin, complete the Prepare a Simulink Model for External Mode section.
In the Simulink model, identify the signals to be logged for monitoring during simulation. Select the identified signal, open its context menu, and click the icon corresponding to Enable Data Logging.
For instructions on logging the signal using other methods, refer to Mark a Signal for Logging (Simulink). Simulink displays a logged signal indicator for each logged signal.
(Optional) Place one or more Sink (Simulink) blocks in the model, and then mark the signals connected to them also for logging. For example, connect Display (Simulink) or Scope (Simulink) blocks and mark the signals connected to them for logging.
To start the simulation,open the Hardware tab and click the Monitor & Tune.
If none of the signals in the model is marked for logging, the MATLAB® Command Window displays a warning message.
You can disregard this warning or mark signals for logging. For instructions on logging the signal, see Mark a Signal for Logging (Simulink).
After several minutes, Simulink starts running the model on the hardware.
During simulation, when new simulation data becomes available in SDI, the Simulation Data Inspector button appears highlighted.
View the simulation output in Sink blocks or in SDI.
Sink blocks – To view the simulation output, double-click the Sink blocks in the model.
SDI – To view the new simulation data, perform these steps:
Click the Simulation Data Inspector button.
A new simulation run appears in the Inspect pane. The Inspect pane lists all logged signals in rows, organized by simulation run. You can expand or collapse any of the runs to view the signals in a run. For more information on signal grouping, see Signal Grouping (Simulink).
We recommend you use SDI rather than using Sink blocks for the following reasons:
Streaming data to SDI does not store data in memory, making more efficient use of the memory available on the hardware. Sink blocks such as Scope (Simulink) stores data in buffers before sending the data to the host.
Using SDI, you can stream signals from top models and reference models simultaneously. Scope blocks can only log signals from a top-level model.
Change the parameter values in the model. Observe the corresponding changes in the simulation output.
Find the optimal parameter values by making adjustments and observing the results in the Sink blocks.
After you are satisfied with the results, stop the Monitor and Tune action, and save the model.
Monitor and Tune action increases the processing burden of the model running on the board. If the software reports an overrun, stop the Monitor and Tune action.
Stop Monitor and Tune
To stop the model that is running in Monitor and Tune, open the Hardware tab and click the Stop button .
If the Simulation stop time parameter is set to a specific number of seconds, Monitor and Tune stops when that time elapses.
When you finish using Monitor and Tune, set Simulation mode back to
Memory overflow issue during compilation
The following error might occur due to insufficient memory:
program will not fit into available memory, or the section contains a call site that requires a trampoline that can't be generated for this section. placement with alignment/blocking fails for section ".text" size 0x360apage 0. Available memory ranges: RAMLS_PROG size: 0x3000 unused: 0x2bd7 max hole: 0x2bd6
This error shown at linking stage indicates that the memory is insufficient to fit the
code section (
.text) in the target memory available. External Mode
simulation requires additional code to enable the communication between Simulink and the
target, which might lead to this code section overflow. To mitigate this issue, select
Faster Runs as the Build Configuration
in the Configuration Parameters screen. This option compiles the code
-O3 optimization level, resulting in a smaller code size which might
fit the target memory.