labscript-suite / labscript-devices

A modular and extensible plugin architecture to control experiment hardware using the 𝘭𝘒𝘣𝘴𝘀𝘳π˜ͺ𝘱𝘡 𝘴𝘢π˜ͺ𝘡𝘦.
http://labscriptsuite.org
Other
5 stars 58 forks source link

NI-DAQmx introspection fails on NI-6366 #62

Closed dihm closed 2 years ago

dihm commented 4 years ago

Trying to use the get_capabilities.py script to add a new NI USB-6366 we acquired and I get the following message:

found device: Dev1 USB-6366 (64 MS) (BNC)
Traceback (most recent call last):
  File "get_capabilities.py", line 387, in <module>
    AI_ranges = supported_AI_ranges_for_non_differential_input(name, AI_ranges)
  File "get_capabilities.py", line 213, in supported_AI_ranges_for_non_differential_input
    task.CreateAIVoltageChan(
  File "<string>", line 3, in CreateAIVoltageChan
  File "<string>", line 2, in function
  File "C:\Miniconda3\envs\labscript\lib\site-packages\PyDAQmx\DAQmxFunctions.py", line 62, in mafunction
    raise exception_class(errBuff.value.decode("utf-8"), f.__name__)
PyDAQmx.DAQmxFunctions.InvalidAttributeValueError: Requested value is not a supported value for this property. The property value may be invalid because it conflicts with another property.
Property: DAQmx_AI_TermCfg
Requested Value: DAQmx_Val_RSE
Possible Values: DAQmx_Val_Diff
Channel Name: Dev1/ai0

Task Name: _unnamedTask<4>

Status Code: -200077
 in function DAQmxCreateAIVoltageChan

Checking with NI-MAX and the spec sheet, this device only has differential inputs (logically) where each AI+ and AI- are the center pin and shield of the BNC inputs of the breakout box. Kind-of an annoying edge case I guess but there it is.

dihm commented 3 years ago

@chrisjbillington, you probably already realized this, but I've been looking in to this again and realizing the deeper issue, namely that the NI_DAQmx class does not support differential analog inputs. So even if this particular thing got fixed, the overall class needs to be updated to handle differential inputs. Apparently only supporting differential inputs is common to all NI DAQs that perform simultaneous sampling (instead of the typical multiplexing).

Seeing as we have two of these type of devices (also got a PXIe-6396), I'm somewhat motivated to get this working in the near-term. Is there anything in particular I can do to help? Should I just take a crack at it (if so, any particular pain point I should worry about)?

Also, it appears these devices also do not have a Sample Clock Delay property (found by skipping the AI check in get_capabilities.py

(labscript) PS C:\Users\naqsL\labscript\labscript-devices\labscript_devices\NI_DAQmx\models> python .\get_capabilities.py
found device: usb_6366 USB-6366 (64 MS) (BNC)
{'supports_buffered_AO': True, 'max_DO_sample_rate': 10000000.0, 'supports_buffered_DO': True, 'max_AO_sample_rate': 3333333.3333333335, 'num_AO': 2, 'num_AI': 8, 'max_AI_single_chan_rate': 2000000.0, 'max_AI_multi_chan_rate': 2000000.0, 'ports': {'port0': {'num_lines': 8, 'supports_buffered': True}, 'port1': {'num_lines': 8, 'supports_buffered': False}, 'port2': {'num_lines': 8, 'supports_buffered': False}}, 'num_CI': 4, 'supports_semiperiod_measurement': True, 'min_semiperiod_measurement': 1e-07, 'AO_range': [-10.0, 10.0]}
Traceback (most recent call last):
  File ".\get_capabilities.py", line 399, in <module>
    capabilities[model]["AI_start_delay"] = AI_start_delay(name)
  File ".\get_capabilities.py", line 194, in AI_start_delay
    task.GetDelayFromSampClkDelay(delay_from_sample_clock)
  File "<string>", line 3, in GetDelayFromSampClkDelay
  File "<string>", line 2, in function
  File "C:\Users\naqsL\miniconda3\envs\labscript\lib\site-packages\PyDAQmx\DAQmxFunctions.py", line 62, in mafunction
    raise exception_class(errBuff.value.decode("utf-8"), f.__name__)
PyDAQmx.DAQmxFunctions.AttributeNotSupportedInTaskContextError: Specified property is not supported by the device or is not applicable to the task.
Property: DAQmx_DelayFromSampClk_Delay