I have added it here as it has been passed around between a few people on the email list and as such it needs to be included in the Wiki.
There have been some safety concerns regarding this change, but several people are using it. So as usual take safety precautions and keep you hand near the Estop button while testing this.
This is a modified manual tool change macro. If you are using an EMC release, this file goes in /usr/bin. Either rename the existing file or rename this one then change your hal file to suit. If you are using run-in-place it goes in emc2-trunk/bin. You may have to change the file's properties to make it executable.
When you hit a tool change you will get the manual tool change dialog as normal. Now however you can go back to Axis and jog, use the MDI etc. When you are finished go to the manual toolchange dialog and click on 'continue'. As I mentioned before it does not track the spindle and coolant. Your code also must not make any assumptions about the tool position after the tool change. You know the drill, from using Mach.
This is just a proof of concept and it has a number of known problems: It does not detect if you load a new g-code file while it is waiting for a tool change. Do not press the run button in Axis while the manual tool change dialog is showing. EMC won't close properly while the manual tool change dialog is showing (this bug also exists in the standard tool change macro).
import emc, hal import rs274.options iniFile = emc.ini(os.environ['INI_FILE_NAME']) emc.nmlfile = os.path.join(os.path.dirname(os.environ['INI_FILE_NAME']), iniFile.find("EMC", "NML_FILE"))
emcStat = emc.stat(); emcCmd = emc.command()
def do_change(n):
emcStat.poll() curLine = emcStat.current_line if n: message = _("Insert tool %d and click continue when ready") % n else: message = _("Remove the tool and click continue when ready") app.wm_withdraw() app.update() if curLine >=0: emcCmd.abort() h.changed = True app.tk.call("nf_dialog", ".tool_change", _("Tool change"), message, "info", 0, _("Continue")) if curLine >=0: emcCmd.mode(emc.MODE_AUTO) emcCmd.auto(emc.AUTO_RUN, curLine + 1) else: h.changed = True app.update()
h = hal.component("hal_manualtoolchange") h.newpin("number", hal.HAL_S32, hal.HAL_IN) h.newpin("change", hal.HAL_BIT, hal.HAL_IN) h.newpin("changed", hal.HAL_BIT, hal.HAL_OUT) h.ready()
import Tkinter, nf, rs274.options
app = Tkinter.Tk(className="AxisToolChanger?") app.wm_geometry("-60-60") app.wm_title(_("AXIS Manual Toolchanger")) rs274.options.install(app) nf.start(app); nf.makecommand(app, "_", _) app.wm_protocol("WM_DELETE_WINDOW", app.wm_withdraw) lab = Tkinter.Message(app, aspect=500, text = _(" This window is part of the AXIS manual toolchanger. It is safe to close
or iconify this window, or it will close automatically after a fewseconds.")) lab.pack()
def withdraw():
app.wm_withdraw() app.bind("<Expose>", lambda event: app.wm_withdraw())
app.after(10 * 1000, withdraw)
try:
while 1: change = h.change if change and not h.changed: do_change(h.number) elif not change: h.changed = False app.after(100) app.update()except KeyboardInterrupt?:
pass