This example shows you how to use XCP blocks to directly acquire measurement values from a slave in Simulink®. It uses an XCP slave simulator available for free download from Vector, and Vector Virtual CAN channels.
Vehicle Network Toolbox™ provides Simulink blocks for acquiring measurement values from a slave via Simulink models over Controller Area Networks (CAN). This example uses the XCP Configuration, XCP Data Acquisition, and XCP CAN Transport Layer blocks to perform data transfer over a CAN bus.
Run a Slave Simulator
For this example, you must install a third party XCP Sample implementation from Vector. This includes a slave simulator and an A2L file. To install this free implementation:
Go to www.vector.com and navigate to the "DOWNLOADS" page.
Search for "Demos" under "Categories" and "XCP" under "Standards".
Download and install the available version of "XCP Sample Implementation".
In MATLAB, navigate to where you installed the sample package, and then go to .\Samples\XCPSim\CANape.
The MATLAB XCP examples will use the XCPSIM.a2l file and the XCPsim.exe slave simulator. Run XCPsim.exe.
Setting up XCP Block Parameters
Create a model to set up XCP data acquisition for the measurements, Triangle and PWM, from the slave.
Use an XCP Configuration block and select the A2L file, XCPSim.a2l
Use an XCP CAN Transport Layer block and set the Device to Vector Virtual Channel 1. The transport layer is configured to transfer XCP messages over CAN via the specified virtual channel.
Use XCP Data Acquisition blocks to receive selected measurements at specified events. For this example we have selected an XCP Data Acquisition block for each measurement of each selected event.
Visualize Measurement Values Received From Slave
Plot the results to see the measurement values for Triangle and PWM from the slave. The X-axis corresponds to the simulation timestep.