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

DEV: Adding the MEG, LEG and HEG gratings in the ZO PMPS evaluation #134

Merged
merged 4 commits into from
Dec 3, 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
18 changes: 9 additions & 9 deletions GratingMonoScope/VSSettings/.vsm
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<Children>
<Node>
<Title>Scope YT NC Project</Title>
<Expanded>True</Expanded>
<FileName>C:\Users\kaushikm\Documents\TcXaeShell\lcls-plc-rixs-optics\GratingMonoScope\Scope YT NC Project.tcscopex</FileName>
<Expanded>False</Expanded>
<FileName>C:\Users\mghaly\Documents\Github local\lcls-plc-rixs-optics\GratingMonoScope\Scope YT NC Project.tcscopex</FileName>
<Children>
<Node>
<Title>DataPool</Title>
<Expanded>True</Expanded>
<Expanded>False</Expanded>
<FileName></FileName>
<Children>
<Node>
Expand Down Expand Up @@ -65,12 +65,12 @@
</Node>
<Node>
<Title>Grating NC</Title>
<Expanded>True</Expanded>
<Expanded>False</Expanded>
<FileName></FileName>
<Children>
<Node>
<Title>Encoder Counts Diff</Title>
<Expanded>True</Expanded>
<Expanded>False</Expanded>
<FileName></FileName>
<Children>
<Node>
Expand All @@ -83,7 +83,7 @@
</Node>
<Node>
<Title>Position absolute</Title>
<Expanded>True</Expanded>
<Expanded>False</Expanded>
<FileName></FileName>
<Children>
<Node>
Expand All @@ -102,7 +102,7 @@
</Node>
<Node>
<Title>Velocity</Title>
<Expanded>True</Expanded>
<Expanded>False</Expanded>
<FileName></FileName>
<Children>
<Node>
Expand All @@ -121,7 +121,7 @@
</Node>
<Node>
<Title>Acceleration</Title>
<Expanded>True</Expanded>
<Expanded>False</Expanded>
<FileName></FileName>
<Children>
<Node>
Expand All @@ -140,7 +140,7 @@
</Node>
<Node>
<Title>Position Lag</Title>
<Expanded>True</Expanded>
<Expanded>False</Expanded>
<FileName></FileName>
<Children>
<Node>
Expand Down
2 changes: 1 addition & 1 deletion lcls-plc-rixs-optics/_Config/PLC/rixs_optics.xti
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ External Setpoint Generation:
</DataType>
</DataTypes>
<Project GUID="{85BF455D-934D-415A-B04C-6D4CDD9FF10E}" Name="rixs_optics" PrjFilePath="..\..\rixs_optics\rixs_optics.plcproj" TmcFilePath="..\..\rixs_optics\rixs_optics.tmc" ReloadTmc="true" AmsPort="851" FileArchiveSettings="#x000e" SymbolicMapping="true">
<Instance Id="#x08502000" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcPath="rixs_optics\rixs_optics.tmc" TmcHash="{1CC584EB-436B-9F6F-7169-17A090C4C9A2}">
<Instance Id="#x08502000" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcPath="rixs_optics\rixs_optics.tmc" TmcHash="{3BCC991F-CDAA-2F60-A71C-945FDC758B7A}">
<Name>rixs_optics Instance</Name>
<CLSID ClassFactory="TcPlc30">{08500001-0000-0000-F000-000000000064}</CLSID>
<Vars VarGrpType="1">
Expand Down
65 changes: 50 additions & 15 deletions lcls-plc-rixs-optics/rixs_optics/POUs/PRG_ZeroOrder_PMPS.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@ VAR
'}
bLRG_Grating_IN : BOOL;

