Thank you Tom for the fast reply!
Sorry it has been some time before getting back to this but other thing just get in the way all the time.
I have decided to take your suggestion of getting an additional Kflop board so that has been ordered and on the way.
I have zip up the Kflop directory from the computer for the K2CNC Water Jet Cutter so anyone willing to look at this would have all the code that goes with all of it.
The funny thing is the KMotionDef.h file was not in this Kflop directory it was in the KMotion431c directory I copied it in to the Kflop directory in the zip file this morning.
Also the Uploads from Kflop 10_27_16.txt file was just done this morning.
Here is the homing code for a signal axis and in this case would be the Z(ch 2) axis.
So what I'm seeing is the encoder is not being zeroed or at least to a hard zero.
From what I'm see is the index_last is being set to a number when the switch changes.
And in is assumed that it is zero.
But I may be way off on that.
Code:
//-------------------------------------------------------------------------
int Home_Single(int axis, int sw, int index, int Multiplier, int nomove)
{
// printf("axis: %d switch: %d\n",axis,sw);
int index_last;
int index_this;
int home_vel = Multiplier * 2000;
int backup_vel = Multiplier * -1000;
int offset;
int SPI; //steps per inch
if (!ReadBit(ESTOP_SW)) return;
Jog(axis, home_vel);
while (!ReadBit(sw)) // wait for switch to change
{
// printf("%d\n",test);
Delay_sec(.001); // little delay for debounce
Home_Abort_If_Needed();
if (CheckDone(axis))
break;
}
Jog(axis,0); // StopMotion
if (!ReadBit(ESTOP_SW)) return;
while(!CheckDone(axis))
;
index_this = ReadBit(index);
index_last = index_last;
Jog(axis, backup_vel); // start moving
while (ReadBit(sw) || (index_this == index_last) ) // wait for switch to change
{
// SetStateBit(46,ReadBit(index));
index_last = index_this;
index_this = ReadBit(index);
Home_Abort_If_Needed();
if (CheckDone(axis))
break;
}
Jog(axis,0); // StopMotion
while (!CheckDone(axis)) ;
Delay_sec(.1);
Zero(axis);
Delay_sec(.1);
///*
SPI=persist.UserData[XSPI + axis];
offset=persist.UserData[XHomeOffset + axis] * SPI / 10000 ; //using axis to chose which offset to USER_INPUT_MODE
//printf("SPI %d\n",SPI); // print the desired speed
//printf("Offset %d\n",offset); // print the desired speed
if ((offset/SPI) < 2 && (offset/SPI) > -2)
{
Home_Abort_If_Needed();
chan[axis].Position = offset;
chan[axis].Dest = offset;
Delay_sec(.1);
if (nomove == 0)
Move(axis,0.0);
}
//*/
//EnableAxisDest(axis,0.0);
persist.UserData[HOMING_PERSIST]&=~(0x01<<axis);
return 1;
}
Cheers and thanks
TomH