Package: nidaqmx
InfoContains a Python API for interacting with NI-DAQmx. SeeGitHubfor the latest source.AuthorNational InstrumentsAboutThenidaqmxpackage contains an API (Application Programming Interface)
for interacting with the NI-DAQmx driver. The package is implemented in Python.
The package is implemented as a complex,
highly object-oriented wrapper around the NI-DAQmx C API using thectypesPython library.nidaqmxsupports all versions of the NI-DAQmx driver that ships with the C
API. The C API is included in any version of the driver that supports it. Thenidaqmxpackage does not require installation of the C header files.Some functions in thenidaqmxpackage may be unavailable with earlier
versions of the NI-DAQmx driver. Visit theni.com/downloadsto upgrade your version of
NI-DAQmx.nidaqmxsupports Windows and Linux operating systems where the NI-DAQmx
driver is supported. Refer toNI Hardware and Operating System Compatibilityfor which versions of the driver support your hardware on a given operating
system.nidaqmxsupports CPython 3.8+ and PyPy3.InstallationRunningnidaqmxrequires NI-DAQmx to be installed. Visitni.com/downloadsto download the latest
version of NI-DAQmx. None of the recommendedAdditional itemsare required
fornidaqmxto function, and they can be removed to minimize installation
size. It is recommended you continue to install theNI Certificatespackage
to allow your Operating System to trust NI built binaries, improving your
software and hardware installation experience.nidaqmxcan be installed withpip:$ python -m pip install nidaqmxSimilar PackagesThere are similar packages available that also provide NI-DAQmx functionality in
Python:daqmx(slightlynybbled/daqmx on GitHub)
provides an abstraction of NI-DAQmx in thenimodule.PyLibNIDAQmx (pearu/pylibnidaqmx on GitHub)
provides an abstraction of NI-DAQmx in thenidaqmxmodule, which collides
with this package’s module name.UsageThe following is a basic example of using annidaqmx.task.Taskobject.
This example illustrates how the single, dynamicnidaqmx.task.Task.readmethod returns the appropriate data type.>>>importnidaqmx>>>withnidaqmx.Task()astask:...task.ai_channels.add_ai_voltage_chan("Dev1/ai0")...task.read()...-0.07476920729381246>>>withnidaqmx.Task()astask:...task.ai_channels.add_ai_voltage_chan("Dev1/ai0")...task.read(number_of_samples_per_channel=2)...[0.26001373311970705,0.37796597238117036]>>>fromnidaqmx.constantsimportLineGrouping>>>withnidaqmx.Task()astask:...task.di_channels.add_di_chan(..."cDAQ2Mod4/port0/line0:1",line_grouping=LineGrouping.CHAN_PER_LINE)...task.read(number_of_samples_per_channel=2)...[[False,True],[True,True]]A single, dynamicnidaqmx.task.Task.writemethod also exists.>>>importnidaqmx>>>fromnidaqmx.typesimportCtrTime>>>withnidaqmx.Task()astask:...task.co_channels.add_co_pulse_chan_time("Dev1/ctr0")...sample=CtrTime(high_time=0.001,low_time=0.001)...task.write(sample)...1>>>withnidaqmx.Task()astask:...task.ao_channels.add_ao_voltage_chan("Dev1/ao0")...task.write([1.1,2.2,3.3,4.4,5.5],auto_start=True)...5Consider using thenidaqmx.stream_readersandnidaqmx.stream_writersclasses to increase the performance of your application, which accept pre-allocated
NumPy arrays.Following is an example of using annidaqmx.system.Systemobject.>>>importnidaqmx.system>>>system=nidaqmx.system.System.local()>>>system.driver_versionDriverVersion(major_version=16L,minor_version=0L,update_version=0L)>>>fordeviceinsystem.devices:...print(device)...Device(name=Dev1)Device(name=Dev2)Device(name=cDAQ1)>>>importcollections>>>isinstance(system.devices,collections.Sequence)True>>>device=system.devices['Dev1']>>>device==nidaqmx.system.Device('Dev1')True>>>isinstance(device.ai_physical_chans,collections.Sequence)True>>>phys_chan=device.ai_physical_chans['ai0']>>>phys_chanPhysicalChannel(name=Dev1/ai0)>>>phys_chan==nidaqmx.system.PhysicalChannel('Dev1/ai0')True>>>phys_chan.ai_term_cfgs[<TerminalConfiguration.RSE:10083>,<TerminalConfiguration.NRSE:10078>,<TerminalConfiguration.DIFFERENTIAL:10106>]>>>fromenumimportEnum>>>isinstance(phys_chan.ai_term_cfgs[0],Enum)TrueBugs / Feature RequestsTo report a bug or submit a feature request, please use theGitHub issues page.Information to Include When Asking for HelpPlease includeallof the following information when opening an issue:Detailed steps on how to reproduce the problem and full traceback, if
applicable.The python version used:$ python -c "import sys; print(sys.version)"The versions of thenidaqmxand numpy packages used:$ python -m pip listThe version of the NI-DAQmx driver used. Followthis KB articleto determine the version of NI-DAQmx you have installed.The operating system and version, for example Windows 7, CentOS 7.2, …DocumentationDocumentation is availablehere.Additional DocumentationRefer to theNI-DAQmx Helpfor API-agnostic information about NI-DAQmx or measurement concepts.NI-DAQmx Help installs only with the full version of NI-DAQmx.Licensenidaqmxis licensed under an MIT-style license (seeLICENSE).
Other incorporated projects may be licensed under different licenses. All
licenses allow for non-commercial and commercial use.gRPC FeaturesFor driver APIs that support it, passing a GrpcSessionOptions instance as a
parameter is subject to the NI General Purpose EULA
(see NILICENSE).