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

Vat590 update #119

Merged
merged 3 commits into from
May 23, 2024
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
14 changes: 0 additions & 14 deletions L2SIVacuum/DUTs/Valves/VAT590/E_VAT590_PressureSensor.TcDUT

This file was deleted.

5 changes: 0 additions & 5 deletions L2SIVacuum/DUTs/Valves/VAT590/ST_VCN_VAT590.TcDUT
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
<DUT Name="ST_VCN_VAT590" Id="{1cac1206-fd6c-43b8-ae08-593989ed3a26}">
<Declaration><![CDATA[TYPE ST_VCN_VAT590 :
STRUCT
(* VCN - Valve Controlled Needle

Check warning on line 6 in L2SIVacuum/DUTs/Valves/VAT590/ST_VCN_VAT590.TcDUT

View workflow job for this annotation

GitHub Actions / standard / Style check / Leading tabs

Leading tabs
Used for VAT590 needle valves *)

Check warning on line 7 in L2SIVacuum/DUTs/Valves/VAT590/ST_VCN_VAT590.TcDUT

View workflow job for this annotation

GitHub Actions / standard / Style check / Leading tabs

Leading tabs
{attribute 'pytmc' := '

Check warning on line 8 in L2SIVacuum/DUTs/Valves/VAT590/ST_VCN_VAT590.TcDUT

View workflow job for this annotation

GitHub Actions / standard / Style check / Leading tabs

Leading tabs
pv: POS_RAW

Check warning on line 9 in L2SIVacuum/DUTs/Valves/VAT590/ST_VCN_VAT590.TcDUT

View workflow job for this annotation

GitHub Actions / standard / Style check / Leading tabs

Leading tabs
io: i

Check warning on line 10 in L2SIVacuum/DUTs/Valves/VAT590/ST_VCN_VAT590.TcDUT

View workflow job for this annotation

GitHub Actions / standard / Style check / Leading tabs

Leading tabs
'}
nRawPosition : DINT; //Position readback

Check warning on line 12 in L2SIVacuum/DUTs/Valves/VAT590/ST_VCN_VAT590.TcDUT

View workflow job for this annotation

GitHub Actions / standard / Style check / Leading tabs

Leading tabs
{attribute 'pytmc' := '

Check warning on line 13 in L2SIVacuum/DUTs/Valves/VAT590/ST_VCN_VAT590.TcDUT

View workflow job for this annotation

GitHub Actions / standard / Style check / Leading tabs

Leading tabs
pv: PRES_RAW

Check warning on line 14 in L2SIVacuum/DUTs/Valves/VAT590/ST_VCN_VAT590.TcDUT

View workflow job for this annotation

GitHub Actions / standard / Style check / Leading tabs

Leading tabs
io: i

Check warning on line 15 in L2SIVacuum/DUTs/Valves/VAT590/ST_VCN_VAT590.TcDUT

View workflow job for this annotation

GitHub Actions / standard / Style check / Leading tabs

Leading tabs
'}
nRawPressure : DINT; //Pressure readback
{attribute 'pytmc' := '
Expand Down Expand Up @@ -51,12 +51,12 @@
io: io
autosave_pass1: VAL DESC
'}
fPresSetLimit : REAL := 1E-2; //Upper limit for pressure control

Check warning on line 54 in L2SIVacuum/DUTs/Valves/VAT590/ST_VCN_VAT590.TcDUT

View workflow job for this annotation

GitHub Actions / standard / Style check / Trailing whitespace

Trailing whitespace
{attribute 'pytmc' := '
pv: PRES_RDBK_LIMIT
io: io
autosave_pass1: VAL DESC
'}

Check warning on line 59 in L2SIVacuum/DUTs/Valves/VAT590/ST_VCN_VAT590.TcDUT

View workflow job for this annotation

GitHub Actions / standard / Style check / Trailing whitespace

Trailing whitespace
fPresRdbkLimit : REAL := 1E-4; //Upper limit for pressure reading before valve close
{attribute 'pytmc' := '
pv: POS_REQ
Expand All @@ -71,21 +71,16 @@
io: io;
'}
fReqPressure : REAL; //Requested pressure in Torr units
{attribute 'pytmc' := '

Check warning on line 74 in L2SIVacuum/DUTs/Valves/VAT590/ST_VCN_VAT590.TcDUT

View workflow job for this annotation

GitHub Actions / standard / Style check / Trailing whitespace

Trailing whitespace
pv: STATE
io: io
'}
eValveControl : E_VCN_VAT590; //Valve control mode
{attribute 'pytmc' := '
pv:

Check warning on line 80 in L2SIVacuum/DUTs/Valves/VAT590/ST_VCN_VAT590.TcDUT

View workflow job for this annotation

GitHub Actions / standard / Style check / Trailing whitespace

Trailing whitespace
'}
stValveStatus : ST_VAT590_STATUS; //All Valve status readbacks
{attribute 'pytmc' := '

Check warning on line 83 in L2SIVacuum/DUTs/Valves/VAT590/ST_VCN_VAT590.TcDUT

View workflow job for this annotation

GitHub Actions / standard / Style check / Trailing whitespace

Trailing whitespace
pv: PRES_SENS
io: io
'}
ePressureSensor : E_VAT590_PressureSensor; //Select pressure sensor
{attribute 'pytmc' := '
pv: REM_CTRL
io: io
'}
Expand Down
3 changes: 0 additions & 3 deletions L2SIVacuum/L2SIVacuum.plcproj
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,6 @@
<Compile Include="DUTs\Valves\VAT590\E_VAT590_PID_CTRL.TcDUT">
<SubType>Code</SubType>
</Compile>
<Compile Include="DUTs\Valves\VAT590\E_VAT590_PressureSensor.TcDUT">
<SubType>Code</SubType>
</Compile>
<Compile Include="DUTs\Valves\VAT590\E_VCN_VAT590.TcDUT">
<SubType>Code</SubType>
</Compile>
Expand Down
70 changes: 35 additions & 35 deletions L2SIVacuum/L2SIVacuum.tmc

Large diffs are not rendered by default.

Binary file modified L2SIVacuum/LineIDs.dbg
Binary file not shown.
58 changes: 29 additions & 29 deletions L2SIVacuum/POUs/Functions/Valves/FB_VCN_VAT590.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
cClosePosition : REAL := 0.0; // Default position setpoint lower scale value
cPresSPUpLim : REAL := 1E+6; // Default pressure setpoint upper scale value
cPresSPLowLim : REAL := 0; // Default pressure setpoint lower scale value
cMinPress : REAL := 1e-11; // Default Min. pressure in Torr that can be used and requested
cMaxPress : REAL := 1e-2; // Default Max. pressure in Torr that can be used and requested
cBasePress : REAL := 1E-11; // Pressure sensor base value
cPressRawSlope : REAL := 1E+5; // Slope (in Units per decade) used for conversion of pressure in Torr to valve External Digital pressure sensor 1 input raw value (0-1000000)
cPressRawBase : REAL := 1E+5; // Valve analog output base(in Units per decade) defined for how much the curve is shifted

cPressCtrl : ST_CoEIndSub := (nIndex := 16#2199, nSubIndex := 0); // Selected pressure controller CoE register
cSensorDelay_AD : ST_CoEIndSub := (nIndex := 16#219A, nSubIndex := 0); // Adaptive DS controller Sensor Delay CoE register
cRampTime_AD : ST_CoEIndSub := (nIndex := 16#219B, nSubIndex := 0); // Adaptive DS controller Ramp Time CoE register
Expand All @@ -42,20 +48,19 @@
VAR
fCalcPosSP : REAL := 0;
fCalcPresSP : REAL := 0;
eValveModeSP : E_ControlModeSP;
fPressRaw : REAL := 0; // Ranges 0 to 1000000 (or 0.0 to 10V) (1E-12 to 1E-2)
eValveModeSP : E_ControlModeSP; // Control Mode setpoint internal variable
fReqPos : REAL; // Requested position internal variable
fReqPres : REAL; // Requested pressure internal variable
fPresLowLim : REAL := 1E-10; // Pressure sensor lower scale value
fSlope : REAL := 1E+5; // Slope (Units per decade) used for conversion from Torr units
fVbase : REAL := 1E+5; // Vbase (Units per decade) defined for how much the curve is shifted

bRemAcsToggle : BOOL; // Remote access control bit
//timer for zero function

Check warning on line 57 in L2SIVacuum/POUs/Functions/Valves/FB_VCN_VAT590.TcPOU

View workflow job for this annotation

GitHub Actions / standard / Style check / Trailing whitespace

Trailing whitespace
tZeroTogg : TON := (PT := T#1S);
//timer for remote function
tRemAcsTogg : TON := (PT := T#500MS);
//used for logging
ePreviousState : E_VCN_VAT590;

Check warning on line 63 in L2SIVacuum/POUs/Functions/Valves/FB_VCN_VAT590.TcPOU

View workflow job for this annotation

GitHub Actions / standard / Style check / Trailing whitespace

Trailing whitespace
(*CoE Interface*)
(*Link this to your VAT590 reference variables under InfoData.*)
//Connect i_stVat590PlcDriveRef.aNetId to the VAT590 Valve InfoData^AdsAddr^netId
Expand All @@ -65,14 +70,14 @@

fbCoeRead : FB_CoERead_ByDriveRef; // CoE Read function block
fbCoeWrite : FB_CoEWrite_ByDriveRef; // CoE Write function block

Check warning on line 73 in L2SIVacuum/POUs/Functions/Valves/FB_VCN_VAT590.TcPOU

View workflow job for this annotation

GitHub Actions / standard / Style check / Trailing whitespace

Trailing whitespace
stCoeParamsInternal : ST_VAT590_COE; // Internal storage of CoE parameters
nCaseReadCoe : UINT := 1; // Iterator for going through all CoE parameters
rtCoeReset : R_TRIG; // Rising edge trigger for reset CoE Interface error
ftCoeReadBusy : F_TRIG; // Falling edge trigger for CoE read new data
ftCoeWriteBusy : F_TRIG; // Falling edge trigger for CoE write data
bFirstRead : BOOL := TRUE; // FALSE after succesfull first readout of all CoE parameters

Check warning on line 80 in L2SIVacuum/POUs/Functions/Valves/FB_VCN_VAT590.TcPOU

View workflow job for this annotation

GitHub Actions / standard / Style check / Trailing whitespace

Trailing whitespace
(*VAT590 Ethercat IO Interface*)
// Ethercat Interface Inputs
i_nRawPosition AT %I* : DINT; // Position readback from the valve
Expand All @@ -85,6 +90,7 @@
// Ethercat Interface Outputs
o_nRawPositionSP AT %Q* : DINT; // Position setpoint
o_nRawPressureSP AT %Q* : DINT; // Pressure setpoint
o_nRawPressure AT %Q* : DINT; // Raw pressure output, eliminate need for external connection of AI, ranges 0 to 1000000 (or 0.0 to 10V) (1E-12 Torr to 1E-2 Torr)
o_eCtrlModeSP AT %Q* : E_ControlModeSP; // Valve control mode setpoint
o_stGenCtrlSP AT %Q* : ST_GeneralControlSP;// General Control setpoint
(*Ethercat Interface Status Check*)
Expand All @@ -105,7 +111,7 @@
It provides:
Valve position ceiling
Interlock
CoE Interface
CoE Interface R/W

It could be used for:
Valve position/flow linearization
Expand Down Expand Up @@ -157,35 +163,28 @@
stVcnVat590.eValveControl := E_VCN_VAT590.CloseValve;
END_IF

(*Requested Position calculation*)
(*Position SP calculation*)
fReqPos := LIMIT(0, fReqPos, fUpperLimit);
fCalcPosSP := fReqPos * (cOpenPosition-cClosePosition)/100 + cClosePosition;
fCalcPosSP := LIMIT(cClosePosition, fCalcPosSP, cOpenPosition); //The requested position SP should remain within this range

(*Pressure calculation*)
(*Pressure SP calculation*)
//Limit the input from EPICS between upper and lower limit defined for seleceted pressure sensor
fReqPres := LIMIT(fPresLowLim, fReqPres, fPresMaxLim);

// Calculate pressure readback and pressure setpoint according to selected pressure gauge
CASE stVcnVat590.ePressureSensor OF
E_VAT590_PressureSensor.MKS500:
fPresLowLim := 1.0E-10;
fSlope := 1E+5;
fVbase := 1E+5;
//Calcuate pressure setpoint
fCalcPresSP := fSlope * LOG(fReqPres/fPresLowLim) + fVbase;
fCalcPresSP := LIMIT(cPresSPLowLim, fCalcPresSP, cPresSPUpLim); //The requested pressure SP should remain within this range
//Calculate pressure readback in Torr units
stVcnVat590.fPressure := LREAL_TO_REAL(EXPT(10,((DINT_TO_REAL(stVcnVat590.nRawPressure)-fVbase)/fSlope + LOG(fPresLowLim))));
ELSE
fCalcPresSP := 0;
stVcnVat590.fPressure := 0;
END_CASE
fReqPres := LIMIT(cMinPress, fReqPres, fPresMaxLim);
//Calcuate pressure setpoint
fCalcPresSP := cPressRawSlope * LOG(fReqPres/cBasePress) + cPressRawBase;
fCalcPresSP := LIMIT(cPresSPLowLim, fCalcPresSP, cPresSPUpLim); //The requested pressure SP should remain within this range

(*Calculated Pressure SP and Pressure readback is 0 if Pressure sensor is not working*)
IF NOT (IG.xPRESS_OK AND IG.rPRESS < fPresRbMaxLim ) THEN
(*Calculated Pressure SP, Pressure readback and PressureRaw output value are 0 if Pressure sensor is not working*)
//Calculate PressureRaw value linked to the Valve's External Digital pressure sensor 1 input
//Pressure information from IG input is linked to stVcnVat590.fPressure
IF IG.xPRESS_OK THEN
stVcnVat590.fPressure := IG.rPRESS;
fPressRaw := cPressRawSlope * LOG(IG.rPRESS/cBasePress) + cPressRawBase;
ELSE
fCalcPresSP := 0;
stVcnVat590.fPressure := 0;
fPressRaw := 0;
END_IF

(*Zero function*)
Expand Down Expand Up @@ -429,10 +428,10 @@
<Implementation>
<ST><![CDATA[(*Read from EPICS*)
fUpperLimit := LIMIT(0, stVcnVat590.fPosSetLimit, 100);
fPresMaxLim := LIMIT(1.0E-10, stVcnVat590.fPresSetLimit, 1.0E-2);
fPresRbMaxLim := LIMIT(1.0E-10, stVcnVat590.fPresRdbkLimit, 1.0E-2);
fPresMaxLim := LIMIT(cMinPress, stVcnVat590.fPresSetLimit, cMaxPress);
fPresRbMaxLim := LIMIT(cMinPress, stVcnVat590.fPresRdbkLimit, cMaxPress);
fReqPos := LIMIT(0, stVcnVat590.fReqPosition, 100);
fReqPres := LIMIT(1.0E-10, stVcnVat590.fReqPressure, 1.0E-2);
fReqPres := LIMIT(cMinPress, stVcnVat590.fReqPressure, cMaxPress);

(*Read from VAT valve*)
stVcnVat590.stValveStatus.eControlMode := i_eControlMode;
Expand Down Expand Up @@ -654,6 +653,7 @@
o_eCtrlModeSP := eValveModeSP;
o_nRawPositionSP := REAL_TO_DINT(fCalcPosSP);
o_nRawPressureSP := REAL_TO_DINT(fCalcPresSP);
o_nRawPressure := REAL_TO_DINT(fPressRaw);
o_stGenCtrlSP.Bit0ExecuteZero := stVcnVat590.bZero;
o_stGenCtrlSP.Bit4AccessMode := bRemAcsToggle;]]></ST>
</Implementation>
Expand Down
Loading