Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Baud Rate Calculator VI?

Solved!
Go to solution

I'm looking for a VI that will give me the 64 bit custom code for CAN and CAN FD baud rates given a set of inputs.  By that I mean I want to give a VI a desired baud rate, and sample point, and it returns the custom hex code that is valid for the custom Baud Rate property:

 

https://www.ni.com/docs/en-US/bundle/ni-xnet/page/nixnet/nxpropsession_intfbaudrate64.html

 

and CAN FD property:

 

https://www.ni.com/docs/en-US/bundle/ni-xnet/page/nixnet/propertyclustercan64bitfdbaudrate.html

 

Yes I know you can just type in the baud rate and sample point into the dialog in the XNet Database Editor, or Bus Monitor in MAX.  But I work with a variety of hardware and don't want the user of my software to have to calculate the hex code, I just want them to give a baud rate and sample point and have the software figure it out.

 

I found a VI posted here which does generate a 32 bit valid custom hex for the interface, which appears to work in the 64 bit property too.  But I'm also looking to do this with the CAN FD baud.  I'll try editing that VI to support my needs but if that doesn't work out does someone have code, or know of code buried in the vi.lib or something that does this calculation?  Thanks.

0 Kudos
Message 1 of 13
(6,644 Views)

I feel a little silly because again I think I came up with my own solution.  I looked at the VI I linked to and I think I made all the needed changes for it to be applied to the 32 bit CAN FD custom baud settings.  My quick test with my hardware appears to work.  If anyone has another solution or a similar set of code for the 64 bit settings feel free to reply here.

Message 2 of 13
(6,606 Views)
Solution
Accepted by Hooovahh

Here is a copy of what I have for the CAN FD baud rates. I highly recommend reviewing it as it is 5 years old and I haven't looked at it since I made it.

 

I think finessing it into a 64-bit is probably doable, but I am not very familiar withe the 64-bit version as I haven't thought much about it in the last 5 years.

Message 3 of 13
(6,564 Views)

Hi Hooovahh,

 

I have a VI that converts 32-bit custom baud rate to 64-bit and vice versa. It does some bit shifting based on the information from the XNET Help. Hope that it is helpful to you.

Senior Technical Support Engineer | CLD CTA | NI


DISCLAIMER: The attached Code is provided As Is. It has not been tested or validated as a product, for use in a deployed application or system, or for use in hazardous environments. You assume all risks for use of the Code and use of the Code is subject to the Sample Code License Terms which can be found at: http://ni.com/samplecodelicense

Message 4 of 13
(6,543 Views)

I always try to "Engineer Ambitiously", but NI often gets in the way and breaks links on their own website.

 

The first 2 links now only go to help files.

0 Kudos
Message 5 of 13
(4,348 Views)

It is hard to know, but I think this link is one of them.  I also can't edit my first post.

Message 6 of 13
(4,336 Views)

Thanks Hooovahh

0 Kudos
Message 7 of 13
(4,314 Views)

Hello Hooovahh,

 

I've the same problem, but the attached vis don't give the same solution as XNET Bus Monitor... I work with XNET on a CAN-FD bus. I've 2 baudrates to configure: 500k and 2M. My goal is a sample point of 75%. Playing with only Baudrate value and sample point I obtain 0x800F00A0032D43 fo 2M/75% and 0x32A0041C09 for 500k/75%.

 

Cisco_0-1717574797461.png  Cisco_1-1717574875180.png

 

I'm looking for a vi to convert 64-bits baudrate and sample point into a custom baudrate, exactly like the screenshots of xnet bus monitor. Do you know if this king of tool exists? I've tested all the vis of this discussion without success...

 

It will be clearlier for the final user to configure directly baudrate and sample point instead of use other tool to obtain custom badrate and report it in the final application...

 

Thank you per advance!

 

 

 

 

Francis M
0 Kudos
Message 8 of 13
(1,548 Views)

Because of how the timing parameters work, there will often be multiple correct answers to a single baud and sample point.  Using the VI NI posted here I put in 500k and a 75% sample point. It found 11 combinations of the timing parameters that meet those requirements.  If you use the Show Only Max SJW then you still have 4 different timing parameters that meet that requirement.  Keep in mind this is for the 40MHz frequency. I think most or all NI hardware use this.

 

My point is that The XNet window you show will only show you one valid solution, and it might not be one of them that the tool came up with.  If you have only a few known rate, and sample points you use, then maybe it would be best to just hard code those.  When the user wants 500k at 75% just use the constant the XNet tool gives you.  If you want to have a UI where the user picks the baud rate and sample point, then you can use NI's tool.

0 Kudos
Message 9 of 13
(1,535 Views)

Thank you for your feedback !

I understand there is a lot of combinations, the custom baudrate depends on some others parameters.

BUT I don't understand why the CustomBaudrate proposed by XNET Bus Monitor doesn't appear in the list populed by the vi... I would imaginate that the "NI default" value" should be in the list... In my example, I use a CAN HS/FD Interface USB-8502.

 

Cisco_2-1717681432628.png

 

Cisco_0-1717681320560.png Cisco_1-1717681380888.png

 

 Why the lis is not complete?

Francis M
0 Kudos
Message 10 of 13
(1,509 Views)