#Script for finding the PID parameters import time #Parameters T_min=380 T_max=300 T_step=-30 P_min=0.65 P_max=0.66 P_step=0.02 I_min=0.0025 I_max=0.0035 I_step=0.002 D_min=1.28 D_max=1.29 D_step=0.05 output_path="/sls/X11MA/data/X11MA/scans/2021/PID/" print "Starting the PID scan" caput('X11MA-PC-LEEM:PID-MainSwitch','Off') for t in range(T_min, T_max, T_step): caput('X11MA-PC-LEEM:FIL_PID.VAL', t) for p in frange(P_min, P_max, P_step): for i in frange(I_min, I_max, I_step): for d in frange(D_min, D_max, D_step): print "Heating with T =",t," P =",p,"I =",i,"D =",d start = time.localtime() caput('X11MA-PC-LEEM:FIL_PID_P', p) caput('X11MA-PC-LEEM:FIL_PID_I', i) caput('X11MA-PC-LEEM:FIL_PID_D', d) output_file=output_path + time.strftime("%Y%m%d_%H%M", start) + ".txt"; f=open(output_file, "w") f.write("T="+str(t)+"K P="+str(p)+" I="+str(i)+" D="+str(d)+"\r\n") f.write("Time\t\t Temp. RBV [K]\t Temp. SP [K]\t Filament Volt. [mA]\r\n") caput('X11MA-PC-LEEM:PID-MainSwitch', 'On') for n in range(360): #180*10(wait time)=1800s=30min Tmp=caget("X11MA-PC-SW:Pt100-K") Fil=caget("X11MA-PC-LEEM:FIL_SP") Tim=time.strftime('%H:%M:%S',time.localtime()) f.write(Tim + "\t " + str(Tmp) + "\t" + str(t) + "\t\t" + str(Fil) + "\t" + "\r\n") time.sleep(10) # wait for 10 s f.close() caput('X11MA-PC-LEEM:PID-MainSwitch','Off') # time.sleep(1800) # cooling for 1800s = 30min print "PID scan finished"