From 55eb220fc70400f33cc9b0e462d0659436cab989 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Wed, 13 May 2026 14:01:55 +0200 Subject: [PATCH 01/11] MBP-388: Add DUTs specific to safety --- DUTs/Safety/ST_LEDState.TcDUT | 11 ++++++++++ DUTs/Safety/ST_PNOZEtherCATIn.TcDUT | 15 ++++++++++++++ DUTs/Safety/ST_PNOZEtherCATOut.TcDUT | 14 +++++++++++++ DUTs/Safety/ST_PNOZEtherCATStatus.TcDUT | 27 +++++++++++++++++++++++++ DUTs/Safety/ST_PNOZRawIn.TcDUT | 11 ++++++++++ DUTs/Safety/ST_PNOZRawOut.TcDUT | 11 ++++++++++ DUTs/Safety/ST_SafetyDiagnostics.TcDUT | 13 ++++++++++++ DUTs/Safety/ST_SafetyFeedback.TcDUT | 10 +++++++++ DUTs/Safety/ST_SafetyFunction.TcDUT | 12 +++++++++++ DUTs/Safety/ST_SafetyFunctionIn.TcDUT | 11 ++++++++++ DUTs/Safety/ST_SafetyFunctionOut.TcDUT | 11 ++++++++++ DUTs/Safety/ST_SequenceIn.TcDUT | 10 +++++++++ DUTs/Safety/ST_SequenceOut.TcDUT | 10 +++++++++ DUTs/Safety/ST_SubSystemIn.TcDUT | 19 +++++++++++++++++ DUTs/Safety/ST_SubSystemOut.TcDUT | 10 +++++++++ 15 files changed, 195 insertions(+) create mode 100644 DUTs/Safety/ST_LEDState.TcDUT create mode 100644 DUTs/Safety/ST_PNOZEtherCATIn.TcDUT create mode 100644 DUTs/Safety/ST_PNOZEtherCATOut.TcDUT create mode 100644 DUTs/Safety/ST_PNOZEtherCATStatus.TcDUT create mode 100644 DUTs/Safety/ST_PNOZRawIn.TcDUT create mode 100644 DUTs/Safety/ST_PNOZRawOut.TcDUT create mode 100644 DUTs/Safety/ST_SafetyDiagnostics.TcDUT create mode 100644 DUTs/Safety/ST_SafetyFeedback.TcDUT create mode 100644 DUTs/Safety/ST_SafetyFunction.TcDUT create mode 100644 DUTs/Safety/ST_SafetyFunctionIn.TcDUT create mode 100644 DUTs/Safety/ST_SafetyFunctionOut.TcDUT create mode 100644 DUTs/Safety/ST_SequenceIn.TcDUT create mode 100644 DUTs/Safety/ST_SequenceOut.TcDUT create mode 100644 DUTs/Safety/ST_SubSystemIn.TcDUT create mode 100644 DUTs/Safety/ST_SubSystemOut.TcDUT diff --git a/DUTs/Safety/ST_LEDState.TcDUT b/DUTs/Safety/ST_LEDState.TcDUT new file mode 100644 index 00000000..16e640f8 --- /dev/null +++ b/DUTs/Safety/ST_LEDState.TcDUT @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT b/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT new file mode 100644 index 00000000..94041aaa --- /dev/null +++ b/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT b/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT new file mode 100644 index 00000000..9981ce45 --- /dev/null +++ b/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/DUTs/Safety/ST_PNOZEtherCATStatus.TcDUT b/DUTs/Safety/ST_PNOZEtherCATStatus.TcDUT new file mode 100644 index 00000000..7e93c29a --- /dev/null +++ b/DUTs/Safety/ST_PNOZEtherCATStatus.TcDUT @@ -0,0 +1,27 @@ + + + + + + \ No newline at end of file diff --git a/DUTs/Safety/ST_PNOZRawIn.TcDUT b/DUTs/Safety/ST_PNOZRawIn.TcDUT new file mode 100644 index 00000000..51723dc7 --- /dev/null +++ b/DUTs/Safety/ST_PNOZRawIn.TcDUT @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/DUTs/Safety/ST_PNOZRawOut.TcDUT b/DUTs/Safety/ST_PNOZRawOut.TcDUT new file mode 100644 index 00000000..a2696777 --- /dev/null +++ b/DUTs/Safety/ST_PNOZRawOut.TcDUT @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/DUTs/Safety/ST_SafetyDiagnostics.TcDUT b/DUTs/Safety/ST_SafetyDiagnostics.TcDUT new file mode 100644 index 00000000..c44e6702 --- /dev/null +++ b/DUTs/Safety/ST_SafetyDiagnostics.TcDUT @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/DUTs/Safety/ST_SafetyFeedback.TcDUT b/DUTs/Safety/ST_SafetyFeedback.TcDUT new file mode 100644 index 00000000..427b88cd --- /dev/null +++ b/DUTs/Safety/ST_SafetyFeedback.TcDUT @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/DUTs/Safety/ST_SafetyFunction.TcDUT b/DUTs/Safety/ST_SafetyFunction.TcDUT new file mode 100644 index 00000000..6f968cd8 --- /dev/null +++ b/DUTs/Safety/ST_SafetyFunction.TcDUT @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/DUTs/Safety/ST_SafetyFunctionIn.TcDUT b/DUTs/Safety/ST_SafetyFunctionIn.TcDUT new file mode 100644 index 00000000..077c8b68 --- /dev/null +++ b/DUTs/Safety/ST_SafetyFunctionIn.TcDUT @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/DUTs/Safety/ST_SafetyFunctionOut.TcDUT b/DUTs/Safety/ST_SafetyFunctionOut.TcDUT new file mode 100644 index 00000000..26efa0d4 --- /dev/null +++ b/DUTs/Safety/ST_SafetyFunctionOut.TcDUT @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/DUTs/Safety/ST_SequenceIn.TcDUT b/DUTs/Safety/ST_SequenceIn.TcDUT new file mode 100644 index 00000000..b7a6ee84 --- /dev/null +++ b/DUTs/Safety/ST_SequenceIn.TcDUT @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/DUTs/Safety/ST_SequenceOut.TcDUT b/DUTs/Safety/ST_SequenceOut.TcDUT new file mode 100644 index 00000000..56488d27 --- /dev/null +++ b/DUTs/Safety/ST_SequenceOut.TcDUT @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/DUTs/Safety/ST_SubSystemIn.TcDUT b/DUTs/Safety/ST_SubSystemIn.TcDUT new file mode 100644 index 00000000..e26c6d60 --- /dev/null +++ b/DUTs/Safety/ST_SubSystemIn.TcDUT @@ -0,0 +1,19 @@ + + + + MCC = one or more subysystems +TYPE ST_SubSystemIn : +STRUCT + bEnabled : BOOL; + Done: BOOL; + Busy: BOOL; + Active: BOOL; + InVelocity: BOOL; + CommandAborted: BOOL; + Error: BOOL; + ErrorID: UDINT; +END_STRUCT +END_TYPE +]]> + + \ No newline at end of file diff --git a/DUTs/Safety/ST_SubSystemOut.TcDUT b/DUTs/Safety/ST_SubSystemOut.TcDUT new file mode 100644 index 00000000..894cfebe --- /dev/null +++ b/DUTs/Safety/ST_SubSystemOut.TcDUT @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file From d25f2e99022b86924f5f30089d685057a641fecc Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Wed, 13 May 2026 14:02:21 +0200 Subject: [PATCH 02/11] MBP-388: GVL safety IO layer --- GVLs/GVL_SafetyIO.TcGVL | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 GVLs/GVL_SafetyIO.TcGVL diff --git a/GVLs/GVL_SafetyIO.TcGVL b/GVLs/GVL_SafetyIO.TcGVL new file mode 100644 index 00000000..b5f92298 --- /dev/null +++ b/GVLs/GVL_SafetyIO.TcGVL @@ -0,0 +1,33 @@ + + + + + + \ No newline at end of file From c847018acbd9fc6ac7e9c4d0f197f65435790a94 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Wed, 13 May 2026 14:02:47 +0200 Subject: [PATCH 03/11] MBP-388: Function block for motion safety --- POUs/Safety/FB_MotionSafety.TcPOU | 106 ++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 POUs/Safety/FB_MotionSafety.TcPOU diff --git a/POUs/Safety/FB_MotionSafety.TcPOU b/POUs/Safety/FB_MotionSafety.TcPOU new file mode 100644 index 00000000..e4a2076a --- /dev/null +++ b/POUs/Safety/FB_MotionSafety.TcPOU @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From e55a040eeda126557d4d85d5eb711e4bc025ca26 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Mon, 18 May 2026 13:51:55 +0200 Subject: [PATCH 04/11] MBP-388: Update DUTs and GVL_SafetyIO --- DUTs/Safety/ST_PNOZEtherCATIn.TcDUT | 5 ++--- DUTs/Safety/ST_PNOZEtherCATOut.TcDUT | 3 +-- DUTs/Safety/ST_PNOZRawIn.TcDUT | 2 +- DUTs/Safety/ST_PNOZRawOut.TcDUT | 2 +- DUTs/Safety/ST_SafetyDiagnostics.TcDUT | 6 +++--- DUTs/Safety/ST_SafetyFunction.TcDUT | 4 ++-- DUTs/Safety/ST_SafetyStatus.TcDUT | 12 ++++++++++++ DUTs/Safety/ST_SequenceIn.TcDUT | 10 ---------- DUTs/Safety/ST_SequenceOut.TcDUT | 10 ---------- DUTs/Safety/ST_SubSystemIn.TcDUT | 8 -------- DUTs/Safety/ST_SubSystemOut.TcDUT | 3 ++- GVLs/GVL_SafetyIO.TcGVL | 5 +++-- 12 files changed, 27 insertions(+), 43 deletions(-) create mode 100644 DUTs/Safety/ST_SafetyStatus.TcDUT delete mode 100644 DUTs/Safety/ST_SequenceIn.TcDUT delete mode 100644 DUTs/Safety/ST_SequenceOut.TcDUT diff --git a/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT b/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT index 94041aaa..f39cefa4 100644 --- a/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT +++ b/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT @@ -4,10 +4,9 @@ diff --git a/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT b/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT index 9981ce45..1ed480a6 100644 --- a/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT +++ b/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT @@ -4,9 +4,8 @@ diff --git a/DUTs/Safety/ST_PNOZRawIn.TcDUT b/DUTs/Safety/ST_PNOZRawIn.TcDUT index 51723dc7..85095b13 100644 --- a/DUTs/Safety/ST_PNOZRawIn.TcDUT +++ b/DUTs/Safety/ST_PNOZRawIn.TcDUT @@ -3,7 +3,7 @@ diff --git a/DUTs/Safety/ST_PNOZRawOut.TcDUT b/DUTs/Safety/ST_PNOZRawOut.TcDUT index a2696777..ac2a1cc8 100644 --- a/DUTs/Safety/ST_PNOZRawOut.TcDUT +++ b/DUTs/Safety/ST_PNOZRawOut.TcDUT @@ -3,7 +3,7 @@ diff --git a/DUTs/Safety/ST_SafetyDiagnostics.TcDUT b/DUTs/Safety/ST_SafetyDiagnostics.TcDUT index c44e6702..89914205 100644 --- a/DUTs/Safety/ST_SafetyDiagnostics.TcDUT +++ b/DUTs/Safety/ST_SafetyDiagnostics.TcDUT @@ -3,9 +3,9 @@ diff --git a/DUTs/Safety/ST_SafetyFunction.TcDUT b/DUTs/Safety/ST_SafetyFunction.TcDUT index 6f968cd8..b27a3e97 100644 --- a/DUTs/Safety/ST_SafetyFunction.TcDUT +++ b/DUTs/Safety/ST_SafetyFunction.TcDUT @@ -3,8 +3,8 @@ diff --git a/DUTs/Safety/ST_SafetyStatus.TcDUT b/DUTs/Safety/ST_SafetyStatus.TcDUT new file mode 100644 index 00000000..6c6e9f32 --- /dev/null +++ b/DUTs/Safety/ST_SafetyStatus.TcDUT @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/DUTs/Safety/ST_SequenceIn.TcDUT b/DUTs/Safety/ST_SequenceIn.TcDUT deleted file mode 100644 index b7a6ee84..00000000 --- a/DUTs/Safety/ST_SequenceIn.TcDUT +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DUTs/Safety/ST_SequenceOut.TcDUT b/DUTs/Safety/ST_SequenceOut.TcDUT deleted file mode 100644 index 56488d27..00000000 --- a/DUTs/Safety/ST_SequenceOut.TcDUT +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DUTs/Safety/ST_SubSystemIn.TcDUT b/DUTs/Safety/ST_SubSystemIn.TcDUT index e26c6d60..9f61d181 100644 --- a/DUTs/Safety/ST_SubSystemIn.TcDUT +++ b/DUTs/Safety/ST_SubSystemIn.TcDUT @@ -4,14 +4,6 @@ MCC = one or more subysystems TYPE ST_SubSystemIn : STRUCT - bEnabled : BOOL; - Done: BOOL; - Busy: BOOL; - Active: BOOL; - InVelocity: BOOL; - CommandAborted: BOOL; - Error: BOOL; - ErrorID: UDINT; END_STRUCT END_TYPE ]]> diff --git a/DUTs/Safety/ST_SubSystemOut.TcDUT b/DUTs/Safety/ST_SubSystemOut.TcDUT index 894cfebe..003c4b84 100644 --- a/DUTs/Safety/ST_SubSystemOut.TcDUT +++ b/DUTs/Safety/ST_SubSystemOut.TcDUT @@ -1,7 +1,8 @@  - MCC = one or more subysystems +TYPE ST_SubSystemOut : STRUCT END_STRUCT END_TYPE diff --git a/GVLs/GVL_SafetyIO.TcGVL b/GVLs/GVL_SafetyIO.TcGVL index b5f92298..e6328fc4 100644 --- a/GVLs/GVL_SafetyIO.TcGVL +++ b/GVLs/GVL_SafetyIO.TcGVL @@ -21,8 +21,9 @@ VAR_GLOBAL END_VAR VAR_GLOBAL CONSTANT - UPPER_BOUND_SF : UINT := 32; // Number of safety functions - UPPER_BOUND_SS : UINT := 2; // Number of subsystems + UPPER_BOUND_SF_INPUT : UINT := 32; // Number of input safety functions + UPPER_BOUND_SF_OUTPUT : UINT := 19; // Number of output safety functions + UPPER_BOUND_SS : UINT := 2; // Number of subsystems, Placeholder, WIP END_VAR From 9227db16658c9816fb7bf194967480c229d12ea9 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Mon, 18 May 2026 13:52:31 +0200 Subject: [PATCH 05/11] MBP-388: Update safety function block --- POUs/Safety/FB_MotionSafety.TcPOU | 93 ++++++++++++++++++++----------- 1 file changed, 62 insertions(+), 31 deletions(-) diff --git a/POUs/Safety/FB_MotionSafety.TcPOU b/POUs/Safety/FB_MotionSafety.TcPOU index e4a2076a..31b3e077 100644 --- a/POUs/Safety/FB_MotionSafety.TcPOU +++ b/POUs/Safety/FB_MotionSafety.TcPOU @@ -3,7 +3,7 @@ - @@ -64,25 +82,15 @@ VAR END_VAR]]> - + + + + + + + From 14379747abb5d602f8906cfed338df291bfbc80f Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Mon, 18 May 2026 16:19:20 +0200 Subject: [PATCH 06/11] MBP-388: Fix pipeline --- POUs/Safety/FB_MotionSafety.TcPOU | 41 ++++++++++++++++--------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/POUs/Safety/FB_MotionSafety.TcPOU b/POUs/Safety/FB_MotionSafety.TcPOU index 31b3e077..01a1ac30 100644 --- a/POUs/Safety/FB_MotionSafety.TcPOU +++ b/POUs/Safety/FB_MotionSafety.TcPOU @@ -14,25 +14,26 @@ VAR stSafetyStatus : ST_SafetyStatus; // Placeholder, WIP stSafetyFeedback : ST_SafetyFeedback; // Placeholder, WIP stSafetyDiagnostics : ST_SafetyDiagnostics; - + i : UINT := 1; //Index for, for loops bRefsLinked : BOOL := FALSE; - bInputBitsHasBeenRead : BOOL := FALSE; - -END_VAR]]> + bInputBitsHasBeenRead : BOOL := FALSE; + +END_VAR +]]> @@ -64,7 +63,7 @@ END_VAR // ----------------------------------------------------------------------------- IF NOT __ISVALIDREF(stMCCSafetyFunctions) THEN - mLinkRefs := FALSE; + mLinkRefs := FALSE; RETURN; END_IF @@ -73,13 +72,15 @@ FOR i := 1 TO GVL_SafetyIO.UPPER_BOUND_SF_INPUT DO stMCCSafetyFunctions.aSafetyFunction[i].refSafetyOut REF=stECATOut.aSafetyFunctionOut[i]; END_FOR; -mLinkRefs := TRUE;]]> +mLinkRefs := TRUE; +]]> +END_VAR +]]> +mReadECATInput := TRUE; +]]> @@ -106,7 +108,6 @@ END_VAR @@ -121,7 +122,7 @@ END_VAR // raw PNOZ EtherCAT output in GVL_SafetyIO. // // Includes sending/showcasing variables to EPICS/NICOS. MCC-specific rules -// should write to stECATOut before this method is called. +// should write to stECATOut before this method is called. // ----------------------------------------------------------------------------- // Copy formatted safety function output data into raw PNOZ EtherCAT output @@ -129,8 +130,8 @@ FOR i := 1 TO GVL_SafetyIO.UPPER_BOUND_SF_OUTPUT DO GVL_SafetyIO.stPNOZRawOut.aSafetyFunction[i] := stECATOut.aSafetyFunctionOut[i]; END_FOR; - -mWriteECATOutput := TRUE;]]> +mWriteECATOutput := TRUE; +]]> From 9dc2fe4c176ac2fec27ee1ec8f59c636bdc0927f Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Thu, 10 Sep 2026 10:01:20 +0200 Subject: [PATCH 07/11] MBP-388: Add technosoft related function/method --- DUTs/ST_TechnosoftMotionError.TcDUT | 26 +++++++++++++++++++++ POUs/Safety/F_TechnosoftErrorActive.TcPOU | 28 +++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 DUTs/ST_TechnosoftMotionError.TcDUT create mode 100644 POUs/Safety/F_TechnosoftErrorActive.TcPOU diff --git a/DUTs/ST_TechnosoftMotionError.TcDUT b/DUTs/ST_TechnosoftMotionError.TcDUT new file mode 100644 index 00000000..20283539 --- /dev/null +++ b/DUTs/ST_TechnosoftMotionError.TcDUT @@ -0,0 +1,26 @@ + + + + + + \ No newline at end of file diff --git a/POUs/Safety/F_TechnosoftErrorActive.TcPOU b/POUs/Safety/F_TechnosoftErrorActive.TcPOU new file mode 100644 index 00000000..e5f5b3c7 --- /dev/null +++ b/POUs/Safety/F_TechnosoftErrorActive.TcPOU @@ -0,0 +1,28 @@ + + + + + + + + + \ No newline at end of file From 3a6df73ee180f97b93bbbdaacf8a56e21b46a14e Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Thu, 10 Sep 2026 10:03:48 +0200 Subject: [PATCH 08/11] MBP-388: Move reusable motion safety into std_lib --- DUTs/Safety/I_SafetyProvider.TcIO | 33 ++ DUTs/Safety/PNOZ/ST_LEDState.TcDUT | 19 + DUTs/Safety/PNOZ/ST_MCCStatusIn.TcDUT | 27 ++ DUTs/Safety/PNOZ/ST_MCCStatusOut.TcDUT | 27 ++ DUTs/Safety/PNOZ/ST_PNOZCommDiag.TcDUT | 13 + DUTs/Safety/PNOZ/ST_PNOZEtherCATIn.TcDUT | 15 + DUTs/Safety/PNOZ/ST_PNOZEtherCATOut.TcDUT | 14 + DUTs/Safety/PNOZ/ST_SafetyFunctionIn.TcDUT | 14 + DUTs/Safety/PNOZ/ST_SafetyFunctionOut.TcDUT | 14 + DUTs/Safety/ST_Safety.TcDUT | 12 + DUTs/Safety/ST_SafetyIn.TcDUT | 16 + DUTs/Safety/ST_SafetyOut.TcDUT | 16 + GVLs/GVL_Safety.TcGVL | 14 + POUs/FB_PulseGenerator.TcPOU | 97 +++++ POUs/Safety/FB_MotionSafety.TcPOU | 411 ++++++++++++++++---- 15 files changed, 664 insertions(+), 78 deletions(-) create mode 100644 DUTs/Safety/I_SafetyProvider.TcIO create mode 100644 DUTs/Safety/PNOZ/ST_LEDState.TcDUT create mode 100644 DUTs/Safety/PNOZ/ST_MCCStatusIn.TcDUT create mode 100644 DUTs/Safety/PNOZ/ST_MCCStatusOut.TcDUT create mode 100644 DUTs/Safety/PNOZ/ST_PNOZCommDiag.TcDUT create mode 100644 DUTs/Safety/PNOZ/ST_PNOZEtherCATIn.TcDUT create mode 100644 DUTs/Safety/PNOZ/ST_PNOZEtherCATOut.TcDUT create mode 100644 DUTs/Safety/PNOZ/ST_SafetyFunctionIn.TcDUT create mode 100644 DUTs/Safety/PNOZ/ST_SafetyFunctionOut.TcDUT create mode 100644 DUTs/Safety/ST_Safety.TcDUT create mode 100644 DUTs/Safety/ST_SafetyIn.TcDUT create mode 100644 DUTs/Safety/ST_SafetyOut.TcDUT create mode 100644 GVLs/GVL_Safety.TcGVL create mode 100644 POUs/FB_PulseGenerator.TcPOU diff --git a/DUTs/Safety/I_SafetyProvider.TcIO b/DUTs/Safety/I_SafetyProvider.TcIO new file mode 100644 index 00000000..5f38ecf9 --- /dev/null +++ b/DUTs/Safety/I_SafetyProvider.TcIO @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DUTs/Safety/PNOZ/ST_LEDState.TcDUT b/DUTs/Safety/PNOZ/ST_LEDState.TcDUT new file mode 100644 index 00000000..803ccbe8 --- /dev/null +++ b/DUTs/Safety/PNOZ/ST_LEDState.TcDUT @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/DUTs/Safety/PNOZ/ST_MCCStatusIn.TcDUT b/DUTs/Safety/PNOZ/ST_MCCStatusIn.TcDUT new file mode 100644 index 00000000..c84c1c1c --- /dev/null +++ b/DUTs/Safety/PNOZ/ST_MCCStatusIn.TcDUT @@ -0,0 +1,27 @@ + + + + IPC, will not change from cabinet to cabinet +TYPE ST_MCCStatusIn : +STRUCT + bit0_Heartbeat: BIT; //The loop-back signal of the heartbeat signal from the PLC-to-PNOZ-to-PLC. + bit1_EStopOK: BIT; //If no E-Stop connected to this cabinet is pressed, this bit is TRUE. When pressed, it is FALSE. + bit2_Remote: 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. + bit3_Fault: BIT; //Feedback to safety controller that fault has been acknowledged + bit4_Reserved: BIT; + bit5_Reserved: BIT; + bit6_Reserved: BIT; + bit7_Reserved: BIT; + bit8_Reserved: BIT; + bit9_Reserved: BIT; + bit10_Reserved: BIT; + bit11_Reserved: BIT; + bit12_Reserved: BIT; + bit13_Reserved: BIT; + bit14_Reserved: BIT; + bit15_Reserved: BIT; +END_STRUCT +END_TYPE +]]> + + \ No newline at end of file diff --git a/DUTs/Safety/PNOZ/ST_MCCStatusOut.TcDUT b/DUTs/Safety/PNOZ/ST_MCCStatusOut.TcDUT new file mode 100644 index 00000000..f65ba8fc --- /dev/null +++ b/DUTs/Safety/PNOZ/ST_MCCStatusOut.TcDUT @@ -0,0 +1,27 @@ + + + + PNOZ, will not change from cabinet to cabinet +TYPE ST_MCCStatusOut : +STRUCT + bit0_Heartbeat: BIT; //Pulsed every ~200ms by the PLC-to-PNOZ, the PNOZ is expected to loop back this signal. + bit1_Reserved: BIT; + bit2_Reserved: BIT; + bit3_ErrAck: BIT; //If there is a fault requiring intervention (from cabinet), CabAck will clear it + bit4_Reserved: BIT; + bit5_Reserved: BIT; + bit6_STOFbk: BIT; + bit7_STO_OK: BIT; + bit8_Reserved: BIT; + bit9_Reserved: BIT; + bit10_Reserved: BIT; + bit11_Reserved: BIT; + bit12_Reserved: BIT; + bit13_Reserved: BIT; + bit14_Reserved: BIT; + bit15_Reserved: BIT; +END_STRUCT +END_TYPE +]]> + + \ No newline at end of file diff --git a/DUTs/Safety/PNOZ/ST_PNOZCommDiag.TcDUT b/DUTs/Safety/PNOZ/ST_PNOZCommDiag.TcDUT new file mode 100644 index 00000000..4c2dc0df --- /dev/null +++ b/DUTs/Safety/PNOZ/ST_PNOZCommDiag.TcDUT @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/DUTs/Safety/PNOZ/ST_PNOZEtherCATIn.TcDUT b/DUTs/Safety/PNOZ/ST_PNOZEtherCATIn.TcDUT new file mode 100644 index 00000000..06dbe382 --- /dev/null +++ b/DUTs/Safety/PNOZ/ST_PNOZEtherCATIn.TcDUT @@ -0,0 +1,15 @@ + + + + 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.cNUM_OF_SAFETY_FUNCTIONS] OF ST_SafetyFunctionIn; //Input Byte 04..15 + stLEDState: ST_LEDState; //Input Byte 16 +END_STRUCT +END_TYPE +]]> + + \ No newline at end of file diff --git a/DUTs/Safety/PNOZ/ST_PNOZEtherCATOut.TcDUT b/DUTs/Safety/PNOZ/ST_PNOZEtherCATOut.TcDUT new file mode 100644 index 00000000..6ddbc047 --- /dev/null +++ b/DUTs/Safety/PNOZ/ST_PNOZEtherCATOut.TcDUT @@ -0,0 +1,14 @@ + + + + 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 + aSafetyFunctionOut: ARRAY[1..GVL_APP.cNUM_OF_SAFETY_FUNCTIONS] OF ST_SafetyFunctionOut; //Output Byte 04..15 +END_STRUCT +END_TYPE +]]> + + \ No newline at end of file diff --git a/DUTs/Safety/PNOZ/ST_SafetyFunctionIn.TcDUT b/DUTs/Safety/PNOZ/ST_SafetyFunctionIn.TcDUT new file mode 100644 index 00000000..11d425a2 --- /dev/null +++ b/DUTs/Safety/PNOZ/ST_SafetyFunctionIn.TcDUT @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/DUTs/Safety/PNOZ/ST_SafetyFunctionOut.TcDUT b/DUTs/Safety/PNOZ/ST_SafetyFunctionOut.TcDUT new file mode 100644 index 00000000..ff8ff01b --- /dev/null +++ b/DUTs/Safety/PNOZ/ST_SafetyFunctionOut.TcDUT @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/DUTs/Safety/ST_Safety.TcDUT b/DUTs/Safety/ST_Safety.TcDUT new file mode 100644 index 00000000..09f0993a --- /dev/null +++ b/DUTs/Safety/ST_Safety.TcDUT @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/DUTs/Safety/ST_SafetyIn.TcDUT b/DUTs/Safety/ST_SafetyIn.TcDUT new file mode 100644 index 00000000..89b2ee1b --- /dev/null +++ b/DUTs/Safety/ST_SafetyIn.TcDUT @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/DUTs/Safety/ST_SafetyOut.TcDUT b/DUTs/Safety/ST_SafetyOut.TcDUT new file mode 100644 index 00000000..37672295 --- /dev/null +++ b/DUTs/Safety/ST_SafetyOut.TcDUT @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/GVLs/GVL_Safety.TcGVL b/GVLs/GVL_Safety.TcGVL new file mode 100644 index 00000000..8430e5a8 --- /dev/null +++ b/GVLs/GVL_Safety.TcGVL @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/POUs/FB_PulseGenerator.TcPOU b/POUs/FB_PulseGenerator.TcPOU new file mode 100644 index 00000000..9f0771b9 --- /dev/null +++ b/POUs/FB_PulseGenerator.TcPOU @@ -0,0 +1,97 @@ + + + + + + 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; + fbTimer(IN := FALSE, PT := tActiveTime); +END_IF + +//Run timer +fbTimer(IN := TRUE, PT := tActiveTime); + +//Phase complete +IF fbTimer.Q THEN + fbTimer(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 +]]> + + + \ No newline at end of file diff --git a/POUs/Safety/FB_MotionSafety.TcPOU b/POUs/Safety/FB_MotionSafety.TcPOU index 01a1ac30..7c5dea18 100644 --- a/POUs/Safety/FB_MotionSafety.TcPOU +++ b/POUs/Safety/FB_MotionSafety.TcPOU @@ -1,138 +1,393 @@  - - + - stSafety.stSafetyOut.stMCCStatusOut.bit0_Heartbeat, + bWatchdogFault => bMCCWatchdogFault + ); //Reset heartbeat generation and watchdog memory + + stSafety.stSafetyOut.stMCCStatusOut.bit3_ErrAck := FALSE; //Clear fault-acknowledge command + + fbSafetyAckLedPulse( + bEnable := FALSE, + bOut => bSafetyAcknowledgeLED + ); //Reset pulse generator and physical LED + + mHandleMotionPermission(); //Process falling edge of motion permission + RETURN; +END_IF; + +mReadInputs(stSafetyData := stSafety); +bDataValid := TRUE; + +mMCCStatus(stSafetyData := stSafety); //Heartbeat generation and MCC watchdog check +mTechnosoftStatus(stSafetyData := stSafety); + +mUpdateFaultFeedback(stSafetyData := stSafety); //Fault/Err Ack. handshake +mHandleMotionPermission(); + +]]> + + + + + 100.0 THEN + fPWClamped := 100.0; END_IF -stSafetyStatus.bValidReference := bRefsLinked; +//Convert heartbeat period and pulse width into ON time +tHeartbeatOnTime := LREAL_TO_TIME(TIME_TO_LREAL(tHeartbeatPeriod) * fPWClamped / 100.0); + +//Generate heartbeat output +tHeartbeatElapsed := tHeartbeatElapsed + tTaskCycleTime; -IF NOT stSafetyStatus.bValidReference THEN - RETURN; +IF tHeartbeatElapsed >= tHeartbeatPeriod THEN + tHeartbeatElapsed := tHeartbeatElapsed - tHeartbeatPeriod; END_IF -// EtherCAT communication diagnostics -stSafetyDiagnostics.bitWcState := GVL_SafetyIO.stPNOZEtherCATStatus.bitWcState; -stSafetyDiagnostics.bitInputToggle := GVL_SafetyIO.stPNOZEtherCATStatus.bitInputToggle; -stSafetyDiagnostics.nEtherCATState := GVL_SafetyIO.stPNOZEtherCATStatus.nState; +bHeartbeatOut := tHeartbeatElapsed < tHeartbeatOnTime; -IF stSafetyDiagnostics.bitWcState THEN - stSafetyStatus.bPNOZCommunicationError := (stSafetyDiagnostics.bitWcState = 1); - RETURN; +//Initialize watchdog memory on first enabled scan +IF NOT bMCCHeartbeatInit THEN + bMCCHeartbeatInOld := bHeartbeatIn; + tMCCWatchdogElapsed := T#0MS; + bMCCHeartbeatInit := TRUE; +END_IF + +//Watch incoming heartbeat for any change, rising or falling +IF bHeartbeatIn <> bMCCHeartbeatInOld THEN + bMCCHeartbeatInOld := bHeartbeatIn; + tMCCWatchdogElapsed := T#0MS; +ELSE + IF tMCCWatchdogElapsed < tWatchdogTime THEN + tMCCWatchdogElapsed := tMCCWatchdogElapsed + tTaskCycleTime; + END_IF END_IF +//Watchdog result +bWatchdogFault := tMCCWatchdogElapsed >= tWatchdogTime; -mReadECATInput(); // Cyclic status update -mReadInputBits(); // Read input bits of each byte, each byte represents a safety function from the PNOZmulti 2 +mCheckMCCHeartbeat := NOT bWatchdogFault; ]]> - - - + + + - + + + + + + stSafetyData.stSafetyOut.stMCCStatusOut.bit0_Heartbeat, + bWatchdogFault => bMCCWatchdogFault +); + +bAxisEnableAllowed := + stSafetyData.stSafetyIn.stMCCStatusIn.bit1_EStopOK + AND bMCC_OK; +]]> + + + + + + 0 THEN + FOR i := 1 TO GVL_APP.cNUM_OF_TECHNOSOFT DO + stSafetyData.stSafetyIn.astTechnosoftMotionError[i] := + astTechnosoftMotionError[i]; + END_FOR END_IF -FOR i := 1 TO GVL_SafetyIO.UPPER_BOUND_SF_INPUT DO - stMCCSafetyFunctions.aSafetyFunction[i].refSafetyIn REF=stECATIn.aSafetyFunctionIn[i]; - stMCCSafetyFunctions.aSafetyFunction[i].refSafetyOut REF=stECATOut.aSafetyFunctionOut[i]; -END_FOR; +_bEStopOK := stSafetyData.stSafetyIn.stMCCStatusIn.bit1_EStopOK; -mLinkRefs := TRUE; ]]> - - + + + + + + + - 0 THEN + FOR nAxes := 1 TO GVL_APP.cNUM_OF_TECHNOSOFT DO + stSafetyData.stSafetyOut.bSTOActive := + stSafetyData.stSafetyOut.bSTOActive + OR stSafetyData.stSafetyIn.astTechnosoftMotionError[nAxes].bit15_STOActive; -// Copy raw PNOZ EtherCAT safety function input into formatted PLC-side structure -FOR i := 1 TO GVL_SafetyIO.UPPER_BOUND_SF_INPUT DO - stECATIn.aSafetyFunctionIn[i] := GVL_SafetyIO.stPNOZRawIn.aSafetyFunction[i]; -END_FOR; + stSafetyData.stSafetyOut.bTechnosoftMotionErrors := + stSafetyData.stSafetyOut.bTechnosoftMotionErrors + OR F_TechnosoftErrorActive(stError := stSafetyData.stSafetyIn.astTechnosoftMotionError[nAxes]); + END_FOR +END_IF -// LED State -stECATIn.stLEDState.usiLEDState := GVL_SafetyIO.stLEDState.usiLEDState; +IF GVL_APP.cNUM_OF_TECHNOSOFT <> 0 THEN + stSafetyData.stSafetyOut.stMCCStatusOut.bit6_STOFbk := + stSafetyData.stSafetyOut.bSTOActive; //TRUE when any Technosoft drive reports STO active -mReadECATInput := TRUE; + stSafetyData.stSafetyOut.stMCCStatusOut.bit7_STO_OK := + NOT stSafetyData.stSafetyOut.bTechnosoftMotionErrors; //Preserve the existing no-motion-error feedback +END_IF ]]> - - + - bSafetyAcknowledgeLED); ]]> - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From d3a46c94b47f946227a67b5b8a8c71be988ff8a2 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Thu, 10 Sep 2026 10:06:02 +0200 Subject: [PATCH 09/11] MBP-388: Fix double square brackets --- POUs/Safety/F_TechnosoftErrorActive.TcPOU | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/POUs/Safety/F_TechnosoftErrorActive.TcPOU b/POUs/Safety/F_TechnosoftErrorActive.TcPOU index e5f5b3c7..9945348e 100644 --- a/POUs/Safety/F_TechnosoftErrorActive.TcPOU +++ b/POUs/Safety/F_TechnosoftErrorActive.TcPOU @@ -4,7 +4,8 @@ +END_VAR +]]> Date: Thu, 10 Sep 2026 10:30:29 +0200 Subject: [PATCH 10/11] MBP-388: Remove old files --- DUTs/Safety/ST_LEDState.TcDUT | 11 -------- DUTs/Safety/ST_PNOZEtherCATIn.TcDUT | 14 ---------- DUTs/Safety/ST_PNOZEtherCATOut.TcDUT | 13 ---------- DUTs/Safety/ST_PNOZEtherCATStatus.TcDUT | 27 -------------------- DUTs/Safety/ST_PNOZRawIn.TcDUT | 11 -------- DUTs/Safety/ST_PNOZRawOut.TcDUT | 11 -------- DUTs/Safety/ST_SafetyDiagnostics.TcDUT | 13 ---------- DUTs/Safety/ST_SafetyFeedback.TcDUT | 10 -------- DUTs/Safety/ST_SafetyFunction.TcDUT | 12 --------- DUTs/Safety/ST_SafetyFunctionIn.TcDUT | 11 -------- DUTs/Safety/ST_SafetyFunctionOut.TcDUT | 11 -------- DUTs/Safety/ST_SafetyStatus.TcDUT | 12 --------- DUTs/Safety/ST_SubSystemIn.TcDUT | 11 -------- DUTs/Safety/ST_SubSystemOut.TcDUT | 11 -------- GVLs/GVL_SafetyIO.TcGVL | 34 ------------------------- 15 files changed, 212 deletions(-) delete mode 100644 DUTs/Safety/ST_LEDState.TcDUT delete mode 100644 DUTs/Safety/ST_PNOZEtherCATIn.TcDUT delete mode 100644 DUTs/Safety/ST_PNOZEtherCATOut.TcDUT delete mode 100644 DUTs/Safety/ST_PNOZEtherCATStatus.TcDUT delete mode 100644 DUTs/Safety/ST_PNOZRawIn.TcDUT delete mode 100644 DUTs/Safety/ST_PNOZRawOut.TcDUT delete mode 100644 DUTs/Safety/ST_SafetyDiagnostics.TcDUT delete mode 100644 DUTs/Safety/ST_SafetyFeedback.TcDUT delete mode 100644 DUTs/Safety/ST_SafetyFunction.TcDUT delete mode 100644 DUTs/Safety/ST_SafetyFunctionIn.TcDUT delete mode 100644 DUTs/Safety/ST_SafetyFunctionOut.TcDUT delete mode 100644 DUTs/Safety/ST_SafetyStatus.TcDUT delete mode 100644 DUTs/Safety/ST_SubSystemIn.TcDUT delete mode 100644 DUTs/Safety/ST_SubSystemOut.TcDUT delete mode 100644 GVLs/GVL_SafetyIO.TcGVL diff --git a/DUTs/Safety/ST_LEDState.TcDUT b/DUTs/Safety/ST_LEDState.TcDUT deleted file mode 100644 index 16e640f8..00000000 --- a/DUTs/Safety/ST_LEDState.TcDUT +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT b/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT deleted file mode 100644 index f39cefa4..00000000 --- a/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT b/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT deleted file mode 100644 index 1ed480a6..00000000 --- a/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DUTs/Safety/ST_PNOZEtherCATStatus.TcDUT b/DUTs/Safety/ST_PNOZEtherCATStatus.TcDUT deleted file mode 100644 index 7e93c29a..00000000 --- a/DUTs/Safety/ST_PNOZEtherCATStatus.TcDUT +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DUTs/Safety/ST_PNOZRawIn.TcDUT b/DUTs/Safety/ST_PNOZRawIn.TcDUT deleted file mode 100644 index 85095b13..00000000 --- a/DUTs/Safety/ST_PNOZRawIn.TcDUT +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DUTs/Safety/ST_PNOZRawOut.TcDUT b/DUTs/Safety/ST_PNOZRawOut.TcDUT deleted file mode 100644 index ac2a1cc8..00000000 --- a/DUTs/Safety/ST_PNOZRawOut.TcDUT +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DUTs/Safety/ST_SafetyDiagnostics.TcDUT b/DUTs/Safety/ST_SafetyDiagnostics.TcDUT deleted file mode 100644 index 89914205..00000000 --- a/DUTs/Safety/ST_SafetyDiagnostics.TcDUT +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DUTs/Safety/ST_SafetyFeedback.TcDUT b/DUTs/Safety/ST_SafetyFeedback.TcDUT deleted file mode 100644 index 427b88cd..00000000 --- a/DUTs/Safety/ST_SafetyFeedback.TcDUT +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DUTs/Safety/ST_SafetyFunction.TcDUT b/DUTs/Safety/ST_SafetyFunction.TcDUT deleted file mode 100644 index b27a3e97..00000000 --- a/DUTs/Safety/ST_SafetyFunction.TcDUT +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DUTs/Safety/ST_SafetyFunctionIn.TcDUT b/DUTs/Safety/ST_SafetyFunctionIn.TcDUT deleted file mode 100644 index 077c8b68..00000000 --- a/DUTs/Safety/ST_SafetyFunctionIn.TcDUT +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DUTs/Safety/ST_SafetyFunctionOut.TcDUT b/DUTs/Safety/ST_SafetyFunctionOut.TcDUT deleted file mode 100644 index 26efa0d4..00000000 --- a/DUTs/Safety/ST_SafetyFunctionOut.TcDUT +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DUTs/Safety/ST_SafetyStatus.TcDUT b/DUTs/Safety/ST_SafetyStatus.TcDUT deleted file mode 100644 index 6c6e9f32..00000000 --- a/DUTs/Safety/ST_SafetyStatus.TcDUT +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DUTs/Safety/ST_SubSystemIn.TcDUT b/DUTs/Safety/ST_SubSystemIn.TcDUT deleted file mode 100644 index 9f61d181..00000000 --- a/DUTs/Safety/ST_SubSystemIn.TcDUT +++ /dev/null @@ -1,11 +0,0 @@ - - - - MCC = one or more subysystems -TYPE ST_SubSystemIn : -STRUCT -END_STRUCT -END_TYPE -]]> - - \ No newline at end of file diff --git a/DUTs/Safety/ST_SubSystemOut.TcDUT b/DUTs/Safety/ST_SubSystemOut.TcDUT deleted file mode 100644 index 003c4b84..00000000 --- a/DUTs/Safety/ST_SubSystemOut.TcDUT +++ /dev/null @@ -1,11 +0,0 @@ - - - - MCC = one or more subysystems -TYPE ST_SubSystemOut : -STRUCT -END_STRUCT -END_TYPE -]]> - - \ No newline at end of file diff --git a/GVLs/GVL_SafetyIO.TcGVL b/GVLs/GVL_SafetyIO.TcGVL deleted file mode 100644 index e6328fc4..00000000 --- a/GVLs/GVL_SafetyIO.TcGVL +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - \ No newline at end of file From a3885460b67f0d7b8c971d8186217799f86b93ce Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Fri, 11 Sep 2026 12:52:31 +0200 Subject: [PATCH 11/11] MBP-388: Update to follow coding standard --- DUTs/ST_TechnosoftMotionError.TcDUT | 32 +- DUTs/Safety/I_SafetyProvider.TcIO | 12 +- DUTs/Safety/PNOZ/ST_LEDState.TcDUT | 16 +- DUTs/Safety/PNOZ/ST_MCCStatusIn.TcDUT | 32 +- DUTs/Safety/PNOZ/ST_MCCStatusOut.TcDUT | 32 +- DUTs/Safety/PNOZ/ST_PNOZEtherCATIn.TcDUT | 2 +- DUTs/Safety/PNOZ/ST_PNOZEtherCATOut.TcDUT | 2 +- DUTs/Safety/PNOZ/ST_SafetyFunctionIn.TcDUT | 8 +- DUTs/Safety/PNOZ/ST_SafetyFunctionOut.TcDUT | 8 +- DUTs/Safety/ST_SafetyIn.TcDUT | 4 +- DUTs/Safety/ST_SafetyOut.TcDUT | 2 +- POUs/FB_PulseGenerator.TcPOU | 12 +- POUs/Monitoring/FB_ZoneMonitoring.TcPOU | 327 ++++++++++++++++++++ POUs/Safety/FB_MotionSafety.TcPOU | 108 +++---- POUs/Safety/F_TechnosoftErrorActive.TcPOU | 30 +- 15 files changed, 477 insertions(+), 150 deletions(-) create mode 100644 POUs/Monitoring/FB_ZoneMonitoring.TcPOU diff --git a/DUTs/ST_TechnosoftMotionError.TcDUT b/DUTs/ST_TechnosoftMotionError.TcDUT index 20283539..18d9a89e 100644 --- a/DUTs/ST_TechnosoftMotionError.TcDUT +++ b/DUTs/ST_TechnosoftMotionError.TcDUT @@ -3,22 +3,22 @@ diff --git a/DUTs/Safety/I_SafetyProvider.TcIO b/DUTs/Safety/I_SafetyProvider.TcIO index 5f38ecf9..6216f7fc 100644 --- a/DUTs/Safety/I_SafetyProvider.TcIO +++ b/DUTs/Safety/I_SafetyProvider.TcIO @@ -5,24 +5,24 @@ ]]> - - + - - + - - + diff --git a/DUTs/Safety/PNOZ/ST_MCCStatusIn.TcDUT b/DUTs/Safety/PNOZ/ST_MCCStatusIn.TcDUT index c84c1c1c..5c8f54e5 100644 --- a/DUTs/Safety/PNOZ/ST_MCCStatusIn.TcDUT +++ b/DUTs/Safety/PNOZ/ST_MCCStatusIn.TcDUT @@ -4,22 +4,22 @@ IPC, will not change from cabinet to cabinet TYPE ST_MCCStatusIn : STRUCT - bit0_Heartbeat: BIT; //The loop-back signal of the heartbeat signal from the PLC-to-PNOZ-to-PLC. - bit1_EStopOK: BIT; //If no E-Stop connected to this cabinet is pressed, this bit is TRUE. When pressed, it is FALSE. - bit2_Remote: 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. - bit3_Fault: BIT; //Feedback to safety controller that fault has been acknowledged - bit4_Reserved: BIT; - bit5_Reserved: BIT; - bit6_Reserved: BIT; - bit7_Reserved: BIT; - bit8_Reserved: BIT; - bit9_Reserved: BIT; - bit10_Reserved: BIT; - bit11_Reserved: BIT; - bit12_Reserved: BIT; - bit13_Reserved: BIT; - bit14_Reserved: BIT; - bit15_Reserved: BIT; + 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 ]]> diff --git a/DUTs/Safety/PNOZ/ST_MCCStatusOut.TcDUT b/DUTs/Safety/PNOZ/ST_MCCStatusOut.TcDUT index f65ba8fc..ef8a4697 100644 --- a/DUTs/Safety/PNOZ/ST_MCCStatusOut.TcDUT +++ b/DUTs/Safety/PNOZ/ST_MCCStatusOut.TcDUT @@ -4,22 +4,22 @@ PNOZ, will not change from cabinet to cabinet TYPE ST_MCCStatusOut : STRUCT - bit0_Heartbeat: BIT; //Pulsed every ~200ms by the PLC-to-PNOZ, the PNOZ is expected to loop back this signal. - bit1_Reserved: BIT; - bit2_Reserved: BIT; - bit3_ErrAck: BIT; //If there is a fault requiring intervention (from cabinet), CabAck will clear it - bit4_Reserved: BIT; - bit5_Reserved: BIT; - bit6_STOFbk: BIT; - bit7_STO_OK: BIT; - bit8_Reserved: BIT; - bit9_Reserved: BIT; - bit10_Reserved: BIT; - bit11_Reserved: BIT; - bit12_Reserved: BIT; - bit13_Reserved: BIT; - bit14_Reserved: BIT; - bit15_Reserved: BIT; + 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 ]]> diff --git a/DUTs/Safety/PNOZ/ST_PNOZEtherCATIn.TcDUT b/DUTs/Safety/PNOZ/ST_PNOZEtherCATIn.TcDUT index 06dbe382..abbef8e8 100644 --- a/DUTs/Safety/PNOZ/ST_PNOZEtherCATIn.TcDUT +++ b/DUTs/Safety/PNOZ/ST_PNOZEtherCATIn.TcDUT @@ -6,7 +6,7 @@ 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.cNUM_OF_SAFETY_FUNCTIONS] OF ST_SafetyFunctionIn; //Input Byte 04..15 + 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 diff --git a/DUTs/Safety/PNOZ/ST_PNOZEtherCATOut.TcDUT b/DUTs/Safety/PNOZ/ST_PNOZEtherCATOut.TcDUT index 6ddbc047..df215d62 100644 --- a/DUTs/Safety/PNOZ/ST_PNOZEtherCATOut.TcDUT +++ b/DUTs/Safety/PNOZ/ST_PNOZEtherCATOut.TcDUT @@ -6,7 +6,7 @@ TYPE ST_PNOZEtherCATOut : STRUCT stMCCStatusOut: ST_MCCStatusOut; //Output Byte 00..01 stMCC_CustomStatusOut: ST_MCC_CustomStatusOut; //Output Byte 02..03 - aSafetyFunctionOut: ARRAY[1..GVL_APP.cNUM_OF_SAFETY_FUNCTIONS] OF ST_SafetyFunctionOut; //Output Byte 04..15 + astSafetyFunctionOut: ARRAY[1..GVL_APP.nNUM_OF_SAFETY_FUNCTIONS] OF ST_SafetyFunctionOut; //Output Byte 04..15 END_STRUCT END_TYPE ]]> diff --git a/DUTs/Safety/PNOZ/ST_SafetyFunctionIn.TcDUT b/DUTs/Safety/PNOZ/ST_SafetyFunctionIn.TcDUT index 11d425a2..335a30a9 100644 --- a/DUTs/Safety/PNOZ/ST_SafetyFunctionIn.TcDUT +++ b/DUTs/Safety/PNOZ/ST_SafetyFunctionIn.TcDUT @@ -3,10 +3,10 @@ diff --git a/DUTs/Safety/PNOZ/ST_SafetyFunctionOut.TcDUT b/DUTs/Safety/PNOZ/ST_SafetyFunctionOut.TcDUT index ff8ff01b..f72d9d6c 100644 --- a/DUTs/Safety/PNOZ/ST_SafetyFunctionOut.TcDUT +++ b/DUTs/Safety/PNOZ/ST_SafetyFunctionOut.TcDUT @@ -3,10 +3,10 @@ diff --git a/DUTs/Safety/ST_SafetyIn.TcDUT b/DUTs/Safety/ST_SafetyIn.TcDUT index 89b2ee1b..21ac9854 100644 --- a/DUTs/Safety/ST_SafetyIn.TcDUT +++ b/DUTs/Safety/ST_SafetyIn.TcDUT @@ -5,10 +5,10 @@ STRUCT stMCCStatusIn: ST_MCCStatusIn; stMCC_CustomStatusIn: ST_MCC_CustomStatusIn; - astSafetyFunctionIn: ARRAY[1..GVL_APP.cNUM_OF_SAFETY_FUNCTIONS] OF ST_SafetyFunctionIn; + astSafetyFunctionIn: ARRAY[1..GVL_APP.nNUM_OF_SAFETY_FUNCTIONS] OF ST_SafetyFunctionIn; stLEDState: ST_LEDState; stPNOZCommDiag: ST_PNOZCommDiag; - astTechnosoftMotionError: ARRAY[1..GVL_APP.cNUM_OF_TECHNOSOFT] OF ST_TechnosoftMotionError; + astTechnosoftMotionError: ARRAY[1..GVL_APP.nNUM_OF_TECHNOSOFT] OF ST_TechnosoftMotionError; END_STRUCT END_TYPE ]]> diff --git a/DUTs/Safety/ST_SafetyOut.TcDUT b/DUTs/Safety/ST_SafetyOut.TcDUT index 37672295..2850524d 100644 --- a/DUTs/Safety/ST_SafetyOut.TcDUT +++ b/DUTs/Safety/ST_SafetyOut.TcDUT @@ -5,7 +5,7 @@ STRUCT stMCCStatusOut: ST_MCCStatusOut; stMCC_CustomStatusOut: ST_MCC_CustomStatusOut; - astSafetyFunctionOut: ARRAY[1..GVL_APP.cNUM_OF_SAFETY_FUNCTIONS] OF ST_SafetyFunctionOut; + astSafetyFunctionOut: ARRAY[1..GVL_APP.nNUM_OF_SAFETY_FUNCTIONS] OF ST_SafetyFunctionOut; bSTOActive: BOOL; bTechnosoftMotionErrors: BOOL; diff --git a/POUs/FB_PulseGenerator.TcPOU b/POUs/FB_PulseGenerator.TcPOU index 9f0771b9..d316525e 100644 --- a/POUs/FB_PulseGenerator.TcPOU +++ b/POUs/FB_PulseGenerator.TcPOU @@ -15,7 +15,7 @@ VAR_OUTPUT END_VAR VAR - fbTimer: TON; //Internal flash timer + 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 @@ -28,7 +28,7 @@ END_VAR + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 AND_THEN iSafetyProvider.ReadFromSafetyController THEN + _EStopReleased := iSafetyProvider.EStopOK; + _STOReleased := iSafetyProvider.STO_OK; +END_IF; + +EStopReleased := _EStopReleased; +]]> + + + + + + aExtraMessageOld[i]); + + //Set the alarm LEDs according to first occurrence + IF NOT bLedActive + AND aAlarmList[i].bLedActive THEN + bLedActive := TRUE; + stMonitorLed.eErrorLED := aAlarmList[i].eErrorLED; + stMonitorLed.eStatusLED := aAlarmList[i].eStatusLED; + END_IF + + //If any error exists requiring an acknowledge, highlight Acknowledge LED. + IF aAlarmList[i].bLedActive AND NOT aAlarmList[i].bLedAutoReset THEN + stMonitorLed.eErrorAcknowledgeLED := aAlarmList[i].eErrorAcknowledgeLED; + END_IF +END_FOR + +aExtraMessageOld := aExtraMessage; //Save last messages for next iteration + +//Copy to output variables +aErrorID := aTempErrorID; +aErrorMsg := aTempErrorMsg; +nAlarmGrpBitNumber := nAlarmBitNumber; + +//Handle LED blinking +fbFastBlinkOn(IN:=NOT fbFastBlinkOff.Q, PT:=T#250MS); +fbFastBlinkOff(IN:=fbFastBlinkOn.Q, PT:=T#250MS); + +fbSlowBlinkOn(IN:=NOT fbSlowBlinkOff.Q, PT:=T#750MS); +fbSlowBlinkOff(IN:=fbSlowBlinkOn.Q, PT:=T#750MS); + +_bSafetyAcknowledgeLED := + (stMonitorLed.eErrorAcknowledgeLED = E_MonitorLed.eSteady) + OR (stMonitorLed.eErrorAcknowledgeLED = E_MonitorLed.eFast AND fbFastBlinkOn.Q) + OR (stMonitorLed.eErrorAcknowledgeLED = E_MonitorLed.eSlow AND fbSlowBlinkOn.Q); + +_bEStopLED := aAlarmList[4].bLedActive; + +]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/POUs/Safety/FB_MotionSafety.TcPOU b/POUs/Safety/FB_MotionSafety.TcPOU index 7c5dea18..18fa7bc4 100644 --- a/POUs/Safety/FB_MotionSafety.TcPOU +++ b/POUs/Safety/FB_MotionSafety.TcPOU @@ -40,7 +40,7 @@ VAR //Motion error registers from the Technosoft drives {attribute 'TcLinkTo' := '[1] := TIID^Device 2 (EtherCAT)^TA701 (iPOS8020 BX-CAT)^Transmit PDO 3 mapping parameters^Motion Error Register; [2] := TIID^Device 2 (EtherCAT)^TA702 (iPOS8020 BX-CAT)^Transmit PDO 3 mapping parameters^Motion Error Register'} - astTechnosoftMotionError AT %I*: ARRAY[1..GVL_APP.cNUM_OF_TECHNOSOFT] OF ST_TechnosoftMotionError; + astTechnosoftMotionError AT %I*: ARRAY[1..GVL_APP.nNUM_OF_TECHNOSOFT] OF ST_TechnosoftMotionError; {attribute 'TcLinkTo' := 'TIID^Device 2 (EtherCAT)^KF201 (EK1100)^KF208 (EL2014)^DIG Outputs^Channel 3^Output'} bSafetyAcknowledgeLED AT %Q*: BOOL; @@ -73,11 +73,11 @@ IF NOT bEnable OR bWcState THEN tHeartbeatPeriod := tHEARTBEAT_PERIOD, fHeartbeatPW := cHEARTBEAT_PW, tWatchdogTime := tMCC_WATCHDOG_TIME, - bHeartbeatOut => stSafety.stSafetyOut.stMCCStatusOut.bit0_Heartbeat, + bHeartbeatOut => stSafety.stSafetyOut.stMCCStatusOut.bHeartbeat, bWatchdogFault => bMCCWatchdogFault ); //Reset heartbeat generation and watchdog memory - stSafety.stSafetyOut.stMCCStatusOut.bit3_ErrAck := FALSE; //Clear fault-acknowledge command + stSafety.stSafetyOut.stMCCStatusOut.bErrAck := FALSE; //Clear fault-acknowledge command fbSafetyAckLedPulse( bEnable := FALSE, @@ -99,6 +99,19 @@ mHandleMotionPermission(); ]]> + + + + + + + + + stSafetyData.stSafetyOut.stMCCStatusOut.bit0_Heartbeat, + bHeartbeatOut => stSafetyData.stSafetyOut.stMCCStatusOut.bHeartbeat, bWatchdogFault => bMCCWatchdogFault ); bAxisEnableAllowed := - stSafetyData.stSafetyIn.stMCCStatusIn.bit1_EStopOK + stSafetyData.stSafetyIn.stMCCStatusIn.bEStopOK AND bMCC_OK; ]]> @@ -228,18 +241,18 @@ END_VAR stSafetyData.stSafetyIn.stMCC_CustomStatusIn := stPNOZEtherCATIn.stMCC_CustomStatusIn; stSafetyData.stSafetyIn.stLEDState := stPNOZEtherCATIn.stLEDState; -FOR i := 1 TO GVL_APP.cNUM_OF_SAFETY_FUNCTIONS DO +FOR i := 1 TO GVL_APP.nNUM_OF_SAFETY_FUNCTIONS DO stSafetyData.stSafetyIn.astSafetyFunctionIn[i] := stPNOZEtherCATIn.astSafetyFunctionIn[i]; END_FOR -IF GVL_APP.cNUM_OF_TECHNOSOFT <> 0 THEN - FOR i := 1 TO GVL_APP.cNUM_OF_TECHNOSOFT DO +IF GVL_APP.nNUM_OF_TECHNOSOFT <> 0 THEN + FOR i := 1 TO GVL_APP.nNUM_OF_TECHNOSOFT DO stSafetyData.stSafetyIn.astTechnosoftMotionError[i] := astTechnosoftMotionError[i]; END_FOR END_IF -_bEStopOK := stSafetyData.stSafetyIn.stMCCStatusIn.bit1_EStopOK; +_bEStopOK := stSafetyData.stSafetyIn.stMCCStatusIn.bEStopOK; ]]> @@ -252,21 +265,21 @@ END_VAR ]]> @@ -286,11 +299,11 @@ END_VAR stSafetyData.stSafetyOut.bSTOActive := FALSE; stSafetyData.stSafetyOut.bTechnosoftMotionErrors := FALSE; -IF GVL_APP.cNUM_OF_TECHNOSOFT <> 0 THEN - FOR nAxes := 1 TO GVL_APP.cNUM_OF_TECHNOSOFT DO +IF GVL_APP.nNUM_OF_TECHNOSOFT <> 0 THEN + FOR nAxes := 1 TO GVL_APP.nNUM_OF_TECHNOSOFT DO stSafetyData.stSafetyOut.bSTOActive := stSafetyData.stSafetyOut.bSTOActive - OR stSafetyData.stSafetyIn.astTechnosoftMotionError[nAxes].bit15_STOActive; + OR stSafetyData.stSafetyIn.astTechnosoftMotionError[nAxes].bSTOActive; stSafetyData.stSafetyOut.bTechnosoftMotionErrors := stSafetyData.stSafetyOut.bTechnosoftMotionErrors @@ -298,11 +311,11 @@ IF GVL_APP.cNUM_OF_TECHNOSOFT <> 0 THEN END_FOR END_IF -IF GVL_APP.cNUM_OF_TECHNOSOFT <> 0 THEN - stSafetyData.stSafetyOut.stMCCStatusOut.bit6_STOFbk := +IF GVL_APP.nNUM_OF_TECHNOSOFT <> 0 THEN + stSafetyData.stSafetyOut.stMCCStatusOut.bSTOFbk := stSafetyData.stSafetyOut.bSTOActive; //TRUE when any Technosoft drive reports STO active - stSafetyData.stSafetyOut.stMCCStatusOut.bit7_STO_OK := + stSafetyData.stSafetyOut.stMCCStatusOut.bSTO_OK := NOT stSafetyData.stSafetyOut.bTechnosoftMotionErrors; //Preserve the existing no-motion-error feedback END_IF ]]> @@ -316,11 +329,11 @@ END_VAR ]]> - - - - - - - - - - - + - - - + - diff --git a/POUs/Safety/F_TechnosoftErrorActive.TcPOU b/POUs/Safety/F_TechnosoftErrorActive.TcPOU index 9945348e..d6bef7ac 100644 --- a/POUs/Safety/F_TechnosoftErrorActive.TcPOU +++ b/POUs/Safety/F_TechnosoftErrorActive.TcPOU @@ -8,21 +8,21 @@ END_VAR ]]>