This commit is contained in:
root
2018-06-18 16:44:57 +02:00
parent 7da4e32097
commit bd9eaaf4d2
12 changed files with 189 additions and 61 deletions

View File

@@ -6,17 +6,31 @@ run("Devices/Elements")
run("Devices/WireScanner")
run("Diagnostics/sig_process_wrapper")
ws_prefix = args[0] if is_panel else "S10DI01-DWSC010" #"S10CB07-DWSC440" #"SINDI01-DWSC090" \\
plt = args[1] if is_panel else plot(None, title = "Wire Scan Calibration")[0]
ws_wire = args[2] if is_panel else WireScanner.WireY2
cal_range = args[3] if is_panel else True
cal_gain = args[4] if is_panel else True
ws_blm = get_wire_scanners_blms(ws_prefix )[0]
#S10DI01-DBLM113:AL1-WS-PMT-GAIN
SATURATION = 19950 / 10
MIN_GAIN, MAX_GAIN = 0.5, 1.1
OPT_STEP = 0.01
OPT_STEP = 0.02
SCAN_RANGE_FACTOR = 6.0
def write_ws_gain(val):
set_setting(ws_blm + "GainWs" + ws_wire, val)
def read_ws_gain():
return get_setting(ws_blm + "GainWs" + ws_wire)
#2) Set the number of RF shots (N_shot) to be acquired during a single cycle WSC measurement (e.g.,N_shot=50)
n_shot = 200
@@ -29,7 +43,7 @@ rr = get_repetition_rate()
ws_speed = (x_max- x_min)*rr/n_shot
#5) Proceed with a test scan (1 cycle) according to the above defined motor settings
args = [ ws_prefix , WireScanner.WireX1, [x_min, x_max, x_min, x_max], 1, ws_speed, [], [ws_blm], 10, plt, False,1]
args = [ ws_prefix , ws_wire, [x_min, x_max, x_min, x_max], 1, ws_speed, [], [ws_blm], 10, plt, False,1]
ret = run("Diagnostics/WireScan", args)
[rms_com, rms_sigma, com, sigma, pos_path, path] = ret
@@ -42,8 +56,11 @@ start_blm_ws(ws_blm, 600.0)
#7) Move the wire to the X_CoM position and optimize the PMT-Gain so that the time-integral of the BLM voltage reaches a value equal to 90% of the Σsat level
offset = caget(ws_prefix + ":W1X_U0_SP")
motor_pos=offset - com * math.sqrt(2)
#offset = caget(ws_prefix + ":W1X_U0_SP")
#motor_pos=offset - com * math.sqrt(2)
ws_info = WireScanInfo("ws_info", ws_prefix )
motor_pos= ws_info.get_motor_pos(com, ws_wire)
caput(ws_prefix+":MOTOR_1.VAL", motor_pos) #DVAL?
#LOPR:0.5 HOPR:1.1
@@ -60,10 +77,11 @@ st.waitCacheChange(10000) #Wait stream be running before starting scan
def get_gain():
return caget(ws_blm + ":WS_PMT_GAIN_VOLTS")
return get_blm_ws_gain(ws_blm)
def set_gain(val):
caput(ws_blm + ":WS_PMT_GAIN_VOLTS", float(val))
set_blm_ws_gain(ws_blm,val)
def get_loss():
global ch
@@ -84,15 +102,28 @@ print "Start Gain = ", start_gain
print "Start Loss = ", start_val
print "Target = ", target
def set_bml_ws_gain(gain):
def change_blm_ws_gain(gain):
set_gain(gain)
stop_blm_ws(ws_blm)
st.getChild("blm1_ws_mode").waitValue(0, SET_BLM_WS_BS_READBACK_TIMEOUT)
start_blm_ws(ws_blm, 600.0)
st.getChild("blm1_ws_mode").waitValue(1, SET_BLM_WS_BS_READBACK_TIMEOUT)
time.sleep(0.1)
#Search loop
for pos in frange(MIN_GAIN, MAX_GAIN, OPT_STEP, True):
change_blm_ws_gain(pos)
loss = get_loss()
print "Pos = ", pos, " Loss = ", loss
if loss>=target:
break
stop_blm_ws(ws_blm)
"""
if start_val>target:
for pos in frange(start_gain, MIN_GAIN, -OPT_STEP, True):
set_bml_ws_gain(pos)
change_blm_ws_gain(pos)
loss = get_loss()
print "Pos = ", pos, " Loss = ", loss
if loss<=target:
@@ -101,13 +132,13 @@ if start_val>target:
elif start_val<target:
for pos in frange(start_gain, MAX_GAIN, OPT_STEP, True):
set_bml_ws_gain(pos)
change_blm_ws_gain(pos)
loss = get_loss()
print "Pos = ", pos, " Loss = ", loss
if loss>=target:
break
stop_blm_ws(ws_blm)
"""
print "Final Gain = ", pos
print "Final Loss = ", loss
@@ -116,18 +147,18 @@ print get_loss()
#set_gain(0.6)
#set_gain(0.5)
st.close()
write_ws_gain(pos)
#UPDATE X1 range
#WIRE = 1X, 2X, 1Y, 2Y
def set_wire_scan_range(wire, start, end):
sel = {'X1':"W1X" , 'Y1': "W1Y", 'X2':"W2X", 'Y2' : "W2Y"}
start = min (max(start, -2000), 2000.0)
end = min (max(end, -2000), 2000.0)
caput((ws_prefix + ":W" + wire +"_START_SP"), x_range_min)
caput((ws_prefix + ":W" + wire +"_END_SP"), x_range_max)
caput((ws_prefix + ":" + sel[wire] +"_START_SP"), x_range_min)
caput((ws_prefix + ":" + sel[wire] +"_END_SP"), x_range_max)
#caget(ws_blm+":SAT_RAW_SUM")
@@ -136,11 +167,9 @@ args = [ ws_prefix , WireScanner.WireX1, [x_min, x_max, x_min, x_max], 1, ws_spe
ret = run("Diagnostics/WireScan", args)
[rms_com, rms_sigma, com, sigma, pos_path, path] = ret
x_range_min, x_range_max = com - SCAN_RANGE_FACTOR * sigma, com + SCAN_RANGE_FACTOR * sigma
set_wire_scan_range("1X", x_range_min, x_range_max)
set_wire_scan_range(ws_wire, x_range_min, x_range_max)