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:
Go to pypi.org/project/uldaq.
Under Navigation click the Download files link.
Click the uldaq-1.2.3.tar.gz link to download the file.
Copy the file from the default download location to a desired location.
Navigate to the file location and run:
$ tar -xvf uldaq-1.2.3.tar.gz
The Python examples are located in the examples folder. Run the following commands to execute the analog input example:
$ cd uldaq-1.2.3/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
Built Distribution
File details
Details for the file uldaq-1.2.3.tar.gz
.
File metadata
- Download URL: uldaq-1.2.3.tar.gz
- Upload date:
- Size: 94.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d405ead334bb4e37c20b72d8ec498f0e372b08f1d3323f622abe0581ac28b98 |
|
MD5 | 6bf96699859575bfcdc88f58f105d66b |
|
BLAKE2b-256 | 9d9dcae9cbdb8285730e8c7a6eae85f6120330a8e833a97cec95d9e288c3dfba |
File details
Details for the file uldaq-1.2.3-py2.py3-none-any.whl
.
File metadata
- Download URL: uldaq-1.2.3-py2.py3-none-any.whl
- Upload date:
- Size: 67.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44e29c0951d0c9a2b982f57ba85db0625a321717640a265cd64df51a6b61af82 |
|
MD5 | 6a1f89a1f03ff2b3deb220fc5cc79e4d |
|
BLAKE2b-256 | d87a1335cf0fc8db9ffa283307b321686d2283abc22abc07ba2cecb8e1222544 |