diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index f1cd022..2ea4309 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -42,7 +42,7 @@ AXES();]]> @@ -83,7 +83,7 @@ END_IF]]> // This ACT will restore the position of an incremental axis on startup with the act position it read before losing power. // It checks the type of axis, 0=incremental, and that the axis was stationary at shut down. // Because 0 equates to incremental we also need to check that the data is valid, otherwise by default it would restore all axes. -// By default an axis will not restore the position unless it is set to opt-in, i.e. gvl.axes[GVL.iAxis].config.eRestorePosition is non-zero. +// By default an axis will not restore the position unless it is set to opt-in, i.e. gvl.aAxes[GVL.iAxis].config.eRestorePosition is non-zero. // This needs to be initialised somewhere in TwinCAT code otherwise it will not be available at start up. // A restore will only be performed on a loss of power, this code shouldn't make any changes on a reset cold, a rest origin or a download. // There is a enum to allow for different types of restore modes, currently only one is implemented. @@ -104,7 +104,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN // Result stored in Value, 0=Inc 1=Abs, execute set during the case statement FOR GVL.iAxis:= 1 TO gvl_app.nAxisNum DO aFbReadEncRefSys[GVL.iAxis]( - Axis := gvl.axes[GVL.iAxis].Axis, + Axis := gvl.aAxes[GVL.iAxis].Axis, Enable := bExecuteReadEncRefSys, ParameterNumber := MC_AxisParameter.AxisEncoderReferenceSystem, Value=>, @@ -114,7 +114,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN // Cycle through set position function blocks for each axis FOR GVL.iAxis:= 1 TO gvl_app.nAxisNum DO aFbRestorePosition[GVL.iAxis]( - Axis := gvl.axes[GVL.iAxis].Axis, + Axis := gvl.aAxes[GVL.iAxis].Axis, Execute := , Position := axesPersistent[GVL.iAxis].iPositionAtShutdown); END_FOR @@ -159,7 +159,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN // Execute position restore by setting aFbRestorePosition.execute = TRUE FOR GVL.iAxis:= 1 TO gvl_app.nAxisNum DO IF aFbReadEncRefSys[GVL.iAxis].Valid = TRUE AND aFbReadEncRefSys[GVL.iAxis].Value = 0 AND NOT(axesPersistent[GVL.iAxis].bMovingAtShutdown) THEN - IF GVL.axes[GVL.iAxis].config.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN + IF GVL.aAxes[GVL.iAxis].config.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN aFbRestorePosition[GVL.iAxis].Execute := TRUE; END_IF END_IF @@ -172,7 +172,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN // bPositionRestoreDone will never get set to TRUE and will take up cycle time FOR GVL.iAxis:= 1 TO gvl_app.nAxisNum DO IF aFbReadEncRefSys[GVL.iAxis].Valid = TRUE AND aFbReadEncRefSys[GVL.iAxis].Value = 0 AND NOT(axesPersistent[GVL.iAxis].bMovingAtShutdown) THEN - IF GVL.axes[GVL.iAxis].config.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN + IF GVL.aAxes[GVL.iAxis].config.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN IF NOT aFbRestorePosition[GVL.iAxis].Done THEN RETURN; END_IF @@ -195,13 +195,13 @@ END_IF]]> 0 THEN + axesPersistent[GVL.iAxis].iPositionAtShutdown := gvl.aAxes[GVL.iAxis].Axis.NcToPlc.ActPos; + IF gvl.aAxes[GVL.iAxis].Axis.NcToPlc.ActVelo <> 0 THEN axesPersistent[GVL.iAxis].bMovingAtShutdown := TRUE; ELSE axesPersistent[GVL.iAxis].bMovingAtShutdown := FALSE; END_IF - axesPersistent[GVL.iAxis].bMovingAtShutdown := axesPersistent[GVL.iAxis].bMovingAtShutdown OR gvl.axes[GVL.iAxis].Axis.Status.Moving; + axesPersistent[GVL.iAxis].bMovingAtShutdown := axesPersistent[GVL.iAxis].bMovingAtShutdown OR gvl.aAxes[GVL.iAxis].Axis.Status.Moving; END_FOR]]> diff --git a/solution/tc_project_app/Test/common/FB_tcUNIT_common.TcPOU b/solution/tc_project_app/Test/common/FB_tcUNIT_common.TcPOU index 8aaea1c..f0b73e6 100644 --- a/solution/tc_project_app/Test/common/FB_tcUNIT_common.TcPOU +++ b/solution/tc_project_app/Test/common/FB_tcUNIT_common.TcPOU @@ -15,7 +15,7 @@ VAR_INPUT iAxisIndex: INT; // The idex of the axis to action the method on. END_VAR]]> - + @@ -24,7 +24,7 @@ VAR_INPUT iAxisIndex: INT; // The idex of the axis to action the method on. END_VAR]]> - + @@ -36,17 +36,17 @@ END_VAR]]> +GVL.aAxes[iAxisIndex].config.fVelocity := tcUNIT_GVL.fDEFAULT_TARGET_VELOCITY; +GVL.aAxes[iAxisIndex].config.fAcceleration := tcUNIT_GVL.fDEFAULT_TARGET_ACCELERATION; +GVL.aAxes[iAxisIndex].config.fDeceleration := tcUNIT_GVL.fDEFAULT_TARGET_DECCELERATION; +GVL.aAxes[iAxisIndex].config.fOverride := tcUNIT_GVL.fDEFAULT_TARGET_OVERRIDE; +GVL.aAxes[iAxisIndex].config.fPosition := tcUNIT_GVL.fDEFAULT_POSITION;]]> @@ -63,16 +63,16 @@ END_VAR]]> +GVL.aAxes[iAxisIndex].config.fVelocity := fTargetVelocity; +GVL.aAxes[iAxisIndex].config.fAcceleration := fTargetAcceleration; +GVL.aAxes[iAxisIndex].config.fDeceleration := fTargetDeceleration; +GVL.aAxes[iAxisIndex].config.fPosition := fTargetPosition;]]> @@ -84,35 +84,34 @@ END_VAR]]> +GVL.aAxes[iAxisIndex].inputs.bLimitBwd := FALSE; +GVL.aAxes[iAxisIndex].inputs.bLimitFwd := FALSE; +GVL.aAxes[iAxisIndex].inputs.bHomeSensor := FALSE;]]> @@ -132,7 +131,7 @@ GVL.axes[iAxisIndex].inputs.bHomeSensor := FALSE;]]> - + diff --git a/solution/tc_project_app/Test/standard_library_tests/FB_Axis_TEST.TcPOU b/solution/tc_project_app/Test/standard_library_tests/FB_Axis_TEST.TcPOU index a5d70eb..68dff0b 100644 --- a/solution/tc_project_app/Test/standard_library_tests/FB_Axis_TEST.TcPOU +++ b/solution/tc_project_app/Test/standard_library_tests/FB_Axis_TEST.TcPOU @@ -6,7 +6,7 @@ FUNCTION_BLOCK FB_Axis_TEST EXTENDS tcUnit.FB_TestSuite VAR fbCommon: FB_tcUNIT_common; - iTargetAxis: INT := 1; // The of the axis within GVL.axes[] to test against. + iTargetAxis: INT := 1; // The of the axis within GVL.aAxes[] to test against. END_VAR]]> nMaxCycles OR ExpectedResult = Result THEN AssertEquals(Expected := ExpectedResult, @@ -62,14 +62,14 @@ END_VAR]]> // a previous test. Therefore if we execute a move we should just check it's moved // from the initial location not some initial default. -InitialValue := GVL.axes[iTargetAxis].config.fPosition; +InitialValue := GVL.aAxes[iTargetAxis].config.fPosition; ExpectedResult := InitialValue + 10; -GVL.axes[iTargetAxis].config.fPosition := ExpectedResult; +GVL.aAxes[iTargetAxis].config.fPosition := ExpectedResult; -GVL.axes[iTargetAxis].control.eCommand := E_MotionFunctions.MoveAbsolute; -GVL.axes[iTargetAxis].control.bExecute := TRUE; +GVL.aAxes[iTargetAxis].control.eCommand := E_MotionFunctions.MoveAbsolute; +GVL.aAxes[iTargetAxis].control.bExecute := TRUE; -Result := GVL.axes[iTargetAxis].status.fActPosition; +Result := GVL.aAxes[iTargetAxis].status.fActPosition; IF nCycle > nCycleMax OR ExpectedResult = Result THEN AssertEquals(Expected := ExpectedResult, @@ -96,7 +96,7 @@ END_VAR]]> ExpectedResult := tcUNIT_gvl.fDEFAULT_TARGET_ACCELERATION; fbCommon.mPrepareDefaultMove(iTargetAxis); -Result := GVL.axes[1].config.fAcceleration; +Result := GVL.aAxes[1].config.fAcceleration; AssertEquals(Expected := ExpectedResult, Actual := Result, @@ -119,9 +119,9 @@ END_VAR]]> // example of test that requires multiple cycles to complete. Due to stateful behaviour of the axis structure. ExpectedResult := TRUE; -GVL.axes[1].control.bEnable := ExpectedResult; +GVL.aAxes[1].control.bEnable := ExpectedResult; -Result := GVL.axes[iTargetAxis].status.bEnabled; +Result := GVL.aAxes[iTargetAxis].status.bEnabled; IF nCycle > nMaxCycles OR ExpectedResult = Result THEN AssertEquals(Expected := ExpectedResult, @@ -148,11 +148,11 @@ END_VAR]]> // Example of using a tcUNIT assert for a specific type (in this case LREAL). -InitialValue := GVL.axes[iTargetAxis].config.fVelocity; +InitialValue := GVL.aAxes[iTargetAxis].config.fVelocity; ExpectedResult := InitialValue + 0.5; -GVL.Axes[iTargetAxis].config.fVelocity := ExpectedResult; +GVL.aAxes[iTargetAxis].config.fVelocity := ExpectedResult; -Result := GVL.axes[iTargetAxis].config.fVelocity; +Result := GVL.aAxes[iTargetAxis].config.fVelocity; AssertEquals_LREAL(Expected := ExpectedResult, Actual := Result, @@ -176,9 +176,9 @@ END_VAR]]> ExpectedResult := TRUE; -GVL.axes[iTargetAxis].inputs.bLimitFwd := TRUE; +GVL.aAxes[iTargetAxis].inputs.bLimitFwd := TRUE; -Result := GVL.axes[iTargetAxis].status.bFwEnabled; +Result := GVL.aAxes[iTargetAxis].status.bFwEnabled; IF nCycle > nMaxCycles OR ExpectedResult = Result THEN AssertEquals(Expected := ExpectedResult, diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index 8edeaa8..d39ddf2 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit 8edeaa86c4b19d466f1a88548399a19014200c2c +Subproject commit d39ddf23118492488719d676239f547530510d0c