diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 4008f18..0485dbc 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -69,7 +69,8 @@ END_IF STARTUP(); PROG(); AXES(); -ERROR();]]> +ERROR(); +SHUTDOWN();]]> @@ -136,7 +137,12 @@ fbEL1808( 0 THEN + bMovingAtShutdown[i]:=TRUE; + ELSE + bMovingAtShutdown[i]:=FALSE; + END_IF + bMovingAtShutdown[i]:=bMovingAtShutdown[i] OR gvl.axes[i].Axis.Status.Moving; END_FOR]]> @@ -145,6 +151,7 @@ END_FOR]]> if busy then continue with PLC cycle and check again next time - // If fbReadEncRefSys not started then go back a step + // Check the encoder reference system has been read for all axis -> if busy then continue with PLC cycle and check again next time. + // If fbReadEncRefSys not started then go back a step. + // If any axes result in an error the code will get stuck here, this happens if gvl_app.axisNum is not set correctly FOR i:=1 TO gvl_app.axisNum DO IF fbReadEncRefSys[i].Valid = FALSE THEN IF fbReadEncRefSys[i].Busy = TRUE THEN // Exit MAIN.STARTUP Action and wait till next cycle, needs to cycle through whole program in order for data to update RETURN; ELSE - // Sometimes the code gets here and the fbReadEncRefSys[i] misses the rising edge. - // If the code gets here it means .valid=FALSE and .busy=FALSE which indicateds the FB probably hasn't started - // and thus needs to see a rising edge. Set execute to low and go back a step in the CASE. + // Sometimes the code gets here and the fbReadEncRefSys[i] misses the rising edge. If the code gets here it means + // .valid=FALSE and .busy=FALSE which indicateds the FB probably hasn't started and thus needs to see a rising edge. + // Set execute to low, Exit MAIN.STARTUP and go back a step in the CASE statement. bExecuteReadEncRefSys:=FALSE; eStartUp:=eStartUp-1; iRetry:=iRetry+1; // counter used for troubleshooting to see how many cycles it takes before fbReadEncRefSys function blocks are read correctly @@ -238,7 +246,7 @@ IF bPositionRestoreDone = FALSE THEN CheckRestore: // Check mode 1: fbRestorePosition or mode 2: direct homing is finished on axes that were opt-in // Nothing actually happens if the restore is not done, the code just returns from here each cycle and the - // bPositionRestoreDone will never get set to TRUE + // bPositionRestoreDone will never get set to TRUE and will take up cycle time FOR i:=1 TO gvl_app.axisNum DO IF fbReadEncRefSys[i].Valid = TRUE AND fbReadEncRefSys[i].Value = 0 THEN CASE gvl.axes[i].config.eRestorePosition OF @@ -271,6 +279,7 @@ END_IF]]> + @@ -305,13 +314,18 @@ END_IF]]> - + + + + + + @@ -339,13 +353,15 @@ END_IF]]> + - + +