{attribute 'pytmc' := '
pv: @(PREFIX)MEG_Grating_IN
field: ZNAM FALSE
field: ONAM TRUE
'}
bMEG_Grating_IN : BOOL;

{attribute 'pytmc' := '
pv: @(PREFIX)HEG_Grating_IN
field: ZNAM FALSE
field: ONAM TRUE
'}
bHEG_Grating_IN : BOOL;

{attribute 'pytmc' := '
pv: @(PREFIX)LEG_Grating_IN
field: ZNAM FALSE
field: ONAM TRUE
'}
bLEG_Grating_IN : BOOL;

{attribute 'pytmc' := '
pv: @(PREFIX)ZOS_IN
field: ZNAM FALSE
Expand Down Expand Up @@ -93,6 +114,8 @@ VAR
i_DevName := 'Zero Order Beam and Exit Slits',
i_Desc := 'Faults when Zero order beam is aligned and exit slits are closed',
i_TypeCode := 16#F506);
mm: INT;
eV: INT;
END_VAR
VAR CONSTANT
Hi2 :LREAL:=1.4;//m
Expand All @@ -113,29 +136,38 @@ END_VAR
bSafeBenderRange := SafeBenderRange();
nMachineMode := PMPS_GVL.stCurrentBeamParameters.nMachineMode;
bMR1K1_Inserted := MR1K1_Inserted();
ACT_Grating_IN();
ACT_CALC();
ACT_ZOS_IN();
ACT_ExitSlitsGap();

//TRUE if Hzos - hb0m3(Zzoz) > D
//Is the ZO beam on the stopper? TRUE if Hzos - hb0m3(Zzoz) > Δ
(*
Δ=2.0 mm for LRG @ >1000 eV
Δ=2.5 mm for LRG @ <1000 eV
Δ=3.0 mm for LRG @ <550 eV
Δ=6.0 mm for LEG, MEG, HEG
*)
Ans := (Hzos*1E3) - Hb0m3; //um
Delta := Ans;
IF GVL_PMPS.rPhotonEnergy <550 THEN
bZOB_on_Lower_Stopper := Ans > 3*1E3;
ELSIF GVL_PMPS.rPhotonEnergy <1000 THEN
bZOB_on_Lower_Stopper := Ans > 2.5*1E3;
ELSIF GVL_PMPS.rPhotonEnergy >=1000 THEN
bZOB_on_Lower_Stopper := Ans > 2*1E3;

IF bLRG_Grating_IN AND GVL_PMPS.rPhotonEnergy <550 THEN Delta := 3*1E3(*um*);
ELSIF bLRG_Grating_IN AND GVL_PMPS.rPhotonEnergy <1000 THEN Delta := 2.5*1E3(*um*);
ELSIF bLRG_Grating_IN AND GVL_PMPS.rPhotonEnergy >=1000 THEN Delta := 2*1E3(*um*);
ELSIF (bMEG_Grating_IN OR bHEG_Grating_IN OR bLEG_Grating_IN) THEN Delta := 6*1E3(*um*);
ELSE Delta := Ans;
END_IF

bZOB_on_Lower_Stopper := Ans > Delta;


ffZeroOrderBeam.i_xOK := (SafeBenderRange() AND (((PMPS_GVL.stCurrentBeamParameters.nMachineMode =1(*SC*)) AND (PMPS_GVL.stCurrentBeamParameters.nBeamClass <=6)) OR (PMPS_GVL.stCurrentBeamParameters.nMachineMode =0(*NC*))))
OR (bLRG_Grating_IN AND bZOS_IN AND bZOB_on_Lower_Stopper AND MR1K1_Inserted()(*NC or SC Any Beamclass with beam at ZOS*));
OR (bLRG_Grating_IN AND bZOS_IN AND bZOB_on_Lower_Stopper AND MR1K1_Inserted()(*NC or SC Any Beamclass with beam at ZOS*))
OR ((bMEG_Grating_IN OR bHEG_Grating_IN OR bLEG_Grating_IN) AND bZOS_IN AND bZOB_on_Lower_Stopper AND MR1K1_Inserted()(*NC or SC Any Beamclass with beam at ZOS*));
ffZeroOrderBeam(io_fbFFHWO := GVL_PMPS.fbFastFaultOutput1);
bBeamPermitted := ffZeroOrderBeam.i_xOK;

//
ACT_CALC();
ACT_ZOS_IN();
ACT_LRG_Grating_IN();
ACT_ExitSlitsGap();]]></ST>
]]></ST>
</Implementation>
<Action Name="ACT_CALC" Id="{29570aa5-9d14-46b0-b59e-651abe0f5e16}">
<Implementation>
Expand Down Expand Up @@ -183,9 +215,12 @@ ffZeroOrderBeamExitSlits.i_xOK := NOT( (( (Hzos*1E3) - 1) <= Hb0m3) AND ( M22.st
ffZeroOrderBeamExitSlits(io_fbFFHWO := GVL_PMPS.fbFastFaultOutput1);]]></ST>
</Implementation>
</Action>
<Action Name="ACT_LRG_Grating_IN" Id="{8babb51d-911c-461c-99fc-bb1adfccc9fe}">
<Action Name="ACT_Grating_IN" Id="{def557f5-6fcd-48fa-9e2d-d3f3ab8c4d09}">
<Implementation>
<ST><![CDATA[bLRG_Grating_IN := ((M9.stAxisStatus.fActPosition) >= 36000) AND ((M9.stAxisStatus.fActPosition) <= 43000);]]></ST>
<ST><![CDATA[bLRG_Grating_IN := PRG_SP1K1_MONO.eStateGet = E_Grating_States.LRG;
bMEG_Grating_IN := PRG_SP1K1_MONO.eStateGet = E_Grating_States.MEG;
bHEG_Grating_IN := PRG_SP1K1_MONO.eStateGet = E_Grating_States.HEG;
bLEG_Grating_IN := PRG_SP1K1_MONO.eStateGet = E_Grating_States.LEG;]]></ST>
</Implementation>
</Action>
<Action Name="ACT_ZOS_IN" Id="{ea635b1c-413a-4430-b9a8-7a35a57ab8c1}">
Expand Down
92 changes: 76 additions & 16 deletions lcls-plc-rixs-optics/rixs_optics/rixs_optics.tmc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<TcModuleClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.beckhoff.com/schemas/2009/05/TcModuleClass" Hash="{1CC584EB-436B-9F6F-7169-17A090C4C9A2}" GeneratedBy="TwinCAT XAE Plc">
<TcModuleClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.beckhoff.com/schemas/2009/05/TcModuleClass" Hash="{3BCC991F-CDAA-2F60-A71C-945FDC758B7A}" GeneratedBy="TwinCAT XAE Plc">
<DataTypes>
<DataType>
<Name Namespace="Tc2_SerialCom">ComSerialLineMode_t</Name>
Expand Down Expand Up @@ -81921,7 +81921,7 @@ The BPTM will throw an error if the arbiter does not have enough space for the t
<AreaNo AreaType="InputDst" CreateSymbols="true">0</AreaNo>
<Name>SerialIO Inputs</Name>
<ContextId>0</ContextId>
<ByteSize>165543936</ByteSize>
<ByteSize>165609472</ByteSize>
<Symbol>
<Name>GVL_SerialIO.Serial_stComIn_M1K2</Name>
<Comment>Better have your inputs and outputs!
Expand All @@ -81944,7 +81944,7 @@ The BPTM will throw an error if the arbiter does not have enough space for the t
<AreaNo AreaType="OutputSrc" CreateSymbols="true">1</AreaNo>
<Name>SerialIO Outputs</Name>
<ContextId>0</ContextId>
<ByteSize>165543936</ByteSize>
<ByteSize>165609472</ByteSize>
<Symbol>
<Name>GVL_SerialIO.Serial_stComOut_M1K2</Name>
<BitSize>192</BitSize>
Expand All @@ -81965,7 +81965,7 @@ The BPTM will throw an error if the arbiter does not have enough space for the t
<AreaNo AreaType="Internal" CreateSymbols="true">3</AreaNo>
<Name>SerialIO Internal</Name>
<ContextId>0</ContextId>
<ByteSize>165543936</ByteSize>
<ByteSize>165609472</ByteSize>
<Symbol>
<Name>P_Serial_Com.fbSerialLineControl_EL6001_M1K2</Name>
<BitSize>10752</BitSize>
Expand Down Expand Up @@ -82063,7 +82063,7 @@ The BPTM will throw an error if the arbiter does not have enough space for the t
<AreaNo AreaType="InputDst" CreateSymbols="true">16</AreaNo>
<Name>StatsTask Inputs</Name>
<ContextId>1</ContextId>
<ByteSize>165543936</ByteSize>
<ByteSize>165609472</ByteSize>
<Symbol>
<Name>Main.M7.Axis.NcToPlc</Name>
<BitSize>2048</BitSize>
Expand All @@ -82081,7 +82081,7 @@ The BPTM will throw an error if the arbiter does not have enough space for the t
<AreaNo AreaType="Internal" CreateSymbols="true">19</AreaNo>
<Name>StatsTask Internal</Name>
<ContextId>1</ContextId>
<ByteSize>165543936</ByteSize>
<ByteSize>165609472</ByteSize>
<Symbol>
<Name>PRG_Stats.fGpiEncoderPosDiff</Name>
<Comment> SP1K1 Grating Mono Vibration Stats</Comment>
Expand Down Expand Up @@ -82239,7 +82239,7 @@ The BPTM will throw an error if the arbiter does not have enough space for the t
<AreaNo AreaType="Internal" CreateSymbols="true">35</AreaNo>
<Name>PiezoDriver Internal</Name>
<ContextId>2</ContextId>
<ByteSize>165543936</ByteSize>
<ByteSize>165609472</ByteSize>
<Symbol>
<Name>PiezoSerial.fbE621SerialDriver_M1K2</Name>
<Comment>PI Serial</Comment>
Expand Down Expand Up @@ -82336,7 +82336,7 @@ The BPTM will throw an error if the arbiter does not have enough space for the t
<AreaNo AreaType="InputDst" CreateSymbols="true">48</AreaNo>
<Name>DaqTask Inputs</Name>
<ContextId>3</ContextId>
<ByteSize>165543936</ByteSize>
<ByteSize>165609472</ByteSize>
<Symbol>
<Name>PRG_DAQ_ENCODER.iLatchPos</Name>
<Comment> Inputs</Comment>
Expand Down Expand Up @@ -82391,7 +82391,7 @@ The BPTM will throw an error if the arbiter does not have enough space for the t
<AreaNo AreaType="Internal" CreateSymbols="true">51</AreaNo>
<Name>DaqTask Internal</Name>
<ContextId>3</ContextId>
<ByteSize>165543936</ByteSize>
<ByteSize>165609472</ByteSize>
<Symbol>
<Name>GVL_Logger.sIpTidbit</Name>
<BitSize>56</BitSize>
Expand Down Expand Up @@ -82868,7 +82868,7 @@ The BPTM will throw an error if the arbiter does not have enough space for the t
<AreaNo AreaType="InputDst" CreateSymbols="true">64</AreaNo>
<Name>PlcTask Inputs</Name>
<ContextId>4</ContextId>
<ByteSize>165543936</ByteSize>
<ByteSize>165609472</ByteSize>
<Symbol>
<Name>lcls_twincat_optics.GVL_TestStructs.TestPitch_LimitSwitches.diEncCnt</Name>
<Comment>Raw encoder count</Comment>
Expand Down Expand Up @@ -92067,7 +92067,7 @@ Emergency Stop for MR1K1</Comment>
<AreaNo AreaType="OutputSrc" CreateSymbols="true">65</AreaNo>
<Name>PlcTask Outputs</Name>
<ContextId>4</ContextId>
<ByteSize>165543936</ByteSize>
<ByteSize>165609472</ByteSize>
<Symbol>
<Name>PRG_MR1K1_BEND.fbM1K1PitchControl.fbMotionStage.fbDriveVirtual.MasterAxis.PlcToNc</Name>
<BitSize>1024</BitSize>
Expand Down Expand Up @@ -94259,7 +94259,7 @@ Emergency Stop for MR1K1</Comment>
<AreaNo AreaType="Internal" CreateSymbols="true">67</AreaNo>
<Name>PlcTask Internal</Name>
<ContextId>4</ContextId>
<ByteSize>165543936</ByteSize>
<ByteSize>165609472</ByteSize>
<Symbol>
<Name>DefaultGlobals.stSys</Name>
<Comment>Included for you</Comment>
Expand Down Expand Up @@ -108630,12 +108630,72 @@ M4K2 KBV X ENC CNT</Comment>
</Properties>
<BitOffs>1314666816</BitOffs>
</Symbol>
<Symbol>
<Name>PRG_ZeroOrder_PMPS.bMEG_Grating_IN</Name>
<BitSize>8</BitSize>
<BaseType>BOOL</BaseType>
<Properties>
<Property>
<Name>pytmc</Name>
<Value>
pv: @(PREFIX)MEG_Grating_IN
field: ZNAM FALSE
field: ONAM TRUE
</Value>
</Property>
</Properties>
<BitOffs>1322839248</BitOffs>
</Symbol>
<Symbol>
<Name>PRG_ZeroOrder_PMPS.bHEG_Grating_IN</Name>
<BitSize>8</BitSize>
<BaseType>BOOL</BaseType>
<Properties>
<Property>
<Name>pytmc</Name>
<Value>
pv: @(PREFIX)HEG_Grating_IN
field: ZNAM FALSE
field: ONAM TRUE
</Value>
</Property>
</Properties>
<BitOffs>1322839256</BitOffs>
</Symbol>
<Symbol>
<Name>PRG_ZeroOrder_PMPS.bLEG_Grating_IN</Name>
<BitSize>8</BitSize>
<BaseType>BOOL</BaseType>
<Properties>
<Property>
<Name>pytmc</Name>
<Value>
pv: @(PREFIX)LEG_Grating_IN
field: ZNAM FALSE
field: ONAM TRUE
</Value>
</Property>
</Properties>
<BitOffs>1322839264</BitOffs>
</Symbol>
<Symbol>
<Name>PRG_ZeroOrder_PMPS.mm</Name>
<BitSize>16</BitSize>
<BaseType>INT</BaseType>
<BitOffs>1322839280</BitOffs>
</Symbol>
<Symbol>
<Name>PRG_ZeroOrder_PMPS.eV</Name>
<BitSize>16</BitSize>
<BaseType>INT</BaseType>
<BitOffs>1322841952</BitOffs>
</Symbol>
</DataArea>
<DataArea>
<AreaNo AreaType="RetainSrc" CreateSymbols="true">68</AreaNo>
<Name>PlcTask Retains</Name>
<ContextId>4</ContextId>
<ByteSize>165543936</ByteSize>
<ByteSize>165609472</ByteSize>
<Symbol>
<Name>PMPS_GVL.SuccessfulPreemption</Name>
<Comment> Any time BPTM applies a new BP request which is confirmed</Comment>
Expand Down Expand Up @@ -108721,15 +108781,15 @@ M4K2 KBV X ENC CNT</Comment>
</Property>
<Property>
<Name>ChangeDate</Name>
<Value>2024-11-24T16:14:11</Value>
<Value>2024-12-03T15:17:20</Value>
</Property>
<Property>
<Name>GeneratedCodeSize</Name>
<Value>1097728</Value>
<Value>1032192</Value>
</Property>
<Property>
<Name>GlobalDataSize</Name>
<Value>163987456</Value>
<Value>163983360</Value>
</Property>
</Properties>
</Module>
Expand Down