Пример #1
0
def check():
	#check cryostat temperatures and mag resistance
	#also driver function for ramping
	# This function runs when count == 3 (once), 4 (loop), or 7 (loop)
	global count
	global t
	global temps
	global curr
	global fiftyK
	global dIdt
	global interrupt_server
	global temp
	global tk_app

	new_inter_temp = interrupt_server.poll()
	if new_inter_temp is not None:
		print('> Received interrupt packet, changing temp to {} K.'.format(new_inter_temp))
		temp = new_inter_temp
		tk_app.myentry.delete(0, END)
		tk_app.myentry.insert(END, str(new_inter_temp))
	
	try:
		t = time.time() - t0
		temps1 = get_temps()
		#get ramp rate
		dIdt = rampRate()
		#time.sleep(1) #Jordan removed this  
		temps2 = get_temps() #using get_temps as time.sleep(1) 
		ami.write('VOLT:SUPP?\n')
		volt = ami.readline()
		ami.write('CURR:TARG?\n')
		targ = ami.readline()
		#print('Supply V: '+volt )
		volt = float(volt)
		ami.write('CURR:MAG?\n')
		curr = ami.readline()
		#print('Mag I: '+curr)
		curr = float(curr)
		temps3 = get_temps() #using get_temps as time.sleep(1)
		
		temps = (temps1+temps2+temps3)/3.
		
		#calculate resistance
		#When current is very low, Z>>0.025
		#the condition should be on current only?
		if float(targ)<float(curr):
			dIdt = -dIdt
		if curr > 0.4: #  if curr > 0.05 and volt >0.1: the bummer here is that voltage is only measured to 10mV
				Z = (volt-dIdt*L)/curr
		else:
			Z=0
		print("")#newline
		print(' Supply V: '+str(volt+.000001)[0:6],end='')#the +.0001 makes sure i doesn't round off a zero at the end for the string
		print(' Mag I: '+str(curr+.000001)[0:6],end='')
		print(' Z: ' + str(Z*1000.+.0000001)[0:4] + ' mOhms',end='')
		print(' ADR T: '+str(temps[18]+.0000001)[0:6],end='')
		print(' 4K HTS: '+str(temps[1]+.0000001)[0:5],end='')
		print(' 4K Plate: '+str(temps[15]+.000001)[0:5],end='')
		print(' 50K HTS: '+str(temps[2]+.0000001)[0:5],end='')
		print(' He-3: '+str(temps[16]+.0000001)[0:5],end='')
		print(' He-4: '+str(temps[17]+.00000001)[0:5],end='')
		#print('t: '+str(t))
		
		#4k HTS
		if temps[1] > 8:
			alarm()
		if temps[1] > 10:
			stop()
		#4k Plate
		if temps[15] > 5:
			alarm()
		if temps[15] > 6:
			stop()
		#50k HTS
		fiftyK.append(temps[2])
		if first==False:
			d50K = fiftyK[1]-fiftyK[0]
		else:
			d50K = 0
		fiftyK[0] = fiftyK.pop()
		#print(d50K)
		if d50K>0.001:
			alarm()
		if d50K>0.05:
			#reads in ~5sec intervals
			print('dT/dt of 50K HTS > 0.6K/min')
			stop()
		if temps[2] > 61:
			alarm()
		if temps[2] > 70:
			stop()
		
		#write to file
		writeToFile(volt,curr,L,dIdt,Z,temps)
		
		#ensure switch doesn't over/under heat during stage 4
		if temps[12]>17.3 and count==4:
			switchOff()
		elif 17.0<temps[12]<17.3 and count==4:
			ag49.write('INST:SEL OUT1')
			ag49.write('Volt 1.6')
		elif 16.8<temps[12]<17.0 and count==4:
			ag49.write('INST:SEL OUT1')
			ag49.write('Volt 1.67')
		elif temps[12]<16.8 and count==4:
			ag49.write('INST:SEL OUT1')
			ag49.write('Volt 1.73')	
		print(' ADR Switch Temp: ' + str(temps[12]+.00001)[0:5],end='')
	
		
		#turn off ADR switch if He-4 Head and ADR cool to 1.2K, wait 5 minutes from start of ramping
		#wait because initially temperature will be low before switch
		if temps[18]<1.4 and temps[17] < 1.3 and temps[18]!=-1 and t>5.0*60.0 and count==4:#1.3,1.2
			count=5
			switchOff()

		#ADR Switch temp and begin ramp down
		if temps[12] < 4.2 and count == 5:
			count=6
			rampD()
			return False
		
		#check magnet resistance
		if Z >= 0.050:
			print('Resistance above 0.050 Ohms')
			stop()
			switchOff()
			return False

		else:
			#time.sleep(1) #Jordan removed compensated by longer get_temps but ami needs this
			return True
		
	except Exception as e: 
		print(e) 
		#print('Error Occured while checking temp. or resistance.')
		stop()
		switchOff()
		alarm()
		return False
