Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devMotorAsyn.c: Set encoder ratio to 1 if ERES is 0 to avoid dividing by 0 #214

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion motorApp/MotorSrc/devMotorAsyn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading