Halt and resume GCodes

Moderators: TomKerekes, dynomotion

Post Reply
IvanSiberia
Posts: 30
Joined: Fri Jun 17, 2022 11:21 am

Halt and resume GCodes

Post by IvanSiberia » Sun Jan 22, 2023 4:29 pm

When a custom G code like MoveAtVel(AXIS_Y,(coordinate)*10000,speed*10000/60 ); is executed in KMotionCNC ; . When you press the F5 button, the interpreter window sometimes pops up with the loss of the trajectory. How to pause code execution correctly?
442d6ab4-0d23-416f-8b31-44b2a1ccfdcd.jpg

User avatar
TomKerekes
Posts: 2529
Joined: Mon Dec 04, 2017 1:49 am

Re: Halt and resume GCodes

Post by TomKerekes » Sun Jan 22, 2023 6:04 pm

Hi Ivan,

Did you mean a Custom MCode that executes a C Program to make a Move?

If after the Move the Code waits until the motion is completed then executes a Halt next line such as this:

Code: Select all

#include "KMotionDef.h"
#define TMP 10
#include "C:\PerforNext\CNC\User\C Programs\KflopToKMotionCNCFunctions.c"

void main()
{
	MoveRel(0,10000);
	while (!CheckDone(0));
	DoPC(PC_COMM_HALT_NEXT_LINE);
}
And the MCode is configured to Exec/wait/sync then the Interpreter should be synchronized with the new position and be able to resume cleanly.
Regards,

Tom Kerekes
Dynomotion, Inc.

IvanSiberia
Posts: 30
Joined: Fri Jun 17, 2022 11:21 am

Re: Halt and resume GCodes

Post by IvanSiberia » Mon Jan 23, 2023 10:06 am

My code will execute on command M 104, I want the operator to be able to stop the code and continue without popup.

User avatar
TomKerekes
Posts: 2529
Joined: Mon Dec 04, 2017 1:49 am

Re: Halt and resume GCodes

Post by TomKerekes » Mon Jan 23, 2023 4:47 pm

I'm not sure what you mean by "I want the operator to be able to stop the code".

But the example I gave should stop and allow a resume without the popup.
Regards,

Tom Kerekes
Dynomotion, Inc.

IvanSiberia
Posts: 30
Joined: Fri Jun 17, 2022 11:21 am

Re: Halt and resume GCodes

Post by IvanSiberia » Mon Jan 30, 2023 8:09 am


M104 exec/wait/sync

Code: Select all

#include "KMotionDef.h"
#include "Mikromat InputOutput.h"
void main()
{

	MoveAtVel(2, -1000, 1000 * 1000 / 60);
	while (!CheckDone(2));

}
M107 exec/wait/sync

Code: Select all

#include "KMotionDef.h"
#include "Mikromat InputOutput.h"
void main()
{

	MoveAtVel(2, 0, 1000 * 1000 / 60);
	while (!CheckDone(2));

}

User avatar
TomKerekes
Posts: 2529
Joined: Mon Dec 04, 2017 1:49 am

Re: Halt and resume GCodes

Post by TomKerekes » Tue Jan 31, 2023 3:23 am

Hi Ivan,

Ah, I didn't realize you were randomly hitting Halt.

I'm not sure how you expect that to work, if you have a C Program that is supposed to do something and you Halt it part way through then KMotionCNC doesn't have a way to resume the C Program part way through. So it asks is if it ok to re-execute the C Program from the beginning after doing these things.

Maybe you could explain your application in detail and what are you trying to do.

You could probably create a new "Halt" button that would wait until the C Program finishes and then Halt.
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply