02-29-2024 03:44 PM
I am using an NI-9239 analog input module plugged into a cDAQ-9171 connected to a computer with USB. The cDAQ-9171 shows up in NI-MAX as "cDAQ1" and the NI-9239 shows up as "Dev1" (screenshot attached), and both components pass successfully when I click the "self-test" button in NI-MAX. However, I get an error when I try to run the following program:
with nidaqmx.Task() as task:
task.ai_channels.add_ai_voltage_chan("Dev1/ai0")
task.read()
Running this test returns the following error with status code -201087:
nidaqmx.errors.DaqError: Task contains physical channels on one or more devices that require you to specify the Sample Clock rate. Use the Sample Clock Timing function/VI to specify a Sample Clock rate.
You cannot specify a Sample Clock rate if Mode is set to On Demand.
Device: cDAQ1
When I modify the code to specify the sample clock timing like so
with nidaqmx.Task() as task:
task.ai_channels.add_ai_voltage_chan("cDAQ1/Dev1/ai0")
task.timing.cfg_samp_clk_timing(10000)
task.read()
I now get the following error with code -200170:
nidaqmx.errors.DaqError: Physical channel specified does not exist on this device.
Refer to the documentation for channels available on this device.
Device: cDAQ1
Physical Channel Name: Dev1/ai0
However, my understanding is that the cDAQ does not have any channels itself - it simply serves as an interface to the module, the NI-9239 in this case, which has the AI channels I am trying to use. So I am not sure how to address the software's assertion that there are no AI channels on the cDAQ.
Any insight into what is going on here?
02-29-2024 09:31 PM
NI-9239 does not support on-demand mode hence you must use sample clock timing.
You don't need to specify the chassis. The following should work:
with nidaqmx.Task() as task:
task.ai_channels.add_ai_voltage_chan("Dev1/ai0")
task.timing.cfg_samp_clk_timing(10000)
task.read()