NI-CAN Software Overview

NI-CAN

NI-CAN Software Overview

The NI-CAN software provides full-featured Application Programming Interfaces (APIs), plus tools for configuration and analysis within National Instruments Measurement & Automation Explorer (MAX). The NI-CAN APIs enable you to develop applications that are customized to the test and simulation requirements.

MAX

The NI-CAN features within MAX enable you to:

  • Verify the installation of the NI CAN hardware.
  • Configure software properties for each CAN port.
  • Create or import configuration information for the Channel API.
  • Interact with the CAN network using various tools.

For more information, refer to Installation and Configuration.

Frame API

As described in the CAN Overview, the frame is the fundamental unit of data transfer on a CAN network. The NI-CAN Frame API provides a set of functions to write and read CAN frames.

Within the Frame API, the data bytes of each frame are not interpreted, but are transferred in their raw format. For example, you can transmit a data frame by calling a write function with the ID, length, and array of data bytes.

For more information, refer to Using the Frame API.

Channel API

A typical CAN data frame contains multiple values encoded as raw fields. The following figure shows an example set of fields for a 6-byte data frame.

Bytes 1 to 2 contain a CruiseCtrlSetSpeed field that represents a vehicle speed in kilometers per hour (km/h). Most CAN devices do not transmit values as floating-point units such as 115.6 km/h. Therefore, this field consists of a 16-bit unsigned integer in which each increment represents 0.0039 km/h. For example, if the field contains the value 25000, that represents (25000 * 0.0039) = 97.5 km/h.

Bytes 3 to 4 contain another unsigned integer VehicleSpeed that represents speed in km/h. Bytes 0 and 5 contain various Boolean fields for which 1 indicates "on" and 0 indicates "off."

When you use the NI-CAN Frame API to read CAN data frames, you must write code in the application to convert each raw field to physical units such as km/h. The NI-CAN Channel API enables you to specify this conversion information at configuration time instead of within the application. This configuration information can be imported from Vector CANdb files, or specified directly in MAX.

For each ID you read or write on the CAN network, you specify a number of fields. For each field, you specify its location in the frame, size in bits, and a formula to convert to/from floating-point units. In other words, you specify the meaning of various fields in each CAN data frame. In NI-CAN terminology, a data frame for which the individual fields are described is called a message.

In other National Instruments software products such as NI-DAQ, NI-DAQmx, and FieldPoint, an application reads or writes a floating-point value using a channel, which is typically converted to/from a raw value in the measurement hardware. The NI-CAN Channel API also uses the term channel to refer to floating-point values converted to/from raw fields in messages. In CAN products of other vendors, this concept is often referred to as a signal. When a CAN message is received, NI-CAN converts the raw fields into physical units, which you then obtain using the Channel API read function. When you call the Channel API write function, you provide floating-point values in physical units, which NI-CAN converts into raw fields and transmits as a CAN message.

For more information, refer to Using the Channel API.