nidaqmx-python icon indicating copy to clipboard operation
nidaqmx-python copied to clipboard

nidaqmx does not generate numbered virtual channel names correctly

Open AlexHearnNI opened this issue 1 year ago • 0 comments

If a DAQmx channel is created for physicalChannel=Dev1/ai0:7 with nameToAssignToChannel=myChan09, then DAQmx will assign Dev1/ai0 the name myChan09, Dev1/ai1 the name myChan10, and so on. In particular, notice the renumbering of the channels and the zero padding of the numbers. See https://www.ni.com/docs/en-US/bundle/ni-daqmx/page/nameassignment.html for reference.

nidaqmx calculates the virtual names incorrectly.

To demonstrate, run the following script:

import nidaqmx

with nidaqmx.Task() as task:
    ai_channel = task.ai_channels.add_ai_voltage_chan("XSeries6363/ai0:3")
    print(ai_channel.name)
    print(ai_channel.chan_type)

with nidaqmx.Task() as task:
    ai_channel = task.ai_channels.add_ai_voltage_chan("XSeries6363/ai0:3", name_to_assign_to_channel="myChan09")
    print(ai_channel.name)
    print(ai_channel.chan_type)

It will fail on the last line with nidaqmx.errors.DaqError: Specified channel is not in the task..

The output before that is

XSeries6363/ai0:3
ChannelType.ANALOG_INPUT
myChan090:3

AlexHearnNI avatar May 09 '24 20:05 AlexHearnNI