Library»NI-DAQmx»Channel Creation/Configuration [CVI]
Task.Channel.CreateChannel Property [.NET]
The NI-DAQmx Create Virtual Channel function creates a virtual channel and adds it to a task. It can also be used to create multiple virtual channels and add all of them to a task. When a task is not specified, the function creates a task. The NI-DAQmx Create Virtual Channel function has numerous instances. These instances correspond to the specific type of measurement or generation the virtual channel(s) perform.
Creating a Channel in LabVIEW
The following figure shows four examples of different instances of the NI-DAQmx Create Virtual Channel VI.
The inputs to the NI-DAQmx Create Virtual Channel function differ for each instance of the function. However, certain inputs are common to most, if not all, of the function's instances. For example, an input is required to specify the physical channels (analog input and analog output), lines (digital), or counter that the virtual channel(s) will use. Additionally, analog input, analog output, and counter operations use minimum value and maximum value inputs to configure and optimize the measurements and generations based on the minimum and maximum expected values of the signals. Furthermore, a custom scale can be applied to many types of virtual channels. In the following LabVIEW block diagram, the NI-DAQmx Create Virtual Channel VI is used to create a thermocouple virtual channel.
Creating a Channel in .NET
Most of the classes in the NI-DAQmx .NET library cannot be instantiated directly. These classes are used as subobjects of the class.
These classes contain properties that are specific to a particular type of channel. For example, properties such as
Count are only applicable to counters and are only available on the CIChannel and COChannel classes. You can associate the following types of channels with a in the NI-DAQmx .NET class library:
Analog input channels— class
Analog output channels— class
Digital input channels— class
Digital output channels— class
Counter input channels— class
Counter output channels— class
The Task class has a channel collection property for each of six types of channels— , , , , , and . To create a channel, you can use one of the many create channel methods on the channel collections.
After instanting a new Task object, creating and assigning an AIChannel object is done by calling the appropriate member function in the Channel class. The following snippet creates a simple analog input voltage channel:
analogInTask = new Task();
myChannel = analogInTask.AIChannels.CreateVoltageChannel(
"dev1/ai1", //The physical name of the channel
"myChannel", //The name to associate with this channel
AITerminalConfiguration.Differential, //Differential wiring
-10, //-10v minimum
10, //10v maximum
AIVoltageUnits.Volts //Use volts
Creating a Task in C/C++
Use the DAQmxCreateTask() function to create a task and DAQmxCreateAIVoltageChan() to create an analog input voltage channel. For information on creating channels for different measurement types, see the NI-DAQmx C Reference Help. Below is a snippet of how to use the two functions:
char chan = "Dev1/ai0";
float64 min = -10, max = 10;
DAQmxCreateAIVoltageChan(taskHandle ,chan ,"", DAQmx_Val_Cfg_Default, min, max, DAQmx_Val_Volts, NULL);
Examples to Examine:
||Digital - Finite Output.vi
|Thermocouple - Continuous Input.vi
||Write Dig Port
|Cont Thrmcpl Samples-Int Clk