Hi all, I am getting close to getting a program scheduler (i.e. something that schedules a sequence of g-code programs) but could use a little help as far as how I go about sending a sequence of motion commands programmatically. A snippet of my first attempt is included at the bottom. I did not really expect it to work this way, but is a start as far as showing what the intended sequence is to be. It actually sort of works, in the sense that it does start the program, but skips all of the preceding commands, which I implemented here through MDI calls, before the actual call to run the program.
The basic sequence I am trying to execute is: 1> Load the specified program. 2> Enable machine coordinates 2a> Set MDI mode (for now) 3> If the zone (G54 - 59.3 coordinates) is zero then do a G0 move to the specified x, y and z coordinates, otherwise select the coordinate system specified based on 'zone'. 4> Set the feed and spindle overrides. 5> Move to the specified starting point (yes, I see I currently have that out of order for coordinate systems in item 3). 6> Enable part coordinates based on the positions in step 5. 7> Switch to auto mode and start the program. My first question is whether effectively doing MDI calls is the best way to do primarily the motion commands. And the second is, do I have to setup something like a state machine to wait for each of the commands to complete before issuing the next command. Any ideas on the best way to do this are appreciated. I have checked all of the code into trunk in the event anyone would like to take a look at it in its entirety. Thanks, Eric ------------>Code Snippet<-------------------------- if (sendProgramOpen(fileStr) != 0) { queueStatus = qsError; printf("Could not open program\n"); } sendMdi(); sendMdiCmd("G92.1\n"); if (q.front().getZone() != 0) { switch (q.front().getZone()) { case 1: sendMdiCmd("G54\n"); break; case 2: sendMdiCmd("G55\n"); break; case 3: sendMdiCmd("G56\n"); break; case 4: sendMdiCmd("G57\n"); break; case 5: sendMdiCmd("G58\n"); break; case 6: sendMdiCmd("G59\n"); break; case 7: sendMdiCmd("G59.1\n"); break; case 8: sendMdiCmd("G59.2\n"); break; case 9: sendMdiCmd("G59.3\n"); } } else { q.front().getOffsets(x, y, z); sendFeedOverride(((double) q.front().getFeedOverride()) / 100.0); sendSpindleOverride(((double) q.front().getSpindleOverride()) / 100.0); sprintf(cmd, "G0 X%f Y%f Z%f\n", x, y, z); sendMdiCmd(cmd); sendMdiCmd("G92 X0 Y0 Z0\n"); } if (sendTaskPlanInit() != 0) { queueStatus = qsError; printf("Could not send Task Plan Init\n"); } sendAuto(); if (sendProgramRun(0) != 0) { queueStatus = qsError; printf("Could not change state to run\n"); } ------------>End Code Snippet<---------------------- ------------------------------------------------------------------------------ This SF.net email is sponsored by: High Quality Requirements in a Collaborative Environment. Download a free trial of Rational Requirements Composer Now! http://p.sf.net/sfu/www-ibm-com _______________________________________________ Emc-developers mailing list Emc-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-developers