Hi Stig,
I found some minor bugs and will merge them soon. I also made changes for functions that returns values that are tested by the caller to return int instead of void. I don't think testing a void value will always work.
Doesn't this code:
Code:
void FindOutTopLeft()
{
MoveUp(BUFFERDISTANCE);
if (MoveNorth(DISTANCETOMOVE)) return;
if (MoveDown(BUFFERDISTANCE + PROBEDEPTH)) return;
ProbeSouth();
MoveUp(BUFFERDISTANCE + PROBEDEPTH);
Drag the probe up the edge of the stock? ProbeSouth finishes with the probe at the stock. Then it moves up.
Actually simulating I found small deviations because of the probing sequence.
Here is how ProbeSouth finishes:
Code:
Jog(YAXIS, -fSLOWSPEEDY);
printf("Waiting for probe to activate\n");
while (ReadBit(PROBEBIT) != PROBE_ACTIVE);
printf("Stopping\n");
Jog(YAXIS, 0);
printf("Waiting for Y motion to stop\n");
while (!CheckDone(YAXIS));
}
Its moving the probe away from the stock waiting for it to de-activate. Then it does a printf which might delay for a millisecond or so. Then it begins to stop. Then it decelerates to a stop. So the probe is some distance from the stock which varies a small amount based on timings, speeds, acceleration, and jerk. Its a small error but I think we could be more accurate. Maybe you are expecting this to give some clearance to move up?
I found this to be more exact:
Code:
printf("Waiting for probe to activate\n");
while (ReadBit(PROBEBIT) != PROBE_ACTIVE);
Trig = chan[YAXIS].Dest; // save trigger position
printf("Stopping\n");
Jog(YAXIS, 0);
printf("Waiting for Y motion to stop\n");
while (!CheckDone(YAXIS));
printf("Moving Y back to trigger position\n");
Move(YAXIS, Trig);
printf("Waiting for Y motion to stop\n");
while (!CheckDone(YAXIS));
}
As soon as the Probe deactivates it captures the commanded Destination into "Trig" then stops and moves back to where it triggered.
What do you think?