Example Code

Handling Remote Frames with NI-XNET in LabVIEW

Code and Documents

Attachment

Download All

Overview


This document discusses handling remote frames with NI-XNET in LabVIEW.

Introduction

A CAN remote frame is usually used to query a device for some data. Upon reception of a remote frame, the device sends back a data frame, usually with the same arbitration ID as the remote frame. In order to configure a Frame to be Remote Event or Remote Cyclic, the Frame Timing Type setting can be edited in the XNET Database. This process is described in Figure 1 below.

 

Figure 1. Remote Frames using NI-XNET

 

The NI-XNET driver handles the sending and receiving of remote frames. For example, if you create an Output Session configured as a remote frame, the driver will take care of receiving a remote frame, or request, and sending a data frame out, or response. When calling the XNET Write (Frame CAN) VI on a Frame Input Single-Point Session, this updates the value the driver will send when receiving the next remote frame. Figure 2 below displays the Slave side code, including the XNET Write (Frame CAN) VI.

 

Figure 2. Example of Slave side code using Remote Frames

 

If you create a Frame Input Single-Point session configured as a remote frame, the NI-XNET driver will send a remote frame, or request, out and then receive the data frame in, or response, from the slave. In order to trigger an Event Remote Frame to be sent, an XNET Write (Frame CAN) VI with an empty data input needs to be added to the Frame Input Single-Point Session. For a Cyclic Remote Frame, the sending of the remote frame is handled by the NI-XNET driver. An XNET Read (Frame CAN) VI is then needed to read the data frame in. Figure 3 below displays an example of Master side code when using Event Remote Frames.

 

Figure 3. Example of Master side code using Event Remote Frames

 

Additional Resources

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

Contributors