Hi again I have spent a few days reading all the manuals etc and studying the various links you all passed on. I decided that Kirks solution of a component written in C was most viable for me.
In the interim I have written a G Code sub routine called m6 which does the tool change and I just have to do a M6Tx to get the tool number set correctly from the manual tool change module. Gets me by for now. Below is my idea of how I could achieve the tool change with a component and the associated .hal entries. Before I start trying to test it, I would be grateful if you could run an eye over it and tell me if I am going in the right direction. There could be an absolute howler in there and I currently am not far enough up the learning curve to know it. Also, does EMC or Axis store the current tool number somewhere that can be read or will I have to implement some sort of .conf file to hold that very necessary data? With no encoder etc, the whole operation hinges on knowing the start point. regards ArcEye /*************************************************************************************************** ## .hal entries loadusr -W hal_ATC net tool-change iocontrol.0.tool-change => hal_ATC.0.toolchange net tool-changed iocontrol.0.tool-changed <= hal_ATC.0.toolchanged net tool-number iocontrol.0.tool-prep-number => hal_ATC.0.toolnumber net move-to stepgen.3.position-cmd <= hal_ATC.0.steps # signal apos-fb already declared in .hal (net apos-fb stepgen.3.position-fb => axis.3.motor-pos-fb) net apos-fb => hal_ATC.0.stepstaken ## unless need a tool-prepare signal this always connects straight back to tool-prepared ## net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared ********************************************************************************************************/ /// ATC.comp component ATC "This component controls the Auto Tool Changer. M6 calls this via net tool-change iocontrol.0.tool-change => hal_ATC.0.toolchange"; pin in bit toolchange "Receives signal from M6 that tool change required"; pin in s32 toolnumber "Receives Tx data from M6 (tool number requested) Only allows 1-8"; pin in s32 stepstaken "Receives feedback from stepgen of position in commanded units"; pin out s32 steps "Sends number required, positive for forward and negative for backward, scale is 80 / mm on this setup"; pin out bit toolchanged "Sends signal when tool change finished"; param rw s32 currenttoolnumber "Holds current position - get from file?"; function _; license "GPL"; ;; FUNCTION(_) { int moves, index; bool bEven, bToggle; moves = index = 0; bEven = bToggle = false; //TODO get current tool number if(toolchange) // will receive input from stepgen.3.position-fb even when ATC jogged externally but no toolchange requested { if(toolnumber != currenttoolnumber && toolnumber > 0 && toolnumber < 9) // if a valid number { if(currenttoolnumber == 2 || currenttoolnumber == 4 || currenttoolnumber == 6 || currenttoolnumber == 8) bEven = true; if(currenttoolnumber < toolnumber) moves = toolnumber - currenttoolnumber; else moves = (8 - currenttoolnumber) + toolnumber; bToggle = bEven; while(index < moves) { if(bToggle) steps = (24 * 80); else steps = (22.2 * 80); index++; bToggle = !bToggle; while(steps > stepstaken) usleep(1000 * 1000); // wait for move to happen before next command } steps = (((moves / 2) + 1) * 80) * -1); // negative figure to lock back against pawl } toolchanged = 1; // signal finished } //TODO set new tool number } ------------------------------------------------------------------------------ The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm _______________________________________________ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users