From 27e8814a66edc7ea6299b858165eb6737de67739 Mon Sep 17 00:00:00 2001 From: kleines Date: Wed, 4 Mar 2020 13:00:17 +0100 Subject: [PATCH 01/36] added descriptive substructure to axes struct in std_lib --- solution/solution.tsproj | 8 -------- solution/tc_project_app/tc_mca_std_lib | 2 +- solution/tc_project_app/tc_project_app.plcproj | 12 ++++++++++++ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/solution/solution.tsproj b/solution/solution.tsproj index 36de82a..6f0e066 100644 --- a/solution/solution.tsproj +++ b/solution/solution.tsproj @@ -33,14 +33,6 @@ tc_project_app Instance {08500001-0000-0000-F000-000000000064} - - PlcTask Outputs - - MAIN.bOutput1 - - BOOL - - diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index 85f11c0..c4ed7b7 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit 85f11c08bc807bda1e02aa5c635a789d355da20c +Subproject commit c4ed7b7c9b340c68f26e38a539fb35719d6ca848 diff --git a/solution/tc_project_app/tc_project_app.plcproj b/solution/tc_project_app/tc_project_app.plcproj index f8a5867..0b03985 100644 --- a/solution/tc_project_app/tc_project_app.plcproj +++ b/solution/tc_project_app/tc_project_app.plcproj @@ -29,6 +29,15 @@ Code + + Code + + + Code + + + Code + Code @@ -41,6 +50,9 @@ Code + + Code + Code From ed55d3823add3e6c57d9d3027944d08baa5facc6 Mon Sep 17 00:00:00 2001 From: kleines Date: Wed, 4 Mar 2020 17:23:20 +0100 Subject: [PATCH 02/36] changed enums to coding conventions --- solution/solution.tsproj | 17 ++++++----- solution/tc_project_app/tc_mca_std_lib | 2 +- .../tc_project_app/tc_project_app.plcproj | 28 +++++++++---------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/solution/solution.tsproj b/solution/solution.tsproj index 6f0e066..86eb586 100644 --- a/solution/solution.tsproj +++ b/solution/solution.tsproj @@ -20,19 +20,18 @@ - - - tc_epicscommodule Instance - {08500001-0000-0000-F000-000000000064} - - - - - tc_project_app Instance {08500001-0000-0000-F000-000000000064} + + PlcTask Outputs + + MAIN.bOutput1 + + BOOL + + diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index c4ed7b7..d74f871 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit c4ed7b7c9b340c68f26e38a539fb35719d6ca848 +Subproject commit d74f8715e1d87ce8570848b95078565a88946c3b diff --git a/solution/tc_project_app/tc_project_app.plcproj b/solution/tc_project_app/tc_project_app.plcproj index 0b03985..c39e3ed 100644 --- a/solution/tc_project_app/tc_project_app.plcproj +++ b/solution/tc_project_app/tc_project_app.plcproj @@ -29,13 +29,13 @@ Code - + Code - + Code - + Code @@ -243,8 +243,8 @@ - - + + "<ProjectRoot>" {192FAD59-8248-4824-A8DE-9177C94C195A} @@ -295,15 +295,15 @@ - - - System.Boolean - System.Collections.Hashtable - System.Int32 - {54dd0eac-a6d8-46f2-8c27-2f43c7e49861} - System.String - - + + + System.Boolean + System.Collections.Hashtable + System.Int32 + {54dd0eac-a6d8-46f2-8c27-2f43c7e49861} + System.String + + \ No newline at end of file From c504ae6ea3e839ed74da43e0dc2681feab8fb4b7 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Wed, 11 Mar 2020 13:01:52 +0100 Subject: [PATCH 03/36] change axisNum to nAxisNum in GVL.APP and their references --- solution/tc_project_app/GVLs/GVL_APP.TcGVL | 2 +- solution/tc_project_app/POUs/MAIN.TcPOU | 24 +++++++++++----------- solution/tc_project_app/tc_mca_std_lib | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/solution/tc_project_app/GVLs/GVL_APP.TcGVL b/solution/tc_project_app/GVLs/GVL_APP.TcGVL index c284299..d6f0aab 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; + nAxisNum : UINT:=0; END_VAR]]> \ No newline at end of file diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 8e73b6a..276381e 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -5,7 +5,7 @@ VAR sVersion: STRING:='1.0.0'; i : UINT; //index variable for AXES() - aFbAxes: ARRAY [1..gvl_app.axisNum] OF FB_Axis; + aFbAxes: ARRAY [1..gvl_app.nAxisNum] OF FB_Axis; hmiAxisSelection : INT:=1; //Not possible to use local hmi variables for array indexes @@ -34,8 +34,8 @@ VAR bRestoreExecute : BOOL := FALSE; bExecuteReadEncRefSys : BOOL := FALSE; iRetry : INT; - fbReadEncRefSys : ARRAY [1..gvl_app.axisNum] OF MC_ReadParameter; - fbRestorePosition : ARRAY [1..GVL_app.axisNum] OF MC_SetPosition; + fbReadEncRefSys : ARRAY [1..gvl_app.nAxisNum] OF MC_ReadParameter; + fbRestorePosition : ARRAY [1..GVL_app.nAxisNum] OF MC_SetPosition; fbGetDeviceIdentification : FB_GetDeviceIdentification; END_VAR @@ -51,7 +51,7 @@ AXES();]]> - @@ -115,7 +115,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN // 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 i:=1 TO gvl_app.axisNum DO + FOR i:=1 TO gvl_app.nAxisNum DO fbReadEncRefSys[i]( Axis:= gvl.axes[i].Axis, Enable:= bExecuteReadEncRefSys, @@ -125,7 +125,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN END_FOR // Cycle through set position function blocks for each axis - FOR i:=1 TO gvl_app.axisNum DO + FOR i:=1 TO gvl_app.nAxisNum DO fbRestorePosition[i]( Axis:= gvl.axes[i].Axis, Execute:= , @@ -148,8 +148,8 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN 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 any axes result in an error the code will get stuck here, this happens if gvl_app.nAxisNum is not set correctly + FOR i:=1 TO gvl_app.nAxisNum 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 @@ -170,7 +170,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN ExecuteRestore: // Execute position restore by setting fbRestorePosition.execute = TRUE - FOR i:=1 TO gvl_app.axisNum DO + FOR i:=1 TO gvl_app.nAxisNum 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; @@ -183,7 +183,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN // 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 + FOR i:=1 TO gvl_app.nAxisNum 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 @@ -196,7 +196,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN FinishRestore: // Remove execute = TRUE for fbRestorePosition - FOR i:=1 TO gvl_app.axisNum DO + FOR i:=1 TO gvl_app.nAxisNum DO fbRestorePosition[i].Execute:=FALSE; END_FOR bPositionRestoreDone:=TRUE; @@ -207,7 +207,7 @@ END_IF]]> - 0 THEN axesPersistent[i].bMovingAtShutdown:=TRUE; diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index 8866844..1005745 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit 88668447be9a9d47cd621d0e7768a6c8f7837428 +Subproject commit 100574565b349e48af43d0608c352432bd14d33c From 456f791f56236acc468d175c30203ec364385c11 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Wed, 11 Mar 2020 13:07:28 +0100 Subject: [PATCH 04/36] change nAxisNum constant to nAXIS_NUM in GVL.APP and their references --- solution/tc_project_app/GVLs/GVL_APP.TcGVL | 2 +- solution/tc_project_app/POUs/MAIN.TcPOU | 24 +++++++++++----------- solution/tc_project_app/tc_mca_std_lib | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/solution/tc_project_app/GVLs/GVL_APP.TcGVL b/solution/tc_project_app/GVLs/GVL_APP.TcGVL index d6f0aab..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 - nAxisNum : UINT:=0; + nAXIS_NUM : UINT:=0; END_VAR]]> \ No newline at end of file diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 276381e..cfde607 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -5,7 +5,7 @@ VAR sVersion: STRING:='1.0.0'; i : UINT; //index variable for AXES() - aFbAxes: ARRAY [1..gvl_app.nAxisNum] OF FB_Axis; + aFbAxes: ARRAY [1..gvl_app.nAXIS_NUM] OF FB_Axis; hmiAxisSelection : INT:=1; //Not possible to use local hmi variables for array indexes @@ -34,8 +34,8 @@ VAR bRestoreExecute : BOOL := FALSE; bExecuteReadEncRefSys : BOOL := FALSE; iRetry : INT; - fbReadEncRefSys : ARRAY [1..gvl_app.nAxisNum] OF MC_ReadParameter; - fbRestorePosition : ARRAY [1..GVL_app.nAxisNum] OF MC_SetPosition; + fbReadEncRefSys : ARRAY [1..gvl_app.nAXIS_NUM] OF MC_ReadParameter; + fbRestorePosition : ARRAY [1..GVL_app.nAXIS_NUM] OF MC_SetPosition; fbGetDeviceIdentification : FB_GetDeviceIdentification; END_VAR @@ -51,7 +51,7 @@ AXES();]]> - @@ -115,7 +115,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN // 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 i:=1 TO gvl_app.nAxisNum DO + FOR i:=1 TO gvl_app.nAXIS_NUM DO fbReadEncRefSys[i]( Axis:= gvl.axes[i].Axis, Enable:= bExecuteReadEncRefSys, @@ -125,7 +125,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN END_FOR // Cycle through set position function blocks for each axis - FOR i:=1 TO gvl_app.nAxisNum DO + FOR i:=1 TO gvl_app.nAXIS_NUM DO fbRestorePosition[i]( Axis:= gvl.axes[i].Axis, Execute:= , @@ -148,8 +148,8 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN 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.nAxisNum is not set correctly - FOR i:=1 TO gvl_app.nAxisNum DO + // If any axes result in an error the code will get stuck here, this happens if gvl_app.nAXIS_NUM is not set correctly + FOR i:=1 TO gvl_app.nAXIS_NUM 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 @@ -170,7 +170,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN ExecuteRestore: // Execute position restore by setting fbRestorePosition.execute = TRUE - FOR i:=1 TO gvl_app.nAxisNum DO + FOR i:=1 TO gvl_app.nAXIS_NUM 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; @@ -183,7 +183,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN // 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.nAxisNum DO + FOR i:=1 TO gvl_app.nAXIS_NUM 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 @@ -196,7 +196,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN FinishRestore: // Remove execute = TRUE for fbRestorePosition - FOR i:=1 TO gvl_app.nAxisNum DO + FOR i:=1 TO gvl_app.nAXIS_NUM DO fbRestorePosition[i].Execute:=FALSE; END_FOR bPositionRestoreDone:=TRUE; @@ -207,7 +207,7 @@ END_IF]]> - 0 THEN axesPersistent[i].bMovingAtShutdown:=TRUE; diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index 1005745..de9fc97 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit 100574565b349e48af43d0608c352432bd14d33c +Subproject commit de9fc973bc5fbf3fca4b2f10580df4e738dcd91e From 6c9885ee547992868ba4bbc9c625aaad1e083f08 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Wed, 11 Mar 2020 13:30:47 +0100 Subject: [PATCH 05/36] Change to coding standards all variables in MAIN and their references --- solution/solution.tsproj | 2 +- solution/tc_project_app/POUs/MAIN.TcPOU | 93 +++++++++++-------------- solution/tc_project_app/tc_mca_std_lib | 2 +- 3 files changed, 44 insertions(+), 53 deletions(-) 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/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index cfde607..e11ab1f 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -3,45 +3,36 @@ if busy then continue with PLC cycle and check again next time. - // If fbReadEncRefSys not started then go back a step. + // 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.nAXIS_NUM is not set correctly FOR i:=1 TO gvl_app.nAXIS_NUM DO - IF fbReadEncRefSys[i].Valid = FALSE THEN - IF fbReadEncRefSys[i].Busy = TRUE THEN + IF aFbReadEncRefSys[i].Valid = FALSE THEN + IF aFbReadEncRefSys[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 + // Sometimes the code gets here and the aFbReadEncRefSys[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 + 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; + eStartUp:= eExecuteRestore; - ExecuteRestore: - // Execute position restore by setting fbRestorePosition.execute = TRUE + eExecuteRestore: + // Execute position restore by setting aFbRestorePosition.execute = TRUE FOR i:=1 TO gvl_app.nAXIS_NUM DO - IF fbReadEncRefSys[i].Valid = TRUE AND fbReadEncRefSys[i].Value = 0 AND NOT(axesPersistent[i].bMovingAtShutdown) THEN + IF aFbReadEncRefSys[i].Valid = TRUE AND aFbReadEncRefSys[i].Value = 0 AND NOT(axesPersistent[i].bMovingAtShutdown) THEN IF GVL.axes[i].config.eRestorePosition = RestorePosition.RestoreWithoutHome THEN - fbRestorePosition[i].Execute:=TRUE; + aFbRestorePosition[i].Execute:=TRUE; END_IF END_IF END_FOR - eStartUp:= CheckRestore; + eStartUp:= eCheckRestore; - CheckRestore: + 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 i:=1 TO gvl_app.nAXIS_NUM DO - IF fbReadEncRefSys[i].Valid = TRUE AND fbReadEncRefSys[i].Value = 0 AND NOT(axesPersistent[i].bMovingAtShutdown) THEN + IF aFbReadEncRefSys[i].Valid = TRUE AND aFbReadEncRefSys[i].Value = 0 AND NOT(axesPersistent[i].bMovingAtShutdown) THEN IF GVL.axes[i].config.eRestorePosition = RestorePosition.RestoreWithoutHome THEN - IF NOT fbRestorePosition[i].Done THEN + IF NOT aFbRestorePosition[i].Done THEN RETURN; END_IF END_IF @@ -195,9 +186,9 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN eStartUp:= FinishRestore; FinishRestore: - // Remove execute = TRUE for fbRestorePosition + // Remove execute = TRUE for aFbRestorePosition FOR i:=1 TO gvl_app.nAXIS_NUM DO - fbRestorePosition[i].Execute:=FALSE; + aFbRestorePosition[i].Execute:=FALSE; END_FOR bPositionRestoreDone:=TRUE; bRestoreExecute:=FALSE; diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index de9fc97..1b8def1 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit de9fc973bc5fbf3fca4b2f10580df4e738dcd91e +Subproject commit 1b8def1012d4825ee0a7df1936895092f4608385 From 9561494a7d93ce72441d2021d052d09c6e2a3c20 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Tue, 17 Mar 2020 11:27:21 +0100 Subject: [PATCH 06/36] Revert change from nAXIS_NUM to nAxisNum, it is not a constant --- solution/tc_project_app/GVLs/GVL_APP.TcGVL | 2 +- solution/tc_project_app/POUs/MAIN.TcPOU | 88 +++++++++++----------- solution/tc_project_app/tc_mca_std_lib | 2 +- 3 files changed, 45 insertions(+), 47 deletions(-) diff --git a/solution/tc_project_app/GVLs/GVL_APP.TcGVL b/solution/tc_project_app/GVLs/GVL_APP.TcGVL index a423ad2..d6f0aab 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 - nAXIS_NUM : UINT:=0; + nAxisNum : UINT:=0; END_VAR]]> \ No newline at end of file diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index e11ab1f..09c49f9 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -5,7 +5,7 @@ VAR sVersion: STRING := '1.0.0'; i: UINT; //index variable for the FOR cycle in action AXES() - aFbAxes: ARRAY [1..gvl_app.nAXIS_NUM] OF FB_Axis; + aFbAxes: ARRAY [1..gvl_app.nAxisNum] 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) @@ -25,8 +25,8 @@ VAR bRestoreExecute: BOOL := FALSE; bExecuteReadEncRefSys: BOOL := FALSE; nRetry: INT; - aFbReadEncRefSys: ARRAY [1..gvl_app.nAXIS_NUM] OF MC_ReadParameter; - aFbRestorePosition: ARRAY [1..GVL_app.nAXIS_NUM] OF MC_SetPosition; + aFbReadEncRefSys: ARRAY [1..gvl_app.nAxisNum] OF MC_ReadParameter; + aFbRestorePosition: ARRAY [1..GVL_app.nAxisNum] OF MC_SetPosition; fbGetDeviceIdentification: FB_GetDeviceIdentification; END_VAR @@ -42,8 +42,8 @@ AXES();]]> - @@ -54,7 +54,7 @@ END_FOR]]> IF eGlobalSUpsState = eSUPS_PowerFailure THEN (* first cycle of powerfailure *) (* execute code that should only be done once with each powerfailure, i.e. increase powerfailure counter *) - bRestoreOnStartup:=TRUE; + bRestoreOnStartup := TRUE; STORE_PERSISTENT(); RETURN; ELSIF eGlobalSUpsState <> eSUPS_PowerOK THEN @@ -66,7 +66,7 @@ END_IF]]> - '0') THEN CHECK_UPS(); RESTORE_POSITIONS(); @@ -82,7 +82,7 @@ END_IF]]> - // 0 'DontRestore' // 1 'RestoreWithoutHome' -restores the position using a set position fb and does not set the home bit in the axis struct. // Note from Beckhoff: "A maximum of 1 MB persistent data can be reliably saved over the entire service life." -///######################################################### IF bRestoreOnStartup AND eGlobalSUpsState = eSUPS_PowerOK THEN - bRestoreOnStartup:=FALSE; - bRestoreExecute:=TRUE; + bRestoreOnStartup := FALSE; + bRestoreExecute := TRUE; END_IF // Upon startup bPositionRestoreDone will be set to FALSE, after successfully completing the following code it will be set TRUE @@ -106,41 +105,41 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN // 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 i:=1 TO gvl_app.nAXIS_NUM DO + FOR i:= 1 TO gvl_app.nAxisNum DO aFbReadEncRefSys[i]( - Axis:= gvl.axes[i].Axis, - Enable:= bExecuteReadEncRefSys, - ParameterNumber:= MC_AxisParameter.AxisEncoderReferenceSystem, + Axis := gvl.axes[i].Axis, + Enable := bExecuteReadEncRefSys, + ParameterNumber := MC_AxisParameter.AxisEncoderReferenceSystem, Value=>, - ReadMode:= E_READMODE.READMODE_ONCE); + ReadMode := E_READMODE.READMODE_ONCE); END_FOR // Cycle through set position function blocks for each axis - FOR i:=1 TO gvl_app.nAXIS_NUM DO + FOR i:= 1 TO gvl_app.nAxisNum DO aFbRestorePosition[i]( - Axis:= gvl.axes[i].Axis, - Execute:= , - Position:= axesPersistent[i].iPositionAtShutdown); + Axis := gvl.axes[i].Axis, + Execute := , + Position := axesPersistent[i].iPositionAtShutdown); END_FOR CASE eStartUp OF eColdStart: // First cycle of the PLC, do nothing just give one cycle for variables to initialise IF NOT bPositionRestoreDone THEN - eStartUp:= eReadAxisFeedbackType; - nRetry:=0; + eStartUp := eReadAxisFeedbackType; + nRetry := 0; END_IF eReadAxisFeedbackType: // Exectute the function blocks to read the encoder reference system (0=inc OR 1=ABS) - bExecuteReadEncRefSys:=TRUE; - eStartUp:=eCheckReadDone; + bExecuteReadEncRefSys := TRUE; + eStartUp := eCheckReadDone; 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.nAXIS_NUM is not set correctly - FOR i:=1 TO gvl_app.nAXIS_NUM DO + // If any axes result in an error the code will get stuck here, this happens if gvl_app.nAxisNum is not set correctly + FOR i:= 1 TO gvl_app.nAxisNum DO IF aFbReadEncRefSys[i].Valid = FALSE THEN IF aFbReadEncRefSys[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 @@ -149,32 +148,32 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN // Sometimes the code gets here and the aFbReadEncRefSys[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:=eReadAxisFeedbackType; - nRetry:=nRetry+1; // counter used for troubleshooting to see how many cycles it takes before aFbReadEncRefSys function blocks are read correctly + 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:= eExecuteRestore; + eStartUp := eExecuteRestore; eExecuteRestore: // Execute position restore by setting aFbRestorePosition.execute = TRUE - FOR i:=1 TO gvl_app.nAXIS_NUM DO + FOR i:= 1 TO gvl_app.nAxisNum DO IF aFbReadEncRefSys[i].Valid = TRUE AND aFbReadEncRefSys[i].Value = 0 AND NOT(axesPersistent[i].bMovingAtShutdown) THEN IF GVL.axes[i].config.eRestorePosition = RestorePosition.RestoreWithoutHome THEN - aFbRestorePosition[i].Execute:=TRUE; + aFbRestorePosition[i].Execute := TRUE; END_IF END_IF END_FOR - eStartUp:= eCheckRestore; + eStartUp := eCheckRestore; 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 i:=1 TO gvl_app.nAXIS_NUM DO + FOR i:= 1 TO gvl_app.nAxisNum DO IF aFbReadEncRefSys[i].Valid = TRUE AND aFbReadEncRefSys[i].Value = 0 AND NOT(axesPersistent[i].bMovingAtShutdown) THEN IF GVL.axes[i].config.eRestorePosition = RestorePosition.RestoreWithoutHome THEN IF NOT aFbRestorePosition[i].Done THEN @@ -183,29 +182,29 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN END_IF END_IF END_FOR - eStartUp:= FinishRestore; + eStartUp := FinishRestore; FinishRestore: // Remove execute = TRUE for aFbRestorePosition - FOR i:=1 TO gvl_app.nAXIS_NUM DO - aFbRestorePosition[i].Execute:=FALSE; + FOR i:= 1 TO gvl_app.nAxisNum DO + aFbRestorePosition[i].Execute := FALSE; END_FOR - bPositionRestoreDone:=TRUE; - bRestoreExecute:=FALSE; + bPositionRestoreDone := TRUE; + bRestoreExecute := FALSE; END_CASE END_IF]]> - 0 THEN - axesPersistent[i].bMovingAtShutdown:=TRUE; + axesPersistent[i].bMovingAtShutdown := TRUE; ELSE - axesPersistent[i].bMovingAtShutdown:=FALSE; + axesPersistent[i].bMovingAtShutdown := FALSE; END_IF - axesPersistent[i].bMovingAtShutdown:=axesPersistent[i].bMovingAtShutdown OR gvl.axes[i].Axis.Status.Moving; + axesPersistent[i].bMovingAtShutdown := axesPersistent[i].bMovingAtShutdown OR gvl.axes[i].Axis.Status.Moving; END_FOR]]> @@ -243,7 +242,6 @@ END_FOR]]> - diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index 1b8def1..6202b7b 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit 1b8def1012d4825ee0a7df1936895092f4608385 +Subproject commit 6202b7b79093816b0270a22112bebfd65e919dad From 68498ae44fc1f25bf5eae0f03b7037156e28dd16 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Tue, 17 Mar 2020 13:33:21 +0100 Subject: [PATCH 07/36] Delete local variable i in MAIN and substitute it with GVL.iAxis --- solution/tc_project_app/POUs/MAIN.TcPOU | 79 ++++++++++++------------- 1 file changed, 37 insertions(+), 42 deletions(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 09c49f9..58591cd 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -4,7 +4,6 @@ - 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]]> @@ -75,9 +74,7 @@ END_IF]]> - + @@ -86,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[i].config.eRestorePosition is non-zero. +// 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. // 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. @@ -105,9 +102,9 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN // 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 i:= 1 TO gvl_app.nAxisNum DO - aFbReadEncRefSys[i]( - Axis := gvl.axes[i].Axis, + FOR GVL.iAxis:= 1 TO gvl_app.nAxisNum DO + aFbReadEncRefSys[GVL.iAxis]( + Axis := gvl.axes[GVL.iAxis].Axis, Enable := bExecuteReadEncRefSys, ParameterNumber := MC_AxisParameter.AxisEncoderReferenceSystem, Value=>, @@ -115,11 +112,11 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN END_FOR // Cycle through set position function blocks for each axis - FOR i:= 1 TO gvl_app.nAxisNum DO - aFbRestorePosition[i]( - Axis := gvl.axes[i].Axis, + FOR GVL.iAxis:= 1 TO gvl_app.nAxisNum DO + aFbRestorePosition[GVL.iAxis]( + Axis := gvl.axes[GVL.iAxis].Axis, Execute := , - Position := axesPersistent[i].iPositionAtShutdown); + Position := axesPersistent[GVL.iAxis].iPositionAtShutdown); END_FOR CASE eStartUp OF @@ -139,13 +136,13 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN // 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 i:= 1 TO gvl_app.nAxisNum DO - IF aFbReadEncRefSys[i].Valid = FALSE THEN - IF aFbReadEncRefSys[i].Busy = TRUE THEN + FOR GVL.iAxis:= 1 TO gvl_app.nAxisNum DO + IF aFbReadEncRefSys[GVL.iAxis].Valid = FALSE THEN + IF aFbReadEncRefSys[GVL.iAxis].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 aFbReadEncRefSys[i] misses the rising edge. If the code gets here it means + // Sometimes the code gets here and the aFbReadEncRefSys[GVL.iAxis] 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; @@ -160,10 +157,10 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN eExecuteRestore: // Execute position restore by setting aFbRestorePosition.execute = TRUE - FOR i:= 1 TO gvl_app.nAxisNum DO - IF aFbReadEncRefSys[i].Valid = TRUE AND aFbReadEncRefSys[i].Value = 0 AND NOT(axesPersistent[i].bMovingAtShutdown) THEN - IF GVL.axes[i].config.eRestorePosition = RestorePosition.RestoreWithoutHome THEN - aFbRestorePosition[i].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 = RestorePosition.RestoreWithoutHome THEN + aFbRestorePosition[GVL.iAxis].Execute := TRUE; END_IF END_IF END_FOR @@ -173,21 +170,21 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN // 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.nAxisNum DO - IF aFbReadEncRefSys[i].Valid = TRUE AND aFbReadEncRefSys[i].Value = 0 AND NOT(axesPersistent[i].bMovingAtShutdown) THEN - IF GVL.axes[i].config.eRestorePosition = RestorePosition.RestoreWithoutHome THEN - IF NOT aFbRestorePosition[i].Done THEN + 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 = RestorePosition.RestoreWithoutHome THEN + IF NOT aFbRestorePosition[GVL.iAxis].Done THEN RETURN; END_IF END_IF END_IF END_FOR - eStartUp := FinishRestore; + eStartUp := eFinishRestore; - FinishRestore: + eFinishRestore: // Remove execute = TRUE for aFbRestorePosition - FOR i:= 1 TO gvl_app.nAxisNum DO - aFbRestorePosition[i].Execute := FALSE; + FOR GVL.iAxis:= 1 TO gvl_app.nAxisNum DO + aFbRestorePosition[GVL.iAxis].Execute := FALSE; END_FOR bPositionRestoreDone := TRUE; bRestoreExecute := FALSE; @@ -197,14 +194,14 @@ END_IF]]> - 0 THEN - axesPersistent[i].bMovingAtShutdown := TRUE; + 0 THEN + axesPersistent[GVL.iAxis].bMovingAtShutdown := TRUE; ELSE - axesPersistent[i].bMovingAtShutdown := FALSE; + axesPersistent[GVL.iAxis].bMovingAtShutdown := FALSE; END_IF - axesPersistent[i].bMovingAtShutdown := axesPersistent[i].bMovingAtShutdown OR gvl.axes[i].Axis.Status.Moving; + axesPersistent[GVL.iAxis].bMovingAtShutdown := axesPersistent[GVL.iAxis].bMovingAtShutdown OR gvl.axes[GVL.iAxis].Axis.Status.Moving; END_FOR]]> @@ -228,8 +225,6 @@ END_FOR]]> - - From 56929e3be11e7a392b1a4fe2890ca44da15f8e4d Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Tue, 17 Mar 2020 14:34:44 +0100 Subject: [PATCH 08/36] Fix all references from the chages DUT's in the FB's and POU's --- solution/tc_project_app/POUs/MAIN.TcPOU | 76 +------------------ .../Test/common/FB_tcUNIT_common.TcPOU | 22 ++---- .../standard_library_tests/FB_Axis_TEST.TcPOU | 2 +- solution/tc_project_app/tc_mca_std_lib | 2 +- .../tc_project_app/tc_project_app.plcproj | 27 +------ 5 files changed, 14 insertions(+), 115 deletions(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 58591cd..f1cd022 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -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 = RestorePosition.RestoreWithoutHome THEN + IF GVL.axes[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 = RestorePosition.RestoreWithoutHome THEN + IF GVL.axes[GVL.iAxis].config.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN IF NOT aFbRestorePosition[GVL.iAxis].Done THEN RETURN; END_IF @@ -227,77 +227,7 @@ 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..8aaea1c 100644 --- a/solution/tc_project_app/Test/common/FB_tcUNIT_common.TcPOU +++ b/solution/tc_project_app/Test/common/FB_tcUNIT_common.TcPOU @@ -37,7 +37,7 @@ END_VAR]]> - - - - - + - - - - - - - - + + \ No newline at end of file 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 36cf024..a5d70eb 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 @@ -66,7 +66,7 @@ InitialValue := GVL.axes[iTargetAxis].config.fPosition; ExpectedResult := InitialValue + 10; GVL.axes[iTargetAxis].config.fPosition := ExpectedResult; -GVL.axes[iTargetAxis].control.eCommand := MotionFunctions.MoveAbsolute; +GVL.axes[iTargetAxis].control.eCommand := E_MotionFunctions.MoveAbsolute; GVL.axes[iTargetAxis].control.bExecute := TRUE; Result := GVL.axes[iTargetAxis].status.fActPosition; diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index 6202b7b..8edeaa8 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit 6202b7b79093816b0270a22112bebfd65e919dad +Subproject commit 8edeaa86c4b19d466f1a88548399a19014200c2c diff --git a/solution/tc_project_app/tc_project_app.plcproj b/solution/tc_project_app/tc_project_app.plcproj index a6e81bf..b3f98ef 100644 --- a/solution/tc_project_app/tc_project_app.plcproj +++ b/solution/tc_project_app/tc_project_app.plcproj @@ -39,7 +39,7 @@ Code - + Code @@ -48,7 +48,7 @@ Code - + Code @@ -87,33 +87,12 @@ Code - - Code - - - Code - - + Code Code - - Code - - - Code - - - Code - - - Code - - - Code - Code From c99efebb07d5d47b29b33df982dccc8ce5da1686 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Tue, 17 Mar 2020 14:52:19 +0100 Subject: [PATCH 09/36] Change GVL to follow our coding standards and update all the references in the FB's --- solution/tc_project_app/POUs/MAIN.TcPOU | 18 ++-- .../Test/common/FB_tcUNIT_common.TcPOU | 85 +++++++++---------- .../standard_library_tests/FB_Axis_TEST.TcPOU | 30 +++---- solution/tc_project_app/tc_mca_std_lib | 2 +- 4 files changed, 67 insertions(+), 68 deletions(-) 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 From cfc3b146f86ef9337f502dd08c4381593d91fe94 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Tue, 17 Mar 2020 16:17:30 +0100 Subject: [PATCH 10/36] Fix calling of FB's as define in the coding standards in Homing directory --- solution/tc_project_app/tc_mca_std_lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index d39ddf2..7fafa12 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit d39ddf23118492488719d676239f547530510d0c +Subproject commit 7fafa12236be672b7886c1646ad8c52b9748115a From 014cc8d807a1794acedbdb051ec95fceebc2f97c Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Tue, 17 Mar 2020 16:18:38 +0100 Subject: [PATCH 11/36] Chenge variable and references of axesPersistent to aAxesPersistent --- solution/tc_project_app/POUs/MAIN.TcPOU | 14 +++++++------- solution/tc_project_app/tc_project_app.plcproj | 7 ------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 2ea4309..2da765a 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -116,7 +116,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN aFbRestorePosition[GVL.iAxis]( Axis := gvl.aAxes[GVL.iAxis].Axis, Execute := , - Position := axesPersistent[GVL.iAxis].iPositionAtShutdown); + Position := aAxesPersistent[GVL.iAxis].iPositionAtShutdown); END_FOR CASE eStartUp OF @@ -158,7 +158,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN eExecuteRestore: // 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 aFbReadEncRefSys[GVL.iAxis].Valid = TRUE AND aFbReadEncRefSys[GVL.iAxis].Value = 0 AND NOT(aAxesPersistent[GVL.iAxis].bMovingAtShutdown) THEN IF GVL.aAxes[GVL.iAxis].config.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN aFbRestorePosition[GVL.iAxis].Execute := TRUE; END_IF @@ -171,7 +171,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN // 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 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 aFbReadEncRefSys[GVL.iAxis].Valid = TRUE AND aFbReadEncRefSys[GVL.iAxis].Value = 0 AND NOT(aAxesPersistent[GVL.iAxis].bMovingAtShutdown) THEN IF GVL.aAxes[GVL.iAxis].config.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN IF NOT aFbRestorePosition[GVL.iAxis].Done THEN RETURN; @@ -195,13 +195,13 @@ END_IF]]> 0 THEN - axesPersistent[GVL.iAxis].bMovingAtShutdown := TRUE; + aAxesPersistent[GVL.iAxis].bMovingAtShutdown := TRUE; ELSE - axesPersistent[GVL.iAxis].bMovingAtShutdown := FALSE; + aAxesPersistent[GVL.iAxis].bMovingAtShutdown := FALSE; END_IF - axesPersistent[GVL.iAxis].bMovingAtShutdown := axesPersistent[GVL.iAxis].bMovingAtShutdown OR gvl.aAxes[GVL.iAxis].Axis.Status.Moving; + aAxesPersistent[GVL.iAxis].bMovingAtShutdown := aAxesPersistent[GVL.iAxis].bMovingAtShutdown OR gvl.aAxes[GVL.iAxis].Axis.Status.Moving; END_FOR]]> diff --git a/solution/tc_project_app/tc_project_app.plcproj b/solution/tc_project_app/tc_project_app.plcproj index b3f98ef..2aa3825 100644 --- a/solution/tc_project_app/tc_project_app.plcproj +++ b/solution/tc_project_app/tc_project_app.plcproj @@ -87,19 +87,12 @@ Code - - Code - Code Code - - Code - Visualization Manager.TcVMO - Code From ab723f139b8fe202d65a30ee7bde1f648de4dec5 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Wed, 18 Mar 2020 13:38:02 +0100 Subject: [PATCH 12/36] fix white space damage --- solution/tc_project_app/tc_mca_std_lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index 7fafa12..217a5d2 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit 7fafa12236be672b7886c1646ad8c52b9748115a +Subproject commit 217a5d285e08d1e8618d854709b84ab9500bb4c8 From e551fc826ac7b20b1d5986de96ebb0205ae9197a Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Wed, 18 Mar 2020 15:03:46 +0100 Subject: [PATCH 13/36] Add an 'e' at the beginning of all values of the enum E_MotionFunctions --- solution/tc_project_app/Test/common/FB_tcUNIT_common.TcPOU | 4 ++-- .../Test/standard_library_tests/FB_Axis_TEST.TcPOU | 2 +- solution/tc_project_app/tc_mca_std_lib | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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 f0b73e6..ce7649f 100644 --- a/solution/tc_project_app/Test/common/FB_tcUNIT_common.TcPOU +++ b/solution/tc_project_app/Test/common/FB_tcUNIT_common.TcPOU @@ -37,7 +37,7 @@ END_VAR]]> Date: Wed, 18 Mar 2020 15:34:23 +0100 Subject: [PATCH 14/36] Change all DUT's variable names and references after merge with MBP-138 --- solution/tc_project_app/POUs/MAIN.TcPOU | 10 +-- .../Test/common/FB_tcUNIT_common.TcPOU | 82 +++++++++---------- .../standard_library_tests/FB_Axis_TEST.TcPOU | 28 +++---- solution/tc_project_app/tc_mca_std_lib | 2 +- 4 files changed, 61 insertions(+), 61 deletions(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 2da765a..aead7a4 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -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.aAxes[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].stConfig.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. @@ -116,7 +116,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN aFbRestorePosition[GVL.iAxis]( Axis := gvl.aAxes[GVL.iAxis].Axis, Execute := , - Position := aAxesPersistent[GVL.iAxis].iPositionAtShutdown); + Position := aAxesPersistent[GVL.iAxis].fPositionAtShutdown); END_FOR CASE eStartUp OF @@ -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(aAxesPersistent[GVL.iAxis].bMovingAtShutdown) THEN - IF GVL.aAxes[GVL.iAxis].config.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN + IF GVL.aAxes[GVL.iAxis].stConfig.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(aAxesPersistent[GVL.iAxis].bMovingAtShutdown) THEN - IF GVL.aAxes[GVL.iAxis].config.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN + IF GVL.aAxes[GVL.iAxis].stConfig.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN IF NOT aFbRestorePosition[GVL.iAxis].Done THEN RETURN; END_IF @@ -195,7 +195,7 @@ END_IF]]> 0 THEN aAxesPersistent[GVL.iAxis].bMovingAtShutdown := TRUE; ELSE 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 ce7649f..fa2a214 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].stConfig.fVelocity := tcUNIT_GVL.fDEFAULT_TARGET_VELOCITY; +GVL.aAxes[iAxisIndex].stConfig.fAcceleration := tcUNIT_GVL.fDEFAULT_TARGET_ACCELERATION; +GVL.aAxes[iAxisIndex].stConfig.fDeceleration := tcUNIT_GVL.fDEFAULT_TARGET_DECCELERATION; +GVL.aAxes[iAxisIndex].stConfig.fOverride := tcUNIT_GVL.fDEFAULT_TARGET_OVERRIDE; +GVL.aAxes[iAxisIndex].stConfig.fPosition := tcUNIT_GVL.fDEFAULT_POSITION;]]> @@ -63,16 +63,16 @@ END_VAR]]> +GVL.aAxes[iAxisIndex].stConfig.fVelocity := fTargetVelocity; +GVL.aAxes[iAxisIndex].stConfig.fAcceleration := fTargetAcceleration; +GVL.aAxes[iAxisIndex].stConfig.fDeceleration := fTargetDeceleration; +GVL.aAxes[iAxisIndex].stConfig.fPosition := fTargetPosition;]]> @@ -84,34 +84,34 @@ END_VAR]]> +GVL.aAxes[iAxisIndex].stInputs.bLimitBwd := FALSE; +GVL.aAxes[iAxisIndex].stInputs.bLimitFwd := FALSE; +GVL.aAxes[iAxisIndex].stInputs.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 005b4d3..23673d2 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 @@ -34,7 +34,7 @@ ExpectedResult := TRUE; fbCommon.mPrepareDefaultMove(iTargetAxis); fbCommon.mExecute(iTargetAxis); -Result := GVL.aAxes[iTargetAxis].status.bBusy; +Result := GVL.aAxes[iTargetAxis].stStatus.bBusy; IF nCycle > 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.aAxes[iTargetAxis].config.fPosition; +InitialValue := GVL.aAxes[iTargetAxis].stConfig.fPosition; ExpectedResult := InitialValue + 10; -GVL.aAxes[iTargetAxis].config.fPosition := ExpectedResult; +GVL.aAxes[iTargetAxis].stConfig.fPosition := ExpectedResult; -GVL.aAxes[iTargetAxis].control.eCommand := E_MotionFunctions.eMoveAbsolute; -GVL.aAxes[iTargetAxis].control.bExecute := TRUE; +GVL.aAxes[iTargetAxis].stControl.eCommand := E_MotionFunctions.eMoveAbsolute; +GVL.aAxes[iTargetAxis].stControl.bExecute := TRUE; -Result := GVL.aAxes[iTargetAxis].status.fActPosition; +Result := GVL.aAxes[iTargetAxis].stStatus.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.aAxes[1].config.fAcceleration; +Result := GVL.aAxes[1].stConfig.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.aAxes[1].control.bEnable := ExpectedResult; +GVL.aAxes[1].stControl.bEnable := ExpectedResult; -Result := GVL.aAxes[iTargetAxis].status.bEnabled; +Result := GVL.aAxes[iTargetAxis].stStatus.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.aAxes[iTargetAxis].config.fVelocity; +InitialValue := GVL.aAxes[iTargetAxis].stConfig.fVelocity; ExpectedResult := InitialValue + 0.5; -GVL.aAxes[iTargetAxis].config.fVelocity := ExpectedResult; +GVL.aAxes[iTargetAxis].stConfig.fVelocity := ExpectedResult; -Result := GVL.aAxes[iTargetAxis].config.fVelocity; +Result := GVL.aAxes[iTargetAxis].stConfig.fVelocity; AssertEquals_LREAL(Expected := ExpectedResult, Actual := Result, @@ -176,9 +176,9 @@ END_VAR]]> ExpectedResult := TRUE; -GVL.aAxes[iTargetAxis].inputs.bLimitFwd := TRUE; +GVL.aAxes[iTargetAxis].stInputs.bLimitFwd := TRUE; -Result := GVL.aAxes[iTargetAxis].status.bFwEnabled; +Result := GVL.aAxes[iTargetAxis].stStatus.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 c58b432..8562f04 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit c58b432be344cef10241d03c09f214d0f88041e6 +Subproject commit 8562f04c5bd1ff6ce796f1d4a12fe2096c483265 From c4c2fdc0f3e774ee5007b63670d61f06f545a8ae Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Wed, 18 Mar 2020 17:05:52 +0100 Subject: [PATCH 15/36] Changed FB_Axis and refernces to follow code standards --- solution/tc_project_app/POUs/MAIN.TcPOU | 57 +++++++++++++------------ solution/tc_project_app/tc_mca_std_lib | 2 +- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index aead7a4..c13b5c3 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -24,6 +24,7 @@ VAR bRestoreExecute: BOOL := FALSE; bExecuteReadEncRefSys: BOOL := FALSE; nRetry: INT; + iAxes : UINT; //index for for loops in Position recovery actions aFbReadEncRefSys: ARRAY [1..gvl_app.nAxisNum] OF MC_ReadParameter; aFbRestorePosition: ARRAY [1..GVL_app.nAxisNum] OF MC_SetPosition; fbGetDeviceIdentification: FB_GetDeviceIdentification; @@ -83,7 +84,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.aAxes[GVL.iAxis].stConfig.eRestorePosition is non-zero. +// By default an axis will not restore the position unless it is set to opt-in, i.e. gvl.aAxes[iAxes].stConfig.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. @@ -102,9 +103,9 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN // 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 GVL.iAxis:= 1 TO gvl_app.nAxisNum DO - aFbReadEncRefSys[GVL.iAxis]( - Axis := gvl.aAxes[GVL.iAxis].Axis, + FOR iAxes:= 1 TO gvl_app.nAxisNum DO + aFbReadEncRefSys[iAxes]( + Axis := gvl.aAxes[iAxes].Axis, Enable := bExecuteReadEncRefSys, ParameterNumber := MC_AxisParameter.AxisEncoderReferenceSystem, Value=>, @@ -112,11 +113,11 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN END_FOR // Cycle through set position function blocks for each axis - FOR GVL.iAxis:= 1 TO gvl_app.nAxisNum DO - aFbRestorePosition[GVL.iAxis]( - Axis := gvl.aAxes[GVL.iAxis].Axis, + FOR iAxes:= 1 TO gvl_app.nAxisNum DO + aFbRestorePosition[iAxes]( + Axis := gvl.aAxes[iAxes].Axis, Execute := , - Position := aAxesPersistent[GVL.iAxis].fPositionAtShutdown); + Position := aAxesPersistent[iAxes].fPositionAtShutdown); END_FOR CASE eStartUp OF @@ -136,13 +137,13 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN // 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 GVL.iAxis:= 1 TO gvl_app.nAxisNum DO - IF aFbReadEncRefSys[GVL.iAxis].Valid = FALSE THEN - IF aFbReadEncRefSys[GVL.iAxis].Busy = TRUE THEN + FOR iAxes:= 1 TO gvl_app.nAxisNum 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 aFbReadEncRefSys[GVL.iAxis] misses the rising edge. If the code gets here it means + // 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; @@ -157,10 +158,10 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN eExecuteRestore: // 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(aAxesPersistent[GVL.iAxis].bMovingAtShutdown) THEN - IF GVL.aAxes[GVL.iAxis].stConfig.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN - aFbRestorePosition[GVL.iAxis].Execute := TRUE; + FOR iAxes:= 1 TO gvl_app.nAxisNum DO + IF aFbReadEncRefSys[iAxes].Valid = TRUE AND aFbReadEncRefSys[iAxes].Value = 0 AND NOT(aAxesPersistent[iAxes].bMovingAtShutdown) THEN + IF GVL.aAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN + aFbRestorePosition[iAxes].Execute := TRUE; END_IF END_IF END_FOR @@ -170,10 +171,10 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN // 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 GVL.iAxis:= 1 TO gvl_app.nAxisNum DO - IF aFbReadEncRefSys[GVL.iAxis].Valid = TRUE AND aFbReadEncRefSys[GVL.iAxis].Value = 0 AND NOT(aAxesPersistent[GVL.iAxis].bMovingAtShutdown) THEN - IF GVL.aAxes[GVL.iAxis].stConfig.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN - IF NOT aFbRestorePosition[GVL.iAxis].Done THEN + FOR iAxes:= 1 TO gvl_app.nAxisNum DO + IF aFbReadEncRefSys[iAxes].Valid = TRUE AND aFbReadEncRefSys[iAxes].Value = 0 AND NOT(aAxesPersistent[iAxes].bMovingAtShutdown) THEN + IF GVL.aAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN + IF NOT aFbRestorePosition[iAxes].Done THEN RETURN; END_IF END_IF @@ -183,8 +184,8 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN eFinishRestore: // Remove execute = TRUE for aFbRestorePosition - FOR GVL.iAxis:= 1 TO gvl_app.nAxisNum DO - aFbRestorePosition[GVL.iAxis].Execute := FALSE; + FOR iAxes:= 1 TO gvl_app.nAxisNum DO + aFbRestorePosition[iAxes].Execute := FALSE; END_FOR bPositionRestoreDone := TRUE; bRestoreExecute := FALSE; @@ -194,14 +195,14 @@ END_IF]]> - 0 THEN - aAxesPersistent[GVL.iAxis].bMovingAtShutdown := TRUE; + 0 THEN + aAxesPersistent[iAxes].bMovingAtShutdown := TRUE; ELSE - aAxesPersistent[GVL.iAxis].bMovingAtShutdown := FALSE; + aAxesPersistent[iAxes].bMovingAtShutdown := FALSE; END_IF - aAxesPersistent[GVL.iAxis].bMovingAtShutdown := aAxesPersistent[GVL.iAxis].bMovingAtShutdown OR gvl.aAxes[GVL.iAxis].Axis.Status.Moving; + aAxesPersistent[iAxes].bMovingAtShutdown := aAxesPersistent[iAxes].bMovingAtShutdown OR gvl.aAxes[iAxes].Axis.Status.Moving; END_FOR]]> diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index 8562f04..d16fa54 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit 8562f04c5bd1ff6ce796f1d4a12fe2096c483265 +Subproject commit d16fa54e4cb29aff9848361d8207752748589ab3 From b30a96abbecda809286bba3aa9b51334f29ad592 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Thu, 19 Mar 2020 14:01:13 +0100 Subject: [PATCH 16/36] Change all the files in the directory 'Test' to follow coding standards --- .../tc_project_app/Test/common/FB_tcUNIT_common.TcPOU | 11 ++++++----- .../Test/standard_library_tests/FB_Axis_TEST.TcPOU | 10 ++++++---- .../standard_library_tests/tcUNIT_STD_LIB_RUN.TcPOU | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) 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 fa2a214..887ef5a 100644 --- a/solution/tc_project_app/Test/common/FB_tcUNIT_common.TcPOU +++ b/solution/tc_project_app/Test/common/FB_tcUNIT_common.TcPOU @@ -5,6 +5,7 @@ FUNCTION_BLOCK FB_tcUNIT_common VAR + END_VAR]]> @@ -12,7 +13,7 @@ END_VAR]]> @@ -21,7 +22,7 @@ END_VAR]]> @@ -31,7 +32,7 @@ END_VAR]]> of the axis within GVL.aAxes[] to test against. + iTargetAxis: UINT := 1; // The of the axis within GVL.aAxes[] to test against. END_VAR]]> @@ -96,7 +97,7 @@ END_VAR]]> ExpectedResult := tcUNIT_gvl.fDEFAULT_TARGET_ACCELERATION; fbCommon.mPrepareDefaultMove(iTargetAxis); -Result := GVL.aAxes[1].stConfig.fAcceleration; +Result := GVL.aAxes[iTargetAxis].stConfig.fAcceleration; AssertEquals(Expected := ExpectedResult, Actual := Result, @@ -110,6 +111,7 @@ TEST_FINISHED();]]> VAR Result: BOOL; ExpectedResult: BOOL; + nCycle: UINT; nMaxCycles: UINT := 30; END_VAR]]> @@ -119,7 +121,7 @@ END_VAR]]> // example of test that requires multiple cycles to complete. Due to stateful behaviour of the axis structure. ExpectedResult := TRUE; -GVL.aAxes[1].stControl.bEnable := ExpectedResult; +GVL.aAxes[iTargetAxis].stControl.bEnable := ExpectedResult; Result := GVL.aAxes[iTargetAxis].stStatus.bEnabled; @@ -167,7 +169,7 @@ AssertEquals_LREAL(Expected := ExpectedResult, VAR Result: BOOL; ExpectedResult: BOOL; - + nCycle: UINT; nMaxCycles: UINT := 30; END_VAR]]> 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..55deaca 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 @@ -5,7 +5,7 @@ PROGRAM tcUNIT_STD_LIB_RUN VAR // Declare standard library POU tests to be run - fbFB_Axis: FB_Axis_TEST; + fbAxisTest: FB_Axis_TEST; END_VAR]]> From f22ce8c6d011a8feb676a8e601a330e271123443 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Thu, 19 Mar 2020 14:09:14 +0100 Subject: [PATCH 17/36] Move VISU directory a level higher, directly under tc_mca_std_lib --- solution/tc_project_app/GlobalTextList.TcGTLO | 25 +++++++++++++++++++ solution/tc_project_app/tc_mca_std_lib | 2 +- .../tc_project_app/tc_project_app.plcproj | 9 +++---- 3 files changed, 30 insertions(+), 6 deletions(-) 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/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index d16fa54..e5e306c 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit d16fa54e4cb29aff9848361d8207752748589ab3 +Subproject commit e5e306c46d2352de09e685dcb6c67368e98c63df diff --git a/solution/tc_project_app/tc_project_app.plcproj b/solution/tc_project_app/tc_project_app.plcproj index 2aa3825..9ca7353 100644 --- a/solution/tc_project_app/tc_project_app.plcproj +++ b/solution/tc_project_app/tc_project_app.plcproj @@ -93,14 +93,14 @@ Code - + Code - + Code Visualization Manager.TcVMO - + Code @@ -125,6 +125,7 @@ + @@ -133,11 +134,9 @@ - - From da6253ae7539706de3196b2fc2eecd5aef14f6cc Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Thu, 19 Mar 2020 14:24:15 +0100 Subject: [PATCH 18/36] Add enum for Homing routines --- solution/tc_project_app/tc_mca_std_lib | 2 +- solution/tc_project_app/tc_project_app.plcproj | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index e5e306c..9bbac03 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit e5e306c46d2352de09e685dcb6c67368e98c63df +Subproject commit 9bbac03e0ef086fbff3aca5ee592dc7504683c38 diff --git a/solution/tc_project_app/tc_project_app.plcproj b/solution/tc_project_app/tc_project_app.plcproj index 9ca7353..23aa3e4 100644 --- a/solution/tc_project_app/tc_project_app.plcproj +++ b/solution/tc_project_app/tc_project_app.plcproj @@ -30,6 +30,9 @@ Code + + Code + Code From 9a0e70450f11601197de71f2b79d059ab32a77c4 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Thu, 19 Mar 2020 16:10:39 +0100 Subject: [PATCH 19/36] Add enums and change refernces for Homing Routines and for Homing states in FB_Homing --- solution/tc_project_app/tc_mca_std_lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index 9bbac03..18f168b 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit 9bbac03e0ef086fbff3aca5ee592dc7504683c38 +Subproject commit 18f168b9f63e6efb0b98141bba3877f1a69d88c8 From 594d4cd2081bb4df4df6ebcc149a2ba2465491cf Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Thu, 19 Mar 2020 17:22:35 +0100 Subject: [PATCH 20/36] Fix white space damage --- solution/tc_project_app/POUs/MAIN.TcPOU | 2 +- solution/tc_project_app/Test/common/FB_tcUNIT_common.TcPOU | 2 +- .../Test/standard_library_tests/FB_Axis_TEST.TcPOU | 6 +++--- solution/tc_project_app/tc_mca_std_lib | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index c13b5c3..6cafbb4 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -24,7 +24,7 @@ VAR bRestoreExecute: BOOL := FALSE; bExecuteReadEncRefSys: BOOL := FALSE; nRetry: INT; - iAxes : UINT; //index for for loops in Position recovery actions + iAxes : UINT; //index for for loops in Position recovery actions aFbReadEncRefSys: ARRAY [1..gvl_app.nAxisNum] OF MC_ReadParameter; aFbRestorePosition: ARRAY [1..GVL_app.nAxisNum] OF MC_SetPosition; fbGetDeviceIdentification: FB_GetDeviceIdentification; 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 887ef5a..0ad5a11 100644 --- a/solution/tc_project_app/Test/common/FB_tcUNIT_common.TcPOU +++ b/solution/tc_project_app/Test/common/FB_tcUNIT_common.TcPOU @@ -5,7 +5,7 @@ FUNCTION_BLOCK FB_tcUNIT_common VAR - + END_VAR]]> 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 4f96381..eb8f5cc 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 @@ -52,7 +52,7 @@ VAR InitialValue: LREAL; Result: LREAL; ExpectedResult: LREAL; - + nCycle: UINT; nCycleMax: UINT := 100; END_VAR]]> @@ -111,7 +111,7 @@ TEST_FINISHED();]]> VAR Result: BOOL; ExpectedResult: BOOL; - + nCycle: UINT; nMaxCycles: UINT := 30; END_VAR]]> @@ -169,7 +169,7 @@ AssertEquals_LREAL(Expected := ExpectedResult, VAR Result: BOOL; ExpectedResult: BOOL; - + nCycle: UINT; nMaxCycles: UINT := 30; END_VAR]]> diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index 18f168b..82f30f3 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit 18f168b9f63e6efb0b98141bba3877f1a69d88c8 +Subproject commit 82f30f3b4a4f92238732ea4ee26231c12c97d33c From 217ef3302185570d09ee240b023e9a94db2a855d Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Fri, 20 Mar 2020 16:53:47 +0100 Subject: [PATCH 21/36] Update tc_mca_std_lib pointer to latest commit 4c2008fa --- solution/tc_project_app/tc_mca_std_lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index 82f30f3..4c2008f 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit 82f30f3b4a4f92238732ea4ee26231c12c97d33c +Subproject commit 4c2008fae85c684037b5419a426163e96b0f3b6a From 743ad6c6d8848fcccf939833988758166b7362e4 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Mon, 23 Mar 2020 14:15:21 +0100 Subject: [PATCH 22/36] Change the array variables of Main and all thier refernces to follow coding standards --- solution/tc_project_app/POUs/MAIN.TcPOU | 48 ++++++++++++------------- solution/tc_project_app/tc_mca_std_lib | 2 +- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 6cafbb4..69d8eaf 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -4,7 +4,7 @@ @@ -84,7 +84,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.aAxes[iAxes].stConfig.eRestorePosition is non-zero. +// By default an axis will not restore the position unless it is set to opt-in, i.e. GVL.aAxes[iAxes].stConfig.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,8 +104,8 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN // 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.nAxisNum DO - aFbReadEncRefSys[iAxes]( - Axis := gvl.aAxes[iAxes].Axis, + afbReadEncRefSys[iAxes]( + Axis := GVL.aAxes[iAxes].Axis, Enable := bExecuteReadEncRefSys, ParameterNumber := MC_AxisParameter.AxisEncoderReferenceSystem, Value=>, @@ -114,8 +114,8 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN // Cycle through set position function blocks for each axis FOR iAxes:= 1 TO gvl_app.nAxisNum DO - aFbRestorePosition[iAxes]( - Axis := gvl.aAxes[iAxes].Axis, + afbRestorePosition[iAxes]( + Axis := GVL.aAxes[iAxes].Axis, Execute := , Position := aAxesPersistent[iAxes].fPositionAtShutdown); END_FOR @@ -135,20 +135,20 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN 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 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.nAxisNum DO - IF aFbReadEncRefSys[iAxes].Valid = FALSE THEN - IF aFbReadEncRefSys[iAxes].Busy = TRUE THEN + 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 aFbReadEncRefSys[iAxes] misses the rising edge. If the code gets here it means + // 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 + 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 @@ -157,11 +157,11 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN eStartUp := eExecuteRestore; eExecuteRestore: - // Execute position restore by setting aFbRestorePosition.execute = TRUE + // Execute position restore by setting afbRestorePosition.execute = TRUE FOR iAxes:= 1 TO gvl_app.nAxisNum DO - IF aFbReadEncRefSys[iAxes].Valid = TRUE AND aFbReadEncRefSys[iAxes].Value = 0 AND NOT(aAxesPersistent[iAxes].bMovingAtShutdown) THEN + IF afbReadEncRefSys[iAxes].Valid = TRUE AND afbReadEncRefSys[iAxes].Value = 0 AND NOT(aAxesPersistent[iAxes].bMovingAtShutdown) THEN IF GVL.aAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN - aFbRestorePosition[iAxes].Execute := TRUE; + afbRestorePosition[iAxes].Execute := TRUE; END_IF END_IF END_FOR @@ -172,9 +172,9 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN // 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.nAxisNum DO - IF aFbReadEncRefSys[iAxes].Valid = TRUE AND aFbReadEncRefSys[iAxes].Value = 0 AND NOT(aAxesPersistent[iAxes].bMovingAtShutdown) THEN + IF afbReadEncRefSys[iAxes].Valid = TRUE AND afbReadEncRefSys[iAxes].Value = 0 AND NOT(aAxesPersistent[iAxes].bMovingAtShutdown) THEN IF GVL.aAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN - IF NOT aFbRestorePosition[iAxes].Done THEN + IF NOT afbRestorePosition[iAxes].Done THEN RETURN; END_IF END_IF @@ -183,9 +183,9 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN eStartUp := eFinishRestore; eFinishRestore: - // Remove execute = TRUE for aFbRestorePosition + // Remove execute = TRUE for afbRestorePosition FOR iAxes:= 1 TO gvl_app.nAxisNum DO - aFbRestorePosition[iAxes].Execute := FALSE; + afbRestorePosition[iAxes].Execute := FALSE; END_FOR bPositionRestoreDone := TRUE; bRestoreExecute := FALSE; @@ -196,13 +196,13 @@ END_IF]]> 0 THEN + aAxesPersistent[iAxes].fPositionAtShutdown := GVL.aAxes[iAxes].Axis.NcToPlc.ActPos; + IF GVL.aAxes[iAxes].Axis.NcToPlc.ActVelo <> 0 THEN aAxesPersistent[iAxes].bMovingAtShutdown := TRUE; ELSE aAxesPersistent[iAxes].bMovingAtShutdown := FALSE; END_IF - aAxesPersistent[iAxes].bMovingAtShutdown := aAxesPersistent[iAxes].bMovingAtShutdown OR gvl.aAxes[iAxes].Axis.Status.Moving; + aAxesPersistent[iAxes].bMovingAtShutdown := aAxesPersistent[iAxes].bMovingAtShutdown OR GVL.aAxes[iAxes].Axis.Status.Moving; END_FOR]]> diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index 4c2008f..0f796b5 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit 4c2008fae85c684037b5419a426163e96b0f3b6a +Subproject commit 0f796b525e92bde0ec76304181d58f5b8151520c From 3181c4b69f7f60e30080c59000ab4fb41dd57810 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Mon, 23 Mar 2020 14:35:31 +0100 Subject: [PATCH 23/36] Delete space after // from restor position actions --- solution/tc_project_app/POUs/MAIN.TcPOU | 92 ++++++++++++------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 69d8eaf..afe7ea8 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -4,7 +4,7 @@ - @@ -81,84 +81,81 @@ END_IF]]> , ReadMode := E_READMODE.READMODE_ONCE); END_FOR - // Cycle through set position function blocks for each axis - FOR iAxes:= 1 TO gvl_app.nAxisNum DO + //Cycle through set position function blocks for each axis + FOR iAxes := 1 TO GVL_APP.nAxisNum DO afbRestorePosition[iAxes]( Axis := GVL.aAxes[iAxes].Axis, - Execute := , Position := aAxesPersistent[iAxes].fPositionAtShutdown); END_FOR CASE eStartUp OF eColdStart: - // First cycle of the PLC, do nothing just give one cycle for variables to initialise + //First cycle of the PLC, do nothing just give one cycle for variables to initialise IF NOT bPositionRestoreDone THEN eStartUp := eReadAxisFeedbackType; nRetry := 0; END_IF eReadAxisFeedbackType: - // Exectute the function blocks to read the encoder reference system (0=inc OR 1=ABS) + //Exectute the function blocks to read the encoder reference system (0=inc OR 1=ABS) bExecuteReadEncRefSys := TRUE; eStartUp := eCheckReadDone; 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.nAxisNum DO + //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.nAxisNum 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 + //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 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. + //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 + 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 + //If the code gets here all axes either have .valid=TRUE for all axes eStartUp := eExecuteRestore; eExecuteRestore: - // Execute position restore by setting afbRestorePosition.execute = TRUE - FOR iAxes:= 1 TO gvl_app.nAxisNum DO + //Execute position restore by setting afbRestorePosition.execute = TRUE + FOR iAxes := 1 TO GVL_APP.nAxisNum DO IF afbReadEncRefSys[iAxes].Valid = TRUE AND afbReadEncRefSys[iAxes].Value = 0 AND NOT(aAxesPersistent[iAxes].bMovingAtShutdown) THEN IF GVL.aAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN afbRestorePosition[iAxes].Execute := TRUE; @@ -168,10 +165,10 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN eStartUp := eCheckRestore; 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.nAxisNum DO + //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.nAxisNum DO IF afbReadEncRefSys[iAxes].Valid = TRUE AND afbReadEncRefSys[iAxes].Value = 0 AND NOT(aAxesPersistent[iAxes].bMovingAtShutdown) THEN IF GVL.aAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN IF NOT afbRestorePosition[iAxes].Done THEN @@ -183,8 +180,8 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN eStartUp := eFinishRestore; eFinishRestore: - // Remove execute = TRUE for afbRestorePosition - FOR iAxes:= 1 TO gvl_app.nAxisNum DO + //Remove execute = TRUE for afbRestorePosition + FOR iAxes := 1 TO GVL_APP.nAxisNum DO afbRestorePosition[iAxes].Execute := FALSE; END_FOR bPositionRestoreDone := TRUE; @@ -195,7 +192,7 @@ END_IF]]> - 0 THEN aAxesPersistent[iAxes].bMovingAtShutdown := TRUE; @@ -228,7 +225,10 @@ END_FOR]]> - + + + + From 9105bd2001aca8717b4a2226d7d4ecf6e0d775ab Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Mon, 23 Mar 2020 14:46:09 +0100 Subject: [PATCH 24/36] Change variable nHomeSeq to eHomeSeq inside Test actions --- solution/tc_project_app/Test/common/FB_tcUNIT_common.TcPOU | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 0ad5a11..8b6c22a 100644 --- a/solution/tc_project_app/Test/common/FB_tcUNIT_common.TcPOU +++ b/solution/tc_project_app/Test/common/FB_tcUNIT_common.TcPOU @@ -108,7 +108,7 @@ GVL.aAxes[iAxisIndex].stConfig.fAcceleration := 0.0; GVL.aAxes[iAxisIndex].stConfig.fDeceleration := 0.0; GVL.aAxes[iAxisIndex].stConfig.fPosition := 0; GVL.aAxes[iAxisIndex].stConfig.fOverride := 0.0; -GVL.aAxes[iAxisIndex].stConfig.nHomeSeq := 0; +GVL.aAxes[iAxisIndex].stConfig.eHomeSeq := 0; GVL.aAxes[iAxisIndex].stInputs.bLimitBwd := FALSE; GVL.aAxes[iAxisIndex].stInputs.bLimitFwd := FALSE; From a8e4f888847c89a64000e40ee3c176f70548d7d7 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Mon, 23 Mar 2020 14:46:56 +0100 Subject: [PATCH 25/36] Delete sapces after //, add e to variables in E_RestorePosition --- solution/tc_project_app/POUs/MAIN.TcPOU | 9 +++------ solution/tc_project_app/tc_mca_std_lib | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index afe7ea8..a92e36b 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -157,7 +157,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN //Execute position restore by setting afbRestorePosition.execute = TRUE FOR iAxes := 1 TO GVL_APP.nAxisNum DO IF afbReadEncRefSys[iAxes].Valid = TRUE AND afbReadEncRefSys[iAxes].Value = 0 AND NOT(aAxesPersistent[iAxes].bMovingAtShutdown) THEN - IF GVL.aAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN + IF GVL.aAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN afbRestorePosition[iAxes].Execute := TRUE; END_IF END_IF @@ -170,7 +170,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN //bPositionRestoreDone will never get set to TRUE and will take up cycle time FOR iAxes := 1 TO GVL_APP.nAxisNum DO IF afbReadEncRefSys[iAxes].Valid = TRUE AND afbReadEncRefSys[iAxes].Value = 0 AND NOT(aAxesPersistent[iAxes].bMovingAtShutdown) THEN - IF GVL.aAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN + IF GVL.aAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN IF NOT afbRestorePosition[iAxes].Done THEN RETURN; END_IF @@ -225,10 +225,7 @@ END_FOR]]> - - - - + diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index 0f796b5..ce74fab 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit 0f796b525e92bde0ec76304181d58f5b8151520c +Subproject commit ce74fabc3a6ca96fa820727ab149d2fee89079fc From 5399e85127f28a2fb0a609d8380690620a6f685d Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Mon, 23 Mar 2020 15:13:51 +0100 Subject: [PATCH 26/36] Update refrences from GVL variable aAxes to astAxes --- solution/tc_project_app/POUs/MAIN.TcPOU | 31 ++++--- .../Test/common/FB_tcUNIT_common.TcPOU | 82 +++++++++---------- .../standard_library_tests/FB_Axis_TEST.TcPOU | 28 +++---- 3 files changed, 70 insertions(+), 71 deletions(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index a92e36b..248bc6e 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -43,7 +43,7 @@ AXES();]]> @@ -80,8 +80,7 @@ END_IF]]> - 0 THEN - aAxesPersistent[iAxes].bMovingAtShutdown := TRUE; + astAxesPersistent[iAxes].fPositionAtShutdown := GVL.astAxes[iAxes].Axis.NcToPlc.ActPos; + IF GVL.astAxes[iAxes].Axis.NcToPlc.ActVelo <> 0 THEN + astAxesPersistent[iAxes].bMovingAtShutdown := TRUE; ELSE - aAxesPersistent[iAxes].bMovingAtShutdown := FALSE; + astAxesPersistent[iAxes].bMovingAtShutdown := FALSE; END_IF - aAxesPersistent[iAxes].bMovingAtShutdown := aAxesPersistent[iAxes].bMovingAtShutdown OR GVL.aAxes[iAxes].Axis.Status.Moving; + astAxesPersistent[iAxes].bMovingAtShutdown := astAxesPersistent[iAxes].bMovingAtShutdown OR GVL.astAxes[iAxes].Axis.Status.Moving; END_FOR]]> @@ -225,7 +224,7 @@ 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 8b6c22a..45b66bc 100644 --- a/solution/tc_project_app/Test/common/FB_tcUNIT_common.TcPOU +++ b/solution/tc_project_app/Test/common/FB_tcUNIT_common.TcPOU @@ -16,7 +16,7 @@ VAR_INPUT iAxisIndex: UINT; // The idex of the axis to action the method on. END_VAR]]> - + @@ -25,7 +25,7 @@ VAR_INPUT iAxisIndex: UINT; // The idex of the axis to action the method on. END_VAR]]> - + @@ -37,17 +37,17 @@ END_VAR]]> +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;]]> @@ -64,16 +64,16 @@ END_VAR]]> +GVL.astAxes[iAxisIndex].stConfig.fVelocity := fTargetVelocity; +GVL.astAxes[iAxisIndex].stConfig.fAcceleration := fTargetAcceleration; +GVL.astAxes[iAxisIndex].stConfig.fDeceleration := fTargetDeceleration; +GVL.astAxes[iAxisIndex].stConfig.fPosition := fTargetPosition;]]> @@ -85,34 +85,34 @@ END_VAR]]> +GVL.astAxes[iAxisIndex].stInputs.bLimitBwd := FALSE; +GVL.astAxes[iAxisIndex].stInputs.bLimitFwd := FALSE; +GVL.astAxes[iAxisIndex].stInputs.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 eb8f5cc..9166d5a 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 @@ -34,7 +34,7 @@ ExpectedResult := TRUE; fbCommon.mPrepareDefaultMove(iTargetAxis); fbCommon.mExecute(iTargetAxis); -Result := GVL.aAxes[iTargetAxis].stStatus.bBusy; +Result := GVL.astAxes[iTargetAxis].stStatus.bBusy; IF nCycle > nMaxCycles OR ExpectedResult = Result THEN AssertEquals(Expected := ExpectedResult, @@ -63,14 +63,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.aAxes[iTargetAxis].stConfig.fPosition; +InitialValue := GVL.astAxes[iTargetAxis].stConfig.fPosition; ExpectedResult := InitialValue + 10; -GVL.aAxes[iTargetAxis].stConfig.fPosition := ExpectedResult; +GVL.astAxes[iTargetAxis].stConfig.fPosition := ExpectedResult; -GVL.aAxes[iTargetAxis].stControl.eCommand := E_MotionFunctions.eMoveAbsolute; -GVL.aAxes[iTargetAxis].stControl.bExecute := TRUE; +GVL.astAxes[iTargetAxis].stControl.eCommand := E_MotionFunctions.eMoveAbsolute; +GVL.astAxes[iTargetAxis].stControl.bExecute := TRUE; -Result := GVL.aAxes[iTargetAxis].stStatus.fActPosition; +Result := GVL.astAxes[iTargetAxis].stStatus.fActPosition; IF nCycle > nCycleMax OR ExpectedResult = Result THEN AssertEquals(Expected := ExpectedResult, @@ -97,7 +97,7 @@ END_VAR]]> ExpectedResult := tcUNIT_gvl.fDEFAULT_TARGET_ACCELERATION; fbCommon.mPrepareDefaultMove(iTargetAxis); -Result := GVL.aAxes[iTargetAxis].stConfig.fAcceleration; +Result := GVL.astAxes[iTargetAxis].stConfig.fAcceleration; AssertEquals(Expected := ExpectedResult, Actual := Result, @@ -121,9 +121,9 @@ END_VAR]]> // example of test that requires multiple cycles to complete. Due to stateful behaviour of the axis structure. ExpectedResult := TRUE; -GVL.aAxes[iTargetAxis].stControl.bEnable := ExpectedResult; +GVL.astAxes[iTargetAxis].stControl.bEnable := ExpectedResult; -Result := GVL.aAxes[iTargetAxis].stStatus.bEnabled; +Result := GVL.astAxes[iTargetAxis].stStatus.bEnabled; IF nCycle > nMaxCycles OR ExpectedResult = Result THEN AssertEquals(Expected := ExpectedResult, @@ -150,11 +150,11 @@ END_VAR]]> // Example of using a tcUNIT assert for a specific type (in this case LREAL). -InitialValue := GVL.aAxes[iTargetAxis].stConfig.fVelocity; +InitialValue := GVL.astAxes[iTargetAxis].stConfig.fVelocity; ExpectedResult := InitialValue + 0.5; -GVL.aAxes[iTargetAxis].stConfig.fVelocity := ExpectedResult; +GVL.astAxes[iTargetAxis].stConfig.fVelocity := ExpectedResult; -Result := GVL.aAxes[iTargetAxis].stConfig.fVelocity; +Result := GVL.astAxes[iTargetAxis].stConfig.fVelocity; AssertEquals_LREAL(Expected := ExpectedResult, Actual := Result, @@ -178,9 +178,9 @@ END_VAR]]> ExpectedResult := TRUE; -GVL.aAxes[iTargetAxis].stInputs.bLimitFwd := TRUE; +GVL.astAxes[iTargetAxis].stInputs.bLimitFwd := TRUE; -Result := GVL.aAxes[iTargetAxis].stStatus.bFwEnabled; +Result := GVL.astAxes[iTargetAxis].stStatus.bFwEnabled; IF nCycle > nMaxCycles OR ExpectedResult = Result THEN AssertEquals(Expected := ExpectedResult, From 8c554fd19c805ed6ea56cc3e29b942617f4c6e05 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Mon, 23 Mar 2020 15:43:39 +0100 Subject: [PATCH 27/36] Delete space after //comment in all POU in Test directory --- .../Test/common/FB_tcUNIT_common.TcPOU | 22 +++++++++---------- .../Test/common/tcUNIT_GVL.TcGVL | 5 ++--- .../standard_library_tests/FB_Axis_TEST.TcPOU | 18 +++++++-------- .../tcUNIT_STD_LIB_RUN.TcPOU | 4 ++-- 4 files changed, 24 insertions(+), 25 deletions(-) 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 45b66bc..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,7 +1,7 @@  - - - @@ -32,10 +32,10 @@ END_VAR]]> - - - - of the axis within GVL.aAxes[] to test against. + iTargetAxis: UINT := 1; //The of the axis within GVL.astAxes[] to test against. END_VAR]]> - - From e485fcc455a8bd0a0cc97ac03e22a0dbe3881485 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Mon, 23 Mar 2020 15:44:23 +0100 Subject: [PATCH 28/36] Changes in tc_mca_std_lib to follow coding standards --- solution/tc_project_app/tc_mca_std_lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index ce74fab..34c251c 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit ce74fabc3a6ca96fa820727ab149d2fee89079fc +Subproject commit 34c251c69ffdb9d44e0a6b78f80cec58a8a8357c From 277f7544b015fdcd9b57d3a88b344f7b1c1fd1af Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Mon, 23 Mar 2020 15:49:46 +0100 Subject: [PATCH 29/36] Change in E_MotorTypeClass from eNoMotor to eVirtualMotor --- solution/tc_project_app/tc_mca_std_lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index 34c251c..c0ef6d0 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit 34c251c69ffdb9d44e0a6b78f80cec58a8a8357c +Subproject commit c0ef6d077e42998c0aa682815f93c0b2882587e4 From 089fd4700fd6c10f9734ef4ff0adefc913894cec Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Mon, 23 Mar 2020 15:53:16 +0100 Subject: [PATCH 30/36] fix white space damage --- solution/tc_project_app/tc_mca_std_lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index c0ef6d0..a378751 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit c0ef6d077e42998c0aa682815f93c0b2882587e4 +Subproject commit a3787511c66bd44de166471e607e14879d30120e From 5fd88c7f229303cc6b77322ed438dede5bfa363a Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Tue, 24 Mar 2020 10:53:13 +0100 Subject: [PATCH 31/36] Update pointer to latest commit of tc_mca_std_lib --- solution/tc_project_app/tc_mca_std_lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index a378751..c5bd6a3 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit a3787511c66bd44de166471e607e14879d30120e +Subproject commit c5bd6a371457d5d1533357d68a67677588fdc884 From 4be8acede15f4f5b488fa90c7f9304cd0b1cc87f Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Wed, 25 Mar 2020 12:51:52 +0100 Subject: [PATCH 32/36] Fix indenting of comments --- solution/tc_project_app/tc_mca_std_lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index c5bd6a3..969474b 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit c5bd6a371457d5d1533357d68a67677588fdc884 +Subproject commit 969474bec590bea5481d0af9e34c9cce2b1c706b From a77bf83d00c5237c55ea6435064238c3ccaa090e Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Wed, 25 Mar 2020 13:06:34 +0100 Subject: [PATCH 33/36] Delete an extra ENTER - cosmetic --- solution/tc_project_app/POUs/MAIN.TcPOU | 1 - 1 file changed, 1 deletion(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 248bc6e..76b6960 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -28,7 +28,6 @@ VAR afbReadEncRefSys: ARRAY [1..GVL_APP.nAxisNum] OF MC_ReadParameter; afbRestorePosition: ARRAY [1..GVL_APP.nAxisNum] OF MC_SetPosition; fbGetDeviceIdentification: FB_GetDeviceIdentification; - END_VAR VAR PERSISTENT From a02cbe7b3aaa20e514872bb08c45b5901069bbef Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Wed, 25 Mar 2020 13:14:37 +0100 Subject: [PATCH 34/36] Fix white space damage --- solution/tc_project_app/tc_mca_std_lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index 969474b..5cd3640 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit 969474bec590bea5481d0af9e34c9cce2b1c706b +Subproject commit 5cd3640dcfacd1fca1abc29cbca2c53e4ba88636 From 43d13b93209b62e46197c366af3652342b435280 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Fri, 27 Mar 2020 13:31:48 +0100 Subject: [PATCH 35/36] Change homing stat eHomeFbDone to eHomeWaitForFbDone --- solution/tc_project_app/tc_mca_std_lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index 5cd3640..51ab59a 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit 5cd3640dcfacd1fca1abc29cbca2c53e4ba88636 +Subproject commit 51ab59a9140f8f7a745eae34f1e0654bac3a1cfc From 48dafb43a47327faebfd0cca4eec300e8c99d02b Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Fri, 3 Apr 2020 15:14:25 +0200 Subject: [PATCH 36/36] Change GVL_APP.nAxisNum to GVL_APP.nAXIS_NUM because it is a constant --- solution/tc_project_app/GVLs/GVL_APP.TcGVL | 2 +- solution/tc_project_app/POUs/MAIN.TcPOU | 22 +++++++++++----------- solution/tc_project_app/tc_mca_std_lib | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/solution/tc_project_app/GVLs/GVL_APP.TcGVL b/solution/tc_project_app/GVLs/GVL_APP.TcGVL index d6f0aab..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 - nAxisNum : UINT:=0; + nAXIS_NUM : UINT:=0; END_VAR]]> \ No newline at end of file diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 76b6960..c0a18e8 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -4,7 +4,7 @@ - @@ -100,7 +100,7 @@ END_IF IF bRestoreExecute AND NOT bPositionRestoreDone THEN //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.nAxisNum DO + FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO afbReadEncRefSys[iAxes]( Axis := GVL.astAxes[iAxes].Axis, Enable := bExecuteReadEncRefSys, @@ -109,7 +109,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN END_FOR //Cycle through set position function blocks for each axis - FOR iAxes := 1 TO GVL_APP.nAxisNum DO + FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO afbRestorePosition[iAxes]( Axis := GVL.astAxes[iAxes].Axis, Position := astAxesPersistent[iAxes].fPositionAtShutdown); @@ -132,7 +132,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN //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.nAxisNum DO + 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 @@ -153,7 +153,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN eExecuteRestore: //Execute position restore by setting afbRestorePosition.execute = TRUE - FOR iAxes := 1 TO GVL_APP.nAxisNum DO + 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; @@ -166,7 +166,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN //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.nAxisNum DO + 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 @@ -179,7 +179,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN eFinishRestore: //Remove execute = TRUE for afbRestorePosition - FOR iAxes := 1 TO GVL_APP.nAxisNum DO + FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO afbRestorePosition[iAxes].Execute := FALSE; END_FOR bPositionRestoreDone := TRUE; @@ -190,7 +190,7 @@ END_IF]]> - 0 THEN astAxesPersistent[iAxes].bMovingAtShutdown := TRUE; diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index 51ab59a..08a5fd1 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit 51ab59a9140f8f7a745eae34f1e0654bac3a1cfc +Subproject commit 08a5fd1399ee7f333765229a2737919377ea0e6e