Skip to content
Draft
26 changes: 26 additions & 0 deletions DUTs/ST_TechnosoftMotionError.TcDUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<DUT Name="ST_TechnosoftMotionError" Id="{90598514-2df2-078a-0a1a-d8b0c6c1a1f5}">
<Declaration><![CDATA[TYPE ST_TechnosoftMotionError :
STRUCT
bEtherCATCommunicationError: BIT; //EtherCAT communication error, bit 0
bShortCircuit: BIT; //Short circuit, bit 1
bInvalidSetupData: BIT; //Invalid setup data, bit2
bControlError: BIT; //Position or speed error, bit3
bCommunicationError: BIT; //Communication error, bit 4
bFeedbackError: BIT; //Feedback error, bit 5
bPositiveLimitSwitchActive: BIT; //Positive limit active, bit 6
bNegativeLimitSwitchActive: BIT; //Negative limit active, bit 7
bOverCurrent: BIT; //Over current, bit 8
bI2TProtection: BIT; //I2T protection active, bit 9
bMotorOverTemperature: BIT; //Motor over temperature, bit 10
bDriveOverTemperature: BIT; //Drive over temperature, bit 11
bOverVoltage: BIT; //Over voltage, bit 12
bUnderVoltage: BIT; //Under voltage, bit 13
bCommandError: BIT; //Command error, bit 14
bSTOActive: BIT; //Enabled or STO disabled, bit 15
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>
33 changes: 33 additions & 0 deletions DUTs/Safety/I_SafetyProvider.TcIO
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<Itf Name="I_SafetyProvider" Id="{75cc1dc0-1fe0-0a83-16f9-f86bc902e86f}">
<Declaration><![CDATA[INTERFACE I_SafetyProvider


]]></Declaration>
<Property Name="EStopOK" Id="{2f4df65d-4a99-0047-0aa9-2b7b567f1a9c}">
<Declaration><![CDATA[PROPERTY EStopOK : BOOL
]]></Declaration>
<Get Name="Get" Id="{f3af02b7-4557-0a7f-3fff-5ff38992b042}">
<Declaration><![CDATA[
]]></Declaration>
</Get>
</Property>
<Property Name="ReadFromSafetyController" Id="{168846af-f985-0ee8-3e0d-dcdf7288878f}">
<Declaration><![CDATA[PROPERTY ReadFromSafetyController : BOOL
]]></Declaration>
<Get Name="Get" Id="{eafce056-75cc-0208-2233-eff73018b5e1}">
<Declaration><![CDATA[
]]></Declaration>
</Get>
</Property>
<Property Name="STO_OK" Id="{dd0f65fe-28b6-029c-3b57-94670f527634}">
<Declaration><![CDATA[PROPERTY STO_OK : BOOL
]]></Declaration>
<Get Name="Get" Id="{238f8237-b7a4-0e8b-1037-652a99d7db86}">
<Declaration><![CDATA[
]]></Declaration>
</Get>
</Property>
</Itf>
</TcPlcObject>
19 changes: 19 additions & 0 deletions DUTs/Safety/PNOZ/ST_LEDState.TcDUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<DUT Name="ST_LEDState" Id="{f261f142-fde3-0208-2395-07dc6293304d}">
<Declaration><![CDATA[//LED state of the safety controller PNOZmulti 2 B0
TYPE ST_LEDState :
STRUCT
bLED_OFAULT: BIT; //OFAULT LED is lit or flashing, bit 1
bLED_IFAULT: BIT; //IFAULT LED is lit or flashing, bit 2
bLED_FAULT: BIT; //FAULT LED is lit or flashing, bit 3
bLED_DIAG: BIT; //DIAG LED is lit or flashing, bit 4
bLED_RUN: BIT; //RUN LED is lit, bit 5
bReserved6: BIT; //Reserved
bReserved7: BIT; //Reserved
bReserved8: BIT; //Reserved
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>
27 changes: 27 additions & 0 deletions DUTs/Safety/PNOZ/ST_MCCStatusIn.TcDUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<DUT Name="ST_MCCStatusIn" Id="{72c2d88f-a765-0a04-1255-9624a4d4f1ce}">
<Declaration><![CDATA[// Status information related to the cabinet PNOZ --> IPC, will not change from cabinet to cabinet
TYPE ST_MCCStatusIn :
STRUCT
bHeartbeat: BIT; //The loop-back signal of the heartbeat signal from the PLC-to-PNOZ-to-PLC.
bEStopOK: BIT; //If no E-Stop connected to this cabinet is pressed, this bit is TRUE. When pressed, it is FALSE.
bRemote: BIT; //When remote mode is active, this allows remote resetting of E-Stop zones from EPICS/NICOS. Remote is active when the physical doors/access into said instruments are locked.
bFault: BIT; //Feedback to safety controller that fault has been acknowledged
bReserved4: BIT;
bReserved5: BIT;
bReserved6: BIT;
bReserved7: BIT;
bReserved8: BIT;
bReserved9: BIT;
bReserved10: BIT;
bReserved11: BIT;
bReserved12: BIT;
bReserved13: BIT;
bReserved14: BIT;
bReserved15: BIT;
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>
27 changes: 27 additions & 0 deletions DUTs/Safety/PNOZ/ST_MCCStatusOut.TcDUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<DUT Name="ST_MCCStatusOut" Id="{4ca824d4-32e3-0c0c-0c21-10b3968bc3f6}">
<Declaration><![CDATA[//Status information related to the cabinet IPC --> PNOZ, will not change from cabinet to cabinet
TYPE ST_MCCStatusOut :
STRUCT
bHeartbeat: BIT; //Pulsed every ~200ms by the PLC-to-PNOZ, the PNOZ is expected to loop back this signal.
bReserved1: BIT;
bReserved2: BIT;
bErrAck: BIT; //If there is a fault requiring intervention (from cabinet), CabAck will clear it
bReserved4: BIT;
bReserved5: BIT;
bSTOFbk: BIT;
bSTO_OK: BIT;
bReserved8: BIT;
bReserved9: BIT;
bReserved10: BIT;
bReserved11: BIT;
bReserved12: BIT;
bReserved13: BIT;
bReserved14: BIT;
bReserved15: BIT;
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>
13 changes: 13 additions & 0 deletions DUTs/Safety/PNOZ/ST_PNOZCommDiag.TcDUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<DUT Name="ST_PNOZCommDiag" Id="{5cc4dacf-5e42-0a6f-2af9-92b983426889}">
<Declaration><![CDATA[TYPE ST_PNOZCommDiag :
STRUCT
bWcState: BOOL; //0 = Valid real-time communication in the last cycle, 1 = Invalid real-time communication
bInputToggle: BOOL; //It changes its state 0/1 whenever new data is received.
nEtherCATState: UINT; //State of EtherCAT slave
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>
15 changes: 15 additions & 0 deletions DUTs/Safety/PNOZ/ST_PNOZEtherCATIn.TcDUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<DUT Name="ST_PNOZEtherCATIn" Id="{4d26afb5-ffd0-0d85-0f77-77acb686f585}">
<Declaration><![CDATA[//Formatted PNOZ -> PLC EtherCAT input data copied from the raw %I* process image.
TYPE ST_PNOZEtherCATIn :
STRUCT
stMCCStatusIn: ST_MCCStatusIn; //Input Byte 00..01
stMCC_CustomStatusIn: ST_MCC_CustomStatusIn; //Input Byte 02..03
astSafetyFunctionIn: ARRAY[1..GVL_APP.nNUM_OF_SAFETY_FUNCTIONS] OF ST_SafetyFunctionIn; //Input Byte 04..15
stLEDState: ST_LEDState; //Input Byte 16
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>
14 changes: 14 additions & 0 deletions DUTs/Safety/PNOZ/ST_PNOZEtherCATOut.TcDUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<DUT Name="ST_PNOZEtherCATOut" Id="{2f65ec2d-5561-0256-2e54-58b3e165bd48}">
<Declaration><![CDATA[//Formatted PLC -> PNOZ EtherCAT output data mapped to the raw %Q* process image.
TYPE ST_PNOZEtherCATOut :
STRUCT
stMCCStatusOut: ST_MCCStatusOut; //Output Byte 00..01
stMCC_CustomStatusOut: ST_MCC_CustomStatusOut; //Output Byte 02..03
astSafetyFunctionOut: ARRAY[1..GVL_APP.nNUM_OF_SAFETY_FUNCTIONS] OF ST_SafetyFunctionOut; //Output Byte 04..15
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>
14 changes: 14 additions & 0 deletions DUTs/Safety/PNOZ/ST_SafetyFunctionIn.TcDUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<DUT Name="ST_SafetyFunctionIn" Id="{8070dc95-c87f-07f6-3fb8-b169434ba19a}">
<Declaration><![CDATA[TYPE ST_SafetyFunctionIn :
STRUCT
bEnabled: BIT;
bReady: BIT; //Input TRUE, ready for RESET
bFault: BIT; //Specific to this safety function
bStart: BIT; //Status of start signal
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>
14 changes: 14 additions & 0 deletions DUTs/Safety/PNOZ/ST_SafetyFunctionOut.TcDUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<DUT Name="ST_SafetyFunctionOut" Id="{d225f0e9-f4be-0268-2036-d232ca0275b9}">
<Declaration><![CDATA[TYPE ST_SafetyFunctionOut :
STRUCT
bDiagOk: BIT; //OK (Where diagnostics need TO be checked, i.e. drive errors)
bOutput: BIT; //Where PLC checks consistency (i.e. STO)
bRequest: BIT;
bDummy: BIT; //Not in use
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>
12 changes: 12 additions & 0 deletions DUTs/Safety/ST_Safety.TcDUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<DUT Name="ST_Safety" Id="{a14bb73e-e071-0777-120d-26666a0ac858}">
<Declaration><![CDATA[TYPE ST_Safety :
STRUCT
stSafetyIn: ST_SafetyIn;
stSafetyOut: ST_SafetyOut;
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>
16 changes: 16 additions & 0 deletions DUTs/Safety/ST_SafetyIn.TcDUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<DUT Name="ST_SafetyIn" Id="{0d1123b7-648b-0e04-09b5-2fa227393647}">
<Declaration><![CDATA[TYPE ST_SafetyIn :
STRUCT
stMCCStatusIn: ST_MCCStatusIn;
stMCC_CustomStatusIn: ST_MCC_CustomStatusIn;
astSafetyFunctionIn: ARRAY[1..GVL_APP.nNUM_OF_SAFETY_FUNCTIONS] OF ST_SafetyFunctionIn;
stLEDState: ST_LEDState;
stPNOZCommDiag: ST_PNOZCommDiag;
astTechnosoftMotionError: ARRAY[1..GVL_APP.nNUM_OF_TECHNOSOFT] OF ST_TechnosoftMotionError;
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>
16 changes: 16 additions & 0 deletions DUTs/Safety/ST_SafetyOut.TcDUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<DUT Name="ST_SafetyOut" Id="{6db86537-94b6-04bd-253e-6dba0646fcc5}">
<Declaration><![CDATA[TYPE ST_SafetyOut :
STRUCT
stMCCStatusOut: ST_MCCStatusOut;
stMCC_CustomStatusOut: ST_MCC_CustomStatusOut;
astSafetyFunctionOut: ARRAY[1..GVL_APP.nNUM_OF_SAFETY_FUNCTIONS] OF ST_SafetyFunctionOut;

bSTOActive: BOOL;
bTechnosoftMotionErrors: BOOL;
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>
14 changes: 14 additions & 0 deletions GVLs/GVL_Safety.TcGVL
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<GVL Name="GVL_Safety" Id="{a52cb188-5548-0f30-0b0b-19989305c2e3}">
<Declaration><![CDATA[{attribute 'qualified_only'}
VAR_GLOBAL
{attribute 'TcLinkTo' := 'TIID^Device 2 (EtherCAT)^KF201 (EK1100)^KF207 (EL2014)^DIG Outputs^Channel 2^Output'}
bOpticalCaveLED AT %Q*: BOOL; //Optical Cave

{attribute 'TcLinkTo' := 'TIID^Device 2 (EtherCAT)^KF201 (EK1100)^KF207 (EL2014)^DIG Outputs^Channel 3^Output'}
bExperimentCaveLED AT %Q*: BOOL; //Expirement Cave
END_VAR
]]></Declaration>
</GVL>
</TcPlcObject>
97 changes: 97 additions & 0 deletions POUs/FB_PulseGenerator.TcPOU
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<POU Name="FB_PulseGenerator" Id="{ecd95264-9cbb-04ca-0c29-fab3421e79eb}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK FB_PulseGenerator
VAR_INPUT
bEnable: BOOL; //Enables custom flash sequence
tFlashPeriod: TIME := T#1S; //Total time for one complete flash group
tOffTime: TIME := T#100MS; //Time lamp stays OFF between flashes
tOnTime: TIME := T#100MS; //Time lamp stays ON for each flash
nFlashCount: UINT := 1; //Number of flashes per flash group
END_VAR

VAR_OUTPUT
bOut: BOOL; //Flash lamp output
END_VAR

VAR
tonTimer: TON; //Internal flash timer
bTimerRun: BOOL; //Timer phase active
bInGap: BOOL; //Currently in gap after flash group
nFlashCounter: UINT; //Completed flashes in current group
tActiveTime: TIME; //Current active timer preset
tUsedFlashTime: TIME; //Total ON/OFF time used by flash group
tGapTime: TIME; //Remaining time between flash groups
nIndex: UINT; //Loop index
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[//Reset when disabled
IF NOT bEnable OR nFlashCount = 0 THEN
tonTimer(IN := FALSE, PT := T#0MS);
bOut := FALSE;
bTimerRun := FALSE;
bInGap := FALSE;
nFlashCounter := 0;
RETURN;
END_IF

//Calculate total time used by the configured flash group
tUsedFlashTime := T#0MS;

FOR nIndex := 1 TO nFlashCount DO
tUsedFlashTime := tUsedFlashTime + tOnTime + tOffTime;
END_FOR

//Calculate gap time after the flash group
IF tFlashPeriod > tUsedFlashTime THEN
tGapTime := tFlashPeriod - tUsedFlashTime;
ELSE
tGapTime := tOffTime; //Fallback gap if configured period is too short
END_IF

//Select active timer phase
IF bInGap THEN
tActiveTime := tGapTime;
bOut := FALSE;
ELSIF bOut THEN
tActiveTime := tOnTime;
ELSE
tActiveTime := tOffTime;
END_IF

//Start new timer phase
IF NOT bTimerRun THEN
bTimerRun := TRUE;
tonTimer(IN := FALSE, PT := tActiveTime);
END_IF

//Run timer
tonTimer(IN := TRUE, PT := tActiveTime);

//Phase complete
IF tonTimer.Q THEN
tonTimer(IN := FALSE, PT := tActiveTime);
bTimerRun := FALSE;

IF bInGap THEN
bInGap := FALSE;
nFlashCounter := 0;
bOut := TRUE; //Start next flash group directly after gap
ELSE
IF bOut THEN
bOut := FALSE;
nFlashCounter := nFlashCounter + 1;

IF nFlashCounter >= nFlashCount THEN
bInGap := TRUE;
END_IF
ELSE
bOut := TRUE;
END_IF
END_IF
END_IF
]]></ST>
</Implementation>
</POU>
</TcPlcObject>
Loading
Loading