Пример #2
0
def switchOn():
	global running
	global count
	
	while running:
		#keep ADR switch on until desired conditions
		try:
			temps = get_temps()
			print("")#newline
			print(' He3 Temp: ',end='')
			print(temps[16],end='')
			print(' He4 Temp: ',end='')
			print(temps[17],end='')
			print(' ADR Temp: ',end='')
			print(temps[18],end='')
			print(' ADR switch Temp: ',end='')
			print(temps[12],end='')
			#If ADR is already on...
			#if -1< temps[18] <1.25:
			#	count = 2
			### POTENTIAL BUG BELOW (incorrect use of `and` with `temps[16] and temps[17]``)
			if temps[16] and temps[17] < 1.3 and temps[18]!=-1 and count == 0:
				#if He3 and He4 are below 1.3K turn on ADR switch
				ag49.write('INST:SEL OUT1')
				ag49.write('Volt 1.75')
				#3.5 #Afyhrie changed from 1.75 to 1.5 on June 28 2017
				#to make sure the ADR switch doesn't heat above 17 K
				print('ADR switch ON')
				count=1
			if 17.2 > temps[12] > 17.0 and count == 1:
				ag49.write('INST:SEL OUT1')
				ag49.write('Volt 1.6')
				#count=2
			if 17 > temps[12] > 16.8 and count == 1:
				ag49.write('INST:SEL OUT1')
				ag49.write('Volt 1.68')
				#count=2
			if 16.8 > temps[12] > 15 and count == 1:
				ag49.write('INST:SEL OUT1')
				ag49.write('Volt 1.85')#jordan changed 2/11/19 from 1.75 to 1.85
			if temps[18] <1.4 and temps[17] < 1.3 and temps[18]!=-1 and count == 1 and temps[12]>16.7:#1.25 1.15
				#wait till He4/ADR return to normal temp. before switch
				print('ADR and He4 Stabalized')
				ag49.write('INST:SEL OUT1')
				ag49.write('Volt 1.75') 
				count=3
				break
			if temps[12] > 17.2:
				print('ADR switch above 17.2K')
				switchOff()
				count = 1
				#running = False
				#break
		except:
			#if get_temps fails, turn off ADR switch to prevent overheating
			running = False
			switchOff()
			alarm()
			print('Error occured while running Switch ON')
			break
		time.sleep(3)
