-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcooldown.py
254 lines (216 loc) · 9.29 KB
/
cooldown.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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
from __future__ import print_function
import numpy as np
import visa
import matplotlib
matplotlib.use('qt4agg')
import matplotlib.pyplot as plt
import time
import datetime
import os
import smtplib
from scipy import interpolate
#########################################################
# Program to cooldown the cryostat #
#########################################################
# we want to just monitor the temperature and when things get cold enough
#turn on the helium 3 and 4 pumps so the can cooldown thoses stages to 4K
# through gas condution
#last time I ran this from start it didn't turn on the pumps. Then I reset the program and it worked fine?
#Change log
#1/11/2016 -Jordan - Added in turning on ADR switch after it gets cold
RX202_lookup = np.loadtxt('RX-202A Mean Curve.tbl')#ADR
#RX202_lookup = np.loadtxt('RX-102A Mean Curve.tbl')# 300mK and 1K stages
RX202_interp = interpolate.interp1d(RX202_lookup[:,1], RX202_lookup[:,0],fill_value = 0.,bounds_error = False)
#test = np.float(RX202_interp(4000))
#RX202_temps = RX202_interp(-linear_bridge*1000)
lines = ['-','--','-.']
labels = ['4K P.T. ','50K HTS ','50K P.T. ','50K plate ','ADR rad shield','4He pump ','3He pump ','4He switch ','3He switch ','ADR switch ','4K-1K switch ','4K plate ','3He head ','4He head ','4K HTS ','ADR ','Head ADR switch']
colors = ['b','g','r','c','m','y','k']
plots = (0,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16)
sleep_interval = 60. #seconds
Cold_enough = 0
Alarm = 0 # 0 for off 1 for on
Alarm_test = np.zeros(15) #
Alarm_base = np.ones(15)*100.# this is where you fill in your max temp values for the alarm
now = datetime.datetime.now()
date_str = str(now)[0:10]
file_prefix = "C:/Users/tycho/Desktop/White_Cryo_Code/Temps/" + date_str
file_suffix = ''
plt.figure(1,figsize = (19,8))
x = np.arange(-420,0)*1.
print(x[0],x[419])
y = np.ones((420,17))*-1
plt.title("Thermometry")
plt.xlabel("time (mins)")
plt.ylabel("Temperature (K)")
plt.ion()
plt.show()
#create a resourcemanager and see what instruments the computer can talk to
rm = visa.ResourceManager()
rm.list_resources()
#form connections to the two lakeshore temperature sensors available
lk218 = rm.open_resource('GPIB0::2::INSTR')
lk224 = rm.open_resource('GPIB0::12::INSTR')
lr750 = rm.open_resource('GPIB0::4::INSTR')
ag49 = rm.open_resource('GPIB0::3::INSTR') #power supply 3649 in the upper RH of Rack
ag47b = rm.open_resource('GPIB0::5::INSTR') #power supply 3647 on bottom row of power supplies
ag47t = rm.open_resource('GPIB0::15::INSTR') #power supply 3647 on top row of rack
#turn on the power supplys
ag49.write('OUTPut ON')
ag47b.write('OUTPut ON')
ag47t.write('OUTPut ON')
start = time.time() #define a start time
if os.path.isfile(file_prefix + '_temps.txt') == True:
file_suffix = '_'+str(datetime.datetime.now())[11:13]+'_'+str(datetime.datetime.now())[14:16]
f = open(file_prefix + file_suffix +'_fridge_cycle_temps.txt' ,'w') #open a file to write the temperatures to
i = 0
k = 0
finished = 0 #run until it looks like the fridge cycle has completed
try: #allows you to kill the loop with ctrl c
while finished == 0: #count the seconds since the start time, and sleep for 1 second between each count
now2 = time.time()
now = datetime.datetime.now()
if str(now)[0:10] != date_str: #if it is a new day start a new file
f.close()
date_str = str(now)[0:10]
file_prefix = "C:/Users/tycho/Desktop/White_Cryo_Code/Temps/" + date_str
file_suffix = ''
f = open(file_prefix + file_suffix +'_cool_down_temps.txt' ,'w') #open a file to write the temperatures to
t = time.time()-start
x = np.roll(x,-1)
x[419] = t/60.
y = np.roll(y,-1,axis = 0)
plt.xlim(x[0],x[419])
plt.ylim(0.1,300)
y[419,0] = lk218_T1 = float(lk218.query('KRDG?1'))
#print(y[419,0],lk218_T1)
y[419,14] = lk218_T2 = float(lk218.query('KRDG?2'))
y[419,1] = lk218_T3 = float(lk218.query('KRDG?3'))
y[419,2] = lk218_T5 = float(lk218.query('KRDG?5'))
y[419,3] = lk218_T6 = float(lk218.query('KRDG?6'))
y[419,4] = lk218_T8 = float(lk218.query('KRDG?8'))
y[419,5] = lk224_TC2 = float(lk224.query('KRDG? C2'))
y[419,6] = lk224_TC3 = float(lk224.query('KRDG? C3'))
y[419,7] = lk224_TC4 = float(lk224.query('KRDG? C4'))
y[419,8] = lk224_TC5 = float(lk224.query('KRDG? C5'))
y[419,9] = lk224_TD2 = float(lk224.query('KRDG? D2')) #ADR switch
y[419,10] = lk224_TD3 = float(lk224.query('KRDG? D3'))
y[419,11] = lk224_TD5 = float(lk224.query('KRDG? D5'))
y[419,12] = lk224_A = float(lk224.query('KRDG? A'))
y[419,13] = lk224_B = float(lk224.query('KRDG? B'))
y[419,16] = lk224_TD1 = float(lk224.query('KRDG? D1'))
lr750_a = lr750.query('GET 0')
#print(lr750_a)
if i == 0: # there is some weirdness where the first call returns an empty string
lr750_a_temp = -1
if i != 0:
lr750_a_num = np.float(lr750_a[0:8])
y[419,15] = lr750_a_temp = RX202_interp(-lr750_a_num*1000)
k = 0
# here if it is not the first time I just edit the label in legend
for j in plots:
#print(y[419,j])
plt.semilogy(x,y[:,j],color = colors[np.mod(j,7)],linestyle = lines[j/7],linewidth = 2, label = labels[j]+" " +str(y[419,j])[0:5]+"K")
if i != 0:
legend.get_texts()[k].set_text(labels[j]+" " +str(y[419,j])[0:5]+"K")
k = k+1
if i == 0:
legend = plt.legend(ncol = 1,loc =2)
plt.draw()
plt.pause(sleep_interval)
if Alarm != 0:
if i > 10: #trigger the alarm if the temps execeed the threshold
Alarm_test[0] = lk218_T1
Alarm_test[1] = lk218_T3
Alarm_test[2] = lk218_T5
Alarm_test[3] = lk218_T6
Alarm_test[4] = lk218_T8
Alarm_test[5] = lk224_TC2
Alarm_test[6] = lk224_TC3
Alarm_test[7] = lk224_TC4
Alarm_test[8] = lk224_TC5
Alarm_test[9] = lk224_TD2
Alarm_test[10] = lk224_TD3
Alarm_test[11] = lk224_TD5
Alarm_test[12] = lk224_A
Alarm_test[13] = lk224_B
Alarm_test[14] = lk218_T2
if (Alarm_test>Alarm_base).any() == True:
print("Alarm Alarm")
if Alarm == 1:
print("first occurance")
fromaddr = 'SubmmLab@gmail.com'
toaddrs = '3145741711@txt.att.net'
msg = 'The temperature alarm was triggered'
username = 'SubmmLab@gmail.com'
password = 'ccatfourier'
server = smtplib.SMTP_SSL('smtp.gmail.com:465')
server.ehlo()
#server.starttls()
server.login(username,password)
server.sendmail(fromaddr, toaddrs, msg)
toaddrs = '3038192582@tmomail.net'
server.sendmail(fromaddr, toaddrs, msg)
server.quit()
Alarm = 2
if i == 0:
print("test")
print('#Human readable time. Time (s) since start. Lakeshore temperature sensor 218 T1,3,5,6,8 and 224 C2,C3,C4,C5,D2,D3,D5,A,B',file=f)
print(str(now)+' '+ str(np.round(t,3)).strip()+' '+str(lk218_T1)+' '+str(lk218_T3)+' '+str(lk218_T5)+' '+str(lk218_T6)+' '+str(lk218_T8)+' '+str(lk224_TC2)+' '+str(lk224_TC3)+' '+str(lk224_TC4)+' '+str(lk224_TC5)+' '+str(lk224_TD2)+' '+str(lk224_TD3)+' '+str(lk224_TD5)+' '+str(lk224_A)+' '+str(lk224_B)+' '+str(lk218_T2)+' '+str(lr750_a_temp)+' '+str(lk224_TD1),file = f) #print the temperature and some nonsense numbers to the file
print(str(now)+' '+ str(np.round(t,3)).strip()+' '+str(lk218_T1)+' '+str(lk218_T3)+' '+str(lk218_T5)+' '+str(lk218_T6)+' '+str(lk218_T8)+' '+str(lk224_TC2)+' '+str(lk224_TC3)+' '+str(lk224_TC4)+' '+str(lk224_TC5)+' '+str(lk224_TD2)+' '+str(lk224_TD3)+' '+str(lk224_TD5)+' '+str(lk224_A)+' '+str(lk224_B)+' '+str(lk218_T2)+' '+str(lr750_a_temp)+' '+str(lk224_TD1))
#time.sleep(60)#sleep for 60 second
i = i + 1
#cooldown crap starts here
#the way I am doing it is a bit weird we are just continously looping
#and excuting certain fridge steps if the time is appropriate
#rather than just do things step by step.
if lk224_TC4 < 6.0 and lk224_TC5 <6.0:
Cold_enough = 1
#print("The cyostat is cold enough to turn on the pumps.")
#Heat up the 4He pump
if Cold_enough == 1 and lk224_TD5<12.: # if the switches have coold and just in case if the 4K plate gets to hot
#print("test")
if lk224_TC2<45.:
ag47t.write('INST:SEL OUT1')
ag47t.write('Volt 25')
if lk224_TC2>45.:
ag47t.write('INST:SEL OUT1')
ag47t.write('Volt 15') #should creep up
if lk224_TC2>50.:
ag47t.write('INST:SEL OUT1')
ag47t.write('Volt 0')
else:
ag47t.write('INST:SEL OUT1')
ag47t.write('Volt 0')
#Heat up the He3
if Cold_enough == 1 and lk224_TD5<12.:
if lk224_TC3<45.:
ag47t.write('INST:SEL OUT2')
ag47t.write('Volt 15')
if lk224_TC3>45.:
ag47t.write('INST:SEL OUT2')
ag47t.write('Volt 5')#should increase slowly
if lk224_TC3>50.:
ag47t.write('INST:SEL OUT2')
ag47t.write('Volt 0')
else:
ag47t.write('INST:SEL OUT2')
ag47t.write('Volt 0')
# turn on the ADR switch when it gets to cold to conduct
'''
if lk224_TD2<26.:
ag49.write('INST:SEL OUT1')
ag49.write('Volt 3.5')#3.5
if lk224_TD2>30.: #temp should drop slowly
ag49.write('INST:SEL OUT1')
ag49.write('Volt 2.5')#2.5
if lk224_TD2>35.: #just in case
ag49.write('INST:SEL OUT1')
ag49.write('Volt 0')
'''
f.close() #close the file
execfile("Temp_monitor.py") #rusume the normal temperature monitoring process
except KeyboardInterrupt:
pass
f.close() #close the file
print("Human interupted the fridge cycle")