Example Code

Send Burst Multiplexed CAN Messages in NI-XNET

Code and Documents

Attachment

Overview

The capability of sending different modes of same-frame multiplexed messages used to be available in NI-CAN as the Message Multiple Frame Distribution, but was not added to the NI-XNET Driver for compatibility issues.  This example shows an NI-XNET work-around for this capability.

Description

A multiplexer bit can only have one value at a time, and frames can only be sent one at a time over the CAN bus.  Therefore, in order to send multiple modes of a multiplexed frame we need to resend our written signals with new multiplexer values for each mode.  The NI-CAN driver had an abstraction which handled iterating through the mode values automatically, so essentially this example explicitly handles that process.

Examining the block diagram of send multiplexed signals.vi, we can see how a new value of the multiplexer is assigned before each write (the initial value coming directly from the front panel).  This is done in each frame of the sequence structure by accessing item 0 in the data array (in this example, the multiplexer signal is the first signal in the output list), and then writing the new mode's value to that item before sending the new array into an XNET Write VI.

Capture.JPG

Steps to Implement or Execute Code

  1. Connect and power your CAN cables for your desired setup
  2. Download all of the attached database and VI and open send multiplexed signals.vi
  3. In the Front Panel click the dropdown option for Select Signal List from database, and reference the signals list to the Mux_Example_Database
  4. Ensure that the selected signals are ordered from top to bottom as: Multiplexer, MUX_1, MUX_2, MUX_3, MUX_4
  5. Select the CAN Interface on the front panel that you would like to send the signals on
  6. Run the VI and Click the Write button.  This will send your 4 messages in a burst.
  7. If you have the available hardware, you setup a CAN loopback to another XNET port and observe the messages returning using the attached read multiplexed signals.vi.  Follow similar setup steps for this VI as above.

Requirements

Software

LabVIEW 2012

NI-XNET 1.6

Hardware

1 NI-XNET Device and port along with a receiving port (2 XNET ports if you intend to use the read multiplexed messages.vi loopback)

Powered CAN Cable


Andrew T.
National Instruments

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

Comments
oukai
Member
Member
on

Thanks for your share.

I try to apply the exam, but it cannot change multiplexed value/

Could you check it again>?

oukai
Member
Member
on

Is the example available to USB-8502 in writing a Multiplexed CAN Messages ?

Contributors