How to use Extended ID in CAN Frames with NI-CAN

Updated Nov 28, 2022

Environment

Hardware

  • USB-8473

Software

  • LabVIEW

Driver

  • NI-CAN

Why are my 29 bits extended arbitration IDs incorrect when writing to a USB-CAN device? This happens even when I use Bus Monitor to check the arbitration IDs.

A conversion must be performed on the extended arbitration IDs before writing and reading them. Before the arbitration ID is written using either the ncWriteNet.vi or the ncWriteNetMult.vi, the extended arbitration ID must be OR'd with the hexadecimal representation 0x20000000. If the ID is being read with the ncReadNet.vi or the ncReadNetMult.vi, the extended arbitration ID must be XOR'd with the same hexadecimal number 0x20000000. This will produce the correct arbitration ID.

The reason for this is that the 30th bit is used to identify extended or standard arbitration ID. The arbitration ID is represented by 32 bits. When the 30th bit is high, extended arbitration IDs will be used. This uses 29 bits to represent the arbitration ID. When the 30th bit is low, the standard arbitration ID is used. This uses 11 bits to represent the arbitration ID.

Note: Most of the shipping examples do not incorporate this logic to support extended arbitration ID's. An example that does include this is the "Transmit Receive same Port.vi", you can find this NI-CAN example in the NI Example Finder.
The front panel of the example is shown as below in Figure 1 and you can manually set whether to use the extended IDs or not.

Figure 1