forked from pcdshub/lcls-twincat-motion
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request pcdshub#217 from NSLentz/Bug-ECS-4719
Fixing Bug ECS 4719 Pertaining to PMPS Position State Limits Being Invalidated when State Switches to Unknown
- Loading branch information
Showing
9 changed files
with
264 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[submodule "lcls-twincat-motion/Library/tc_mca_std_lib"] | ||
path = lcls-twincat-motion/Library/tc_mca_std_lib | ||
url = ../tc_mca_std_lib.git | ||
url = [email protected]:pcdshub/tc_mca_std_lib.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
lcls-twincat-motion/Library/Tests/Helpers/FB_MotionStageSetAndMoveHelper.TcPOU
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<TcPlcObject Version="1.1.0.1"> | ||
<POU Name="FB_MotionStageSetAndMoveHelper" Id="{d7e042f5-46bb-44d9-bf49-77a017ae9e25}" SpecialFunc="None"> | ||
<Declaration><![CDATA[FUNCTION_BLOCK FB_MotionStageSetAndMoveHelper | ||
VAR_INPUT | ||
// Begin on rising edge, stop on falling edge. | ||
bExecute: BOOL; | ||
// The position to set the motor to | ||
fStartPosition: LREAL; | ||
// The goal to move the motor towards | ||
fGoalPosition: LREAL; | ||
// The velocity to move at | ||
fVelocity: LREAL; | ||
// The allowable deviation from the goal position to be considered done moving. | ||
fDelta: LREAL; | ||
END_VAR | ||
VAR_IN_OUT | ||
stMotionStage: ST_MotionStage; | ||
END_VAR | ||
VAR_OUTPUT | ||
// Goes to TRUE once the motor has no errors and is deactivated. | ||
bResetDone: BOOL; | ||
// Goes to TRUE once the set position completes. | ||
bSetDone: BOOL; | ||
// Goes to TRUE once the motor begins moving. | ||
bMotionStarted: BOOL; | ||
// Goes to TRUE once the motor reaches its destination. | ||
bMoveDone: BOOL; | ||
END_VAR | ||
VAR | ||
rtExec: R_TRIG; | ||
mcSetPos: MC_SetPosition; | ||
END_VAR | ||
]]></Declaration> | ||
<Implementation> | ||
<ST><![CDATA[rtExec(CLK:=bExecute); | ||
IF rtExec.Q THEN | ||
stMotionStage.bReset := TRUE; | ||
stMotionStage.bEnable := FALSE; | ||
stMotionStage.nEnableMode := E_StageEnableMode.NEVER; | ||
mcSetPos( | ||
Axis:=stMotionStage.Axis, | ||
Execute:=FALSE | ||
); | ||
bResetDone := FALSE; | ||
bSetDone := FALSE; | ||
bMotionStarted := FALSE; | ||
bMoveDone := FALSE; | ||
END_IF | ||
bResetDone := NOT stMotionStage.bError AND NOT stMotionStage.bBusy; | ||
bMoveDone := stMotionStage.stAxisStatus.fActPosition <= fGoalPosition + fDelta AND | ||
stMotionStage.stAxisStatus.fActPosition >= fGoalPosition - fDelta; | ||
IF NOT bSetDone THEN | ||
stMotionStage.bReset := TRUE; | ||
stMotionStage.bEnable := FALSE; | ||
IF stMotionStage.stAxisStatus.fActPosition <> fStartPosition THEN | ||
mcSetPos( | ||
Axis:=stMotionStage.Axis, | ||
Execute:=NOT mcSetPos.Execute, | ||
Position:=fStartPosition, | ||
Mode:=FALSE, | ||
Done=> | ||
); | ||
ELSE | ||
bSetDone := TRUE; | ||
END_IF | ||
ELSE | ||
stMotionStage.bEnable := TRUE; | ||
IF NOT bMotionStarted AND NOT stMotionStage.Axis.Status.Disabled THEN | ||
stMotionStage.fPosition := fGoalPosition; | ||
stMotionStage.fVelocity := fVelocity; | ||
stMotionStage.bMoveCmd := TRUE; | ||
bMotionStarted := TRUE; | ||
END_IF | ||
END_IF | ||
IF bMoveDone THEN | ||
stMotionStage.bReset := TRUE; | ||
END_IF | ||
]]></ST> | ||
</Implementation> | ||
</POU> | ||
</TcPlcObject> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.