This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

CAN FD Pack

Pack individual signals into message for CAN FD bus

Library

Vehicle Network Toolbox: CAN FD Communication

Description

The CAN FD Pack block loads signal data into a message at specified intervals during the simulation.

Note

To use this block, you also need a license for Simulink® software.

The CAN FD Pack block has one input port by default. The number of block inputs is dynamic and depends on the number of signals you specify for the block. For example, if your block has four signals, it has four block inputs.

This block has one output port, Msg. The CAN FD Pack block takes the specified input parameters and packs the signals into a bus message.

The block outputs CAN FD messages as a Simulink bus signal. For more information on Simulink bus objects, see Composite Signals (Simulink).

Other Supported Features

The CAN FD Pack block supports:

  • The use of Simulink Accelerator™ mode. Using this feature, you can speed up the execution of Simulink models. For more information, see Acceleration (Simulink).

  • Code generation to deploy models to targets.

    Note

    Code generation is not supported if your signal information consists of signed or unsigned integers greater than 32 bits long.

Dialog Box

Use the Function Block Parameters dialog box to select your CAN FD Pack block parameters.

Parameters

Data is input as

Select your data signal:

  • raw data: Input data as a uint8 vector array. If you select this option, you only specify the message fields. All other signal parameter fields are unavailable. This option opens only one input port on your block.

  • manually specified signals: Allows you to specify data signal definitions. If you select this option, use the Signals table to create your signals. The number of block inputs depends on the number of signals you specify.

  • CANdb specified signals: Allows you to specify a CAN database file that contains message and signal definitions. If you select this option, select a CANdb file. The number of block inputs depends on the number of signals specified in the CANdb file for the selected message.

Note

The block supports the following input signals data types: single, double, int8, int16, int32, int64, uint8, uint16, uint32, uint64, and boolean. The block does not support fixed-point data types.

CANdb file

This option is available if you specify that your data is input via a CANdb file in the Data is input as list. Click Browse to find the CANdb file on your system. The message list specified in the CANdb file populates the Message section of the dialog box. The CANdb file also populates the Signals table for the selected message.

Note

File names that contain non-alphanumeric characters such as equal signs, ampersands, and so forth are not valid CAN database file names. You can use periods in your database name. Rename CAN database files with non-alphanumeric characters before you use them.

Message list

This option is available if you specify that your data is input via a CANdb file in the Data is input as field and you select a CANdb file in the CANdb file field. Select the message to display signal details in the Signals table.

Message

Name

Specify a name for your CAN FD message. The default is Msg. This option is available if you choose to input raw data or manually specify signals. This option in unavailable if you choose to use signals from a CANdb file.

Protocol mode

Specify the message protocol mode as CAN FD or CAN.

Identifier type

Specify whether your message identifier is a Standard or an Extended type. The default is Standard. A standard identifier is an 11-bit identifier and an extended identifier is a 29-bit identifier. This option is available if you choose to input raw data or manually specify signals. For CANdb specified signals, the Identifier type inherits the type from the database.

Identifier

Specify your message ID. This number must be a positive integer from 0 through 2047 for a standard identifier and from 0 through 536870911 for an extended identifier. You can also specify hexadecimal values using the hex2dec function. This option is available if you choose to input raw data or manually specify signals.

Length (bytes)

Specify the length of your message. For CAN messages the value can be 0-8 bytes; for CAN FD the value can be 0-8, 12, 16, 20, 24, 32, 48, or 64 bytes. If you are using CANdb specified signals for your data input, the CANdb file defines the length of your message. This option is available if you choose to input raw data or manually specify signals.

Remote frame

(Disabled for CAN FD protocol mode.) Specify the CAN message as a remote frame.

Bit Rate Switch (BRS)

(Disabled for CAN protocol mode.) Enable bitrate switch.

Signals Table

This table appears if you choose to specify signals manually or define signals using a CANdb file.

If you are using a CANdb file, the data in the file populates this table automatically and you cannot edit the fields. To edit signal information, switch to manually specified signals.

