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

Conversation

kmpeters
Copy link
Member

Set encoder ratio to 1 if ERES is 0 in devMotorAsyn.c to avoid dividing by 0.

Fixes #213

@kmpeters kmpeters requested a review from MarkRivers January 22, 2024 15:04
@kmpeters
Copy link
Member Author

This is a trivial change that doesn't really need a review. I'm trying to get into the habit of keeping people in the loop as changes happen.

@kmpeters kmpeters self-assigned this Jan 22, 2024
@kmpeters kmpeters merged commit 8166246 into master Jan 22, 2024
2 of 3 checks passed
@kmpeters kmpeters deleted the issue213 branch January 22, 2024 15:15
Copy link
Contributor

@tboegi tboegi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a good reason to have a workaround in one driver (asyn)
and not in the motorRecord.cc ?

Somewhere around here :
/* Call device support to initialize itself and the driver */
if (pdset->base.init_record)

@kmpeters
Copy link
Member Author

There is a check for ERES=0 in the motor record already:

if (pmr->eres == 0.0)
{
pmr->eres = pmr->mres;
MARK(M_ERES);
}

I'm not sure why this wasn't sufficient protection in the case of the Gailil controller.

@MarkRivers
Copy link
Member

I think the problem is that the encoder ratio is set in devMotorAsyn::init_controller

eratio = pmr->mres / pmr->eres;
, which is called from devMotorAsyn::init_record
init_controller(pmr, pasynUser);
. But in the motor_record.cc the device support init_record is called
status = (*pdset->base.init_record) (pmr);
before the check for ERES=0
if (pmr->eres == 0.0)

tboegi added a commit to EuropeanSpallationSource/motor that referenced this pull request Jun 27, 2024
Merge 'motor/master' into HEAD:

Update from R7-3-1, plus the latest from the master branch,
up to
    commit 8166246
    Merge: f8a3239 148c943
    Author: Kevin Peterson <[email protected]>
    Date:   Mon Jan 22 09:15:46 2024 -0600
        Merge pull request epics-modules#214 from epics-modules/issue213
        devMotorAsyn.c: Set encoder ratio to 1 if ERES is 0
        to avoid dividing by 0.

Note:
  The ACCS/ACCL/ACCU interaction is similar to the ess-master
  version: writing to ACCS or ACCL sets ACCU.
  This is different to motor/master, where ACCU must be configured
  int the database or changed on demand.

Update the motor version to 7.23:
    This allow test scripts to identify the new features

Conflicts:
    motorApp/MotorSrc/devMotorAsyn.c
    motorApp/MotorSrc/motorRecord.cc
    motorApp/MotorSrc/motorRecord.dbd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Infinite encoder ratio in devMotorAsyn.c if ERES undefined
3 participants