pcdshub / lcls-twincat-motion

TwinCAT 3 Motion Control Utilities - PLC Motion Library for all PCDS Applications
https://pcdshub.github.io/lcls-twincat-motion
Other
35 stars 20 forks source link

ENH: Relative encoder support (homing, saving) #108

Closed ZLLentz closed 4 years ago

ZLLentz commented 4 years ago

Implements the following:

I'm going to do a writeup here and include much of the information that follows in the README.

To activate a homing routing, put 1 to the EPICS ~.HOMF or .HOMR fields. As far as the TwinCAT program is concerned, these both mean the same thing: "home using our internal configuration".~ :PLC:bHomeCmd PV.

To configure a homing routine, set the fHomePosition variable to the position to use after homing, and set the nHomingMode variable to pick a strategy. These strategies are stored in ENUM_EpicsHomeCmd enum. All homing motion strategies move towards their destinations using the "Homing Velocity (towards plc cam)" parameter , then off of the switch using the "Homing velocity (off plc cam)" parameter. The normal options are:

There are two additional special-case options:

If the homing strategy is set to any value other than None, the library knows we have a motor that wants save/restore. In these cases, the last position of the motor will be saved on TwinCAT shutdown and restored on the first cycle of the PLC program. This prevents the location of your relatively encoded motor from being lost when the PLC is reconfigured.

ZLLentz commented 4 years ago

I've addressed Ken's comments, I will re-test for a bit, call this done, and then continue to hope for our Travis funding to exist.

ZLLentz commented 4 years ago

I thought this was going to be done, but it seems like the motor record HOMF/HOMR do some... odd things, like setting the VAL field, and ask for extra moves to specific positions. I didn't notice these until I started modifying pcdsdevices to get a typhos screen going. Rather than debug that rabbit hole I'm going to redo this a tiny bit to work off of an auxiliary PV to trigger the homing.

ZLLentz commented 4 years ago

This now works very well in my test setup! There were a few remaining edge cases related to the motor record status. I've made the fixes so that now:

ZLLentz commented 4 years ago

Any more thoughts before I merge? @klauer @slacAWallace @ghalym

ZLLentz commented 4 years ago

have to decide how we'll support these two versions

Right, that's annoying. I was planning to update the LFE/KFE/TMO plcs at PAMM, but that doesn't guarantee that everything is handled.

ZLLentz commented 4 years ago

I'm going to merge this now