-
Notifications
You must be signed in to change notification settings - Fork 0
/
livecondata.py
133 lines (99 loc) · 3.93 KB
/
livecondata.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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# -*- coding: utf-8 -*-
"""
Created on Fri Dec 14 11:53:53 2012
This program is responsible for collecting data from instruments
@author: keyan
"""
import time
import SRS830
import lakeshore332
import os, errno
import keithley
import threading
class acquiredata():
def __init(self,data_q):
threading.Thread.__init__(self)
self.data_q = data_q
# What does this do?
self.alive = threading.Event()
self.alive.set()
self.stepTime = 0.3
self.max_gate = -2.2
self.stepsize = 0.001
self.windowlower = -1.5
self.windowupper = -2.0
self.windowstep = 0.0001
self.gateVoltage = 0.0
# Initialize the devices
self.lockin1 = SRS830.device('GPIB0::8')
self.lockin2 = SRS830.device('GPIB0::16')
#gate = DAC488.device('GPIB::10')
self.gate = keithley.device('GPIB0::24')
self.temp = lakeshore332.device('GPIB0::12')
self.gate.reset()
self.gate.configure_output('VOLT',gateVoltage,0.00005)
self.gate.enable_output()
t_start = time.time()
self.setupfile("VA150ALD2","III")
def setupfile(self,sample,wire):
'''
Sets up the file
'''
# sample = 'VA150ALD2'
# wire = 'III'
notes = '.............'
date = time.strftime('%d-%m-%y',time.localtime())
def mkdir_p(path):
try:
os.makedirs(path)
except OSError as exc:
if exc.errno == errno.EEXIST:
pass
else: raise
path = 'C:\\Users\\bram\\Documents\\Data\\' + date + '\\' + sample +'\\' + wire + '\\'
if os.path.isfile(path+'rampup.dat'):
print 'Warning! File already exists'
path = path + 'I'
mkdir_p(path)
dat_file = open (path + 'rampup.dat', 'w')
meas_file = open (path + 'measurement.txt','w')
def run(self):
# print "Window %f to %f" % (windowlower, windowupper)
print("Temp(K) \t Time(s) \t Gate(V) \t X-Value(V)\t X-Value-2\n")
dat_file.write("Temp(K) \t Time(s) \t Gate(V) \t X-Value(V)\t X-Value-2\n")
# Sweep Up Gate
while gateVoltage > max_gate:
# Set the new Gate Voltage
gate.configure_output('VOLT',gateVoltage,0.00005)
# Wait
currTemp = float(temp.read('c'))
xValue1 = lockin1.read_input(1)
yValue1 = lockin1.read_input(2)
xValue2 = lockin2.read_input(1)
yValue2 = lockin2.read_input(2)
currTime = (time.time()-t_start)
#plot1.addPoint(gateVoltage,xValue1)
# Write the values to file
print "%f \t %f \t %f \t %r \t %r" % (currTemp, currTime, gateVoltage, xValue1, yValue1, xValue2, yValue2)
dat_file.write("%f \t %f \t %f \t %r \t %r \n" % (currTemp, currTime, gateVoltage, xValue1, yValue1, xValue2, yValue2))
if (gateVoltage <= windowlower and gateVoltage >= windowupper):
gateVoltage = gateVoltage - windowstep
else:
gateVoltage = gateVoltage - stepsize
## Sweep Down Gate
while gateVoltage <= 0:
# Set the new Gate Voltage
gate.configure_output('VOLT',gateVoltage,0.00005)
# Wait
time.sleep(stepTime)
currTemp = float(temp.read('c'))
xValue1 = lockin1.read_input(1)
xValue2 = lockin2.read_input(1)
currTime = (time.time()-t_start)/60
# Write the values to file
print "%f \t %f \t %f \t %r \t %r" % (currTemp, currTime, gateVoltage, xValue1, xValue2)
dat_file.write("%f \t %f \t %f \t %r \t %r \n" % (currTemp, currTime, gateVoltage, xValue1, xValue2))
if (gateVoltage <= windowlower and gateVoltage >= windowupper):
gateVoltage = gateVoltage + windowstep
else:
gateVoltage = gateVoltage + stepsize