How to Use CAN FD With Automotive Diagnostic Command Set and Configure Bit Timings Using Custom Baud Rates

Updated May 22, 2023

Environment

Hardware

  • USB-8502
  • PCI-8512
  • PCI-8513
  • PXI-8512
  • PXI-8513
  • NI-9860
  • NI-9862
  • PCIe-8510

Software

  • Automotive Diagnostic Command Set Toolkit

Driver

  • NI-XNET

I want to establish CAN FD communication using the Automotive Diagnostic Command Set Toolkit (ADCS) and an NI-XNET CAN interface. How can I use a custom baud rate to configure the bit timing settings like the sample point that my CAN FD bus requires?

When a numeric baud rate (e.g. 500000) is provided to ADCS, the default XNET bit timings will be used, which may not be compatible with some CAN bus configurations.
With CAN FD, it is critical that the bit timing settings match for all nodes on the bus, most importantly the resulting baud rates and the sample points. In case of mismatch, communication might be unreliable or not work at all. Using NI-XNET’s custom baud rates allows configuration of these settings.

LabVIEW API

To use custom baud rates with Open Diagnostic on CAN FD.vi, you need to set the inputs Baud Rate, FD Baud Rate and IO Mode using the steps listed below.


 
  1. First, generate the custom baud rates values (for both nominal and FD baud rate) for your bit timing requirements according to this document: Error or Incorrect Frames When Using NI-XNET in CAN FD & BRS .
  2. Set Baud Rate to the generated custom nominal baud rate. This is the baud rate used for CAN 2.0 and CAN FD frames, and during the CAN FD+BRS frame arbitration phase.
  3. Set FD Baud Rate to the generated custom FD baud rate. This is the baud rate used during the CAN FD+BRS frame data phase.
  4. Set IO Mode to CAN FD+BRS to enable using the FD Baud Rate. This parameter controls which kind of CAN frames ADCS sends to the ECU.
  5. Optionally, change Max DLC to an appropriate number. Max DLC is the maximum CAN FD frame payload length to be transmitted to the ECU by ADCS, the default is 8 bytes. Independent from this setting, the ECU may respond with any valid frame payload length. Frame padding can be configured using the property Fill CAN Frames via Diag Set Property.vi.


Note: To enter the hexadecimal custom baud rate in LabVIEW, follow these instructions:
  1. Right-click the baud rate constant or control and select Properties.
  2. On the Display Format tab, change Type to Hexadecimal.
  3. Click OK.
  4. Now, you can enter the hexadecimal value into the constant or control.





C API
When using the ADCS C API, the process is the same as in LabVIEW. The values are used as parameters of the function ndOpenDiagnosticOnCanFD.

Additional Information
A custom baud rate is a 64-bit integer, which encodes the bit timings used by the CAN controller. For more information, refer to this document: Error or Incorrect Frames When Using NI-XNET in CAN FD & BRS or the NI-XNET help.