Page 1 of 1

C Program - Move to XYZ Location

Posted: Wed Jan 02, 2019 7:54 pm
by CNC_Machines
Greetings,

I am wondering is there is a C function to move my CNC machine to an XYZ location? Using the Move function is based off Machine Coordinates. Do I have to communicate with the KMotionCNC to determine the fixture offset and do something like this?

Move(desired Axis) = Desired Position- Current Position - Fixture Offset?

Can anyone think of an easier way to do this? If not do I use the "KFlopToKMotionCNCFunctions.c" file? I dont see fixture offset in that file.

Thanks,

Scott

Re: C Program - Move to XYZ Location

Posted: Wed Jan 02, 2019 8:19 pm
by Moray
You are correct in that you need to use an alternative method, as KFlop only works in axis counts and has no idea regarding the XYZ positions.

The simplest method I can think of, is to use KflopToKMotionCNCFunctions.c, and the MDI function.

Here's a quick example from a C program I've been working on -

Code: Select all


double x = 0.0;
double y 0.0;
gcode = 53;
char s[80];

sprintf(s,"G%f G1 X%f Y%f\n", gcode, d[0], d[1]);
printf(s);
//printf("\nMDI time:%f\n", Time_sec());
//printf("MDI sent,%f\n", Time_sec());
MDI(s);