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

MCS2 zeroes position on power cycle #10

Open
djvine opened this issue Jun 22, 2021 · 3 comments
Open

MCS2 zeroes position on power cycle #10

djvine opened this issue Jun 22, 2021 · 3 comments

Comments

@djvine
Copy link
Collaborator

djvine commented Jun 22, 2021

When the MCS2 controller is power cycled it resets the position to zero.

Is there a way to have the motor record restore the position on a connect/reconnect event?

Alternatively, is there a flag that indicates a disconnect/reconnect cycle occurred and that the user should rehome the stages?

@kmpeters
Copy link
Contributor

The motor record expects the controller to not be power-cycled while the IOC is running. Autosave (https://github.com/epics-modules/autosave) can restore the position of a motor to a controller that has been power-cycled when the IOC starts.

The motor record doesn't know about the connected state of the asyn port that is used to communicate with the controller. The asynMotor{Controller,Axis} classes don't have a flag that indicates a disconnect/reconnect cycle occured. asynPortDriver does have connect/disconnect methods that could be overridden by the MCS2 driver to add controller-specific reconnect functionality.

I regularly disconnect EPICS IOCs from motor controllers so that I can talk to them with vendor software. How would you distinguish between a user-initiated disconnect and a disconnect because the controller was power-cycled? You wouldn't want to redefine the position if the controller wasn't power-cycled.

@kmpeters
Copy link
Contributor

asyn has exception callbacks:

https://github.com/epics-modules/asyn/blob/64b8a71b9dfbe36e75da03427f151e9b2c7016a9/asyn/asynDriver/asynDriver.h#L128-L130

@MarkRivers, should motor drivers create asyn exception callbacks to handle re-initialization on reconnect from a power-cycle while the IOC is running?

@MarkRivers
Copy link
Contributor

@MarkRivers, should motor drivers create asyn exception callbacks to handle re-initialization on reconnect from a power-cycle while the IOC is running?

Our approach to networked motor controllers at GSECARS is to have each one controlled by its own dedicated IOC running on Linux, so it can be quickly restarted with no side-effects on other devices.

Power-cycling the controller without rebooting the IOC is a fairly complex topic.

  • First, how does asyn detect that there has been a disconnect or reconnect?
    • For serial devices this is not possible at all as far as I know.
    • For Ethernet devices Linux can take hours to finally disconnect a TCP socket automatically when a device is power-cycled.
      • In asyn you can set the option "disconnectOnReadTimeout". Then it will disconnect (close the socket) if a read operation times out.
      • If the asyn "autoConnect" flag is set then it will try to reconnect (create a new socket) every 20 seconds.
      • asyn will call the exception handlers on the disconnect and reconnect events.
  • Second, what should be done on a reconnect event? Does one want to push the position? There is no need to push things like velocity and acceleration because those are sent on every move operation. What about enable/disable torque?

I am currently working on a similar problem for areaDetector. There are 2 problems to solve:

  • Re-establish control of the camera if it is power-cycled. This is driver dependent. 30 minutes ago I got it working with ADAravis.
  • Push the previous settings back to the camera. This can be done with the configMenu software in autosave. For now I am working on having the user manually restore with configMenu. In principle that could be be automated based on detecting a reconnect.

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

No branches or pull requests

3 participants