hipd/config/commands/commands.tcl
Added some of the procedures in extraconfig.tcl as "commands"

motors/sct_jogmotor_common.tcl
Added stop command.  Send SH, JG and BG commands on one line when jogging motor.

fakeDMC
dmc2280Server.tcl
mkSimAxes.tcl
simAxis.tcl
Added jog command.

exebuf.c
Batch file executor now sends a BATCHEND event when there is an AbortBatch interrupt.
This means we can now execute cleanup comands when a batch file terminates.

r2764 | ffr | 2009-01-23 16:06:03 +1100 (Fri, 23 Jan 2009) | 17 lines
This commit is contained in:
Ferdi Franceschini
2009-01-23 16:06:03 +11:00
committed by Douglas Clowes
parent fb817f2aa8
commit b134c901c5
6 changed files with 251 additions and 63 deletions

View File

@@ -1,8 +1,14 @@
# $Revision: 1.8 $
# $Date: 2008-05-30 00:26:54 $
# $Revision: 1.9 $
# $Date: 2009-01-23 05:06:03 $
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
# Last revision by: $Author: ffr $
proc sleep {mstime} {
set x 0
after $mstime {set x 1}
vwait x
}
# Requires a configuration array for each axis that you want to simulate.
# eg
#array set B [list AC 25000 TP 7827107 TD 25000 PA 25000 stepsperx 25000 cntsperx 8192 DC 25000 SP 25000]
@@ -30,10 +36,23 @@ proc dmset {cmd axis args} {
} else {
set val [evaluate $args]
}
if {[string first $cmd "PA SP AC DC"] != -1} {
uplevel #0 set ${axis}($cmd) $val;
} else {
uplevel #0 $cmd $axis $val;
set inst [string range $cmd 0 1]
switch $inst {
"PA" - "PR" {
uplevel #0 set ${axis}(MVTYPE) $inst
uplevel #0 set ${axis}($cmd) $val;
}
"JG" {
uplevel #0 set ${axis}(MVTYPE) $inst
uplevel #0 set ${axis}($cmd) $val;
# uplevel #0 set ${axis}(SP) $val;
}
"SP" - "AC" - "DC" {
uplevel #0 set ${axis}($cmd) $val;
}
default {
uplevel #0 $cmd $axis $val;
}
}
}
@@ -51,8 +70,12 @@ proc DP {axis val} {
proc TS {axis} {
uplevel #0 eval set ${axis}(TS)
}
proc ST {axis} {
uplevel #0 eval set ${axis}(ST) 1
proc ST {_axis} {
upvar #0 $_axis axis;
set axis(ST) 1
while {$axis(BG) == 1} {
sleep 1000
}
}
proc SH {args} {}
@@ -67,15 +90,24 @@ proc BG {_axis} {
set axis(BG) 1; # motor is moving
set axis(SC) 0; # motor is running
set timeStep 0.1; # seconds
set target $axis(PA);
set diff [expr $target - $axis(TD)];
set sign [expr ($axis(PA) - $axis(TD)) < 0 ? -1 : 1];
set step [expr $sign * $timeStep * $axis(SP) ];
if {[expr abs($diff) < abs($step)]} {
set step $diff;
set timeStep [expr abs($step / $axis(SP))];
set axis(ST) 0
switch $axis(MVTYPE) {
"PA" {
set target $axis(PA);
set diff [expr $target - $axis(TD)];
set sign [expr ($axis(PA) - $axis(TD)) < 0 ? -1 : 1];
set step [expr $sign * $timeStep * $axis(SP) ];
if {[expr abs($diff) < abs($step)]} {
set step $diff;
set timeStep [expr abs($step / $axis(SP))];
}
every [expr round($timeStep * 1000)] "nextstep $_axis $step target $_axis $target $step"
}
"JG" {
set step [expr $timeStep * $axis(JG) ];
every [expr round($timeStep * 1000)] "nextstep $_axis $step jogit"
}
}
every [expr round($timeStep * 1000)] "nextstep $_axis $step $target"
# set diff [expr $target - $axis(TD)];
# set mult [expr $axis(cntsperx).0/$axis(stepsperx)];
@@ -107,29 +139,66 @@ proc every {ms body} {
return;
}
proc nextstep {paxis step target} {
proc nextstep {paxis step args} {
upvar #0 $paxis axis;
set finished false
if {($axis(ATLIM) == "upper") && ($step > 0)} {
return 0
} elseif {($axis(ATLIM) == "lower") && ($step < 0)} {
return 0
}
set mult [expr double($axis(cntsperx))/$axis(stepsperx)];
set axis(TP) [expr int($step * $mult + $axis(TP))];
set TD_POS [expr int($axis(TD) + $step)];
set axis(TD) [expr int($TD_POS)];
set currPos [expr ($axis(TP) - $axis(ABSHOME))/abs(double($axis(cntsperx)))]
if {$axis(ST) == 1} {
set axis(TS) 44; # Stopped, limit switches open
set axis(BG) 0; # motor has stopped
set axis(ST) 0; # make sure stop flag is unset
set axis(SC) 4; # motor stopped by stop command (ST)
return 0;
} elseif {[expr abs($target - $axis(TD)) < abs($step)]} {
set diff [expr $target - $axis(TD)];
set axis(TP) [expr int(round($diff*$mult + $axis(TP)))];
set axis(TD) [expr int($target)];
set axis(ATLIM) false
set finished true
} elseif {$currPos >= $axis(UPLIM)} {
set axis(TS) 36; # Stopped on forward limit switch
set axis(BG) 0; # motor has stopped
set axis(ST) 0; # make sure stop flag is unset
set axis(SC) 2; # motor stopped by limit switch
set axis(ATLIM) upper
set finished true
} elseif {$currPos <= $axis(LOLIM)} {
set axis(TS) 40; # Stopped on reverse limit switch
set axis(BG) 0; # motor has stopped
set axis(ST) 0; # make sure stop flag is unset
set axis(SC) 3; # motor stopped by limit switch
set axis(ATLIM) lower
set finished true
} elseif {[eval $args]} {
# Stop if condition specified in "args" is met
# set diff [expr $target - $axis(TD)];
# set axis(TP) [expr int(round($diff*$mult + $axis(TP)))];
# set axis(TD) [expr int($target)];
set axis(TS) 44; # Stopped, limit switches open
set axis(BG) 0; # motor has stopped
set axis(ST) 0; # make sure stop flag is unset
set axis(SC) 1; # motor stopped at commanded position
return 0;
set axis(ATLIM) false
set finished true
} else {
return 1;
set finished false
}
if {$finished} {
set axis(MVTYPE) "unknown"
return 0
} else {
return 1
}
}
proc target {paxis target step} {
upvar #0 $paxis axis;
return [expr abs($target - $axis(TD)) < abs($step)]
}
proc jogit {} {
return false
}