01-09-2019 02:41 AM
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
01-09-2019 08:17 AM
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
09-28-2021 04:48 PM
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
09-29-2021 08:25 AM - edited 09-29-2021 08:26 AM
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
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
10-04-2021 06:56 AM
Thank You Hooovahh,
Appreciated for the VI and Explanation.
Actually, i am working for getting the BUS Load information for CAN FD. Could you please suggest any idea for implementation ?
10-04-2021 08:07 AM
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord