Skip to content
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: VRC_NO soft IO mapping fix and state fix #69

Merged
merged 1 commit into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions L2SIVacuum/DUTs/Valves/ST_VRC_NO.TcDUT
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ STRUCT
io: io ;
'}
pv_xCLS_SW : BOOL;

{attribute 'pytmc' := '
pv: CLS_DO ;
field: ONAM CLOSE;
field: ZNAM OPEN;
io: io ;
'}
q_xCLS_DO : BOOL;
{attribute 'pytmc' := '
pv: FORCE_CLS;
field: ONAM CLOSE;
Expand Down
10 changes: 5 additions & 5 deletions L2SIVacuum/L2SIVacuum.tmc

Large diffs are not rendered by default.

Binary file modified L2SIVacuum/LineIDs.dbg
Binary file not shown.
10 changes: 5 additions & 5 deletions L2SIVacuum/POUs/Functions/Valves/FB_VRC_NO.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ END_IF
///Check valve position
IF iq_stValve.i_xClsLS AND iq_stValve.i_xOpnLS THEN
iq_stValve.eState:=INVALID;
ELSIF NOT iq_stValve.i_xClsLS AND iq_stValve.i_xOpnLS AND iq_stValve.q_xOPN_DO THEN
ELSIF NOT iq_stValve.i_xClsLS AND iq_stValve.i_xOpnLS AND NOT iq_stValve.q_xCLS_DO THEN
iq_stValve.eState:=OPEN;
ELSIF iq_stValve.i_xClsLS AND NOT iq_stValve.i_xOpnLS AND NOT iq_stValve.q_xOPN_DO THEN
ELSIF iq_stValve.i_xClsLS AND NOT iq_stValve.i_xOpnLS AND iq_stValve.q_xCLS_DO THEN
iq_stValve.eState:=CLOSED;
ELSIF NOT iq_stValve.i_xClsLS AND NOT iq_stValve.i_xOpnLS THEN
iq_stValve.eState:=MOVING;
Expand Down Expand Up @@ -111,8 +111,8 @@ IF (iq_stValve.eState=INVALID) THEN
END_IF

(*Timers*)
tOPNtimeout(IN:= iq_stValve.q_xOPN_DO, PT := tTimeOutDuration );
tCLStimeout(IN:= NOT iq_stValve.q_xOPN_DO, PT := tTimeOutDuration);
tOPNtimeout(IN:= NOT iq_stValve.q_xCLS_DO, PT := tTimeOutDuration );
tCLStimeout(IN:= iq_stValve.q_xCLS_DO, PT := tTimeOutDuration);


(*Soft IO Mapping*)
Expand All @@ -129,7 +129,7 @@ iq_stValve.i_xClsLS:= i_xClsLS;
//iq_stValve. := i_xEXT_OK;
iq_stValve.xOverrideMode := i_xOverrideMode;
(*outputs*)
//q_xOPN_DO:= iq_stValve.q_xOPN_DO;
iq_stValve.q_xCLS_DO := q_xCLS_DO;
]]></ST>
</Implementation>
</Action>
Expand Down
106 changes: 96 additions & 10 deletions L2SIVacuum/POUs/Functions/Valves/FB_VRC_NO_FFO.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ END_VAR
VAR_INPUT
i_xPMPS_OK: BOOL ; (*Set to True To switch off the bptm and PMPS Arbiter*)
i_xIsAperture:BOOL :=FALSE; // Set tp True if this is an Aperture Valve, the MPS Fault will trip only when moving.
i_sDevName : T_MaxString := 'VGC'; // Device name for diagnostic
i_sDevName : T_MaxString := 'VGC_NO'; // Device name for diagnostic
i_nTransitionRootID: UDINT; //A unique transition Root ID that is equal to or greater than 1000i_xIsAperture:BOOL :=FALSE; // Set tp True if this is an Aperture Valve, the MPS Fault will trip only when moving.
END_VAR
VAR_OUTPUT
Expand All @@ -31,17 +31,102 @@ VAR

