I have done a bit of search here, Google and the Yahoo group and I seem to be missing some thing.
Here are my system specs,
I have separate limit/home switches at both ends of travel all all 3 axis. These are wired in the OPTI-IN of a Kanalog board.
This is on a mill. My drives are controlled by step/dir signals and the loop is closed at the drives (not sure this really matters).
I'm using Mach3 for my control software. As of right now I can jog and run g-code with no problems.
I'm having trouble seeing how to get Mach3/kflop to home my machine.
Lets start with getting Mach3 to pass the homing call to Kflop. In my searching I found reference to this page Mach3 Plugin Enoder Setup which states that I need to modify the ref x/y/z buttons in Mach3. Only differences that I see between my button configs and the pics in the above link is the OEM code#. Mine are set on 22, 23, 24. The above link has them set for 1022, 1023, 1024, I assume this is what I need to change. It's not clear on that page what actually needs to be changed.
I didn't find any information on what may need to be done with the 'Ref all' button in Mach. My best guess is I leave this one alone since it looks like it just "pushes" the ref x/y/z buttons for me.
Now on to the c program.
I have been studying SimpleHome3Axis.c and HomeMach3.c, it has been a while since I have done any type of programming but its starting to come back. Below is how I think my c program should look.
Note I'm only working on the the z-axis. Figure I get that one working and the others are going to be really easy to set up.
Couple of questions on some of the code.
Jog(2,100); // So this reads jog axis number 2 (Z-axis) at 100 counts/second? If this jogs the wrong way do I just change the 100 to a negative number?
while (!ReadBit(10)) // I think the '10' in this statements needs to be changed to the input number that I have the home switch connected too.
Move(2,-1000.0); // Is the -1000.0 the number of encoder counts the motor is suppose to move? I would like 0.1" back off from the home switch, I have 10,000 counts/inch so it looks like the -1000.0 would be the correct number.
Thanks
-Wes
Code:
#include "KMotionDef.h"
//Plugin calls for Mach3 Home (actually Purge) Commands
main()
{
int flags = persist.UserData[5]; // Mach3 flags bit0=X, bit1=Y, Bit2=Z, etc...
printf("Mach3 Home Call, flags = %d\n",flags);
if (flags==1)
{
// do x homing here
}
if (flags==2)
{
// do y homing here
}
if (flags==4)
{
// Z-axis Homing
int SaveZLimits; //place to save limit switch settings
DisableAxis(2); // Disable Z axis
// I don't have access to my axis parameters right now.
// My machine is at my dads house, I know what needs to go here.
// Set the axis parameters here
// after everything is configured in the KMotion Screens
// use copy C Code to clipboard on the configuration screen
// then paste here. Repeat for each axis
SaveZLimits = ch2->LimitSwitchOptions; // save how the limit is set
ch2->LimitSwitchOptions = 0; // disable the limit
EnableAxis(2); // enable Z axes and begin servoing where we are
// jog z-axis until it sees the limit
Jog(2,100); // jog slowly positive
while (!ReadBit(10)) ; // loop until IO bit goes high
Jog(2,0); // stop
while (!CheckDone(2)) ; // loop until motion completes
DisableAxis(2); // disable the axis
Zero(2); // Zero the position
EnableAxis(2); // re-enable the ServoTick
Move(2,-1000.0); // move some amount inside the limits
while (!CheckDone(2)) ; // loop until motion completes
ch2->LimitSwitchOptions = SaveZLimits; // restore limit settings
}
printf("Done\n");
}
Similar Threads: