CAN Init Start.vi
Purpose
Initialize a task for the specified channel list, then start communication.
Format
Inputs
filepath is an optional path to a CAN database file from which to import the channel (signal) configurations. If filepath is unwired (empty), the channel configuration is obtained from MAX. The MAX CAN channels are in the MAX CAN Channels listing within Data Neighborhood. | |||||||
channel list is the array of channel names to initialize and start as a task. Each channel name is provided in an array entry. You can type in the channel list entries as string constants, or you can obtain the list from MAX or another CAN database by using CAN Get Names.vi. Channel names are case sensitive. You can initialize the same channel list with different interface, mode, or sample rate, because each task reference is unique. The following paragraphs describe the syntax of each channel name. Brackets indicate optional fields. [message.]channel
The following examples demonstrate the channel list syntax:
| |||||||
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 default (unwired) value is MAX default, which means to use the default interface as defined in the Message/Channel configuration properties. If the default interface in MAX is All, or if filepath is wired to use a CAN database (not MAX), the interface is a required input to this VI. The Channel API and Frame API cannot use the same CAN network interface simultaneously. If the CAN network interface is already initialized in the Frame API, this function returns an error. 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. For this mode, the channels in channel list can be contained in multiple messages. 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. For this mode, there are restrictions on using channels in channel list that are contained in multiple messages. Refer to CAN Write.vi for more information. 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 Write.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. For this mode, the channels in channel list must be contained in a single message. | |||||||
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 Output Recent, sample rate must be greater than zero (periodic transmit). 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). | |||||||
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.
|
Outputs
Use task reference out with all subsequent VIs to reference the running task. Because CAN Init Start starts communication, you can wire this task reference to CAN Read.vi or CAN Write.vi. | |||||||
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.
|
Description
The diagram for this VI simply calls CAN Initialize.vi followed by CAN Start.vi. This provides an easy way to start a list of channels.
The following list describes the scenarios for which CAN Init Start.vi cannot be used:
- If you need to set properties for the channels, use CAN Initialize, then CAN Set Property.vi, then CAN Start.vi. The CAN Init Start VI starts communication, and most channel properties cannot be changed after the task is started.
- If you need to synchronize tasks for multiple NI-CAN or NI DAQ cards, refer to the VIs in the CAN/DAQ Synchronization palette, such as CAN Sync Start with NI-DAQ.vi.
- If you need to create channel configurations entirely within LabVIEW, without using MAX or a CAN database file, use CAN Create Message.vi, then CAN Start.vi. The CAN Init Start VI accepts only channel names defined in MAX or a CAN database file.
Mode Dependent Channel Syntax
If you are using mode dependent channels, and each channel name is not unique, you will need to use a special syntax described in this section. Within MAX, channels with the same name are shown with a yellow exclamation point. For channels with unique names, you can use the simple syntax described previously for channel list. The brackets [] define optional parameters:
[message name.[[multiplexer.]mode_value.]]channel.
message name refers to the message in which the channel is contained. The message name must be followed by a decimal point.
- multiplexer refers to the multiplexer name in MAX or the CAN database. The multiplexer must be followed by a decimal point.
- mode_value refers to the multiplexer mode in MAX or the CAN database. The mode_value must be followed by a decimal point.
- channel refers to the channel (signal) name in MAX or the CAN database.
You cannot use the same channel name for a normal CAN channel and a mode dependent CAN channel within the same CAN message.
For more information on mode dependent channels, refer to Mode Dependent Channels.