Signal Monitoring and Parameter Tuning Over XCP-based CAN Interface
This example shows how to monitor signals and tune parameters of a Simulink® model on Texas Instruments™ C2000™ board using XCP-based CAN Interface.
Complete the Getting Started with Embedded Coder Support Package for TI C2000 Processors video.
Required MathWorks Products
Embedded Coder Support Package for Texas Instruments C2000
Vehicle Network Toolbox™
Any Texas Instruments C2000 board with CAN module
To open the pre-configured model, run this command at the MATLAB® prompt:
In this example, multiple signals of different data types such as int36, int32, single are selected for logging. The visualization section on the right-hand side contains Dashboard Scope and Dashboard Display blocks which shows the values of different signals that are being logged.
Different parameters in source blocks are tunable. Dashboard Knob, Toggle Switch and Edit boxes can also be used to tune the parameters.
Configuring the Model
In this task, you will configure a Simulink model and enable calibration of parameters in third-party calibration tools.
Note: These steps are not required in the pre-configured model. Perform these steps if you have changed the hardware or not using the pre-configured model.
1. Open the model.
2. Go to Modeling > Model Settings to open the Configuration Parameters dialog box.
3. Open the Hardware Implementation pane, and select the required Texas Instruments C2000 board from the list in Hardware board parameter.
4. Expand Target hardware resources for that board.
5. Go to External mode tab and choose XCP on CAN as the Communication interface.
6. Select Simulink as the Host interface.
7. Configure the eCAN module on the target.
a. Enter the values for CAN vendor, CAN device, and CAN channel number. Use the Vehicle Network Toolbox function
canChannelList() to get values for CAN vendor, CAN device, CAN channel. This function returns a list of all the CAN interfaces whose drivers have been installed and connected to the computer. In the MATLAB command window, type
canChannelList() and press enter. A sample screen is shown here.
b. Enter the values for CAN ID command and CAN ID response.
c. Select Extended CAN ID option, if you want to use extended ID.
d. Select Verbose option to view the External Mode execution progress and updates in the Diagnostic Viewer or in the MATLAB Command Window.
e. Select Set logging buffer size automatically option to set the optimal buffer size for logging data.
f. Select the CAN module to use with external mode, if the target supports multiple eCAN modules.
g. Enter the values for Rx mailbox number and Tx mailbox number.
8. Click Apply and OK.
Initiate Monitor and Tune Action for the Model
On the Hardware tab of the Simulink toolstrip, click Monitor & Tune to monitor signals and tune parameters.