Пример #3
0
        x = np.roll(x, -1)  #shift the time array by 1 interval
        x[419] = t / 60.  #record current time to last position of time array
        y = np.roll(y, -1, axis=0)  # shift temperature array by 1 interval
        volt_y = np.roll(volt_y, -1,
                         axis=0)  #shift voltage array by 1 interval
        curr_y = np.roll(curr_y, -1,
                         axis=0)  #shift current array by 1 interval
        press_y = np.roll(press_y, -1,
                          axis=0)  #shift pressure array by 1 interval

        #grab pressure and store in pressure array
        press = get_press()
        press_y[419, :] = press

        #grab temperatures and store them to the temperature array
        temps = get_temps()
        y[419, :] = temps

        k = 0  #intiialize a counter

        plt.subplot(gs[0:2, :])  #create top subplot
        for j in plots:  #plot all of the temperatures with appropriate labels
            #print(y[419,j])
            plt.semilogy(x,
                         y[:, j],
                         color=colors[np.mod(j, 7)],
                         linestyle=lines[j / 7],
                         linewidth=2,
                         label=labels[k] + " " + str(y[419, j])[0:5] + "K")
            if i != 0:
                legend.get_texts()[k].set_text(
Пример #4
0
	0,#	4He Head        
	0))#ADR

sleep_interval = 10. #seconds change back
Alarm = 0 # 0 for off 1 for on

now = datetime.datetime.now()
date_str = str(now)[0:10]
# we want the file prefix to reflect the date in which the temperature data is taken
file_prefix =  "./Temps/" + date_str
file_suffix = ''
file_prefix2 =  "./Voltage_Current/" + date_str
file_suffix2 = ''

#do a check to make sure the  he3 and he4 switches have cooled
temps = get_temps()
if temps[9] >15. or temps[10]>15:
	print("He4 or He3 switch still hot waiting at least 20mins to cool")
	if sleep_time<20*60 and sleep_time>-1:
		sleep_time = 20*60

# Create and open the monitoring plot
monitor_plot = MonitorPlot(sleep_interval, 420, plot_pressure=False)
monitor_plot.show()

start = time.time()+sleep_time #define a start time here if we have a delay we just start at t<0
if os.path.isfile(file_prefix + '_temps_fridgecycle.txt') == True: #check if there is already a file with the prefix we are trying to use
	#If a file already exists add a suffix to the end that consist of the time it was created so it can be distinguished from the original file
	file_suffix = '_'+str(datetime.datetime.now())[11:13]+'_'+str(datetime.datetime.now())[14:16]
