On 29 July 2010 16:32, Schooner <schoone...@tiscali.co.uk> wrote: > Below is my idea of how I could achieve the tool change with a component > and the associated .hal entries.
I have been thinking about this a bit, and your solution (not unexpectedly) differs from mine. One thing that I don't like about your approach is the usleep, I think it means that the component has to be userspace (which is probably perfectly OK for a toolchanger). Realtime HAL components probably need to run through to completion every time they are called. I would write it as a state machine with an internal flag (the state flag can even be a pin). This is off the top of my head (and I am not really a C-programmer) <pin definitions + headers + variables> switch (state) { case 0: if (toolchange) { state = 1; toolchange_finished = false; steps = tool_req - tool_sel; if (steps < 0) steps = steps + 8 ; pos_out = pos_in + scale1 * steps; } returrn; case 1: if (pos_out - pos_in < 0.001) { state = 3; pos_out = pos_out - scale2; } return; case 3: if (pos_out - pos_in < 0.001) { state = 0; toolchange_finished = true; } return; default: rtapi_print_msg(RTAPI_MSG_ERR, "Oh dear! /n"); } -- atp ------------------------------------------------------------------------------ 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