Choose Source of Channel Configuration

NI-CAN

Choose Source of Channel Configuration

The first step in using the Channel API is to create the channel configuration for the applications. This channel configuration describes how the NI-CAN software converts raw data in messages to or from the physical units of each channel.

The NI-CAN software provides various methods to create the channel configuration. The following flowchart shows a process you can use to decide the source of the channel configuration. A description of each step in the decision process follows the flowchart.

Decision Process for Choosing Source of Channel Configuration

Already Have a CAN Database File?

If you have a CAN database file, the channel configuration has already been created using a tool such as Vector's CANdb Editor. You can use each signal name in the CAN database as a channel name in the NI-CAN Channel API.

If you answer yes, refer to Application Uses a Subset of Channels?. If you answer no, refer to User Must Create within Application?.

Application Uses a Subset of Channels?

If the CAN database file contains a large number of channel descriptions (1,000 or more), does the application use only a subset of these channels (100 or less)? Importing the channels into MAX provides many benefits, but managing the transfer of large amounts of data from CAN databases can be cumbersome. For example, if the large CAN database file is updated periodically, you need to ensure that the changes are reflected in MAX after each update.

If you answer yes, refer to Import CAN Database into MAX. If you answer no, refer to Access CAN Database within Application.

There are limitations on how NI-CAN uses information from a Vector CANdb database file. For current information on NI-CAN support for Vector CANdb files, refer to the NI-CAN readme file.

Import CAN Database into MAX

The benefits of importing channels into MAX include:

  • The option of initializing the channel name alone within the Channel API. No path to the CAN database file is required.
  • Using the Test Panel in MAX to read and write the channels.

To import channel configurations from a Vector CANdb file into MAX, right-click the CAN Channels heading, then select Import from CANdb File. Use shift-click to select multiple channels, and then select Import. If you need to select another set, you can select the channels and then Import again. When you are finished with the import, select Done to return to MAX.

You can download the MAX channel configuration to a LabVIEW RT system by right-clicking the CAN Channels heading, and selecting Send to RT System.

Access CAN Database within Application

To access the CAN database within the application, you must initialize the channel name with the file path as a prefix. For example, if you are using a channel named EngineRPM in the C:\DBC_Files\Prototype.DBC file, you pass the following name to the Init Start function:

C:\DBC_Files\Prototype.DBC::EngineRPM

For more information, refer to the description of the Init Start function in the Channel API reference sections of this help file.

You can download the channel configuration to a LabVIEW RT system by right-clicking the CAN Channels heading, and selecting Send to RT System.

User Must Create within Application?

Are you developing an application that another person will use, and that person must create the channel configuration using the application itself?

If you answer yes, refer to Use Create Message Function in Application.

If you answer no, you create the channel configuration within MAX. You can save the MAX channel configuration to a file, so this method does not prevent you from deploying the application for use by others. For more information, refer to Create in MAX.

Use Create Message Function in Application

The Create Message function (CAN Create Message in LabVIEW and nctCreateMessage in other languages) takes inputs for a single message configuration, then one or more channel configurations. By using Create Message to create the channel configurations, the application is entirely self contained, not depending on MAX or a CAN database file.

The inputs to Create Message are relatively advanced for many users. Use of MAX or a CAN database helps to isolate the application end user from the specifics of CAN message encoding.

Mode dependent channels are a special kind of CAN message used within some networks. Refer to Mode Dependent Channels for more information. If you must support creation of mode dependent channel configurations within the application, use the Create MessageEx function instead of Create Message. The Create MessageEx function provides extensions for creation of mode dependent as well as normal channels.

Create in MAX

To create channel configurations within MAX, right-click the CAN Channels heading, then select Create Message. Enter the message properties, then select OK. Right-click the message name, then select Create Channel. Enter the channel properties, then select OK. Select Create Channel again for each channel contained in the message. Channel names are case sensitive.

To save channel configurations to a file, right-click the CAN Channels heading, then select Save Channel Configuration. The resulting NI-CAN database uses file extension .ncd. You can access the NI-CAN database using the Init Start function just like any other CAN database. By simply installing the NI-CAN database file along with the application, you can deploy the application to a variety of users.