diff --git a/.gitignore b/.gitignore
index 8f8c117..63a08bd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,5 @@ logs.0*
solution/TrialLicense.tclrs
tools/linux/ADS/
tools/linux/getADSState/getADSState.bin
+_Config/NC/Axes
+_Config/IO
diff --git a/solution/_Config/NC/NC.xti b/solution/_Config/NC/NC.xti
new file mode 100644
index 0000000..759c7a3
--- /dev/null
+++ b/solution/_Config/NC/NC.xti
@@ -0,0 +1,20 @@
+
+
+
+
+ NC-Task 1 SAF
+
+ Inputs
+
+
+ Outputs
+
+
+ Image
+
+
+
+ NC-Task 1 SVB
+
+
+
diff --git a/solution/solution.tsproj b/solution/solution.tsproj
index f74cba4..36de82a 100644
--- a/solution/solution.tsproj
+++ b/solution/solution.tsproj
@@ -1,879 +1,6 @@
-
-
- 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
-
-
- 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
-
-
-
- NCTOPLC_AXIS_REF_OPMODE
- 32
-
- OpModePosAreaMonitoring
- BIT
- 1
- 0
-
-
- OpModeTargetPosMonitoring
- BIT
- 1
- 1
-
-
- OpModeLoop
- BIT
- 1
- 2
-
-
- OpModeMotionMonitoring
- BIT
- 1
- 3
-
-
- OpModePEHTimeMonitoring
- BIT
- 1
- 4
-
-
- OpModeBacklashCompensation
- BIT
- 1
- 5
-
-
- OpModeDelayedErrorReaction
- BIT
- 1
- 6
-
-
- OpModeModulo
- BIT
- 1
- 7
-
-
- OpModeSimulationAxis
- BIT
- 1
- 8
-
-
- OpModePosLagMonitoring
- BIT
- 1
- 16
-
-
- OpModeVeloLagMonitoring
- BIT
- 1
- 17
-
-
- OpModeSoftLimitMinMonitoring
- BIT
- 1
- 18
-
-
- OpModeSoftLimitMaxMonitoring
- BIT
- 1
- 19
-
-
- OpModePosCorrection
- BIT
- 1
- 20
-
-
- OpModeAllowSlaveCommands
- BIT
- 1
- 21
-
-
- OpModeAllowExtSetAxisCommands
- BIT
- 1
- 22
-
-
- ApplicationRequest
- BIT
- 1
- 23
-
-
-
- NCTOPLC_AXIS_REF_STATE2_FLAGS
- 32
-
- AvoidingCollision
- BIT
- 1
- 0
-
-
- %08x
-
-
- 0x%08x
-
-
- 16#%08X
-
-
-
- NCTOPLC_AXIS_REF_STATE2
- 32
-
- Value
- DWORD
- 32
- 0
-
-
- Flags
- NCTOPLC_AXIS_REF_STATE2_FLAGS
- 32
- 0
-
-
- %08x
-
-
- 0x%08x
-
-
- 16#%08X
-
-
-
- NCTOPLC_AXIS_REF_CAMCOUPLINGSTATE
- 8
-
- CamActivationPending
- BIT
- 1
- 0
-
-
- CamDeactivationPending
- BIT
- 1
- 1
-
-
- CamActive
- BIT
- 1
- 2
-
-
- CamDataQueued
- BIT
- 1
- 6
-
-
- CamScalingPending
- BIT
- 1
- 7
-
-
-
- UINTARR8
- 128
- UINT
-
- 0
- 8
-
-
-
- NCTOPLC_AXIS_REF
- 2048
-
- StateDWord
- NCTOPLC_AXIS_REF_STATE
- 32
- 0
-
-
- ErrorCode
- UDINT
- 32
- 32
-
-
- AxisState
- UDINT
-
- 32
- 64
-
-
- AxisModeConfirmation
- UDINT
- 32
- 96
-
-
- HomingState
- UDINT
-
- 32
- 128
-
-
- CoupleState
- UDINT
-
- 32
- 160
-
-
- SvbEntries
- UDINT
- 32
- 192
-
-
- SafEntries
- UDINT
- 32
- 224
-
-
- AxisId
- UDINT
- 32
- 256
-
-
- OpModeDWord
- NCTOPLC_AXIS_REF_OPMODE
- 32
- 288
-
-
- ActPos
- LREAL
- 64
- 320
-
-
- ModuloActPos
- LREAL
- 64
- 384
-
-
- ActiveControlLoopIndex
- UINT
- 16
- 448
-
-
- ControlLoopIndex
- UINT
- 16
- 464
-
-
- ModuloActTurns
- DINT
- 32
- 480
-
-
- ActVelo
- LREAL
- 64
- 512
-
-
- PosDiff
- LREAL
- 64
- 576
-
-
- SetPos
- LREAL
- 64
- 640
-
-
- SetVelo
- LREAL
- 64
- 704
-
-
- SetAcc
- LREAL
- 64
- 768
-
-
- TargetPos
- LREAL
- 64
- 832
-
-
- ModuloSetPos
- LREAL
- 64
- 896
-
-
- ModuloSetTurns
- DINT
- 32
- 960
-
-
- CmdNo
- UINT
- 16
- 992
-
-
- CmdState
- UINT
- 16
- 1008
-
-
- SetJerk
- LREAL
- 64
- 1024
-
-
- SetTorque
- LREAL
- 64
- 1088
-
-
- ActTorque
- LREAL
- 64
- 1152
-
-
- StateDWord2
- NCTOPLC_AXIS_REF_STATE2
- 32
- 1216
-
-
- StateDWord3
- DWORD
- 32
- 1248
-
-
- TouchProbeState
- DWORD
- 32
- 1280
-
-
- TouchProbeCounter
- DWORD
- 32
- 1312
-
-
- CamCouplingState
- NCTOPLC_AXIS_REF_CAMCOUPLINGSTATE
-
- 0
- 8
-
- 64
- 1344
-
-
- CamCouplingTableID
- UINTARR8
- 128
- 1408
-
-
- ActTorqueDerivative
- LREAL
- 64
- 1536
-
-
- SetTorqueDerivative
- LREAL
- 64
- 1600
-
-
- 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
-
-
-
-
-
+
@@ -889,6 +16,9 @@ External Setpoint Generation:
+
+
+
@@ -903,135 +33,6 @@ External Setpoint Generation:
tc_project_app Instance
{08500001-0000-0000-F000-000000000064}
-
- PlcTask Inputs
-
- GVL.axes[1].inputs.bLimitFwd
-
- BOOL
-
-
- GVL.axes[1].inputs.bLimitBwd
-
- BOOL
-
-
- GVL.axes[1].inputs.bHomeSensor
-
- BOOL
-
-
- GVL.axes[1].inputs.bEncLAtch
-
- BOOL
-
-
- GVL.axes[1].Axis.NcToPlc
- NCTOPLC_AXIS_REF
-
- AxisState
-
-
-
- HomingState
-
-
-
- CoupleState
-
-
-
-
- GVL.axes[2].inputs.bLimitFwd
-
- BOOL
-
-
- GVL.axes[2].inputs.bLimitBwd
-
- BOOL
-
-
- GVL.axes[2].inputs.bHomeSensor
-
- BOOL
-
-
- GVL.axes[2].inputs.bEncLAtch
-
- BOOL
-
-
- GVL.axes[2].Axis.NcToPlc
- NCTOPLC_AXIS_REF
-
- AxisState
-
-
-
- HomingState
-
-
-
- CoupleState
-
-
-
-
PlcTask Outputs
@@ -1039,14 +40,6 @@ External Setpoint Generation:
BOOL
-
- GVL.axes[1].Axis.PlcToNc
- PLCTONC_AXIS_REF
-
-
- GVL.axes[2].Axis.PlcToNc
- PLCTONC_AXIS_REF
-
diff --git a/solution/tc_project_app/GVLs/GVL_APP.TcGVL b/solution/tc_project_app/GVLs/GVL_APP.TcGVL
index 9e800ab..e125049 100644
--- a/solution/tc_project_app/GVLs/GVL_APP.TcGVL
+++ b/solution/tc_project_app/GVLs/GVL_APP.TcGVL
@@ -7,7 +7,7 @@ VAR_GLOBAL
END_VAR
VAR_GLOBAL CONSTANT
- axisNum : UINT:=2;
+ axisNum : UINT:=0;
//axisCoupleMax : UINT:=4;
END_VAR]]>
diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU
index f81cabd..2621b5e 100644
--- a/solution/tc_project_app/POUs/MAIN.TcPOU
+++ b/solution/tc_project_app/POUs/MAIN.TcPOU
@@ -6,6 +6,7 @@ VAR
sVersion: STRING:='1.0.0';
i : UINT; //index variable for AXES()
aFbAxes: ARRAY [1..gvl_app.axisNum] OF FB_Axis;
+
hmiAxisSelection : INT:=1; //Not possible to use local hmi variables for array indexes
(******Outputs: Power for Limit switches and Home Sensors (every 4th output)********)
@@ -48,6 +49,7 @@ VAR
iRetry : INT;
fbReadEncRefSys : ARRAY [1..gvl_app.axisNum] OF MC_ReadParameter;
fbRestorePosition : ARRAY [1..GVL_app.axisNum] OF MC_SetPosition;
+ fbGetDeviceIdentification : FB_GetDeviceIdentification;
END_VAR
@@ -55,7 +57,22 @@ VAR PERSISTENT
bRestoreOnStartup : BOOL;
END_VAR]]>
-
+
+
+
+
+
+
+
+
+
+ eSUPS_PowerFailure THEN
+ELSIF eGlobalSUpsState <> eSUPS_PowerOK THEN
(* next cycles of powerfailure *)
(* skip regular code execution for the remaining cycles of the powerfailure/writing of persistent data/quick shutdown ... *)
RETURN;
-END_IF
-
-RESTORE_POSITIONS();
-PROG();
-AXES();
-ERROR();]]>
-
-
-
-
+END_IF]]>
@@ -121,6 +127,15 @@ fbEL1808(
]]>
+
+
+ '0') THEN
+ CHECK_UPS();
+ RESTORE_POSITIONS();
+END_IF]]>
+
+
-
+
if busy then continue with PLC cycle and check again next time.
@@ -199,14 +214,14 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN
// .valid=FALSE and .busy=FALSE which indicateds the FB probably hasn't started and thus needs to see a rising edge.
// Set execute to low, Exit MAIN.STARTUP and go back a step in the CASE statement.
bExecuteReadEncRefSys:=FALSE;
- eStartUp:=eStartUp-1;
+ eStartUp:=ReadAxisFeedbackType;
iRetry:=iRetry+1; // counter used for troubleshooting to see how many cycles it takes before fbReadEncRefSys function blocks are read correctly
RETURN;
END_IF
END_IF
END_FOR
// If the code gets here all axes either have .valid=TRUE for all axes
- eStartUp:=eStartUp+1;
+ eStartUp:= ExecuteRestore;
ExecuteRestore:
// Execute position restore by setting fbRestorePosition.execute = TRUE
@@ -217,7 +232,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN
END_IF
END_IF
END_FOR
- eStartUp:=eStartUp+1;
+ eStartUp:= CheckRestore;
CheckRestore:
// Check the set position fbs are finished
@@ -232,7 +247,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN
END_IF
END_IF
END_FOR
- eStartUp:=eStartUp+1;
+ eStartUp:= FinishRestore;
FinishRestore:
// Remove execute = TRUE for fbRestorePosition
@@ -245,7 +260,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN
END_IF]]>
-
+
-
-
-
-
+
@@ -271,6 +283,10 @@ END_FOR]]>
+
+
+
+
@@ -287,6 +303,10 @@ END_FOR]]>
+
+
+
+