From ad1f60a92db15480651b568a05f881dab9774f51 Mon Sep 17 00:00:00 2001 From: Markus Kristensson Date: Tue, 11 Nov 2025 08:46:47 +0100 Subject: [PATCH 1/8] MBP-247: Extend E_RestorePosition Adds an additional restore position state to E_RestorePosition. --- DUTs/E_RestorePosition.TcDUT | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DUTs/E_RestorePosition.TcDUT b/DUTs/E_RestorePosition.TcDUT index 9f96adfd..088f598f 100644 --- a/DUTs/E_RestorePosition.TcDUT +++ b/DUTs/E_RestorePosition.TcDUT @@ -6,7 +6,8 @@ TYPE E_RestorePosition : ( eDontRestore :=0, - eRestoreWithoutHome := 1 //Redefined the position of the axis to that when the power was lost + eRestoreWithoutHome := 1, //Redefine the position of the axis to that when the power was lost + eRestoreWithHome := 2 //Redefine the position of the axis to that when the power was lost and home ); END_TYPE ]]> From a28bb3cd0aadafbd763702b8f1acb41cace51498 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Fri, 6 Mar 2026 12:23:39 +0100 Subject: [PATCH 2/8] MBP-247: Add persistent time variable in the GVL Add persistent variable in the GVL to store the current date and time at shutdown. --- DUTs/Axis_Structures/ST_SwitchInfo.TcDUT | 4 ++-- GVLs/GVL.TcGVL | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/DUTs/Axis_Structures/ST_SwitchInfo.TcDUT b/DUTs/Axis_Structures/ST_SwitchInfo.TcDUT index 3c1b831d..ba547a77 100644 --- a/DUTs/Axis_Structures/ST_SwitchInfo.TcDUT +++ b/DUTs/Axis_Structures/ST_SwitchInfo.TcDUT @@ -1,6 +1,6 @@  - + - + \ No newline at end of file diff --git a/GVLs/GVL.TcGVL b/GVLs/GVL.TcGVL index ba332f53..40d5f1e4 100644 --- a/GVLs/GVL.TcGVL +++ b/GVLs/GVL.TcGVL @@ -25,6 +25,7 @@ END_VAR VAR_GLOBAL PERSISTENT astAxesPersistent: ARRAY [1..GVL_APP.nAXIS_NUM] OF ST_AxisPersistent; + timeAtShutdownPersistent : DT; //Date and time when the CPU was powered off END_VAR ]]> From 5824a599afbc086663d06f1e572f3b707b8b255d Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Fri, 6 Mar 2026 12:41:49 +0100 Subject: [PATCH 3/8] MPB-247: Fix whitespace --- GVLs/GVL.TcGVL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GVLs/GVL.TcGVL b/GVLs/GVL.TcGVL index 40d5f1e4..b532928f 100644 --- a/GVLs/GVL.TcGVL +++ b/GVLs/GVL.TcGVL @@ -25,7 +25,7 @@ END_VAR VAR_GLOBAL PERSISTENT astAxesPersistent: ARRAY [1..GVL_APP.nAXIS_NUM] OF ST_AxisPersistent; - timeAtShutdownPersistent : DT; //Date and time when the CPU was powered off + timeAtShutdownPersistent: DT; //Date and time when the CPU was powered off END_VAR ]]> From 7334d3b5bb2ebd9c460609032a5c2f365e43f70d Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Thu, 26 Mar 2026 08:28:40 +0100 Subject: [PATCH 4/8] MBP-247: Add persistent variable Add homing status of axis before shutdown. --- DUTs/Axis_Structures/ST_AxisPersistent.TcDUT | 1 + DUTs/E_RestorePosition.TcDUT | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/DUTs/Axis_Structures/ST_AxisPersistent.TcDUT b/DUTs/Axis_Structures/ST_AxisPersistent.TcDUT index 85b947e7..740bce4e 100644 --- a/DUTs/Axis_Structures/ST_AxisPersistent.TcDUT +++ b/DUTs/Axis_Structures/ST_AxisPersistent.TcDUT @@ -7,6 +7,7 @@ STRUCT fPositionAtShutdown: LREAL; //Position of the axis when the CPU was powered off fEncoderBiasAtShutdown: LREAL; //Encoder bias value when the CPU was powered off bMovingAtShutdown: BOOL; //Indicates if the axis was moving during the shutdown (True if moving, false otherwise) + bHomedAtShutdown: BOOL; //Homing status of the axis when the CPU was powered off END_STRUCT END_TYPE ]]> diff --git a/DUTs/E_RestorePosition.TcDUT b/DUTs/E_RestorePosition.TcDUT index 088f598f..459e6da7 100644 --- a/DUTs/E_RestorePosition.TcDUT +++ b/DUTs/E_RestorePosition.TcDUT @@ -6,8 +6,8 @@ TYPE E_RestorePosition : ( eDontRestore :=0, - eRestoreWithoutHome := 1, //Redefine the position of the axis to that when the power was lost - eRestoreWithHome := 2 //Redefine the position of the axis to that when the power was lost and home + eRestoreWithoutHome := 1, //Restores the position of the axis to that when the power was lost + eRestoreWithHome := 2 // Restores the position of the axis to that when the power was lost and sets the home position to the restored position ); END_TYPE ]]> From 08a6735d9bebe4e4a33405f2f193f20e7833f806 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Tue, 7 Apr 2026 08:47:34 +0200 Subject: [PATCH 5/8] MBP-247: Extend restore position --- DUTs/E_RestorePosition.TcDUT | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/DUTs/E_RestorePosition.TcDUT b/DUTs/E_RestorePosition.TcDUT index 459e6da7..4d6cb5de 100644 --- a/DUTs/E_RestorePosition.TcDUT +++ b/DUTs/E_RestorePosition.TcDUT @@ -5,9 +5,10 @@ {attribute 'strict'} TYPE E_RestorePosition : ( - eDontRestore :=0, - eRestoreWithoutHome := 1, //Restores the position of the axis to that when the power was lost - eRestoreWithHome := 2 // Restores the position of the axis to that when the power was lost and sets the home position to the restored position + eDontRestore := 0, + eRestoreWithoutHome := 1, //Restores the position of the axis to that when the power was lost (incremental) + eRestoreWithHome := 2, // Restores the position of the axis to that when the power was lost and sets the home calibration flag (incremental) + eRestorePositionBias := 3 //Restores position bias (absolute) ); END_TYPE ]]> From 79ccffa71c3a1c2b03542156b697e3bb075e4cfb Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Tue, 7 Apr 2026 08:48:13 +0200 Subject: [PATCH 6/8] MBP-247: Extend ST_AxisPersistent ST_AxisPersistent is extended to include axis status variables to be saved before power failure. --- DUTs/Axis_Structures/ST_AxisPersistent.TcDUT | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/DUTs/Axis_Structures/ST_AxisPersistent.TcDUT b/DUTs/Axis_Structures/ST_AxisPersistent.TcDUT index 740bce4e..0bcb3519 100644 --- a/DUTs/Axis_Structures/ST_AxisPersistent.TcDUT +++ b/DUTs/Axis_Structures/ST_AxisPersistent.TcDUT @@ -8,6 +8,20 @@ STRUCT fEncoderBiasAtShutdown: LREAL; //Encoder bias value when the CPU was powered off bMovingAtShutdown: BOOL; //Indicates if the axis was moving during the shutdown (True if moving, false otherwise) bHomedAtShutdown: BOOL; //Homing status of the axis when the CPU was powered off + bInitialized: BOOL; //Initialized status of the axis when the CPU was powered off + + //Axis status variables + stMotionState: MC_AXISSTATES; + bError: BOOL; + nErrorID: UDINT; + bErrorStop: BOOL; + bStandStill: BOOL; + bHasBeenStopped: BOOL; + bMoving: BOOL; + fPositionDifference: LREAL; + bDisabled: BOOL; + + nCycles: ULINT; //Number of PLC cycles executed before shutdown END_STRUCT END_TYPE ]]> From 49e09a82617f01c04ff904d3c42c319d05828eea Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Tue, 7 Apr 2026 10:41:40 +0200 Subject: [PATCH 7/8] MBP-247: Remove enums E_RestorePosition Remove the enums eRestoreWithHome and eRestoreWithoutHome. --- DUTs/E_RestorePosition.TcDUT | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/DUTs/E_RestorePosition.TcDUT b/DUTs/E_RestorePosition.TcDUT index 4d6cb5de..f6d32d82 100644 --- a/DUTs/E_RestorePosition.TcDUT +++ b/DUTs/E_RestorePosition.TcDUT @@ -6,9 +6,8 @@ TYPE E_RestorePosition : ( eDontRestore := 0, - eRestoreWithoutHome := 1, //Restores the position of the axis to that when the power was lost (incremental) - eRestoreWithHome := 2, // Restores the position of the axis to that when the power was lost and sets the home calibration flag (incremental) - eRestorePositionBias := 3 //Restores position bias (absolute) + eRestorePosition := 1, //Restores the position of the axis to that when the power was lost (incremental) + eRestorePositionBias := 2 //Restores position bias (absolute) ); END_TYPE ]]> From 3a30e01062541a833a77a49e500f66a76115941c Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Tue, 7 Apr 2026 10:48:09 +0200 Subject: [PATCH 8/8] MBP-247: Remove persistent variables Only keep the persistent variables that are required for the position recovery. --- DUTs/Axis_Structures/ST_AxisPersistent.TcDUT | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/DUTs/Axis_Structures/ST_AxisPersistent.TcDUT b/DUTs/Axis_Structures/ST_AxisPersistent.TcDUT index 0bcb3519..c2b15cda 100644 --- a/DUTs/Axis_Structures/ST_AxisPersistent.TcDUT +++ b/DUTs/Axis_Structures/ST_AxisPersistent.TcDUT @@ -8,20 +8,8 @@ STRUCT fEncoderBiasAtShutdown: LREAL; //Encoder bias value when the CPU was powered off bMovingAtShutdown: BOOL; //Indicates if the axis was moving during the shutdown (True if moving, false otherwise) bHomedAtShutdown: BOOL; //Homing status of the axis when the CPU was powered off - bInitialized: BOOL; //Initialized status of the axis when the CPU was powered off - - //Axis status variables - stMotionState: MC_AXISSTATES; - bError: BOOL; - nErrorID: UDINT; - bErrorStop: BOOL; - bStandStill: BOOL; - bHasBeenStopped: BOOL; - bMoving: BOOL; - fPositionDifference: LREAL; - bDisabled: BOOL; - - nCycles: ULINT; //Number of PLC cycles executed before shutdown + bInitializedAtShutdown: BOOL; //Initialized status of the axis when the CPU was powered off + fPositionDifferenceAtShutdown: LREAL; //Position difference between the sampled position and the position at shutdown END_STRUCT END_TYPE ]]>