Changing Virtual Channel Names in Text-Based Programming

Updated Feb 11, 2020

Reported In

Driver

  • NI-DAQmx

Programming Language

  • C

Issue Details

  • How can I change the physical channel names for my counter terminal?
  • How can I give the virtual channels custom names?

Solution

When using NI-DAQmx in Text-Based Programming Environments, the syntax can vary from language to language. Refer to the DAQ-mx help documentation for your specific programming language.

If programming in C, the following code will create a task and an analog input virtual channel with a custom name:

DAQmxCreateTask("", &taskHandle));

DAQmxCreateAIVoltageChan (taskHandle, "Dev1/ai0", "Voltage", DAQmx_Val_Cfg_Default, -10.0, 10.0, DAQmx_Val_Volts, NULL);


The first line of C code creates a task. Refer to NI-DAQmx C Reference Help documentation for more information regarding Task Configuration and Control.
The second line of C code creates an analog input virtual voltage channel with the following properties: 

  • Task to which channel was created: taskHandle
  • Physical channel name: Dev1/ai0
  • Custom name assigned to virtual channel: Voltage
  • Input terminal configuration: DAQmx_Val_Cfg_Default (default)
  • Minimum expected input: -10.0
  • Maximum expected input: 10.0
  • Units of measurement: DAQmx_Val_Volts (volts)
  • Custom scale name: NULL
Now that the virtual channel has been created and given a custom name, the name must be used when referring to it in other NI-DAQmx functions.

Additional Information

A physical channel is a terminal or pin at which you can measure or generate an analog or digital signal. 
Virtual channels are software entities that encapsulate the physical channel along with other channel specific information—range, terminal configuration, and custom scaling—that formats the data.
Local virtual channels can only be used within the task. They are created with the DAQmx Create Virtual Channel function and can be assigned a custom name.
Global virtual channels can be applied to multiple tasks. They are created with DAQ Assistant and can be referenced outside the context of the task.