Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

CAN Bus load

In the XNET Bus Monitor there is an indicator for the bus load. Unfortunately I have not the sources for the bus monitor, so I can't figure out how it works.

 

How to detect the bus load on CAN programmatically?

 

Madottati

0 Kudos
Message 1 of 6
(4,287 Views)

I'm unsure how NI calculates it, and since this is often requested they should publish an example VI for this.  That being said you can use the code buried in the examples to figure out how long a transmission should take, and with that you might be able to calculate bus load:

 

 

<LabVIEW>\examples\CompactRIO\Module Specific\NI 985x\cRIO CAN Periodic Transmit\CAN Rate Calculator.vi

 

That being said this won't be completely accurate as it won't take into account frames that need to be resent due to a collision and retransmit.  If you do go down this route be sure and turn on the Echo so that any frames you send will also be read and be part of the bus load calculation.

0 Kudos
Message 2 of 6
(4,270 Views)

Can You Please Share this VI Here.

 

<LabVIEW>\examples\CompactRIO\Module Specific\NI 985x\cRIO CAN Periodic Transmit\CAN Rate Calculator.vi

 

Unfortunately I'm unable to get the VI in the Specified path. It would be a great help if you can Share the VI here. I'm using LV2020. 

 

 

Regards

Srinibas

0 Kudos
Message 3 of 6
(2,868 Views)

Using this VI with 500k baud, 8 bytes per frame, and extended ID, it says the maximum frames per second is 3816.  So to keep things simple what I'd do is count the number of frames read and written (remember to use echo) in one second.  Then divide that by the maximum for your bus, and that gives you the percentage of bus load.  It won't be exact but will give an overall idea.  This is a pretty neat idea and something I could see doing in the background automatically, but it does get complicated with CAN-FD

0 Kudos
Message 4 of 6
(2,854 Views)

Thank You 

 

0 Kudos
Message 5 of 6
(2,815 Views)

So the timing information is in that VI for CAN 2.0 data.  This should match the timing and bit packing information found in the spec.  Here is the wiki page on it.

 

For CAN-FD you'd need to create a similar VI for the timing that matches the bit packing found in this page.  This is complicated by the fact that FD can be ran at the higher baud rate all the time, but more common is to have the slower baud rate used until the payload is sent, and then have the higher baud sent.

 

But if you are dealing with a somewhat static environment, you might be able to use some shortcuts.  If it were me a close enough solution would be to run a known set of data on the bus, then run the bus monitor and see what the percentage load is.  Do this for a table of various bus loads, and then when you read the frames you have an idea of what your bus load is roughly.

0 Kudos
Message 6 of 6
(2,808 Views)