Skip to content

Commit

Permalink
add further states to actuatoir state
Browse files Browse the repository at this point in the history
  • Loading branch information
sjuergen committed Dec 18, 2024
1 parent 090397d commit f2cf6dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Actuator/ActuatorStates.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAMESPACE Simatic.Ax.axftcmlib
TYPE
ActuatorState : (InHomePosition, MoveToWorkPosition, InWorkPosition, MoveToHomePosition) := InHomePosition;
ActuatorState : (InHomePosition, MoveToWorkPosition, InWorkPosition, MoveToHomePosition, Error, Undefined) := Undefined;
END_TYPE
END_NAMESPACE
11 changes: 7 additions & 4 deletions src/Actuator/TimeBasedActuator.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ NAMESPACE Simatic.Ax.axftcmlib
OnDuration : TIME;
END_VAR
VAR
_tonOnDuration : OnDelay;
_tonOffDuration : OffDelay;
_state : ActuatorState;
END_VAR

Expand All @@ -24,19 +24,22 @@ NAMESPACE Simatic.Ax.axftcmlib
THIS.SetError(WORD#16#8101);
RETURN;
END_IF;
_tonOnDuration(signal := Q_ToWorkPosition.IsOn(), Duration := OnDuration);
CASE _state OF
// If undefined, go initial state:
ActuatorState#Undefined:
_state := ActuatorState#InHomePosition;
// Switch all outputs off, when actuator is idle in home position
ActuatorState#InHomePosition:
Q_ToWorkPosition.SetOff();

// Received the command GoToWorkPosition switch on ToWorkPosition
ActuatorState#MoveToWorkPosition:
Q_ToWorkPosition.SetOn();
_state := ActuatorState#InWorkPosition;
// After Timeout switch off "ToWorkPosition"
ActuatorState#InWorkPosition:
IF (_tonOnDuration.output) THEN
_tonOffDuration(signal := TRUE, Duration := OnDuration);
IF (_tonOffDuration.output) THEN
_tonOffDuration(signal := FALSE);
_state := ActuatorState#MoveToHomePosition;
Q_ToWorkPosition.SetOff();
END_IF;
Expand Down

0 comments on commit f2cf6dc

Please sign in to comment.