Incorporated in-situ modifications to Release 2.2

r2731 | ffr | 2008-11-03 19:59:56 +1100 (Mon, 03 Nov 2008) | 2 lines
This commit is contained in:
Ferdi Franceschini
2008-11-03 19:59:56 +11:00
committed by Douglas Clowes
parent c791fc65c7
commit 0c69a21706
7 changed files with 672 additions and 101 deletions

View File

@@ -0,0 +1,74 @@
# This must be loaded by motor_configuration.tcl
set ephi_Home 6647698
set echi_Home 8919294
set eom_Home 22960659
# Sample Tilt 1, euler omega stage
Motor eom $motor_driver_type [params \
asyncqueue mc2\
axis A\
units degrees\
hardlowerlim -45\
hardupperlim 60\
maxSpeed 1\
maxAccel 1\
maxDecel 1\
stepsPerX 25000\
absEnc 1\
absEncHome $eom_Home\
cntsPerX -8192]
setHomeandRange -motor eom -home 0 -lowrange 35 -uprange 55
eom speed 1
eom movecount $move_count
eom precision 0.01
eom part sample
eom long_name euler_omega
# Sample Tilt 2, euler chi stage
Motor echi $motor_driver_type [params \
asyncqueue mc2\
axis B\
units degrees\
hardlowerlim -20\
hardupperlim 95\
maxSpeed 1\
maxAccel 1\
maxDecel 1\
stepsPerX -25000\
absEnc 1\
absEncHome $echi_Home\
cntsPerX 8192]
setHomeandRange -motor echi -home 0 -lowrange 10 -uprange 95
echi softlowerlim -10
echi softupperlim 90
echi home 0
echi speed 1
echi movecount $move_count
echi precision 0.01
echi part sample
echi long_name euler_chi
# Sample Trans 1, upper, y
Motor ephi $motor_driver_type [params \
asyncqueue mc2\
axis C\
units degrees\
hardlowerlim -185\
hardupperlim 185\
maxSpeed 5\
maxAccel 5\
maxDecel 1\
stepsPerX -12500\
absEnc 1\
absEncHome $ephi_Home\
cntsPerX -4096]
setHomeandRange -motor ephi -home 0 -lowrange 180 -uprange 180
ephi softlowerlim -180
ephi softupperlim 180
ephi home 0
ephi speed 1
ephi movecount $move_count
ephi precision 0.01
ephi part sample
ephi long_name euler_phi

View File