f = open(file_prefix + file_suffix +'_temps_fridgecycle.txt' ,'w') #open a file to write the temperatures to
Пример #5
0
def main():
    global start_time
    global count
    global dIdt
    while True:  #Main is always looping

        new_time = time.time() - start_time  #current time
        new_temps = get_temps()
        _, new_volt, new_curr = read_power_supplies()
        #monitor_plot.update(new_time, new_temps, new_volt, new_curr, [0])
        dIdt, volt, targ, curr, Z = get_ami_data(ami)

        if count == -3:  #make sure the 4He and 3He switches are off
            turn_off_3He_4He_switches(new_temps, ps)
            start_time = time.time() + sleep_time
            count = -2

        new_time = time.time() - start_time
        while new_time < 0:  #for haveing a delay in the start hang here until ready to heat 4He pump
            new_time = time.time() - start_time  #current time
            new_temps = get_temps()
            _, new_volt, new_curr = read_power_supplies()
            monitor_plot.update(new_time, new_temps, new_volt, new_curr, [0],
                                curr)
            writeToFile(volt, curr, L, dIdt, Z, new_temps)
            print_pretty(volt, curr, L, dIdt, Z, new_temps)

        if count == -2:  #heat up the 4He pump
            turn_on_ADR_switch(ps)  #turn on the ADR switch at the beginning
            print("Heating up 4He Pump")
            while new_time < 30 * 60:
                new_time = time.time() - start_time  #current time
                new_temps = get_temps()
                _, new_volt, new_curr = read_power_supplies()
                monitor_plot.update(new_time, new_temps, new_volt, new_curr,
                                    [0], curr)
                heat_4He_pump(new_temps, ps)
                writeToFile(volt, curr, L, dIdt, Z, new_temps)
                print_pretty(volt, curr, L, dIdt, Z, new_temps)
            count = -1

        if count == -1:  #Heat up the 3He pump keep 4He pump hot
            print("Heating up 3He pump")
            while new_time < 50 * 60:
                new_time = time.time() - start_time  #current time
                new_temps = get_temps()
                _, new_volt, new_curr = read_power_supplies()
                monitor_plot.update(new_time, new_temps, new_volt, new_curr,
                                    [0], curr)
                heat_4He_pump(new_temps, ps)
                heat_3He_pump(new_temps, ps)
                writeToFile(volt, curr, L, dIdt, Z, new_temps)
                print_pretty(volt, curr, L, dIdt, Z, new_temps)
            count = 0

        if count == 0:  #wait until ready to ramp up
            print("Waiting to ramp up")
            while check_start_ramp(new_temps):
                new_time = time.time() - start_time  #current time
                new_temps = get_temps()
                _, new_volt, new_curr = read_power_supplies()
                monitor_plot.update(new_time, new_temps, new_volt, new_curr,
                                    [0], curr)
                heat_4He_pump(new_temps, ps)
                heat_3He_pump(new_temps, ps)
                writeToFile(volt, curr, L, dIdt, Z, new_temps)
                print_pretty(volt, curr, L, dIdt, Z, new_temps)
            count = 1

        if count == 1:  #start ramp up
            print("starting ramp up")
            new_temps = get_temps()
            if temp_safety_check(
                    new_temps):  #run a safety check on temps before ramping up
                pass
            else:
                print(
                    "Did not pass tempearature safety before beginning ramp up exiting program"
                )
                sys.exit()
            dIdt, volt, targ, curr, Z = get_ami_data(ami)
            if magnet_safety_check(
                    dIdt, volt, targ, curr, Z
            ):  #run a safety check on the magnet current and resistance
                pass
            else:
                print(
                    "Did not pass magnet safety check before beginning ramp up exiting program"
                )
                sys.exit()

            start_ramp_time = time.time()
            rampU(ami)  #start the ramp up
            while (time.time() - start_ramp_time
                   ) < 30 * 60:  #20 mins to ramp and 10 mins for good measure
                new_time = time.time() - start_time  #current time
                new_temps = get_temps()
                _, new_volt, new_curr = read_power_supplies()
                dIdt, volt, targ, curr, Z = get_ami_data(ami)
                monitor_plot.update(new_time, new_temps, new_volt, new_curr,
                                    [0], curr)
                heat_4He_pump(new_temps, ps)  #keep pumps hot during ramp up
                heat_3He_pump(new_temps, ps)
                writeToFile(volt, curr, L, dIdt, Z, new_temps)
                print_pretty(volt, curr, L, dIdt, Z, new_temps)
                if temp_safety_check(new_temps):  #temp safety check
                    pass
                else:
                    emergency_ramp_down(ami)
                    count = 6
                    break
                if magnet_safety_check(dIdt, volt, targ, curr,
                                       Z):  #magnet safety check
                    pass
                else:
                    emergency_ramp_down(ami)
                    count = 6
                    break
            if count != 6:
                count = 2

        if count == 2:  # the magnet is energized time to sink the 4He pump:
            print("sinking 4He pump")
            new_temps = get_temps()
            while new_temps[
                    7] > 5.0:  #4He pump It might be better to trigger this when the 4He/3He gets below 2K because when the
                # 4He head is cold but the 3He pump is hot the 4He charge has to fight the conductino of the 3He hot pump to 4K
                # of course we don't want to sink them at teh same time
                # maybe don't sink it but stop heating it if the 4He and 3He heads are cold
                new_time = time.time() - start_time  #current time
                new_temps = get_temps()
                _, new_volt, new_curr = read_power_supplies()
                dIdt, volt, targ, curr, Z = get_ami_data(ami)
                monitor_plot.update(new_time, new_temps, new_volt, new_curr,
                                    [0], curr)
                writeToFile(volt, curr, L, dIdt, Z, new_temps)
                print_pretty(volt, curr, L, dIdt, Z, new_temps)
                cool_4He_pump(new_temps, ps)
                heat_3He_pump(new_temps, ps)
                if temp_safety_check(new_temps):
                    pass
                else:
                    ps.change_voltage(
                        'He4 switch', 0
                    )  #turn off 4He switch so that the 4HE pump stop sinking and increassing the 4K plate temp
                    emergency_ramp_down(ami)
                    count = 6
                    break
                if magnet_safety_check(dIdt, volt, targ, curr, Z):
                    pass
                else:
                    ps.change_voltage(
                        'He4 switch', 0
                    )  #turn off 4He switch so that the 4HE pump stop sinking and increassing the 4K plate temp
                    emergency_ramp_down(ami)
                    count = 6
                    break
            if count != 6:
                count = 3

        if count == 3:  # the magnet is energized and the 4He pump is sunk, time to sink the 3He pump
            print("sinking 3He pump")
            new_temps = get_temps()
            while new_temps[8] > 4.5:  #3He pump
                new_time = time.time() - start_time  #current time
                new_temps = get_temps()
                _, new_volt, new_curr = read_power_supplies()
                dIdt, volt, targ, curr, Z = get_ami_data(ami)
                monitor_plot.update(new_time, new_temps, new_volt, new_curr,
                                    [0], curr)
                writeToFile(volt, curr, L, dIdt, Z, new_temps)
                print_pretty(volt, curr, L, dIdt, Z, new_temps)
                cool_3He_pump(new_temps, ps)
                if temp_safety_check(new_temps):
                    pass
                else:
                    ps.change_voltage(
                        'He3 switch', 0
                    )  #turn off 3He switch so that the 4HE pump stop sinking and increassing the 4K plate temp
                    emergency_ramp_down(ami)
                    count = 6
                    break
                if magnet_safety_check(dIdt, volt, targ, curr, Z):
                    pass
                else:
                    ps.change_voltage(
                        'He3 switch', 0
                    )  #turn off 3He switch so that the 4HE pump stop sinking and increassing the 4K plate temp
                    emergency_ramp_down(ami)
                    count = 6
                    break
            if count != 6:
                count = 4

        if count == 4:  # both 4H3 and 3He pumpu are sunk turn off the ADR switch
            print("Turning off ADR switch")
            turn_off_ADR_switch(ps)
            new_temps = get_temps()
            while new_temps[12] > 4.5:  #adr switch
                new_time = time.time() - start_time  #current time
                new_temps = get_temps()
                _, new_volt, new_curr = read_power_supplies()
                dIdt, volt, targ, curr, Z = get_ami_data(ami)
                monitor_plot.update(new_time, new_temps, new_volt, new_curr,
                                    [0], curr)
                writeToFile(volt, curr, L, dIdt, Z, new_temps)
                print_pretty(volt, curr, L, dIdt, Z, new_temps)
                if temp_safety_check(new_temps):
                    pass
                else:
                    emergency_ramp_down(ami)
                    count = 6
                    break
                if magnet_safety_check(dIdt, volt, targ, curr, Z):
                    pass
                else:
                    emergency_ramp_down(ami)
                    count = 6
                    break
            if count != 6:
                count = 5

        if count == 5:  # ADR switch is off start ramp down
            print("Starting ramp down")  # do i need this
            #ami.write('CONF:CURR:TARG 0\n')
            #ami.write('CONF:RAMP:RATE:CURR 1,0.25,10\n')
            #ami.write('RAMP\n')
            dIdt_old = -0.25 / 60
            #dIdt = -0.25/60
            #time.sleep(5)
            print('Ramping down at -0.25 A/min.')
            dIdt, volt, targ, curr, Z = get_ami_data(ami)
            #start pid looping
            while curr > 0.001 and dont_stop:  #stay here until the current is all depleted or stop() is called
                new_time = time.time() - start_time  #current time
                listen_for_temp_interupt()
                new_temps = get_temps()
                _, new_volt, new_curr = read_power_supplies()
                dIdt, volt, targ, curr, Z = get_ami_data(ami)
                monitor_plot.update(new_time, new_temps, new_volt, new_curr,
                                    [0], curr)
                writeToFile(volt, curr, L, dIdt, Z, new_temps)
                print_pretty(volt, curr, L, dIdt, Z, new_temps)

                if running:  #to allow for pausing
                    if use_pid:
                        pid.setpoint = np.float(temp)
                        current_temp = new_temps[18]  #
                        print("")
                        print(current_temp)
                        print(pid.setpoint)
                        dIdt_old = dIdt
                        dIdt = pid(current_temp)  #
                        print(str(dIdt)[0:6])  #
                        print(str(np.abs(dIdt))[0:6])  #
                        print("")
                        if dIdt > 0:  #
                            ami.write('CONF:CURR:TARG 1.5\n')  #
                        else:  #
                            ami.write('CONF:CURR:TARG 0\n')  #
                        ami.write('CONF:RAMP:RATE:CURR 1,' +
                                  str(np.abs(dIdt))[0:6] + ',10\n')  #
                        ami.write('RAMP\n')  #
                        if dIdt != dIdt_old:
                            time.sleep(
                                5
                            )  #needs time to equilibrate before measure resistance
                    else:
                        temp_control(new_temps, ami, curr)
                if temp_safety_check(new_temps):
                    pass
                else:
                    emergency_ramp_down(ami)
                    break
                if magnet_safety_check(dIdt, volt, targ, curr, Z):
                    pass
                else:
                    emergency_ramp_down(ami)
                    break
            count = 6
            # just make sure you ramp to zero when you are done
            ami.write('CONF:CURR:TARG 0\n')
            ami.write('CONF:RAMP:RATE:CURR 1,0.5,10\n')
            ami.write('RAMP\n')

        if count == 6:  # just keep monitoring after the fact
            while True:
                new_time = time.time() - start_time  #current time
                new_temps = get_temps()
                _, new_volt, new_curr = read_power_supplies()
                dIdt, volt, targ, curr, Z = get_ami_data(ami)
                monitor_plot.update(new_time, new_temps, new_volt, new_curr,
                                    [0], curr)
