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
Machine Calibration
Moderators: TomKerekes, dynomotion
- TomKerekes
- Posts: 2677
- Joined: Mon Dec 04, 2017 1:49 am
Re: Machine Calibration
Hi Scott,
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.
I don't understand this. Please describe in more detail.We currently calibrate our KFlop CNC machines using a set of precision gauges manually
From a C Program the Axis Offsets can be changed with:and then opening the ".set" file and typing in the correct values for "axis_offset_x" and "axis_offset_y".
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.
Tom Kerekes
Dynomotion, Inc.
-
- Posts: 60
- Joined: Fri Apr 27, 2018 10:43 pm
Re: Machine Calibration
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
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
- TomKerekes
- Posts: 2677
- Joined: Mon Dec 04, 2017 1:49 am
Re: Machine Calibration
Hi Scott,
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:
That is correct.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.
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.
Tom Kerekes
Dynomotion, Inc.
-
- Posts: 60
- Joined: Fri Apr 27, 2018 10:43 pm
Re: Machine Calibration
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.
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.
-
- Posts: 60
- Joined: Fri Apr 27, 2018 10:43 pm
Re: Machine Calibration
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?
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?
- TomKerekes
- Posts: 2677
- Joined: Mon Dec 04, 2017 1:49 am
Re: Machine Calibration
Hi Scott,
GetAxisOffset() should return the current G92 offset.
GetAxisOffset() should return the current G92 offset.
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.