-
Notifications
You must be signed in to change notification settings - Fork 0
/
fixedgate.py
202 lines (145 loc) · 4.83 KB
/
fixedgate.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 05 15:58:48 2012
@author: bram
"""
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 19 11:08:03 2012
Program for Bias Cooling
This program will ramp to set gate voltage and vary the bias at that voltage
Changelog:
- Created 7/19/2012
-
@author: Brraaaam
"""
import time
import matplotlib
import SRS830
import DAC488
import lakeshore332
import winsound
import datetime
import os, errno
# Program Parameters
gateSet = -2.0
gateVoltage = -0.0
biasSet = 5.0
biasVoltage = 0.0
biasStep = 0.1
stepTime = 1
stepVoltage = 0.1 # 1mV steps
#Sample Info
sample = 'VA150ALD2'
wire = 'III'
notes = '.............'
date = time.strftime('%d/%m/%y',time.localtime())
# Initialize the devices
lockin1 = SRS830.device('GPIB::8')
lockin2 = SRS830.device('GPIB::16')
gate = DAC488.device('GPIB::10')
temp = lakeshore332.device('GPIB1::12')
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 + '\\'
# Make the sample directory
mkdir_p(path)
dat_file = open (path + 'rampup.dat', 'w')
meas_file = open (path + 'measurement.txt','w')
gate.set_range(1,3)
t_start = time.time()
# Measurement info is stored in a separate file than the actual values
# Sample info
s = 'Sample: %s \t Wire: %s \n' % (sample,wire)
meas_file.write(s)
print(s)
s = time.strftime('%H:%M:%S',time.localtime()) + '\t Ramping the Gate Voltage from %f to %f \n' % (gateVoltage,gateSet)
meas_file.write(s)
print(s)
print("...")
print("...")
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")
# Start Ramping the Gate
while gateVoltage > gateSet:
# Set the new Gate Voltage
gate.set_voltage(1,gateVoltage)
# Wait
time.sleep(stepTime)
# Get Temperature, Voltages, Time
currTemp = float(temp.read('b'))
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))
# Increment the gate voltage
gateVoltage = gateVoltage + stepVoltage
s = time.strftime('%H:%M:%S',time.localtime()) + '\t Finished Ramping. Gate Voltage: %f /n' % gateVoltage
print(s)
meas_file.write(s)
# Close the ramp up file
dat_file.close()
# Open a new data file
dat_file = open (path + 'static_gate.dat')
# Alert that ramp is finished
Freq = 2500 # Set Frequency To 2500 Hertz
Dur = 300 # Set Duration To 1000 ms == 1 second
winsound.Beep(Freq,Dur)
s = time.strftime('%H:%M:%S',time.localtime()) + '\t Beginning Bias Sweep \n'
print s
meas_file.write(s)
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")
while biasVoltage<biasSet:
# Set the new Gate Voltage
lockin1.set_amplitude(biasVoltage)
# Wait
time.sleep(stepTime)
# Get Temperature, Voltages, Time
currTemp = float(temp.read('b'))
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, biasVoltage, xValue1, xValue2)
dat_file.write("%f \t %f \t %f \t %r \t %r \n" % (currTemp, currTime, biasVoltage, xValue1, xValue2))
# Increment the gate voltage
biasVoltage = biasVoltage + biasStep
# Close the bias sweep file
dat_file.close()
# Open a new data file
dat_file = open (path + 'rampdown.dat')
s = time.strftime('%H:%M:%S',time.localtime()) + '\t Bias Sweep Finished. Beginning ramp down \n'
print s
meas_file.write(s)
s = "Temp(K) \t Time(s) \t Gate(V) \t X-Value(V) \t X-Value-2\n"
dat_file.write(s)
while gateVoltage < 0:
# Set the new Gate Voltage
gate.set_voltage(1,gateVoltage)
# Wait
time.sleep(stepTime)
# Get Temperature, Voltages, Time
currTemp = float(temp.read('b'))
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))
# Increment the gate voltage
gateVoltage = gateVoltage + stepVoltage
print("Cooldown Finished!")
print("...")
print("Ramping Voltage back to zero")
s=time.strftime('%H:%M:%S',time.localtime()) + '\t Measurement Finished \n'
print s
meas_file.write(s)
winsound.Beep(Freq,Dur)