Пример #6
0
def check():
	#check cryostat temperatures and mag resistance
	try:
		temps = get_temps()
		
		print 'ADR T:'
		print temps[18]
		#get ramp rate
		dIdt = rampRate()
		time.sleep(1)
		ami.write('VOLT:SUPP?\n')
		volt = ami.readline()
		volt = float(volt)
		print 'V: '
		print volt
		ami.write('CURR:MAG?\n')
		curr = ami.readline()
		curr = float(curr)
		print 'I:'
		print curr
		#print 'place'
		#ami.write('IND?\n')
		#L = ami.readline()
		#print 'dIdt: '
		#print dIdt
		#calculate resistance
		if curr > 0.05 and dIdt!=0 and volt > 0.05:
			Z = (volt-dIdt*L)/curr
		else: 
			Z=0
		print 'Z:'
		print Z
		#4k HTS
		if temps[1] > 8:
			Alarm+1
			alarm()
		if temps[1] > 8.5:
			print '4K HTS too hot'
			stop()
			return False
		#4k Plate
		if temps[15] > 5:
			alarm()
		if temps[15] > 6:
			print '4K Plate too hot'
			stop()
			return False
		#50k HTS
		if temps[2] > 61:
			alarm()
		if temps[2] > 70:
			print '50K too hot'
			stop()
			return False


		#check magnet resistance
		if Z >= 0.025:
			print 'resistance too high'
			stop()
			return False
		else:
			return True
	except Exception as e:
		print 'Error Occured:'
		print e
		stop()
		return False