www.gusucode.com > vnt 源码程序 matlab案例代码 > vnt/demoVNTSL_XCPCANCommunicationExample.m

    %% XCP Data Acquisition over CAN
% This example shows you how to use XCP blocks to directly acquire
% measurement values from a slave in Simulink(R). It uses an XCP slave 
% simulator available for free download from Vector, and Vector Virtual CAN 
% channels. 
%
% Vehicle Network Toolbox(TM) 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.

%%
% Copyright 2012-2013 The MathWorks, Inc.

%%
%
% <<../demoVNTSL_XCPCANCommunication_Model.png>>
%

%% 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.

%%
%
% <<../demoVNTSL_XCPCANCommunication_Subsystem.png>>
%

%% 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.
%
% <<../demoVNTSL_XCPCANCommunication_Scope.png>>
%