Main Content

Control Output Data Type of the CAN Unpack Block

This example shows how to control the output data type of the CAN Unpack block using Signal Specification blocks.

The output of the CAN FD Unpack block can also be controlled in the same way.

This example uses the CAN Configuration,CAN Pack, CAN Transmit, CAN Receive, CAN Unpack, and Signal Specification (Simulink) blocks to perform a data transfer over a CAN bus and unpack them into the specified data type.

open_system("ControlOutputDataTypeOfCANUnpackBlock");

Explore the Example Model

  • Transmission: The constant values are packed using the CAN Pack block, which is then transmitted using the CAN Transmit block over a MathWorks® virtual channel.

  • Reception: The CAN Receive blocks receive the messages and trigger a function call when the message arrives.

  • Processing: The messages received are processed inside the CAN Unpack subsystem, where the messages are unpacked. The data type of the unpacked messages is controlled using the Signal Specification block.

CAN Unpack Subsystem

The signal specification block is used inside the CAN Unpack Subsystem to control the data type of the unpacked signal. By default, the data type of the unpacked signals is double. Using the Signal Specification block, the data type of the signal line can be set. In this example the data type of 'Signal1' is set to 'uint32' and the type of 'Signal2' is set to 'int32'. The transmitted signals have the data type 'double'.

Simulate the model to observe the base data types of the output signal lines.