comparison example.py @ 3:62ffab79227e

Add example.py with pylab plotting example. Tested with the Tek 2024B.
author Daniel O'Connor <darius@dons.net.au>
date Wed, 13 May 2009 17:08:41 +0930
parents
children 51d1fc44a753
comparison
equal deleted inserted replaced
2:adaff1c4fd6b 3:62ffab79227e
1 #!/usr/bin/env python
2
3 import usb488
4 import matplotlib.pylab as pylab
5 import numpy
6 import time
7
8 def main():
9 u = usb488.USB488Device()
10 print "Found device"
11
12 u.write("*IDN?")
13 print "ID is..",
14 print u.read()
15
16 u.write("DATA:ENC RIB") # Big endian signed
17 u.write("DATA:WIDTH 2") # 2 bytes wide
18 u.write("SELECT:CH1 ON") # Turn channel 1 on
19 u.write("DATA:SOURCE CH1") # Set the curve source to channel 1
20 u.write("CURVE?") # Ask for the curve data
21 time.sleep(1) # Wait for the data..
22 # XXX: need some way of polling
23 result = u.read()
24 data = result[13:] # Chop off the header
25 dattype = numpy.dtype('>h') # Big endian 16 bit quantity
26 ary = numpy.fromstring(data, dtype = dattype)
27 pylab.plot(ary)
28 pylab.show()
29
30 if __name__ == "__main__":
31 main()