%% Get Started with CAN Communication in Simulink
% This example shows how to use MathWorks virtual CAN channels to set up transmission and reception of CAN messages in Simulink. The virtual channels are connected in a loopback configuration.
% Vehicle Network Toolbox provides Simulink blocks for transmitting and receiving live messages via Simulink models over networks using the Controller Area Network (CAN) format. This example uses the CAN Configuration, CAN Pack, CAN Transmit, CAN Receive, and CAN Unpack blocks to perform data transfer over a CAN bus.
%
%% Transmit and Receive CAN Messages
% Create a model to transmit and receive a CAN message carrying a sine wave data signal. The model transmits a single message per timestep. A DBC-file defines the message and signal used in the model.
%
%
%% Process CAN Messages
% The CAN Receive block generates a function-call trigger if it receives a new message at any particular timestep. This indicates to other blocks in the model that a message is available for decoding activities. Signal decoding and processing is performed inside the Function-Call Subsystem.
%
%
%% Visualize Signal Data
% Plot the sine wave values before and after transmission. The X-axis corresponds to the simulation timestep and the Y-axis corresponds to the value of the signal. The phase shift between the two plots represents the propagation delay as the signal travels across the network.
%
%
%% Extend the Example
% This example uses MathWorks virtual CAN channels. You can connect your models to other supported hardware. You can also modify the model to transmit at periodic rates.
%
% Copyright 2021 The MathWorks, Inc.