Rework the motor end-of-motion tests when creeping

This commit is contained in:
Douglas Clowes
2013-07-11 17:19:44 +10:00
parent 1a64c0a4a9
commit 1d18fbf646

View File

@@ -606,25 +606,34 @@ static int motCreep(pDMC2280Driv self, double target) {
else if (offset < 0) /* moving down */ else if (offset < 0) /* moving down */
self->creep_val = +1; self->creep_val = +1;
} else { } else {
int iRet = 0;
/* /*
* not first, bump the direction sensitive counters * not first, bump the direction sensitive counters
*/ */
if (self->creep_val > 0) { /* moving down */ if (self->creep_val > 0) { /* moving down */
/* Handle the case of overrunning the target by reversing direction */
if (offset >= 0)
iRet = 1;
++self->creep_val; ++self->creep_val;
} else { } else {
/* Handle the case of overrunning the target by reversing direction */
if (offset <= 0)
iRet = 1;
--self->creep_val; --self->creep_val;
} }
/* /*
* In all repetitive things, there just has to be a limit * In all repetitive things, there just has to be a limit
*/ */
if (abs(self->creep_val) > MAX_CREEP_STEPS && if (abs(self->creep_val) > MAX_CREEP_STEPS) {
abs(self->creep_val) > 2.0 * fabs(self->stepsPerX / self->cntsPerX)) {
if (self->debug) { if (self->debug) {
char line[CMDLEN]; char line[CMDLEN];
snprintf(line, CMDLEN, "Motor=%s creep stopped, stepcount = %d", snprintf(line, CMDLEN, "Motor=%s creep stopped, stepcount = %d",
self->name, self->stepCount); self->name, self->stepCount);
SICSLogWrite(line, eStatus); SICSLogWrite(line, eStatus);
} }
iRet = 1;
}
if (iRet > 0) {
/* /*
* self->preseek remains zero to say we are finished * self->preseek remains zero to say we are finished
*/ */