-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakeIVscan.py
More file actions
72 lines (60 loc) · 1.64 KB
/
Copy pathmakeIVscan.py
File metadata and controls
72 lines (60 loc) · 1.64 KB
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
from DT5485Wrapper import DT5485
from time import sleep
import time
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-p","--port")
parser.add_option("-m","--vmin")
parser.add_option("-M","--vmax")
parser.add_option("-s","--vstep")
parser.add_option("-n","--nmeas")
parser.add_option("-o","--out")
(options,args)=parser.parse_args()
c0=DT5485(options.port)
c0.printID()
vmin=float(options.vmin)
vmax=float(options.vmax)
vstep=float(options.vstep)
nmeas=int(options.nmeas)
hvONOFF=c0.getChStatus()
if (hvONOFF>0):
r=c0.setRegister(0,0)
hvONOFF=c0.getChStatus()
print "Waiting for CH0 to be off"
while (hvONOFF!=0):
hvONOFF=c0.getChStatus()
sleep(1)
print "Retrying"
print "Setting VSET @"+str(vmin)
r=c0.setChVSET(vmin)
vset=c0.getChVSET()
if (vset != vmin):
print "Cannot set VSET to "+vmin
exit(-1)
print "Turning CH0 ON"
r=c0.setRegister(0,1)
import csv
outFile=open(options.out, mode='w+')
csvWriter = csv.writer(outFile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
print "Writing data to "+options.out
while (vset<=vmax):
sleep(5)
print "VSET@"+str(vset)+" V"
for i in range(0,nmeas):
vout=c0.getChVOUT()
iout=c0.getChIOUT()
csvWriter.writerow(['1',str(vset),str(vout),str(iout),str(time.time())])
print "%f,%f,%f"%(vset,vout,iout)
vset+=vstep
r=c0.setChVSET(vset)
if (r!=0):
print "Problems setting VSET"
outFile.close()
print "Turning CH0 OFF"
r=c0.setRegister(0,0)
hvONOFF=c0.getChStatus()
print "Waiting for CH0 to be off"
while (hvONOFF!=0):
hvONOFF=c0.getChStatus()
sleep(1)
print "Retrying"