This commit is contained in:
2016-04-15 15:24:36 +02:00
parent 1e73b5374c
commit d4e6a3d046
12 changed files with 87 additions and 71 deletions
+2 -2
View File
@@ -16,7 +16,7 @@ if int(ENERGY) < 6:
# if theta1 and theta2 differ too much (>0.01deg), rock won't work well, sete should be used in this case
# 20130614, change threshold from 0.015 to 0.02
if abs(THETA1 - THETA2) > 0.02:
if abs(THETA1 + THETA2) > 0.02:
raise Exception("Two mono crystals are not synchronized, please use 'sete()'")
#
# check the flux
@@ -82,7 +82,7 @@ POSV = int(BPM1POSV * 1000)
if POSV <= -6 or POSV >= 6 :
print "Beam is not aligned at E-BOX BPM1"
print "lets fix it."
fbm()
#fbm()
time.sleep(2)
else :
print "Beam is aligned at E-BOX BPM1,"
+1 -1
View File
@@ -1,6 +1,6 @@
"""
Diode scan
"""
asd
#Execute the scan: 200 steps, a1 from 0 to 40
+8 -3
View File
@@ -163,11 +163,16 @@ def flux_diode():
"""
"""
run("flux_diode")
def sete(e, all=True, wavelengt=False):
def sete(e, all=True, wavelength=False):
run("sete", {"e":e, "all":all, "wavelength":wavelength})
def seteq(e):
def seteq(e):
run("seteq", {"e":e})
def check_rock():
run("check_rock")
import ch.psi.pshell.device.ReadonlyRegisterBase as ReadonlyRegisterBase
+2 -2
View File
@@ -38,10 +38,10 @@ def rock(axis = th1, tt = 0.2, seti0 = False, dx = None, noref = False):
br = mono_beam.read()
mono_beam_ref.write(br)
print 'rock_success new mono beam at ' + str(br) + ' at' + str(e) + ' keV'
return true
return True
else:
print 'fit failed - centering on maximum'
max_x= xdata[ydata.index(max(ydata))]
axis.move(max_x)
return false
return False
+4 -4
View File
@@ -37,14 +37,14 @@ act = 0
# do a setenergy to move theta 1 and 2 to calculated position in case they are not synchronized.
theta1 = th1.read() #TODO: setpoint?
etheta1 = a2e(abs(theta1),1,1,1,True)
etheta1 = a2e(abs(theta1),1,1,1,deg=True,ln=True)
theta2 = th2.read()
etheta2 = a2e(ABS(theta2),1,1,1,True)
etheta2 = a2e(abs(theta2),1,1,1,deg=True,ln=False)
if abs (etheta1-etheta2) > 0.01:
set_energy(e)
while abs(e-e0) > 3e-5/tan(angle(e, deg=False)): #TODO: deg==false? WHILE ABS(e-e0) GT 3e-5/TAN(ANGLE(e)) DO BEGIN
while abs(e-e0) > 3e-5/math.tan(angle(e, deg=False)): #TODO: deg==false? WHILE ABS(e-e0) GT 3e-5/TAN(ANGLE(e)) DO BEGIN
set_energy(e)
e0 = get_energy(False)
@@ -75,7 +75,7 @@ rock()
e0 = get_energy()
print e0
mono_energy.write(e0)
print caget(mono_energy.read())
print mono_energy.read()
caput(beam_err, 'Finito')
caput(beam_set, 'DONE')
+47 -46
View File
@@ -33,59 +33,60 @@ print "X06DA-ES-BPM1:POSV BEFORE" + str(eboxbpm0)
#--------------- setting theta 1, 2 --------------------
# adjust 'Retry deadband' to 0.0001 (from 0.00004) and 'Retries Max' to 1 (from 5)
caput(th1.channelName +'.RDBD',0.00001)
caput(th2.channelName +'.RDBD',0.00001)
caput(th1.channelName +'.RTRY',1)
caput(th2.channelName +'.RTRY',1)
try:
caput(th1.channelName +'.RDBD',0.00001)
caput(th2.channelName +'.RDBD',0.00001)
caput(th1.channelName +'.RTRY',1)
caput(th2.channelName +'.RTRY',1)
#in order to do a small energy change without rock,
# 1) move theta2 to calculated angle
# 2) move theta1 to exact amount as theta2 moved
#
while abs(e-e0) > (3e-5 / math.tan(angle(e, deg=False)))): #TODO: deg==false? WHILE ABS(e-e0) GT 3e-5/TAN(ANGLE(e)) DO BEGIN
t1v = th1.read() #TODO: setpoint?
t2v = th2.read()
t2s = angle(float(e),1,1,1)
dt2 = t2s-t2v
dt1 = -dt2
t1p = t1v+dt1
t2p = t2s # which is t2v+dt2
print 'set angles th1, th2, relative move dt1, dt2 ', t1p, t2p, dt1, dt2
th1.move(t1p)
th2.move(t2p)
eo=get_energy(False)
time.sleep(2.0)
Inow = mono_beam.read()
print e, Istart, Inow
#in order to do a small energy change without rock,
# 1) move theta2 to calculated angle
# 2) move theta1 to exact amount as theta2 moved
while (abs(e-e0) > (3e-5 / math.tan(angle(e, deg=False)))):
t1v = th1.read() #TODO: setpoint?
t2v = th2.read()
t2s = angle(float(e),1,1,1, deg=True)
dt2 = t2s-t2v
dt1 = -dt2
t1p = t1v+dt1
t2p = t2s # which is t2v+dt2
print 'set angles th1, th2, relative move dt1, dt2 ', t1p, t2p, dt1, dt2
th1.move(t1p)
th2.move(t2p)
e0=get_energy(False)
time.sleep(2.0)
Inow = mono_beam.read()
print e, Istart, Inow
# feedback at BPM5
eboxbpm = es_beam_posv.read()
while abs(eboxbpm-eboxbpm0) > 0.002:
if (eboxbpm-eboxbpm0) >0:
th1.moveRel(-0.00004)
else:
th1.moveRel(0.00004)
time.sleep(1.0)
eboxbpm = es_beam_posv.read()
# if BPM1:POSV is too off, stop it
if eboxbpm > 0.050:
raise Exception("BPM1:POSV is too off")
# put 'Retry deadband' to 0.00004 and 'Retries Max' to 5
# wait a bit until motor movement finished (of course, this won't work if move across large energy range. but who use seteq to do that.)
time.sleep(0.2)
# feedback at BPM5
eboxbpm = es_beam_posv.read()
while abs(eboxbpm-eboxbpm0) > 0.002:
if (eboxbpm-eboxbpm0) >0:
th1.moveRel(-0.00004)
else:
th1.moveRel(0.00004)
time.sleep(1.0)
eboxbpm = es_beam_posv.read()
# if BPM1:POSV is too off, stop it
if eboxbpm > 0.050:
raise Exception("BPM1:POSV is too off")
# put 'Retry deadband' to 0.00004 and 'Retries Max' to 5
# wait a bit until motor movement finished (of course, this won't work if move across large energy range. but who use seteq to do that.)
time.sleep(0.2)
caput(th1.channelName +'.RDBD',0.00004)
caput(th2.channelName +'.RDBD',0.00004)
caput(th1.channelName +'.RTRY',5)
caput(th2.channelName +'.RTRY',5)
finally:
caput(th1.channelName +'.RDBD',0.00004)
caput(th2.channelName +'.RDBD',0.00004)
caput(th1.channelName +'.RTRY',5)
caput(th2.channelName +'.RTRY',5)
e0 = get_energy()
print e0
mono_energy.write(e0)
print caget(mono_energy.read())
print mono_energy.read()
# release the token!