Skip to main content
Help us improve Python packaging – donate today!

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 download 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:

$ python -m pip install uldaq

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-0.0.1b7.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-0.0.1b7.tar.gz
    
  6. The Python examples are located in the examples folder. Run the following commands to execute the analog input example:

    $ cd uldaq-0.0.1b7/examples
    $ python -m a_in
    

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.

Release history Release notifications

This version
History Node

0.0.1b7

History Node

0.0.1b6

History Node

0.0.1b5

History Node

0.0.1b4

History Node

0.0.1b3

History Node

0.0.1b1

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
uldaq-0.0.1b7-py2.py3-none-any.whl (53.0 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Apr 25, 2018
uldaq-0.0.1b7.tar.gz (2.7 MB) Copy SHA256 hash SHA256 Source None Apr 25, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page