Skip to content

Commit

Permalink
Merge pull request #38 from netbymatt/motion-overflow
Browse files Browse the repository at this point in the history
Motion overflow
  • Loading branch information
pswift066 authored Sep 15, 2023
2 parents 7689f28 + dd17618 commit 100307a
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 37 deletions.
38 changes: 36 additions & 2 deletions Base Project/Base Project.tsproj
Original file line number Diff line number Diff line change
Expand Up @@ -3904,7 +3904,7 @@ External Setpoint Generation:
</DataType>
<DataType>
<Name GUID="{FA8688D6-9668-4845-AED5-C25BE790FF69}" Namespace="MC" TcBaseType="true">MC_GearInPosDefaultDynamicsAfterSync</Name>
<Comment TxtId=""><![CDATA[Specifies the default dynamics used for MC_GearInPosCA command after the slave axis has become synchronous for the first time.]]></Comment>
<Comment TxtId=""><![CDATA[Specifies the default dynamics used for MC_GearInPosCA command after the slave axis has become synchronous for the first time. (see GearInPosCAOptions)]]></Comment>
<BitSize>32</BitSize>
<BaseType GUID="{18071995-0000-0000-0000-000000000008}">UDINT</BaseType>
<EnumInfo>
Expand Down Expand Up @@ -4002,6 +4002,13 @@ and will return to Group State Standby when the situation permits.
<BitSize>1</BitSize>
<BitOffs>1</BitOffs>
</SubItem>
<SubItem>
<Name>InPosition</Name>
<Type GUID="{18071995-0000-0000-0000-000000000010}">BIT</Type>
<Comment><![CDATA[Indicates whether the group is in position.]]></Comment>
<BitSize>1</BitSize>
<BitOffs>2</BitOffs>
</SubItem>
</DataType>
<DataType>
<Name GUID="{51F0F443-1D05-4E13-ADFA-62EA48380092}" Namespace="MC">ST_GroupStatus</Name>
Expand Down Expand Up @@ -4311,7 +4318,7 @@ and will return to Group State Standby when the situation permits.
</Hides>
</DataType>
<DataType>
<Name GUID="{A46942AB-8119-469F-8FB9-31307702CB5F}" PersistentType="true">XtsBaseEventClass</Name>
<Name GUID="{1859B616-1305-42C4-9209-A1CDBA9AFBC6}" PersistentType="true">XtsBaseEventClass</Name>
<DisplayName TxtId=""><![CDATA[XtsBaseEventClass]]></DisplayName>
<EventId>
<Name Id="1">UserEvent</Name>
Expand Down Expand Up @@ -4398,6 +4405,31 @@ and will return to Group State Standby when the situation permits.
<DisplayName TxtId=""><![CDATA[{0} ActivateTrack command complete. TrackId: {1}]]></DisplayName>
<Severity>Verbose</Severity>
</EventId>
<EventId>
<Name Id="18">MoverMoveToPositionOverload</Name>
<DisplayName TxtId=""><![CDATA[{0} MoveToPosition command overloaded buffer. Commanded Position = {2}. Source: {1}]]></DisplayName>
<Severity>Info</Severity>
</EventId>
<EventId>
<Name Id="19">MoverMoveToStationOverload</Name>
<DisplayName TxtId=""><![CDATA[{0} MoveToStation command overloaded buffer. Commanded Station = {2}. Source: {1}]]></DisplayName>
<Severity>Info</Severity>
</EventId>
<EventId>
<Name Id="20">MoverSyncToMoverOverload</Name>
<DisplayName TxtId=""><![CDATA[{0} SyncToMover command overloaded buffer. MasterMover = {2}. GapDistance = {3}. Source: {1}]]></DisplayName>
<Severity>Info</Severity>
</EventId>
<EventId>
<Name Id="21">MoverSyncToAxisOverload</Name>
<DisplayName TxtId=""><![CDATA[{0} SyncToAxis command overloaded buffer. Source: {1}]]></DisplayName>
<Severity>Info</Severity>
</EventId>
<EventId>
<Name Id="22">MoverMoveVelocityOverload</Name>
<DisplayName TxtId=""><![CDATA[{0} MoveVelocity command overloaded buffer. Commanded Velocity = {2}. Source: {1}]]></DisplayName>
<Severity>Info</Severity>
</EventId>
<Hides>
<Hide GUID="{05156EAA-0F28-483B-B3ED-0A061BA2DDE9}"/>
<Hide GUID="{18E0FAE1-EDAC-4CEB-9B5F-AEA0EA7CB0BB}"/>
Expand Down Expand Up @@ -4425,6 +4457,8 @@ and will return to Group State Standby when the situation permits.
<Hide GUID="{2B435041-8BE5-4A36-B2B9-02DDB0A46756}"/>
<Hide GUID="{C1F56B6B-2FA5-4868-B3DD-F95A36FCCFBF}"/>
<Hide GUID="{42F400CB-95A8-4C06-BFF7-C26D2D0E2F33}"/>
<Hide GUID="{A46942AB-8119-469F-8FB9-31307702CB5F}"/>
<Hide GUID="{55A1315C-BCCD-427F-89D8-C9CE2941C762}"/>
</Hides>
</DataType>
</DataTypes>
Expand Down
3 changes: 2 additions & 1 deletion Base Project/Main/DUTs/MoverState_enum.TcDUT
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.11">
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
<DUT Name="MoverState_enum" Id="{89a812d1-f23a-47af-b019-1e4ee25dac44}">
<Declaration><![CDATA[{attribute 'strict'}
TYPE MoverState_enum : (
Expand All @@ -10,6 +10,7 @@ TYPE MoverState_enum : (
MV_M1_READSTATUS := 40,
MV_M1_EVALSTATUS := 50,
MV_M1_DETECT := 60,
MV_M1_DELAY := 65,
MV_ENABLING := 70,
MV_ADDTOGROUP := 80,
MV_READGROUPSTATUS := 90,
Expand Down
147 changes: 118 additions & 29 deletions Base Project/Main/POUs/XTS/Mover.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ VAR
internalDisable : BOOL; // moves the axis from Standstill to Disabled, removes Axis from CA Group
internalCurrentMoveType : MoverCommandType_enum; // Most recent move command type
internalReissue : BOOL; // reissue last command flag alows summing of all reissue commands per-scan
internalCurrentDestPosition : LREAL; // Track position of the current motion destination;
internalCurrentDestObjective : STRING; // Instance path of the current destination objective
Expand Down Expand Up @@ -90,6 +91,7 @@ VAR
fbReadM1DetectValid : ADSREAD;
fbReadM1DetectActive : ADSREAD;
fbWriteM1Detect : ADSWRITE;
fbDelayM1Timer : TON;
IdDetectionMode : DINT; // 0: Standard 1: Mover1
IsIdDetectionValid : BOOL; // M1 Detection has completed
IsIdDetectionActive : BOOL; // M1 Detection currently underway
Expand Down Expand Up @@ -360,7 +362,21 @@ CASE internalState OF
fbWriteM1Detect.IDXOFFS := 16#03080250;
fbWriteM1Detect.WRITE := TRUE;
internalState := MV_M1_READSTATUS; // go back to Read M1 Detect status to confirm it has completed
internalState := MV_M1_DELAY; // go back to Read M1 Detect status to confirm it has completed
MV_M1_DELAY: // ------------------------------------------------------ delay to allow M1 Detect Completion
Ready := FALSE;
Busy := TRUE;
Error := FALSE;
ErrorID := 0;
fbDelayM1Timer( IN := TRUE, PT := T#500MS );
IF fbDelayM1Timer.Q THEN
fbDelayM1Timer( IN := FALSE );
internalState := MV_M1_READSTATUS;
END_IF
MV_ENABLING: // ------------------------------------------------------- axis is enabling
Expand Down Expand Up @@ -498,6 +514,26 @@ CASE internalState OF
END_IF;
THIS^.CyclicTrack();
IF (internalReissue) THEN
THIS^.SourceInstancePath := 'ReissueCommand';
CASE internalCurrentMoveType OF
MOVETYPE_NONE:
// No current command to reissue
MOVETYPE_POSITION:
THIS^.MoveToPosition( internalCurrentDestPosition );
MOVETYPE_STATION:
THIS^.MoveToStation( internalCurrentDestStation );
MOVETYPE_VELOCITY:
THIS^.MoveVelocity( MotionParameters.Velocity );
MOVETYPE_SYNC_MOVER:
THIS^.SyncToMover( internalMasterMover, internalGap );
MOVETYPE_SYNC_AXIS:
// This command should perhaps not be compatible with Reissue command
END_CASE
internalReissue := FALSE;
END_IF
// And catch all internal function block errors
IF fbMoveAbsCA[0].Error THEN
Expand Down Expand Up @@ -1053,6 +1089,7 @@ IF NOT( Ready ) THEN // if the mover is not ready & able to accept a moveabs com
ELSE // otherwise let 'er rip
newCallTime := ULINT_TO_LREAL(F_GetSystemTime())/1E7;
internalReissue := FALSE; // reissue no longer necessary
IF fbMoveAbsCA[0].Busy = FALSE THEN
Expand Down Expand Up @@ -1095,6 +1132,10 @@ ELSE // otherwise let 'er rip
fbMoveAbsCA[1]( Axis := AxisReference );
ELSE
MsgCreate.CreateEx( TC_EVENTS.XtsBaseEventClass.MoverMoveToPositionOverload,0 );
MsgCreate.ipArguments.Clear().AddString(THIS^.InstancePath).AddString(THIS^.SourceInstancePath).AddLReal(DestinationPosition);
MsgCreate.Send(0);
END_IF
END_IF
Expand Down Expand Up @@ -1138,6 +1179,7 @@ END_VAR]]></Declaration>
ELSE // otherwise let 'er rip
newCallTime := ULINT_TO_LREAL(F_GetSystemTime())/1E7;
internalReissue := FALSE; // reissue no longer necessary
IF fbMoveAbsCA[0].Busy = FALSE THEN
Expand Down Expand Up @@ -1179,6 +1221,11 @@ ELSE // otherwise let 'er rip
fbMoveAbsCA[1]( Axis := AxisReference );
ELSE
MsgCreate.CreateEx( TC_EVENTS.XtsBaseEventClass.MoverMoveToStationOverload,0 );
MsgCreate.ipArguments.Clear().AddString(THIS^.InstancePath).AddString(THIS^.SourceInstancePath).AddString(DestinationStation.InstancePath);
MsgCreate.Send(0);
END_IF
// Set the current destination object to the instance path of the objective, or 0 if unassigned
Expand Down Expand Up @@ -1228,6 +1275,7 @@ END_VAR]]></Declaration>
ELSE
newCallTime := ULINT_TO_LREAL(F_GetSystemTime())/1E7;
internalReissue := FALSE; // reissue no longer necessary
negativeCommand := SEL( DesiredVelocity < 0, FALSE, TRUE );
MotionParameters.Velocity := ABS( DesiredVelocity );
Expand Down Expand Up @@ -1265,8 +1313,11 @@ ELSE
fbMoveRelCA[1].Execute := TRUE; // execute this block, and...
fbMoveRelCA[0].Execute := FALSE; // if necessary, interrupt this one
fbMoveRelCA[1]( Axis := AxisReference );
fbMoveRelCA[1]( Axis := AxisReference );
ELSE
MsgCreate.CreateEx( TC_EVENTS.XtsBaseEventClass.MoverMoveVelocityOverload,0 );
MsgCreate.ipArguments.Clear().AddString(THIS^.InstancePath).AddString(THIS^.SourceInstancePath).AddLReal(DesiredVelocity);
MsgCreate.Send(0);
END_IF
END_IF
Expand Down Expand Up @@ -1326,22 +1377,8 @@ END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[
THIS^.SourceInstancePath := 'ReissueCommand';
CASE internalCurrentMoveType OF
MOVETYPE_NONE:
// No current command to reissue
MOVETYPE_POSITION:
THIS^.MoveToPosition( internalCurrentDestPosition );
MOVETYPE_STATION:
THIS^.MoveToStation( internalCurrentDestStation );
MOVETYPE_VELOCITY:
THIS^.MoveVelocity( MotionParameters.Velocity );
MOVETYPE_SYNC_MOVER:
THIS^.SyncToMover( internalMasterMover, internalGap );
MOVETYPE_SYNC_AXIS:
// This command should perhaps not be compatible with Reissue command
END_CASE
// set flag for use in .Cyclic()
internalReissue := TRUE;
ReissueCommand := THIS^;]]></ST>
Expand Down Expand Up @@ -1538,6 +1575,7 @@ IF NOT( Ready ) THEN
ELSE
newCallTime := ULINT_TO_LREAL(F_GetSystemTime())/1E7;
internalReissue := FALSE; // reissue no longer necessary
internalMasterAxis REF= MasterAxis;
Expand Down Expand Up @@ -1601,7 +1639,11 @@ ELSE
fbGearInPosAxisCA[1].BufferMode := Tc3_Mc3Definitions.MC_BUFFER_MODE.mcAborting;
fbGearInPosAxisCA[1]( Master := MasterAxis, Slave := THIS^.AxisReference );
ELSE
MsgCreate.CreateEx( TC_EVENTS.XtsBaseEventClass.MoverSyncToAxisOverload, 0 );
MsgCreate.ipArguments.Clear().AddString(THIS^.InstancePath).AddString(THIS^.SourceInstancePath);
MsgCreate.Send(0);
END_IF
END_IF
Expand Down Expand Up @@ -1650,6 +1692,7 @@ END_VAR]]></Declaration>
ELSE // let 'er rip
newCallTime := ULINT_TO_LREAL(F_GetSystemTime())/1E7;
internalReissue := FALSE; // reissue no longer necessary
internalMasterMover REF= MasterMover;
internalGap := Gap;
Expand Down Expand Up @@ -1708,6 +1751,11 @@ ELSE // let 'er rip
fbGearInPosMoverCA[1]( Master := internalMasterMover.AxisReference, Slave := THIS^.AxisReference );
ELSE
MsgCreate.CreateEx( TC_EVENTS.XtsBaseEventClass.MoverSyncToMoverOverload,0 );
MsgCreate.ipArguments.Clear().AddString(THIS^.InstancePath).AddString(THIS^.SourceInstancePath).AddString(MasterMover.InstancePath).AddLReal(Gap);
MsgCreate.Send(0);
END_IF
END_IF;
Expand Down Expand Up @@ -1772,8 +1820,15 @@ SyncToMover := THIS^;
<LineId Id="2" Count="0" />
</LineIds>
<LineIds Name="Mover.Cyclic">
<LineId Id="3" Count="276" />
<LineId Id="3" Count="140" />
<LineId Id="507" Count="13" />
<LineId Id="144" Count="135" />
<LineId Id="465" Count="1" />
<LineId Id="483" Count="1" />
<LineId Id="487" Count="14" />
<LineId Id="485" Count="0" />
<LineId Id="502" Count="0" />
<LineId Id="486" Count="0" />
<LineId Id="280" Count="45" />
<LineId Id="468" Count="2" />
<LineId Id="467" Count="0" />
Expand Down Expand Up @@ -1885,20 +1940,39 @@ SyncToMover := THIS^;
<LineId Id="2" Count="0" />
</LineIds>
<LineIds Name="Mover.MoveToPosition">
<LineId Id="3" Count="16" />
<LineId Id="3" Count="8" />
<LineId Id="92" Count="0" />
<LineId Id="12" Count="7" />
<LineId Id="78" Count="1" />
<LineId Id="20" Count="17" />
<LineId Id="81" Count="1" />
<LineId Id="80" Count="0" />
<LineId Id="38" Count="30" />
<LineId Id="38" Count="10" />
<LineId Id="93" Count="0" />
<LineId Id="95" Count="1" />
<LineId Id="94" Count="0" />
<LineId Id="49" Count="19" />
<LineId Id="2" Count="0" />
</LineIds>
<LineIds Name="Mover.MoveToStation">
<LineId Id="97" Count="73" />
<LineId Id="97" Count="7" />
<LineId Id="180" Count="0" />
<LineId Id="105" Count="39" />
<LineId Id="182" Count="0" />
<LineId Id="181" Count="0" />
<LineId Id="184" Count="1" />
<LineId Id="183" Count="0" />
<LineId Id="145" Count="25" />
<LineId Id="2" Count="0" />
</LineIds>
<LineIds Name="Mover.MoveVelocity">
<LineId Id="3" Count="72" />
<LineId Id="3" Count="7" />
<LineId Id="86" Count="0" />
<LineId Id="11" Count="37" />
<LineId Id="87" Count="0" />
<LineId Id="89" Count="1" />
<LineId Id="88" Count="0" />
<LineId Id="50" Count="25" />
<LineId Id="2" Count="0" />
</LineIds>
<LineIds Name="Mover.Payload.Get">
Expand All @@ -1910,7 +1984,9 @@ SyncToMover := THIS^;
<LineId Id="2" Count="0" />
</LineIds>
<LineIds Name="Mover.ReissueCommand">
<LineId Id="3" Count="18" />
<LineId Id="25" Count="0" />
<LineId Id="3" Count="0" />
<LineId Id="19" Count="2" />
<LineId Id="2" Count="0" />
</LineIds>
<LineIds Name="Mover.SetAcceleration">
Expand All @@ -1934,19 +2010,32 @@ SyncToMover := THIS^;
<LineId Id="2" Count="0" />
</LineIds>
<LineIds Name="Mover.SyncToAxis">
<LineId Id="3" Count="23" />
<LineId Id="3" Count="9" />
<LineId Id="130" Count="0" />
<LineId Id="13" Count="13" />
<LineId Id="107" Count="0" />
<LineId Id="109" Count="1" />
<LineId Id="108" Count="0" />
<LineId Id="27" Count="26" />
<LineId Id="111" Count="0" />
<LineId Id="113" Count="0" />
<LineId Id="112" Count="0" />
<LineId Id="54" Count="36" />
<LineId Id="54" Count="14" />
<LineId Id="131" Count="0" />
<LineId Id="69" Count="0" />
<LineId Id="133" Count="1" />
<LineId Id="132" Count="0" />
<LineId Id="70" Count="20" />
<LineId Id="2" Count="0" />
</LineIds>
<LineIds Name="Mover.SyncToMover">
<LineId Id="3" Count="88" />
<LineId Id="3" Count="7" />
<LineId Id="105" Count="0" />
<LineId Id="11" Count="56" />
<LineId Id="106" Count="1" />
<LineId Id="109" Count="1" />
<LineId Id="108" Count="0" />
<LineId Id="68" Count="23" />
<LineId Id="2" Count="0" />
</LineIds>
</POU>
Expand Down
Loading

0 comments on commit 100307a

Please sign in to comment.