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.
Locking user buttons when executing G-code and vice versa.
Moderators: TomKerekes, dynomotion
Re: Locking user buttons when executing G-code and vice versa.
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.
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.
- TomKerekes
- Posts: 2724
- Joined: Mon Dec 04, 2017 1:49 am
Re: Locking user buttons when executing G-code and vice versa.
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: Locking user buttons when executing G-code and vice versa.
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.
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?
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);
}
The question then comes down to how to transfer the state of the buttons and the G-code to the C-program?
- TomKerekes
- Posts: 2724
- Joined: Mon Dec 04, 2017 1:49 am
Re: Locking user buttons when executing G-code and vice versa.
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:
Here is a C Example
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.
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
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 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.
Last edited by TomKerekes on Fri Dec 27, 2024 7:22 pm, edited 2 times in total.
Reason: include DSP_KFLOP folder for KFLOP systems
Reason: include DSP_KFLOP folder for KFLOP systems
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: Locking user buttons when executing G-code and vice versa.
Thanks, Tom!
Everything is working.
Everything is working.