Example Code

CAN Receive Frame and Display Current Arbitration Data Instead of Multiple Lines

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Hardware

  • Industrial Communication

    Software

  • LabVIEW

Code and Documents

Attachment

Functional Description

The VI has a subVI that was modified (NetClusterArrayTo2DStringArray_Modified_LV85.vi) to make the NI-CAN example, CAN Receive.vi, appear more like Measurement & Automation Explorer's Bus Monitor (CAN Receive_Modified_LV85.vi).  It keeps track of the arbitration IDs that are received, which allows the VI to overlay new data for previously tabled arbitration IDs or it adds a new line for newly received arbitration IDs.  This prevents the CAN Receive.vi from displaying multiple lines of the same arbitration ID and only the latest information for that particular arbitration ID.  Added programming was included to the CAN Receive example to calculate approximate Bus Load on the CAN Network.  This was derived from the NI-CAN CAN Receive with Bus Load Monitoring example.

Caveats and Additional Notes

This example uses the Frame API.  NI-CAN driver must be installed as well.

CAN Receive_Modified_LV85_FP.jpg

CAN Receive_Modified_LV85_BD.jpg

NetClusterArrayTo2DStringArray_Modified_FP.jpg

NetClusterArrayTo2DStringArray_Modified_BD.jpg

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Todd S.
NI Employee (retired)
on

Great stuff! Thanks for posting.

Todd S.
LabVIEW Community Manager
National Instruments
豆腐菜
Member
Member
on

Could you save it as 8.5

mr-vizsla
Member
Member
on

Added in LabVIEW 8.5 too...

豆腐菜
Member
Member
on

Thanks TylerC !

Raghu123
Member
Member
on

Great Stuff Tyler... I have few questions. Why do we need to enter a value for Number of Arbitrations to Monitor? What is this actually doing. Will this limit the Bus load percentage if the number of arbitration ID's that are received on BUS are morethan 10. What should we do if we need to see all the Arbitration ID's that are received on CAN bus.

mr-vizsla
Member
Member
on

If I recall, that was just to initialize the size of the array used for the table. If you have 20 IDs, you should make that 20. The only trouble here is if you are unaware of how many arbitration IDs you will be working with, then you'd need to choose a large number or change the logic that determines the array size.

Zhangj
Member
Member
on

Tyler, Iam trying this vi to monitor the busload. When I run the vi Iam seeing a Bus load of 0%, but when I monitor the busload through CAN Busmonitor from MAX i see a bus load of  6-7%. Can you please help me in trouble shooting this. I really very much need this vi. I am attaching the snapshot of the 2- cases.

BusLoad1.pngbusload-2.jpg

mr-vizsla
Member
Member
on

I don't have the hardware to test this out, but you'll probably need to tweak the approximation factor for your given baud rate. Again, I don't have the hardware or else I'd try to give you a better idea. I hope this helps.

approx.png

johny_smith
Member
Member
on
can u pls suggest me where i can download full code of this example. in this some library files and sub vi's are missing
labview*
Member
Member
on

hi great job dear friend 

i try to run this your vi but when change data or id or anything else i only the firt line changed i just keep the last data Capture1.PNG

Contributors