diff --git a/site_ansto/motor_dmc2280.c b/site_ansto/motor_dmc2280.c index 66170e02..e58ed767 100644 --- a/site_ansto/motor_dmc2280.c +++ b/site_ansto/motor_dmc2280.c @@ -109,6 +109,7 @@ typedef struct __MoDriv { pNWTimer airpad_timer; /**< timer waiting for airpad action to complete */ pNWTimer motor_timer; /**< motor off timer */ int debug; + int preseek; /**< Flag = 1 if current move is a backlash preseek */ } DMC2280Driv, *pDMC2280Driv; int DMC2280MotionControl = 1; /* defaults to enabled */ @@ -712,18 +713,24 @@ static int DMC2280RunCommon(pDMC2280Driv self,float fValue){ snprintf(BGx, CMDLEN, "BG%c", axis); target = fValue - self->home; - if (self->backlash_offset > FLT_EPSILON) { - if (target > self->lastPosition) { - target += self->backlash_offset; - if (target > self->fUpper) - target = self->fUpper; + if (self->preseek) + self->preseek = 0; + else { + if (self->backlash_offset > FLT_EPSILON) { + if (target > self->lastPosition) { + self->preseek = 1; + target += self->backlash_offset; + if (target > self->fUpper) + target = self->fUpper; + } } - } - else if (self->backlash_offset < -FLT_EPSILON) { - if (target < self->lastPosition) { - target += self->backlash_offset; - if (target < self->fLower) - target = self->fLower; + else if (self->backlash_offset < -FLT_EPSILON) { + if (target < self->lastPosition) { + self->preseek = 1; + target += self->backlash_offset; + if (target < self->fLower) + target = self->fLower; + } } } @@ -1187,7 +1194,13 @@ static int DMC2280Status(void *pData){ } #endif /* - * When we get here, the motion has completed and we + * When we get here, the motion has completed + */ + if (self->preseek) { + DMC_RunCommon(self, self->fTarget); + return HWBusy; + } + /* and we * must determine when and how to shut off the motor */ if (self->settle) {