Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

NI PXI-4461 question

31 views
Skip to first unread message

Aaron Holman

unread,
Nov 8, 2024, 3:54:39 PM11/8/24
to the labscript suite
Hi all,
I am looking to incorporate a high resolution resolution Analog Input card with labscript. I successfully run the generate_subclasses.py file and create a NI_PXI_4461.py file. However, when I compile BLACs, it is not happy with the "Sample Timing Type." Does anyone know how I can change this setting? Copied below is the device python file, the connection table initialization, and the error message I receive. Thanks for the help!
Aaron

Python file:
from labscript_devices.NI_DAQmx.labscript_devices import NI_DAQmx

#:
CAPABILITIES = {
    'AI_range': [-42.4, 42.4],
    'AI_range_Diff': [-42.4, 42.4],
    'AI_start_delay': 0.0,
    'AI_term': 'Diff',
    'AI_term_cfg': {'ai0': ['Diff', 'PseudoDiff'], 'ai1': ['Diff', 'PseudoDiff']},
    'AO_range': [-10.0, 10.0],
    'max_AI_multi_chan_rate': 204800.0,
    'max_AI_single_chan_rate': 204800.0,
    'max_AO_sample_rate': 204800.0,
    'max_DO_sample_rate': None,
    'min_semiperiod_measurement': None,
    'num_AI': 2,
    'num_AO': 2,
    'num_CI': 0,
    'ports': {},
    'supports_buffered_AO': True,
    'supports_buffered_DO': False,
    'supports_semiperiod_measurement': False,
    'supports_simultaneous_AI_sampling': True,
}


class NI_PXI_4461(NI_DAQmx):
    description = 'NI-PXI-4461'

    def __init__(self, *args, **kwargs):
        """Class for NI-PXI-4461"""
        # Any provided kwargs take precedent over capabilities
        combined_kwargs = CAPABILITIES.copy()
        combined_kwargs.update(kwargs)
        NI_DAQmx.__init__(self, *args, **combined_kwargs)


Connection table:
NI_PXI_4461(
     name='ni_pxi_4461',
     MAX_name='Dev2',
     parent_device=prawn.clocklines[0],
     clock_terminal='/Dev1/PFI2',
     #acquisition_rate=100000
)

BLACs error:

Exception in worker - Fri Nov 08, 15:32:24 :
Traceback (most recent call last):
  File "C:\Users\Columbia\miniconda3\envs\labscript\Lib\site-packages\labscript_devices\NI_DAQmx\blacs_workers.py", line 44, in init
    self.start_manual_mode_tasks()
  File "C:\Users\Columbia\miniconda3\envs\labscript\Lib\site-packages\labscript_devices\NI_DAQmx\blacs_workers.py", line 103, in start_manual_mode_tasks
    self.AO_task.StartTask()
  File "<string>", line 3, in StartTask
  File "<string>", line 2, in function
  File "C:\Users\Columbia\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.DevOnlySupportsSampClkTimingAOError: Sample Timing Type is set to On Demand which is not supported for analog output on this device.
Set Sample Timing Type to Sample Clock. You can achieve this while setting related properties through DAQmx VIs or functions for configuring timing.

Task Name: _unnamedTask<0>

Status Code: -200758
 in function DAQmxStartTask

Fatal exception in main process - Fri Nov 08, 15:32:24 :
Traceback (most recent call last):
  File "C:\Users\Columbia\miniconda3\envs\labscript\Lib\site-packages\blacs\tab_base_classes.py", line 837, in mainloop
    next_yield = inmain(generator.send,results)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Columbia\miniconda3\envs\labscript\Lib\site-packages\qtutils\invoke_in_main.py", line 88, in inmain
    return get_inmain_result(_in_main_later(fn, False, *args, **kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Columbia\miniconda3\envs\labscript\Lib\site-packages\qtutils\invoke_in_main.py", line 150, in get_inmain_result
    raise value.with_traceback(traceback)
  File "C:\Users\Columbia\miniconda3\envs\labscript\Lib\site-packages\qtutils\invoke_in_main.py", line 46, in event
    result = event.fn(*event.args, **event.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Columbia\miniconda3\envs\labscript\Lib\site-packages\blacs\tab_base_classes.py", line 536, in _initialise_worker
    raise Exception('Device failed to initialise')
Exception: Device failed to initialise

dihm....@gmail.com

unread,
Nov 13, 2024, 1:54:48 PM11/13/24
to the labscript suite
Unfortunately, I don't think our DAQmx driver supports this kind of device (despite what the script says). Based on some quick reading, these types of devices behave much more like DDS's than standard DACs. In particular, you must use a fixed-frequency sample clock to generate outputs, even if the outputs are not changing. It comes down to the delta-sigma generation method that they use. Our driver follows the more standard DAC paradigm: we provide a list of successive outputs, tell the device to increment the list at each external trigger, then provide triggers at the correct times (ie not a regular, single frequency). These devices instead need a list of the output states at a fixed time step, then are configured to increment internally based on that time-step.

While it is 2024 and anything is possible, modifying the current driver to support this method of output generation would be tricky to do. Labscript somewhat fundamentally assumes the former method of sample generation. A way to potentially support this could be to modify code to automatically generate the dense output states at the desired sampling frequency based on what the user has provided, then clock the device with a dedicated pseudoclock output to its SampleClk at the correct frequency, which the device code could automatically request through standard labscript internals. Though that may not work since I suspect the device is going to want the clock input to exist at all times, not just when samples are requested. More likely to work, but harder to implement, is the above but only send a single starting trigger to the 4461. This converts the device to an "internally-timed device" in our parlance. It's antithetical to the normal operation of labscript, so it takes some care and there aren't many examples of it out there, but it can be done.

In any case, the existing code does not support this device out of the box. Guess I'll need to figure out how to detect that and update the script to reflect it. If you want to put in the effort to support this device, I can provide some advice, and we'd be happy to see the end result ultimately incorporated in the suite for others to use.

-David

Reply all
Reply to author
Forward
0 new messages