Machine Calibration

Moderators: TomKerekes, dynomotion

Post Reply
CNC_Machines
Posts: 60
Joined: Fri Apr 27, 2018 10:43 pm

Machine Calibration

Post by CNC_Machines » Fri Nov 22, 2019 3:36 pm

Greetings,

We currently calibrate our KFlop CNC machines using a set of precision gauges manually, and then opening the ".set" file and typing in the correct values for "axis_offset_x" and "axis_offset_y". I would love to write a C program using a touch probe to write these variables to the set file. Can anyone think of a way to do that?

Thanks!

Scott

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

Re: Machine Calibration

Post by TomKerekes » Fri Nov 22, 2019 10:17 pm

Hi Scott,
We currently calibrate our KFlop CNC machines using a set of precision gauges manually
I don't understand this. Please describe in more detail.

and then opening the ".set" file and typing in the correct values for "axis_offset_x" and "axis_offset_y".
From a C Program the Axis Offsets can be changed with:
DoPCFloat(PC_COMM_SET_X,0.0);
This would set the appropriate Axis Offset to make the DRO read 0.0


Here is a great video tutorial by Jeremy Brown. See the description with a link to his code.

Regards,

Tom Kerekes
Dynomotion, Inc.

CNC_Machines
Posts: 60
Joined: Fri Apr 27, 2018 10:43 pm

Re: Machine Calibration

Post by CNC_Machines » Fri Nov 22, 2019 11:15 pm

Tom,

Thanks for the video. Let me explain a bit better.

We have a permanent fixture set up on the machine, and use the global coordinator G92 for this fixture. A technician calibrates this fixture location by manually jogging the machine to a known location (feeler gauges and precision ground blocks). The tech will manually type the "axis_offset_x" and "axis_offset_y" offsets into the .set file for the machine. Now every time KMotionCNC is loaded it will pull the correct offsets in.

I am writing a program very similar to the video. I believe that DoPCFloat(PC_COMM_SET_X,0.0) would just rewrite the current G92 value for X, but it would not rewrite the .set file "axis_offset_x". The .set file is very useful because it makes the calibration persistent between rebooting the computer. I would like to only have to calibrate periodically with a procedure like the video, but have it stay permanently.

Does this make sense?

Is there a way to go the opposite direction as well? Is there a function that will return the G92 offset for any given axis?

Thanks!

Scott

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

Re: Machine Calibration

Post by TomKerekes » Sat Nov 23, 2019 12:49 am

Hi Scott,
I am writing a program very similar to the video. I believe that DoPCFloat(PC_COMM_SET_X,0.0) would just rewrite the current G92 value for X, but it would not rewrite the .set file "axis_offset_x". The .set file is very useful because it makes the calibration persistent between rebooting the computer.
That is correct.

There is an option "Save Always" to make any changes of offsets persistent. Would that work for you?

Otherwise I suppose you could read/modify/write the Settings file from KFLOP using the disk read/write functions like this:

Code: Select all

#include "KMotionDef.h"

// Example to copy Interpreter's Settings File and make modifications

char * strstr ( const char *, const char * ); // find string function

double NewX = 111.1;  // dummy values to set
double NewY = 222.2;

void main()
{
	FILE *f, *g;
	char s[256];
	
	f=fopen("c:\\Temp\\MM.set","rt");  // open original file
	if (!f)
	{
		printf("Unable to open file\n");  
		return;
	}

	g=fopen("c:\\Temp\\MM2.set","wt");  // open new file to be created
	if (!g)
	{
		printf("Unable to open file\n");
		fclose(f);
		return;
	}
		
	while (!feof(f))  // loop through every line of original file
	{
		fgets(s, 255, f);// read a line 
		
		if (strstr(s, "axis_offset_x"))  // modify if x offset
			sprintf(s,"axis_offset_x\t\t\t%g\t\t\tany real number",NewX);
		else if (strstr(s, "axis_offset_y")) // modify if y offset
			sprintf(s,"axis_offset_y\t\t\t%g\t\t\tany real number",NewY);
		
		fprintf(g, "%s\n",s); // write the original or modified line
	}
	fclose(f);
	fclose(g);
}
Regards,

Tom Kerekes
Dynomotion, Inc.

CNC_Machines
Posts: 60
Joined: Fri Apr 27, 2018 10:43 pm

Re: Machine Calibration

Post by CNC_Machines » Mon Nov 25, 2019 4:00 pm

Thanks Tom! That is just what I needed.

Do you know of a function that to return the current offset for an axis? I have been looking through the PC communication functions to try to find one but havent been successful.

CNC_Machines
Posts: 60
Joined: Fri Apr 27, 2018 10:43 pm

Re: Machine Calibration

Post by CNC_Machines » Mon Nov 25, 2019 7:28 pm

I have been working a bit more on this.. I think one of these two functions is what I need.

int GetOriginOffset(double *OriginOffset, int FixtureIndex, int Axis)
{
if (GetVars(5200+FixtureIndex*20+Axis+1,1,TMP)) return 1; // Download to persist TMP
*OriginOffset=GetUserDataDouble(TMP);
return 0;
}

int GetAxisOffset(double *AxisOffset, int Axis)
{
if (GetVars(5200+Axis+11,1,TMP)) return 1; // Download to persist TMP
*AxisOffset=GetUserDataDouble(TMP);
return 0;
}

Would either of these return the current G92 offset for the requested axis?

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

Re: Machine Calibration

Post by TomKerekes » Mon Nov 25, 2019 9:18 pm

Hi Scott,

GetAxisOffset() should return the current G92 offset.
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply