PyUniversalLibrary is a Python wrapper for Measurement Computing’s Universal Library for data acquisition on Microsoft Windows operating systems.
Currently PyUniversalLibrary is incomplete. I have so far wrapped analog I/O, digital I/O, and temperature functions. Some of these I have not personally needed, so please be aware of potential bugs. If you need more functionality, you will hopefully find that the start I have made in wrapping this library useful. I welcome your changes and additions. I will include them with the next release with appropriate credit.
Rewrote as a pure-Python implementation, which uses ctypes and numpy (new requirements). There is no longer a requirement on Numeric, and this should work with any reasonably backwards-compatible future versions of Python, ctypes, and numpy. The analog output examples were changed to work on USB PMD-1208FS devices.
Lots of Universal Library is now covered, including all analog I/O, digital I/O, and temperature input functions.
First public release.
Various Python wrappers for data acquisition are available. Here are a few I know of:
- National Instruments NI-DAQ: http://sourceforge.net/projects/uncpythontools/
- Data Translation: Martin Spacek has indicated (personal commication) he has drivers
- Comedi apparently comes with Python wrappers: http://www.comedi.org/
- Dr. Warren Jasper’s Measurement Computing USB drivers for Linux (Andrew Straw has written Python wrappers for these - contact him for further information)
You must have Python installed.
You must have ctypes installed (this is included with Python 2.5), but can be downloaded for older versions of Python.
You must have numpy installed.
Download PyUniversalLibrary: Grab a binary installer or the source code from the download directory.
To get the examples, download the source code. You can still install the binaries.
Here is ulai01.py from the example directory. It is a direct translation of the essentials of ulai01.c, included with Universal Library. Error checking occurs automatically through Python exceptions.
import UniversalLibrary as UL BoardNum = 0 Gain = UL.BIP5VOLTS Chan = 0 while 1: DataValue = UL.cbAIn(BoardNum, Chan, Gain) EngUnits = UL.cbToEngUnits(BoardNum, Gain, DataValue) print DataValue, EngUnits
‘PyUL’ is used here to mean the UniversalLibray Python module. Because UniversalLibrary is cumbersome to type, the example programs actually use “import UniversalLibrary as UL”.
PyUniversalLibrary endeavors to keep function signatures identical to the C API. These sometimes result in non-Pythonic quirks: some arguments to a function have no effect on that function because in C they are output variables. In these cases, they are returned as outputs from the function.
The PyUL checks for errors upon every call and raises a UniversalLibraryError if an error was encountered. Instances of UniversalLibraryError have an errno attribute which can be converted to a string with a call to _get_error_message(errno).
The short story is that importing PyUL (“import UniversalLibrary”) will do all initialization necessary.
The long story is that C programs call the cbDeclareRevision() and cbErrHandling() functions upon initialization. PyUL calls cbDeclareRevision() automatically, and calling cbErrHandling() is not needed because the default state DONTPRINT, DONTSTOP, which is exactly what PyUL expects, because PyUL checks all the error codes anyhow.
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|
|PyUniversalLibrary-20061020.win32.exe (75.0 kB) Copy SHA256 hash SHA256||Windows Installer||2.5||Sep 15, 2014|
|PyUniversalLibrary-20061020.zip (34.4 kB) Copy SHA256 hash SHA256||Source||None||Sep 15, 2014|