Skip to content

MBP-247: Position Recovery Improvements - #17

Closed
aslanliafichev wants to merge 35 commits into
masterfrom
aslanl/position-recovery-improvements
Closed

aslanliafichev wants to merge 35 commits into
masterfrom
aslanl/position-recovery-improvements

Conversation

@aslanliafichev

Copy link
Copy Markdown
Collaborator
  1. Check that position, encoder position bias are saved after a power failure.
  2. Check that we timestamp the power failure and startup of the CPU.
  3. At startup check that axises are calibrated and initliazed correctly.

Comment thread solution/tc_project_app/POUs/MAIN.TcPOU Outdated
Comment thread solution/tc_project_app/POUs/MAIN.TcPOU Outdated
Comment thread solution/tc_project_app/POUs/MAIN.TcPOU Outdated
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.
@aslanliafichev

Copy link
Copy Markdown
Collaborator Author

Please review the latest changes to the position recovery improvements. Overall the following changes have been made:

  • As discovered the status of the axis before power failure cannot be confirmed (goes to error stop) which is important to confirm if moving or standstill before power failure for incremental encoders. Furthermore whilst moving before a power failure there is always some positional difference between the sampled position before shutdown and the actual one at startup. Therefore the position of the axis is sampled every 5 seconds this can be changed with a positional difference limit of 0.001 can also be changed. This is only important for incremental encoders.

  • Furthermore status variables has been added to be saved as persistent variables.

  • Also E_RestorePosition still includes the options to RestoreWithHome, which is relevant for incremental encoders, I still believe that this option should be included, as there are cases where the position of an incremental encoder can be recovered accurately ( for exampled disabled or standstill for more than 5 seconds), eRestorePositionBias has also been included as this is the default value for absolute encoders.

Change to correct naming for TON-timers and time.
MBP-247: Adjust execution logic to match E_RestorePosition changes.
Comment thread solution/tc_project_app/POUs/MAIN.TcPOU Outdated
Comment thread solution/tc_project_app/POUs/MAIN.TcPOU Outdated
Comment thread solution/tc_project_app/POUs/MAIN.TcPOU Outdated
Comment thread solution/tc_project_app/POUs/MAIN.TcPOU Outdated
Comment thread solution/tc_project_app/POUs/MAIN.TcPOU Outdated
Comment thread solution/tc_project_app/POUs/MAIN.TcPOU Outdated
Comment thread solution/tc_project_app/POUs/MAIN.TcPOU Outdated
Comment thread solution/tc_project_app/POUs/MAIN.TcPOU Outdated
Comment thread solution/tc_project_app/POUs/MAIN.TcPOU Outdated
Comment thread solution/tc_project_app/POUs/MAIN.TcPOU
The following function blocks have been changed to fb's
fbReadEncRefSys: MC_ReadParameter;
fbSetHomePosition: MC_Home;
fbSetPosition: MC_SetPosition;
fbWritePositionBias: MC_WriteParameter;

To adhere to the solution handling each axis separeatly.
The following afb is still kept as is, as these values needs to be stored
as persistent before shutdown.

afbReadPositionBias: ARRAY [1..GVL_APP.nAXIS_NUM] OF MC_ReadParameter;
Included more steps into the eRestorePositions enum
to handle each edge case for an encoder separatly.
Added error handling for the fbs as well as a retry counter.
Uses encoder reference system to decide restore type.
Keeps only the check for whether restore is needed.
Comment thread solution/tc_project_app/POUs/MAIN.TcPOU Outdated
Comment thread solution/tc_project_app/POUs/MAIN.TcPOU Outdated
@szilard-ess

szilard-ess commented Apr 28, 2026 •

Copy link
Copy Markdown
Collaborator

Tested for various setups, code works as expected.

  1. Absolute + Not Homed + Not Moving = Update Position Bias
  2. Absolute + Not Homed + Moving = Update Position Bias
  3. Absolute + Homed + Not Moving = Update Position Bias
  4. Absolute + Homed + Moving = Update Position Bias
  • Incremental + Not Homed + Not Moving = Update Position
  • Incremental + Not Homed + Moving = Update Position
  • Incremental + Homed + Not Moving = Update Position + Set Calibration Flag
  • Incremental + Homed + Moving = Update Position

In all cases Initialized was TRUE, otherwise no restore occurs.
In Open Loop axis handled as Incremental, position restored accordingly to the saved shutdown variables.

@federrg

federrg commented Jun 17, 2026

Copy link
Copy Markdown
Member

I just noticed that you have doen here What I asked in the other one. Could you just copy paste the info here in teh confluence page and if you seem something can be added or explain more in detail do, if not then just also copy oaste this to the ticket and I will merge both tickets

@federrg

federrg commented Jun 22, 2026 •

Copy link
Copy Markdown
Member

I will close this PR because it does not follow the branch naming convention. I already created a new branch and new PR here:
#25

@federrg federrg closed this Jun 22, 2026
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

Successfully merging this pull request may close these issues.

3 participants