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