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

Auto recover #80

Merged
merged 9 commits into from
Sep 2, 2021
4 changes: 2 additions & 2 deletions L2SIVacuum/DUTs/Gauges/E_PressureState.TcDUT
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<Declaration><![CDATA[TYPE E_PressureState :
(
// Invalid states
PressInvalid,// //gc_GaugeValidState - 1,
Off,// //gc_GaugeValidState - 1,
GaugeDisconnected, //gc_GaugeValidState -2,
OoR, //gc_GaugeValidState -6,
// Ion gauges
Off, //gc_GaugeValidState - 3,
PressInvalid, //gc_GaugeValidState - 3,
Starting, //gc_GaugeValidState - 4

//Valid States (Positive)
Expand Down
4 changes: 2 additions & 2 deletions L2SIVacuum/DUTs/Gauges/ST_VG.TcDUT
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ STRUCT
xPRESS_OK: BOOL;
{attribute 'pytmc' := '
pv: STATE;
field: ZRST PressInvalid;
field: ZRST Off;
field: ONST GaugeDisconnected;
field: TWST OoR;
field: THST Off;
field: THST PressInvalid;
field: FRST Starting;
field: FVST Valid;
field: SXST ValidHi;
Expand Down
36 changes: 18 additions & 18 deletions L2SIVacuum/L2SIVacuum.tmc

Large diffs are not rendered by default.

Binary file modified L2SIVacuum/LineIDs.dbg
Binary file not shown.
13 changes: 7 additions & 6 deletions L2SIVacuum/POUs/Functions/Gauges/FB_MKS422.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ VAR_OUTPUT
END_VAR
VAR
rV : REAL;

timer:TON;
(*IOs to be linked*)
/// Controls and I/Os
i_iPRESS_R AT %I* :INT; // input Pressure // Link to analog Input
q_xHV_DIS AT %Q* : BOOL := True; // Disable Gauge High Voltage when True // 'TcLinkTo' (EL2794) ^Output
stPump: INT;
END_VAR
VAR CONSTANT
MinPressure: REAL := 1E-10;
Expand Down Expand Up @@ -54,15 +52,18 @@ END_IF


(* Pressure gauge State checks *)
IF (rV <=9.6 ) AND (rV>=0.6) THEN
IF (rV <=9.6 ) AND (rV>=0.6) AND (IG.xHV_SW) THEN
IG.eState := Valid; // normal
ELSIF rV >= 0.18 AND rV <= 0.22 THEN
ELSIF rV >= 0.18 AND rV <= 0.22 AND (IG.xHV_SW) THEN
IG.eState := ValidLo; //LO
ELSIF rV > 9.6 AND rV<= 9.9 THEN
ELSIF rV > 9.6 AND rV<= 9.9 AND (IG.xHV_SW) THEN
IG.eState := ValidHi; //HIGH
ELSIF rV < 0.18 THEN //
Copy link
Contributor

@klauer klauer Aug 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a dumb question as I'm drive-by reviewing for a project I have nothing to do with, but should this include: AND Ig.xHV_SW like the others?
(If so, it might be a bit more readable to do a top-level IF xHV_SW THEN (check voltages) ELSE set_off_state)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it missing the range rv< 0.6 and rv>0.22? which should be valid or valid low?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these values be local constants? Avoiding hardcoded values?

IG.eState := GaugeDisconnected; //not on
IG.rPRESS :=cDefaultPressure;
ELSIF NOT (IG.xHV_SW) THEN
IG.eState := Off; //other fault - could be no gauge, controller powering up etc
IG.rPRESS :=cDefaultPressure;
ELSE
IG.eState := PressInvalid; //other fault - could be no gauge, controller powering up etc
IG.rPRESS :=cDefaultPressure;
Expand Down Expand Up @@ -180,7 +181,7 @@ IF NOT (IG.rHYS_PR = rHYS_PR) THEN
rHYS_PR:= IG.rHYS_PR;
END_IF;
stateTimer(PT:=T#10S);
IF (ePrevState <> IG.eState) THEN
IF (stateTimer.Q) THEN
bWasOn := (IG.eState >=Valid );
stateTimer.IN := FALSE;
END_IF;]]></ST>
Expand Down
25 changes: 18 additions & 7 deletions L2SIVacuum/POUs/Functions/Gauges/FB_MKS500.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ END_VAR
VAR
rV : REAL;
GaugeTurnOnTmr : TON;
tStartupTimer:TON;
iTermBits: UINT := 32767 ; // The terminal's maximum value in bits
(*IOs to be linked*)
/// Controls and I/Os
Expand All @@ -31,7 +32,7 @@ VAR
// only for EL and ES terminal
i_xHV_ON AT %I* : BOOL; // True when High Voltage is on // 'TcLinkTo' (EL1124) ^Input
i_xDisc_Active AT %I* : BOOL;// Discharge Current Active // 'TcLinkTo' (EL1124) ^Input

binit:BOOL:=TRUE;
END_VAR

VAR CONSTANT
Expand All @@ -52,26 +53,36 @@ END_VAR

]]></Declaration>
<Implementation>
<ST><![CDATA[(* 500 Logarithmic Output Conversion, factory default configuration *)
<ST><![CDATA[(*Startup time*)
IF (bInit) THEN
tStartupTimer.IN:=TRUE;
bInit :=FALSE;
END_IF
tStartupTimer(PT:=T#3S);

(* 500 Logarithmic Output Conversion, factory default configuration *)
If (iTermBits=0) THEN iTermBits := 32767;END_IF
rV := 10*INT_TO_REAL(IG.i_iPRESS_R)/iTermBits;

(* Set Guage State based on the Analog voltage*)
IF rV < vDisconnected THEN
IF NOT (tStartupTimer.Q) THEN // Give time for the gauge controller to start
IG.eState := Off;
IG.rPRESS := cDefaultPressure;
ELSIF rV < vDisconnected THEN
IG.eState := GaugeDisconnected;
IG.rPRESS := cDefaultPressure;
ELSIF rV >= vDisconnected AND rV < (vNoDischarge -rDeadband) THEN
ELSIF rV >= vDisconnected AND rV < (vNoDischarge -rDeadband) AND (IG.xHV_SW) THEN
IG.eState := Valid;
IG.rPRESS := LREAL_TO_REAL(EXPT(10,((rV-vBase)/vSlope+LOG(pBase))));
ELSIF rV >= (vNoDischarge -rDeadband) AND rV <(vGaugeOff -rDeadband) THEN
ELSIF rV >= (vNoDischarge -rDeadband) AND rV <(vGaugeOff -rDeadband) AND (IG.xHV_SW) THEN
IG.eState := Starting;
IG.rPRESS := LREAL_TO_REAL(EXPT(10,((rV-vBase)/vSlope+LOG(pBase))));
ELSIF rV >= (vGaugeOff -rDeadband) THEN
IG.eState := Off;
//IG.rPRESS := LREAL_TO_REAL(EXPT(10,((rV-vBase)/vSlope+LOG(pBase))));
IG.rPRESS := cDefaultPressure;
ELSE
IG.eState := OoR;
IG.eState := PressInvalid;
//IG.rPRESS := LREAL_TO_REAL(EXPT(10,((rV-vBase)/vSlope+LOG(pBase))));
IG.rPRESS := cDefaultPressure;
END_IF
Expand Down Expand Up @@ -199,7 +210,7 @@ IF NOT (IG.rHYS_PR = rHYS_PR) THEN
rHYS_PR:= IG.rHYS_PR;
END_IF;
stateTimer(PT:=T#10S);
IF (ePrevState <> IG.eState) THEN
IF (stateTimer.Q) THEN
bWasOn := (IG.eState >=Valid );
stateTimer.IN := FALSE;
END_IF;]]></ST>
Expand Down
1 change: 0 additions & 1 deletion L2SIVacuum/POUs/Functions/Valves/FB_VCN.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ IF iq_stVCN.xIlkOK THEN
ELSIF iq_stVCN.eValveControl = PressureControl THEN
IF (i_xPurge) THEN
iq_stVCN.rReqPosition := LIMIT(0, i_ReqPos, 100);
i_xPurge := FALSE;
ELSE iq_stVCN.rReqPosition := LIMIT(0, i_ReqPos, iq_stVCN.rUpperLimit);
END_IF
END_IF
Expand Down