C Program - Move to XYZ Location

Moderators: TomKerekes, dynomotion

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

C Program - Move to XYZ Location

Post by CNC_Machines » Wed Jan 02, 2019 7:54 pm


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.



Posts: 101
Joined: Thu Apr 26, 2018 10:16 pm

Re: C Program - Move to XYZ Location

Post by Moray » Wed Jan 02, 2019 8:19 pm

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("\nMDI time:%f\n", Time_sec());
//printf("MDI sent,%f\n", Time_sec());

Post Reply