Incorrect/Unexpected Behaviour or Slow CAN Frames When Using NI-XNET in CAN FD & BRS

Updated Apr 3, 2023

Reported In

Hardware

  • NI-9862
  • PXI-8512
  • PXI-8513/2
  • PXI-8512/2
  • PXI-8513
  • PCI-8513/2
  • PCI-8513
  • PCI-8512/2
  • PCI-8512

Driver

  • NI-XNET

Other

This is reported in CAN Networks where CAN Flexible Data-Rate (CAN FD) and Bit Rate Switching (BRS) clusters are implemented.

Issue Details

I have a CAN FD and BRS cluster on my bus, which includes a NI-XNET device. All other devices seem to be working fine, however, I am seeing error frames or incorrect behavior with the default NI-XNET bit rate timing settings. The frames are slow and it causes a data loss. The frame rate of my configuration does not match the results I see in NI-XNET Bus Monitor, where the rate is much smaller.
The problem only exists when using CAN FD+BRS type of data transfer. There are no problems when using regular CAN or CAN FD.

Solution

This behavior is typically caused by a mismatch between the sample points of the devices.

The NI-XNET Bus Monitor (NI-XNET Bus Monitor) and later, can be used to determine and set the hexadecimal values needed for a specific sample point. This is explained in greater detail below.

Alternatively, you can use the XNET Interface: Baud Rate and XNET Interface: 64bit FD Baud Rate properties to set the bit timings of other devices in the node. You can find more information in the NI-XNET Hardware and Software Manual.

You can adjust the parameters of TSEG1, TSEG2 and SJW to get the values of sample point and Baud rate which work with your hardware setup. The Baud rate calculator in the NI-XNET Database editor will calculate what the resulting values of sample point and Baud rate are from the value of the parameters you use. 
NI XNET Hardware runs with 40 MHz clock rate, so it as a minimum time quantum of 25 ns.

If you get the parameters from a hardware with a different frequency, you have to adapt the values. NI-XNET hardware interprets certain values differently than the programmed value, so these may need adjusting by +1 or -1 in your configuration.
 
For example, if you are using equipment that runs on 80MHz clock rate, a rough formula is to -1, divide by 2 to go from 80MHz to 40MHz clock, and then + or -1 by trial and error to get the correct formula.

Please see Interface:CAN:64bit FD Baud Rate for more detail on which settings need +1 or -1 when programming.

Additional Information

BRS denotes the point in the CAN frame where the bit rate is switched from the nominal rate (used for the Arbitration ID and header) to the data rate. A transmitter will send the BRS as a recessive bit until the sample point, at which it immediately switches the data rate.

It is imperative that the sample point of all nodes match since the data bit rate is usually much higher than the nominal rate. If the nominal rate sample point does not match with another node, many data bits can be transmitted early or misinterpreted during the overlap between the transmitter's sample point and that of the receivers.

For example: A transmitter and receiver are configured with a data bit rate that is 4X the nominal bit rate. The transmitter sends a frame with a nominal rate sample point of 60% to a receiver with a sample point of 80%. At the sample point, the transmitter will switch to the faster bit rate while the receiver is still waiting to sample the signal. The transmitter then continues with the rest of the frame and the receiver may read an indeterminate value or an incorrect value (A). The sample points for the remainder of the data will continue to be offset and errors will ensue. 

CAN in Automation (CiA) is the international users' and manufacturers' group that develops and publishes recommendations for CAN FD. The bit rate timing values used by the default XNET baud rates were selected based on CiA recommendations, reliability testing, and the results of plugtest participation. Some device manufacturers may choose to operate with settings that differ from the XNET defaults. To avoid a BRS mismatch with other devices, care must be taken to ensure all devices on the cluster are operating with the same bit timing settings.

NI-XNET 16.1 and later includes a simple graphical utility in the bus monitor to help determine the hexadecimal values needed for a specific sample point. This utility can be accessed by opening the NI-XNET Bus Monitor, navigating to Settings» Interface and Database... to open the interface and database settings. Then from the Baud Rate drop-down, choose the <Custom> option. This will result in the dialog below, from which the Sample Point slider can be used to adjust the sample point while keeping the pre-selected baud rate. Once a proper sample point has been selected, you can copy the hexadecimal Custom Baudrate, which is the same value used for the properties discussed above. 


The below is frequently used Baudrate specification with 80% sample point. For more exact values, please refer to ECU's specification or reach out to the manufacturer.
  • CAN Baudrate : 500k, 32A0071E07(HEX)
    • BRP 1 
    • SJW 7 
    • TSEG1 30 
    • TSEG2 7 
  • CAN FD Baudrate : 2M, 800F00A0032E33 (HEX) 
    • BRP 0 
    • SJW 3 
    • TSEG1 14 
    • TSEG2 3