This example shows how to use XCP blocks to directly stimulate measurement values from a slave in Simulink®.
This example shows how to use an XCP slave simulator available for free download from Vector, and Vector Virtual CAN channels.
Browse to www.vector.com and click on Downloads.
In the Categories list select Drivers and Firmware.
In the Standards list select XCP.
Download and install the available version of the XCP Sample Implementation.
Find .\Samples\XCPSim\CANape in your MATLAB® installation folder.
You will use the XCPSim.a2l file and the XCPsim.exe slave simulator to run this example.
This example shows how to use the XCP Configuration, XCP Data Stimulation, and XCP Transport Layer blocks. You also need to install a third-party XCP Sample implementation from Vector, which includes a slave simulator and an A2L file.
Create a model to stimulate date for the Triangle measurement for the 100ms event on the slave.
Create a new Simulink Model and add an XCP Configuration block to it.
Double click on the model and open the Block Parameters dialog box.
Type Config1 in the Config name field.
Click Browse in the A2L File field and browse to the location with your downloaded implementation files and select XCPSIM.a2l.
Add an XCP CAN Transport Layer block to the model and open the Block Parameters dialog box.
Select Vector Virtual 1 (Channel 1) in the Device list. This will serve as the transport layer which transfers the XCP messages over CAN via the configured virtual channel.
Add an XCP Data Stimulation block to the model. Double click the block to open the Block Parameters dialog box.
Config1 from the Config name list.
100ms (100ms) from the Event name list.
Triangle from the All Measurements list and click the blue arrow to move this measurement to the Selected Measurements list.
Add a Counter Limited source block to the model and open the block mask. Set:
Upper limit to 255.
Sample time to -1.
Add a scope to your model.
Connect the Counter Limited block to the XCP Data Stimulation block and to the scope.
Run the model.