Vehicle Network Toolbox
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.
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:
1. Go to www.vector.com. 2. Click on "DOWNLOADS". Find and select for "Drivers & Firmware" in the Categories list and "XCP" in the "Standards" list. 3. Download and install the available version of the "XCP Sample Implementation". 4. In MATLAB, navigate to the installed sample package location, and browse to .\Samples\XCPSim\CANape. 5. This Simulink XCP example will use the XCPSIM.a2l file and the XCPsim.exe slave simulator. Run XCPsim.exe.
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.
Plot the results to see the measurement values for Triangle and PWM from the slave. The X-axis corresponds to the simulation timestep.