Skip to main content

Universal Library Python API for Measurement Computing DAQ devices

Project description

Info

Contains a Python API for interacting with Measurement Computing’s Universal Library for Linux.

Author

Measurement Computing

About

The uldaq Python package contains an API (Application Programming Interface) for interacting with Measurement Computing DAQ devices. The package is implemented as an object-oriented wrapper around the UL for Linux C API using the ctypes Python library.

uldaq supports Python 2.7, 3.4+

Prerequisites

Running the uldaq Python API requires the UL for Linux C API.

  • Visit uldaq on GitHub to install the latest version of the UL for Linux C API.

Installing the uldaq Python API requires Python along with the pip, setuptools and wheel packages.

  • For more information on installing Python, go to python.org.

  • For more information on installing Python packages with pip, see the Installing Packages tutorial on python.org.

Installation

Install the uldaq Python API with:

$ pip install uldaq

Note: Installation may need to be run with sudo.

Examples

A complete set of examples is include in the source tarball. To obtain and run the examples, follow these steps:

  1. Go to pypi.org/project/uldaq.

  2. Under Navigation click the Download files link.

  3. Click the uldaq-1.2.2.tar.gz link to download the file.

  4. Copy the file from the default download location to a desired location.

  5. Navigate to the file location and run:

    $ tar -xvf uldaq-1.2.2.tar.gz
  6. The Python examples are located in the examples folder. Run the following commands to execute the analog input example:

    $ cd uldaq-1.2.2/examples
    $ ./a_in.py

Note: For best results, run examples in a terminal window.

Usage

The following is a simple example for reading a single voltage value from each channel in an analog input subsystem of a Measurement Computing DAQ device.

from uldaq import (get_daq_device_inventory, DaqDevice, InterfaceType,
                   AiInputMode, Range, AInFlag)

try:
    # Get a list of available DAQ devices
    devices = get_daq_device_inventory(InterfaceType.USB)
    # Create a DaqDevice Object and connect to the device
    daq_device = DaqDevice(devices[0])
    daq_device.connect()
    # Get AiDevice and AiInfo objects for the analog input subsystem
    ai_device = daq_device.get_ai_device()
    ai_info = ai_device.get_info()

    # Read and display voltage values for all analog input channels
    for channel in range(ai_info.get_num_chans()):
        data = ai_device.a_in(channel, AiInputMode.SINGLE_ENDED,
                              Range.BIP10VOLTS, AInFlag.DEFAULT)
        print('Channel', channel, 'Data:', data)

    daq_device.disconnect()
    daq_device.release()

except ULException as e:
    print('\n', e)  # Display any error messages

The same example using a with block:

from uldaq import (get_daq_device_inventory, DaqDevice, InterfaceType,
                   AiInputMode, Range, AInFlag)

try:
    # Get a list of available devices
    devices = get_daq_device_inventory(InterfaceType.USB)
    # Create a DaqDevice Object and connect to the device
    with DaqDevice(devices[0]) as daq_device:
        # Get AiDevice and AiInfo objects for the analog input subsystem
        ai_device = daq_device.get_ai_device()
        ai_info = ai_device.get_info()

        # Read and display voltage values for all analog input channels
        for channel in range(ai_info.get_num_chans()):
            data = ai_device.a_in(channel, AiInputMode.SINGLE_ENDED,
                                  Range.BIP10VOLTS, AInFlag.DEFAULT)
            print('Channel', channel, 'Data:', data)

except ULException as e:
    print('\n', e)  # Display any error messages

Support/Feedback

The uldaq package is supported by MCC. For uldaq support, contact technical support through mccdaq.com/Support.aspx . Please include version information for Python, uldaq C API and uldaq Python API packages used as well as detailed steps on how to reproduce the problem.

Documentation

Documentation is available at mccdaq.com.

License

uldaq is licensed under an MIT-style license. Other incorporated projects may be licensed under different licenses. All licenses allow for non-commercial and commercial use.

Project details


Download files

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

Source Distribution

uldaq-1.2.2.tar.gz (94.8 kB view hashes)

Uploaded Source

Built Distribution

uldaq-1.2.2-py2.py3-none-any.whl (67.0 kB view hashes)

Uploaded Python 2 Python 3

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