Page 3 of 4

Re: Unexpected motion during a macro.

PostPosted: Sat Dec 23, 2017 8:29 am
by Robertspark
Hope you all have a great break + all the best for the new year.

I'd suggest posting something with the new release that cncdrive will be closed and away for a while so as to avoid complaints

Re: Unexpected motion during a macro.

PostPosted: Fri Mar 02, 2018 3:50 pm
by Derek
Just a FYI that I just had this happen again.

Same scenario except this time the Y axis was moving with the B axis as opposed to the X. V1.2102

Re: Unexpected motion during a macro.

PostPosted: Fri Mar 02, 2018 5:52 pm
by cncdrive
It is likely the macro codes which causes this issue.
I see that there are some G31 codes in it and if the macro is not waiting for that for example to end before executing other G-codes can cause issues like what you described, it can roll back coordinates if the end of the G31 or other movements are not waited out and new g-codes are sent before that.
Unfortunately the posted macro codes when I download it do not contain any break/new line characters, so when I open your macros they open as if it is written in a single line,
so basicly the macros are unreadable for me as it downloads on my computer, so I could not even look through them properly checking for any possible errors.

Re: Unexpected motion during a macro.

PostPosted: Fri Mar 02, 2018 6:30 pm
by Derek
Hi Balazs

The problem macro is the M200001. The M970 was a user error problem:)

The M20001 is the tool out macro for my power draw bar. I have run it hundreds of times since I first posted the problem. This is the first time it has happened since the original post in December.

Re: Unexpected motion during a macro.

PostPosted: Fri Mar 02, 2018 6:38 pm
by dezsoe
Balázs, I attached the M20001 with CR/LF.

Derek, after the first movement there's no while (exec.IsMoving()); and that may cause the problem.

Re: Unexpected motion during a macro.

PostPosted: Fri Mar 02, 2018 6:50 pm
by Derek
Would that cause movement on an axis that isn't used in the macro?

Re: Unexpected motion during a macro.

PostPosted: Fri Mar 02, 2018 10:56 pm
by cncdrive
Yes, it can possibly, because if you commanding a movement in a macro then the macro's exec.Code function interprets the code and then commands the movement with pushing the movement into the motion buffer.
Now if the macro is not waiting for that motion to stop and commanding another movement with another exec.Code then the movement is still ongoing and when this second movement is placed into the buffer then the non programmed in this second code axes positions will be stored as they are at the moment. But the previous motion is still ongoing, so there is an intermediate coordinate for the axes.
And so when the second command gets executed then it will roll the coordinates which were not programmed back to the coordinates where the coordinates were when the second command was placed into the motion buffer, because the software could tell the API, that because these axes do not have to move, so their coordinates have to be this and that, but what coordinates at that timepoint the software sees is those intermediate coordinates, because the axis did not stop, it was still in motion.
This can't work elseway, because if it was working in a way that this possible problem was disabled in code then the exec.Codelist function could not work.
One or the other could not work... it is not possible to make everything all way to work, because there are logical contradictions between the 2.
So, in other words, because you guys asked for a .Codelist function with multi-line macro code execution using the lookahead buffer, for this reason the exec.Codes can't wait for eachother and the above explained problem could happen if the user is not coding a wait until the motion stops before executing a new movement with another exec.Code function.
It is the user's task to take care of this in the macros, otherwise these type of issues can happen.
Or use a Codelist function with multiply codes, but that is not always possible for all type of tasks, depends on what the user wants to code if it is possible or not.
Or the user could note the coordinates of the endmovement and then code the axes coordinates if it is nessessary not to wait to end the previous movement, however this is not possible with a probing, because the user code will not know in advance what the probing results will be.

Re: Unexpected motion during a macro.

PostPosted: Fri Mar 02, 2018 10:58 pm
by cncdrive
However if the macro is not moving an axis at all, I mean there is no movement for that axis at all anywhere in that macro then the above mentioned issue can't happen on that axis, but again, the macro you posted downloads unreadable for me, so I do not see what it exactly doing.

Re: Unexpected motion during a macro.

PostPosted: Fri Mar 02, 2018 11:19 pm
by Derek
Hi Balazs
The M20001 macro only has B axis motion.
Forget about the M970 macro. I was using it improperly.

Am I understanding you correctly that you can't open the file I uploaded?

Thanks
Derek

Re: Unexpected motion during a macro.

PostPosted: Fri Mar 02, 2018 11:20 pm
by cncdrive
I can open it, but it is unreadable, because there are no new line characters and it just takes too much time to figure out where one line ends and where the next starts.