CAN Output
- Updated2025-04-03
- 6 minute(s) read
Write a CAN frame to be transmitted.
Complete the following steps to write to a CAN port using CAN Output.
- Use the Add Targets and Devices dialog box to add the CAN module to your CompactRIO configuration. Right-click the CAN module in the Project Explorer window and select Properties to specify the configuration properties for the module.
- Create an FPGA I/O item for CAN by right-clicking the FPGA target under My Computer in the Project Explorer window, selecting New»FPGA I/O, and then adding CAN»NI 9852»CAN0 (or CAN»NI 9853»CAN0) and/or CAN»NI 9852»CAN1 (or CAN»NI 9853»CAN1) to the FPGA I/O list. Refer to New FPGA I/O dialog box (FPGA Module) for more information about creating and adding FPGA I/O to your CompactRIO configuration.
- Place an I/O Node from the FPGA I/O palette onto your FPGA VI diagram.
- Right-click the I/O Node and select Select FPGA I/O»CAN»NI 9852»CAN0 (or Select FPGA I/O»CAN»NI 9853»CAN0) or Select FPGA I/O»CAN»NI 9852»CAN1 (or Select FPGA I/O»CAN»NI 9853»CAN1).
- Right-click the I/O Node and select Change to Write to use the I/O node for CAN Output.
- Right-click the I/O Node and choose Properties to select the Data Type.
Start communication on the CAN port prior to using CAN Output. To start communication, enable Auto Start in the Module Configuration, or invoke the Start method.
The communication path from LabVIEW FPGA to the CAN port on the module is implemented as a FIFO. The CAN Output node waits for an available element in the FIFO, then writes the frame to the FIFO. If no other CAN frame exists in the FIFO, the CAN frame will begin to transmit immediately.
CAN Output does not wait for the requested transmit to complete on the network (acknowledgement). Call CAN Output followed by Wait on Transmit Complete (I/O Method) if you want to transmit CAN frames one at a time.
Write multiple frames to the output FIFO if you want to transmit CAN frames as fast as possible. The CAN module submits these frames to the SJA1000 controller as fast as possible, thus generating close to 100% busload.
When the output FIFO is full, the CAN Output node waits for an element to become available, then writes the frame to the FIFO. The Output Timeout (ms) of the CAN Advanced Port Configuration dialog box specifies how long to wait for a new element to become available, which occurs when a frame from a previous CAN Output transmits successfully onto the network. If you specify Output Timeout (ms) of 0, the CAN Output node returns an error status of TRUE (error) if a new element is not available (non-blocking). When an error is returned, attempt CAN Output of the same frame again at a later time.
Properties Dialog
Selects the Data Type for the CAN frame written to the CAN Input node. The available values are Cluster (default) and Array of 6 U32.
The benefits of using the Cluster data type are:
- Simpler block diagram (easy to use)
- Fast and efficient, if you limit use to the block diagram only (not front panel)
The benefits of the Array of 6 U32 data type, and handshaking integers to the host VI one at a time, are:
- Faster for transfer to/from host VI
- Fewer FPGA gates
Refer to the Using Clusters and Arrays in LabVIEW FPGA Application Note for more information on the use of clusters and arrays.
Node Inputs
Data Type | Element | Description |
---|---|---|
Timestamp High | Ignored. The transmit request always occurs as soon as possible (not timed). | |
Timestamp Low | Ignored. The transmit request always occurs as soon as possible (not timed). | |
Identifier |
Arbitration ID. If bit 29 (20000000 hexadecimal) is clear, this ID uses the standard format (11-bit). If bit 29 is set, this ID uses extended format (29-bit). This representation of the CAN identifier is the same as NI-CAN. |
|
Type | Type of frame.
|
|
InfoA | Reserved for future use. | |
InfoB | Reserved for future use. | |
Data Length |
For data frames, this provides the number of bytes in Data (0–8). For remote frames, this indicates the number of bytes requested. |
|
Data |
For data frames, this provides the data bytes. The array uses a fixed size of 8 bytes. If the Data Type is defined as Array of 6 U32, the CAN frame is represented as an array of 6 U32 values, as shown in the following table. |
Most significant byte | ... | ... | Least significant byte |
---|---|---|---|
Timestamp (upper U32) | |||
Timestamp (lower U32) | |||
Identifier | |||
Type | InfoA | InfoB | DataLength |
Data[0] | Data[1] | Data[2] | Data[3] |
Data[4] | Data[5] | Data[6] | Data[7] |
In the table above, the meaning of each element is the same as the Cluster data type.