CAN Input
- Updated2025-10-09
- 5 minute(s) read
Wait for a CAN frame to be received, then return that frame.
Complete the following steps to read from a CAN port using CAN Input.
- 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.
- 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 Read to use the I/O node for CAN Input.
- Right-click the I/O Node and choose Properties to select the Data Type.
Start communication on the CAN port prior to using CAN Input. Enable Auto Start in the Module Configuration, or invoke the Start method to start communication.
The Input Timeout (ms) of the CAN Advanced Port Configuration dialog box specifies how long to wait for a new frame to be received. If you specify Input Timeout (ms) of 0, the CAN Input node will simply check to see if a new frame has arrived (non-blocking).
Properties Dialog
The Data Type selects the type for the CAN frame returned by 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
Node Outputs
| Data Type | Element | Description |
|---|---|---|
| Timestamp High, Timestamp Low | Timestamp of when the frame was received. The timestamp is acquired at the end of the CAN frame. The high and low U32 represent a single U64 timestamp. The timestamp is large enough to avoid handling rollover. The timestamp is zero-based (relative). The time starts ticking at zero when CAN communication starts. The resolution is 100 ns. | |
| 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). |
|
| 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. For remote frames, the values contained in Data are not valid and should be ignored. 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.