Main Content

CAN FD Transmit

Transmit CAN FD message to selected CAN FD device

  • CAN FD Transmit block

Libraries:
Vehicle Network Toolbox / CAN FD Communication

Description

The CAN FD Transmit block transmits messages to the CAN network using the specified CAN device. The CAN FD Transmit block can transmit a single message or an array of messages during a given timestep. To transmit an array of messages from a signal bus, use a Bus Creator (Simulink) or Vector Concatenate, Matrix Concatenate (Simulink) block.

Note

You need a license for both Vehicle Network Toolbox™ and Simulink® software to use this block.

The CAN FD Transmit block has one input port. This port accepts a CAN message packed using the CAN FD Pack block. It has no output ports.

CAN is a peer-to-peer network, so when transmitting messages on a physical bus at least one other node must be present to properly acknowledge the message. Without another node, the transmission will fail as an error frame, and the device will continually retry to transmit.

Other Supported Features

The CAN FD Transmit 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).

The CAN FD Transmit block supports the use of code generation along with the packNGo function to group required source code and dependent shared libraries.

Code Generation

Vehicle Network Toolbox Simulink blocks allow you to generate code, enabling models containing these blocks to run in accelerator, rapid accelerator, external, and deployed modes.

Code Generation with Simulink Coder

You can use Vehicle Network Toolbox, Simulink Coder™, and Embedded Coder® software together to generate code on the host end that you can use to implement your model. For more information on code generation, see Generated Code Compilation (Simulink Coder).

Shared Library Dependencies

The block generates code with limited portability. The block uses precompiled shared libraries, such as DLLs, to support I/O for specific types of devices. With this block, you can use the packNGo function supported by Simulink Coder to set up and manage the build information for your models. The packNGo (Simulink Coder) function allows you to package model code and dependent shared libraries into a zip file for deployment. You do not need MATLAB® installed on the target system, but the target system needs to be supported by MATLAB.

To set up packNGo:

set_param(gcs,'PostCodeGenCommand','packNGo(buildInfo)');

In this example, gcs is the current model that you want to build. Building the model creates a zip file with the same name as model name. You can move this zip file to another machine and there build the source code in the zip file to create an executable which can run independent of MATLAB and Simulink. The generated code compiles with both C and C++ compilers. For more information, see Code Compilation Customization (Simulink Coder).

Note

On Linux® platforms, you need to add the folder where you unzip the libraries to the environment variable LD_LIBRARY_PATH.

Examples

Ports

Input

expand all

CAN FD messages to transmit, as packed by a CAN FD Pack block, input as a Simulink signal bus of type CAN_FD_MESSAGE_BUS.

Data Types: CAN_FD_MESSAGE_BUS

Parameters

expand all

Tip

Configure the CAN FD Configuration block in the model before you configure the CAN FD Transmit block parameters.

Select the CAN device and channel for transmitting CAN FD messages to the network. This list shows all the devices installed on the system. It displays the vendor name, the device name, and the channel ID. The default is the first available device on your system.

Note: When using PEAK-System devices, CAN FD Transmit blocks in multiple enabled subsystems might skip some messages. If possible, replace the enabled subsystems with a different type of conditional subsystem, such as an if-action, switch-case-action, or triggered subsystem; or redesign your model so that all the CAN FD Transmit blocks are contained within a single enabled subsystem.

Programmatic Use

Block Parameter: Device
Type: character vector, string

The following parameters define transmit options.

When event-based transmission is enabled, messages are transmitted only at those time steps when a change in message data is detected. When the input data matches the most recent transmission for a given message ID, the message is not re-transmitted.

Event and periodic transmission can both be enabled to work together simultaneously. If neither is selected, the default behavior is to transmit the current input at each time step.

Programmatic Use

Block Parameter: EnableEventTransmit
Type: character vector, string
Values: 'off' | 'on'
Default: 'off'

Select this option to enable periodic transmission of the message on the configured channel at the specified message period. The period references real time, regardless of the Simulink model time step size (fundamental sample time) or block execution sample time. This is equivalent to the MATLAB function transmitPeriodic.

The periodic transmission is a nonbuffered operation. Only the last CAN message or set of messages present at the input of the CAN FD Transmit block is sent when the time period occurs.

Programmatic Use

Block Parameter: EnablePerioicTransmit
Type: character vector, string
Values: 'off' | 'on'
Default: 'off'

Specify a period in seconds. This value is used to transmit the message in the specified period. By default this value is 1.000 seconds.

Programmatic Use

Block Parameter: MessagePeriod
Type: character vector, string
Values: double
Default: '1.000'

Extended Capabilities

Version History

Introduced in R2018a