From 976ef8dedc7019a01a8b0ea87bb37296ab986ead Mon Sep 17 00:00:00 2001 From: Cooper Date: Thu, 7 Jul 2022 14:36:10 +0100 Subject: [PATCH 01/29] OOP implementation of FB_Axis created with basic functionality --- solution.sln | 4 +- solution/_Config/NC/NC.xti | 1561 ++++++++++++++++- solution/_Config/PLC/tc_project_app.xti | 1013 ++++++++++- solution/solution.tsproj | 5 +- solution/tc_project_app/GVLs/GVL_APP.TcGVL | 5 +- solution/tc_project_app/POUs/MAIN.TcPOU | 29 +- solution/tc_project_app/tc_mca_std_lib | 2 +- .../tc_project_app/tc_project_app.plcproj | 60 +- 8 files changed, 2639 insertions(+), 40 deletions(-) diff --git a/solution.sln b/solution.sln index 2694336..60113c2 100644 --- a/solution.sln +++ b/solution.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 +# TcXaeShell Solution File, Format Version 11.00 +VisualStudioVersion = 15.0.28307.1300 MinimumVisualStudioVersion = 10.0.40219.1 Project("{B1E792BE-AA5F-4E3C-8C82-674BF9C0715B}") = "solution", "solution\solution.tsproj", "{9CF97348-B9D3-4938-B1F2-5F0B0B6AA66A}" EndProject diff --git a/solution/_Config/NC/NC.xti b/solution/_Config/NC/NC.xti index 32cccdf..47b0332 100644 --- a/solution/_Config/NC/NC.xti +++ b/solution/_Config/NC/NC.xti @@ -1,5 +1,1411 @@ - + + + + UINTARR2 + 32 + UINT + + 0 + 2 + + + [%u, %u] + [0] + [1] + + + 0x%08x [%u, %u] + . + [0] + [1] + + + 0x%08x (%u) + . + . + + + + NCENCODERSTRUCT_IN2B + 320 + + nDataIn1 + UINTARR2 + 32 + 0 + + + nDataIn2 + UINTARR2 + 32 + 32 + + + nState1 + USINT + 8 + 64 + + + nState2 + USINT + 8 + 72 + + + nState3 + USINT + 8 + 80 + + + nState4 + USINT + + 8 + 88 + + + nDataIn3 + UINTARR2 + 32 + 96 + + + nDataIn4 + UINTARR2 + 32 + 128 + + + nDataIn5 + UINTARR2 + 32 + 160 + + + nDataIn6 + UINTARR2 + 32 + 192 + + + nState5 + USINT + 8 + 224 + + + nState6 + USINT + 8 + 232 + + + nState7 + USINT + 8 + 240 + + + nState8 + USINT + 8 + 248 + + + nDcInputTime + DINT + 32 + 256 + + + nDataIn7 + UINTARR2 + + 32 + 288 + + + + NCENCODERSTRUCT_IN + + 96 + + + + + + NCENCODERSTRUCT_OUT2 + 320 + + nDataOut1 + UINTARR2 + 32 + 0 + + + nDataOut2 + UINTARR2 + 32 + 32 + + + nCtrl1 + USINT + 8 + 64 + + + nCtrl2 + USINT + 8 + 72 + + + nCtrl3 + USINT + 8 + 80 + + + nCtrl4 + USINT + 8 + 88 + + + nDataOut3 + UINTARR2 + 32 + 96 + + + nDataOut4 + UINTARR2 + 32 + 128 + + + nDataOut5 + UINTARR2 + 32 + 160 + + + nDataOut6 + UINTARR2 + 32 + 192 + + + nCtrl5 + USINT + 8 + 224 + + + nCtrl6 + USINT + 8 + 232 + + + nCtrl7 + USINT + 8 + 240 + + + nCtrl8 + USINT + 8 + 248 + + + + NCENCODERSTRUCT_OUT + + 96 + + + + + + NCDRIVESTRUCT_IN2 + 320 + + nDataIn1 + UINTARR2 + 32 + 0 + + + nDataIn2 + UINTARR2 + 32 + 32 + + + nState1 + USINT + 8 + 64 + + + nState2 + USINT + 8 + 72 + + + nState3 + USINT + 8 + 80 + + + nState4 + USINT + + 8 + 88 + + + nDataIn3 + UINTARR2 + 32 + 96 + + + nDataIn4 + UINTARR2 + 32 + 128 + + + nDataIn5 + UINTARR2 + 32 + 160 + + + nDataIn6 + UINTARR2 + 32 + 192 + + + nState5 + USINT + 8 + 224 + + + nState6 + USINT + 8 + 232 + + + nState7 + USINT + 8 + 240 + + + nState8 + USINT + + 8 + 248 + + + nDcOutputTime + DINT + 32 + 256 + + + + NCDRIVESTRUCT_IN + + 96 + + + + + + NCDRIVESTRUCT_OUT2 + 320 + + nDataOut1 + UINTARR2 + 32 + 0 + + + nDataOut2 + UINTARR2 + 32 + 32 + + + nCtrl1 + USINT + 8 + 64 + + + nCtrl2 + USINT + 8 + 72 + + + nCtrl3 + USINT + 8 + 80 + + + nCtrl4 + USINT + 8 + 88 + + + nDataOut3 + UINTARR2 + 32 + 96 + + + nDataOut4 + UINTARR2 + 32 + 128 + + + nDataOut5 + UINTARR2 + 32 + 160 + + + nDataOut6 + UINTARR2 + 32 + 192 + + + nCtrl5 + USINT + 8 + 224 + + + nCtrl6 + USINT + 8 + 232 + + + nCtrl7 + USINT + 8 + 240 + + + nCtrl8 + USINT + 8 + 248 + + + + NCDRIVESTRUCT_OUT + + 96 + + + + + + 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 + + + + + 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 + + + OpModeStopMonitoring + BIT + 1 + 12 + + + OpModeOutputSmoothingFilter + BIT + 1 + 13 + + + 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_STATE3_FLAGS + 32 + + TouchProbe1InputState + BIT + 1 + 0 + + + TouchProbe2InputState + BIT + 1 + 1 + + + %08x + + + 0x%08x + + + 16#%08X + + + + NCTOPLC_AXIS_REF_STATE3 + 32 + + Value + DWORD + 32 + 0 + + + Flags + NCTOPLC_AXIS_REF_STATE3_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 + NCTOPLC_AXIS_REF_STATE3 + 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 + + + + + + + + + + + + + + + + + + + NC-Task 1 SAF @@ -16,5 +1422,158 @@ NC-Task 1 SVB + + Axis 1 + + + + + + Inputs + + In + NCENCODERSTRUCT_IN2B + + nDataIn1 + + + nDataIn2 + + + nDataIn3 + + + nDataIn4 + + + nDataIn5 + + + nDataIn6 + + + nDataIn7 + + + + + + Outputs + + Out + NCENCODERSTRUCT_OUT2 + + nDataOut1 + + + nDataOut2 + + + nDataOut3 + + + nDataOut4 + + + nDataOut5 + + + nDataOut6 + + + + + + + + + + Inputs + + In + NCDRIVESTRUCT_IN2 + + nDataIn1 + + + nDataIn2 + + + nDataIn3 + + + nDataIn4 + + + nDataIn5 + + + nDataIn6 + + + + + Outputs + + Out + NCDRIVESTRUCT_OUT2 + + nDataOut1 + + + nDataOut2 + + + nCtrl2 + + + + nCtrl3 + + + + nDataOut3 + + + nDataOut4 + + + nDataOut5 + + + nDataOut6 + + + + + + + + + + + Inputs + + FromPlc + PLCTONC_AXIS_REF + + + + Outputs + + ToPlc + NCTOPLC_AXIS_REF + + + diff --git a/solution/_Config/PLC/tc_project_app.xti b/solution/_Config/PLC/tc_project_app.xti index 9067711..188fd9a 100644 --- a/solution/_Config/PLC/tc_project_app.xti +++ b/solution/_Config/PLC/tc_project_app.xti @@ -1,9 +1,1010 @@ - + + + + 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 + + + OpModeStopMonitoring + BIT + 1 + 12 + + + OpModeOutputSmoothingFilter + BIT + 1 + 13 + + + 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_STATE3_FLAGS + 32 + + TouchProbe1InputState + BIT + 1 + 0 + + + TouchProbe2InputState + BIT + 1 + 1 + + + %08x + + + 0x%08x + + + 16#%08X + + + + NCTOPLC_AXIS_REF_STATE3 + 32 + + Value + DWORD + 32 + 0 + + + Flags + NCTOPLC_AXIS_REF_STATE3_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 + NCTOPLC_AXIS_REF_STATE3 + 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 + + + + - + tc_project_app Instance {08500001-0000-0000-F000-000000000064} + + PlcTask Inputs + + GVL.astAxes[1].stStatus.nEncoderRawCounter + + UDINT + + + GVL.astAxes[1].stStatus.nStepperDriveCounter + + UDINT + + + GVL.astAxes[1].stInputs.bLimitFwd + BOOL + + + GVL.astAxes[1].stInputs.bLimitBwd + BOOL + + + GVL.astAxes[1].stInputs.bHomeSensor + + BOOL + + + GVL.astAxes[1].Axis.NcToPlc + NCTOPLC_AXIS_REF + + + + PlcTask Outputs + + GVL.astAxes[1].Axis.PlcToNc + PLCTONC_AXIS_REF + + 0 @@ -20,4 +1021,12 @@ + + + + + + + + diff --git a/solution/solution.tsproj b/solution/solution.tsproj index 4bf7c31..cc88502 100644 --- a/solution/solution.tsproj +++ b/solution/solution.tsproj @@ -1,9 +1,8 @@ - + - - + diff --git a/solution/tc_project_app/GVLs/GVL_APP.TcGVL b/solution/tc_project_app/GVLs/GVL_APP.TcGVL index f8c5309..981641b 100644 --- a/solution/tc_project_app/GVLs/GVL_APP.TcGVL +++ b/solution/tc_project_app/GVLs/GVL_APP.TcGVL @@ -1,5 +1,5 @@  - + diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 16ea784..899cfd5 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -1,10 +1,12 @@  - + + + + + + + + + + diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index ef11a1b..d038658 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit ef11a1b4c06047b86d3852e31ed5242c9f5ca51e +Subproject commit d038658aa1ccb02078ee4d3f6074d82b71a21f4d diff --git a/solution/tc_project_app/tc_project_app.plcproj b/solution/tc_project_app/tc_project_app.plcproj index 0c11005..cd390f3 100644 --- a/solution/tc_project_app/tc_project_app.plcproj +++ b/solution/tc_project_app/tc_project_app.plcproj @@ -40,6 +40,33 @@ Code + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + Code @@ -61,6 +88,9 @@ Code + + Code + Code @@ -88,34 +118,10 @@ Code - - Code - - - Code - Code - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - + Code @@ -124,6 +130,9 @@ Code + + Code + Code @@ -154,6 +163,7 @@ + From 7020a23a83492d135a283ee9fe774a486d0c0c73 Mon Sep 17 00:00:00 2001 From: SCooper Date: Fri, 8 Jul 2022 11:33:32 +0100 Subject: [PATCH 02/29] new status methods added for done, busy, error, cmdAborted. MoveVelocity added --- solution/_Config/PLC/tc_project_app.xti | 2 +- solution/solution.tsproj | 8 +- .../Visualization Manager.TcVMO | 8 +- .../tc_project_app/tc_project_app.plcproj | 155 +++++++++++++++++- 4 files changed, 165 insertions(+), 8 deletions(-) diff --git a/solution/_Config/PLC/tc_project_app.xti b/solution/_Config/PLC/tc_project_app.xti index 188fd9a..d2e45af 100644 --- a/solution/_Config/PLC/tc_project_app.xti +++ b/solution/_Config/PLC/tc_project_app.xti @@ -965,7 +965,7 @@ External Setpoint Generation: - + tc_project_app Instance {08500001-0000-0000-F000-000000000064} diff --git a/solution/solution.tsproj b/solution/solution.tsproj index cc88502..937b828 100644 --- a/solution/solution.tsproj +++ b/solution/solution.tsproj @@ -1,8 +1,8 @@ - + - + @@ -17,5 +17,9 @@ + + + + diff --git a/solution/tc_project_app/Visualization Manager.TcVMO b/solution/tc_project_app/Visualization Manager.TcVMO index 8dc78a2..14b4580 100644 --- a/solution/tc_project_app/Visualization Manager.TcVMO +++ b/solution/tc_project_app/Visualization Manager.TcVMO @@ -1,5 +1,5 @@  - + @@ -45,10 +45,10 @@ FB_Init c98701bd-1e9f-450a-a2a8-a2474d536f2e - FB_Reinit - 5b6e372a-a69d-40e8-aef7-f470b7c53d95 FB_Exit 0be1b9ab-e8eb-4b33-b803-109abb46bde4 + FB_Reinit + 5b6e372a-a69d-40e8-aef7-f470b7c53d95 "NotImportant" {aa8b7e42-e967-427f-8f2e-f00f9d706470} @@ -58,7 +58,7 @@ 7 4096 "1002 0004" - "1.0.0.4" + "1.0.0.6" {cb73a13e-6ccc-4bc6-8859-f5aa98bb116b} diff --git a/solution/tc_project_app/tc_project_app.plcproj b/solution/tc_project_app/tc_project_app.plcproj index cd390f3..7c4e37a 100644 --- a/solution/tc_project_app/tc_project_app.plcproj +++ b/solution/tc_project_app/tc_project_app.plcproj @@ -270,8 +270,161 @@ + + CAA Callback Extern, * (CAA Technical Workgroup) + + + CAA Memory Block Manager Extern, * (CAA Technical Workgroup) + + + CAA Ressource Manager Extern, * (CAA Technical Workgroup) + + + CAA Types Extern, * (CAA Technical Workgroup) + + + CmpApp, * (System) + + + CmpBitmapPool, * (System) + + + CmpDynamicText, * (System) + + + CmpEventMgr, * (System) + + + CmpLog, * (System) + + + CmpSchedule, * (System) + + + CmpTargetVisu, * (System) + + + CmpVisuHandler, * (System) + + + Collections, * (System) + + + Component Manager, * (System) + + + FloatingPointUtils, * (System) + + + Tc2_Standard, * (Beckhoff Automation GmbH) + + + Tc2_Standard, * (Beckhoff Automation GmbH) + + + StringUtils, * (System) + + + SysCpuHandling, * (System) + + + SysDir, * (System) + + + SysFile, * (System) + + + SysMem, * (System) + + + SysProcess, * (System) + + + SysShm, * (System) + + + SysTarget, * (System) + + + VisuElemBase, * (System) + + + VisuElemEventTable, * (System) + + + VisuElemMeter, * (System) + + + VisuElems, * (System) + + + VisuElemsSpecialControls, * (System) + + + VisuElemsWinControls, * (System) + + + VisuElemTextEditor, * (System) + + + VisuInputs, * (System) + + + VisuInputs, * (System) + + + VisuNativeControl, * (System) + + + SysTime, * (System) + + + SysTimeCore, * (System) + + + SysTimeRtc, * (System) + + + Tc2_Drive, * (Beckhoff Automation GmbH) + + + Tc2_EtherCAT, * (Beckhoff Automation GmbH) + + + Tc2_IoFunctions, * (Beckhoff Automation GmbH) + + + Tc2_Math, * (Beckhoff Automation GmbH) + - Tc2_MC2, 3.3.41.0 (Beckhoff Automation GmbH) + Tc2_MC2, * (Beckhoff Automation GmbH) + + + Tc2_MC2_Drive, * (Beckhoff Automation GmbH) + + + Tc2_Standard, * (Beckhoff Automation GmbH) + + + Tc2_SUPS, * (Beckhoff Automation GmbH) + + + Tc2_System, * (Beckhoff Automation GmbH) + + + Tc2_Utilities, * (Beckhoff Automation GmbH) + + + Tc3_MC2_AdvancedHoming, * (Beckhoff Automation GmbH) + + + Tc3_Module, * (Beckhoff Automation GmbH) + + + Util, * (System) + + + VisuDialogs, * (System) From 0808f6c41b14acdeea2ef10dbcffc0d63e4e4c31 Mon Sep 17 00:00:00 2001 From: SCooper Date: Fri, 8 Jul 2022 15:00:47 +0100 Subject: [PATCH 03/29] Gear in and gear out implemented --- solution/_Config/NC/Axes/Axis 2.xti | 1562 ++++++++++++++++++++ solution/_Config/NC/NC.xti | 2 + solution/_Config/PLC/tc_project_app.xti | 37 +- solution/tc_project_app/GVLs/GVL_APP.TcGVL | 2 +- solution/tc_project_app/tc_mca_std_lib | 2 +- 5 files changed, 1602 insertions(+), 3 deletions(-) create mode 100644 solution/_Config/NC/Axes/Axis 2.xti diff --git a/solution/_Config/NC/Axes/Axis 2.xti b/solution/_Config/NC/Axes/Axis 2.xti new file mode 100644 index 0000000..9fb7bf0 --- /dev/null +++ b/solution/_Config/NC/Axes/Axis 2.xti @@ -0,0 +1,1562 @@ + + + + + UINTARR2 + 32 + UINT + + 0 + 2 + + + [%u, %u] + [0] + [1] + + + 0x%08x [%u, %u] + . + [0] + [1] + + + 0x%08x (%u) + . + . + + + + NCENCODERSTRUCT_IN2B + 320 + + nDataIn1 + UINTARR2 + 32 + 0 + + + nDataIn2 + UINTARR2 + 32 + 32 + + + nState1 + USINT + 8 + 64 + + + nState2 + USINT + 8 + 72 + + + nState3 + USINT + 8 + 80 + + + nState4 + USINT + + 8 + 88 + + + nDataIn3 + UINTARR2 + 32 + 96 + + + nDataIn4 + UINTARR2 + 32 + 128 + + + nDataIn5 + UINTARR2 + 32 + 160 + + + nDataIn6 + UINTARR2 + 32 + 192 + + + nState5 + USINT + 8 + 224 + + + nState6 + USINT + 8 + 232 + + + nState7 + USINT + 8 + 240 + + + nState8 + USINT + 8 + 248 + + + nDcInputTime + DINT + 32 + 256 + + + nDataIn7 + UINTARR2 + + 32 + 288 + + + + NCENCODERSTRUCT_IN + + 96 + + + + + + NCENCODERSTRUCT_OUT2 + 320 + + nDataOut1 + UINTARR2 + 32 + 0 + + + nDataOut2 + UINTARR2 + 32 + 32 + + + nCtrl1 + USINT + 8 + 64 + + + nCtrl2 + USINT + 8 + 72 + + + nCtrl3 + USINT + 8 + 80 + + + nCtrl4 + USINT + 8 + 88 + + + nDataOut3 + UINTARR2 + 32 + 96 + + + nDataOut4 + UINTARR2 + 32 + 128 + + + nDataOut5 + UINTARR2 + 32 + 160 + + + nDataOut6 + UINTARR2 + 32 + 192 + + + nCtrl5 + USINT + 8 + 224 + + + nCtrl6 + USINT + 8 + 232 + + + nCtrl7 + USINT + 8 + 240 + + + nCtrl8 + USINT + 8 + 248 + + + + NCENCODERSTRUCT_OUT + + 96 + + + + + + NCDRIVESTRUCT_IN2 + 320 + + nDataIn1 + UINTARR2 + 32 + 0 + + + nDataIn2 + UINTARR2 + 32 + 32 + + + nState1 + USINT + 8 + 64 + + + nState2 + USINT + 8 + 72 + + + nState3 + USINT + 8 + 80 + + + nState4 + USINT + + 8 + 88 + + + nDataIn3 + UINTARR2 + 32 + 96 + + + nDataIn4 + UINTARR2 + 32 + 128 + + + nDataIn5 + UINTARR2 + 32 + 160 + + + nDataIn6 + UINTARR2 + 32 + 192 + + + nState5 + USINT + 8 + 224 + + + nState6 + USINT + 8 + 232 + + + nState7 + USINT + 8 + 240 + + + nState8 + USINT + + 8 + 248 + + + nDcOutputTime + DINT + 32 + 256 + + + + NCDRIVESTRUCT_IN + + 96 + + + + + + NCDRIVESTRUCT_OUT2 + 320 + + nDataOut1 + UINTARR2 + 32 + 0 + + + nDataOut2 + UINTARR2 + 32 + 32 + + + nCtrl1 + USINT + 8 + 64 + + + nCtrl2 + USINT + 8 + 72 + + + nCtrl3 + USINT + 8 + 80 + + + nCtrl4 + USINT + 8 + 88 + + + nDataOut3 + UINTARR2 + 32 + 96 + + + nDataOut4 + UINTARR2 + 32 + 128 + + + nDataOut5 + UINTARR2 + 32 + 160 + + + nDataOut6 + UINTARR2 + 32 + 192 + + + nCtrl5 + USINT + 8 + 224 + + + nCtrl6 + USINT + 8 + 232 + + + nCtrl7 + USINT + 8 + 240 + + + nCtrl8 + USINT + 8 + 248 + + + + NCDRIVESTRUCT_OUT + + 96 + + + + + + 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 + + + + + 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 + + + OpModeStopMonitoring + BIT + 1 + 12 + + + OpModeOutputSmoothingFilter + BIT + 1 + 13 + + + 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_STATE3_FLAGS + 32 + + TouchProbe1InputState + BIT + 1 + 0 + + + TouchProbe2InputState + BIT + 1 + 1 + + + %08x + + + 0x%08x + + + 16#%08X + + + + NCTOPLC_AXIS_REF_STATE3 + 32 + + Value + DWORD + 32 + 0 + + + Flags + NCTOPLC_AXIS_REF_STATE3_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 + NCTOPLC_AXIS_REF_STATE3 + 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 + + + + + + + + + + + + + + + + + + + + + __FILENAME__ + + + + + + Inputs + + In + NCENCODERSTRUCT_IN2B + + nDataIn1 + + + nDataIn2 + + + nDataIn3 + + + nDataIn4 + + + nDataIn5 + + + nDataIn6 + + + nDataIn7 + + + + + + Outputs + + Out + NCENCODERSTRUCT_OUT2 + + nDataOut1 + + + nDataOut2 + + + nDataOut3 + + + nDataOut4 + + + nDataOut5 + + + nDataOut6 + + + + + + + + + + Inputs + + In + NCDRIVESTRUCT_IN2 + + nDataIn1 + + + nDataIn2 + + + nDataIn3 + + + nDataIn4 + + + nDataIn5 + + + nDataIn6 + + + + + Outputs + + Out + NCDRIVESTRUCT_OUT2 + + nDataOut1 + + + nDataOut2 + + + nCtrl2 + + + + nCtrl3 + + + + nDataOut3 + + + nDataOut4 + + + nDataOut5 + + + nDataOut6 + + + + + + + + + + + Inputs + + FromPlc + PLCTONC_AXIS_REF + + + + Outputs + + ToPlc + NCTOPLC_AXIS_REF + + + + diff --git a/solution/_Config/NC/NC.xti b/solution/_Config/NC/NC.xti index 47b0332..4198911 100644 --- a/solution/_Config/NC/NC.xti +++ b/solution/_Config/NC/NC.xti @@ -1487,6 +1487,7 @@ External Setpoint Generation: + Inputs @@ -1575,5 +1576,6 @@ External Setpoint Generation: + diff --git a/solution/_Config/PLC/tc_project_app.xti b/solution/_Config/PLC/tc_project_app.xti index d2e45af..407b10e 100644 --- a/solution/_Config/PLC/tc_project_app.xti +++ b/solution/_Config/PLC/tc_project_app.xti @@ -965,7 +965,7 @@ External Setpoint Generation: - + tc_project_app Instance {08500001-0000-0000-F000-000000000064} @@ -997,6 +997,33 @@ External Setpoint Generation: GVL.astAxes[1].Axis.NcToPlc NCTOPLC_AXIS_REF + + GVL.astAxes[2].stStatus.nEncoderRawCounter + + UDINT + + + GVL.astAxes[2].stStatus.nStepperDriveCounter + + UDINT + + + GVL.astAxes[2].stInputs.bLimitFwd + BOOL + + + GVL.astAxes[2].stInputs.bLimitBwd + BOOL + + + GVL.astAxes[2].stInputs.bHomeSensor + + BOOL + + + GVL.astAxes[2].Axis.NcToPlc + NCTOPLC_AXIS_REF + PlcTask Outputs @@ -1004,6 +1031,10 @@ External Setpoint Generation: GVL.astAxes[1].Axis.PlcToNc PLCTONC_AXIS_REF + + GVL.astAxes[2].Axis.PlcToNc + PLCTONC_AXIS_REF + @@ -1027,6 +1058,10 @@ External Setpoint Generation: + + + + diff --git a/solution/tc_project_app/GVLs/GVL_APP.TcGVL b/solution/tc_project_app/GVLs/GVL_APP.TcGVL index 981641b..fd47c34 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 := 1; (*~ (OPC: 1 : available for OPC-clients)(OPC_PROP[0005]: 1 : OPC_PROP_RIGHTS, here read only)*) + nAXIS_NUM: UINT := 2; (*~ (OPC: 1 : available for OPC-clients)(OPC_PROP[0005]: 1 : OPC_PROP_RIGHTS, here read only)*) nPNEUMATIC_AXIS_NUM: UINT := 0; END_VAR ]]> diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index d038658..a51213c 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit d038658aa1ccb02078ee4d3f6074d82b71a21f4d +Subproject commit a51213ca1368444f4ce1bca951d5d2f2adc8ac5f From f0dff8ea56e0584960a700816e157abace2c59b9 Mon Sep 17 00:00:00 2001 From: SCooper Date: Wed, 13 Jul 2022 11:30:28 +0100 Subject: [PATCH 04/29] multi gearing logic improved. Status logic changed to array of pointers for easier scaling. Homing added --- solution/_Config/NC/NC.xti | 1 + solution/_Config/PLC/tc_project_app.xti | 2 +- solution/tc_project_app/POUs/MAIN.TcPOU | 19 +++++++++++++++++++ solution/tc_project_app/tc_mca_std_lib | 2 +- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/solution/_Config/NC/NC.xti b/solution/_Config/NC/NC.xti index 4198911..2017d23 100644 --- a/solution/_Config/NC/NC.xti +++ b/solution/_Config/NC/NC.xti @@ -1425,6 +1425,7 @@ External Setpoint Generation: Axis 1 + diff --git a/solution/_Config/PLC/tc_project_app.xti b/solution/_Config/PLC/tc_project_app.xti index 407b10e..d4a8d92 100644 --- a/solution/_Config/PLC/tc_project_app.xti +++ b/solution/_Config/PLC/tc_project_app.xti @@ -965,7 +965,7 @@ External Setpoint Generation: - + tc_project_app Instance {08500001-0000-0000-F000-000000000064} diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 899cfd5..03737b6 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -98,6 +98,18 @@ Axis_Template(); //Application program calls //Application_Template(); + +IF astAxes[1].stStatus.fActPosition > 50 THEN + astAxes[1].stInputs.bLimitFwd := FALSE; +ELSE + astAxes[1].stInputs.bLimitFwd := TRUE; +END_IF + +IF astAxes[1].stStatus.fActPosition < -5 THEN + astAxes[1].stInputs.bLimitBwd := FALSE; +ELSE + astAxes[1].stInputs.bLimitBwd := TRUE; +END_IF ]]> @@ -265,6 +277,13 @@ END_FOR]]> + + + + + + + diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index a51213c..e4547af 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit a51213ca1368444f4ce1bca951d5d2f2adc8ac5f +Subproject commit e4547afd3176ab1eba1d126d4921e4bc83072d17 From 0033d956274356b1667bac09b79f5a4bf73b0449 Mon Sep 17 00:00:00 2001 From: SCooper Date: Wed, 13 Jul 2022 15:19:46 +0100 Subject: [PATCH 05/29] Error IDs propragating through --- solution/_Config/PLC/tc_project_app.xti | 2 +- solution/tc_project_app/tc_mca_std_lib | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/solution/_Config/PLC/tc_project_app.xti b/solution/_Config/PLC/tc_project_app.xti index d4a8d92..269f8e4 100644 --- a/solution/_Config/PLC/tc_project_app.xti +++ b/solution/_Config/PLC/tc_project_app.xti @@ -965,7 +965,7 @@ External Setpoint Generation: - + tc_project_app Instance {08500001-0000-0000-F000-000000000064} diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index e4547af..f97601c 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit e4547afd3176ab1eba1d126d4921e4bc83072d17 +Subproject commit f97601c9cdfbe313a6bac9bebe4118c43cf352e2 From 2bdf9e786bab73bdf641a6daf7c519de581eebc8 Mon Sep 17 00:00:00 2001 From: SCooper Date: Wed, 27 Jul 2022 12:28:33 +0100 Subject: [PATCH 06/29] Read parameter added to OOP implementation. Visu parameter reads fixed to reference GVL not afbaxes. Text list support added for parameters to allow combo box selection on Visu rather than typing in number --- solution/_Config/PLC/tc_project_app.xti | 2 +- solution/tc_project_app/POUs/MAIN.TcPOU | 22 +++++++++++++++---- .../tc_project_app/tc_project_app.plcproj | 3 +++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/solution/_Config/PLC/tc_project_app.xti b/solution/_Config/PLC/tc_project_app.xti index 269f8e4..1d9983f 100644 --- a/solution/_Config/PLC/tc_project_app.xti +++ b/solution/_Config/PLC/tc_project_app.xti @@ -965,7 +965,7 @@ External Setpoint Generation: - + tc_project_app Instance {08500001-0000-0000-F000-000000000064} diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 03737b6..a4d6184 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -22,6 +22,8 @@ VAR afbReadEncRefSys: ARRAY [1..GVL_APP.nAXIS_NUM] OF MC_ReadParameter; afbRestorePosition: ARRAY [1..GVL_APP.nAXIS_NUM] OF MC_SetPosition; fbGetDeviceIdentification: FB_GetDeviceIdentification; + + counter : BYTE; END_VAR VAR PERSISTENT @@ -30,7 +32,8 @@ END_VAR]]> +PROG(); +AXES_EndOfCycle();]]> @@ -58,6 +61,14 @@ END_FOR*) FOR GVL.iPneumaticAxis := 1 TO GVL_APP.nPNEUMATIC_AXIS_NUM DO afbPneumaticAxes[GVL.iPneumaticAxis](stPneumaticAxisStruct := GVL.astPneumaticAxes[GVL.iPneumaticAxis]); END_FOR +]]> + + + + + @@ -109,8 +120,7 @@ IF astAxes[1].stStatus.fActPosition < -5 THEN astAxes[1].stInputs.bLimitBwd := FALSE; ELSE astAxes[1].stInputs.bLimitBwd := TRUE; -END_IF -]]> +END_IF]]> @@ -241,6 +251,7 @@ END_FOR]]> + @@ -260,6 +271,10 @@ END_FOR]]> + + + + @@ -284,7 +299,6 @@ END_FOR]]> - diff --git a/solution/tc_project_app/tc_project_app.plcproj b/solution/tc_project_app/tc_project_app.plcproj index 7c4e37a..8c8c8df 100644 --- a/solution/tc_project_app/tc_project_app.plcproj +++ b/solution/tc_project_app/tc_project_app.plcproj @@ -149,6 +149,9 @@ Code Visualization Manager.TcVMO + + Code + Code Visualization Manager.TcVMO From 37b8f7490c4d6064aebba9cfdd64937e9f9e10ec Mon Sep 17 00:00:00 2001 From: SCooper Date: Wed, 27 Jul 2022 14:39:02 +0100 Subject: [PATCH 07/29] Write parameter implemented --- solution/_Config/PLC/tc_project_app.xti | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/_Config/PLC/tc_project_app.xti b/solution/_Config/PLC/tc_project_app.xti index 1d9983f..5c7ba94 100644 --- a/solution/_Config/PLC/tc_project_app.xti +++ b/solution/_Config/PLC/tc_project_app.xti @@ -965,7 +965,7 @@ External Setpoint Generation: - + tc_project_app Instance {08500001-0000-0000-F000-000000000064} From 2222e7539e00eb8dbb99c72d4838ee2816eb0277 Mon Sep 17 00:00:00 2001 From: SCooper Date: Wed, 27 Jul 2022 15:25:53 +0100 Subject: [PATCH 08/29] refactoring to clean up whitespace --- solution/tc_project_app/POUs/MAIN.TcPOU | 7 ++----- solution/tc_project_app/tc_project_app.tmcRefac | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 solution/tc_project_app/tc_project_app.tmcRefac diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index a4d6184..fdeebfe 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -6,7 +6,6 @@ VAR sVersion: STRING := '1.0.0'; aIAxes : ARRAY [1..GVL_APP.nAXIS_NUM] OF I_Axis; afbAxes: ARRAY [1..GVL_APP.nAXIS_NUM] OF FB_Axis; - afbAxesV2: ARRAY [1..GVL_APP.nAXIS_NUM] OF FB_Axis_V2; afbPneumaticAxes: ARRAY [1..GVL_APP.nPNEUMATIC_AXIS_NUM] OF FB_PneumaticAxis; hmiAxisSelection: INT := 1; //Not possible to use local hmi variables for array indexes hmiPneumaticAxisSelection: INT := 1; @@ -22,8 +21,6 @@ VAR afbReadEncRefSys: ARRAY [1..GVL_APP.nAXIS_NUM] OF MC_ReadParameter; afbRestorePosition: ARRAY [1..GVL_APP.nAXIS_NUM] OF MC_SetPosition; fbGetDeviceIdentification: FB_GetDeviceIdentification; - - counter : BYTE; END_VAR VAR PERSISTENT @@ -43,8 +40,8 @@ GVL.fbGetCurTaskIndex(); IF _TaskInfo[fbGetCurTaskIndex.index].FirstCycle THEN FOR GVL.iAxis := 1 TO GVL_APP.nAXIS_NUM DO - afbAxesV2[GVL.iAxis].stAxis REF= astAxes[GVL.iAxis]; - aIAxes[GVL.iAxis] := afbAxesV2[GVL.iAxis]; + afbAxes[GVL.iAxis].stAxis REF= astAxes[GVL.iAxis]; + aIAxes[GVL.iAxis] := afbAxes[GVL.iAxis]; END_FOR END_IF diff --git a/solution/tc_project_app/tc_project_app.tmcRefac b/solution/tc_project_app/tc_project_app.tmcRefac new file mode 100644 index 0000000..df9ad91 --- /dev/null +++ b/solution/tc_project_app/tc_project_app.tmcRefac @@ -0,0 +1,15 @@ + + + + + FB_AXIS_V2 + FB_Axis_V2 + FB_Axis + + + MAIN + afbAxesV2 + afbAxes + + + \ No newline at end of file From 387a662d19bf074369e868b7c7f0026f5b5b9df3 Mon Sep 17 00:00:00 2001 From: SCooper Date: Wed, 27 Jul 2022 15:34:28 +0100 Subject: [PATCH 09/29] include TMC and TPY, remove axes from test --- solution/_Config/NC/NC.xti | 1564 +---------------- solution/_Config/PLC/tc_project_app.xti | 12 - solution/solution.tsproj | 2 +- solution/tc_project_app/GVLs/GVL_APP.TcGVL | 6 +- .../Axes/Axis_Template.TcPOU | 9 +- solution/tc_project_app/POUs/MAIN.TcPOU | 54 +- .../tc_project_app/tc_project_app.plcproj | 3 - .../tc_project_app/tc_project_app.tmcRefac | 15 - 8 files changed, 22 insertions(+), 1643 deletions(-) delete mode 100644 solution/tc_project_app/tc_project_app.tmcRefac diff --git a/solution/_Config/NC/NC.xti b/solution/_Config/NC/NC.xti index 2017d23..cd4a2c2 100644 --- a/solution/_Config/NC/NC.xti +++ b/solution/_Config/NC/NC.xti @@ -1,1413 +1,7 @@ - - - UINTARR2 - 32 - UINT - - 0 - 2 - - - [%u, %u] - [0] - [1] - - - 0x%08x [%u, %u] - . - [0] - [1] - - - 0x%08x (%u) - . - . - - - - NCENCODERSTRUCT_IN2B - 320 - - nDataIn1 - UINTARR2 - 32 - 0 - - - nDataIn2 - UINTARR2 - 32 - 32 - - - nState1 - USINT - 8 - 64 - - - nState2 - USINT - 8 - 72 - - - nState3 - USINT - 8 - 80 - - - nState4 - USINT - - 8 - 88 - - - nDataIn3 - UINTARR2 - 32 - 96 - - - nDataIn4 - UINTARR2 - 32 - 128 - - - nDataIn5 - UINTARR2 - 32 - 160 - - - nDataIn6 - UINTARR2 - 32 - 192 - - - nState5 - USINT - 8 - 224 - - - nState6 - USINT - 8 - 232 - - - nState7 - USINT - 8 - 240 - - - nState8 - USINT - 8 - 248 - - - nDcInputTime - DINT - 32 - 256 - - - nDataIn7 - UINTARR2 - - 32 - 288 - - - - NCENCODERSTRUCT_IN - - 96 - - - - - - NCENCODERSTRUCT_OUT2 - 320 - - nDataOut1 - UINTARR2 - 32 - 0 - - - nDataOut2 - UINTARR2 - 32 - 32 - - - nCtrl1 - USINT - 8 - 64 - - - nCtrl2 - USINT - 8 - 72 - - - nCtrl3 - USINT - 8 - 80 - - - nCtrl4 - USINT - 8 - 88 - - - nDataOut3 - UINTARR2 - 32 - 96 - - - nDataOut4 - UINTARR2 - 32 - 128 - - - nDataOut5 - UINTARR2 - 32 - 160 - - - nDataOut6 - UINTARR2 - 32 - 192 - - - nCtrl5 - USINT - 8 - 224 - - - nCtrl6 - USINT - 8 - 232 - - - nCtrl7 - USINT - 8 - 240 - - - nCtrl8 - USINT - 8 - 248 - - - - NCENCODERSTRUCT_OUT - - 96 - - - - - - NCDRIVESTRUCT_IN2 - 320 - - nDataIn1 - UINTARR2 - 32 - 0 - - - nDataIn2 - UINTARR2 - 32 - 32 - - - nState1 - USINT - 8 - 64 - - - nState2 - USINT - 8 - 72 - - - nState3 - USINT - 8 - 80 - - - nState4 - USINT - - 8 - 88 - - - nDataIn3 - UINTARR2 - 32 - 96 - - - nDataIn4 - UINTARR2 - 32 - 128 - - - nDataIn5 - UINTARR2 - 32 - 160 - - - nDataIn6 - UINTARR2 - 32 - 192 - - - nState5 - USINT - 8 - 224 - - - nState6 - USINT - 8 - 232 - - - nState7 - USINT - 8 - 240 - - - nState8 - USINT - - 8 - 248 - - - nDcOutputTime - DINT - 32 - 256 - - - - NCDRIVESTRUCT_IN - - 96 - - - - - - NCDRIVESTRUCT_OUT2 - 320 - - nDataOut1 - UINTARR2 - 32 - 0 - - - nDataOut2 - UINTARR2 - 32 - 32 - - - nCtrl1 - USINT - 8 - 64 - - - nCtrl2 - USINT - 8 - 72 - - - nCtrl3 - USINT - 8 - 80 - - - nCtrl4 - USINT - 8 - 88 - - - nDataOut3 - UINTARR2 - 32 - 96 - - - nDataOut4 - UINTARR2 - 32 - 128 - - - nDataOut5 - UINTARR2 - 32 - 160 - - - nDataOut6 - UINTARR2 - 32 - 192 - - - nCtrl5 - USINT - 8 - 224 - - - nCtrl6 - USINT - 8 - 232 - - - nCtrl7 - USINT - 8 - 240 - - - nCtrl8 - USINT - 8 - 248 - - - - NCDRIVESTRUCT_OUT - - 96 - - - - - - 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 - - - - - 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 - - - OpModeStopMonitoring - BIT - 1 - 12 - - - OpModeOutputSmoothingFilter - BIT - 1 - 13 - - - 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_STATE3_FLAGS - 32 - - TouchProbe1InputState - BIT - 1 - 0 - - - TouchProbe2InputState - BIT - 1 - 1 - - - %08x - - - 0x%08x - - - 16#%08X - - - - NCTOPLC_AXIS_REF_STATE3 - 32 - - Value - DWORD - 32 - 0 - - - Flags - NCTOPLC_AXIS_REF_STATE3_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 - NCTOPLC_AXIS_REF_STATE3 - 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 - - - - - - - - - - - - - - - - - - - - + NC-Task 1 SAF Inputs @@ -1422,161 +16,5 @@ External Setpoint Generation: NC-Task 1 SVB - - Axis 1 - - - - - - - Inputs - - In - NCENCODERSTRUCT_IN2B - - nDataIn1 - - - nDataIn2 - - - nDataIn3 - - - nDataIn4 - - - nDataIn5 - - - nDataIn6 - - - nDataIn7 - - - - - - Outputs - - Out - NCENCODERSTRUCT_OUT2 - - nDataOut1 - - - nDataOut2 - - - nDataOut3 - - - nDataOut4 - - - nDataOut5 - - - nDataOut6 - - - - - - - - - - - Inputs - - In - NCDRIVESTRUCT_IN2 - - nDataIn1 - - - nDataIn2 - - - nDataIn3 - - - nDataIn4 - - - nDataIn5 - - - nDataIn6 - - - - - Outputs - - Out - NCDRIVESTRUCT_OUT2 - - nDataOut1 - - - nDataOut2 - - - nCtrl2 - - - - nCtrl3 - - - - nDataOut3 - - - nDataOut4 - - - nDataOut5 - - - nDataOut6 - - - - - - - - - - - Inputs - - FromPlc - PLCTONC_AXIS_REF - - - - Outputs - - ToPlc - NCTOPLC_AXIS_REF - - - - diff --git a/solution/_Config/PLC/tc_project_app.xti b/solution/_Config/PLC/tc_project_app.xti index 5c7ba94..33dba56 100644 --- a/solution/_Config/PLC/tc_project_app.xti +++ b/solution/_Config/PLC/tc_project_app.xti @@ -1052,16 +1052,4 @@ External Setpoint Generation: - - - - - - - - - - - - diff --git a/solution/solution.tsproj b/solution/solution.tsproj index 937b828..0009c9a 100644 --- a/solution/solution.tsproj +++ b/solution/solution.tsproj @@ -1,6 +1,6 @@ - + diff --git a/solution/tc_project_app/GVLs/GVL_APP.TcGVL b/solution/tc_project_app/GVLs/GVL_APP.TcGVL index fd47c34..b8e952e 100644 --- a/solution/tc_project_app/GVLs/GVL_APP.TcGVL +++ b/solution/tc_project_app/GVLs/GVL_APP.TcGVL @@ -3,13 +3,11 @@ +END_VAR]]> \ No newline at end of file diff --git a/solution/tc_project_app/POUs/Application_Specific/Axes/Axis_Template.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Axes/Axis_Template.TcPOU index b7dc9f6..026a49a 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Axes/Axis_Template.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Axes/Axis_Template.TcPOU @@ -1,5 +1,5 @@  - + +END_VAR]]> +Eg. GVL.astAxes[x].stControl.bInterlockFwd := NOT bInterlockFwdOK;*)]]> @@ -34,7 +32,6 @@ Eg. GVL.astAxes[x].stControl.bInterlockFwd := NOT bInterlockFwdOK;*) - \ 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 fdeebfe..a151118 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -38,35 +38,32 @@ AXES_EndOfCycle();]]> +END_FOR]]> - +END_FOR]]> @@ -101,23 +98,11 @@ END_IF]]> //Create as many programs in that folder as axes and applications you have or need //Axes initial parameters and program -Axis_Template(); +//Axis_Template(); //Pneumatics_Template(); //Application program calls -//Application_Template(); - -IF astAxes[1].stStatus.fActPosition > 50 THEN - astAxes[1].stInputs.bLimitFwd := FALSE; -ELSE - astAxes[1].stInputs.bLimitFwd := TRUE; -END_IF - -IF astAxes[1].stStatus.fActPosition < -5 THEN - astAxes[1].stInputs.bLimitBwd := FALSE; -ELSE - astAxes[1].stInputs.bLimitBwd := TRUE; -END_IF]]> +//Application_Template();]]> @@ -252,25 +237,23 @@ END_FOR]]> + + - + - - - - + - + - @@ -289,13 +272,6 @@ END_FOR]]> - - - - - - - diff --git a/solution/tc_project_app/tc_project_app.plcproj b/solution/tc_project_app/tc_project_app.plcproj index 8c8c8df..278b1b1 100644 --- a/solution/tc_project_app/tc_project_app.plcproj +++ b/solution/tc_project_app/tc_project_app.plcproj @@ -130,9 +130,6 @@ Code - - Code - Code diff --git a/solution/tc_project_app/tc_project_app.tmcRefac b/solution/tc_project_app/tc_project_app.tmcRefac deleted file mode 100644 index df9ad91..0000000 --- a/solution/tc_project_app/tc_project_app.tmcRefac +++ /dev/null @@ -1,15 +0,0 @@ - - - - - FB_AXIS_V2 - FB_Axis_V2 - FB_Axis - - - MAIN - afbAxesV2 - afbAxes - - - \ No newline at end of file From 15bc90833a37af43a0c84d1b9d0211ad00a83723 Mon Sep 17 00:00:00 2001 From: SCooper Date: Wed, 27 Jul 2022 15:37:44 +0100 Subject: [PATCH 10/29] Update 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 f97601c..b3886b7 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit f97601c9cdfbe313a6bac9bebe4118c43cf352e2 +Subproject commit b3886b762b0cf8f77a93f90d2e39d3b3fc46a4fe From 60700b1d46129f4b01b55fef9b43dfc1005887ad Mon Sep 17 00:00:00 2001 From: SCooper Date: Fri, 29 Jul 2022 14:26:18 +0100 Subject: [PATCH 11/29] Swap AXES and PROG execution order, allow logic to execute and send commands on the same cycle --- solution/solution.tsproj | 4 ---- solution/tc_project_app/POUs/MAIN.TcPOU | 6 ++---- solution/tc_project_app/tc_mca_std_lib | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/solution/solution.tsproj b/solution/solution.tsproj index 0009c9a..8540b5c 100644 --- a/solution/solution.tsproj +++ b/solution/solution.tsproj @@ -17,9 +17,5 @@ - - - - diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index a151118..388a292 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -28,9 +28,8 @@ VAR PERSISTENT END_VAR]]> +AXES();]]> @@ -231,9 +230,8 @@ END_FOR]]> + - - diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index b3886b7..9df77c9 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit b3886b762b0cf8f77a93f90d2e39d3b3fc46a4fe +Subproject commit 9df77c95a603fd24efa32522784df02c340607ec From c4bdac87e8d3ed78f3bf6ef5c18452e680b52bc3 Mon Sep 17 00:00:00 2001 From: Cooper Date: Mon, 15 Aug 2022 15:20:29 +0100 Subject: [PATCH 12/29] Code refactor to meeting coding standards --- solution.sln | 16 ---- solution/tc_project_app/LineIDs.dbg | Bin 0 -> 3272 bytes solution/tc_project_app/POUs/MAIN.TcPOU | 76 ++-------------- solution/tc_project_app/tc_mca_std_lib | 2 +- .../tc_project_app/tc_project_app.tmcRefac | 85 ++++++++++++++++++ 5 files changed, 93 insertions(+), 86 deletions(-) create mode 100644 solution/tc_project_app/LineIDs.dbg create mode 100644 solution/tc_project_app/tc_project_app.tmcRefac diff --git a/solution.sln b/solution.sln index 60113c2..725c379 100644 --- a/solution.sln +++ b/solution.sln @@ -33,22 +33,6 @@ Global {9CF97348-B9D3-4938-B1F2-5F0B0B6AA66A}.Release|TwinCAT RT (x64).Build.0 = Release|TwinCAT RT (x64) {9CF97348-B9D3-4938-B1F2-5F0B0B6AA66A}.Release|TwinCAT RT (x86).ActiveCfg = Release|TwinCAT RT (x86) {9CF97348-B9D3-4938-B1F2-5F0B0B6AA66A}.Release|TwinCAT RT (x86).Build.0 = Release|TwinCAT RT (x86) - {FB261665-FD20-4BF2-97F8-2854C82B752D}.Debug|TwinCAT CE7 (ARMV7).ActiveCfg = Debug|TwinCAT CE7 (ARMV7) - {FB261665-FD20-4BF2-97F8-2854C82B752D}.Debug|TwinCAT CE7 (ARMV7).Build.0 = Debug|TwinCAT CE7 (ARMV7) - {FB261665-FD20-4BF2-97F8-2854C82B752D}.Debug|TwinCAT OS (ARMT2).ActiveCfg = Debug|TwinCAT OS (ARMT2) - {FB261665-FD20-4BF2-97F8-2854C82B752D}.Debug|TwinCAT OS (ARMT2).Build.0 = Debug|TwinCAT OS (ARMT2) - {FB261665-FD20-4BF2-97F8-2854C82B752D}.Debug|TwinCAT RT (x64).ActiveCfg = Debug|TwinCAT RT (x64) - {FB261665-FD20-4BF2-97F8-2854C82B752D}.Debug|TwinCAT RT (x64).Build.0 = Debug|TwinCAT RT (x64) - {FB261665-FD20-4BF2-97F8-2854C82B752D}.Debug|TwinCAT RT (x86).ActiveCfg = Debug|TwinCAT RT (x86) - {FB261665-FD20-4BF2-97F8-2854C82B752D}.Debug|TwinCAT RT (x86).Build.0 = Debug|TwinCAT RT (x86) - {FB261665-FD20-4BF2-97F8-2854C82B752D}.Release|TwinCAT CE7 (ARMV7).ActiveCfg = Release|TwinCAT CE7 (ARMV7) - {FB261665-FD20-4BF2-97F8-2854C82B752D}.Release|TwinCAT CE7 (ARMV7).Build.0 = Release|TwinCAT CE7 (ARMV7) - {FB261665-FD20-4BF2-97F8-2854C82B752D}.Release|TwinCAT OS (ARMT2).ActiveCfg = Release|TwinCAT OS (ARMT2) - {FB261665-FD20-4BF2-97F8-2854C82B752D}.Release|TwinCAT OS (ARMT2).Build.0 = Release|TwinCAT OS (ARMT2) - {FB261665-FD20-4BF2-97F8-2854C82B752D}.Release|TwinCAT RT (x64).ActiveCfg = Release|TwinCAT RT (x64) - {FB261665-FD20-4BF2-97F8-2854C82B752D}.Release|TwinCAT RT (x64).Build.0 = Release|TwinCAT RT (x64) - {FB261665-FD20-4BF2-97F8-2854C82B752D}.Release|TwinCAT RT (x86).ActiveCfg = Release|TwinCAT RT (x86) - {FB261665-FD20-4BF2-97F8-2854C82B752D}.Release|TwinCAT RT (x86).Build.0 = Release|TwinCAT RT (x86) EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/solution/tc_project_app/LineIDs.dbg b/solution/tc_project_app/LineIDs.dbg new file mode 100644 index 0000000000000000000000000000000000000000..be60dce36d6d6ab41dc2fe82046b3f48d0d20a9c GIT binary patch literal 3272 zcmbVO2~d?)6#f%T1Q9_oapS?0<$)_=nwrLAd9uhd>NL4EWQ}1ilc`KWE@hfYiY!6% zBy&O#0|UiWv=l2VaY0j`#B)I-aiC1gD242NzWX_E9GjZX%zfuS_rLd?@0{=4`@bRH zSIhkLS*8^Zt;aTYIvw+frfHpJKxP{@4355=9Fsriuf0wkPMW&O+@mraWb~8)akVL} zkJ7zFcaZUzvimCCU(NSZc307eWl%PJcT@vYe)tgykb!mnFhmYlUs~DKU=1&{7_VP^ zx1~G$Io*4sY0gTAipHK0Wg`}ZSl#8>QHC2PMSvBUnG69KL8aPHP+eg`5ls!;1a&}SnlS&(v4pVx((l3ooYZw<98UNPebkFhg8xxTi z_#k$~8m`u&-VoMTC(n34NCw1L26FR;Ap+hY$QAQLV2BKpfqg?^h|KM|rf=}6>i9Q< z4OhHMM-&1(FklUGfv~RVBltqSA?$_jHdFIZx`$}w;H5ONxIcb1$vG+6nB|inJbT*t znW#Bqv4-FtF&KNp(L3KoZ$A<7aYN0bTl(e~!FeYc@Xs~O8Q3w$zR}4u1UMkXLH>!K zwPi1}U-FZ@T0Bx)CYCq-RyoCa)DmEWf8b*bo-O9?DeoYL?jlAI(`JirCJ3!fb(Gd1A@|4z>iJ_B;j;g?pO0q#pEsd zX}YIJ+e%<&-HD%Pj=jtLfDb$|FPts-CZ?a;?&Oqbj*Hl%KVKWEf9?eQp+B&OeS^H< zgLujHV3~t}AK(d=fjThn_D$x_FX-n+eNY*&*t*$27rbK~urXJjeb#_ngIi!AmwTIn zQ@l1`j@;kx%QqZP1ZDukf5l0k#EbeP9_|guKpBV?1VhB%rZj6sX#IkNQ^E@;uZuo) zso3>lF?oJbUvT?ijs7V%YZNGZ5Sv&IZSwu-d23_BitX7sS=O|7{twsS3-Tb>$D$9k|StLGIdyZZU7% zdOX2AYM#|`hU2%q50M|&pg*yf{l~uK`671gg#ZuM^X#)9_&sBNc^4cxSUh4^`?RRf zf{bT7)merBBL;k+@7Txom~j7rJKh1kZX0rHzMmSqzQ^ji#`@M2av)1I;KEvdyNDNi z?S1l$pyx49{0_O-stRu8M68+HkYBoU>=EE%O?Z|s_P=hr(cUt#On0p7H$~=kz)$~- zi#Z7QFb?ZH;Oo4aTIZV)m2-}^HY8U3iuF7%Sw468ah|NZP$@jH`mI)$(I3Br2}_y4nMhpo07DBFh$Ab^-XRq-rM`5uDbA8ojY9^%@ zD;=%$YfAGh@*WIP^WX@Ay9(lOQ};PeS9Y4xF?}ZPK3()hT;c4-xWwQcp93Rm1#yqa z?BlwtF>+V4rFWbqY~uSj(_7Q3u2D>~O@H#qnc3q+EXgCv`&C9c2u%brQE zB$VHpm;OWbtOaxWZ)K*6nIwNpd-OAt&$!0mtwO4xz~%dIrLHAptv=PBMo^ zXVmGc^7@^-i#{cPtSft!cN=;LxOhhf$TNg@pr6gue3aIUMm*j*lNt|07DVrCuKo2 - - - - - - @@ -93,7 +84,10 @@ END_IF]]> - END_FOR]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index 9df77c9..3a2e248 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit 9df77c95a603fd24efa32522784df02c340607ec +Subproject commit 3a2e248736bd864a9353a265a966120f6a09f1dc diff --git a/solution/tc_project_app/tc_project_app.tmcRefac b/solution/tc_project_app/tc_project_app.tmcRefac new file mode 100644 index 0000000..b12bc24 --- /dev/null +++ b/solution/tc_project_app/tc_project_app.tmcRefac @@ -0,0 +1,85 @@ + + + + + FB_Axis + mcStatusPower + stMcStatusPower + + + FB_Axis + mcStatusStop + stMcStatusStop + + + FB_Axis + mcStatusHalt + stMcStatusHalt + + + FB_Axis + mcStatusReset + stMcStatusReset + + + FB_Axis + mcStatusMoveAbsolute + stMcStatusMoveAbsolute + + + FB_Axis + mcStatusMoveRelative + stMcStatusMoveRelative + + + FB_Axis + mcStatusMoveVelocity + stMcStatusMoveVelocity + + + FB_Axis + mcStatusMoveModulo + stMcStatusMoveModulo + + + FB_Axis + mcStatusHome + stMcStatusHome + + + FB_Axis + mcStatusReadParameter + stMcStatusReadParameter + + + FB_Axis + mcStatusWriteParameter + stMcStatusWriteParameter + + + FB_Axis + mcStatusGearIn + stMcStatusGearIn + + + FB_Axis + mcStatusGearOut + stMcStatusGearOut + + + FB_Axis + mcStatusGearInMultiMaster + stMcStatusGearInMultiMaster + + + FB_Axis + mcSTATUS_ARRAY_SIZE + nMCSTATUS_ARRAY_SIZE + + + FB_Axis + mcStatus + astMcStatus + + + \ No newline at end of file From 0d6a9e255adc29b78d17dae4ebfa6d50f1bb52a4 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Thu, 25 Aug 2022 13:18:31 +0200 Subject: [PATCH 13/29] Delete file tc_project_app.tmcRefac --- .../tc_project_app/tc_project_app.tmcRefac | 85 ------------------- 1 file changed, 85 deletions(-) delete mode 100644 solution/tc_project_app/tc_project_app.tmcRefac diff --git a/solution/tc_project_app/tc_project_app.tmcRefac b/solution/tc_project_app/tc_project_app.tmcRefac deleted file mode 100644 index b12bc24..0000000 --- a/solution/tc_project_app/tc_project_app.tmcRefac +++ /dev/null @@ -1,85 +0,0 @@ - - - - - FB_Axis - mcStatusPower - stMcStatusPower - - - FB_Axis - mcStatusStop - stMcStatusStop - - - FB_Axis - mcStatusHalt - stMcStatusHalt - - - FB_Axis - mcStatusReset - stMcStatusReset - - - FB_Axis - mcStatusMoveAbsolute - stMcStatusMoveAbsolute - - - FB_Axis - mcStatusMoveRelative - stMcStatusMoveRelative - - - FB_Axis - mcStatusMoveVelocity - stMcStatusMoveVelocity - - - FB_Axis - mcStatusMoveModulo - stMcStatusMoveModulo - - - FB_Axis - mcStatusHome - stMcStatusHome - - - FB_Axis - mcStatusReadParameter - stMcStatusReadParameter - - - FB_Axis - mcStatusWriteParameter - stMcStatusWriteParameter - - - FB_Axis - mcStatusGearIn - stMcStatusGearIn - - - FB_Axis - mcStatusGearOut - stMcStatusGearOut - - - FB_Axis - mcStatusGearInMultiMaster - stMcStatusGearInMultiMaster - - - FB_Axis - mcSTATUS_ARRAY_SIZE - nMCSTATUS_ARRAY_SIZE - - - FB_Axis - mcStatus - astMcStatus - - - \ No newline at end of file From 1b57b2e04ca19c9f70dd7305002916072f578985 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Tue, 27 Sep 2022 16:50:37 +0200 Subject: [PATCH 14/29] Add code to read. store and restore the encoder position BIAS in case of power failure --- solution/tc_project_app/POUs/MAIN.TcPOU | 59 ++++++++++++++++++++----- 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index a97fe32..dfb07a0 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -19,7 +19,9 @@ VAR iAxes : UINT; //index for for loops in Position recovery actions afbReadEncRefSys: ARRAY [1..GVL_APP.nAXIS_NUM] OF MC_ReadParameter; afbRestorePosition: ARRAY [1..GVL_APP.nAXIS_NUM] OF MC_SetPosition; - fbGetDeviceIdentification: FB_GetDeviceIdentificationEx; + afbReadPositionBias: ARRAY [1..GVL_APP.nAXIS_NUM] OF MC_ReadParameter; + afbWritePositionBias: ARRAY [1..GVL_APP.nAXIS_NUM] OF MC_WriteParameter; + fbGetDeviceIdentification: FB_GetDeviceIdentificationEx; END_VAR VAR PERSISTENT @@ -50,6 +52,16 @@ END_FOR]]> '0') THEN +IF (fbGetDeviceIdentification.stDevIdent.strHardwareSerialNo <> '') THEN CHECK_UPS(); RESTORE_POSITIONS(); END_IF]]> @@ -89,6 +101,9 @@ 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." +//Encoder Reference system types: INCREMENTAL=0; INCREMENTAL (singleturn absolute)=4; +// ABSOLUTE=1; ABSOLUTE MULTITURN RANGE (with single overflow)=3; ABSOLUTE SINGLETURN RANGE (with single overflow)=5; +// ABSOLUTE (modulo)=2; IF bRestoreOnStartup AND eGlobalSUpsState = eSUPS_PowerOK THEN bRestoreOnStartup := FALSE; @@ -113,6 +128,11 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN afbRestorePosition[iAxes]( Axis := GVL.astAxes[iAxes].Axis, Position := astAxesPersistent[iAxes].fPositionAtShutdown); + + afbWritePositionBias[iAxes]( + Axis:= GVL.astAxes[iAxes].Axis, + ParameterNumber:= E_AxisParameters.AxisEncoderOffset, + Value:= astAxesPersistent[iAxes].fBiasAtShutdown); END_FOR CASE eStartUp OF @@ -153,23 +173,32 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN eExecuteRestore: //Execute position restore by setting afbRestorePosition.execute = TRUE - FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO - IF afbReadEncRefSys[iAxes].Valid = TRUE AND afbReadEncRefSys[iAxes].Value = 0 AND NOT(astAxesPersistent[iAxes].bMovingAtShutdown) THEN + FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO + //Restore position value for incremental encoders + IF afbReadEncRefSys[iAxes].Valid = TRUE AND NOT astAxesPersistent[iAxes].bMovingAtShutdown AND + (afbReadEncRefSys[iAxes].Value = 0 OR afbReadEncRefSys[iAxes].Value = 4 OR afbReadEncRefSys[iAxes].Value = 2) THEN IF GVL.astAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN afbRestorePosition[iAxes].Execute := TRUE; END_IF - END_IF - END_FOR + //Restore encoder position BIAS for absolute encoders + ELSIF afbReadEncRefSys[iAxes].Valid = TRUE THEN + IF GVL.astAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN + afbWritePositionBias[iAxes].Execute := TRUE; + END_IF + END_IF + END_FOR + 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.nAXIS_NUM DO - IF afbReadEncRefSys[iAxes].Valid = TRUE AND afbReadEncRefSys[iAxes].Value = 0 AND NOT(astAxesPersistent[iAxes].bMovingAtShutdown) THEN + FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO + IF afbReadEncRefSys[iAxes].Valid = TRUE AND NOT astAxesPersistent[iAxes].bMovingAtShutdown AND + (afbReadEncRefSys[iAxes].Value = 0 OR afbReadEncRefSys[iAxes].Value = 4 OR afbReadEncRefSys[iAxes].Value = 2) THEN IF GVL.astAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN - IF NOT afbRestorePosition[iAxes].Done THEN + IF NOT afbRestorePosition[iAxes].Done OR NOT afbWritePositionBias[iAxes].Done THEN RETURN; END_IF END_IF @@ -181,6 +210,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN //Remove execute = TRUE for afbRestorePosition FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO afbRestorePosition[iAxes].Execute := FALSE; + afbWritePositionBias[iAxes].Execute := FALSE; END_FOR bPositionRestoreDone := TRUE; bRestoreExecute := FALSE; @@ -191,13 +221,18 @@ END_IF]]> 0 THEN + //Store Position beofre shutdown + astAxesPersistent[iAxes].fPositionAtShutdown := GVL.astAxes[iAxes].Axis.NcToPlc.ActPos; + + //Store encoder position BIAS at shutdown + astAxesPersistent[iAxes].fBiasAtShutdown := afbReadPositionBias[iAxes].Value; + + //Store value of moving at shutdown + IF NOT GVL.astAxes[iAxes].Axis.Status.StandStill THEN astAxesPersistent[iAxes].bMovingAtShutdown := TRUE; ELSE astAxesPersistent[iAxes].bMovingAtShutdown := FALSE; END_IF - astAxesPersistent[iAxes].bMovingAtShutdown := astAxesPersistent[iAxes].bMovingAtShutdown OR GVL.astAxes[iAxes].Axis.Status.Moving; END_FOR]]> From 054a460e8d16bff04edf78b347cab8372bafa29a Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Tue, 27 Sep 2022 16:51:22 +0200 Subject: [PATCH 15/29] Build solution with new code and new commits form tc_mca_std_lib --- solution/_Config/PLC/tc_project_app.xti | 2 +- solution/solution.tsproj | 4 ++ solution/tc_project_app/POUs/MAIN.TcPOU | 72 ++++++++++++------------- solution/tc_project_app/tc_mca_std_lib | 2 +- 4 files changed, 42 insertions(+), 38 deletions(-) diff --git a/solution/_Config/PLC/tc_project_app.xti b/solution/_Config/PLC/tc_project_app.xti index 30060c1..e29aaf0 100644 --- a/solution/_Config/PLC/tc_project_app.xti +++ b/solution/_Config/PLC/tc_project_app.xti @@ -1,7 +1,7 @@ - + tc_project_app Instance {08500001-0000-0000-F000-000000000064} diff --git a/solution/solution.tsproj b/solution/solution.tsproj index f495754..44582e8 100644 --- a/solution/solution.tsproj +++ b/solution/solution.tsproj @@ -18,5 +18,9 @@ + + + + diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index dfb07a0..2c2978f 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -20,8 +20,8 @@ VAR afbReadEncRefSys: ARRAY [1..GVL_APP.nAXIS_NUM] OF MC_ReadParameter; afbRestorePosition: ARRAY [1..GVL_APP.nAXIS_NUM] OF MC_SetPosition; afbReadPositionBias: ARRAY [1..GVL_APP.nAXIS_NUM] OF MC_ReadParameter; - afbWritePositionBias: ARRAY [1..GVL_APP.nAXIS_NUM] OF MC_WriteParameter; - fbGetDeviceIdentification: FB_GetDeviceIdentificationEx; + afbWritePositionBias: ARRAY [1..GVL_APP.nAXIS_NUM] OF MC_WriteParameter; + fbGetDeviceIdentification: FB_GetDeviceIdentificationEx; END_VAR VAR PERSISTENT @@ -53,13 +53,13 @@ END_FOR]]> //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." -//Encoder Reference system types: INCREMENTAL=0; INCREMENTAL (singleturn absolute)=4; -// ABSOLUTE=1; ABSOLUTE MULTITURN RANGE (with single overflow)=3; ABSOLUTE SINGLETURN RANGE (with single overflow)=5; -// ABSOLUTE (modulo)=2; +//Encoder Reference system types: INCREMENTAL=0; INCREMENTAL (singleturn absolute)=4; +// ABSOLUTE=1; ABSOLUTE MULTITURN RANGE (with single overflow)=3; ABSOLUTE SINGLETURN RANGE (with single overflow)=5; +// ABSOLUTE (modulo)=2; IF bRestoreOnStartup AND eGlobalSUpsState = eSUPS_PowerOK THEN bRestoreOnStartup := FALSE; @@ -128,11 +128,11 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN afbRestorePosition[iAxes]( Axis := GVL.astAxes[iAxes].Axis, Position := astAxesPersistent[iAxes].fPositionAtShutdown); - - afbWritePositionBias[iAxes]( - Axis:= GVL.astAxes[iAxes].Axis, - ParameterNumber:= E_AxisParameters.AxisEncoderOffset, - Value:= astAxesPersistent[iAxes].fBiasAtShutdown); + + afbWritePositionBias[iAxes]( + Axis:= GVL.astAxes[iAxes].Axis, + ParameterNumber:= E_AxisParameters.AxisEncoderOffset, + Value:= astAxesPersistent[iAxes].fBiasAtShutdown); END_FOR CASE eStartUp OF @@ -173,30 +173,30 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN eExecuteRestore: //Execute position restore by setting afbRestorePosition.execute = TRUE - FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO - //Restore position value for incremental encoders - IF afbReadEncRefSys[iAxes].Valid = TRUE AND NOT astAxesPersistent[iAxes].bMovingAtShutdown AND - (afbReadEncRefSys[iAxes].Value = 0 OR afbReadEncRefSys[iAxes].Value = 4 OR afbReadEncRefSys[iAxes].Value = 2) THEN + FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO + //Restore position value for incremental encoders + IF afbReadEncRefSys[iAxes].Valid = TRUE AND NOT astAxesPersistent[iAxes].bMovingAtShutdown AND + (afbReadEncRefSys[iAxes].Value = 0 OR afbReadEncRefSys[iAxes].Value = 4 OR afbReadEncRefSys[iAxes].Value = 2) THEN IF GVL.astAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN afbRestorePosition[iAxes].Execute := TRUE; END_IF - //Restore encoder position BIAS for absolute encoders - ELSIF afbReadEncRefSys[iAxes].Valid = TRUE THEN - IF GVL.astAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN + //Restore encoder position BIAS for absolute encoders + ELSIF afbReadEncRefSys[iAxes].Valid = TRUE THEN + IF GVL.astAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN afbWritePositionBias[iAxes].Execute := TRUE; - END_IF - END_IF - END_FOR - + END_IF + END_IF + END_FOR + 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.nAXIS_NUM DO - IF afbReadEncRefSys[iAxes].Valid = TRUE AND NOT astAxesPersistent[iAxes].bMovingAtShutdown AND - (afbReadEncRefSys[iAxes].Value = 0 OR afbReadEncRefSys[iAxes].Value = 4 OR afbReadEncRefSys[iAxes].Value = 2) THEN + FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO + IF afbReadEncRefSys[iAxes].Valid = TRUE AND NOT astAxesPersistent[iAxes].bMovingAtShutdown AND + (afbReadEncRefSys[iAxes].Value = 0 OR afbReadEncRefSys[iAxes].Value = 4 OR afbReadEncRefSys[iAxes].Value = 2) THEN IF GVL.astAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN IF NOT afbRestorePosition[iAxes].Done OR NOT afbWritePositionBias[iAxes].Done THEN RETURN; @@ -210,7 +210,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN //Remove execute = TRUE for afbRestorePosition FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO afbRestorePosition[iAxes].Execute := FALSE; - afbWritePositionBias[iAxes].Execute := FALSE; + afbWritePositionBias[iAxes].Execute := FALSE; END_FOR bPositionRestoreDone := TRUE; bRestoreExecute := FALSE; @@ -222,12 +222,12 @@ END_IF]]> Date: Fri, 30 Sep 2022 16:07:16 +0200 Subject: [PATCH 16/29] Test: Delete redundancy in linking FB and interfaces in AXES() --- solution.sln | 16 + solution/_Config/NC/Axes/Axis 2.xti | 1562 ----------------------- solution/_Config/PLC/tc_project_app.xti | 70 +- solution/tc_project_app/LineIDs.dbg | Bin 3272 -> 3508 bytes solution/tc_project_app/POUs/MAIN.TcPOU | 9 +- solution/tc_project_app/tc_mca_std_lib | 2 +- 6 files changed, 25 insertions(+), 1634 deletions(-) delete mode 100644 solution/_Config/NC/Axes/Axis 2.xti diff --git a/solution.sln b/solution.sln index 725c379..60113c2 100644 --- a/solution.sln +++ b/solution.sln @@ -33,6 +33,22 @@ Global {9CF97348-B9D3-4938-B1F2-5F0B0B6AA66A}.Release|TwinCAT RT (x64).Build.0 = Release|TwinCAT RT (x64) {9CF97348-B9D3-4938-B1F2-5F0B0B6AA66A}.Release|TwinCAT RT (x86).ActiveCfg = Release|TwinCAT RT (x86) {9CF97348-B9D3-4938-B1F2-5F0B0B6AA66A}.Release|TwinCAT RT (x86).Build.0 = Release|TwinCAT RT (x86) + {FB261665-FD20-4BF2-97F8-2854C82B752D}.Debug|TwinCAT CE7 (ARMV7).ActiveCfg = Debug|TwinCAT CE7 (ARMV7) + {FB261665-FD20-4BF2-97F8-2854C82B752D}.Debug|TwinCAT CE7 (ARMV7).Build.0 = Debug|TwinCAT CE7 (ARMV7) + {FB261665-FD20-4BF2-97F8-2854C82B752D}.Debug|TwinCAT OS (ARMT2).ActiveCfg = Debug|TwinCAT OS (ARMT2) + {FB261665-FD20-4BF2-97F8-2854C82B752D}.Debug|TwinCAT OS (ARMT2).Build.0 = Debug|TwinCAT OS (ARMT2) + {FB261665-FD20-4BF2-97F8-2854C82B752D}.Debug|TwinCAT RT (x64).ActiveCfg = Debug|TwinCAT RT (x64) + {FB261665-FD20-4BF2-97F8-2854C82B752D}.Debug|TwinCAT RT (x64).Build.0 = Debug|TwinCAT RT (x64) + {FB261665-FD20-4BF2-97F8-2854C82B752D}.Debug|TwinCAT RT (x86).ActiveCfg = Debug|TwinCAT RT (x86) + {FB261665-FD20-4BF2-97F8-2854C82B752D}.Debug|TwinCAT RT (x86).Build.0 = Debug|TwinCAT RT (x86) + {FB261665-FD20-4BF2-97F8-2854C82B752D}.Release|TwinCAT CE7 (ARMV7).ActiveCfg = Release|TwinCAT CE7 (ARMV7) + {FB261665-FD20-4BF2-97F8-2854C82B752D}.Release|TwinCAT CE7 (ARMV7).Build.0 = Release|TwinCAT CE7 (ARMV7) + {FB261665-FD20-4BF2-97F8-2854C82B752D}.Release|TwinCAT OS (ARMT2).ActiveCfg = Release|TwinCAT OS (ARMT2) + {FB261665-FD20-4BF2-97F8-2854C82B752D}.Release|TwinCAT OS (ARMT2).Build.0 = Release|TwinCAT OS (ARMT2) + {FB261665-FD20-4BF2-97F8-2854C82B752D}.Release|TwinCAT RT (x64).ActiveCfg = Release|TwinCAT RT (x64) + {FB261665-FD20-4BF2-97F8-2854C82B752D}.Release|TwinCAT RT (x64).Build.0 = Release|TwinCAT RT (x64) + {FB261665-FD20-4BF2-97F8-2854C82B752D}.Release|TwinCAT RT (x86).ActiveCfg = Release|TwinCAT RT (x86) + {FB261665-FD20-4BF2-97F8-2854C82B752D}.Release|TwinCAT RT (x86).Build.0 = Release|TwinCAT RT (x86) EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/solution/_Config/NC/Axes/Axis 2.xti b/solution/_Config/NC/Axes/Axis 2.xti deleted file mode 100644 index 9fb7bf0..0000000 --- a/solution/_Config/NC/Axes/Axis 2.xti +++ /dev/null @@ -1,1562 +0,0 @@ - - - - - UINTARR2 - 32 - UINT - - 0 - 2 - - - [%u, %u] - [0] - [1] - - - 0x%08x [%u, %u] - . - [0] - [1] - - - 0x%08x (%u) - . - . - - - - NCENCODERSTRUCT_IN2B - 320 - - nDataIn1 - UINTARR2 - 32 - 0 - - - nDataIn2 - UINTARR2 - 32 - 32 - - - nState1 - USINT - 8 - 64 - - - nState2 - USINT - 8 - 72 - - - nState3 - USINT - 8 - 80 - - - nState4 - USINT - - 8 - 88 - - - nDataIn3 - UINTARR2 - 32 - 96 - - - nDataIn4 - UINTARR2 - 32 - 128 - - - nDataIn5 - UINTARR2 - 32 - 160 - - - nDataIn6 - UINTARR2 - 32 - 192 - - - nState5 - USINT - 8 - 224 - - - nState6 - USINT - 8 - 232 - - - nState7 - USINT - 8 - 240 - - - nState8 - USINT - 8 - 248 - - - nDcInputTime - DINT - 32 - 256 - - - nDataIn7 - UINTARR2 - - 32 - 288 - - - - NCENCODERSTRUCT_IN - - 96 - - - - - - NCENCODERSTRUCT_OUT2 - 320 - - nDataOut1 - UINTARR2 - 32 - 0 - - - nDataOut2 - UINTARR2 - 32 - 32 - - - nCtrl1 - USINT - 8 - 64 - - - nCtrl2 - USINT - 8 - 72 - - - nCtrl3 - USINT - 8 - 80 - - - nCtrl4 - USINT - 8 - 88 - - - nDataOut3 - UINTARR2 - 32 - 96 - - - nDataOut4 - UINTARR2 - 32 - 128 - - - nDataOut5 - UINTARR2 - 32 - 160 - - - nDataOut6 - UINTARR2 - 32 - 192 - - - nCtrl5 - USINT - 8 - 224 - - - nCtrl6 - USINT - 8 - 232 - - - nCtrl7 - USINT - 8 - 240 - - - nCtrl8 - USINT - 8 - 248 - - - - NCENCODERSTRUCT_OUT - - 96 - - - - - - NCDRIVESTRUCT_IN2 - 320 - - nDataIn1 - UINTARR2 - 32 - 0 - - - nDataIn2 - UINTARR2 - 32 - 32 - - - nState1 - USINT - 8 - 64 - - - nState2 - USINT - 8 - 72 - - - nState3 - USINT - 8 - 80 - - - nState4 - USINT - - 8 - 88 - - - nDataIn3 - UINTARR2 - 32 - 96 - - - nDataIn4 - UINTARR2 - 32 - 128 - - - nDataIn5 - UINTARR2 - 32 - 160 - - - nDataIn6 - UINTARR2 - 32 - 192 - - - nState5 - USINT - 8 - 224 - - - nState6 - USINT - 8 - 232 - - - nState7 - USINT - 8 - 240 - - - nState8 - USINT - - 8 - 248 - - - nDcOutputTime - DINT - 32 - 256 - - - - NCDRIVESTRUCT_IN - - 96 - - - - - - NCDRIVESTRUCT_OUT2 - 320 - - nDataOut1 - UINTARR2 - 32 - 0 - - - nDataOut2 - UINTARR2 - 32 - 32 - - - nCtrl1 - USINT - 8 - 64 - - - nCtrl2 - USINT - 8 - 72 - - - nCtrl3 - USINT - 8 - 80 - - - nCtrl4 - USINT - 8 - 88 - - - nDataOut3 - UINTARR2 - 32 - 96 - - - nDataOut4 - UINTARR2 - 32 - 128 - - - nDataOut5 - UINTARR2 - 32 - 160 - - - nDataOut6 - UINTARR2 - 32 - 192 - - - nCtrl5 - USINT - 8 - 224 - - - nCtrl6 - USINT - 8 - 232 - - - nCtrl7 - USINT - 8 - 240 - - - nCtrl8 - USINT - 8 - 248 - - - - NCDRIVESTRUCT_OUT - - 96 - - - - - - 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 - - - - - 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 - - - OpModeStopMonitoring - BIT - 1 - 12 - - - OpModeOutputSmoothingFilter - BIT - 1 - 13 - - - 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_STATE3_FLAGS - 32 - - TouchProbe1InputState - BIT - 1 - 0 - - - TouchProbe2InputState - BIT - 1 - 1 - - - %08x - - - 0x%08x - - - 16#%08X - - - - NCTOPLC_AXIS_REF_STATE3 - 32 - - Value - DWORD - 32 - 0 - - - Flags - NCTOPLC_AXIS_REF_STATE3_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 - NCTOPLC_AXIS_REF_STATE3 - 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 - - - - - - - - - - - - - - - - - - - - - __FILENAME__ - - - - - - Inputs - - In - NCENCODERSTRUCT_IN2B - - nDataIn1 - - - nDataIn2 - - - nDataIn3 - - - nDataIn4 - - - nDataIn5 - - - nDataIn6 - - - nDataIn7 - - - - - - Outputs - - Out - NCENCODERSTRUCT_OUT2 - - nDataOut1 - - - nDataOut2 - - - nDataOut3 - - - nDataOut4 - - - nDataOut5 - - - nDataOut6 - - - - - - - - - - Inputs - - In - NCDRIVESTRUCT_IN2 - - nDataIn1 - - - nDataIn2 - - - nDataIn3 - - - nDataIn4 - - - nDataIn5 - - - nDataIn6 - - - - - Outputs - - Out - NCDRIVESTRUCT_OUT2 - - nDataOut1 - - - nDataOut2 - - - nCtrl2 - - - - nCtrl3 - - - - nDataOut3 - - - nDataOut4 - - - nDataOut5 - - - nDataOut6 - - - - - - - - - - - Inputs - - FromPlc - PLCTONC_AXIS_REF - - - - Outputs - - ToPlc - NCTOPLC_AXIS_REF - - - - diff --git a/solution/_Config/PLC/tc_project_app.xti b/solution/_Config/PLC/tc_project_app.xti index c18c2d8..a4e7439 100644 --- a/solution/_Config/PLC/tc_project_app.xti +++ b/solution/_Config/PLC/tc_project_app.xti @@ -1,77 +1,9 @@ - + tc_project_app Instance {08500001-0000-0000-F000-000000000064} - - PlcTask Inputs - - GVL.astAxes[1].stStatus.nEncoderRawCounter - - UDINT - - - GVL.astAxes[1].stStatus.nStepperDriveCounter - - UDINT - - - GVL.astAxes[1].stInputs.bLimitFwd - BOOL - - - GVL.astAxes[1].stInputs.bLimitBwd - BOOL - - - GVL.astAxes[1].stInputs.bHomeSensor - - BOOL - - - GVL.astAxes[1].Axis.NcToPlc - NCTOPLC_AXIS_REF - - - GVL.astAxes[2].stStatus.nEncoderRawCounter - - UDINT - - - GVL.astAxes[2].stStatus.nStepperDriveCounter - - UDINT - - - GVL.astAxes[2].stInputs.bLimitFwd - BOOL - - - GVL.astAxes[2].stInputs.bLimitBwd - BOOL - - - GVL.astAxes[2].stInputs.bHomeSensor - - BOOL - - - GVL.astAxes[2].Axis.NcToPlc - NCTOPLC_AXIS_REF - - - - PlcTask Outputs - - GVL.astAxes[1].Axis.PlcToNc - PLCTONC_AXIS_REF - - - GVL.astAxes[2].Axis.PlcToNc - PLCTONC_AXIS_REF - - 0 diff --git a/solution/tc_project_app/LineIDs.dbg b/solution/tc_project_app/LineIDs.dbg index be60dce36d6d6ab41dc2fe82046b3f48d0d20a9c..d28bd2618f6a986a3b5a4ba57359270618d023f6 100644 GIT binary patch delta 299 zcmX>hxkY-z24+Tq$s3uIB_$Xb7#M+A9f(0d8bUEJP3C10XXKeI$Ywk_f<;152q?}3 z#F9V^QqQzGlVv$0BOg$Kw<1UqBnXlO0Z|CWAO)qFCWo>G%d!A@Y(P8#h*_aB)1fre z=B;e)OpLsfZ8?n%Wq^Vp;{>6!9F&F`s{rJKfH)9C-NFgfEIj!mw>7IKNN}0wpbw?>K=fo!o_d)JG80@c9TRcfe*RvwVxi)Euz^rj02Edr&j0`b delta 88 zcmdlYeL`}>24+T{$s3uIC!4ScFmg`zWHX*z!6LDF1 IF _TaskInfo[fbGetCurTaskIndex.index].FirstCycle THEN FOR GVL.iAxis := 1 TO GVL_APP.nAXIS_NUM DO afbAxes[GVL.iAxis].stAxis REF= astAxes[GVL.iAxis]; - aIAxes[GVL.iAxis] := afbAxes[GVL.iAxis]; + //aIAxes[GVL.iAxis] := afbAxes[GVL.iAxis]; END_FOR //Custom axis types defined and linked to aiAxes here + //fbCustomAxis extends FB_axis + //fbCustomAxis.stAxis REF= astAxes[x]; END_IF //Execute FB_Axis logic FOR GVL.iAxis := 1 TO GVL_APP.nAXIS_NUM DO - aIAxes[GVL.iAxis].Run(); + afbAxes[GVL.iAxis].Run(); + //aIAxes[GVL.iAxis].Run(); + //Run the Run() of the custom axis + //fbCustomAxis.Run(); END_FOR //Execute Pneumatic Axis logic diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index c176846..e2becdb 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit c17684688ba488189bc26cd49c221eb0b241fc5f +Subproject commit e2becdb1a3fbbfde36738eabdf3dcb44937adc71 From 99a3efce666aaa881fa22b44844fe010b8c967fb Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Tue, 4 Oct 2022 17:11:37 +0200 Subject: [PATCH 17/29] Add FB_CustomAxis example and update pointer --- solution/tc_project_app/LineIDs.dbg | Bin 3508 -> 3456 bytes solution/tc_project_app/POUs/MAIN.TcPOU | 14 +++++--------- solution/tc_project_app/tc_mca_std_lib | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/solution/tc_project_app/LineIDs.dbg b/solution/tc_project_app/LineIDs.dbg index d28bd2618f6a986a3b5a4ba57359270618d023f6..70f5aaa75dd77ae63fd0196522a4278d6f4751b1 100644 GIT binary patch delta 53 ucmdlY-5|YT1`nga - Date: Thu, 6 Oct 2022 10:57:56 +0200 Subject: [PATCH 18/29] Add git ignore for the LineIDs.dbg file --- .gitignore | 1 + solution/tc_project_app/LineIDs.dbg | Bin 3456 -> 0 bytes 2 files changed, 1 insertion(+) delete mode 100644 solution/tc_project_app/LineIDs.dbg diff --git a/.gitignore b/.gitignore index 83f035e..e5ef5ae 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ UpgradeLog.htm _Boot/ _CompileInfo/ _Libraries/ +solution/tc_project_app/LineIDs.dbg LineIDs.dbg logs.0* solution/TrialLicense.tclrs diff --git a/solution/tc_project_app/LineIDs.dbg b/solution/tc_project_app/LineIDs.dbg deleted file mode 100644 index 70f5aaa75dd77ae63fd0196522a4278d6f4751b1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3456 zcma)72~d?)6#f%T1Q9_napU1*dmy5SX<{0W<;kMJsMF-ukTr(6Or|mgxs+)pDY693 zlgtT04Ga`h&{C|d#05=#63+#V#DOv`qZG39`R+HvG&=dsT+V;)JNK;Ly@YsOEA!Q7 zn^xMj9pBXLOx$CdrgfJE%rR^n8hbA#u3+vzRSsQFnR?0I_4Ls)a3I{1N!ef}I}}!I7HFt9lx&kwq5cjZ5#h_J%)) z`@d+Kqmp4FaVAvhhy^fLSNXP=<$_HCaz)OpiM2$^9%}6;3qXzla>9A$WWuK4DVxxA zN`{L>9%Gd5t@IvBA0iSpJ1PBXC5=i(C^=rqSH`9{j*E_-^v;qDkMRqdl28}s!Q2sR zgtA4y0rpoX-}pUP7BE;AYV(33z}x`Tiv18Mg5k1oZWt87ygq9O1f8y#^mdTps%PoQ zBIJ%7V1rr!_7yyWFZ3HA7kb-N%}q&nk*L8_N#^4EAJcR|pc=@(|9=ZwW3 zV)lr^*c*@C{ULVe$*4~oYZu?vx4ev*casJGv|-K29ed=BPQC%;0Wc5FpZT-5pl`7CQMz6vKpvw$#Ag2FFZ;kcyu}87bg}@{4IMlOSRY~niD%ODzFBZO zE`RASGd$edS78>M3+v;ZB)3^VY%xdHjk||f%o%+l7qHKmzqa4aEzcSkwNHPcE?WP> zNyGuKU_-v4AMnjO$&sP52VkzqGe{QvvR@sW&D~$p&x`q}(tn9{i(el20z2f)9`Vg! z@5m8w0y(fpRn0-Eo?EU&9~k)cTlOadGLgfh=1HH-7jr{A&S8jrBUYd+z|ST$YeiVY z!b4Ldi>9oPJ$<>v`9U#x@6mT~;=et5SZwwvK+YgGb2+?u@Fy=?n-W*<%*oBRroYFx z2sV$(0n7_{5C`CgIgu;mF*%X)T&nTxyRczzaen5a?i(!? z!zX-jA?D4F>h^VfTe3RY!dyAR#&FOo` zkX!rXwD=9~YwDXC+EOtu_yCX>Z27;E`QmJ6pS)YRE7)iLc6ryU3vcE|t)16cP`Z2U zQRKy*kQbK*-7wwkXq{N5JKpoVV)J^$rhmp|K0L!XtjXuw{MtIlTTzvBkF_->Rs0Tn z-ZRep|9p5~bZTE~XpFD=xo$;#xJx}^hs#1eqh$eOY~ud^OMLn$o%h05>9`j-hr5Xx zM9Kn&$-=$?ionk%H23Q{cLMvKHEy%ap60RXoD=$ld@*m<7*Ty{!G}4kC+$wT?P% zWUu({hN^wc7QovGaJJ+|hHYC*S2C{u#Jy*Vze*^Y)0B`DwChXc$bP#_1nJ5uO*h>o}ckk z&FqEv84JBpN3^|mR|2-~tTPrkyA`kUDjZB3_@&LLre!_q(??9G45-Q2|7>#(Y(~kS z)J`^2vS-vjKeWPR-qGt?!1k1K%!M<7F90)!Ps|XKvjb-U#tZe|y=<~MEH<-VSDiob z{5{MF96?;Zo&NF-;4a}D-$-9<3WnQ+=B*^>5Ug|`B}0_tn}s`sIGiVQ+TUU~(-fFB jp=^G0@Mnvx$*7H7BF9h%>{%D?CqT}UgX{~r%KrQdK;B(< From dc531c102f0f0a4c7b77561e9ec7a38f962f8c20 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Thu, 6 Oct 2022 11:16:02 +0200 Subject: [PATCH 19/29] Recompile files without LineIDs --- .../Applications/Application_Template.TcPOU | 4 ---- .../Application_Specific/Axes/Axis_Template.TcPOU | 11 ----------- .../Axes/Pneumatics_Template.TcPOU | 12 ------------ 3 files changed, 27 deletions(-) diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Application_Template.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Application_Template.TcPOU index 3c265a4..d653e82 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Application_Template.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Application_Template.TcPOU @@ -10,9 +10,5 @@ END_VAR - - - - \ No newline at end of file diff --git a/solution/tc_project_app/POUs/Application_Specific/Axes/Axis_Template.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Axes/Axis_Template.TcPOU index 026a49a..43513fc 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Axes/Axis_Template.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Axes/Axis_Template.TcPOU @@ -22,16 +22,5 @@ END_IF*) (*Eg. Stop when temperature reaches certain values, reduce speed if a signal is activated, etc. Eg. GVL.astAxes[x].stControl.bInterlockFwd := NOT bInterlockFwdOK;*)]]> - - - - - - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/POUs/Application_Specific/Axes/Pneumatics_Template.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Axes/Pneumatics_Template.TcPOU index 7192ca5..d374ed2 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Axes/Pneumatics_Template.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Axes/Pneumatics_Template.TcPOU @@ -17,17 +17,5 @@ END_VAR ]]> - - - - - - - - - - - - \ No newline at end of file From 0aa2f1745ca034f0aa247cd294bc4b11f27fcd96 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Thu, 6 Oct 2022 12:55:33 +0200 Subject: [PATCH 20/29] Update pointer to newest verison 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 1f21fee..7ed8b3e 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit 1f21feeafd2b9a75694e1bf0430e098ba8588f3d +Subproject commit 7ed8b3e727578d8d5866039e6c3d62824798e4dd From c8a3bd36191b2f4399e0ac84b9d79590b2aac6b7 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Fri, 14 Oct 2022 13:51:44 +0200 Subject: [PATCH 21/29] Restore files that have nothing to do with the MBP_OOP ticket --- solution/_Config/PLC/tc_project_app.xti | 2 +- solution/solution.tsproj | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/solution/_Config/PLC/tc_project_app.xti b/solution/_Config/PLC/tc_project_app.xti index a4e7439..30060c1 100644 --- a/solution/_Config/PLC/tc_project_app.xti +++ b/solution/_Config/PLC/tc_project_app.xti @@ -1,7 +1,7 @@ - + tc_project_app Instance {08500001-0000-0000-F000-000000000064} diff --git a/solution/solution.tsproj b/solution/solution.tsproj index 8540b5c..f495754 100644 --- a/solution/solution.tsproj +++ b/solution/solution.tsproj @@ -2,7 +2,8 @@ - + + From 2d5075390a6e0fe161df476ef0f0d79445b865a4 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Fri, 14 Oct 2022 14:42:52 +0200 Subject: [PATCH 22/29] Update tc_mca_Std_lib pointer after OOP merge --- 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 1859657..242464a 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit 18596570b034876e609fff8caef0bd0cea955eda +Subproject commit 242464a4ccb0ef0053072dde46ba206b9e1619c3 From 3c0a37a0e716ee8eec2b415156513f3a61c064a5 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Fri, 14 Oct 2022 15:11:03 +0200 Subject: [PATCH 23/29] Format notes and correct indentation to MAIN.RESTORE_POSITION() Format the comments about the reference system types Correct wierd identation Fix Format of if evaluation of boolean variables withouth the "= True or = False" --- solution/tc_project_app/POUs/MAIN.TcPOU | 66 +++++++++++++------------ 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 2c2978f..48ef335 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -55,7 +55,7 @@ END_FOR]]> FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO //Read encoder position BIAS IF astAxes[iAxes].stStatus.bAxisInitialized THEN - afbReadPositionBias[iAxes](Axis := GVL.astAxes[iAxes].Axis, + afbReadPositionBias[iAxes](Axis := GVL.astAxes[iAxes].Axis, Enable := TRUE, ReadMode:= READMODE_CYCLIC, ParameterNumber := E_AxisParameters.AxisEncoderOffset); @@ -101,9 +101,14 @@ 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." -//Encoder Reference system types: INCREMENTAL=0; INCREMENTAL (singleturn absolute)=4; -// ABSOLUTE=1; ABSOLUTE MULTITURN RANGE (with single overflow)=3; ABSOLUTE SINGLETURN RANGE (with single overflow)=5; -// ABSOLUTE (modulo)=2; +//Encoder Reference system types: https://infosys.beckhoff.com/english.php?content=../content/1033/tf50x0_tc3_nc_ptp/3439907723.html&id= +//INCREMENTAL=0; +//ABSOLUTE=1; +//ABSOLUTE (modulo)=2; +//ABSOLUTE MULTITURN RANGE (with single overflow)=3; +//INCREMENTAL (singleturn absolute)=4; +//ABSOLUTE SINGLETURN RANGE (with single overflow)=5; + IF bRestoreOnStartup AND eGlobalSUpsState = eSUPS_PowerOK THEN bRestoreOnStartup := FALSE; @@ -117,44 +122,44 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN //Result stored in Value, 0=Inc 1=Abs, execute set during the case statement FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO afbReadEncRefSys[iAxes]( - Axis := GVL.astAxes[iAxes].Axis, - Enable := bExecuteReadEncRefSys, - ParameterNumber := MC_AxisParameter.AxisEncoderReferenceSystem, - ReadMode := E_READMODE.READMODE_ONCE); + Axis := GVL.astAxes[iAxes].Axis, + Enable := bExecuteReadEncRefSys, + ParameterNumber := MC_AxisParameter.AxisEncoderReferenceSystem, + ReadMode := E_READMODE.READMODE_ONCE); END_FOR //Cycle through set position function blocks for each axis FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO afbRestorePosition[iAxes]( - Axis := GVL.astAxes[iAxes].Axis, - Position := astAxesPersistent[iAxes].fPositionAtShutdown); + Axis := GVL.astAxes[iAxes].Axis, + Position := astAxesPersistent[iAxes].fPositionAtShutdown); afbWritePositionBias[iAxes]( - Axis:= GVL.astAxes[iAxes].Axis, - ParameterNumber:= E_AxisParameters.AxisEncoderOffset, - Value:= astAxesPersistent[iAxes].fBiasAtShutdown); + Axis:= GVL.astAxes[iAxes].Axis, + ParameterNumber:= E_AxisParameters.AxisEncoderOffset, + Value:= astAxesPersistent[iAxes].fBiasAtShutdown); 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.nAXIS_NUM is not set correctly + //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 iAxes := 1 TO GVL_APP.nAXIS_NUM DO - IF afbReadEncRefSys[iAxes].Valid = FALSE THEN - IF afbReadEncRefSys[iAxes].Busy = TRUE THEN + IF NOT afbReadEncRefSys[iAxes].Valid THEN + IF afbReadEncRefSys[iAxes].Busy THEN //Exit MAIN.STARTUP Action and wait till next cycle, needs to cycle through whole program in order for data to update RETURN; ELSE @@ -168,35 +173,32 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN 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 have .valid=TRUE for all axes 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.nAXIS_NUM DO //Restore position value for incremental encoders - IF afbReadEncRefSys[iAxes].Valid = TRUE AND NOT astAxesPersistent[iAxes].bMovingAtShutdown AND - (afbReadEncRefSys[iAxes].Value = 0 OR afbReadEncRefSys[iAxes].Value = 4 OR afbReadEncRefSys[iAxes].Value = 2) THEN + IF afbReadEncRefSys[iAxes].Valid AND NOT astAxesPersistent[iAxes].bMovingAtShutdown AND (afbReadEncRefSys[iAxes].Value = 0 OR afbReadEncRefSys[iAxes].Value = 4 OR afbReadEncRefSys[iAxes].Value = 2) THEN IF GVL.astAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN afbRestorePosition[iAxes].Execute := TRUE; END_IF //Restore encoder position BIAS for absolute encoders - ELSIF afbReadEncRefSys[iAxes].Valid = TRUE THEN + ELSIF afbReadEncRefSys[iAxes].Valid THEN IF GVL.astAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN afbWritePositionBias[iAxes].Execute := TRUE; END_IF END_IF END_FOR - 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 + //Check the set position fbs are finished + //Nothing actually happens if the restore is not done, the code just returns from here each cycle and the + //bPositionRestoreDone will never get set to TRUE and will take up cycle time FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO - IF afbReadEncRefSys[iAxes].Valid = TRUE AND NOT astAxesPersistent[iAxes].bMovingAtShutdown AND - (afbReadEncRefSys[iAxes].Value = 0 OR afbReadEncRefSys[iAxes].Value = 4 OR afbReadEncRefSys[iAxes].Value = 2) THEN + IF afbReadEncRefSys[iAxes].Valid AND NOT astAxesPersistent[iAxes].bMovingAtShutdown AND (afbReadEncRefSys[iAxes].Value = 0 OR afbReadEncRefSys[iAxes].Value = 4 OR afbReadEncRefSys[iAxes].Value = 2) THEN IF GVL.astAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN IF NOT afbRestorePosition[iAxes].Done OR NOT afbWritePositionBias[iAxes].Done THEN RETURN; @@ -207,7 +209,7 @@ 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.nAXIS_NUM DO afbRestorePosition[iAxes].Execute := FALSE; afbWritePositionBias[iAxes].Execute := FALSE; From 3335971d3f0844ec44890ba8ee00278b9a911421 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Fri, 14 Oct 2022 16:06:29 +0200 Subject: [PATCH 24/29] Refactoring code with new variable name fEncoderBiasAtShutdown --- solution/tc_project_app/POUs/MAIN.TcPOU | 46 ++++++++++++------------- solution/tc_project_app/tc_mca_std_lib | 2 +- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 28c6543..ced1c85 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -66,7 +66,7 @@ END_FOR]]> FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO //Read encoder position BIAS IF astAxes[iAxes].stStatus.bAxisInitialized THEN - afbReadPositionBias[iAxes](Axis := GVL.astAxes[iAxes].Axis, + afbReadPositionBias[iAxes](Axis := GVL.astAxes[iAxes].Axis, Enable := TRUE, ReadMode:= READMODE_CYCLIC, ParameterNumber := E_AxisParameters.AxisEncoderOffset); @@ -125,9 +125,9 @@ GVL.fbGetCurTaskIndex(); //Note from Beckhoff: "A maximum of 1 MB persistent data can be reliably saved over the entire service life." //Encoder Reference system types: https://infosys.beckhoff.com/english.php?content=../content/1033/tf50x0_tc3_nc_ptp/3439907723.html&id= //INCREMENTAL=0; -//ABSOLUTE=1; +//ABSOLUTE=1; //ABSOLUTE (modulo)=2; -//ABSOLUTE MULTITURN RANGE (with single overflow)=3; +//ABSOLUTE MULTITURN RANGE (with single overflow)=3; //INCREMENTAL (singleturn absolute)=4; //ABSOLUTE SINGLETURN RANGE (with single overflow)=5; @@ -144,41 +144,41 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN //Result stored in Value, 0=Inc 1=Abs, execute set during the case statement FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO afbReadEncRefSys[iAxes]( - Axis := GVL.astAxes[iAxes].Axis, - Enable := bExecuteReadEncRefSys, - ParameterNumber := MC_AxisParameter.AxisEncoderReferenceSystem, - ReadMode := E_READMODE.READMODE_ONCE); + Axis := GVL.astAxes[iAxes].Axis, + Enable := bExecuteReadEncRefSys, + ParameterNumber := MC_AxisParameter.AxisEncoderReferenceSystem, + ReadMode := E_READMODE.READMODE_ONCE); END_FOR //Cycle through set position function blocks for each axis FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO afbRestorePosition[iAxes]( - Axis := GVL.astAxes[iAxes].Axis, - Position := astAxesPersistent[iAxes].fPositionAtShutdown); + Axis := GVL.astAxes[iAxes].Axis, + Position := astAxesPersistent[iAxes].fPositionAtShutdown); afbWritePositionBias[iAxes]( - Axis:= GVL.astAxes[iAxes].Axis, - ParameterNumber:= E_AxisParameters.AxisEncoderOffset, - Value:= astAxesPersistent[iAxes].fBiasAtShutdown); + Axis:= GVL.astAxes[iAxes].Axis, + ParameterNumber:= E_AxisParameters.AxisEncoderOffset, + Value:= astAxesPersistent[iAxes].fEncoderBiasAtShutdown); 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.nAXIS_NUM is not set correctly + //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 iAxes := 1 TO GVL_APP.nAXIS_NUM DO IF NOT afbReadEncRefSys[iAxes].Valid THEN IF afbReadEncRefSys[iAxes].Busy THEN @@ -199,7 +199,7 @@ 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.nAXIS_NUM DO //Restore position value for incremental encoders IF afbReadEncRefSys[iAxes].Valid AND NOT astAxesPersistent[iAxes].bMovingAtShutdown AND (afbReadEncRefSys[iAxes].Value = 0 OR afbReadEncRefSys[iAxes].Value = 4 OR afbReadEncRefSys[iAxes].Value = 2) THEN @@ -216,9 +216,9 @@ 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 + //Check the set position fbs are finished + //Nothing actually happens if the restore is not done, the code just returns from here each cycle and the + //bPositionRestoreDone will never get set to TRUE and will take up cycle time FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO IF afbReadEncRefSys[iAxes].Valid AND NOT astAxesPersistent[iAxes].bMovingAtShutdown AND (afbReadEncRefSys[iAxes].Value = 0 OR afbReadEncRefSys[iAxes].Value = 4 OR afbReadEncRefSys[iAxes].Value = 2) THEN IF GVL.astAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN @@ -231,7 +231,7 @@ 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.nAXIS_NUM DO afbRestorePosition[iAxes].Execute := FALSE; afbWritePositionBias[iAxes].Execute := FALSE; @@ -249,7 +249,7 @@ END_IF]]> astAxesPersistent[iAxes].fPositionAtShutdown := GVL.astAxes[iAxes].Axis.NcToPlc.ActPos; //Store encoder position BIAS at shutdown - astAxesPersistent[iAxes].fBiasAtShutdown := afbReadPositionBias[iAxes].Value; + astAxesPersistent[iAxes].fEncoderBiasAtShutdown := afbReadPositionBias[iAxes].Value; //Store value of moving at shutdown IF NOT GVL.astAxes[iAxes].Axis.Status.StandStill THEN diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index f86e45d..b288bf7 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit f86e45d2b4cc52573f095f141b7bdf1fede84bdb +Subproject commit b288bf7705508e878d39dbd89320862aa8995681 From c4d865edc1e432812d1f5e3c9eb040a475d0193d Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Thu, 20 Oct 2022 16:24:22 +0200 Subject: [PATCH 25/29] Optimize code for executing postiong restoring --- solution/tc_project_app/POUs/MAIN.TcPOU | 71 ++++++++++++++----------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index ced1c85..3cf4192 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -19,7 +19,7 @@ VAR nRetry: INT; iAxes: UINT; //index for for loops in Position recovery actions afbReadEncRefSys: ARRAY [1..GVL_APP.nAXIS_NUM] OF MC_ReadParameter; - afbRestorePosition: ARRAY [1..GVL_APP.nAXIS_NUM] OF MC_SetPosition; + afbSetPosition: ARRAY [1..GVL_APP.nAXIS_NUM] OF MC_SetPosition; afbReadPositionBias: ARRAY [1..GVL_APP.nAXIS_NUM] OF MC_ReadParameter; afbWritePositionBias: ARRAY [1..GVL_APP.nAXIS_NUM] OF MC_WriteParameter; fbGetDeviceIdentification: FB_GetDeviceIdentificationEx; @@ -104,7 +104,7 @@ GVL.fbGetCurTaskIndex(); //Create as many programs in that folder as axes and applications you have or need //Axes initial parameters and program -//Axis_Template(); +Axis_Template(); //Pneumatics_Template(); //Application program calls @@ -141,18 +141,16 @@ END_IF //and should stay TRUE for the rest of the time the PLC is operational, thus this routine should only be completed once. 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.nAXIS_NUM DO - afbReadEncRefSys[iAxes]( + afbReadEncRefSys[iAxes]( Axis := GVL.astAxes[iAxes].Axis, - Enable := bExecuteReadEncRefSys, ParameterNumber := MC_AxisParameter.AxisEncoderReferenceSystem, ReadMode := E_READMODE.READMODE_ONCE); END_FOR //Cycle through set position function blocks for each axis FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO - afbRestorePosition[iAxes]( + afbSetPosition[iAxes]( Axis := GVL.astAxes[iAxes].Axis, Position := astAxesPersistent[iAxes].fPositionAtShutdown); @@ -172,8 +170,10 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN eReadAxisFeedbackType: //Exectute the function blocks to read the encoder reference system (0=inc OR 1=ABS) - bExecuteReadEncRefSys := TRUE; - eStartUp := eCheckReadDone; + FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO + afbReadEncRefSys[iAxes].Enable := TRUE; + eStartUp := eCheckReadDone; + END_FOR eCheckReadDone: //Check the encoder reference system has been read for all axis -> if busy then continue with PLC cycle and check again next time. @@ -188,7 +188,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN //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; + afbReadEncRefSys[iAxes].Enable := 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; @@ -200,44 +200,55 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN eExecuteRestore: //Execute position restore by setting afbRestorePosition.execute = TRUE + //Restore position value for incremental encoders FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO - //Restore position value for incremental encoders - IF afbReadEncRefSys[iAxes].Valid AND NOT astAxesPersistent[iAxes].bMovingAtShutdown AND (afbReadEncRefSys[iAxes].Value = 0 OR afbReadEncRefSys[iAxes].Value = 4 OR afbReadEncRefSys[iAxes].Value = 2) THEN - IF GVL.astAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN - afbRestorePosition[iAxes].Execute := TRUE; - END_IF - //Restore encoder position BIAS for absolute encoders - ELSIF afbReadEncRefSys[iAxes].Valid THEN - IF GVL.astAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN - afbWritePositionBias[iAxes].Execute := TRUE; - END_IF - END_IF + IF GVL.astAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN + IF NOT astAxesPersistent[iAxes].bMovingAtShutdown AND (afbReadEncRefSys[iAxes].Value = 0 OR afbReadEncRefSys[iAxes].Value = 2 OR afbReadEncRefSys[iAxes].Value = 4) THEN + afbSetPosition[iAxes].Execute := TRUE; + //Restore encoder position BIAS for absolute encoders + ELSIF afbReadEncRefSys[iAxes].Value = 1 OR afbReadEncRefSys[iAxes].Value = 3 OR afbReadEncRefSys[iAxes].Value = 5 THEN + afbWritePositionBias[iAxes].Execute := TRUE; + END_IF + ELSE + RETURN; + END_IF END_FOR 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.nAXIS_NUM DO - IF afbReadEncRefSys[iAxes].Valid AND NOT astAxesPersistent[iAxes].bMovingAtShutdown AND (afbReadEncRefSys[iAxes].Value = 0 OR afbReadEncRefSys[iAxes].Value = 4 OR afbReadEncRefSys[iAxes].Value = 2) THEN - IF GVL.astAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN - IF NOT afbRestorePosition[iAxes].Done OR NOT afbWritePositionBias[iAxes].Done THEN + IF GVL.astAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN + IF NOT astAxesPersistent[iAxes].bMovingAtShutdown AND (afbReadEncRefSys[iAxes].Value = 0 OR afbReadEncRefSys[iAxes].Value = 2 OR afbReadEncRefSys[iAxes].Value = 4) THEN + IF NOT afbSetPosition[iAxes].Done THEN + afbSetPosition[iAxes].Execute := FALSE; + eStartUp := eExecuteRestore; + RETURN; + END_IF + ELSIF afbReadEncRefSys[iAxes].Value = 1 OR afbReadEncRefSys[iAxes].Value = 3 OR afbReadEncRefSys[iAxes].Value = 5 THEN + IF NOT afbWritePositionBias[iAxes].Done THEN + afbWritePositionBias[iAxes].Execute := FALSE; + eStartUp := eExecuteRestore; RETURN; END_IF END_IF + ELSE + RETURN; END_IF END_FOR - eStartUp := eFinishRestore; + eStartUp := eFinishRestore; eFinishRestore: //Remove execute = TRUE for afbRestorePosition FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO - afbRestorePosition[iAxes].Execute := FALSE; + afbSetPosition[iAxes].Execute := FALSE; afbWritePositionBias[iAxes].Execute := FALSE; + bPositionRestoreDone := TRUE; + bRestoreExecute := FALSE; END_FOR - bPositionRestoreDone := TRUE; - bRestoreExecute := FALSE; END_CASE END_IF]]> @@ -252,10 +263,10 @@ END_IF]]> astAxesPersistent[iAxes].fEncoderBiasAtShutdown := afbReadPositionBias[iAxes].Value; //Store value of moving at shutdown - IF NOT GVL.astAxes[iAxes].Axis.Status.StandStill THEN - astAxesPersistent[iAxes].bMovingAtShutdown := TRUE; - ELSE + IF GVL.astAxes[iAxes].Axis.Status.StandStill OR GVL.astAxes[iAxes].Axis.Status.Disabled THEN astAxesPersistent[iAxes].bMovingAtShutdown := FALSE; + ELSE + astAxesPersistent[iAxes].bMovingAtShutdown := TRUE; END_IF END_FOR]]> From 695ea97bb4eb9ba8d1a2bf1d3e2913c2255daba3 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Fri, 21 Oct 2022 09:32:25 +0200 Subject: [PATCH 26/29] Update tc_mca_Std_lib pointer --- 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 b288bf7..92f5593 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit b288bf7705508e878d39dbd89320862aa8995681 +Subproject commit 92f5593e2ee77203c6d2cb3229cb0de9f1141b83 From 8b085864bef976ae7b6f10fe6d0f19a542c8c021 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Tue, 1 Nov 2022 13:34:26 +0100 Subject: [PATCH 27/29] Update tc_mca_std_lib pointer to latest commit 28617c2 --- 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 92f5593..28617c2 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit 92f5593e2ee77203c6d2cb3229cb0de9f1141b83 +Subproject commit 28617c247e0739fb00126eeb9afe52c1b2676732 From df85fad7a270e1663e817dbedecc87f76648dfae Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Tue, 1 Nov 2022 13:34:55 +0100 Subject: [PATCH 28/29] Format IF statements with jump line each condition --- solution/tc_project_app/POUs/MAIN.TcPOU | 40 +++++++++++++++---------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 3cf4192..76d2080 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -104,7 +104,7 @@ GVL.fbGetCurTaskIndex(); //Create as many programs in that folder as axes and applications you have or need //Axes initial parameters and program -Axis_Template(); +//Axis_Template(); //Pneumatics_Template(); //Application program calls @@ -148,7 +148,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN ReadMode := E_READMODE.READMODE_ONCE); END_FOR - //Cycle through set position function blocks for each axis + //Cycle through set position and MC_WritePArameter function blocks for each axis FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO afbSetPosition[iAxes]( Axis := GVL.astAxes[iAxes].Axis, @@ -199,16 +199,21 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN eStartUp := eExecuteRestore; eExecuteRestore: - //Execute position restore by setting afbRestorePosition.execute = TRUE - //Restore position value for incremental encoders - FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO + //Execute position and encoder BIAS restore by setting Execute = TRUE + FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO IF GVL.astAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN - IF NOT astAxesPersistent[iAxes].bMovingAtShutdown AND (afbReadEncRefSys[iAxes].Value = 0 OR afbReadEncRefSys[iAxes].Value = 2 OR afbReadEncRefSys[iAxes].Value = 4) THEN - afbSetPosition[iAxes].Execute := TRUE; - //Restore encoder position BIAS for absolute encoders - ELSIF afbReadEncRefSys[iAxes].Value = 1 OR afbReadEncRefSys[iAxes].Value = 3 OR afbReadEncRefSys[iAxes].Value = 5 THEN - afbWritePositionBias[iAxes].Execute := TRUE; - END_IF + //Restore position value for incremental encoders + IF NOT astAxesPersistent[iAxes].bMovingAtShutdown AND + (afbReadEncRefSys[iAxes].Value = 0 OR + afbReadEncRefSys[iAxes].Value = 2 OR + afbReadEncRefSys[iAxes].Value = 4) THEN + afbSetPosition[iAxes].Execute := TRUE; + //Restore encoder position BIAS for absolute encoders + ELSIF afbReadEncRefSys[iAxes].Value = 1 OR + afbReadEncRefSys[iAxes].Value = 3 OR + afbReadEncRefSys[iAxes].Value = 5 THEN + afbWritePositionBias[iAxes].Execute := TRUE; + END_IF ELSE RETURN; END_IF @@ -217,18 +222,23 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN eCheckRestore: - //Check the set position fbs are finished + //Check the set position and write enocder BIAS fbs are finished //Nothing actually happens if the restore is not done, the code just returns from here each cycle and the //bPositionRestoreDone will never get set to TRUE and will take up cycle time FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO IF GVL.astAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN - IF NOT astAxesPersistent[iAxes].bMovingAtShutdown AND (afbReadEncRefSys[iAxes].Value = 0 OR afbReadEncRefSys[iAxes].Value = 2 OR afbReadEncRefSys[iAxes].Value = 4) THEN + IF NOT astAxesPersistent[iAxes].bMovingAtShutdown AND + (afbReadEncRefSys[iAxes].Value = 0 OR + afbReadEncRefSys[iAxes].Value = 2 OR + afbReadEncRefSys[iAxes].Value = 4) THEN IF NOT afbSetPosition[iAxes].Done THEN afbSetPosition[iAxes].Execute := FALSE; eStartUp := eExecuteRestore; RETURN; END_IF - ELSIF afbReadEncRefSys[iAxes].Value = 1 OR afbReadEncRefSys[iAxes].Value = 3 OR afbReadEncRefSys[iAxes].Value = 5 THEN + ELSIF afbReadEncRefSys[iAxes].Value = 1 OR + afbReadEncRefSys[iAxes].Value = 3 OR + afbReadEncRefSys[iAxes].Value = 5 THEN IF NOT afbWritePositionBias[iAxes].Done THEN afbWritePositionBias[iAxes].Execute := FALSE; eStartUp := eExecuteRestore; @@ -242,7 +252,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN eStartUp := eFinishRestore; eFinishRestore: - //Remove execute = TRUE for afbRestorePosition + //Remove execute = TRUE for afbRestorePosition and fbWritePositionBias FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO afbSetPosition[iAxes].Execute := FALSE; afbWritePositionBias[iAxes].Execute := FALSE; From aa679246500c8f1dc4f31b02253d41fc98a02f87 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Tue, 1 Nov 2022 14:20:53 +0100 Subject: [PATCH 29/29] Add example to configure retore position of an axis in Axis_Template --- solution/_Config/PLC/tc_project_app.xti | 2 +- solution/solution.tsproj | 4 ---- .../POUs/Application_Specific/Axes/Axis_Template.TcPOU | 1 + 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/solution/_Config/PLC/tc_project_app.xti b/solution/_Config/PLC/tc_project_app.xti index e29aaf0..30060c1 100644 --- a/solution/_Config/PLC/tc_project_app.xti +++ b/solution/_Config/PLC/tc_project_app.xti @@ -1,7 +1,7 @@ - + tc_project_app Instance {08500001-0000-0000-F000-000000000064} diff --git a/solution/solution.tsproj b/solution/solution.tsproj index 44582e8..f495754 100644 --- a/solution/solution.tsproj +++ b/solution/solution.tsproj @@ -18,9 +18,5 @@ - - - - diff --git a/solution/tc_project_app/POUs/Application_Specific/Axes/Axis_Template.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Axes/Axis_Template.TcPOU index 43513fc..5e9edcc 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Axes/Axis_Template.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Axes/Axis_Template.TcPOU @@ -16,6 +16,7 @@ END_VAR]]> GVL.astAxes[1].stConfig.eHomeSeq := 0; GVL.astAxes[1].stConfig.fHomePosition := 0.0; GVL.astAxes[1].stConfig.fHomeFinishDistance := 0.0; + GVL.astAxes[1].stConfig.eRestorePosition := E_RestorePosition.eRestoreWithoutHome; END_IF*) //Define ACTIONS() or write exclusive code for an specific axis.