DoHomeIndexFunction debounce time
Posted: Tue Mar 31, 2026 5:09 pm
Hi Tom,
we have some problem during axis homing.
It often happens, but only on one axis, that during the dog switch search phase, the axis stops searching before actually finding it and zeros in the wrong place.
I'm worried that it might be due to some noise picked up by the sensor cable.
As a zero function we are using the standard version found in the examples. (HomeIndexFunction.c)
Considering the define "DEBOUNCE_VAL 150", how can I calculate the duration in actual time for the value of 150?
int DoHomeIndexFunction(int axis, // axis number to home
float speed, // speed to move toward home
int dir, // direction to move toward home (+1 or -1)
int Dogbit, // Dog bit number to watch for (use -1 for none)
int Dogpolarity, // Dog polarity to wait for (1 or 0)
float indexspeed, // speed to move while searching for index
int indexbit, // index bit number to watch for (use -1 for none)
int indexpolarity, // index polarity to wait for (1 or 0)
float offset, // amount to move inside limits
float Set_New_Pos) // Set New Position
{
printf("Dogbit - %d \nDogpolarity - %d\nindexbit %d\nindexbitpola %d\n", Dogbit, Dogpolarity, indexbit, indexpolarity);
printf("ofs - %f \nnewpos - %f\n", offset, Set_New_Pos);
printf("speed - %f \nindex - %f\n", speed, indexspeed);
//return 1;
if (Dogbit != -1) // limit bit specified?
{
#define DEBOUNCE_VAL 150
int debounce=DEBOUNCE_VAL;
// search for dog
Jog(axis, speed * -dir); // jog slowly in opposite dir
while (1) // loop until Limit bit goes to specified polarity
{
if(ReadBit(Dogbit) != Dogpolarity)
debounce=DEBOUNCE_VAL;
else
debounce--;
if(debounce==0)break;
if (!chan[axis].Enable) return 1; // abort/exit if disabled
}
// release dog
Jog(axis, indexspeed * dir); // jog slowly in opposite dir
while (1) // loop until Limit bit goes to specified polarity
{
if(ReadBit(Dogbit) == Dogpolarity)
debounce=DEBOUNCE_VAL;
else
debounce--;
if(debounce==0)break;
if (!chan[axis].Enable) return 1; // abort/exit if disabled
}
}
.........
Thanks for your suggestion.
Roberto
we have some problem during axis homing.
It often happens, but only on one axis, that during the dog switch search phase, the axis stops searching before actually finding it and zeros in the wrong place.
I'm worried that it might be due to some noise picked up by the sensor cable.
As a zero function we are using the standard version found in the examples. (HomeIndexFunction.c)
Considering the define "DEBOUNCE_VAL 150", how can I calculate the duration in actual time for the value of 150?
int DoHomeIndexFunction(int axis, // axis number to home
float speed, // speed to move toward home
int dir, // direction to move toward home (+1 or -1)
int Dogbit, // Dog bit number to watch for (use -1 for none)
int Dogpolarity, // Dog polarity to wait for (1 or 0)
float indexspeed, // speed to move while searching for index
int indexbit, // index bit number to watch for (use -1 for none)
int indexpolarity, // index polarity to wait for (1 or 0)
float offset, // amount to move inside limits
float Set_New_Pos) // Set New Position
{
printf("Dogbit - %d \nDogpolarity - %d\nindexbit %d\nindexbitpola %d\n", Dogbit, Dogpolarity, indexbit, indexpolarity);
printf("ofs - %f \nnewpos - %f\n", offset, Set_New_Pos);
printf("speed - %f \nindex - %f\n", speed, indexspeed);
//return 1;
if (Dogbit != -1) // limit bit specified?
{
#define DEBOUNCE_VAL 150
int debounce=DEBOUNCE_VAL;
// search for dog
Jog(axis, speed * -dir); // jog slowly in opposite dir
while (1) // loop until Limit bit goes to specified polarity
{
if(ReadBit(Dogbit) != Dogpolarity)
debounce=DEBOUNCE_VAL;
else
debounce--;
if(debounce==0)break;
if (!chan[axis].Enable) return 1; // abort/exit if disabled
}
// release dog
Jog(axis, indexspeed * dir); // jog slowly in opposite dir
while (1) // loop until Limit bit goes to specified polarity
{
if(ReadBit(Dogbit) == Dogpolarity)
debounce=DEBOUNCE_VAL;
else
debounce--;
if(debounce==0)break;
if (!chan[axis].Enable) return 1; // abort/exit if disabled
}
}
.........
Thanks for your suggestion.
Roberto