ni / nidaqmx-python

A Python API for interacting with NI-DAQmx
Other
434 stars 154 forks source link

nidaqmx does not generate numbered virtual channel names correctly #579

Open AlexHearnNI opened 5 months ago

AlexHearnNI commented 5 months ago

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