From 8433721ea4ce71b33539dba7cf90fc13fc680314 Mon Sep 17 00:00:00 2001 From: Paul Barron Date: Wed, 12 Feb 2020 11:56:26 +0100 Subject: [PATCH] Add check in MAIN.RESTOR_POSITIONS Add check when resetting bRestoreOnStartup flag to only reset if the UPS is OK. Otherwise during a power loss it is set and then reset before getting to the end of the PLC cycle. This was a result of moving some code that was previously in MAIN to an ACT and the RETURN command does not work the same. I believe it only returns from the current act and not the whole code. Originally it was supposed to prevent the rest of the code from executing in the event of a power failure but this is no longer the case. --- solution/tc_project_app/POUs/MAIN.TcPOU | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 458ca9d..b3bbcc1 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -6,6 +6,7 @@ VAR sVersion: STRING:='1.0.0'; i : UINT; //index variable for AXES() aFbAxes: ARRAY [1..gvl_app.axisNum] OF FB_Axis; + hmiAxisSelection : INT:=1; //Not possible to use local hmi variables for array indexes (******Outputs: Power for Limit switches and Home Sensors (every 4th output)********) @@ -158,7 +159,7 @@ END_IF]]> // Note from Beckhoff: "A maximum of 1 MB persistent data can be reliably saved over the entire service life." ///######################################################### -IF bRestoreOnStartup THEN +IF bRestoreOnStartup AND eGlobalSUpsState = eSUPS_PowerOK THEN bRestoreOnStartup:=FALSE; bRestoreExecute:=TRUE; END_IF @@ -273,7 +274,7 @@ END_FOR]]> - +