diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 1b367f8..f7387cc 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -1,5 +1,5 @@  - + - eSUPS_PowerFailure THEN + (* next cycles of powerfailure *) + (* skip regular code execution for the remaining cycles of the powerfailure/writing of persistent data/quick shutdown ... *) + RETURN; +END_IF + +PROG(); AXES(); ERROR();]]> @@ -106,8 +130,110 @@ fbEL1808( //]]> + + + + + + + + , + ReadMode:= E_READMODE.READMODE_ONCE); +END_FOR + +FOR i:=1 TO gvl_app.axisNum DO + fbRestorePosition[i]( + Axis:= gvl.axes[i].Axis, + Execute:= , + Position:= iPositionAtShutdown[i]); +END_FOR + +IF bColdstartDone = FALSE THEN + CASE iStartup OF + 0: // First cycle + IF NOT bColdstartDone THEN + iStartup:=iStartup+1; + iretry:=0; + END_IF + 1: // Read Enc Ref Sys - incremental or absolute + bExecuteReadEncRefSys:=TRUE; + iStartup:=iStartup+1; + tmrRetry(in:=FALSE); + 2: // Check if Enc Ref Sys has been read for all axis -> if not read again + tmrRetry(in:=TRUE, pt:=T#100MS); + FOR i:=1 TO gvl_app.axisNum DO + IF fbReadEncRefSys[i].Valid = FALSE THEN + IF tmrretry.Q THEN + bExecuteReadEncRefSys:=FALSE; + iStartup:=iStartup-1; + iRetry:=iRetry+1; + END_IF + RETURN; + ELSE + iStartup:=iStartup+1; + EXIT; + END_IF + END_FOR + 3: // Check if axis is incremental, opt-in/restore home and not moving at shutdown -> if so restore + FOR i:=1 TO gvl_app.axisNum DO + IF fbReadEncRefSys[i].Value=0 AND NOT(bMovingAtShutdown[i]) THEN + IF gvl.axes[i].config.iRestorePosition=2 THEN + gvl.axes[i].config.nHomeSeq:=15; + gvl.axes[i].control.eCommand:=10; + //Doesn't work yet because you can only home to zero position + //gvl.axes[i].config.######:=iPositionAtShutdown[i]; + END_IF + END_IF + END_FOR + iStartup:=iStartup+1; + 4: // Execute position restore with or without bHome set + FOR i:=1 TO gvl_app.axisNum DO + IF fbReadEncRefSys[i].Value = 0 THEN + CASE GVL.axes[i].config.iRestorePosition OF + 1: fbRestorePosition[i].Execute:=TRUE; + 2: gvl.axes[i].control.bExecute:=TRUE; + END_CASE + END_IF + END_FOR + iStartup:=iStartup+1; + 5: // Check set position or direct homing is finished on axes that were opt-in + FOR i:=1 TO gvl_app.axisNum DO + IF fbReadEncRefSys[i].Value = 0 THEN + CASE gvl.axes[i].config.iRestorePosition OF + 1: + IF NOT fbRestorePosition[i].Done THEN + RETURN; + END_IF + 2: + IF NOT gvl.axes[i].status.bHomed THEN + RETURN; + END_IF + END_CASE + END_IF + END_FOR + iStartup:=iStartup+1; + 6: // Reset set position FBs and Finish + FOR i:=1 TO gvl_app.axisNum DO + fbRestorePosition[i].Execute:=FALSE; + END_FOR + bColdstartDone:=TRUE; + END_CASE +END_IF]]> + + + + + @@ -140,5 +266,13 @@ fbEL1808( + + + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index f2b1862..32b87da 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit f2b186273119f71345ff25367b3145b07dfa66f4 +Subproject commit 32b87da57e91d57eaebbf927638554641a37c6b9 diff --git a/solution/tc_project_app/tc_project_app.plcproj b/solution/tc_project_app/tc_project_app.plcproj index 903cef5..6c2d7b0 100644 --- a/solution/tc_project_app/tc_project_app.plcproj +++ b/solution/tc_project_app/tc_project_app.plcproj @@ -308,6 +308,10 @@ Tc2_Standard, * (Beckhoff Automation GmbH) Tc2_Standard + + Tc2_SUPS, * (Beckhoff Automation GmbH) + Tc2_SUPS + Tc2_System, * (Beckhoff Automation GmbH) Tc2_System