Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-XNET C API - is there a function or a way for CAN/CANFD baud rate detection?

I run into issue of setting correct baud rate every time I communicate with a new controller. Most times setting standard baud rate (500k,1M,2M etc.) works, but often I run into a situation where I have to try a custom variant of these baud rates with different sample point % (I use NI-XNET Bus Monitor to get the Bit timing resister(BTR) values). It's like the controller provided says 500k or 1M or 2M  should work but it doesn't always.

For example : 

Setting standard 500K baud rate didn't work, for every transmit I saw bunch of error state warnings which sometimes would lead to bus off state and completely stop communication. In that case I had to use custom BTR values out of which sample point range 75%-80% worked for me.

Same situation when setting up CAN FD Arbitration 500k and Data 2M, communication would stop and go in bus off state. So after playing around different custom baud rates for both Arbitration and Data baud rate, custom baud rate of 80% sample point for 500k Arbitration and standard baud rate 2M for Data baud rate worked for me.

Long story short is there a function or steps I could follow to figure out correct baud rate without getting warnings/errors of bus communication (using nxReadSate() to get the bus state)?


Note : My drivers use NI-XNET C API's and not LabView.

 

 

0 Kudos
Message 1 of 2
(1,100 Views)

Well apart from just trying the various settings that are known to work, and then seeing if there is communication, I can't think of a way that this could be automated.

 

In the past I've seen issues like this, especially when going to CAN-FD.  For standard high speed CAN the default 500k would work just fine which I think has a sample point of 87.5%.  But as you noticed some network setups aren't as forgiving.  This might be due to less than ideal wiring, with too long of runs, nodes not an appropriate distance from the bus, or missing or incorrect terminating resistors.  But even if these things are perfect, there are times the network was really just designed to be at some random sample point.

 

In my environment I have the user specify the DUT they want to talk to at the start of the test, and from there I have a config saved telling my software what CAN setup is needed for it.  In LabVIEW I use the XNet property nodes to change the baud rate settings, on an existing database at runtime.  I suspect this is available for you in C under the XNet Cluster as well.

 

Oh and there was a tool posted by someone at NI that can create the XNet custom baud value, based on the baud and sample point here.

0 Kudos
Message 2 of 2
(1,077 Views)