|
1 | | -NI DAQS |
2 | | -======= |
| 1 | +NI DAQs |
| 2 | +======= |
| 3 | + |
| 4 | +Overview |
| 5 | +~~~~~~~~ |
| 6 | + |
| 7 | +This labscript device is a master device that can control a wide range of NI Multi-function data acquistion devices. |
| 8 | + |
| 9 | +Installation |
| 10 | +~~~~~~~~~~~~ |
| 11 | + |
| 12 | +This labscript device requires an installation of the NI-DAQmx module, available for free from `NI <https://www.ni.com/en-us/support/downloads/drivers/download.ni-daqmx.html>`_. |
| 13 | + |
| 14 | +The python bindings are provided by the PyDAQmx package, available through pip. |
| 15 | + |
| 16 | + |
| 17 | +Adding a Device |
| 18 | +~~~~~~~~~~~~~~~ |
| 19 | + |
| 20 | +While the `NI_DAQmx` device can be used directly by manually specifying the many necessary parameters, it is preferable to add the device via an appropriate subclass. This process is greatly simplified by using the `get_capabilities.py` script. |
| 21 | + |
| 22 | +To add support for a DAQmx device that is not yet supported, run `get_capabilities.py` on |
| 23 | +a computer with the device in question connected (or with a simulated device of the |
| 24 | +correct model configured in NI-MAX). This will introspect the capabilities of the device |
| 25 | +and add those details to capabilities.json. To generate labscript device classes for all |
| 26 | +devices whose capabilities are known, run `generate_classes.py`. Subclasses of NI_DAQmx |
| 27 | +will be made in the `models` subfolder, and they can then be imported into labscript code with: |
| 28 | + |
| 29 | +..code-block:: python |
| 30 | + |
| 31 | + from labscript_devices.NI_DAQmx.labscript_devices import NI_PCIe_6363 |
| 32 | + |
| 33 | +or similar. The class naming is based on the model name by prepending "NI\_" and |
| 34 | +replacing the hyphen with an underscore, i.e. 'PCIe-6363' -> NI_PCIe_6363. |
| 35 | + |
| 36 | +Generating device classes requires the Python code-formatting library 'black', which can |
| 37 | +be installed via pip (Python 3.6+ only). If you don't want to install this library, the |
| 38 | +generation code will still work, it just won't be formatted well. |
| 39 | + |
| 40 | +The current list of pre-subclassed devices is: |
| 41 | + |
| 42 | +.. toctree:: |
| 43 | + :maxdepth: 2 |
| 44 | + |
| 45 | + ni_daq_models |
| 46 | + |
| 47 | + |
| 48 | +Usage |
| 49 | +~~~~~ |
| 50 | + |
| 51 | +NI Multifunction DAQs generally provide hardware channels for the :ref:`StaticAnalogOut <labscript/StaticAnalogOut>`, :ref:`StaticDigitalOut <labscript/StaticDigitalOut>`, :ref:`AnalogOut <labscript/AnalogOut>`, :ref:`DigitalOut <labscript/DigitalOut>`, and :ref:`AnalogIn <labscript/AnalogIn>` labscript quantities for use in experiments. Exact numbers of channels, performance, and configuration depend on the model of DAQ used. |
| 52 | + |
| 53 | +.. code-block:: python |
| 54 | +
|
| 55 | + from labscript import * |
| 56 | +
|
| 57 | + from labscript_devices.DummyPseudoclock.labscript_devices import DummyPseudoclock |
| 58 | + from labscript_devices.NI_DAQmx.models.NI_USB_6343 import NI_USB_6343 |
| 59 | +
|
| 60 | + DummyPseudoclock('dummy_clock',BLACS_connection='dummy') |
| 61 | +
|
| 62 | + NI_USB_6343(name='daq',parent_device=dummy_clock.clockline, |
| 63 | + MAX_name='ni_usb_6343', |
| 64 | + clock_terminal='/ni_usb_6343/PFI0', |
| 65 | + acquisition_rate=100e3) |
| 66 | +
|
| 67 | + AnalogIn('daq_ai0',daq,'ai0') |
| 68 | + AnalogIn('daq_ai1',daq,'ai1') |
| 69 | +
|
| 70 | + AnalogOut('daq_ao0',daq,'ao0') |
| 71 | + AnalogIn('daq_ai1',daq,'ai1') |
| 72 | +
|
| 73 | +NI DAQs are also used within labscript to provide a :ref:`WaitMonitor <labscript/waitmonitor>`. When configured, the `WaitMonitor` allows for arbitrary-length pauses in experiment execution, waiting for some trigger to restart. The monitor provides a measurement of the duration of the wait for use in interpreting the resulting data from the experiment. |
| 74 | + |
| 75 | +Configuration uses three digital I/O connections on the DAQ: |
| 76 | + |
| 77 | +* The parent_connection which sends pulses at the beginning of the experiment, the start of the wait, and the end of the wait. |
| 78 | +* The acquisition_connection which must be wired to a counter and measures the time between the pulses of the parent connection. |
| 79 | +* The timeout_connection which can send a restart pulse if the wait times out. |
| 80 | + |
| 81 | +An example configuration of a `WaitMonitor` using a NI DAQ is shown here |
| 82 | + |
| 83 | +.. code-block:: python |
| 84 | +
|
| 85 | + # A wait monitor for AC-line triggering |
| 86 | + # This requires custom hardware |
| 87 | + WaitMonitor(name='wait_monitor',parent_device=daq,connection='port0/line0', |
| 88 | + acquisition_device=daq, acquisition_connection='ctr0', |
| 89 | + timeout_device=daq, timeout_connection='PFI1') |
| 90 | + # Necessary to ensure even number of digital out lines in shot |
| 91 | + DigitalOut('daq_do1',daq,'port0/line1') |
| 92 | +
|
| 93 | +Note that the counter connection is specified using the logical label `'ctr0'`. On many NI DAQs, the physical connection to this counter is PFI9. The physical wiring for this configuration would have port0/line0 wired directly to PFI9, which PFI1 being sent to the master pseudoclock retriggering system in case of timeout. If timeouts are not expect/represent experiment failure, this physical connection can be omitted. |
| 94 | + |
| 95 | + |
| 96 | +Detailed Documentation |
| 97 | +~~~~~~~~~~~~~~~~~~~~~~ |
| 98 | + |
| 99 | +.. automodule:: labscript_devices.NI_DAQmx |
| 100 | + :members: |
| 101 | + :undoc-members: |
| 102 | + :show-inheritance: |
| 103 | + :private-members: |
| 104 | + |
| 105 | +.. automodule:: labscript_devices.NI_DAQmx.labscript_devices |
| 106 | + :members: |
| 107 | + :undoc-members: |
| 108 | + :show-inheritance: |
| 109 | + :private-members: |
| 110 | + |
| 111 | +.. automodule:: labscript_devices.NI_DAQmx.blacs_tabs |
| 112 | + :members: |
| 113 | + :undoc-members: |
| 114 | + :show-inheritance: |
| 115 | + :private-members: |
| 116 | + |
| 117 | +.. automodule:: labscript_devices.NI_DAQmx.blacs_workers |
| 118 | + :members: |
| 119 | + :undoc-members: |
| 120 | + :show-inheritance: |
| 121 | + :private-members: |
| 122 | + |
| 123 | +.. automodule:: labscript_devices.NI_DAQmx.runviewer_parsers |
| 124 | + :members: |
| 125 | + :undoc-members: |
| 126 | + :show-inheritance: |
| 127 | + :private-members: |
| 128 | + |
| 129 | +.. automodule:: labscript_devices.NI_DAQmx.daqmx_utils |
| 130 | + :members: |
| 131 | + :undoc-members: |
| 132 | + :show-inheritance: |
| 133 | + :private-members: |
| 134 | + |
| 135 | +.. automodule:: labscript_devices.NI_DAQmx.utils |
| 136 | + :members: |
| 137 | + :undoc-members: |
| 138 | + :show-inheritance: |
| 139 | + :private-members: |
0 commit comments