END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[(*PMPS*)
<ST><![CDATA[(*VRC_NO*)

(* This function block is different from the regular VRC in that CLOSING must be permitted. *)

(* On first PLC pass, put valve into vented state, which implies a closed valve *)
fbFSInit( CLK := TRUE, Q => xFirstPass);
IF xFirstPass THEN
iq_stValve.pv_xCLS_SW := FALSE;
END_IF




///Check valve position
IF iq_stValve.i_xClsLS AND iq_stValve.i_xOpnLS THEN
iq_stValve.eState:=INVALID;
ELSIF NOT iq_stValve.i_xClsLS AND iq_stValve.i_xOpnLS AND NOT iq_stValve.q_xCLS_DO THEN
iq_stValve.eState:=OPEN;
ELSIF iq_stValve.i_xClsLS AND NOT iq_stValve.i_xOpnLS AND iq_stValve.q_xCLS_DO THEN
iq_stValve.eState:=CLOSED;
ELSIF NOT iq_stValve.i_xClsLS AND NOT iq_stValve.i_xOpnLS THEN
iq_stValve.eState:=MOVING;
ELSE
iq_stValve.eState:=INVALID;
END_IF


(*evaluate Valve CLose external interlock*)
iq_stValve.xCLS_OK := i_xExtILK_OK;
IF NOT iq_stValve.xCLS_OK and NOT tonOvrd.Q THEN
iq_stValve.pv_xCLS_SW := FALSE;
END_IF


(* Override logic *)
(* Goal: give ability to override, but do so in a way that people won't forget it.
Solution: Override only after ten seconds of override, protect against blips,
when the valve permission goes true for more than ten seconds consistently, remove override
*)

tonDelOK(IN:=iq_stValve.xCLS_OK, PT:=T#10S);
rtOK(CLK:=tonDelOK.Q);
IF rtOK.Q AND iq_stValve.pv_xOvrdCls THEN
iq_stValve.pv_xOvrdCls :=FALSE;
if (iq_stValve.eState=CLOSED) AND (i_xOverrideMode) THEN iq_stValve.pv_xCLS_SW := TRUE; END_IF
//Log
fbLogger(sMsg:='Override expired', eSevr:=TcEventSeverity.Warning);
END_IF

//Override timer
tonOvrd(IN:=iq_stValve.pv_xOvrdCls, PT:=tOvrd);

(* Here's where the valve Actuates *)
q_xCLS_DO := ((iq_stValve.xCLS_OK AND iq_stValve.pv_xCLS_SW)OR (tonOvrd.Q AND i_xOverrideMode));
iq_stValve.q_xOPN_DO := NOT q_xCLS_DO;



///Check valve moving position timout
IF NOT iq_stValve.i_xClsLS AND tCLStimeout.Q THEN
iq_stValve.bErrorPresent := TRUE;
//iq_stValve.sErrorMessage := ' Close Timeout';
ELSIF NOT iq_stValve.i_xOpnLS AND tOPNtimeout.Q THEN
iq_stValve.bErrorPresent := TRUE;
//iq_stValve.sErrorMessage := ' Open Timeout';
END_IF
IF (iq_stValve.eState=INVALID) THEN
iq_stValve.bErrorPresent := TRUE;
//iq_stValve.sErrorMessage := CONCAT(sPath,' Invalid Valve Position');
END_IF

(*Timers*)
tOPNtimeout(IN:= NOT iq_stValve.q_xCLS_DO, PT := tTimeOutDuration );
tCLStimeout(IN:= iq_stValve.q_xCLS_DO, PT := tTimeOutDuration);


(*Soft IO Mapping*)
ACT_IO();

// Log States and triggers
ACT_Logger();




(*PMPS*)
IF NOT(i_xPMPS_OK) THEN
ACT_PMPS();
END_IF
(*when interlock is lost the Valve closes regardless of the status of the PMPS and EPS*)
xPMPS_OK := i_xPMPS_OK OR (bptm.q_xTransitionAuthorized OR tBPTMtimeout.Q);
IF NOT (iq_stValve.xOPN_OK) THEN
iq_stValve.pv_xOPN_SW:= FALSE; // Reset switch after inlk is lost
iq_stValve.q_xOPN_DO := (iq_stValve.pv_xOPN_SW AND iq_stValve.xOPN_OK) OR (tonOvrd.Q AND i_xOverrideMode);
IF NOT (iq_stValve.xCLS_OK) THEN
iq_stValve.pv_xCLS_SW:= FALSE; // Reset switch after inlk is lost
iq_stValve.q_xCLS_DO := (iq_stValve.pv_xCLS_SW AND iq_stValve.xCLS_OK) OR (tonOvrd.Q AND i_xOverrideMode);
ELSIF xPMPS_OK THEN
iq_stValve.q_xOPN_DO := (iq_stValve.pv_xOPN_SW AND iq_stValve.xOPN_OK) OR (tonOvrd.Q AND i_xOverrideMode);
iq_stValve.q_xCLS_DO := (iq_stValve.pv_xCLS_SW AND iq_stValve.xCLS_OK) OR (tonOvrd.Q AND i_xOverrideMode);
//ELSIF NOT (i_xPMPS_OK) THEN
// Only override mode
//iq_stValve.q_xOPN_DO := (tonOvrd.Q AND i_xOverrideMode);
Expand Down Expand Up @@ -72,21 +157,22 @@ iq_stValve.i_xClsLS:= i_xClsLS;
iq_stValve.xOverrideMode := i_xOverrideMode;
(*outputs*)
//q_xOPN_DO:= iq_stValve.q_xOPN_DO;
iq_stValve.q_xCLS_DO:= q_xCLS_DO;
]]></ST>
</Implementation>
</Action>
<Action Name="ACT_PMPS" Id="{2d4909a8-c4a0-4b25-b483-8d410c71684c}">
<Implementation>
<ST><![CDATA[bMoving := (iq_stValve.pv_xOPN_SW AND iq_stValve.i_xClsLS) XOR (NOT iq_stValve.pv_xOPN_SW AND i_xOpnLS);
bDone := (iq_stValve.pv_xOPN_SW AND iq_stValve.i_xOpnLS) XOR (NOT iq_stValve.pv_xOPN_SW AND i_xClsLS);
If (i_xIsAperture ) OR (iq_stValve.pv_xOPN_SW )THEN
<ST><![CDATA[bMoving := (iq_stValve.pv_xCLS_SW AND NOT iq_stValve.i_xClsLS) XOR (NOT iq_stValve.pv_xCLS_SW AND NOT i_xOpnLS);
bDone := (NOT iq_stValve.pv_xCLS_SW AND iq_stValve.i_xOpnLS) XOR ( iq_stValve.pv_xCLS_SW AND i_xClsLS);
If (i_xIsAperture ) OR NOT (iq_stValve.pv_xCLS_SW )THEN
bptm.i_stRequestedAssertion := PMPS_GVL.cstFullBeam;
ELSE bptm.i_stRequestedAssertion := PMPS_GVL.cst0RateBeam;
END_IF
bptm(fbArbiter:=fbArbiter,
i_TransitionAssertionID:=i_nTransitionRootID+2,
i_stTransitionAssertion:=PMPS_GVL.cst0RateBeam,
i_nRequestedAssertionID:=i_nTransitionRootID+ BOOL_TO_UDINT( iq_stValve.pv_xOPN_SW),
i_nRequestedAssertionID:=i_nTransitionRootID+ BOOL_TO_UDINT( iq_stValve.pv_xCLS_SW),
i_stRequestedAssertion:=,
i_xMoving:=bMoving,
i_xDoneMoving:= bDone,
Expand Down