Skip to main content


Project description

PyUniversalLibrary is a Python wrapper for Measurement Computing’s Universal Library for data acquisition on Microsoft Windows operating systems.

This document is both the webpage for PyUniversalLibrary and the README.txt file (distributed with the source code of PyUniversalLibrary). It is in reStructuredText format.

Work in Progress

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.

Release 20061020

Current version

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.

Release 20050624

Lots of Universal Library is now covered, including all analog I/O, digital I/O, and temperature input functions.

Release 20050623

First public release.

Also of interest

Various Python wrappers for data acquisition are available. Here are a few I know of:

Installation and Download

You must download and install InstaCal from Measurement Computing. This contains the various libraries needed to access your hardware.

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.


If you intend make significant use of PyUniversalLibrary, I suggest you buy Universal Library C API. It costs $50 and includes extensive documentation and example code.


Here is 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
Chan = 0

while 1:
    DataValue = UL.cbAIn(BoardNum, Chan, Gain)
    EngUnits = UL.cbToEngUnits(BoardNum, Gain, DataValue)

    print DataValue, EngUnits

Further examples are included, including a simple wxPython/matplotlib based oscilloscope.

Usage notes

Naming conventions

‘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.

Error handling

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.


BSD license. See the file LICENSE.txt distributed with the source code.

Owner: California Institute of Technology Author: Andrew Straw

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 (34.4 kB view hashes)

Uploaded source

Built Distribution

PyUniversalLibrary-20061020.win32.exe (75.0 kB view hashes)

Uploaded 2 5

Supported by

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