Skip to content

Commit

Permalink
Merge pull request #56 from ghalym/master
Browse files Browse the repository at this point in the history
WIP: PMPS logic for VGC
  • Loading branch information
slacAdpai authored Jul 14, 2020
2 parents 805a060 + 8c09fc7 commit cf61c6e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 22 deletions.
13 changes: 11 additions & 2 deletions L2SIVacuum/POUs/Functions/Pumps/FB_PIP_Gamma.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<POU Name="FB_PIP_Gamma" Id="{c735b214-fb8d-491c-9d35-e2f8609cfbf0}" SpecialFunc="None">
<Declaration><![CDATA[(* This function block does basic controls FOR the ION pump connected to a Gamma QPCe controller.
Provides interlocking interface. Enable HV only when interlock gauge press is less than 1.0E-4 Torr *)
{attribute 'reflection'}
FUNCTION_BLOCK FB_PIP_Gamma Extends FB_Pump
VAR_INPUT
i_stGauge : ST_VG; //Ion or Pirani gauge for pump interlock
Expand Down Expand Up @@ -40,6 +41,10 @@ MinPressure : REAL:= 1E-11; // Minimum readback pressure, pump must register pre
tonDelOK : TON;
rtOK : R_TRIG;
tOvrd : TIME := T#10s;
{attribute 'instance-path'}
{attribute 'noinit'}
sPath: STRING;
END_VAR
]]></Declaration>
<Implementation>
Expand All @@ -59,7 +64,7 @@ IF i_stGauge.rPRESS <= stPump.rHVEna_SP AND i_stGauge.xPRESS_OK THEN
ELSE stPump.q_xHVEna_DO := stPump.xHVEna_SW;
END_IF
stPump.xILKOk:= TRUE;
ELSIF stPump.q_xHVEna_DO AND timer.Q THEN
ELSIF stPump.q_xHVEna_DO (*AND timer.Q*) THEN
IF q_IG.rPRESS > (stPump.rHVEna_SP + stPump.rHYS_PR) THEN // Ion pumps when running switches off based on their own pressure readings
stPump.q_xHVEna_DO := FALSE;
stPump.xHVEna_SW := FALSE;
Expand Down Expand Up @@ -216,7 +221,9 @@ stPump.xError := (stPump.eState = pumpFAULT);
stPump.i_iPRESS:= i_iPRESS;
stPump.i_xHV_DI:= i_xSP_DI;
(*output*)
q_xHVEna_DO:= stPump.q_xHVEna_DO; //According to Manual pin should be grounded to activate function]]></ST>
q_xHVEna_DO:= stPump.q_xHVEna_DO; //According to Manual pin should be grounded to activate function
This^.stPump.sPath:= sPath;]]></ST>
</Implementation>
</Action>
<Method Name="M_AutoOn" Id="{28cd0a93-5190-4d36-9dd8-bf794bc89b09}">
Expand Down Expand Up @@ -272,6 +279,8 @@ this^.stPump.xHVEna_SW := run;]]></ST>
<LineId Id="9" Count="0" />
<LineId Id="3" Count="3" />
<LineId Id="1" Count="0" />
<LineId Id="11" Count="0" />
<LineId Id="10" Count="0" />
</LineIds>
<LineIds Name="FB_PIP_Gamma.M_AutoOn">
<LineId Id="2" Count="0" />
Expand Down
47 changes: 30 additions & 17 deletions L2SIVacuum/POUs/Functions/Valves/FB_VGC.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ VAR
tonDelOK : TON;
rtOK : R_TRIG;
tonOvrd : TON;
rtOpen : R_TRIG;
ftClose: F_TRIG;
tDelOK : TIME := T#60S;
tOvrd : TIME := T#10s;
Expand Down Expand Up @@ -248,7 +250,7 @@ CASE iq_stValve.eVGC_State OF
END_IF
ERR_ExtFault:
IF NOT (iq_stValve.xERR_ExtFault) AND (NOT i_xExt_OK) THEN
IF NOT (iq_stValve.xERR_ExtFault) AND (i_xExt_OK) THEN
IF iq_stValve.xAT_VAC AND (NOT (iq_stValve.xERR_DifPres)) AND (NOT (iq_stValve.xERR_SP)) AND (NOT (iq_stValve.xERR_ExtFault))THEN
iq_stValve.eVGC_State := AtVacuum;
ELSE
Expand Down Expand Up @@ -292,28 +294,32 @@ IF NOT (i_xOverrideMode) THEN iq_stValve.pv_xOvrdOpn :=FALSE; END_IF
//Override timer
tonOvrd(IN:=iq_stValve.pv_xOvrdOpn, PT:=tOvrd);
(* If Epics Command to close the Valve while it was open, check if PMPS and EPS are ok, otherwise Keep command set to open valve *)
IF NOT(iq_stValve.pv_xOPN_SW) AND (iq_stValve.eState =OPEN) AND (NOT (i_xPMPS_OK) OR (i_xEPS_OK)) THEN
//iq_stValve.pv_xOPN_SW := TRUE; // plc to only reset never to set this signal
END_IF
(* Reset the EPICS command to open the valve if the interlock is lost *)
(* based on EPS ok state, EPS overrides OPN_OK*)
IF NOT iq_stValve.xOPN_OK THEN
IF i_xEPS_OK THEN iq_stValve.pv_xOPN_SW := FALSE; iq_stValve.sErrorMessage := 'ILK Active';
ELSE //iq_stValve.pv_xOPN_SW := TRUE; // plc to only reset never to set this signal
END_IF
(* Valve operation *)
(* Here's where we evaluate sw actions and operate the valve *)
(* Valve operation *)
ftClose(CLK:= iq_stValve.pv_xOPN_SW);
rtOpen(CLK:= iq_stValve.pv_xOPN_SW);
(*when interlock is lost the Valve closes regarldess of the status of the PMPS and EPS*)
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);
ELSIF i_xPMPS_OK THEN
iq_stValve.q_xOPN_DO := (iq_stValve.pv_xOPN_SW AND iq_stValve.xOPN_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);
END_IF
(* Here's where the valve opens *)
iq_stValve.q_xOPN_DO := (iq_stValve.pv_xOPN_SW AND iq_stValve.xOPN_OK) OR (tonOvrd.Q AND i_xOverrideMode);
(*MPS Fault setting*)
If (i_xIsAperture ) THEN
(* When the valve is open or in Closed position MPS is OK, Fault while moving*)
xMPS_OK := i_xOpnLS XOR i_xClsLS; //(iq_stValve.eState=OPEN) OR (iq_stValve.eState=OPEN_F) OR (iq_stValve.eState=CLOSED);//iq_stValve.i_xOpnLS;
xMPS_OK := i_xOpnLS XOR i_xClsLS;
ELSE
(* When the valve is open MPS is OK*)
xMPS_OK := i_xOpnLS; //(iq_stValve.eState=OPEN) OR (iq_stValve.eState=OPEN_F);//iq_stValve.i_xOpnLS;
xMPS_OK := i_xOpnLS AND NOT i_xClsLS AND q_xOPN_DO;
END_IF
Expand Down Expand Up @@ -448,6 +454,7 @@ IF tOverrideActivated.Q THEN fbLogger(sMsg:='Valve override mode activated', eSe
<ST><![CDATA[iq_stValve.xERR_DifPres R= iq_stValve.pv_xAlmRst;
iq_stValve.xERR_SP R= iq_stValve.pv_xAlmRst;
iq_stValve.bErrorPresent R= iq_stValve.pv_xAlmRst;
iq_stValve.xERR_ExtFault R= iq_stValve.pv_xAlmRst;
IF ( iq_stValve.pv_xAlmRst) THEN
iq_stValve.sErrorMessage :='';
Expand Down Expand Up @@ -503,7 +510,11 @@ END_VAR
<LineId Id="201" Count="0" />
<LineId Id="369" Count="0" />
<LineId Id="371" Count="0" />
<LineId Id="203" Count="16" />
<LineId Id="203" Count="1" />
<LineId Id="908" Count="1" />
<LineId Id="1011" Count="0" />
<LineId Id="1013" Count="13" />
<LineId Id="1028" Count="1" />
<LineId Id="472" Count="0" />
<LineId Id="220" Count="0" />
<LineId Id="473" Count="1" />
Expand Down Expand Up @@ -538,7 +549,9 @@ END_VAR
<LineId Id="1" Count="0" />
</LineIds>
<LineIds Name="FB_VGC.ACT_ResetAlarms">
<LineId Id="2" Count="5" />
<LineId Id="2" Count="2" />
<LineId Id="8" Count="0" />
<LineId Id="5" Count="2" />
<LineId Id="1" Count="0" />
</LineIds>
<LineIds Name="FB_VGC.M_IsClosed">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
FUNCTION_BLOCK FB_VFS_Interface EXTENDS FB_Valve
VAR_INPUT
IG : ST_VG; // The MKS422 Cold Cathode Data Structure
END_VAR
VAR
VAR_OUTPUT
{attribute 'pytmc' := '
pv: ;
'}
iq_stValve : ST_VFS; (* All valve data and states will be in this struct*)
i_xVAC_FAULT_OK AT%I*: BOOL; (*Valve Vacuum OK, is set to False when there is Vacuum Fault*)
END_VAR
VAR
tonOvrd : TON;
tOvrd : TIME := T#10s;
(*outputs*)
Expand All @@ -27,7 +30,6 @@ VAR
i_xTrigger AT %I* : BOOL;
i_xVFS_Open AT %I* : BOOL;
i_xVFS_Closed AT %I* : BOOL;
i_xVAC_FAULT_OK AT%I*: BOOL; (*Valve Vacuum OK, is set to False when there is Vacuum Fault*)
{attribute 'pytmc' := '
pv: MPS_FAULT_OK
field: ZNAM MPS FAULT ;
Expand Down

0 comments on commit cf61c6e

Please sign in to comment.