Hi Tom,
I've writing my probing routine and had a tough time of it. My probe is a switch probe so when it is inactive, input 1 is held to ground.
What I found was the (ReadBit(pin) ^ polarity) logic would return zero at different points, even though the probe was inactive.
The logic works like this:
MoveRelAtVel(axis, dist, vel);
while (ReadBit(pin) ^ polarity) {
if (CheckDone(axis)) {
// Ran distance, no probe trigger
ret = -1;
break;
}
}
What I found that works is I had to add a WaitNextTimeSlice(); statement before I performed a ReadBit command. This code works as I expect:
while(TRUE)
{
if(CheckDone(axis))
{
ret = -1;
break;
}
WaitNextTimeSlice();
if(!(ReadBit(pin) ^ polarity))
{
break;
}
}
Tom, does this make sense that WaitNextTimeSlice() needs to be added? Do I need WaitNextTimeSlice before CheckDone as well?
Eric