init setup pelican config
r3300 | jgn | 2011-12-01 09:48:53 +1100 (Thu, 01 Dec 2011) | 1 line
This commit is contained in:
committed by
Douglas Clowes
parent
ec7389b6fd
commit
01f84254e4
@@ -5,100 +5,118 @@
|
||||
#
|
||||
# Date: 11/11/2011
|
||||
|
||||
# get a specified parameter value of a motor
|
||||
proc getSetting {mot field} {
|
||||
|
||||
# DriveMono: drive the 3 Monochromators to translating as a "bunch"
|
||||
switch $field {
|
||||
"position" {
|
||||
set tmpStr1 [$mot]
|
||||
set tmpStr2 [split $tmpStr1 "="]
|
||||
array set tmpstr3 $tmpStr2
|
||||
set ind "$mot "
|
||||
return $tmpstr3($ind)
|
||||
}
|
||||
"softlowerlim" {
|
||||
set tmpStr1 [$mot softlowerlim]
|
||||
set tmpStr2 [split $tmpStr1 "="]
|
||||
array set tmpstr3 $tmpStr2
|
||||
set ind "$mot.softlowerlim "
|
||||
return $tmpstr3($ind)
|
||||
}
|
||||
"softupperlim" {
|
||||
set tmpStr1 [$mot softupperlim]
|
||||
set tmpStr2 [split $tmpStr1 "="]
|
||||
array set tmpstr3 $tmpStr2
|
||||
set ind "$mot.softupperlim "
|
||||
return $tmpstr3($ind)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
proc DriveMono {motor pos angle} {
|
||||
histmem stop
|
||||
bat_table -set NO_BAT_ENTRIES $framenum NO_BAT_PERIODS $framenum
|
||||
bat_table -set NO_REPEAT_ENTRY 1 NO_REPEAT_TABLE 1 NO_EXECUTE_TABLE 1 PERIOD_INDICES { 0 1 }
|
||||
fat_table -set NOS_PERIODS $framenum
|
||||
oat_table -set T {0 2200000} NTC 1
|
||||
histmem loadconf
|
||||
histmem fsrce EXTERNAL
|
||||
|
||||
# DriveMono: drive the 3 Monochromators to translate as a "bunch"
|
||||
proc DriveMono {mot focus} {
|
||||
variable currAngleMoma
|
||||
variable currAngleMomb
|
||||
variable currAngleMomc
|
||||
|
||||
variable mraPosition
|
||||
variable mraSoftlowerlim
|
||||
variable mraSoftupperlim
|
||||
variable mrbPosition
|
||||
variable mrbSoftlowerlim
|
||||
variable mrbSoftupperlim
|
||||
variable mrcPosition
|
||||
variable mrcSoftlowerlim
|
||||
variable mrcSoftupperlim
|
||||
|
||||
variable translateDis
|
||||
|
||||
variable moveFlag
|
||||
|
||||
# set moveFlag to 1 to move the three motors
|
||||
set moveFlag 1
|
||||
|
||||
# Record current angle positions of the three motors
|
||||
set currAngleMoma [getSetting moma position]
|
||||
set currAngleMomb [getSetting momb position]
|
||||
set currAngleMomc [getSetting momc position]
|
||||
|
||||
# Get current focus positions of the three motors mra, mrb and mrc
|
||||
set mraPosition [getSetting mra position]
|
||||
set mrbPosition [getSetting mrb position]
|
||||
set mrcPosition [getSetting mrc position]
|
||||
|
||||
# Get soft lower/upper limits of mra, mrb and mrc
|
||||
set mraSoftlowerlim [getSetting mra softlowerlim]
|
||||
set mraSoftupperlim [getSetting mra softupperlim]
|
||||
set mrbSoftlowerlim [getSetting mrb softlowerlim]
|
||||
set mrbSoftupperlim [getSetting mrb softupperlim]
|
||||
set mrcSoftlowerlim [getSetting mrc softlowerlim]
|
||||
set mrcSoftupperlim [getSetting mrc softupperlim]
|
||||
|
||||
# Calculate moving distance
|
||||
set translateDis [expr $focus - [getSetting $mot position]]
|
||||
|
||||
# Determine if the movement is within the ranges of the three motors
|
||||
if {[expr $mraPosition + $translateDis] > $mraSoftupperlim ||
|
||||
[expr $mraPosition + $translateDis] < $mraSoftlowerlim} {
|
||||
broadcast "Error: the movement is out of the range limit of motor mra"
|
||||
set moveFlag 0
|
||||
}
|
||||
|
||||
if {[expr $mrbPosition + $translateDis] > $mrbSoftupperlim ||
|
||||
[expr $mrbPosition + $translateDis] < $mrbSoftlowerlim} {
|
||||
broadcast "Error: the movement is out of the range limit of motor mrb"
|
||||
set moveFlag 0
|
||||
}
|
||||
|
||||
if {[expr $mrcPosition + $translateDis] > $mrcSoftupperlim ||
|
||||
[expr $mrcPosition + $translateDis] < $mrcSoftlowerlim} {
|
||||
broadcast "Error: the movement is out of the range limit of motor mrc"
|
||||
set moveFlag 0
|
||||
}
|
||||
|
||||
# move the three motors
|
||||
if {$moveFlag == 1} {
|
||||
# Unlock the three motors
|
||||
mra fixed -1
|
||||
mrb fixed -1
|
||||
mrc fixed -1
|
||||
|
||||
drive momb $currAngleMoma momc $currAngleMoma
|
||||
drive mra [expr $mraPosition + $translateDis]
|
||||
drive mrb [expr $mrbPosition + $translateDis]
|
||||
drive mrc [expr $mrcPosition + $translateDis]
|
||||
drive momb $currAngleMomb momc $currAngleMomc
|
||||
|
||||
# Lock the three motors again
|
||||
mra fixed 1
|
||||
mrb fixed 1
|
||||
mrc fixed 1
|
||||
}
|
||||
}
|
||||
|
||||
publish DriveMono user
|
||||
|
||||
# SetHistoNormal: resets the histo for standard operation
|
||||
|
||||
proc SetHistoNormal {} {
|
||||
histmem stop
|
||||
bat_table -set NO_BAT_ENTRIES 1 NO_BAT_PERIODS 1
|
||||
bat_table -set NO_REPEAT_ENTRY 0 NO_REPEAT_TABLE 0 NO_EXECUTE_TABLE 0 PERIOD_INDICES { 0}
|
||||
fat_table -set NOS_PERIODS 1
|
||||
oat_table -set T {0 2200000} NTC 1
|
||||
histmem loadconf
|
||||
histmem fsrce INTERNAL
|
||||
proc ::histogram_memory::pre_count {} {}
|
||||
}
|
||||
|
||||
# continous scan for EPHI- the euler cradle phi stage (innermost axis)
|
||||
# note make sure controller 2 has the PHISCAN code in it
|
||||
|
||||
publish SetHistoNormal user
|
||||
|
||||
|
||||
proc EphiCtsScan {start step range steptime} {
|
||||
|
||||
# magic number: steps per rotation for phi
|
||||
set ephisteps -12500
|
||||
set ephispeed [expr {($step*1.0)/$steptime}]
|
||||
set numsteps [expr {round($range/$step)}]
|
||||
# broadcast $omspeed $numsteps
|
||||
|
||||
# run ephi to start angle -1 so that first pulse signals as ephi crosses 0 angle
|
||||
# at correct velocity
|
||||
ephi accel 1
|
||||
ephi decel 1
|
||||
ephi speed 3
|
||||
drive ephi [expr {$start-1}]
|
||||
ephi speed $ephispeed
|
||||
ephi accel [expr {$ephispeed*1.2}]
|
||||
|
||||
# now set ephi parameters to galil and clear the bit
|
||||
|
||||
set scval [expr {($range+2.2)*$ephisteps}]
|
||||
set stval [expr {$ephisteps * $step}]
|
||||
broadcast $scval $stval
|
||||
som send CTLEN=$scval
|
||||
som send CTSTEP=$stval
|
||||
# som send OMN = [expr {$numsteps+1}]
|
||||
som send CB5
|
||||
|
||||
proc ::histogram_memory::pre_count {} {
|
||||
ephi send "XQ #EPHSCAN,2"
|
||||
}
|
||||
|
||||
histmem mode unlimited
|
||||
histmem start block
|
||||
|
||||
newfile HISTOPERIOD_XY
|
||||
for {set i 0} {$i<$numsteps} {incr i} {save $i}
|
||||
ephi speed 1
|
||||
|
||||
|
||||
# this we needed when it didn't work properly
|
||||
# proc ::histogram_memory::pre_count {} {}
|
||||
# ephi send SHC
|
||||
# ephi send SPC=25000
|
||||
# ephi send BCG
|
||||
# wait 3
|
||||
# ephi send "XQ #THREAD0,0"
|
||||
# wait 3
|
||||
# ephi reset
|
||||
}
|
||||
publish EphiCtsScan user
|
||||
|
||||
proc EulerCtsScan {range step steptime} {
|
||||
set numsteps [expr {round($range/$step)}]
|
||||
SetHistoSync $numsteps
|
||||
foreach chi {0 15 30 45 60 75 90} {
|
||||
drive echi $chi
|
||||
EphiCtsScan [expr {-$range/2}] $step $range $steptime
|
||||
}
|
||||
# SetHistoNormal
|
||||
}
|
||||
|
||||
publish EulerCtsScan user
|
||||
|
||||
|
||||
Reference in New Issue
Block a user