Files
sics/site_ansto/instrument/hipd/config/commands/commands.tcl
Douglas Clowes 81554ee0d7 Adjust motor oscillation and SetRadCol command
Count full cycles on motor oscillate
Add logging on motor oscillate
Add "motor oscillate start high/low" options
Remove SetRadCol offset because it is not needed
2014-07-03 12:12:52 +10:00

143 lines
2.8 KiB
Tcl

source $cfPath(commands)/commands_common.tcl
namespace eval motor {
# is_homing_list = comma separated list of motors which are safe to send "home"
variable is_homing_list ""
}
namespace eval ajscmds {
namespace export SetRadColl SimpleRun SimpleScan RadCollRun RadCollTimed RadCollScan
# SetRadColl
command SetRadColl {
float time
float range
} {
catch {
#ffr Changed 0.5 to 0.2 on 30/06/2014 because
# oct hits upper limit switch at about 1.27 degrees
# with new "oct oscillate" command.
#dcl Removed 0.2 because old osc limits it to +/-1.0
oct oscillate_low [expr -abs($range/2.0)]
oct oscillate_high [expr abs($range/2.0)]
set spd [expr 2.0*$range / $time]
oct maxretry 5
oct accel 0.25
oct speed 0.25
oct decel 0.25
drive oct [expr abs($range/2.0)]
oct speed $spd
oct accel [expr $spd*5]
oct decel [expr $spd*5]
oct maxretry 0
} msg
clientput $msg
}
# SimpleRun
command SimpleRun {
float=0:inf steptime
int=1:inf numsteps
} {
# RadCollOff
histmem mode time
histmem preset $steptime
newfile HISTOGRAM_XY
for {set i 0} {$i < $numsteps} {incr i} {
hmm countblock
save $i
}
}
# SimpleScan
command SimpleScan {
text=drivable motor
float start
float step
int=1:inf numsteps
float=0:inf steptime
} {
# RadCollOff
histmem mode time
histmem preset $steptime
newfile HISTOGRAM_XY
for {set i 0} {$i < $numsteps} {incr i} {
drive $motor [expr $i*$step+$start]
hmm countblock
save $i
}
}
# RadCollRun
command RadCollRun {
int=1:inf oscno
int=1:inf reps
} {
# RadCollOn $oscno
histmem mode unlimited
newfile HISTOGRAM_XY
for {set i 0} {$i < $reps} {incr i} {
oct oscillate_count $oscno
oct oscillate start
hmm countblock
save $i
}
# RadCollOff
}
# RadCollTimed
command RadCollTimed {
int=1:inf oscno
float=0:inf time
} {
RadCollOn $oscno
set tim1 [clock seconds]
histmem mode unlimited
newfile HISTOGRAM_XY
set bool 0
set i 0
set timsecs [expr $time*60]
while {$bool == 0} {
histmem start block
save $i
incr i
set tim2 [expr [clock seconds] - $tim1]
if {$tim2 > $timsecs} {set bool 1}
}
RadCollOff
}
# RadCollScan
command RadCollScan {
text=drivable motor
float start
float step
int=1:inf numsteps
int=1:inf oscno
} {
# RadCollOn $oscno
histmem mode unlimited
newfile HISTOGRAM_XY
for {set i 0} {$i < $numsteps} {incr i} {
drive $motor [expr $i*$step+$start]
oct oscillate_count $oscno
oct oscillate start
hmm countblock
save $i
}
# RadCollOff
}
}
namespace import ::ajscmds::*
publish SetRadColl user
publish SimpleRun user
publish SimpleScan user
publish RadCollRun user
publish RadCollTimed user
publish RadCollScan user
proc ::commands::isc_initialize {} {
::commands::ic_initialize
}