Vehicle Network Toolbox

CAN Bus Communication from MATLAB and Simulink

Vehicle Network Toolbox lets you interact directly with a CAN bus from MATLAB or Simulink. You can execute toolbox functions from the MATLAB command line and through MATLAB programs. The toolbox also contains Simulink blocks that enable you to connect a Simulink model to a CAN bus.

Configuring CAN Channels

CAN channel functions in MATLAB and CAN configuration blocks in Simulink enable you to define a connection to Vector CAN interface hardware that establishes a physical connection with a CAN bus. The toolbox provides CAN channel functions to query and configure CAN interface hardware settings, such as bus speed and transceiver settings. You can also verify other CAN channel properties, such as the number of messages available and the number of messages received or transmitted on the channel. By attaching Vector CAN database files to CAN channels, incoming messages are automatically presented using information stored in the database. After defining a CAN channel, you can send and receive CAN messages on the channel.

Sending and Receiving CAN Packets

CAN messages contain properties for storing the CAN message identifier (standard 11-bit or extended 29-bit), the time stamp, and up to 8 bytes of CAN data. Transmit and receive functions and blocks in the toolbox enable the sending and receiving of CAN messages over CAN channels. For large data sets, you can log CAN messages for offline analysis.

Building and Extracting Signals from CAN Messages

Vehicle Network Toolbox provides functions and blocks for encoding and decoding CAN messages. CAN message data may contain data representing multiple signals. Unpack functions and blocks let the user specify start bit, signal length, data type, and byte ordering. Pack functions and blocks provide the same options for building up data for CAN message transmission.

Logging and Replaying CAN messages

Using the CAN Log block in the toolbox, you can save CAN messages received by your model to a MAT-file. You can then use the CAN Replay block to replay the messages in another Simulink model. The CAN Replay block preserves the time stamps of the logged data so the replayed data will have the same timing characteristics as the recorded data.

Next: Communicating over the XCP Protocol

Try Vehicle Network Toolbox

Get trial software

CAN-Bus Daten direkt in MATLAB verarbeiten

View webinar