diff --git a/solution/solution.tsproj b/solution/solution.tsproj
index 9e5511d..a883408 100644
--- a/solution/solution.tsproj
+++ b/solution/solution.tsproj
@@ -26,7 +26,7 @@
PlcTask Outputs
MAIN.bOutput1
-
+
BOOL
diff --git a/solution/tc_project_app/GVLs/GVL_APP.TcGVL b/solution/tc_project_app/GVLs/GVL_APP.TcGVL
index c284299..a423ad2 100644
--- a/solution/tc_project_app/GVLs/GVL_APP.TcGVL
+++ b/solution/tc_project_app/GVLs/GVL_APP.TcGVL
@@ -7,7 +7,7 @@ VAR_GLOBAL
END_VAR
VAR_GLOBAL CONSTANT
- axisNum : UINT:=0;
+ nAXIS_NUM : UINT:=0;
END_VAR]]>
\ No newline at end of file
diff --git a/solution/tc_project_app/GlobalTextList.TcGTLO b/solution/tc_project_app/GlobalTextList.TcGTLO
index 1818614..21a3034 100644
--- a/solution/tc_project_app/GlobalTextList.TcGTLO
+++ b/solution/tc_project_app/GlobalTextList.TcGTLO
@@ -175,6 +175,11 @@
"fPosition"
+
+ "149"
+ "fRatio"
+
+
"708"
"Free Entries:"
@@ -190,11 +195,26 @@
"gearIn"
+
+ "717"
+ "gearInMultiMaster"
+
+
"300"
"gearOut"
+
+ "566"
+ "homeSensorNeg"
+
+
+
+ "677"
+ "homeSensorPos"
+
+
"711"
"Inactive:"
@@ -235,6 +255,11 @@
"moveVelocity"
+
+ "575"
+ "nIndex"
+
+
"709"
"Overflows:"
diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU
index 8e73b6a..c0a18e8 100644
--- a/solution/tc_project_app/POUs/MAIN.TcPOU
+++ b/solution/tc_project_app/POUs/MAIN.TcPOU
@@ -3,45 +3,35 @@
-
- eSUPS_PowerOK THEN
- (* next cycles of powerfailure *)
- (* skip regular code execution for the remaining cycles of the powerfailure/writing of persistent data/quick shutdown ... *)
+ //next cycles of powerfailure
+ //skip regular code execution for the remaining cycles of the powerfailure/writing of persistent data/quick shutdown...
RETURN;
END_IF]]>
- '0') THEN
CHECK_UPS();
RESTORE_POSITIONS();
@@ -84,137 +74,130 @@ END_IF]]>
-
+
- ,
- ReadMode:= E_READMODE.READMODE_ONCE);
+ //Cycle through function blocks that read the encoder reference system i.e. whether axis is incremental or absolute
+ //Result stored in Value, 0=Inc 1=Abs, execute set during the case statement
+ FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO
+ afbReadEncRefSys[iAxes](
+ Axis := GVL.astAxes[iAxes].Axis,
+ Enable := bExecuteReadEncRefSys,
+ ParameterNumber := MC_AxisParameter.AxisEncoderReferenceSystem,
+ ReadMode := E_READMODE.READMODE_ONCE);
END_FOR
- // Cycle through set position function blocks for each axis
- FOR i:=1 TO gvl_app.axisNum DO
- fbRestorePosition[i](
- Axis:= gvl.axes[i].Axis,
- Execute:= ,
- Position:= axesPersistent[i].iPositionAtShutdown);
+ //Cycle through set position function blocks for each axis
+ FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO
+ afbRestorePosition[iAxes](
+ Axis := GVL.astAxes[iAxes].Axis,
+ Position := astAxesPersistent[iAxes].fPositionAtShutdown);
END_FOR
CASE eStartUp OF
- ColdStart:
- // First cycle of the PLC, do nothing just give one cycle for variables to initialise
+ eColdStart:
+ //First cycle of the PLC, do nothing just give one cycle for variables to initialise
IF NOT bPositionRestoreDone THEN
- eStartUp:= ReadAxisFeedbackType;
- iRetry:=0;
+ eStartUp := eReadAxisFeedbackType;
+ nRetry := 0;
END_IF
- ReadAxisFeedbackType:
- // Exectute the function blocks to read the encoder reference system (0=inc OR 1=ABS)
- bExecuteReadEncRefSys:=TRUE;
- eStartUp:=CheckReadDone;
+ eReadAxisFeedbackType:
+ //Exectute the function blocks to read the encoder reference system (0=inc OR 1=ABS)
+ bExecuteReadEncRefSys := TRUE;
+ eStartUp := eCheckReadDone;
- CheckReadDone:
- // 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
+ eCheckReadDone:
+ //Check the encoder reference system has been read for all axis -> if busy then continue with PLC cycle and check again next time.
+ //If afbReadEncRefSys 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.nAxisNum is not set correctly
+ FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO
+ IF afbReadEncRefSys[iAxes].Valid = FALSE THEN
+ IF afbReadEncRefSys[iAxes].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, Exit MAIN.STARTUP and go back a step in the CASE statement.
- bExecuteReadEncRefSys:=FALSE;
- eStartUp:=ReadAxisFeedbackType;
- iRetry:=iRetry+1; // counter used for troubleshooting to see how many cycles it takes before fbReadEncRefSys function blocks are read correctly
+ //Sometimes the code gets here and the afbReadEncRefSys[iAxes] 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 := eReadAxisFeedbackType;
+ nRetry := nRetry + 1; //counter used for troubleshooting to see how many cycles it takes before afbReadEncRefSys function blocks are read correctly
RETURN;
END_IF
END_IF
END_FOR
- // If the code gets here all axes either have .valid=TRUE for all axes
- eStartUp:= ExecuteRestore;
+ //If the code gets here all axes either have .valid=TRUE for all axes
+ eStartUp := eExecuteRestore;
- ExecuteRestore:
- // Execute position restore by setting fbRestorePosition.execute = TRUE
- FOR i:=1 TO gvl_app.axisNum DO
- IF fbReadEncRefSys[i].Valid = TRUE AND fbReadEncRefSys[i].Value = 0 AND NOT(axesPersistent[i].bMovingAtShutdown) THEN
- IF GVL.axes[i].config.eRestorePosition = RestorePosition.RestoreWithoutHome THEN
- fbRestorePosition[i].Execute:=TRUE;
+ eExecuteRestore:
+ //Execute position restore by setting afbRestorePosition.execute = TRUE
+ FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO
+ IF afbReadEncRefSys[iAxes].Valid = TRUE AND afbReadEncRefSys[iAxes].Value = 0 AND NOT(astAxesPersistent[iAxes].bMovingAtShutdown) THEN
+ IF GVL.astAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN
+ afbRestorePosition[iAxes].Execute := TRUE;
END_IF
END_IF
END_FOR
- eStartUp:= CheckRestore;
+ eStartUp := eCheckRestore;
- CheckRestore:
- // Check the set position fbs are finished
- // 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 and will take up cycle time
- FOR i:=1 TO gvl_app.axisNum DO
- IF fbReadEncRefSys[i].Valid = TRUE AND fbReadEncRefSys[i].Value = 0 AND NOT(axesPersistent[i].bMovingAtShutdown) THEN
- IF GVL.axes[i].config.eRestorePosition = RestorePosition.RestoreWithoutHome THEN
- IF NOT fbRestorePosition[i].Done THEN
+ eCheckRestore:
+ //Check the set position fbs are finished
+ //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 and will take up cycle time
+ FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO
+ IF afbReadEncRefSys[iAxes].Valid = TRUE AND afbReadEncRefSys[iAxes].Value = 0 AND NOT(astAxesPersistent[iAxes].bMovingAtShutdown) THEN
+ IF GVL.astAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN
+ IF NOT afbRestorePosition[iAxes].Done THEN
RETURN;
END_IF
END_IF
END_IF
END_FOR
- eStartUp:= FinishRestore;
+ eStartUp := eFinishRestore;
- FinishRestore:
- // Remove execute = TRUE for fbRestorePosition
- FOR i:=1 TO gvl_app.axisNum DO
- fbRestorePosition[i].Execute:=FALSE;
+ eFinishRestore:
+ //Remove execute = TRUE for afbRestorePosition
+ FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO
+ afbRestorePosition[iAxes].Execute := FALSE;
END_FOR
- bPositionRestoreDone:=TRUE;
- bRestoreExecute:=FALSE;
+ bPositionRestoreDone := TRUE;
+ bRestoreExecute := FALSE;
END_CASE
END_IF]]>
- 0 THEN
- axesPersistent[i].bMovingAtShutdown:=TRUE;
+ 0 THEN
+ astAxesPersistent[iAxes].bMovingAtShutdown := TRUE;
ELSE
- axesPersistent[i].bMovingAtShutdown:=FALSE;
+ astAxesPersistent[iAxes].bMovingAtShutdown := FALSE;
END_IF
- axesPersistent[i].bMovingAtShutdown:=axesPersistent[i].bMovingAtShutdown OR gvl.axes[i].Axis.Status.Moving;
+ astAxesPersistent[iAxes].bMovingAtShutdown := astAxesPersistent[iAxes].bMovingAtShutdown OR GVL.astAxes[iAxes].Axis.Status.Moving;
END_FOR]]>
@@ -238,82 +221,9 @@ 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 9fb8d47..14c9f5f 100644
--- a/solution/tc_project_app/Test/common/FB_tcUNIT_common.TcPOU
+++ b/solution/tc_project_app/Test/common/FB_tcUNIT_common.TcPOU
@@ -1,118 +1,118 @@
-
-
-
+
-
-
+
-
+GVL.astAxes[iAxisIndex].stConfig.fVelocity := tcUNIT_GVL.fDEFAULT_TARGET_VELOCITY;
+GVL.astAxes[iAxisIndex].stConfig.fAcceleration := tcUNIT_GVL.fDEFAULT_TARGET_ACCELERATION;
+GVL.astAxes[iAxisIndex].stConfig.fDeceleration := tcUNIT_GVL.fDEFAULT_TARGET_DECCELERATION;
+GVL.astAxes[iAxisIndex].stConfig.fOverride := tcUNIT_GVL.fDEFAULT_TARGET_OVERRIDE;
+GVL.astAxes[iAxisIndex].stConfig.fPosition := tcUNIT_GVL.fDEFAULT_POSITION;]]>
-
+GVL.astAxes[iAxisIndex].stConfig.fVelocity := fTargetVelocity;
+GVL.astAxes[iAxisIndex].stConfig.fAcceleration := fTargetAcceleration;
+GVL.astAxes[iAxisIndex].stConfig.fDeceleration := fTargetDeceleration;
+GVL.astAxes[iAxisIndex].stConfig.fPosition := fTargetPosition;]]>
+GVL.astAxes[iAxisIndex].stInputs.bLimitBwd := FALSE;
+GVL.astAxes[iAxisIndex].stInputs.bLimitFwd := FALSE;
+GVL.astAxes[iAxisIndex].stInputs.bHomeSensor := FALSE;]]>
@@ -125,25 +125,15 @@ GVL.axes[iAxisIndex].inputs.bHomeSensor := FALSE;]]>
-
-
-
-
-
+
-
-
-
-
-
-
-
-
+
+
\ No newline at end of file
diff --git a/solution/tc_project_app/Test/common/tcUNIT_GVL.TcGVL b/solution/tc_project_app/Test/common/tcUNIT_GVL.TcGVL
index 10cbe42..e80baa0 100644
--- a/solution/tc_project_app/Test/common/tcUNIT_GVL.TcGVL
+++ b/solution/tc_project_app/Test/common/tcUNIT_GVL.TcGVL
@@ -1,15 +1,14 @@
-
- of the axis within GVL.axes[] to test against.
+ iTargetAxis: UINT := 1; //The of the axis within GVL.astAxes[] to test against.
END_VAR]]>
- nMaxCycles OR ExpectedResult = Result THEN
AssertEquals(Expected := ExpectedResult,
@@ -52,24 +52,25 @@ VAR
InitialValue: LREAL;
Result: LREAL;
ExpectedResult: LREAL;
+
nCycle: UINT;
nCycleMax: UINT := 100;
END_VAR]]>
nCycleMax OR ExpectedResult = Result THEN
AssertEquals(Expected := ExpectedResult,
@@ -91,12 +92,12 @@ END_VAR]]>
VAR
Result: BOOL;
ExpectedResult: BOOL;
+
nCycle: UINT;
nMaxCycles: UINT := 30;
END_VAR]]>
nMaxCycles OR ExpectedResult = Result THEN
AssertEquals(Expected := ExpectedResult,
@@ -146,13 +148,13 @@ END_VAR]]>
ExpectedResult := TRUE;
-GVL.axes[iTargetAxis].inputs.bLimitFwd := TRUE;
+GVL.astAxes[iTargetAxis].stInputs.bLimitFwd := TRUE;
-Result := GVL.axes[iTargetAxis].status.bFwEnabled;
+Result := GVL.astAxes[iTargetAxis].stStatus.bFwEnabled;
IF nCycle > nMaxCycles OR ExpectedResult = Result THEN
AssertEquals(Expected := ExpectedResult,
diff --git a/solution/tc_project_app/Test/standard_library_tests/tcUNIT_STD_LIB_RUN.TcPOU b/solution/tc_project_app/Test/standard_library_tests/tcUNIT_STD_LIB_RUN.TcPOU
index e7cb079..0c553c6 100644
--- a/solution/tc_project_app/Test/standard_library_tests/tcUNIT_STD_LIB_RUN.TcPOU
+++ b/solution/tc_project_app/Test/standard_library_tests/tcUNIT_STD_LIB_RUN.TcPOU
@@ -1,11 +1,11 @@
-
diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib
index 5ee22a6..08a5fd1 160000
--- a/solution/tc_project_app/tc_mca_std_lib
+++ b/solution/tc_project_app/tc_mca_std_lib
@@ -1 +1 @@
-Subproject commit 5ee22a6d093b48768c6bc912b5893a9d0d383d84
+Subproject commit 08a5fd1399ee7f333765229a2737919377ea0e6e
diff --git a/solution/tc_project_app/tc_project_app.plcproj b/solution/tc_project_app/tc_project_app.plcproj
index c52eb62..23aa3e4 100644
--- a/solution/tc_project_app/tc_project_app.plcproj
+++ b/solution/tc_project_app/tc_project_app.plcproj
@@ -30,7 +30,19 @@
Code
-
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
Code
@@ -39,7 +51,10 @@
Code
-
+
+ Code
+
+
Code
@@ -75,48 +90,20 @@
Code
-
- Code
-
-
- Code
-
-
- Code
-
Code
-
- Code
-
-
- Code
-
-
- Code
-
-
- Code
-
-
- Code
-
Code
-
+
+ Code
+
+
Code
Visualization Manager.TcVMO
-
- Code
-
-
- Code
- Visualization Manager.TcVMO
-
-
+
Code
@@ -141,6 +128,7 @@
+
@@ -149,11 +137,9 @@
-
-