On-board CAN Transmit
Transmit messages to CAN network using on-board Arduino CAN controller
Since R2024b
Add-On Required: This feature requires the Simulink Support Package for Arduino Hardware add-on.
Libraries:
Simulink Support Package for Arduino Hardware /
Communication
Description
Use the On-board CAN Transmit block to transmit CAN messages from the on-board Arduino® CAN controller. The block transmits messages from the mailboxes into the CAN network in a first-in, first-out method at every sample time.
Supported Arduino Boards
Arduino Due
Arduino compatible Teensy 4.0 and 4.1
Ports
Input
Message — Transmitted CAN messages
message vector
The block accepts CAN messages in raw or CAN message formats.
Raw data — To accept the message as a
uint8
vector array, set Data is input as toRaw data
.CAN message — To accept the message in the CAN message format, set Data is input as to
CAN Msg
.
Data Types: uint8
| CAN Msg
Output
Status — Status of output CAN message
scalar
The block outputs CAN message transmission status.
Arduino Due board uses these transmission statues.
1
— The CAN controller transmits data successfully on to the CAN network.0
— The CAN controller cannot transmit data successfully on to the CAN network or if the transmission CAN mailbox is full.
Arduino Teensy boards use these transmission statues.
-2
— Value in the transmit error counter (TEC) is >= 96 due to CAN controller failure or accumulation of transmission errors.-1
— The CAN controller cannot transmit data successfully on to the CAN network or if no transmit mailboxes are available to transmit data on to the CAN network.0
— No transmission queue available.1
— The CAN controller transmits data successfully on to the CAN network.
Dependencies
To enable this port, select Output status.
Data Types: uint8
Parameters
CAN module — CAN controller
CAN0
(default) | CAN1
| CAN2
| CAN3
Select the CAN controller according to the Arduino board you use.
Arduino Boards | Supported CAN Controller |
---|---|
Arduino Due | CAN0 and CAN1 |
Arduino compatible Teensy 4.0 and 4.1 | CAN1, CAN2, and CAN3 |
For more information on how to assign or view the Arduino board pins for the On-board CAN Receive block, click View pin map.
Data is input as — Data input type
Raw data
(default) | CAN Msg
Select the input message type.
Raw data
— Select this option to accept the input message as a 1-by-Nuint8
array.CAN Msg
— Select this option to accept the input message in CAN message format.Perform these steps to accept message in CAN message format.
To your Simulink® model, add a CAN Pack (Vehicle Network Toolbox) from the Vehicle Network Toolbox™.
Connect the output of the CAN Pack (Vehicle Network Toolbox) to the input port of the On-board CAN Transmit block.
Using the options in the Data is input as list of the CAN Pack (Vehicle Network Toolbox) block, specify if you want to create your messages or you want to upload a CAN database file. If you choose to upload a CAN database file, the CAN Pack inherits the message properties from the uploaded file.
Output status — Status of data transmission
off
(default) | on
Select this option to request status of CAN message transmission.
Message
To enable the parameters under the Message section, set
Data is input as to Raw data
.
Identifier type — CAN identifier type
Standard (11-bit identifier)
(default) | Extended (29-bit identifier)
Specify the CAN identifier type.
Standard (11-bit identifier)
— Use this option to transmit CAN messages with a standard 11-bit identifier.Extended (29-bit identifier)
— Use this option to transmit CAN messages with an extended 29-bit identifier.
Message ID — CAN message identifier
100
(default) | numeric identifier of length 11
or 29
bits
Specify the message identifier, which is 11 bits long for the standard CAN frame
size or 29 bit long for the extended CAN frame size. You can specify the value in
decimal, binary, or hexadecimal. For binary and hexadecimal formats, use bin2dec
and hex2dec
, respectively. The message
identifier is coded into a message that is sent to the CAN bus.
Message length — CAN message length
8
(default) | positive integer [1, 8]
Specify the length of CAN message in bytes.
Remote frame — Identify remote frames
off
(default) | on
Select this option to identify if the data frame the block transmits on the CAN network is a remote frame or not.
Version History
Introduced in R2024b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)