Page 1 of 1

What is the correct way to wait for motion in macro call?

PostPosted: Fri Aug 25, 2017 6:53 pm
by merrick
Looking at the shared macros, I've seen them done in a few different ways:

a. exec.Code("G0 X0 Y0");
while (exec.IsMoving ()){}
exec.Wait (200);
Q: why wait after motion is completed?

b. exec.Callbutton(107);
while (exec.IsMoving ()){ exec.Wait(200); }
Q. why wait inside the loop? To avoid empty loop too many times?

c. exec.Code("G0 X0 Y0");
exec.Wait(200);
while (exec.IsMoving ()){}
Q. why wait before the loop? To avoid the next loop finished before the code is inserted into the motion buffer?

So, what's do you recommend and why? Thanks.

Re: What is the correct way to wait for motion in macro call

PostPosted: Fri Aug 25, 2017 7:14 pm
by ger21
You don't need the wait(200) at all if your just waiting for the motion to stop.

Re: What is the correct way to wait for motion in macro call

PostPosted: Sun Aug 27, 2017 5:55 pm
by merrick
So the code:

exec.Callbutton(107);
while (exec.IsMoving ()){}
exec.AddStatusmessage("Motion stopped");


Is guaranteed that the message "Motion stopped" only appear after the motion has stopped?