Transmit CAN message to selected CAN device
The CAN Transmit block transmits messages to the CAN network using the specified CAN device. The CAN Transmit block can transmit a single message or an array of messages during a given timestep. To transmit an array of messages, use a mux (multiplex) block from the Simulink® block library.
The CAN Transmit block has one input port. This port accepts a CAN message packed using the CAN Pack block. It has no output ports.
Note: You cannot have more than one Transmit block in a model using the same NI-XNET device channel.
The CAN Transmit block supports the use of Simulink Accelerator™ mode. Using this feature, you can speed up the execution of Simulink models.
For more information on this feature, see the Simulink documentation.
The CAN Transmit block supports the use of code generation along with the packNGo function to group required source code and dependent shared libraries. For more information, see Code Generation.
Vehicle Network Toolbox Simulink blocks allow you to generate code, enabling models containing these blocks to run successfully in Accelerator, Rapid Accelerator, External, and Deployed modes.
You can use Vehicle Network Toolbox, Simulink Coder™, and Embedded Coder®products together to generate code (on the host end) that you can use to implement your model for a practical application. For more information on code generation, see Program Builds.
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 the Simulink Coder, to set up and manage the build information for your models. The packNGo 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 wish 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 the source code in the zip file can be built to create an executable which can be run independent of MATLAB and Simulink. The generated code compiles with both C and C++ compilers. For more information on packNGo, see packNGo.
Use the Sink Block Parameters dialog box to select your CAN Transmit block parameters.
Select the CAN device and a channel on the device to use to transmit CAN 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.
Select this option to enable periodic transmit of the message on the configured channel to transmit at the specified period.
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.