Testing and utility scripts
- Subject: Testing and utility scripts
- From: Fred Proctor <frederick.proctor-at-nist.gov>
- Date: Fri, 22 Sep 2000 18:50:33 -0400
- Content-Transfer-Encoding: 7bit
- Content-Type: text/plain; charset=us-ascii
EMC folks,
One of the reasons we wrote a Tcl/Tk-based EMC shell (emcsh) was so that
we could write testing scripts. I envisioned a directory full of scripts
that I'd run each time we built a new release, which would test things
like incremental jogs working at the right speed, programs running
properly and finishing at about the right time and at the right end
position, etc. I also expected to write some utility scripts that you
could pull up from a scripts menu in the GUI, that would do things like
take the machine out of estop, turn servos on, home the axes, and put it
in auto mode with one click.
I wrote a script here for testing that I wanted to show as an example of
what can be done. It puts the machine in
estop-off/machine-on/manual-mode, and incrementally jogs the X, Y, and Z
axes, printing errors if any of them are greater than some delta from
the desired end position. It's appended here. You can use any of the
"emc_XXX" commands listed in emc/src/emctask/emcsh.cc, which are
peppered throughout the tkemc.tcl GUI script in the same directory.
--Fred
#!/bin/sh
# the next line restarts using emcsh \
exec plat/nonrealtime/bin/emcsh "$0" "$-at-"
# set the handshaking so that commands return when EMC finishes them,
# using 'done', rather than return when EMC gets them, using 'received'
emc_wait done
# take out of estop, if necessary
if {[emc_estop] != "off"} {
emc_estop off
}
# turn on, if necessary
if {[emc_machine] != "on"} {
emc_machine on
}
# put in manual mode, if necessary
if {[emc_mode] != "manual"} {
emc_mode manual
}
# set jog speed, increment for incremental jog tests
set jogspeed 60.0
set jogincr 0.1
# set error delta for acceptable increment
set jogdelta 0.005
# define an absolute value function
proc abs {val} {
if {$val < 0} {
return [expr - $val]
}
return $val
}
# incrementally jog each axis, record start and end pos, and print
# error if it's more than jogdelta from target end position
foreach axis {0 1 2} {
# record start position
set startpos [emc_abs_act_pos $axis]
# do the jog
emc_jog_incr $axis $jogspeed $jogincr
# it's done, record end position
set endpos [emc_abs_act_pos $axis]
# compute error from end position
set delta [abs [expr $endpos - $startpos - $jogincr]]
# flag error, if necessary
if {$delta > $jogdelta} {
puts stdout "***error: position error of $delta for axis $axis"
}
}
exit
Date Index |
Thread Index |
Back to archive index |
Back to Mailing List Page
Problems or questions? Contact