diff --git a/motor.c b/motor.c index 57175954..b4452f03 100644 --- a/motor.c +++ b/motor.c @@ -689,8 +689,8 @@ static int MotorGetHardPositionImpl(pMotor self, SConnection * pCon, /*---------------------------------------------------------------------------*/ static long MotorRunImpl(void *sulf, SConnection * pCon, float fNew) { - float fHard; - int i, iRet, iCode; + float fHard, fCurrHard, fNewHard, fZero; + int i, iRet, iCode, iSign; char pBueffel[512]; char pError[132]; pMotor self; @@ -709,6 +709,13 @@ static long MotorRunImpl(void *sulf, SConnection * pCon, float fNew) SCSetInterrupt(pCon, eAbortBatch); return 0; } + self->pDriver->GetPosition(self->pDriver, &fCurrHard); + iSign = ObVal(self->ParArray, SIGN); + fZero = ObVal(self->ParArray, SZERO); + fNewHard = iSign * (fNew + fZero); + if (absf(fCurrHard - fNewHard) <= ObVal(self->ParArray, PREC)) { + return OKOK; + } /* check boundaries first */ iRet = MotorCheckBoundaryImpl(self, fNew, &fHard, pError, 131);