-
Notifications
You must be signed in to change notification settings - Fork 7
/
README
107 lines (73 loc) · 2.93 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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()
# 1 MHz, -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 1980s 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@FreeBSD.org>.
License?
=========
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <phk@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
* ----------------------------------------------------------------------------
*/