comparison tek2024b_example.py @ 18:9bb8a9f3df6b

Update examples to match new code.
author Daniel O'Connor <darius@dons.net.au>
date Wed, 10 Aug 2011 15:18:26 +0930
parents c2c13d804fce
children 91b476ebc0f2
comparison
equal deleted inserted replaced
17:20df02be818a 18:9bb8a9f3df6b
50 vscale = float(u.read(1).split()[1]) 50 vscale = float(u.read(1).split()[1])
51 print "Channel 1 scale is %.2f volts/div" % (vscale) 51 print "Channel 1 scale is %.2f volts/div" % (vscale)
52 52
53 # Fetch horizontal scale 53 # Fetch horizontal scale
54 u.write("HOR:MAIN:SCALE?") 54 u.write("HOR:MAIN:SCALE?")
55 hscale = float(u.read(1).split()[1]) 55 hscale = scpi.getdata(u.read())
56 print "Horizontal scale is %f sec/div" % (hscale) 56 print "Horizontal scale is %f nsec/div" % (hscale * 1e9)
57 57
58 # Make sure the previous commands have been executed 58 # Make sure the previous commands have been executed
59 u.write("*WAI") 59 u.write("*WAI")
60 60
61 # Fetch curve data (wait up to 1 second) 61 # Fetch curve data (wait up to 1 second) since the read takes a little while
62 u.write("CURVE?") 62 u.write("CURVE?")
63 then = time.time() 63 then = time.time()
64 result = u.read(1.0) 64 result = u.read(1.0)
65 now = time.time() 65 now = time.time()
66 print "CURVE read took %f milliseconds" % ((now - then) * 1000.0) 66 print "CURVE read took %f milliseconds" % ((now - then) * 1000.0)
67 67
68 # Parse data 68 # Parse data
69 ary = scpi.bindecode(result, header = ':CURVE ', dtype = numpy.dtype('>h')) 69 ary = scpi.bindecode(result, dtype = numpy.dtype('>h'))
70 70
71 # Convert to volts 71 # Convert to volts
72 ary = ary / 32768.0 * vscale 72 ary = ary / 32768.0 * vscale
73 73
74 # Plot data 74 # Plot data