Tool Correction

Moderators: TomKerekes, dynomotion

Post Reply
cemoa9
Posts: 82
Joined: Mon Jun 01, 2020 11:01 am

Tool Correction

Post by cemoa9 » Mon Aug 15, 2022 11:56 am

Hello Tom,

With a spec screen I want to be able to make tools correction as available on commercial lathes, spec screen is ready but I have issues (as usual) with the C program, reading the content of the Edit button works perfectly. But I do not manage to get the tool length or offsets. Rigth under the code with some lines in comments for simpler trials :


#include "KMotionDef.h"

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


main()
{
int FixtureIndex,Units, TWORD, HWORD, DWORD;
double NewToolLength,Length,OriginOffsetZ,AxisOffsetZ,XRes,YRes,ZRes;
double Machinex,Machiney,Machinez,Machinea,Machineb,Machinec;
double NewToolDiameter,ToolDiameter,NewToolOffsetX,ToolOffsetX,NewToolOffsetZ,ToolOffsetZ;

double Xcorrection, Zcorrection, Tool;

GetEditControlDouble(&Tool, 150, 1000);
GetEditControlDouble(&Xcorrection, 151, 1000);
GetEditControlDouble(&Zcorrection, 152, 1000);

TWORD = (int)Tool;

printf("TOOL ID %i \n", TWORD);
printf("X correction %f \n", Xcorrection);
printf("Z correction %f \n", Zcorrection);


//GetToolOffsetX(TWORD, &ToolOffsetX);
//NewToolOffsetX = &ToolOffsetX + Xcorrection;
//SetToolOffsetX(TWORD,NewToolOffsetX);
//printf("NewToolOffsetX %f \n", NewToolOffsetX);


GetToolLength(TWORD, &Length);
printf("ToolLength %g \n",Length);
//NewToolOffsetZ = &Length + Zcorrection;
//printf("NewToolOffsetZ %f \n", NewToolOffsetZ);
//SetToolLength(TWORD,NewToolOffsetZ);


}


Cordially,

Francois
Attachments
printscreen_Tool.png

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

Re: Tool Correction

Post by TomKerekes » Mon Aug 15, 2022 9:58 pm

Hi Francois,

To Get/Set Tool Table Parameters the Tool Table index is required. The Tool Table index is basically the line number of the Tool Table. There currently isn't a method for KFLOP to obtain the Tool Table Index for a specific Tool ID. Your code is trying to use the Tool ID as an index.

The GetMiscSettings() function can obtain the Tool Table Index of the currently selected Tool. Could you use that instead of having a 2nd control for selecting the Tool to modify?
Regards,

Tom Kerekes
Dynomotion, Inc.

cemoa9
Posts: 82
Joined: Mon Jun 01, 2020 11:01 am

Re: Tool Correction

Post by cemoa9 » Tue Aug 16, 2022 7:06 am

Hello Tom,

That unfortunately will not work as the tool to be corrected is not always (rarely) the active tool, target is really to be able to make corrections while a program is running (with bar-puller for example).

Cordially,

Francois

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

Re: Tool Correction

Post by TomKerekes » Wed Aug 17, 2022 3:09 am

Hi Francois,

Here is a patch to add a new command to request the Tool Table Index for a Tool ID (or slot) for Version 4.35f.

Copy KMotionCNC.exe to C:\KMotion435f\KMotion\release

Copy KMotionCNCFunctions.c to C:\KMotion435f\C Programs

Copy pc-dsp.h to C:\KMotion435f\DSP_KFLOP

Here is an example to adjust a tool length of a specific Tool ID (or slot):

Code: Select all

#include "KMotionDef.h"

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

main()
{
	int TIndex;
	double ToolLength;
	
	if (!GetToolTableIndexFromID(1002, &TIndex))
	{
		// Change Currently Selected Tool Length
		GetToolLength(TIndex,&ToolLength);
		SetToolLength(TIndex,ToolLength + 0.001);
	}
}
Regards,

Tom Kerekes
Dynomotion, Inc.

cemoa9
Posts: 82
Joined: Mon Jun 01, 2020 11:01 am

Re: Tool Correction

Post by cemoa9 » Thu Aug 18, 2022 12:15 pm

Hello Tom,

Thank you very much for your support and those files, I tried with the files, when KmotionCNC opens I get an error message : Error Screen Script File. Screen Control not found. IDC_But0

The screenset is not what it is supposed to be. I tried to use the back-up of the screen script file, result is the same, I also tried to reverse and replaced with the old 3 files and the error happens again
Also tried using one of the existing custom screens, I also get the error message.

Cordially,

Francois

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

Re: Tool Correction

Post by TomKerekes » Thu Aug 18, 2022 4:30 pm

Hi Francois,

I forgot Resourse.h copy to C:\KMotion435f\PC VC Examples\KMotionCNC\

For me restoring KMotionCNC.exe without the new Resource.h made the Custom Screens work normally again.
Regards,

Tom Kerekes
Dynomotion, Inc.

cemoa9
Posts: 82
Joined: Mon Jun 01, 2020 11:01 am

Re: Tool Correction

Post by cemoa9 » Fri Aug 19, 2022 6:34 pm

Hello Tom,

It now works perfectly, also with restoring KmotionCNC.exe.

Thanks a lot !

Francois

Post Reply