epics-motor / motorSmarAct

EPICS motor drivers for SmarAct controllers
3 stars 13 forks source link

MCS2 zeroes position on power cycle #10

Open djvine opened 3 years ago

djvine commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

@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.

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