Dynomotion

Group: DynoMotion Message: 11473 From: gehigley Date: 5/4/2015
Subject: kmotion

So I am new to kflop and kstep. I had a friend help me build my controller so my machine is configured, dialed in and works very good. The problem is I don't really understand how he set it up, were talking about kmotion that after it is very first installed wont do anything with a machine until you set it up with the language of C. The problem I have is that I am not educated in the language of C and I no longer have someone to help me set it up further. If I want to add a touch plate, I have to know C. If I want to add a home button to just tell the machine to move to X0, Y0, Z0 in which I want the z axis to move to safe z height first, then to move to X0,Y0 I have to know the language of C. I am finding myself asking myself why did I ever decide to go to one of the best controllers and Drivers (Kflop and Kstep) only if you know the language of C? As a hobbyist that was tired of Mach3 unexpected Crashes and seeing how well kmotion worked without flaw I guess is why I am here today scratching my head. So I guess what I am trying to do is just add another button called "home" and when I click on it the machine will return to X0,Y0. Other controlling software where the home button is already set up and programed, kmotion is not. Is there anyone out there that can help me set up a home button that is willing to share a c program that can walk me through linking the program with the button?  

Group: DynoMotion Message: 11474 From: tmday7 Date: 5/5/2015
Subject: Re: kmotion

Hello,

Don’t let the C programming “run you away”. I knew nothing about C when I started with Kflop, but Tom here is much helpful.

 You can add 10 extra user buttons in KmotionCNC by going to Tool Setup page. Also, first have a look at some C program examples provided with the KMotion software. This will help to get a little familiar with how the C programs work. Even if you cant make to much sence of it. … I couldn’t at first. J And I still need help with it now.

 

Troy

Group: DynoMotion Message: 11475 From: Tom Kerekes Date: 5/5/2015
Subject: Re: kmotion
Hi gehigley,

Having the ability to code your own Home program in C allows infinite flexibility and control over the method used to home your system.

The standard methods that most controllers offer are already coded in C for you so you don't have to write any code.  All you need to do is set all the parameters for your system like you would need to do with any system.  In any case you must understand how your system should be homed: ie which order, what directions, what speeds, what home sensor inputs are used, what the polarity of the inputs are, etc...  See the Example:

\C Programs\SimpleHomeIndexFunctionTest.c

HTH
Regards
TK


Group: DynoMotion Message: 11476 From: gehigley Date: 5/5/2015
Subject: Re: kmotion
Thanks guys, I appreciate all the help, I think I confused you tom as how I used the term home so loosely, Im not that advanced, I am not trying to home the machine, I simply want to have a button that tells the machine to go to X zero Y zero is all. That's prob really simple but yet seems like a mountain for me, lol.
Group: DynoMotion Message: 11477 From: Tom Kerekes Date: 5/5/2015
Subject: Re: kmotion
Hi gehigley,

To simply move an Axis using C Code there is a C Function called "Move" that accepts two parameters.  The first is the axis to move and the second is the absolute machine position to move to in KFLOP units.

So to write a C Program to move Axes #0 and #1 (I assume those are your x and y axes) both to zero you could use the C Code below.  The #include "KMotionDef.h" is needed to include the file that defines all the available KFLOP functions and variables including "Move" for the C Compiler.  The main() function definition instructs the C compiler where the program should begin execution.  The curly brackets show the compiler where the main function begins and ends. 

Try pasting this code into Thread #2 in the KMotion.exe C Programs Screen and save it as a file called something like GoZero.c  Then press the "Save, Compile, Download, Run" button and see if your xy axes move to machine coordinates 0,0.   

#include "KMotionDef.h"
main()
{
    Move(0,0);
    Move(1,0);
}
Let us know how much of this makes sense.
Regards
TK
Group: DynoMotion Message: 11479 From: gehigley Date: 5/5/2015
Subject: Re: kmotion
    

Thanks Tom, I think im starting to figure this stuff out a little, I forget where I found it but because I have dual steppers moving in y and 1 stepper moving in x........I found a spot somewhere in kmotion setting that showed me that 0 and 1 had the same number and 2 was totally different, so I assumed that the two that were the same was the y axis leaving 2 for the x so I believe...... SO I altered what you showed me, I was afraid that one axis might move on the y axis causing the gantry to move at an angle.


#include "KMotionDef.h"
main()
{
    Move(0,0);
    Move(1,0);

    Move(2,0);

}

So this is what I used instead as I crossed my fingers. I did exactly what you said to do and I ran it, what happened next was it moved to 0,0 only in machine coordinates, how would I get it to work if I zero all axis at a location on the table moved it say 4 inches up and across the table having it to move right back where I zeroed it at in stead of machine cords?

Group: DynoMotion Message: 11480 From: Tom Kerekes Date: 5/5/2015
Subject: Re: kmotion
Hi gehigley,

Moving 3 axes to move xy doesn't seem right.  If your Y axis has two motors properly slaved together then commanding the Master should cause both to move.  Its important for you to know your own system and exactly how it is designed and configured.  You should figure all that out and document it first before trying to add new features.

I had mentioned that the moves would be in absolute machine coordinates.  To move to locations that involve Interpreter Offsets is somewhat more complex and there are several methods that could be used.  But I think it would be simpler to be executed in GCode as:

G0X0Y0
M30

If you type those into a Gcode file that has a file extension of *.ngc you can simply assign that to a User Button of type "Exec Program".  The file extension of *.ngc will cause KMotionCNC to execute it as GCode instead of C Code in KFLOP.

Regards
TK



Group: DynoMotion Message: 11481 From: gehigley Date: 5/5/2015
Subject: Re: kmotion

Thank you so much Tom, I am an idiot but coming along lol, so I tried  


#include "KMotionDef.h"
main()
{
    Move(0,0);
    Move(1,0);

}


to make sure the table is configured right and it worked so that's good but thank you for the work around, gcode I understand a little better. I didn't know it would run Gcode like a program so I did this, it works for me, kind of cautious when it comes to telling the mill to come out of a part and return home, first I want it to come out of the part a safe z height, then pause a moment before running across the part so this is what I came up with, it works for me and it works, thank you so much for all your help.


G0Z0.1250

G4 P3

G0 X0 Y0

M30


Thanks again