MBP-247: Position Recovery Improvements #17
Conversation
aslanliafichev
commented
Mar 6, 2026
- Check that position, encoder position bias are saved after a power failure.
- Check that we timestamp the power failure and startup of the CPU.
- At startup check that axises are calibrated and initliazed correctly.
Incorporate eRestoreWithoutHome in RESTORE_POSITIONS() action.
Check that BUSY bit is false, before the check of the DONE bit is made.
| //0 'DontRestore' | ||
| //1 'RestoreWithoutHome' -restores the position using a set position fb and does not set the home bit in the axis struct. | ||
| //1 'RestoreWithoutHome' - Restores the position using a set position fb and does not set the home bit in the axis struct. | ||
| //2 ''RestoreWithHome' - Restores the position using a set position fb and does set the home bit in the axis struct. |
There was a problem hiding this comment.
Please remove the extra apostrophe before ''RestoreWithHome'
| afbSetPosition[iAxes].Execute := FALSE; | ||
| eStartUp := eExecuteRestore; | ||
| RETURN; | ||
| END_IF |
There was a problem hiding this comment.
Check the identation after the line 278, as the following 2 IF statements have different identations, but they should use the same one
| <Implementation> | ||
| <ST><![CDATA[fbSystemTime(timeLoDW => timeAsFileTime.dwLowDateTime, timeHiDW => timeAsFileTime.dwHighDateTime); | ||
| timeAsDT := FILETIME_TO_DT(timeAsFileTime); | ||
|
|
There was a problem hiding this comment.
fbSystemTime uses the function block GETSYSTEMTIME, probably would be better to use the newer function F_GetSystemTime(), as it is stated on Infosys Beckhoff
This function block is replaced by the newer function F_GetSystemTime(), which only needs one return value, not two.
You also probably dont need the extra variable, and it will be a oneliner so you dont even need the SYSTEM_TIME action either.
Make the timestamping a one-liner, instead of an action.
MC_SetPosition is replaced by MC_Home, thus it sets the home position to actual position and the calibration flag.
Changed solution to loop using the iCurrentAxis index, and incrementing if position restore was properly executed or if axis was not initialized properly or if axis was not homed before power failure.
Changed encoder reference to be constants, for better readability.
Always restore position despite an axis not being initilized or homed during shutdown.
For incremental encoders the moving status of the axis cannot be determined before a power failure, therefore the position of the axis is sampled every 5 seconds with a difference limit of 0.001 mm. These values can be changed.
Cleanup of the execution logic for restore position action.
|
Please review the latest changes to the position recovery improvements. Overall the following changes have been made:
|
Change to correct naming for TON-timers and time.
MBP-247: Adjust execution logic to match E_RestorePosition changes.