-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX: issues relating to "queued" moves in state mover with bMoveOk #205
Changes from all commits
0e50f24
b101160
051c034
2bd8a35
d39582d
1170c26
cc683b2
02f3c64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<TcPlcObject Version="1.1.0.1"> | ||
<DUT Name="E_LCLSMotionError" Id="{ddea4357-8fae-44da-b5b7-bd2ca001f059}"> | ||
<Declaration><![CDATA[{attribute 'qualified_only'} | ||
{attribute 'strict'} | ||
TYPE E_LCLSMotionError : | ||
( | ||
ABORTED := 16#7900, | ||
UNSAFE := 16#7901, | ||
INVALID := 16#7902, | ||
TEST := 16#FFFF | ||
) UDINT; | ||
END_TYPE | ||
]]></Declaration> | ||
</DUT> | ||
</TcPlcObject> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,17 +91,25 @@ VAR_OUTPUT | |
END_VAR | ||
VAR | ||
fbMotionRequest: FB_MotionRequest; | ||
rtExec: R_TRIG; | ||
rtReset: R_TRIG; | ||
bInnerExec: BOOL; | ||
bAllowMove: BOOL; | ||
nLatchAllowErrorID: UDINT; | ||
END_VAR | ||
]]></Declaration> | ||
<Implementation> | ||
<ST><![CDATA[// Veto the move for uninitialized and unsafe states | ||
bAllowMove := stPositionState.bMoveOk AND stPositionState.bValid AND stPositionState.bUpdated; | ||
|
||
rtExec(CLK:=bExecute); | ||
bInnerExec S= rtExec.Q AND bAllowMove AND NOT bError; | ||
bInnerExec R= NOT bExecute; | ||
|
||
// Do the move | ||
fbMotionRequest( | ||
stMotionStage := stMotionStage, | ||
bExecute := bExecute AND bAllowMove, | ||
bExecute := bInnerExec, | ||
bReset := bReset, | ||
enumMotionRequest := enumMotionRequest, | ||
fPos := stPositionState.fPosition, | ||
|
@@ -114,15 +122,24 @@ fbMotionRequest( | |
bBusy => bBusy, | ||
bDone => bDone); | ||
|
||
rtReset(CLK:=bReset); | ||
IF rtReset.Q THEN | ||
nLatchAllowErrorID := 0; | ||
END_IF | ||
|
||
// Inject custom error if we can't move because of bMoveOk or bValid | ||
IF bExecute AND NOT bAllowMove THEN | ||
IF nLatchAllowErrorID <> 0 OR (bExecute AND NOT bAllowMove) THEN | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the scenario of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's exactly correct. I need to reapply my own FB's error status, including |
||
bError := TRUE; | ||
IF stPositionState.bValid THEN | ||
nErrorId := 16#7901; | ||
IF nLatchAllowErrorID <> 0 THEN | ||
nErrorID := nLatchAllowErrorID; | ||
ELSIF stPositionState.bValid THEN | ||
nErrorID := E_LCLSMotionError.UNSAFE; | ||
ELSE | ||
nErrorId := 16#7902; | ||
nErrorID := E_LCLSMotionError.INVALID; | ||
END_IF | ||
sErrorMessage := F_MotionErrorCodeLookup(nErrorId := nErrorID); | ||
// Keep error latched until it is cleared, otherwise it can be lost early | ||
nLatchAllowErrorID := nErrorID; | ||
sErrorMessage := CONCAT(CONCAT(F_MotionErrorCodeLookup(nErrorId := nErrorID), ' for '), stPositionState.sName); | ||
END_IF | ||
|
||
// This can be useful if we're running this FB standalone for some reason | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ VAR_INPUT | |
bMoveBusy: BOOL; | ||
// The starting state number to seed nCurrGoal with | ||
nStartingState: UINT; | ||
// TRUE if we have a move error, to prevent moves | ||
bMoveError: BOOL; | ||
END_VAR | ||
VAR_OUTPUT | ||
// The goal index to input to the motion FB. This will be clamped to the range 0..GeneralConstants.MAX_STATES | ||
|
@@ -84,6 +86,10 @@ CASE nState OF | |
END_IF | ||
END_CASE | ||
|
||
IF bMoveError THEN | ||
bExecMove := FALSE; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I think this is the line that explains my above question... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is indeed why it works out, but I think your previous point still stands |
||
END_IF | ||
|
||
// Help us detect if there is an EPICS put before the next cycle | ||
stUserInput.nSetValue := 0; | ||
stUserInput.bReset := FALSE; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd naively have expected if there were a latched error we wouldn't execute
fbMotionRequest
at all. I'd imagine there are some details I'm missing there - mind giving a quick explanation?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, despite your other comment, you're correct. It may be worth doing something additional here, making the inner function blocks also protect themselves for the sake of robustness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handled in cc683b2