From 1079229ffb7948f452ddd2b3b5515f9300a066db Mon Sep 17 00:00:00 2001 From: Simon-Cooper <39404307+Simon-Cooper@users.noreply.github.com> Date: Fri, 7 Feb 2020 10:17:46 +0000 Subject: [PATCH 1/9] ALLOW LOCAL SIMULATIONS TO BYBASS UPS CHECK Add CHECK_UPS action to house monitoring of the UPS global status Modify RESTORE_POSITIONS state machine to remove numerical enumeration usage Add device identity functionblock to check whether local simulation or CX Add POSITION RECOVERY action to check device type and determine whether to run position restore and ups checking Add solution/_Config/ folder to gitignore to remove NC and IO --- .gitignore | 1 + solution/solution.tsproj | 129 ++++++++---------------- solution/tc_project_app/POUs/MAIN.TcPOU | 73 +++++++++----- 3 files changed, 91 insertions(+), 112 deletions(-) diff --git a/.gitignore b/.gitignore index 8f8c117..cab1dc8 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ logs.0* solution/TrialLicense.tclrs tools/linux/ADS/ tools/linux/getADSState/getADSState.bin +_Config/ diff --git a/solution/solution.tsproj b/solution/solution.tsproj index f74cba4..5dd70ed 100644 --- a/solution/solution.tsproj +++ b/solution/solution.tsproj @@ -1,8 +1,8 @@ - + - NCTOPLC_AXIS_REF_STATE + NCTOPLC_AXIS_REF_STATE 32 Operational @@ -112,6 +112,12 @@ 1 17 + + IsDriveLimitActive + BIT + 1 + 18 + ContinuousMotion BIT @@ -199,6 +205,11 @@ 16#%08X + + + {4C3FC5AC-D5AA-44C6-AC5A-159774BA0F6D} + + NCTOPLC_AXIS_REF_OPMODE @@ -394,11 +405,11 @@ - NCTOPLC_AXIS_REF + NCTOPLC_AXIS_REF 2048 StateDWord - NCTOPLC_AXIS_REF_STATE + NCTOPLC_AXIS_REF_STATE 32 0 @@ -646,6 +657,18 @@ External Setpoint Generation: 64 1600 + + AbsPhasingPos + LREAL + 64 + 1664 + + + TorqueOffset + LREAL + 64 + 1728 + ActPosWithoutPosCorrection LREAL @@ -692,6 +715,9 @@ External Setpoint Generation: + + + @@ -873,7 +899,7 @@ External Setpoint Generation: - + @@ -889,6 +915,9 @@ External Setpoint Generation: + + + @@ -927,46 +956,7 @@ External Setpoint Generation: GVL.axes[1].Axis.NcToPlc - NCTOPLC_AXIS_REF - - AxisState - - - - HomingState - - - - CoupleState - - + NCTOPLC_AXIS_REF GVL.axes[2].inputs.bLimitFwd @@ -990,46 +980,7 @@ External Setpoint Generation: GVL.axes[2].Axis.NcToPlc - NCTOPLC_AXIS_REF - - AxisState - - - - HomingState - - - - CoupleState - - + NCTOPLC_AXIS_REF @@ -1055,4 +1006,12 @@ External Setpoint Generation: + + + + + + + + diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index f81cabd..5eebc02 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -1,5 +1,5 @@  - + - + + + + + + + + + + eSUPS_PowerFailure THEN +ELSIF eGlobalSUpsState <> eSUPS_PowerOK THEN (* next cycles of powerfailure *) (* skip regular code execution for the remaining cycles of the powerfailure/writing of persistent data/quick shutdown ... *) RETURN; -END_IF - -RESTORE_POSITIONS(); -PROG(); -AXES(); -ERROR();]]> - - - - +END_IF]]> @@ -121,6 +126,15 @@ fbEL1808( ]]> + + + '0') THEN + CHECK_UPS(); + RESTORE_POSITIONS(); +END_IF]]> + + - + if busy then continue with PLC cycle and check again next time. @@ -199,14 +213,14 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN // .valid=FALSE and .busy=FALSE which indicateds the FB probably hasn't started and thus needs to see a rising edge. // Set execute to low, Exit MAIN.STARTUP and go back a step in the CASE statement. bExecuteReadEncRefSys:=FALSE; - eStartUp:=eStartUp-1; + eStartUp:=ReadAxisFeedbackType; iRetry:=iRetry+1; // counter used for troubleshooting to see how many cycles it takes before fbReadEncRefSys 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:=eStartUp+1; + eStartUp:= ExecuteRestore; ExecuteRestore: // Execute position restore by setting fbRestorePosition.execute = TRUE @@ -217,7 +231,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN END_IF END_IF END_FOR - eStartUp:=eStartUp+1; + eStartUp:= CheckRestore; CheckRestore: // Check the set position fbs are finished @@ -232,7 +246,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN END_IF END_IF END_FOR - eStartUp:=eStartUp+1; + eStartUp:= FinishRestore; FinishRestore: // Remove execute = TRUE for fbRestorePosition @@ -245,7 +259,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN END_IF]]> - + - - - - + @@ -271,6 +282,10 @@ END_FOR]]> + + + + @@ -287,6 +302,10 @@ END_FOR]]> + + + + From bcbc791fe1c96ad5e5ee7d3f89ff0542c5c17f36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Mon, 10 Feb 2020 10:39:51 +0100 Subject: [PATCH 2/9] Add solution/_Config/NC/NC.xti The NC.xti file is needed for the PLC NC task. So we re-add it here. --- solution/_Config/NC/NC.xti | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 solution/_Config/NC/NC.xti diff --git a/solution/_Config/NC/NC.xti b/solution/_Config/NC/NC.xti new file mode 100644 index 0000000..759c7a3 --- /dev/null +++ b/solution/_Config/NC/NC.xti @@ -0,0 +1,20 @@ + + + + + NC-Task 1 SAF + + Inputs + + + Outputs + + + Image + + + + NC-Task 1 SVB + + + From 5c19425abcf8d9d6fa746d0f03b297f059ff987c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Mon, 10 Feb 2020 10:42:26 +0100 Subject: [PATCH 3/9] Partly ignore solution/_Config/ We need NC/nc.xti to be able to run the NC PLC task. So don't ignore it. But ignore all IO and Axes. --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index cab1dc8..63a08bd 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ logs.0* solution/TrialLicense.tclrs tools/linux/ADS/ tools/linux/getADSState/getADSState.bin -_Config/ +_Config/NC/Axes +_Config/IO From b522fe177e0bbc8d54d67fe57e5bc5ff55bef52d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Mon, 10 Feb 2020 10:44:25 +0100 Subject: [PATCH 4/9] fix whitespace damage --- solution/tc_project_app/POUs/MAIN.TcPOU | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 5eebc02..2c922e6 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -48,7 +48,7 @@ VAR iRetry : INT; fbReadEncRefSys : ARRAY [1..gvl_app.axisNum] OF MC_ReadParameter; fbRestorePosition : ARRAY [1..GVL_app.axisNum] OF MC_SetPosition; - fbGetDeviceIdentification : FB_GetDeviceIdentification; + fbGetDeviceIdentification : FB_GetDeviceIdentification; END_VAR @@ -130,8 +130,8 @@ fbEL1808( '0') THEN - CHECK_UPS(); - RESTORE_POSITIONS(); + CHECK_UPS(); + RESTORE_POSITIONS(); END_IF]]> From b914a2f62ad9b004ad7c9cfb6d2b2e09a4038c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Mon, 10 Feb 2020 10:51:12 +0100 Subject: [PATCH 5/9] Initial number of axes is 0 Change axisNum in GVL_APP to 0 --- solution/tc_project_app/GVLs/GVL_APP.TcGVL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/tc_project_app/GVLs/GVL_APP.TcGVL b/solution/tc_project_app/GVLs/GVL_APP.TcGVL index 9e800ab..e125049 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:=2; + axisNum : UINT:=0; //axisCoupleMax : UINT:=4; END_VAR]]> From de53c24b1569826149def478bde4d7da1290cafb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Mon, 10 Feb 2020 10:53:57 +0100 Subject: [PATCH 6/9] solution.tsproj: Remove the 2 axes, commit with TC 3.1.4024.0 --- solution/solution.tsproj | 968 +-------------------------------------- 1 file changed, 1 insertion(+), 967 deletions(-) diff --git a/solution/solution.tsproj b/solution/solution.tsproj index 5dd70ed..36de82a 100644 --- a/solution/solution.tsproj +++ b/solution/solution.tsproj @@ -1,904 +1,5 @@ - - - - NCTOPLC_AXIS_REF_STATE - 32 - - Operational - BIT - 1 - 0 - - - Homed - BIT - 1 - 1 - - - NotMoving - BIT - 1 - 2 - - - InPositionArea - BIT - 1 - 3 - - - InTargetPosition - BIT - 1 - 4 - - - Protected - BIT - 1 - 5 - - - ErrorPropagationDelayed - BIT - 1 - 6 - - - HasBeenStopped - BIT - 1 - 7 - - - HasJob - BIT - 1 - 8 - - - PositiveDirection - BIT - 1 - 9 - - - NegativeDirection - BIT - 1 - 10 - - - HomingBusy - BIT - 1 - 11 - - - ConstantVelocity - BIT - 1 - 12 - - - Compensating - BIT - 1 - 13 - - - ExtSetPointGenEnabled - BIT - 1 - 14 - - - PhasingActive - BIT - 1 - 15 - - - ExternalLatchValid - BIT - 1 - 16 - - - NewTargetPos - BIT - 1 - 17 - - - IsDriveLimitActive - BIT - 1 - 18 - - - ContinuousMotion - BIT - 1 - 19 - - - ControlLoopClosed - BIT - 1 - 20 - - - CamTableQueued - BIT - 1 - 21 - - - CamDataQueued - BIT - 1 - 22 - - - CamScalingPending - BIT - 1 - 23 - - - CmdBuffered - BIT - 1 - 24 - - - PTPmode - BIT - 1 - 25 - - - SoftLimitMinExceeded - BIT - 1 - 26 - - - SoftLimitMaxExceeded - BIT - 1 - 27 - - - DriveDeviceError - BIT - 1 - 28 - - - MotionCommandsLocked - BIT - 1 - 29 - - - IoDataInvalid - BIT - 1 - 30 - - - Error - BIT - 1 - 31 - - - %08x - - - 0x%08x - - - 16#%08X - - - - {4C3FC5AC-D5AA-44C6-AC5A-159774BA0F6D} - - - - - NCTOPLC_AXIS_REF_OPMODE - 32 - - OpModePosAreaMonitoring - BIT - 1 - 0 - - - OpModeTargetPosMonitoring - BIT - 1 - 1 - - - OpModeLoop - BIT - 1 - 2 - - - OpModeMotionMonitoring - BIT - 1 - 3 - - - OpModePEHTimeMonitoring - BIT - 1 - 4 - - - OpModeBacklashCompensation - BIT - 1 - 5 - - - OpModeDelayedErrorReaction - BIT - 1 - 6 - - - OpModeModulo - BIT - 1 - 7 - - - OpModeSimulationAxis - BIT - 1 - 8 - - - OpModePosLagMonitoring - BIT - 1 - 16 - - - OpModeVeloLagMonitoring - BIT - 1 - 17 - - - OpModeSoftLimitMinMonitoring - BIT - 1 - 18 - - - OpModeSoftLimitMaxMonitoring - BIT - 1 - 19 - - - OpModePosCorrection - BIT - 1 - 20 - - - OpModeAllowSlaveCommands - BIT - 1 - 21 - - - OpModeAllowExtSetAxisCommands - BIT - 1 - 22 - - - ApplicationRequest - BIT - 1 - 23 - - - - NCTOPLC_AXIS_REF_STATE2_FLAGS - 32 - - AvoidingCollision - BIT - 1 - 0 - - - %08x - - - 0x%08x - - - 16#%08X - - - - NCTOPLC_AXIS_REF_STATE2 - 32 - - Value - DWORD - 32 - 0 - - - Flags - NCTOPLC_AXIS_REF_STATE2_FLAGS - 32 - 0 - - - %08x - - - 0x%08x - - - 16#%08X - - - - NCTOPLC_AXIS_REF_CAMCOUPLINGSTATE - 8 - - CamActivationPending - BIT - 1 - 0 - - - CamDeactivationPending - BIT - 1 - 1 - - - CamActive - BIT - 1 - 2 - - - CamDataQueued - BIT - 1 - 6 - - - CamScalingPending - BIT - 1 - 7 - - - - UINTARR8 - 128 - UINT - - 0 - 8 - - - - NCTOPLC_AXIS_REF - 2048 - - StateDWord - NCTOPLC_AXIS_REF_STATE - 32 - 0 - - - ErrorCode - UDINT - 32 - 32 - - - AxisState - UDINT - - 32 - 64 - - - AxisModeConfirmation - UDINT - 32 - 96 - - - HomingState - UDINT - - 32 - 128 - - - CoupleState - UDINT - - 32 - 160 - - - SvbEntries - UDINT - 32 - 192 - - - SafEntries - UDINT - 32 - 224 - - - AxisId - UDINT - 32 - 256 - - - OpModeDWord - NCTOPLC_AXIS_REF_OPMODE - 32 - 288 - - - ActPos - LREAL - 64 - 320 - - - ModuloActPos - LREAL - 64 - 384 - - - ActiveControlLoopIndex - UINT - 16 - 448 - - - ControlLoopIndex - UINT - 16 - 464 - - - ModuloActTurns - DINT - 32 - 480 - - - ActVelo - LREAL - 64 - 512 - - - PosDiff - LREAL - 64 - 576 - - - SetPos - LREAL - 64 - 640 - - - SetVelo - LREAL - 64 - 704 - - - SetAcc - LREAL - 64 - 768 - - - TargetPos - LREAL - 64 - 832 - - - ModuloSetPos - LREAL - 64 - 896 - - - ModuloSetTurns - DINT - 32 - 960 - - - CmdNo - UINT - 16 - 992 - - - CmdState - UINT - 16 - 1008 - - - SetJerk - LREAL - 64 - 1024 - - - SetTorque - LREAL - 64 - 1088 - - - ActTorque - LREAL - 64 - 1152 - - - StateDWord2 - NCTOPLC_AXIS_REF_STATE2 - 32 - 1216 - - - StateDWord3 - DWORD - 32 - 1248 - - - TouchProbeState - DWORD - 32 - 1280 - - - TouchProbeCounter - DWORD - 32 - 1312 - - - CamCouplingState - NCTOPLC_AXIS_REF_CAMCOUPLINGSTATE - - 0 - 8 - - 64 - 1344 - - - CamCouplingTableID - UINTARR8 - 128 - 1408 - - - ActTorqueDerivative - LREAL - 64 - 1536 - - - SetTorqueDerivative - LREAL - 64 - 1600 - - - AbsPhasingPos - LREAL - 64 - 1664 - - - TorqueOffset - LREAL - 64 - 1728 - - - ActPosWithoutPosCorrection - LREAL - 64 - 1792 - - - ActAcc - LREAL - 64 - 1856 - - - DcTimeStamp - UDINT - 32 - 1920 - - - - NcStructType - 2 - - - - - NCAXLESTRUCT_TOPLC - - - NCAXLESTRUCT_TOPLC2 - - - NCAXLESTRUCT_TOPLC3 - - - NCAXLESTRUCT_TOPLC4 - - - - - - - - - - - - - - - - - PLCTONC_AXIS_REF_CTRL - 32 - - Enable - BIT - 1 - 0 - - - FeedEnablePlus - BIT - 1 - 1 - - - FeedEnableMinus - BIT - 1 - 2 - - - HomingSensor - BIT - 1 - 5 - - - AcceptBlockedDrive - BIT - 1 - 8 - - - PlcDebugFlag - BIT - 1 - 30 - - - NcDebugFlag - BIT - 1 - 31 - - - %08x - - - 0x%08x - - - 16#%08X - - - - PLCTONC_AXIS_REF - 1024 - - ControlDWord - PLCTONC_AXIS_REF_CTRL - 32 - 0 - - - Override - UDINT - 32 - 32 - - - AxisModeRequest - UDINT - 32 - 64 - - - AxisModeDWord - UDINT - 32 - 96 - - - AxisModeLReal - LREAL - 64 - 128 - - - PositionCorrection - LREAL - 64 - 192 - - - ExtSetPos - LREAL - 64 - 256 - - - ExtSetVelo - LREAL - 64 - 320 - - - ExtSetAcc - LREAL - 64 - 384 - - - ExtSetDirection - DINT - 32 - 448 - - - ExtControllerOutput - LREAL - 64 - 512 - - - GearRatio1 - LREAL - 64 - 576 - - - GearRatio2 - LREAL - 64 - 640 - - - GearRatio3 - LREAL - 64 - 704 - - - GearRatio4 - LREAL - 64 - 768 - - - MapState - BOOL - 8 - 832 - - - PlcCycleControl - BYTE - 8 - 840 - - - PlcCycleCount - BYTE - 8 - 848 - - - - NcStructType - 1 - - - - - NCAXLESTRUCT_FROMPLC3 - - - - + @@ -932,57 +33,6 @@ External Setpoint Generation: tc_project_app Instance {08500001-0000-0000-F000-000000000064} - - PlcTask Inputs - - GVL.axes[1].inputs.bLimitFwd - - BOOL - - - GVL.axes[1].inputs.bLimitBwd - - BOOL - - - GVL.axes[1].inputs.bHomeSensor - - BOOL - - - GVL.axes[1].inputs.bEncLAtch - - BOOL - - - GVL.axes[1].Axis.NcToPlc - NCTOPLC_AXIS_REF - - - GVL.axes[2].inputs.bLimitFwd - - BOOL - - - GVL.axes[2].inputs.bLimitBwd - - BOOL - - - GVL.axes[2].inputs.bHomeSensor - - BOOL - - - GVL.axes[2].inputs.bEncLAtch - - BOOL - - - GVL.axes[2].Axis.NcToPlc - NCTOPLC_AXIS_REF - - PlcTask Outputs @@ -990,14 +40,6 @@ External Setpoint Generation: BOOL - - GVL.axes[1].Axis.PlcToNc - PLCTONC_AXIS_REF - - - GVL.axes[2].Axis.PlcToNc - PLCTONC_AXIS_REF - @@ -1006,12 +48,4 @@ External Setpoint Generation: - - - - - - - - From 06fff58f08fd4e15b51daa0dfad5858785921398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Mon, 10 Feb 2020 10:58:35 +0100 Subject: [PATCH 7/9] MAIN.TcPOU: Save with TC version 3.1.4024.0 --- solution/tc_project_app/POUs/MAIN.TcPOU | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 2c922e6..458ca9d 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -1,5 +1,5 @@  - + Date: Wed, 12 Feb 2020 11:56:26 +0100 Subject: [PATCH 8/9] Add check in MAIN.RESTOR_POSITIONS Add check when resetting bRestoreOnStartup flag to only reset if the UPS is OK. Otherwise during a power loss it is set and then reset before getting to the end of the PLC cycle. This was a result of moving some code that was previously in MAIN to an ACT and the RETURN command does not work the same. I believe it only returns from the current act and not the whole code. Originally it was supposed to prevent the rest of the code from executing in the event of a power failure but this is no longer the case. --- solution/tc_project_app/POUs/MAIN.TcPOU | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 458ca9d..b3bbcc1 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -6,6 +6,7 @@ VAR sVersion: STRING:='1.0.0'; i : UINT; //index variable for AXES() aFbAxes: ARRAY [1..gvl_app.axisNum] 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)********) @@ -158,7 +159,7 @@ END_IF]]> // Note from Beckhoff: "A maximum of 1 MB persistent data can be reliably saved over the entire service life." ///######################################################### -IF bRestoreOnStartup THEN +IF bRestoreOnStartup AND eGlobalSUpsState = eSUPS_PowerOK THEN bRestoreOnStartup:=FALSE; bRestoreExecute:=TRUE; END_IF @@ -273,7 +274,7 @@ END_FOR]]> - + From 51464ddd8716ac9c8924d2198343911e3c899072 Mon Sep 17 00:00:00 2001 From: Paul Barron Date: Wed, 12 Feb 2020 12:12:10 +0100 Subject: [PATCH 9/9] Fix whitespace damage --- solution/tc_project_app/POUs/MAIN.TcPOU | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index b3bbcc1..2621b5e 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -6,7 +6,7 @@ VAR sVersion: STRING:='1.0.0'; i : UINT; //index variable for AXES() aFbAxes: ARRAY [1..gvl_app.axisNum] 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)********)