External Mode Simulation with XCP Communication
External mode simulation helps you establish a communication channel between your Simulink® model and the target hardware. The channel runs the executable file in real time and is created by the build and code generation process.
The communication channel could be the Universal Measurement and Calibration Protocol (XCP) on TCP/IP or XCP on Serial. You can use the channel to:
- Tune parameters in real-time with dashboard blocks
- Monitor and log signal data from the executing target application
- Stream data to the Simulation Data Inspector or Logic Analyzer
- Stream signals for referenced models from within a model hierarchy
You can also generate an A2L file including its XCP slave address by choosing ert.tlc (requires Embedded Coder®). This A2L file can be used directly with any third-party calibration tools that support XCP.
Customize your XCP slave software to run on your hardware by following these instructions: Customize XCP Slave Software.
See which XCP-based external mode simulations are enabled to the commercial and maker targets supported by Simulink code generation products:
XCP-based external mode simulation hardware options.
Try the external mode over XCP feature by following this documentation:
External Mode Simulation by Using XCP Communication.
Published: 18 Aug 2020
This video shows how to use Simulink to tune and log data from a generated executable running on your PC or hardware using external mode. External mode simulation helps you establish a communication channel between the assembling model and the target hardware. It runs the executable file in real time created by the build and code generation process. The communication channel could be the universal measurement and calibration protocol. That is, XCP. It can be on TCP/IP, or XCP on serial.
You can tune parameters in real time with dashboard blocks and monitor lock signal data from the executing target application. You can also stream data to the simulation data inspector or logic analyzer. Additionally, you can stream signals for reference model from within a model hierarchy.
Now let us prepare this fault-tolerant fuel system model for external mode simulation. Let me start the preparation by opening the abstract on the Simulink tool strip. Let me click Run on custom hardware. Over here, I can use the grt.tlc.
OK, now let's go to the Solver pane. To specify the value for fixed-step size field, in the Optimization pane, make sure the default parameter behavior is set to tunable. Now select the external mode option and set transport layer to XCP on TCP/IP. XCP uses the static memory allocator on the target. This static memory buffer size value specifies the size of XCP slave memory that is allocated for signal logging. Let's use the default value for the demo.
OK, now we are all set with the configuration. Let's save these settings and the model. Now build a target application using this button. Looks like building is done, along with the code generation. Now let's run the application on the target by clicking this Deploy button. Now we can connect Simulink to our waiting or running target application. At last, let's start real time execution of the generated code in this target environment.
Here you can queue in the parameters using these dashboard blocks. Let me open the assimilation data inspector to view the stream signals. You can also view the same signals using Logic Analyzer as well. You can also do the simulation by a single click on this Monitor and Tune button. You can generate A2L files, including its details of XCP slave address by choosing the ert.tlc. Then enable ASAP2 interface option.
Now let me build the model. Notice that A2L files are generated. It contains details of the XCP slave interface and address of the characteristics and measurements. This can be directly used with any third party calibration tools that support XCP. Furthermore, you can customize your XCP slave software to run on your hardware by following these instructions.
We have also enabled XCP-based external mode simulations, the commercial and maker targets supported by Simulink and code generation products. In this video, you have learned how to configure your model for external mode simulation using XCP. Now it is your turn to try external mode feature by following this documentation.