Skip to main content

DAQ control using National Instruments DAQmx framework

Project description

Purpose

To create a python API for working with National Instruments NIDAQmx. Check the documentation for details.

Project Maturity

The project is somewhat immature, but works well for where items are implemented. Currently, it has been tested on a single model device; however there is no reason to suspect that the project wouldn't work on any device that supports digital IO, analog inputs, and analog outputs. There is approximately ~80% test coverage and a pretty good start on the documentation.

Installation

python -m pip install daqmx

Usage

You must first import the package:

from ni import NIDAQmxInstrument

You can then allocate the hardware without any further specifiers. Note that, if there is more than one DAQmx instrument available on your PC, the hardware allocated may not be the one you are expecting! Be sure to specify the device name, model number, or serial number to make the hardware acquisition process more deterministic.

daq = NIDAQmxInstrument()  # hardware with no specifiers

daq = NIDAQmxInstrument(device_name='Dev3')  # hardware specified by the device name

daq = NIDAQmxInstrument(model_number='USB-6001')  # hardware specified by model number

daq = NIDAQmxInstrument(serial_number=1234)  # hardware specified by serial number

Once you have the NIDAQmxInstrument instance, then you can use it to operate the instrument. See the examples directory for complete examples.
Some snippets to demonstrate common usages:

daq = NIDAQmxInstrument()  # automatic acquisition of hardware

daq.ao0 = 2.7V  # set the analog out 0 to 2.7V
daq.ao1 = 1.3V  # set the analog out 1 to 1.3V

print(f'daq.ai0.value: {daq.ai0.value:.3f}V')  # print a single sample 
                                               # from analog input 0

values = daq.ai1.capture(
    sample_count=10, rate=100,
    max_voltage=10.0, min_voltage=-10.0,
    mode='differential', timeout=3.0
)  # capture 10 samples from ai1 at a rate of 100Hz in differential mode
print(values)

daq.port0.line2 = True  # set the daq.<port>.<line> to True or False to write
print(daq.port0.line3)  # read the daq.<port>.<line> to read state of line

Contribution Guidelines

Since I don't have access to unlimited instruments, I have to trust that contributions that say they work do actually work. As a result, any new instruments that are contributed should have the following:

  • An issue associated with the instrument
  • A test in the test directory which describes the necessary connections and implements testing

Pull requests are welcome!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

daqmx-0.4.4-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file daqmx-0.4.4-py3-none-any.whl.

File metadata

  • Download URL: daqmx-0.4.4-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.10

File hashes

Hashes for daqmx-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 afe810fd75c9045d6f1fbaf351a5ce03cffc9ee11bca70c84fb6623eed7abe45
MD5 edba4bc9f506f6aba07dcf40ff122e54
BLAKE2b-256 e7eb24810f2f7c3c8f03dca17c36729754cfa2c4f909fa6b969d735704cb5010

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page