CAN Create MessageEx.vi

NI-CAN

CAN Create MessageEx.vi

Purpose

Create a message configuration and associated channel configurations within the application.

Format

Inputs

interface specifies the CAN interface to use for this task.

The interface input uses a ring typedef in which value 0 selects CAN0, value 1 selects CAN1, and so on.

The interface input is required. Since the messages and channels are not defined in MAX, you cannot use MAX default as the interface.

The default baud rate for the interface is defined within MAX, but you can change it by setting the Interface Baud Rate property with CAN Set Property.vi.

The special interface values 256 and 257 refer to virtual interfaces. For more information on usage of virtual interfaces, refer to Frame to Channel Conversion.

mode specifies the I/O mode for the task. For an overview of the I/O modes, including figures, refer to the Channel API Basic Programming Model.

Input

Input channel data from received CAN messages. Use CAN Read.vi to obtain input samples as single point, array, or waveform.

Use this input mode to read waveforms of timed samples, such as for comparison with NI-DAQ waveforms. You also can use this input mode to read a single point from the most recent message, such as for control or simulation.

Output

Output channel data to CAN messages for transmit. Use CAN Write.vi to write output samples as single-point, array, or waveform. Each sample value that you write is transmitted in a message on the network. If you write an array or waveform, the samples are buffered for subsequent transmit.

Output Recent

Output channel data to CAN messages for transmit. This mode is used with sample rate greater than zero (periodic transmit). Use CAN Write.vi to provide a single sample per channel. Each periodic message uses the sample values from the most recent CAN Write.vi.

For this mode, there are restrictions on using channels in channel list that are contained in multiple messages. Refer to CAN Read.vi for more information.

Timestamped Input

Input channel data from received CAN messages. Use CAN Read.vi to obtain input samples as an array of sample/timestamp pairs (Poly VI types ending in Timestamped Dbl).

Use this input mode to read samples with timestamps that indicate when each message is received from the network.

sample rate specifies the timing to use for samples of the task. The sample rate is specified in Hertz (samples per second). A sample rate of zero means to sample immediately.

For mode of Input, a sample rate of zero means that CAN Read returns a single point from the most recent message received, and greater than zero means that CAN Read returns samples timed at the specified rate.

For mode of Output, a sample rate of zero means that CAN messages transmit immediately when CAN Write is called, and greater than zero means that CAN messages are transmitted periodically at the specified rate.

For mode of Timestamped Input, sample rate is ignored.

When the interface specifies a virtual interface (256 or 257), and mode is Output or Output Recent, this sample rate must be zero (greater than zero not supported).

message config configures properties for a new message. These properties are similar to the message properties in MAX. Can Create Message.vi creates a task for a single message with one or more channels.

message ID

Configures the arbitration ID of the message.

Use the extended ID? Boolean to specify whether the ID is standard (11-bit) or extended (29-bit).

extended ID?

Configures a Boolean value that indicates whether the arbitration ID of the message is standard 11-bit format (false) or extended 29-bit format (true).

number of bytes

Configures the number of data bytes in the message. The range is 1 to 8.

channel config list configures a list of channels for the new message. The channel config list is an array of clusters, with one cluster for each channel. The properties of each channel entry are similar to the channel properties in MAX:

start bit

Configures the starting bit position in the message. The range is 0 (lowest bit in first byte) to 63 (highest bit in last byte).

number of bits

Configures the number of bits for the raw data in the message. The range is 1 to 64.

byte order

Configures the byte order of the channel in the message.

The value of byte order is an enumeration:

0 Intel Bytes are in little-endian order, with most-significant first.
1 Motorola Bytes are in big-endian order, with least-significant first.

data type

Configures the data type of channel in the message.

The value of Channel Data Type is an enumeration:

0 Signed Raw data in the message is a signed integer.
1 Unsigned Raw data in the message is an unsigned integer.
2 IEEE Float Raw data in the message is floating-point; no scaling required.

scaling factor

Configures the scaling factor used to convert raw data in the message to/from scaled floating-point units. The scaling factor is the A in the linear scaling formula AX+B, where X is the raw data, and B is the scaling offset.

scaling offset

Configures the scaling offset used to convert raw data in the message to/from scaled floating-point units. The scaling offset is the B in the linear scaling formula AX+B, where X is the raw data, and A is the scaling factor.

min value

Configures the minimum value of the channel in scaled floating-point units.

The CAN Read and CAN Write VIs do not coerce samples when converting to/from CAN messages. You can use this value with property nodes to set the range of front-panel controls and indicators.

max value

Configures the maximum value of the channel in scaled floating-point units.

The CAN Read and CAN Write VIs do not coerce samples when converting to/from CAN messages. You can use this value with property nodes to set the range of front-panel controls and indicators.

default value

Configures the default value of the channel in scaled floating-point units.

For information on how the default value is used, refer to CAN Read.vi and CAN Write.vi.

unit string

Configures the channel unit string. The string is no more than 64 characters in length.

You can use this value to display units (such as volts or RPM) along with the samples on a channel.

Mode channel config configures a list of the mode channels for this (data) channel. Currently, only one mode channel is allowed per (data) channel. Note that the same mode channel can be specified for several channels.

Mode value

Configures the mode channel value for which the data channel is valid.

Start Bit

Configures the starting bit position in the message. The range is 0 (lowest bit in first byte) to 63 (highest bit in last byte).

Num Bits

Configures the number of bits for the raw data in the message. The range is 1 to 64.

byte order

Configures the byte order of a channel in the message.

The value of byte order is an enumeration:

0 Intel Bytes are in little-endian order, with most-significant first.
1 Motorola Bytes are in big-endian order, with least-significant first.

Default Value

This field is reserved. Set it to 0.

Error in describes error conditions occurring before the VI executes. If an error has already occurred, the VI returns the value of the Error in cluster in Error out.
status is True if an error occurred. If status is True, the VI does not perform any operations.
code is the error code number identifying an error. A value of 0 means success. A negative value means error: VI did not execute the intended operation. A positive value means warning: VI executed intended operation, but an informational warning is returned. For a description of the code, wire the error cluster to a LabVIEW error-handling VI, such as the Simple Error Handler.

Outputs

Use task reference out with all subsequent VIs to reference the task. Wire this task reference to CAN Start.vi before you read or write samples for the message.
Error out describes error conditions. If the Error in cluster indicated an error, the Error out cluster contains the same information. Otherwise, Error out describes the error status of this VI.
status is True if an error occurred.
code is the error code number identifying an error. A value of 0 means success. A negative value means error: VI did not execute the intended operation. A positive value means warning: VI executed intended operation, but an informational warning is returned. For a description of the code, wire the error cluster to a LabVIEW error-handling VI, such as the Simple Error Handler.
source identifies the VI where the error occurred.

Description

To use message and channel configurations from MAX or a CAN database, use CAN Init Start.vi or CAN Initialize.vi. CAN Create MessageEx provides an alternative in which you create the message and channel configurations within the application, without use of MAX or a CAN database. In addition, CAN Create MessageEx offers optionally the possibility to specify mode dependent messages without using MAX or CAN databases.

CAN Create MessageEx returns a task reference that you wire to CAN Start.vi to start communication for the message and its channels.