Add Home button in KMotionCNC

Moderators: TomKerekes, dynomotion

Post Reply
AndreyP
Posts: 7
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: 2527
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.

AndreyP
Posts: 7
Joined: Wed May 29, 2019 6:34 pm

Re: Add Home button in KMotionCNC

Post by AndreyP » Thu Jun 20, 2019 9:41 pm

Thanks so much for the reply!
So not sure what I am forgetting maybe I need to include some paths or something but I get this error when I hit the home button while the gcode is running and if I first hit the pause button then the home it gives only the error compiling message. I set the feed rate at the beginning of every gcode I run with say "F60" and I change this from time to time. I do not use any offsets that I am aware of. I only have a "home.c" file but do not have a "home.c:5" that it seems it is looking for but not sure. It seems to not like the line: #include "KflopToKMotionCNCFunctions.c". It may only like .h files but no idea. I am stuck again. Thanks for any help.
Home button error KFLOP.png

AndreyP
Posts: 7
Joined: Wed May 29, 2019 6:34 pm

Re: Add Home button in KMotionCNC

Post by AndreyP » Thu Jun 20, 2019 10:16 pm

Ok I got it work it was a simple fix just made an absolute path for that one line:
#include "D:\Programs\KMotion434\C Programs\KflopToKMotionCNCFunctions.c"

So for the future what is the fix to not to have to do the full path? I know it's simple but totally forget.

Post Reply