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.
Embedded Coder® Support Package for Texas Instruments™ C2000™
Note: The integration of Simulink with CANape using Texas Instruments™ C2000™ board has been tested with CANape 16.0 SP6.
Any Texas Instruments™ C2000™ board with CAN module
To open the pre-configured model, run this command at the MATLAB prompt:
This example contains four signals that are enabled for logging and two parameters for tuning. The four signals are:
Counter - Increments the output by COUNTER_INCR at every time step and COUNTER_INCR is tunable
Sine_Wave - A Sine Wave
Pulse - A Pulse signal
Constant - A Constant signal of value STEP_PARAM and STEP_PARAM is tunable
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.
Note.: XCP on CAN Communication interface supports only Third party calibration tools as Host interface.
6. Configure the eCAN module on the target.
a. If the target supports multiple eCAN modules, select the eCAN module to be used with external mode.
b. Select the CAN ID type.
c. Enter the values for CAN Master ID and CAN slave ID.
d. Enter the values for Rx mailbox number and Tx mailbox number.
e. Enter a suitable value for Logging buffer size.
7. Go to Code Generation > Optimization and then set Default parameter behavior to
8. Click Apply and OK.
On the Hardware tab of the Simulink toolstrip, click Build for Monitoring.
Click Deploy in the Simulink Toolstrip to deploy the executable onto the target.
The model is deployed on the Texas Instruments C2000 board and an A2L file named modelname.a2l is generated in the current folder path in MATLAB. After successful deployment, third-party calibration tools can be used to connect to the Texas Instruments C2000 board for monitoring signals and tuning parameters.
1. Open Vector CANape software. Create a new Project.
2. Drag and drop the A2L file generated from the model into CANape. This opens a new dialog box which creates a new device. Click Next.
3. In Network settings, click New network button. This opens a dialog box where CAN Channel can be selected. Also, change the Baud Rate to the value that was used in Simulink model. Accept the changes and close the dialog.
4. Click Next and finally click OK. A new device is created, and the Settings dialog box for the newly created device opens.
5. Expand the Protocol tab in the Settings dialog box. Click Transport Layer.
6. Ensure that CAN Master ID, CAN Slave ID and other settings are same as the ones used in Simulink model.
7. Click on Protocol tab. Go to Expert settings. Change SHORT_DOWNLOAD_DISABLED and SHORT_UPLOAD_DISABLED options to yes.
8. Click Accept all changes in the top-left corner of the Settings dialog box and close it.
9. Click Online to connect to the Texas Instruments C2000 target.
1. Open the list of signals and parameters by expanding the Devices tab in the Explorer pane.
2. Drag the signals that you want to monitor, to the Display area and select a graphic window.
3. Drag the parameters that you want to tune, to the Display area and select Parameter window.
4. Click Start measurement in the Start tab to start monitoring the selected signals.
5. Use the Parameter window to tune the parameters.
While you perform calibration of parameters using third-party, you may encounter these errors:
CANape fails to connect with the error:
No response from the ECU
To resolve this issue, ensure that the CAN Channel Baud Rate, CAN Slave ID, CAN Master ID, CAN ID Type are correct and try to connect again.
Data Acquisition does not start when you click Start for the first time.
To resolve the issue, click Start again.
The issue occurs because CANape sends command 0xD7 (GET_DAQ_EVENT_INFO) and 0xDC (GET_DAQ_CLOCK) to the slave, even though these are not listed as supported optional commands in the ASAP2 file. By default, CANape has XCP_OPTIONAL_CMD_AUTO_LEARNING feature, which learns that the GET_DAQ_EVENT_INFO and GET_DAQ_CLOCK commands are not supported, and correctly sends DAQ on the second attempt. This information persists in the project database, so the failure does not occur again for the same project.