[time-nuts] "PYLT" Python LabTools

Poul-Henning Kamp phk at phk.freebsd.dk
Sun Jan 16 10:00:20 UTC 2011


I have created a Github project for the Python Labtools I'm using
to deal with my instruments.

	https://github.com/bsdphk/pylt


What ?
======
This is a set of python classes for communicating with IEEE488/GPIB
instruments which I use in my private lab.

The base class is "pylt" - PYthon LabTools - which defines the generic
API that hides the particular details of getting HPIB working for
this instrument.

As a result, a typical python script for measuring something can look
almost readable:

        import u2004a

        d = u2004a.u2004a()

        # 1MHz, -25 dBm, best resolution
        d.config(1e6, -25, 4)

        while True:
                print(d.measure())

Currently two hardware connections are supported:  Prologix USB-GPIB
adapter and direct USBTMC/USB488 connection.


Why ?
=====

For those of you who are happy with LabView etc, this will look
like yet another 1980'ies rerun.   Now that I've said it, you
don't need to waste email-bandwidth telling anybody that :-)

Yes, I am aware of py-visa and a few other efforts, but I needed
something that worked and found that they generally spent a lot
of code offering things I didn't need or even want.

Be aware that this is not even close to a nice and polished release,
and that you will probably never see one either:  This is a snapshot 
of what I happened to have on my lab-computer right now, and I will
update it as time/need/inspiration strikes.

There is a sort of vision behind it which has matured as I went
along and learned more and more python, and I will try to move
closer to that as I go.  The best place to spot it is in the
pylt.py file, where the methods all instruments should support
are defaulted.

Prologix.biz USB-GPIB
=====================

The one thing you need to know is that you must tell where to
find your instruments.  

For instance:

        class hp3336c(prologix_usb.gpib_dev):
                def __init__(self, name = "gpib0", adr = 13):

"gpib0" corresponds to /dev/gpib0 (which is where one of my
Prologix USB-GPIB adapters show up.)  and 13 is the bus address.

There is a nifty multiplexing facility built in, so you can
talk to multiple instruments at a Prologix driven bus at the
same time from the same python script, without having to
think about it.


USBTMC/USB488
=============

This one caused me no end of pain, what a sucky standard, but
at least it looks like the Agilent U2004A Power Sensor works
reliably now.

You will need py-usb 1.0 and some backend for it, I use libusb.


Getting started
===============

With git installed do:

        cd /some/where
        mkdir pylt
        cd pylt
        git -clone git://github.com/bsdphk/pylt.git


Who ?
=====

Written by Poul-Henning Kamp, <phk at FreeBSD.org>


License ?
=========

/*
 * ----------------------------------------------------------------------------
 * "THE BEER-WARE LICENSE" (Revision 42):
 * <phk at FreeBSD.ORG> wrote this file.  As long as you retain this notice you
 * can do whatever you want with this stuff. If we meet some day, and you think
 * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
 * ----------------------------------------------------------------------------
 */


Enjoy,

Poul-Henning

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.



More information about the time-nuts mailing list