I am doing a home routine for various axis following this code for all them:
Code: Select all
ch4->Dest=104.5;
Jog(4,-1); // start moving
while (ReadBit(1032)) ; // wait for switch (input #16) to change
Jog(4,1); // start moving
while (!ReadBit(1032)) ;
Zero(4);
MoveAtVel(4,100,10);
while (!CheckDone(4));
Zero(4);
The problem we detected is that, when the axis is close to the sensor (but the sensor is not active yet) and I call the home routine, the second Jog is ignored and the first Jog continues the movement until the axis hits its phisical limit. This never occurs when the position of the axis is far enough from the sensor, only when the position is near the limit.
We have found a solution using the next code:
Code: Select all
ch4->Dest=104.5;
Jog(4,-1);
while (ReadBit(1032)) ; // wait for switch (input #16) to change
printf("valor %d\n"); //print to control the code
if (ReadBit(1032)== 0)
{
DisableAxis(4); //Disable and enable the axis to stop the movement
EnableAxis(4);
Jog(4,1);
printf("valor %d\n",ReadBit(1032)); //print to control the code
}
printf("valor %d\n");
while (!ReadBit(1032))
{
printf("valor %d\n",ReadBit(1032)); //print to control the code
//Delay_sec(0.3);
}
Zero(4);
MoveAtVel(4,100,10);
while (!CheckDone(4));
Zero(4);
Code: Select all
Jog(4,0)
Code: Select all
Jog(4,1)
I still not sure if this is the best way to solve this, so I post this here to ask for opinions and othe points of view.
Thank you!