If you have selected to specify signals manually, create your signals manually in this table. Each signal you create has the following values:

Name

Specify a descriptive name for your signal. The Simulink block in your model displays this name. The default is Signal [row number].

Start bit

Specify the start bit of the data. The start bit is the least significant bit counted from the start of the message data. For CAN the start bit must be an integer from 0 through 63, for CAN FD 0 through 511, within the number of bits in the message. (Note that message length is specified in bytes.)

Length (bits)

Specify the number of bits the signal occupies in the message. The length must be an integer from 1 through 64. The sum of all the signal lengths in a message is limited to the number of bits in the message length; that is, all signals must cumulatively fit within the length of the message. (Note that message length is specified in bytes and signal length in bits.)

Byte order

Select either of the following options:

  • LE: Where the byte order is in little-endian format (Intel®). In this format you count bits from the start, which is the least significant bit, to the most significant bit, proceeding to the next higher byte as you cross a byte boundary. For example, if you pack one byte of data in little-endian format, with the start bit at 20, the data bit table resembles this figure.

    Little-Endian Byte Order Counted from the Least Significant Bit to the Highest Address

  • BE: Where byte order is in big-endian format (Motorola®). In this format you count bits from the start, which is the least significant bit, to the most significant bit, proceeding to the next lower byte as you cross a byte boundary. For example, if you pack one byte of data in big-endian format, with the start bit at 20, the data bit table resembles this figure.

    Big-Endian Byte Order Counted from the Least Significant Bit to the Lowest Address

Data type

Specify how the signal interprets the data in the allocated bits. Choose from:

  • signed (default)

  • unsigned

  • single

  • double

    Note: If you have a double signal that does not align exactly to the message byte boundaries, to generate code with Embedded Coder® you must check Support long long under Device Details in the Hardware Implementation pane of the Configuration Parameters dialog.

Multiplex type

Specify how the block packs the signals into the message at each timestep:

  • Standard: The signal is packed at each timestep.

  • Multiplexor: The Multiplexor signal, or the mode signal is packed. You can specify only one Multiplexor signal per message.

  • Multiplexed: The signal is packed if the value of the Multiplexor signal (mode signal) at run time matches the configured Multiplex value of this signal.

For example, a message has four signals with the following types and values.

Signal NameMultiplex TypeMultiplex Value
Signal-AStandardN/A
Signal-BMultiplexed1
Signal-CMultiplexed0
Signal-DMultiplexorN/A

In this example:

  • The block packs Signal-A (Standard signal) and Signal-D (Multiplexor signal) in every timestep.

  • If the value of Signal-D is 1 at a particular timestep, then the block packs Signal-B along with Signal-A and Signal-D in that timestep.

  • If the value of Signal-D is 0 at a particular timestep, then the block packs Signal-C along with Signal-A and Signal-D in that timestep.

  • If the value of Signal-D is not 1 or 0, the block does not pack either of the Multiplexed signals in that timestep.

Multiplex value

This option is available only if you have selected the Multiplex type to be Multiplexed. The value you provide here must match the Multiplexor signal value at run time for the block to pack the Multiplexed signal. The Multiplex value must be a positive integer or zero.

Factor

Specify the Factor value to apply to convert the physical value (signal value) to the raw value packed in the message. See Conversion Formula to understand how physical values are converted to raw values packed into a message.

Offset

Specify the Offset value to apply to convert the physical value (signal value) to the raw value packed in the message. See Conversion Formula to understand how physical values are converted to raw values packed into a message.

Min, Max

Define a range of signal values. The default settings are -Inf (negative infinity) and Inf, respectively. For CANdb specified signals, these settings are read from the CAN database. For manually specified signals, you can specify the minimum and maximum physical value of the signal. By default, these settings do not clip signal values that exceed them.

Conversion Formula

The conversion formula is

raw_value = (physical_value - Offset) / Factor
where physical_value is the original value of the signal, and raw_value is the packed signal value.

Introduced in R2018a