Add Home button in KMotionCNC

Moderators: TomKerekes, dynomotion

Post Reply
AndreyP
Posts: 2
Joined: Wed May 29, 2019 6:34 pm

Add Home button in KMotionCNC

Post by AndreyP » Tue Jun 04, 2019 10:55 pm

Need a Home button to go to zero position.
From right click on KMotionCNC>Tool setup screen>User Buttons
Add button name eg Home.
Add key eg 100.
Add execute prog.
Add thread eg 4.
Add var eg 0.
Create "home.c" file and point to it in c file field.
Note I created the home.c file using Atom which is a text/code editor and not something like Microsoft Visual Studio so no compiling but I don't think I need to.

The home.c file looks like:

#include "KMotionDef.h"

//Brings the head back to X0,Y0,Z0,A0,B0,C0,U0,V0 position after Pause button while motors are still on. Will not work after Stop button. Note my machine uses 8 axis so that is why it is so long.

Here is the code which I have no idea.
I noted all I have to do is replicate what the Manual Entry field does as if I enter G1 X0 Y0 Z0 A0 B0 C0 U0 VO and hit Send it works. "The Manual Entry cell allows the user to quickly enter a single line of G Code and Send it to the interpreter for execution." -the field below the gcode window.
I guess the code would also have to pause the gcode file from running if it is, keep the motors powered, and also do what the Restart button does above the gcode window.
So the head goes to zero position and the gcode file can be run again from the start or another file can be loaded.
If someone knows how the code will look if you can hack that out with some comments it would be the fastest way to explain how to do it as I think it will be a very short code. Ok cheers.

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

Re: Add Home button in KMotionCNC

Post by TomKerekes » Wed Jun 05, 2019 6:28 pm

Hi AndreyP,

That line of GCode may not always move to the same place depending on which Global, Fixture, Tool, etc offsets are in effect. You also didn't specify a feed rate. But if that works you might try this:

Code: Select all

#include "KMotionDef.h"

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


main()
{
	DoPC(PC_COMM_HALT);  // Halt in case we are running a Job
	MDI("G1 X0 Y0 Z0 A0 B0 C0 U0 V0 F100");  // move to zero
	DoPC(PC_COMM_RESTART);  // Restart the position of the GCode
}
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply