See the attached document.
Note that I did some testing with that procedure, and I had some trouble when I ran the PLC again with the axis in different positions. There was a problem with the stored home position. I remedied that with some code that used the HomeOffset to compensate for the last stored home position. The code I added is in the two commented out sections here:
open plc Mot5AbsPos
LOCAL Direction //Is the drive set as CW+ or CCW+
/*
local OldHomePos, HomePosDiff, HomeOffsetSetting
HomeOffsetSetting=Motor[5].HomeOffset // Store HomeOffset
Motor[5].HomeOffset=0
OldHomePos=Motor[5].HomePos
*/
Sys.Udata[13] = ecattypedsdo(0,0,1,$4510,$84,0,$4)
sys.Idata[14] = ecattypedsdo(0,0,1,$4510,$85,0,$4)
Direction = ecattypedsdo(0,0,1,$3000,1,0,4)
CALL Timer(0.050)
Motor[5].AbsPosSf = ((2 * Direction) - 1) * Motor[5].PosSf
CALL Timer(0.050)
HOMEZ 5
/*
CALL Timer(0.050)
Motor[5].HomeOffset = HomeOffsetSetting + OldHomePos - Motor[5].HomePos // Restore HomeOffset and add in the change in HomePos
HOMEZ 5
CALL Timer(0.050)
Motor[5].HomeOffset = HomeOffsetSetting // Restore proper setting
*/
DISABLE PLC Mot5AbsPos
CLOSE
Absolute Homing a 1S Drive over EtherCAT.pdf