Re: [Emc-developers] Programatically sending a sequence of motion commands

2009-04-08 Thread Chris Radek
On Wed, Apr 08, 2009 at 10:17:39PM -0400, Eric H. Johnson wrote:
> Hi all,
> 
> 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.

Yes I think MDI is the right way to do these kinds of setup commands.

Isn't it just emcCommandWaitDone() that you need?

But if your code can't just sit there waiting, you have to get
fancier.  halui has some complexity in it because it wants to wait for
the mdi to complete, but also wants to continue polling the inputs, so
for instance the user can abort the move.  You might look at halui for
ideas.

Chris


--
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


[Emc-developers] Programatically sending a sequence of motion commands

2009-04-08 Thread Eric H. Johnson
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


Re: [Emc-developers] Programatically sending a sequence of motion commands

2009-04-08 Thread Eric H. Johnson
Oops,

I should have mentioned that the code snippet comes from the file
src/emc/usr_intf/emcsched.cc.

Regards,
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