diff --git a/motorApp/MotorSrc/devMotorAsyn.c b/motorApp/MotorSrc/devMotorAsyn.c index 79ad5ea88..603f49f8c 100644 --- a/motorApp/MotorSrc/devMotorAsyn.c +++ b/motorApp/MotorSrc/devMotorAsyn.c @@ -174,10 +174,17 @@ static void init_controller(struct motorRecord *pmr, asynUser *pasynUser ) int use_rel = (pmr->rtry != 0 && pmr->rmod != motorRMOD_I && (pmr->ueip || pmr->urip)); int dval_non_zero_pos_near_zero = (fabs(pmr->dval) > rdbd) && (pmr->mres != 0) && (fabs(position * pmr->mres) < rdbd); - epicsFloat64 eratio = pmr->mres / pmr->eres; + epicsFloat64 eratio; int initPos = 0; int status; + /* Don't let the encoder ratio be infinite */ + if (pmr->eres == 0.0) { + eratio = 1.0; + } else { + eratio = pmr->mres / pmr->eres; + } + /* Write encoder ratio to the driver.*/ pPvt->pasynUserSync->reason = pPvt->driverReasons[motorEncRatio]; status = pasynFloat64SyncIO->write(pPvt->pasynUserSync, eratio, pasynUser->timeout);