I give you a glimpse of something that has taken me the last few days to create and figure out. I've got my KFlop discovering Zero on X, Y and Z with one button press.
This was made possible from my initial setup by a few distinct things. 1) Figuring out how to get KFlop to recognize when a circuit was made (required wiring 12v to one end with a ground on the other end - through one of the optical digital inputs) 2) Acquire / create the mechanism that will do the sensing 3) Learn all about the KFlop / KMotionCNC programming model and how data is shuttled back and forth 4) Learn how to control motion and track position using C code 5) Writing, testing, iterating until I had what worked.
I'd call this a success!
Edit: Due to popular request, I'll share a bit more about how I put this together.
This is all done with a single .c file which links to two header files that come with KMotionCNC. I invoke this action by use of custom button, which you can configure as follows:
* Open KMotionCNC, click Tool Setup, choose the User Buttons tab
* For one of the available buttons, do the following
- Name the button (I chose X0Y0Z0 All)
- Choose Execute Prog
- Pick a thread (I choose thread 7 for my setup routines)
- For VAR, enter 0
- For C File, enter the path to your .c file
Now onto the source. When I first started looking into it, I thought I'd act like a user would act, by reading the DRO and doing math. Turns out there's a more precise way to figure out where the spindle is and where to move it; you use the internal Axis Resolution. So, my math is based on where I wanted to go in inches, utilizing the appropriate Axis Resolution accordingly.
The code is fairly well organized, and I tried to move all variables to a single section near the top, but there are extra functions that I don't call right now, but may in the future; this file being a prototype for KFlop machine movement of sorts.
Well, I tried to paste the code in the comment window, and it looks like this maxes out the description pane. So instead, I've uploaded the file to my personal site. Grab it from there. [ Ссылка ].
Cheers,
Jeremy
Ещё видео!