-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.py
executable file
·47 lines (34 loc) · 956 Bytes
/
run.py
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
#!/usr/bin/python
import numpy
import instrument
scope = instrument.RigolScope("/dev/usbtmc0")
#scope.write(":beep:act")
#scope.write(":beep:act")
scope.write(":stop")
scope.write(":wav:pin:mode nor")
scope.write(":wav:data? chan1")
rawdata = scope.read(100)
data = 255 - numpy.frombuffer(rawdata, 'B', offset=10)
scope.write(":chan1:scal?")
vscale = float(scope.read(20)) #in volts
scope.write(":chan1:offs?")
voff = float(scope.read(20)) #in volts
scope.write(":tim:scal?")
tscale = float(scope.read(20)) #in seconds
scope.write(":tim:offs?")
toff = float(scope.read(20)) #in seconds
time = numpy.arange(-300./50*tscale, 300./50*tscale, tscale/50)
data = (data - 130.0 - voff/vscale*25) / 25*vscale
if time[-1:] < 1e-3:
time *= 1e6
tUnit = "uS"
elif time[-1:] < 1:
time *= 1e3
tUnit = "mS"
else:
tUnit = "S"
time = numpy.resize(time,(1,data.size))
print tUnit
print numpy.vstack((data,time)).T
scope.write(":key:lock dis")
scope.close()