@@ -32,16 +32,12 @@ if {$sim_mode == "true"} {
}
#Measured absolute encoder reading at home position
set mphi_Home 7613516
set mchi_Home 7503905
set my_Home 6767221
set mx_Home 7464891
set mom_Home 9274794
set mtth_Home 19927837
set sphi_Home 7937974
set schi_Home 7585956
set sy_Home 7557524
set sx_Home 7557304
set mphi_Home 7613516
set mchi_Home 7503905
set my_Home 6767221
set som_Home 17214054
set stth_Home 2896180
set oct_Home 7743768
@@ -103,6 +99,8 @@ set slit2HGroup second/horizontal
# hnotify messages to a reasonable level
set move_count 10
#fileeval $cfPath(motors)/tilt_configuration.tcl
fileeval $cfPath(motors)/euler_configuration.tcl
############################
# Motor Controller 1
# Motor Controller 1
@@ -123,7 +121,7 @@ Motor dummy_motor asim [params \
maxDecel 1\
stepsPerX -25000\
absEnc 1\
absEncHome $mphi_Home\
absEncHome 7613516\
cntsPerX -8192]
setHomeandRange -motor dummy_motor -home 0 -lowrange 169 -uprange 169
dummy_motor speed 1
@@ -276,98 +274,13 @@ mtth long_name takeoff_angle
# Motor Controller 2
# Motor Controller 2
############################
# Sample Tilt 1, upper, phi
Motor sphi $motor_driver_type [params \
asyncqueue mc2\
axis A\
units degrees\
hardlowerlim -15\
hardupperlim 15\
maxSpeed 1\
maxAccel 1\
maxDecel 1\
stepsPerX -25000\
absEnc 1\
absEncHome $sphi_Home\
cntsPerX -8192]
setHomeandRange -motor sphi -home 0 -lowrange 15 -uprange 15
sphi speed 1
sphi movecount $move_count
sphi precision 0.01
sphi part sample
sphi long_name phi
# Sample Tilt 2, lower, chi
Motor schi $motor_driver_type [params \
asyncqueue mc2\
axis B\
units degrees\
hardlowerlim 75\
hardupperlim 105\
maxSpeed 1\
maxAccel 1\
maxDecel 1\
stepsPerX 25000\
absEnc 1\
absEncHome $schi_Home\
cntsPerX 8192]
setHomeandRange -motor schi -home 90 -lowrange 15 -uprange 15
schi speed 1
schi movecount $move_count
schi precision 0.01
schi part sample
schi long_name chi
# Sample Trans 1, upper, y
Motor sy $motor_driver_type [params \
asyncqueue mc2\
axis C\
units mm\
hardlowerlim -20\
hardupperlim 20\
maxSpeed 1\
maxAccel 1\
maxDecel 1\
stepsPerX 25000\
absEnc 1\
absEncHome $sy_Home\
cntsPerX 8192]
setHomeandRange -motor sy -home 0 -lowrange 20 -uprange 20
sy speed 1
sy movecount $move_count
sy precision 0.01
sy part sample
sy long_name translate_y
# Sample Trans2, lower, x
Motor sx $motor_driver_type [params \
asyncqueue mc2\
axis D\
units mm\
hardlowerlim -20\
hardupperlim 20\
maxSpeed 1\
maxAccel 1\
maxDecel 1\
stepsPerX -25000\
absEnc 1\
absEncHome $sx_Home\
cntsPerX -8192]
setHomeandRange -motor sx -home 0 -lowrange 20 -uprange 20
sx speed 1
sx movecount $move_count
sx precision 0.01
sx part sample
sx long_name translate_x
# Sample Omega, rotate
Motor som $motor_driver_type [params \
asyncqueue mc2\
axis E\
units degrees\
hardlowerlim -110\
hardupperlim 110\
hardupperlim 160\
maxSpeed 1\
maxAccel 1\
maxDecel 1\

View File

@@ -0,0 +1,91 @@
# This must be loaded by motor_configuration.tcl
set sphi_Home 7937974
set schi_Home 7585956
set sy_Home 7557524
set sx_Home 7557304
# Sample Tilt 1, upper, phi
Motor sphi $motor_driver_type [params \
asyncqueue mc2\
axis A\
units degrees\
hardlowerlim -15\
hardupperlim 15\
maxSpeed 1\
maxAccel 1\
maxDecel 1\
stepsPerX -25000\
absEnc 1\
absEncHome $sphi_Home\
cntsPerX -8192]
setHomeandRange -motor sphi -home 0 -lowrange 15 -uprange 15
sphi speed 1
sphi movecount $move_count
sphi precision 0.01
sphi part sample
sphi long_name phi
# Sample Tilt 2, lower, chi
Motor schi $motor_driver_type [params \
asyncqueue mc2\
axis B\
units degrees\
hardlowerlim 75\
hardupperlim 105\
maxSpeed 1\
maxAccel 1\
maxDecel 1\
stepsPerX 25000\
absEnc 1\
absEncHome $schi_Home\
cntsPerX 8192]
setHomeandRange -motor schi -home 90 -lowrange 15 -uprange 15
schi speed 1
schi movecount $move_count
schi precision 0.01
schi part sample
schi long_name chi
# Sample Trans 1, upper, y
Motor sy $motor_driver_type [params \
asyncqueue mc2\
axis C\
units mm\
hardlowerlim -20\
hardupperlim 20\
maxSpeed 1\
maxAccel 1\
maxDecel 1\
stepsPerX 25000\
absEnc 1\
absEncHome $sy_Home\
cntsPerX 8192]
setHomeandRange -motor sy -home 0 -lowrange 20 -uprange 20
sy speed 1
sy movecount $move_count
sy precision 0.01
sy part sample
sy long_name translate_y
# Sample Trans2, lower, x
Motor sx $motor_driver_type [params \
asyncqueue mc2\
axis D\
units mm\
hardlowerlim -20\
hardupperlim 20\
maxSpeed 1\
maxAccel 1\
maxDecel 1\
stepsPerX -25000\
absEnc 1\
absEncHome $sx_Home\
cntsPerX -8192]
setHomeandRange -motor sx -home 0 -lowrange 20 -uprange 20
sx speed 1
sx movecount $move_count
sx precision 0.01
sx part sample
sx long_name translate_x

View File

@@ -13,6 +13,6 @@
for pcx forbid {80 130}
for pcr forbid {-inf inf} when mom in {45 50}
for stth forbid {160 167} when mtth in {87 88}
for stth forbid {0 15} when mtth in {139.5 140.5}
#for stth forbid {0 15} when mtth in {139.5 140.5}
for mtth forbid {87 100} when stth in {166 167}
for mtth forbid {130 140.5} when stth in {0 1}

View File

@@ -7,11 +7,14 @@ if {$::sim_mode == "true"} {
} else {
makeasyncqueue acq ORHVPS ca1-quokka 4001
evfactory new dhv1 orhvps acq
dhv1 lowerlimit 800
dhv1 lowerlimit 0
dhv1 upperlimit 2400
dhv1 tolerance 19
dhv1 max 2600
dhv1 rate 10
dhv1 debug 1
dhv1 unlock
dhv1 debug 0
# dhv1 lock
}

View File

@@ -0,0 +1,488 @@
# Ordela 21000N detector calibration
proc ord_get_pot { potxy potnumber } {
# NOTE: Contains reordering of lower 2 bits. Remove when device driver is fixed!!! (?)
for { set rsp "Bad" } { $rsp == "Bad" } { } {
set potname [ format "%s%d" $potxy [ expr $potnumber ^ 3 ] ]
set rspall [ dhv1 cmd P $potname ]
set rsp [lindex [split $rspall " "] 1]
}
return $rsp
}
Publish ord_get_pot User
proc ord_set_pot { potxy potnumber potvalue } {
# NOTE: Contains reordering of lower 2 bits. Remove when device driver is fixed!!! (?)
set potname [ format "%s%d" $potxy [ expr $potnumber ^ 3 ] ]
set rsp [ dhv1 cmd p $potname $potvalue ]
return $rsp
}
Publish ord_set_pot User
set ord_pot_all_x ""
Publish ord_pot_all_x User
set ord_pot_all_y ""
Publish ord_pot_all_y User
set ord_pot_all_xy ""
Publish ord_pot_all_xy User
proc ord_get_pot_all { } {
global ord_pot_all_x
global ord_pot_all_y
global ord_pot_all_xy
clientput " Reading Ordela 21000N pots, please wait..."
set ord_pot_all_x ""
set ord_pot_all_y ""
for { set ixy 0 } { $ixy <= 191 } { incr ixy } {
lappend ord_pot_all_x [ord_get_pot x $ixy]
lappend ord_pot_all_y [ord_get_pot y $ixy]
}
set ord_pot_all_xy [ format "%s\n%s\n" $ord_pot_all_x $ord_pot_all_y ]
clientput " All pots read. Current x and y pot settings are shown below:"
return $ord_pot_all_xy
}
Publish ord_get_pot_all User
proc ord_set_pot_all { } {
global ord_pot_all_x
global ord_pot_all_y
clientput " Writing Ordela 21000N pots, please wait..."
set rspx ""
for { set ixy 0 } { $ixy <= 191 } { incr ixy } {
lappend rspx [ord_set_pot x $ixy [lindex $ord_pot_all_x $ixy] ]
}
set rspy ""
for { set ixy 0 } { $ixy <= 191 } { incr ixy } {
lappend rspy [ord_set_pot y $ixy [lindex $ord_pot_all_y $ixy] ]
}
clientput " All pots written. x and y pot setting responses are shown below:"
set rsp [ format "%s\n%s\n" $rspx $rspy ]
return $rsp
}
Publish ord_set_pot_all User
proc ord_set_pot_all_const_range_x_y { xy ord_pot_all_x_y pot_l s_x_y pot_h } {
global $ord_pot_all_x_y
set $ord_pot_all_x_y ""
if { $s_x_y <= 0 } {
clientput " Applying constant value" $pot_h "to all" $xy "pots."
} elseif { $s_x_y >= 192 } {
clientput " Applying constant value" $pot_l "to all" $xy "pots."
} else {
clientput " Applying constant value" $pot_l "to" $xy "pots 0 to" [expr $s_x_y - 1] "and" $pot_h "to" $xy "pots" $s_x_y "to 191."
}
for { set ixy 0 } { $ixy <= 191 } { incr ixy } {
if { $ixy < $s_x_y } {
set pot_value_x_y $pot_l
} else {
set pot_value_x_y $pot_h
}
lappend $ord_pot_all_x_y $pot_value_x_y
}
}
proc ord_set_pot_all_const_range_xy { pot_l_x s_x pot_h_x pot_l_y s_y pot_h_y } {
global ord_pot_all_x
global ord_pot_all_y
ord_set_pot_all_const_range_x_y x ord_pot_all_x $pot_l_x $s_x $pot_h_x
ord_set_pot_all_const_range_x_y y ord_pot_all_y $pot_l_y $s_y $pot_h_y
clientput $ord_pot_all_x
clientput $ord_pot_all_y
}
Publish ord_set_pot_all_const_range_xy User
proc ord_set_pot_all_const_range { pot_l_x s_x pot_h_x pot_l_y s_y pot_h_y } {
ord_set_pot_all_const_range_xy $pot_l_x $s_x $pot_h_x $pot_l_y $s_y $pot_h_y
return [ord_set_pot_all]
}
Publish ord_set_pot_all_const_range User
proc ord_set_pot_all_const_xy { pot_value_x pot_value_y } {
ord_set_pot_all_const_range_xy $pot_value_x 0 $pot_value_x $pot_value_y 0 $pot_value_y
return [ord_set_pot_all]
}
Publish ord_set_pot_all_const_xy User
proc ord_set_pot_all_const { pot_value } {
ord_set_pot_all_const_range_xy $pot_value 0 $pot_value $pot_value 0 $pot_value
return [ord_set_pot_all]
}
Publish ord_set_pot_all_const User
proc ord_save_pot_all { filename } {
global ord_pot_all_xy
set fh [ open $filename w ]
puts $fh $ord_pot_all_xy
close $fh
clientput " All pot settings saved to file."
}
Publish ord_save_pot_all User
proc ord_load_pot_all { filename } {
global ord_pot_all_x
global ord_pot_all_y
global ord_pot_all_xy
set fh [ open $filename ]
gets $fh ord_pot_all_x
gets $fh ord_pot_all_y
set ord_pot_all_xy [ format "%s\n%s\n" $ord_pot_all_x $ord_pot_all_y ]
close $fh
clientput " All pot settings loaded from file."
clientput "x settings:" $ord_pot_all_x
clientput "y settings:" $ord_pot_all_y
}
Publish ord_load_pot_all User
set histogram_xy ""
set histogram_x ""
set histogram_y ""
# Calibration procedure should not include data from edges of the detector pattern in corresponding 2D histogram.
# The set values can be viewed/adjusted using the ord_get_cal_roi and ord_set_bs_pos functions provided below.
set roi_x_l 24
set roi_x_h 167
set roi_y_l 24
set roi_y_h 167
proc ord_get_histogram_xy { bs_x_l bs_x_h bs_y_l bs_y_h roi_x_l roi_x_h roi_y_l roi_y_h } {
# Use data from within the x,y ROI (inclusive) to calculate 2D histograms.
# Excludes the beamstop region from the histogram calculations.
# Note the ROI and beamstop coords are in terms of histogram server coord system
# but the result x and y histograms are in detector coordinate system (match pot order).
# Also note that when calculating the x and y 1D histogram, it includes data from the y or x ROI respectively
# and excludes data from the BS region. (i.e. x histogram is computed by summing in y across the y ROI,
# but excludes the portion of y occupied by the beamstop). The calculation is done in this way so that
# the result is as uniform as possible in x and y.
global histogram_xy
global histogram_x
global histogram_y
clientput "Retrieving 2D xy histogram..."
set histogram_xy [ lreplace [ split [ hmm get 1 ] ] 0 1 ]
if { ($bs_x_l > $bs_x_h || $bs_y_l > $bs_y_h) && $roi_x_l == 0 && $roi_x_h == 191 && $roi_y_l == 0 && $roi_y_h == 191 } {
set get_full_histogram 1
clientput "Calculating 2D histograms over full detector area..."
set bs_x_l 1
set bs_x_h 0
set bs_y_l 1
set bs_y_h 0
} else {
set get_full_histogram 0
clientput "Calculating 2D histograms excluding beamstop area x =" $bs_x_l "to" $bs_x_h "and y =" $bs_y_l "to" $bs_y_h "..."
clientput "Histograms ROI is x =" $roi_x_l "to" $roi_x_h "(for y histogram) and y =" $roi_y_l "to" $roi_y_h "(for x histogram)."
}
set histogram_memory_x ""
set histogram_memory_y ""
for { set ia 0 } { $ia <= 191 } { incr ia } {
set sum_x 0
set sum_y 0
# NOTE: In the sum loops below, do NOT include the edges! Too unreliable. Sum in the ROI only instead.
for { set ib $roi_x_l } { $ib < $bs_x_l } { incr ib } {
set sum_x [expr $sum_x + [lindex $histogram_xy [expr $ib + $ia * 192] ]]
}
for { set ib [expr $bs_x_h + 1] } { $ib <= $roi_x_h } { incr ib } {
set sum_x [expr $sum_x + [lindex $histogram_xy [expr $ib + $ia * 192] ]]
}
for { set ib $roi_y_l } { $ib < $bs_y_l } { incr ib } {
set sum_y [expr $sum_y + [lindex $histogram_xy [expr $ia + $ib * 192] ]]
}
for { set ib [expr $bs_y_h + 1] } { $ib <= $roi_y_h } { incr ib } {
set sum_y [expr $sum_y + [lindex $histogram_xy [expr $ia + $ib * 192] ]]
}
lappend histogram_memory_x $sum_y
lappend histogram_memory_y $sum_x
}
#
# If x and y need to be swapped or reordered, do it in the loop below.
# (histo server raw data x,y order matches pot order)
set histogram_x ""
set histogram_y ""
for { set ixy 0 } { $ixy <= 191 } { incr ixy } {
lappend histogram_x [lindex $histogram_memory_y [expr $ixy]]
lappend histogram_y [lindex $histogram_memory_x [expr 191 - $ixy]]
}
#
#
if { $get_full_histogram == 1 } {
clientput "Calculated x and y histograms over entire detector area. Data:"
} else {
clientput "Calculated x and y histograms for ROI, excluding beamstop area. Data:"
}
set rsp [ format "%s\n%s\n" $histogram_x $histogram_y ]
return $rsp
}
Publish ord_get_histogram_xy User
# Beamstop and spill nominally occupies the center 1/4 of the detector pattern.
# The set values can be viewed/adjusted using the ord_get_bs_pos and ord_set_bs_pos functions provided below.
set bss_x_l 72
set bss_x_h 120
set bss_y_l 72
set bss_y_h 120
proc ord_get_bs_pos { } {
global bss_x_l
global bss_x_h
global bss_y_l
global bss_y_h
clientput "The current beamstop position settings (in histogram server xy coordinates) are: xl =" $bss_x_l "xh =" $bss_x_h$
}
Publish ord_get_bs_pos User
proc ord_set_bs_pos { bss_x_l_new bss_x_h_new bss_y_l_new bss_y_h_new } {
global bss_x_l
global bss_x_h
global bss_y_l
global bss_y_h
set bss_x_l $bss_x_l_new
set bss_x_h $bss_x_h_new
set bss_y_l $bss_y_l_new
set bss_y_h $bss_y_h_new
return [ord_get_bs_pos]
}
Publish ord_set_bs_pos User
# Calibration procedure should not include data from edges of the detector pattern in corresponding 2D histogram.
# The set values can be viewed/adjusted using the ord_get_cal_roi and ord_set_bs_pos functions provided below.
set roi_x_l 24
set roi_x_h 167
set roi_y_l 24
set roi_y_h 167
proc ord_get_roi_pos { } {
global roi_x_l
global roi_x_h
global roi_y_l
global roi_y_h
clientput "The current histogram ROI settings (in histogram server xy coordinates) are: xl =" $roi_x_l "xh =" $roi_x_h "yl =" $roi_y_l "yh =" $roi_y_h
}
Publish ord_get_roi_pos User
proc ord_set_roi_pos { roi_x_l_new roi_x_h_new roi_y_l_new roi_y_h_new } {
global roi_x_l
global roi_x_h
global roi_y_l
global roi_y_h
set roi_x_l $roi_x_l_new
set roi_x_h $roi_x_h_new
set roi_y_l $roi_y_l_new
set roi_y_h $roi_y_h_new
return [ord_get_roi_pos]
}
Publish ord_set_roi_pos User
proc ord_get_histogram_xy_bs { } {
global bss_x_l
global bss_x_h
global bss_y_l
global bss_y_h
global roi_x_l
global roi_x_h
global roi_y_l
global roi_y_h
return [ ord_get_histogram_xy $bss_x_l $bss_x_h $bss_y_l $bss_y_h $roi_x_l $roi_x_h $roi_y_l $roi_y_h ]
}
Publish ord_get_histogram_xy_bs User
proc ord_get_histogram_xy_all { } {
return [ ord_get_histogram_xy 1 0 1 0 0 191 0 191 ]
}
Publish ord_get_histogram_xy_all User
set histogram_min_x ""
set histogram_min_y ""
set histogram_max_x ""
set histogram_max_y ""
set histogram_mean_x ""
set histogram_mean_y ""
proc ord_calc_hist_mmm_xy { } {
# Calculates min, max and mean of histogram values.
# NOTE: Because of edge effects in the detector, three of the edges return
# very high or low values. In order to stop these from dragging the mean
# high or low, they are excluded from the min/max/mean calculation entirely.
global histogram_x
global histogram_y
global histogram_min_x
global histogram_min_y
global histogram_max_x
global histogram_max_y
global histogram_mean_x
global histogram_mean_y
global bss_x_l
global bss_x_h
global bss_y_l
global bss_y_h
# NOTE: Ignore the edges entirely, as they are not reliable.
set histogram_mean_x 0
set histogram_mean_y 0
for { set ixy 1 } { $ixy <= 190 } { incr ixy } {
set histogram_x_val [lindex $histogram_x $ixy]
set histogram_y_val [lindex $histogram_y $ixy]
if { $ixy == 1 } { # NOTE edge at 0 is ignored
set histogram_min_x $histogram_x_val
set histogram_min_y $histogram_y_val
set histogram_max_x $histogram_x_val
set histogram_max_y $histogram_y_val
} else {
if {$histogram_x_val < $histogram_min_x } {
set histogram_min_x $histogram_x_val
}
if {$histogram_y_val < $histogram_min_y } {
set histogram_min_y $histogram_y_val
}
if {$histogram_x_val > $histogram_max_x } {
set histogram_max_x $histogram_x_val
}
if {$histogram_y_val > $histogram_max_y } {
set histogram_max_y $histogram_y_val
}
}
set histogram_mean_x [expr $histogram_mean_x + $histogram_x_val ]
set histogram_mean_y [expr $histogram_mean_y + $histogram_y_val ]
}
# NOTE beamstop region and edges are not included.
# ALSO NOTE we sum x histo over y, but x and y are transposed when the histo is retrieved,
# so we divide x histo values by span_x and y by span_y!
# set span_x [expr 190 - ( $bss_x_h - $bss_x_l ) ]
# set span_y [expr 190 - ( $bss_y_h - $bss_y_l ) ]
# if { $bss_x_l == 0 } { incr span_x }
# if { $bss_x_h == 191 } { incr span_x }
# if { $bss_y_l == 0 } { incr span_y }
# if { $bss_y_h == 191 } { incr span_y }
set span_x 190
set span_y 190
set histogram_mean_x [expr double($histogram_mean_x) / double($span_x) ]
set histogram_mean_y [expr double($histogram_mean_y) / double($span_y) ]
clientput "Calculated histogram means: mx =" $histogram_mean_x "and my =" $histogram_mean_y "(should be
roughly equal if bs window is square)."
}
Publish ord_calc_hist_mmm_xy User
proc ord_calc_pot { pot_in histogram_value histogram_mean CP_divider add_deviation } {
set CP 0.25
set histogram_deviation [expr double($histogram_value) / double($histogram_mean) - 1.]
set pot_out [ expr double($pot_in) - $histogram_deviation * $CP * 100. / $CP_divider ]
set pot_out [ expr int($pot_out + double($add_deviation) + 0.5) ]
if { $pot_out < 0 } {
set pot_out 0
} elseif { $pot_out > 63 } {
set pot_out 63
}
return $pot_out
}
Publish ord_calc_pot User
proc ord_calc_pot_all_xy { CP_divider desiredpotsmidrange_x desiredpotsmidrange_y } {
global histogram_x
global histogram_y
global histogram_mean_x
global histogram_mean_y
global ord_pot_all_x
global ord_pot_all_y
clientput "Calculating new pot settings based on old pot settings and histogram data..."
set ord_pot_all_x_new ""
set ord_pot_all_y_new ""
set ord_pot_dev_av_x 0
set ord_pot_dev_av_y 0
set ord_pot_dev_max_x 0
set ord_pot_dev_max_y 0
# Find current mean pot values. Do NOT include the edge pots.
set ord_pot_mean_x 0
set ord_pot_mean_y 0
for { set ixy 1 } { $ixy <= 190 } { incr ixy } {
set ord_pot_mean_x [expr $ord_pot_mean_x + [lindex $ord_pot_all_x $ixy]]
set ord_pot_mean_y [expr $ord_pot_mean_y + [lindex $ord_pot_all_y $ixy]]
}
set ord_pot_mean_x [expr double($ord_pot_mean_x) / 190.]
set ord_pot_mean_y [expr double($ord_pot_mean_y) / 190.]
# Calculate additional deviation to apply during new pot value calculation,
# to keep pot average close to desired mid range.
set ord_pot_add_dev_x [expr double($desiredpotsmidrange_x) - $ord_pot_mean_x]
set ord_pot_add_dev_y [expr double($desiredpotsmidrange_y) - $ord_pot_mean_y]
# Find all new pot values.
for { set ixy 0 } { $ixy <= 191 } { incr ixy } {
# clientput "Index" $ixy "x pot value" [lindex $ord_pot_all_x $ixy]
# clientput "Index" $ixy "histogram x value" [lindex $histogram_x $ixy]
# clientput "Index" $ixy "x pot value" $histogram_mean_x
# clientput "Index" $ixy "y pot value" [lindex $ord_pot_all_y $ixy]
# clientput "Index" $ixy "histogram y value" [lindex $histogram_y $ixy]
# clientput "Index" $ixy "y pot value" $histogram_mean_y
set ord_pot_old_x [lindex $ord_pot_all_x $ixy]
set ord_pot_old_y [lindex $ord_pot_all_y $ixy]
set ord_pot_new_x [ ord_calc_pot $ord_pot_old_x [lindex $histogram_x $ixy] $histogram_mean_x $CP_divider $ord_pot_add_dev_x ]
set ord_pot_new_y [ ord_calc_pot $ord_pot_old_y [lindex $histogram_y $ixy] $histogram_mean_y $CP_divider $ord_pot_add_dev_y ]
lappend ord_pot_all_x_new $ord_pot_new_x
lappend ord_pot_all_y_new $ord_pot_new_y
# Also get some stats on deviations (just take this as absolute)
set ord_pot_dev_x [ expr abs ( $ord_pot_new_x - $ord_pot_old_x ) ]
set ord_pot_dev_y [ expr abs ( $ord_pot_new_y - $ord_pot_old_y ) ]
set ord_pot_dev_av_x [ expr $ord_pot_dev_av_x + $ord_pot_dev_x ]
set ord_pot_dev_av_y [ expr $ord_pot_dev_av_y + $ord_pot_dev_y ]
if { $ord_pot_dev_x > $ord_pot_dev_max_x } {
set ord_pot_dev_max_x $ord_pot_dev_x
}
if { $ord_pot_dev_y > $ord_pot_dev_max_y } {
set ord_pot_dev_max_y $ord_pot_dev_y
}
}
set ord_pot_dev_av_x [ expr $ord_pot_dev_av_x / 192. ]
set ord_pot_dev_av_y [ expr $ord_pot_dev_av_y / 192. ]
clientput "Average deviations: x =" $ord_pot_dev_av_x "and y =" $ord_pot_dev_av_y
clientput "Maximum deviations: x =" $ord_pot_dev_max_x "and y =" $ord_pot_dev_max_y
#
set ord_pot_all_x $ord_pot_all_x_new
set ord_pot_all_y $ord_pot_all_y_new
set ord_pot_all_xy [ format "%s\n%s\n" $ord_pot_all_x $ord_pot_all_y ]
return $ord_pot_all_xy
}
Publish ord_calc_pot_all_xy User
proc ord_calibrate_iterate { CP_divider desiredpotsmidrange_x desiredpotsmidrange_y iteration } {
# For this to work we must first read pot values and the x and y histograms.
# Note the beamstop location is hard coded - position detector so that beamstop image is in the specified range
clientput [ord_get_histogram_xy_bs]
clientput [ord_calc_hist_mmm_xy]
# if { $iteration == 1 } {
# clientput [ord_get_pot_all] ## while iterating, the pot values are in the memory anyway so don't read
# }
clientput [ord_calc_pot_all_xy $CP_divider $desiredpotsmidrange_x $desiredpotsmidrange_y]
clientput [ord_set_pot_all]
}
proc ord_calibrate { CP_divider desiredpotsmidrange_x desiredpotsmidrange_y } {
clientput [ord_get_pot_all]
ord_calibrate_iterate $CP_divider $desiredpotsmidrange_x $desiredpotsmidrange_y 1
}
Publish ord_calibrate User
proc ord_calibrate_auto { CP_divider desiredpotsmidrange_x desiredpotsmidrange_y resetallpotsmidrange iterations acqtime } {
#
if { $resetallpotsmidrange == 1 } {
clientput [ord_set_pot_all_const $desiredpotsmidrange_x $desiredpotsmidrange_y ]
} else {
clientput [ord_get_pot_all]
}
#
for { set iteration 1 } { $iteration <= $iterations } { incr iteration } {
clientput "*** Commencing detector calibration iteration" $iteration
# NOTE: Assumes the histogram memory is set up in its DEFAULT state
# (that which SICS configures, but perhaps including HISTOGRAM_TRANSPOSE_RAW_XY=ENABLE).
# At 9/08 the configuration is HISTOGRAM_TRANSPOSE_RAW_XY=ENABLE, X OAT flipped, Y OAT non-flipped.
# Modify ordering in the ord_get_histogram_xy routine as needed.
# Alternately reconfigure transpose and OAT flipping here, so we get what we expect...
# (but this might not get put back by SICS so it's better not to)
# dhv1 cmd d # Diagnostic mode - CD turned off
histmem stop
histmem mode time
histmem preset $acqtime
histmem pause # NOTE - start in paused mode - server sends reset to Ordela first
# dhv1 cmd d # Place in diagnostic mode - will stay in this mode since reset won't occur on start, from paused
clientput [histmem start block]
# wait $acqtime # Can't figure out how to make histmem block, so just wait
clientput [histmem stop]
# dhv1 cmd n # Normal mode - CD turned back on
clientput [ord_calibrate_iterate $CP_divider $desiredpotsmidrange_x $desiredpotsmidrange_y $iteration ]
clientput "*** Detector calibration iteration" $iteration "completed."
}
}
Publish ord_calibrate_auto User

View File

@@ -1,5 +1,5 @@
# $Revision: 1.25 $
# $Date: 2008-10-31 04:37:31 $
# $Revision: 1.26 $
# $Date: 2008-11-03 08:59:56 $
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
# Last revision by: $Author: ffr $
@@ -277,9 +277,9 @@ Motor samx $motor_driver_type [params \
units mm\
hardlowerlim -500\
hardupperlim 500\
maxSpeed 1\
maxAccel 5\
maxDecel 5\
maxSpeed 10\
maxAccel 10\
maxDecel 10\
stepsPerX [expr 25000.0/5.0]\
absEnc 1\
absEncHome $samx_Home\
@@ -385,10 +385,12 @@ Motor det $motor_driver_type [params \
cntsPerX $det_CntsPerX]
det part detector
det long_name detector_y
det precision 1
det softlowerlim 400
det softupperlim 18900
det home 350.5
det speed 20
det Blockage_Fail 0
# Detector translation across beam [-50,450] mm
# Looks like an non-metric screw pitch 0.2 inches / turn