Page 1 of 1

Locking user buttons when executing G-code and vice versa.

Posted: Sun Dec 22, 2024 7:52 pm
by AlexSV
Hello Tom!

How to set up locking user buttons when executing G-code similar to how it happens with jog/step buttons?
Also need a way to lock jog/step and Cycle Start from C programs.

It is necessary that when executing the tool measurement cycle, it is impossible to start the execution of the G-code, or arbitrarily move the axes, or vice versa, start the measurement cycle during the execution of the G-code.

Re: Locking user buttons when executing G-code and vice versa.

Posted: Sun Dec 22, 2024 11:45 pm
by Moray
That button disabling functionality is hard coded in to KMotionCNC, so can't be replicated from a C program.

You can prevent running of a program by having a C program that executes when Cycle Start is pressed, that checks that it's OK to run, or stops G-code execution if not OK to run.

I think there is also a way to disable jogging in a C program (but the screen buttons will still appear 'active'), however I can't remember the details right now.

Re: Locking user buttons when executing G-code and vice versa.

Posted: Sun Dec 22, 2024 11:57 pm
by TomKerekes
Hi Alex,

You might see this Thread.

Re: Locking user buttons when executing G-code and vice versa.

Posted: Mon Dec 23, 2024 8:39 am
by AlexSV
Tom, for me this function works only when G-code is activated, you can unlock and lock the jog button. In normal mode, there is no locking.

I run this program in a parallel thread from KMotion.

Code: Select all

#include "KMotionDef.h"
#define TMP 10 // which spare persist to use to transfer data
#include "KflopToKMotionCNCFunctions.c"

void main() 
{

 // DoPC(PC_COMM_ENABLE_JOG_KEYS);
 // Delay_sec(5);
 DoPC(PC_COMM_DISABLE_JOG_KEYS);
 Delay_sec(5);

}
Moray, I think it is possible to track in an infinite loop, but you need to get the flags of the state of the G-code operation, and pressing the jog buttons, Cycle Start, etc. and process the combination of these flags.

The question then comes down to how to transfer the state of the buttons and the G-code to the C-program?

Re: Locking user buttons when executing G-code and vice versa.

Posted: Fri Dec 27, 2024 2:52 am
by TomKerekes
Hi Alex,

Here is a patch for V5.3.6 with new commands to disable controls. One will disable all the Jog Buttons and such regardless of the Job running state. The two others will allow enabling/disabling a list of controls that are not otherwise controlled. The new commands are:

Code: Select all

#define PC_COMM_FORCE_DISABLE_JOG_KEYS 116  // Disable Jog Buttons regardless if Job is Running or not

// Enable Dialog Controls Persist+1 = gather buffer offset (32-bit words) List of Controls to Enable, defined in resource.h
#define PC_COMM_ENABLE_CONTROLS 117   // Persist+1=gather offser to null terminated list of int ControlIDs

// Disable Dialog Controls Persist+1 = gather buffer offset (32-bit words) List of Controls to Disable, defined in resource.h
#define PC_COMM_DISABLE_CONTROLS 118   // Persist+1=gather offser to null terminated list of int ControlIDs

Here is a C Example

Code: Select all

#include "KMotionDef.h"
#define TMP 10 // which spare persist to use to transfer data
#include "KflopToKMotionCNCFunctions.c"
#include "..\PC VC Examples\KMotionCNC\resource.h"

void main() 
{
	int *p=(char *)gather_buffer+GATH_OFF*sizeof(int);  // pointer to list
	
	*p++ = IDC_SpindleOnCW;
	*p++ = IDC_SpindleOnCCW;
	*p++ = IDC_SpindleOff;
	*p++ = IDC_SaveFile;
	*p++ = IDC_SaveAs;
	*p++ = IDC_But0;
	*p++ = IDC_GO;
	*p++ = 0;  // terminate list
	
	DoPCInt(PC_COMM_DISABLE_CONTROLS,GATH_OFF);
//	DoPCInt(PC_COMM_ENABLE_CONTROLS,GATH_OFF);

	
	DoPC(PC_COMM_FORCE_DISABLE_JOG_KEYS);
//	DoPC(PC_COMM_ENABLE_JOG_KEYS);
}
Copy KMotionCNC.exe to the C:\KMotion5.3.6\KMotion\Release Folder

Copy PC-DSP.h to the C:\KMotion5.3.6\DSP_KOGNA folder and to the C:\KMotion5.3.6\DSP_KFLOP folder

The source code is included here.

Let us know of any issues.

Re: Locking user buttons when executing G-code and vice versa.

Posted: Sat Dec 28, 2024 11:03 pm
by AlexSV
Thanks, Tom!
Everything is working.