Example Code

NI-CAN Transmit Multipe Objects at Different Rates

Code and Documents

Attachment

Functional Description

This example demonstrates how to transmit periodic messages with varying arbitration IDs and sample rates.  In this example we create two objects where the end user can configure them with the appropriate CAN settings.  We start off by setting up a standard CAN baud rate then define the interface to be used in the ncConfigCANNet.vi.  Next, the CAN object names are computed based on the arbitration ID and their format.  Once the names have been developed, they are used in the ncConfigCANObj.vi.  This VI is where the end user can add their particular CAN setting for the two varying transmissions.  Once the application has entered the while loop, the program will transmit as those defined periods until an error or the stop button occurs.

To test this, use a two port CAN interface.  Connect the ports together and run this example VI on one port and run another community example on the other port (CAN Receive Frame and Display Current Arbitration Data Instead of Multiple Lines).  This should demonstrate the behavior if you make the periods noticeable for demonstrations sake.

Transmit Multiple Object at Different Rates_FP.gif

Transmit Multiple Object at Different Rates_BD.gif

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

Contributors