From 880f08195ba6add4079c7bba1cd805a43c65c918 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Mon, 18 May 2026 20:10:38 +0200 Subject: [PATCH 01/41] MBP-388: Add DUTs related to MCC_SafetyFunctions --- solution/_Config/IO/PNOZ (EtherCAT).xti | 576 ++++++++++++++++++ .../DUTs/Safety/E_MCCSafetyFunctions.TcDUT | 21 + .../MCC_SafetyFunctions/ST_SF3_1_ESTOP.TcDUT | 15 + .../ST_SF3_2_PSS_ACCESS.TcDUT | 13 + .../ST_SF3_3_RESTART_PREVENTION_EXP.TcDUT | 14 + .../DUTs/Safety/ST_MCCSafetyFunctions.TcDUT | 16 + 6 files changed, 655 insertions(+) create mode 100644 solution/_Config/IO/PNOZ (EtherCAT).xti create mode 100644 solution/tc_project_app/DUTs/Safety/E_MCCSafetyFunctions.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_1_ESTOP.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_2_PSS_ACCESS.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_3_RESTART_PREVENTION_EXP.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/ST_MCCSafetyFunctions.TcDUT diff --git a/solution/_Config/IO/PNOZ (EtherCAT).xti b/solution/_Config/IO/PNOZ (EtherCAT).xti new file mode 100644 index 0000000..956100a --- /dev/null +++ b/solution/_Config/IO/PNOZ (EtherCAT).xti @@ -0,0 +1,576 @@ + + + + 424de6000000000000007600000028000000100000000e00000001000400000000007000000000000000000000001000000000000000000000001198cb0097a199001c6574005ea5be00596374001487b2005fc9ed0037635f008bd7ed00ffffff0009433f009ebbc0007283830022b4eb003f4d4a00a8ff8aac338338caa8558aa60000004aa82d8aa1116611eaa8ff8aa611e1117aa8ff8aa74777779aa82d8aa77777479aa8c28aa47774579aa8bb8aa44444279aa8bb8aa4dddd2c9aa8bb8aa444442c9aafbb8aa41eeeee7aafbb8aa13eeeee7aaf00faa1111111eaad88daa13333334a + + + __FILENAME__ + + + Local Area Connection 2 (TwinCAT-Intel PCI Ethernet + \DEVICE\{225F8895-47D0-450D-B6DF-ACF28535D923} + 000105248854 + + + + Image + + + Box (PNOZ m ES EtherCAT) + 1000 + + 001cc000260001000100000032000001c000001c26010000 + 001ec000220001000200000032000001c000001e22010000 + 001113006400010003000000010080001300001164010000 + 001320002000010004000000000000012000001320010000 + 0000000000000000001100020100000001000000000000000000000000000000 + 0000000000000000001300010100000002000000000000000000000000000000 + 00000000000000000d0800010100000003000000000000000000000000000000 + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + USINT + + + + + + + diff --git a/solution/tc_project_app/DUTs/Safety/E_MCCSafetyFunctions.TcDUT b/solution/tc_project_app/DUTs/Safety/E_MCCSafetyFunctions.TcDUT new file mode 100644 index 0000000..68a6834 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/E_MCCSafetyFunctions.TcDUT @@ -0,0 +1,21 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_1_ESTOP.TcDUT b/solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_1_ESTOP.TcDUT new file mode 100644 index 0000000..a36894d --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_1_ESTOP.TcDUT @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_2_PSS_ACCESS.TcDUT b/solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_2_PSS_ACCESS.TcDUT new file mode 100644 index 0000000..ba00108 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_2_PSS_ACCESS.TcDUT @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_3_RESTART_PREVENTION_EXP.TcDUT b/solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_3_RESTART_PREVENTION_EXP.TcDUT new file mode 100644 index 0000000..5eb61df --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_3_RESTART_PREVENTION_EXP.TcDUT @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_MCCSafetyFunctions.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_MCCSafetyFunctions.TcDUT new file mode 100644 index 0000000..1d3a281 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/ST_MCCSafetyFunctions.TcDUT @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file From bb191ddb03102499e7846d750037b8cee59d0885 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Mon, 18 May 2026 20:11:24 +0200 Subject: [PATCH 02/41] MBP-388: Update MAIN to include Safety call --- solution/tc_project_app/POUs/MAIN.TcPOU | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 2a1aff0..3abddf3 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -27,6 +27,10 @@ VAR fbGetDeviceIdentification: FB_GetDeviceIdentificationEx; nTestNum: UINT :=0 ; //Variable used in ESS's FAT_SAT_tools scripts to keep track of the test number + + // Motion Safety + fbMotionSafety : FB_MotionSafety; + stMCCSafetyFunctions : ST_MCCSafetyFunctions; END_VAR VAR PERSISTENT @@ -37,7 +41,7 @@ END_VAR +SAFETY();]]> @@ -291,6 +295,24 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN END_FOR END_CASE END_IF +]]> + + + + + From 85d608c2a724c63566933429a0acb57e2b75809c Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Mon, 18 May 2026 20:14:08 +0200 Subject: [PATCH 03/41] MBP-388: Fix double square brackets --- solution/tc_project_app/POUs/MAIN.TcPOU | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 3abddf3..0ced98c 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -27,8 +27,8 @@ VAR fbGetDeviceIdentification: FB_GetDeviceIdentificationEx; nTestNum: UINT :=0 ; //Variable used in ESS's FAT_SAT_tools scripts to keep track of the test number - - // Motion Safety + + // Motion Safety fbMotionSafety : FB_MotionSafety; stMCCSafetyFunctions : ST_MCCSafetyFunctions; END_VAR From 0b08f72aacd34e8252b904fa3d17dcf85a0d7018 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Mon, 18 May 2026 20:16:45 +0200 Subject: [PATCH 04/41] MBP-388: Fix pipeline --- solution/tc_project_app/POUs/MAIN.TcPOU | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 0ced98c..52d14f3 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -41,7 +41,8 @@ END_VAR +SAFETY(); +]]> From b201a39a241e5ffe466be3f4c7a1e84b97ac261c Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Wed, 20 May 2026 20:17:26 +0200 Subject: [PATCH 05/41] MBP-388 Rename DUT to E_SafetyFunctions Updates DUT name from E_MCCSafetyFunctions to E_SafetyFunctions. --- .../DUTs/Safety/E_MCCSafetyFunctions.TcDUT | 21 ---------------- .../DUTs/Safety/E_SafetyFunctions.TcDUT | 25 +++++++++++++++++++ 2 files changed, 25 insertions(+), 21 deletions(-) delete mode 100644 solution/tc_project_app/DUTs/Safety/E_MCCSafetyFunctions.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/E_SafetyFunctions.TcDUT diff --git a/solution/tc_project_app/DUTs/Safety/E_MCCSafetyFunctions.TcDUT b/solution/tc_project_app/DUTs/Safety/E_MCCSafetyFunctions.TcDUT deleted file mode 100644 index 68a6834..0000000 --- a/solution/tc_project_app/DUTs/Safety/E_MCCSafetyFunctions.TcDUT +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/E_SafetyFunctions.TcDUT b/solution/tc_project_app/DUTs/Safety/E_SafetyFunctions.TcDUT new file mode 100644 index 0000000..93042c8 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/E_SafetyFunctions.TcDUT @@ -0,0 +1,25 @@ + + + + + + \ No newline at end of file From 546b07cb4a8dfc606bb6f4142343f71297659203 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Wed, 20 May 2026 20:25:10 +0200 Subject: [PATCH 06/41] MBP-388 Add DUT LED state Adds LED state for safety controller --- .../tc_project_app/DUTs/Safety/ST_LEDState.TcDUT | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 solution/tc_project_app/DUTs/Safety/ST_LEDState.TcDUT diff --git a/solution/tc_project_app/DUTs/Safety/ST_LEDState.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_LEDState.TcDUT new file mode 100644 index 0000000..a73501c --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/ST_LEDState.TcDUT @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file From da0e5688f21e29ab6652298f650d13154cd58eca Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Wed, 20 May 2026 20:28:31 +0200 Subject: [PATCH 07/41] MBP-388 Cleanup DUTs Removes unused DUTs and places DUTs in progress in WIP folder --- .../MCC_SafetyFunctions/ST_SF3_1_ESTOP.TcDUT | 15 --------------- .../ST_SF3_2_PSS_ACCESS.TcDUT | 13 ------------- .../ST_SF3_3_RESTART_PREVENTION_EXP.TcDUT | 14 -------------- .../DUTs/Safety/ST_MCCSafetyFunctions.TcDUT | 16 ---------------- .../DUTs/Safety/WIP/ST_SafetyDiagnostics.TcDUT | 11 +++++++++++ .../DUTs/Safety/WIP/ST_SafetyFeedback.TcDUT | 11 +++++++++++ .../DUTs/Safety/WIP/ST_SafetyStatus.TcDUT | 11 +++++++++++ .../DUTs/Safety/WIP/ST_SegmentNumber.TcDUT | 13 +++++++++++++ .../DUTs/Safety/WIP/ST_SegmentNumberIn.TcDUT | 10 ++++++++++ .../DUTs/Safety/WIP/ST_SegmentNumberOut.TcDUT | 10 ++++++++++ .../DUTs/Safety/WIP/ST_Sequence.TcDUT | 13 +++++++++++++ .../DUTs/Safety/WIP/ST_SequenceIn.TcDUT | 10 ++++++++++ .../DUTs/Safety/WIP/ST_SequenceOut.TcDUT | 10 ++++++++++ .../DUTs/Safety/WIP/ST_SubSystem.TcDUT | 13 +++++++++++++ .../DUTs/Safety/WIP/ST_SubSystemIn.TcDUT | 11 +++++++++++ .../DUTs/Safety/WIP/ST_SubSystemOut.TcDUT | 11 +++++++++++ .../DUTs/Safety/WIP/ST_TableNumber.TcDUT | 13 +++++++++++++ .../DUTs/Safety/WIP/ST_TableNumberIn.TcDUT | 10 ++++++++++ .../DUTs/Safety/WIP/ST_TableNumberOut.TcDUT | 10 ++++++++++ 19 files changed, 167 insertions(+), 58 deletions(-) delete mode 100644 solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_1_ESTOP.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_2_PSS_ACCESS.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_3_RESTART_PREVENTION_EXP.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/ST_MCCSafetyFunctions.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyDiagnostics.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyFeedback.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyStatus.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumber.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumberIn.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumberOut.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_Sequence.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_SequenceIn.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_SequenceOut.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystem.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystemIn.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystemOut.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumber.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumberIn.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumberOut.TcDUT diff --git a/solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_1_ESTOP.TcDUT b/solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_1_ESTOP.TcDUT deleted file mode 100644 index a36894d..0000000 --- a/solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_1_ESTOP.TcDUT +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_2_PSS_ACCESS.TcDUT b/solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_2_PSS_ACCESS.TcDUT deleted file mode 100644 index ba00108..0000000 --- a/solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_2_PSS_ACCESS.TcDUT +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_3_RESTART_PREVENTION_EXP.TcDUT b/solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_3_RESTART_PREVENTION_EXP.TcDUT deleted file mode 100644 index 5eb61df..0000000 --- a/solution/tc_project_app/DUTs/Safety/MCC_SafetyFunctions/ST_SF3_3_RESTART_PREVENTION_EXP.TcDUT +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_MCCSafetyFunctions.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_MCCSafetyFunctions.TcDUT deleted file mode 100644 index 1d3a281..0000000 --- a/solution/tc_project_app/DUTs/Safety/ST_MCCSafetyFunctions.TcDUT +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyDiagnostics.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyDiagnostics.TcDUT new file mode 100644 index 0000000..46d26f3 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyDiagnostics.TcDUT @@ -0,0 +1,11 @@ + + + + need to define what purpose this struct serves +TYPE ST_SafetyDiagnostics : +STRUCT +END_STRUCT +END_TYPE +]]> + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyFeedback.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyFeedback.TcDUT new file mode 100644 index 0000000..1f4f6e1 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyFeedback.TcDUT @@ -0,0 +1,11 @@ + + + + need to define what purpose this struct serves +TYPE ST_SafetyFeedback : +STRUCT +END_STRUCT +END_TYPE +]]> + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyStatus.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyStatus.TcDUT new file mode 100644 index 0000000..6e93bba --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyStatus.TcDUT @@ -0,0 +1,11 @@ + + + + need to define what purpose this struct serves +TYPE ST_SafetyStatus : +STRUCT +END_STRUCT +END_TYPE +]]> + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumber.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumber.TcDUT new file mode 100644 index 0000000..be589db --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumber.TcDUT @@ -0,0 +1,13 @@ + + + + need to define what purpose this struct serves +TYPE ST_SegmentNumber : +STRUCT + refIn: REFERENCE TO ST_SegmentNumberIn; + refOut: REFERENCE TO ST_SegmentNumberOut; +END_STRUCT +END_TYPE +]]> + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumberIn.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumberIn.TcDUT new file mode 100644 index 0000000..af9616a --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumberIn.TcDUT @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumberOut.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumberOut.TcDUT new file mode 100644 index 0000000..40665d9 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumberOut.TcDUT @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_Sequence.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_Sequence.TcDUT new file mode 100644 index 0000000..e940fdb --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/WIP/ST_Sequence.TcDUT @@ -0,0 +1,13 @@ + + + + need to define what purpose this struct serves +TYPE ST_Sequence : +STRUCT + refIn: REFERENCE TO ST_SequenceIn; + refOut: REFERENCE TO ST_SequenceOut; +END_STRUCT +END_TYPE +]]> + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SequenceIn.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SequenceIn.TcDUT new file mode 100644 index 0000000..ea9f10a --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/WIP/ST_SequenceIn.TcDUT @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SequenceOut.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SequenceOut.TcDUT new file mode 100644 index 0000000..85a45bb --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/WIP/ST_SequenceOut.TcDUT @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystem.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystem.TcDUT new file mode 100644 index 0000000..4db4c3b --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystem.TcDUT @@ -0,0 +1,13 @@ + + + + need to define what purpose this struct serves +TYPE ST_SubSystem : +STRUCT + refIn: REFERENCE TO ST_SubSystemIn; + refOut: REFERENCE TO ST_SubSystemOut; +END_STRUCT +END_TYPE +]]> + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystemIn.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystemIn.TcDUT new file mode 100644 index 0000000..b8f7478 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystemIn.TcDUT @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystemOut.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystemOut.TcDUT new file mode 100644 index 0000000..cb6b6ee --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystemOut.TcDUT @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumber.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumber.TcDUT new file mode 100644 index 0000000..ea8609c --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumber.TcDUT @@ -0,0 +1,13 @@ + + + + need to define what purpose this struct serves +TYPE ST_TableNumber : +STRUCT + refIn: REFERENCE TO ST_TableNumberIn; + refOut: REFERENCE TO ST_TableNumberOut; +END_STRUCT +END_TYPE +]]> + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumberIn.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumberIn.TcDUT new file mode 100644 index 0000000..f5e7b1a --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumberIn.TcDUT @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumberOut.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumberOut.TcDUT new file mode 100644 index 0000000..9118b31 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumberOut.TcDUT @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file From 9bb582738495802249c4bfd483fa37e5e3a92fcc Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Wed, 20 May 2026 20:32:05 +0200 Subject: [PATCH 08/41] MBP-388 Add GVL_SafetyIO Implements a hardware abstraction layer for safety I/O --- .../tc_project_app/GVLs/GVL_SafetyIO.TcGVL | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL diff --git a/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL b/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL new file mode 100644 index 0000000..f248e1c --- /dev/null +++ b/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL @@ -0,0 +1,32 @@ + + + + PLC bytes, Scanner Input Bytes 00..31 + cPNOZ_RXPDO_BYTES: UINT := 19; //Total PLC -> PNOZ bytes, Scanner Output Bytes 00..18 + + cLOWER_BOUND_SF: UINT := 5; //Lower Bound = 5, Virtual Output/Input bytes 04..11, each containing 8 bits + cUPPER_BOUND_SF: UINT := 12; //Upper Bound = 12, Virtual Output/Input bytes 04..11, each containing 8 bits + cUPPER_NBR_OF_SS: UINT := 2; //Number of subsystems, Placeholder, WIP +END_VAR]]> + + \ No newline at end of file From ee2314150ad750a485d8e17f386feacb99c9f966 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Wed, 20 May 2026 20:33:58 +0200 Subject: [PATCH 09/41] MBP-388: Add DUT to handle PNOZ EtherCAT info --- .../DUTs/Safety/ST_PNOZCommDiag.TcDUT | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 solution/tc_project_app/DUTs/Safety/ST_PNOZCommDiag.TcDUT diff --git a/solution/tc_project_app/DUTs/Safety/ST_PNOZCommDiag.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_PNOZCommDiag.TcDUT new file mode 100644 index 0000000..5b32501 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/ST_PNOZCommDiag.TcDUT @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file From 1f4ead685fc10e38e2c99b9779d7380550e2de48 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Wed, 20 May 2026 20:35:30 +0200 Subject: [PATCH 10/41] MBP-388: Add DUT for linking PNOZ EtherCAT info --- .../DUTs/Safety/ST_PNOZEtherCATStatus.TcDUT | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATStatus.TcDUT diff --git a/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATStatus.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATStatus.TcDUT new file mode 100644 index 0000000..1bb573e --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATStatus.TcDUT @@ -0,0 +1,25 @@ + + + + + + \ No newline at end of file From 82802c2a09d29d756e9216e9fc72a4bb0409d3b8 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Wed, 20 May 2026 20:37:25 +0200 Subject: [PATCH 11/41] MBP-388 Add PNOZ DUTs Implements DUTs for decoding raw PNOZ EtherCAT input and output data into structs --- .../DUTs/Safety/ST_PNOZEtherCATIn.TcDUT | 23 +++++++++++++++++++ .../DUTs/Safety/ST_PNOZEtherCATOut.TcDUT | 22 ++++++++++++++++++ .../DUTs/Safety/ST_PNOZRawIn.TcDUT | 11 +++++++++ .../DUTs/Safety/ST_PNOZRawOut.TcDUT | 11 +++++++++ 4 files changed, 67 insertions(+) create mode 100644 solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/ST_PNOZRawIn.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/ST_PNOZRawOut.TcDUT diff --git a/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT new file mode 100644 index 0000000..287e21b --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT @@ -0,0 +1,23 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT new file mode 100644 index 0000000..c979711 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT @@ -0,0 +1,22 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_PNOZRawIn.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_PNOZRawIn.TcDUT new file mode 100644 index 0000000..5b39f76 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/ST_PNOZRawIn.TcDUT @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_PNOZRawOut.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_PNOZRawOut.TcDUT new file mode 100644 index 0000000..9fb9b5f --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/ST_PNOZRawOut.TcDUT @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file From 49220875f5fed25abc87d9a4e85290e656b62dea Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Wed, 20 May 2026 20:40:53 +0200 Subject: [PATCH 12/41] MBP-388: Add DUTs for Safety Function mapping --- .../DUTs/Safety/ST_SafetyFunction.TcDUT | 12 ++++++++++++ .../DUTs/Safety/ST_SafetyFunctionIn.TcDUT | 14 ++++++++++++++ .../DUTs/Safety/ST_SafetyFunctionOut.TcDUT | 14 ++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 solution/tc_project_app/DUTs/Safety/ST_SafetyFunction.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/ST_SafetyFunctionIn.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/ST_SafetyFunctionOut.TcDUT diff --git a/solution/tc_project_app/DUTs/Safety/ST_SafetyFunction.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_SafetyFunction.TcDUT new file mode 100644 index 0000000..86e7268 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/ST_SafetyFunction.TcDUT @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_SafetyFunctionIn.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_SafetyFunctionIn.TcDUT new file mode 100644 index 0000000..972c798 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/ST_SafetyFunctionIn.TcDUT @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_SafetyFunctionOut.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_SafetyFunctionOut.TcDUT new file mode 100644 index 0000000..ff8ff01 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/ST_SafetyFunctionOut.TcDUT @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file From f63d9b7b658bcfb3ea925d29f45f8f5df4f2daca Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Wed, 20 May 2026 20:41:58 +0200 Subject: [PATCH 13/41] MBP-388: Add ST_Safety DUT Implements central DUT where all decoded raw input and output signals from the safety controller are gathered for structured access --- .../DUTs/Safety/ST_Safety.TcDUT | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 solution/tc_project_app/DUTs/Safety/ST_Safety.TcDUT diff --git a/solution/tc_project_app/DUTs/Safety/ST_Safety.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_Safety.TcDUT new file mode 100644 index 0000000..c760177 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/ST_Safety.TcDUT @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file From 3e49f71911461471939c31f076641c053ba28479 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Wed, 20 May 2026 20:45:24 +0200 Subject: [PATCH 14/41] MBP-388 Add helper functions Implements helper functions for handling raw input and to output raw data back to the safety controller. --- .../F_MapRawInputToSafetyFunctionIn.TcPOU | 76 +++++++++++++++++ .../F_MapSafetyFunctionOutToRawOutput.TcPOU | 83 +++++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_MapRawInputToSafetyFunctionIn.TcPOU create mode 100644 solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_MapSafetyFunctionOutToRawOutput.TcPOU diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_MapRawInputToSafetyFunctionIn.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_MapRawInputToSafetyFunctionIn.TcPOU new file mode 100644 index 0000000..dae74e1 --- /dev/null +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_MapRawInputToSafetyFunctionIn.TcPOU @@ -0,0 +1,76 @@ + + + + + + GVL_SafetyIO.cUPPER_BOUND_SF) THEN + RETURN; +END_IF + +(* +The configured safety function range can start from any index. +Therefore, the selected safety function is converted to a zero-based index. + +Example: +If GVL_SafetyIO.cLOWER_BOUND_SF = 5 +nSafetyFunction = 5 -> nZeroBasedIndex = 0 +nSafetyFunction = 6 -> nZeroBasedIndex = 1 +nSafetyFunction = 7 -> nZeroBasedIndex = 2 +*) +nZeroBasedIndex := nSafetyFunction - GVL_SafetyIO.cLOWER_BOUND_SF; +nByteIndex := (nZeroBasedIndex / 2) + 1; //Two safety functions are stored in each byte +bUpperNibble := (nZeroBasedIndex MOD 2) = 1; //Odd indexes use upper nibble, even indexes use lower nibble + +byRaw := stRawIn.abyInput[nByteIndex]; + +(* +A bit mask is used to check one specific bit in the raw byte. +The expression: (byRaw AND BYTE#16#01) <> BYTE#0 + +Works like this: +1. AND keeps only the bit selected by the mask. +2. All other bits are cleared. +3. If the result is not zero, that bit was set. +4. The comparison returns TRUE or FALSE. + +Example: +bitEnabled -> bit 0 -> mask BYTE#16#01 -> 0000 0001 +bitReady -> bit 1 -> mask BYTE#16#02 -> 0000 0010 +bitFault -> bit 2 -> mask BYTE#16#04 -> 0000 0100 +bitStart -> bit 3 -> mask BYTE#16#08 -> 0000 1000 +*) +IF NOT bUpperNibble THEN + //Lower nibble: bits 0..3 + F_MapRawInputToSafetyFunctionIn.bitEnabled := (byRaw AND BYTE#16#01) <> BYTE#0; + F_MapRawInputToSafetyFunctionIn.bitReady := (byRaw AND BYTE#16#02) <> BYTE#0; + F_MapRawInputToSafetyFunctionIn.bitFault := (byRaw AND BYTE#16#04) <> BYTE#0; + F_MapRawInputToSafetyFunctionIn.bitStart := (byRaw AND BYTE#16#08) <> BYTE#0; +ELSE + //Upper nibble: bits 4..7 + F_MapRawInputToSafetyFunctionIn.bitEnabled := (byRaw AND BYTE#16#10) <> BYTE#0; + F_MapRawInputToSafetyFunctionIn.bitReady := (byRaw AND BYTE#16#20) <> BYTE#0; + F_MapRawInputToSafetyFunctionIn.bitFault := (byRaw AND BYTE#16#40) <> BYTE#0; + F_MapRawInputToSafetyFunctionIn.bitStart := (byRaw AND BYTE#16#80) <> BYTE#0; +END_IF +]]> + + + \ No newline at end of file diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_MapSafetyFunctionOutToRawOutput.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_MapSafetyFunctionOutToRawOutput.TcPOU new file mode 100644 index 0000000..b772a15 --- /dev/null +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_MapSafetyFunctionOutToRawOutput.TcPOU @@ -0,0 +1,83 @@ + + + + + + GVL_SafetyIO.cUPPER_BOUND_SF) THEN + RETURN; +END_IF +(* +The configured safety function range can start from any index. +Therefore, the selected safety function is converted to a zero-based index. + +Example: +If GVL_SafetyIO.cLOWER_BOUND_SF = 5 +nSafetyFunction = 5 -> nZeroBasedIndex = 0 +nSafetyFunction = 6 -> nZeroBasedIndex = 1 +nSafetyFunction = 7 -> nZeroBasedIndex = 2 +*) +nZeroBasedIndex := nSafetyFunction - GVL_SafetyIO.cLOWER_BOUND_SF; +nByteIndex := (nZeroBasedIndex / 2) + 1; //Two safety functions are stored in each byte +bUpperNibble := (nZeroBasedIndex MOD 2) = 1; //Odd indexes use upper nibble, even indexes use lower nibble + +(* +Build one 4-bit value from the safety function output structure. +Each BOOL is written into one bit of byValue using OR. +If the BOOL is TRUE, the corresponding bit is set. +If the BOOL is FALSE, the corresponding bit remains 0. + +Bit layout inside byValue: +bitDiagOk -> bit 0 -> mask BYTE#16#01 -> 0000 0001 +bitOutput -> bit 1 -> mask BYTE#16#02 -> 0000 0010 +bitRequest -> bit 2 -> mask BYTE#16#04 -> 0000 0100 +bitDummy -> bit 3 -> mask BYTE#16#08 -> 0000 1000 +*) +byValue := BYTE#0; + +IF stSafetyFunctionOut.bitDiagOk THEN + byValue := byValue OR BYTE#16#01; +END_IF + +IF stSafetyFunctionOut.bitOutput THEN + byValue := byValue OR BYTE#16#02; +END_IF + +IF stSafetyFunctionOut.bitRequest THEN + byValue := byValue OR BYTE#16#04; +END_IF + +IF stSafetyFunctionOut.bitDummy THEN + byValue := byValue OR BYTE#16#08; +END_IF + +IF NOT bUpperNibble THEN + //Lower nibble: bits 0..3 + stRawOut.abyOutput[nByteIndex] := + (stRawOut.abyOutput[nByteIndex] AND BYTE#16#F0) OR byValue; +ELSE + //Upper nibble: bits 4..7 + stRawOut.abyOutput[nByteIndex] := + (stRawOut.abyOutput[nByteIndex] AND BYTE#16#0F) OR SHL(byValue, 4); +END_IF + +F_MapSafetyFunctionOutToRawOutput := TRUE;]]> + + + \ No newline at end of file From f6c27ac832719ee652cbd410b3c3e2bc1c74129c Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Wed, 20 May 2026 20:50:42 +0200 Subject: [PATCH 15/41] MBP-388: Add FB_MotionSafety Implements FB_MotionSafety for safety handling with communication diagnostics, reference linking, raw PNOZ EtherCAT input mapping, and cyclic output writes through mLinkRefs, mReadECATInput, and mWriteECATOutput. --- .../Applications/Safety/FB_MotionSafety.TcPOU | 138 ++++++++++++++++++ .../Applications/Safety/Motion_Safety.TcPOU | 34 +++++ 2 files changed, 172 insertions(+) create mode 100644 solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU create mode 100644 solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU new file mode 100644 index 0000000..2a350bc --- /dev/null +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU @@ -0,0 +1,138 @@ + + + + + + + + + + + PLC + stSafety.aSafetyFunction[i].refIn REF=stECATIn.aSafetyFunctionIn[i]; + + //PLC -> PNOZ + stSafety.aSafetyFunction[i].refOut REF=stECATOut.aSafetyFunctionOut[i]; +END_FOR + +//PNOZ -> PLC +stSafety.refLEDState REF=stECATIn.stLEDState; +stSafety.stTableNumber.refIn REF=stECATIn.stTableNumberIn; +stSafety.stSegmentNumber.refIn REF=stECATIn.stSegmentNumberIn; + +//PLC -> PNOZ +stSafety.stTableNumber.refOut REF=stECATOut.stTableNumberOut; +stSafety.stSegmentNumber.refOut REF=stECATOut.stSegmentNumberOut; + +mLinkRefs := TRUE;]]> + + + + + + selects the safety function. +refSafetyIn.bEnabled --> selects the bit/state of that safety function. +*) + +mReadECATInput := FALSE; + +//PNOZ safety function inputs +FOR i := GVL_SafetyIO.cLOWER_BOUND_SF TO GVL_SafetyIO.cUPPER_BOUND_SF DO + stECATIn.aSafetyFunctionIn[i] := F_MapRawInputToSafetyFunctionIn(stRawIn := GVL_SafetyIO.stPNOZRawIn, nSafetyFunction := i); +END_FOR + +//PNOZ LED state +stECATIn.stLEDState.nLEDState := GVL_SafetyIO.stLEDState.nLEDState; + +mReadECATInput := TRUE;]]> + + + + + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU new file mode 100644 index 0000000..b9010ed --- /dev/null +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU @@ -0,0 +1,34 @@ + + + + + + + + + \ No newline at end of file From 74f573f3053c7f3000d9c97d083bf98bc761713f Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Wed, 20 May 2026 21:02:17 +0200 Subject: [PATCH 16/41] MBP-388: Fix double square brackets --- solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL | 3 ++- .../Applications/Safety/FB_MotionSafety.TcPOU | 6 ++++-- .../Safety/F_MapRawInputToSafetyFunctionIn.TcPOU | 3 ++- .../Safety/F_MapSafetyFunctionOutToRawOutput.TcPOU | 6 ++++-- .../Applications/Safety/Motion_Safety.TcPOU | 3 ++- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL b/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL index f248e1c..890854c 100644 --- a/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL +++ b/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL @@ -27,6 +27,7 @@ VAR_GLOBAL CONSTANT cLOWER_BOUND_SF: UINT := 5; //Lower Bound = 5, Virtual Output/Input bytes 04..11, each containing 8 bits cUPPER_BOUND_SF: UINT := 12; //Upper Bound = 12, Virtual Output/Input bytes 04..11, each containing 8 bits cUPPER_NBR_OF_SS: UINT := 2; //Number of subsystems, Placeholder, WIP -END_VAR]]> +END_VAR +]]> \ No newline at end of file diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU index 2a350bc..bd6d639 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU @@ -74,7 +74,8 @@ stSafety.stSegmentNumber.refIn REF=stECATIn.stSegmentNumberIn; stSafety.stTableNumber.refOut REF=stECATOut.stTableNumberOut; stSafety.stSegmentNumber.refOut REF=stECATOut.stSegmentNumberOut; -mLinkRefs := TRUE;]]> +mLinkRefs := TRUE; +]]> @@ -106,7 +107,8 @@ END_FOR //PNOZ LED state stECATIn.stLEDState.nLEDState := GVL_SafetyIO.stLEDState.nLEDState; -mReadECATInput := TRUE;]]> +mReadECATInput := TRUE; +]]> diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_MapRawInputToSafetyFunctionIn.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_MapRawInputToSafetyFunctionIn.TcPOU index dae74e1..379ecbf 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_MapRawInputToSafetyFunctionIn.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_MapRawInputToSafetyFunctionIn.TcPOU @@ -11,7 +11,8 @@ VAR nByteIndex: UINT; //Index of the raw input byte containing the safety function bUpperNibble: BOOL; //1 nibble = 4 bits, TRUE = use upper nibble, FALSE = use lower nibble byRaw: BYTE; //Raw byte read from the input array -END_VAR]]> +END_VAR +]]> +END_VAR +]]> +F_MapSafetyFunctionOutToRawOutput := TRUE; +]]> \ No newline at end of file diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU index b9010ed..4ef1e0d 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU @@ -28,7 +28,8 @@ bEStopEnabled := stSafety.aSafetyFunction[E_SafetyFunctions.eEStop].refIn.bitEna //LOGIC SPECIFIC TO THIS CABINET, Placeholder, WIP //MCC-specific safety rules/effects should be added below. -fbMotionSafety.mWriteECATOutput();]]> +fbMotionSafety.mWriteECATOutput(); +]]> \ No newline at end of file From d38258e4942e92c83e2a2aee376ca0c67e5116b6 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Thu, 21 May 2026 20:39:30 +0200 Subject: [PATCH 17/41] MBP-388: Change indexing for E_SafetyFunctions --- .../DUTs/Safety/E_SafetyFunctions.TcDUT | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/solution/tc_project_app/DUTs/Safety/E_SafetyFunctions.TcDUT b/solution/tc_project_app/DUTs/Safety/E_SafetyFunctions.TcDUT index 93042c8..5a4b697 100644 --- a/solution/tc_project_app/DUTs/Safety/E_SafetyFunctions.TcDUT +++ b/solution/tc_project_app/DUTs/Safety/E_SafetyFunctions.TcDUT @@ -6,18 +6,20 @@ (* Central definition of safety functions includes for a motion control cabinet. Add new safety functions to match the incoming safety functions from the PNOZmulti 2. -Each safety function represents 4-bits. +Each safety function represents 4-bits of information. However the PLC still stores the incoming 4-bits +into 1-byte. *) TYPE E_SafetyFunctions : ( - eEStop := 5, - ePSSAccess := 6, - eRestartPreventionExp := 7, - eRestartPreventionOpt := 8, - eStopMiddleFocus := 9, - eEnableMiddleFocus := 10, - eSafeTorqueOff := 11, - eReserved := 12 + eNone, + eEStop, + ePSSAccess, + eRestartPreventionExp, + eRestartPreventionOpt, + eStopMiddleFocus, + eEnableMiddleFocus, + eSafeTorqueOff, + eReserved ); END_TYPE ]]> From 8f33d3cc1fad6aa46021c1e9c8d5f207b5d4b817 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Thu, 21 May 2026 20:42:50 +0200 Subject: [PATCH 18/41] MBP-388: Cleanup DUTs --- .../DUTs/Safety/ST_MCCStatus.TcDUT | 16 +++++++++++ .../DUTs/Safety/ST_MCCStatusIn.TcDUT | 27 +++++++++++++++++++ .../DUTs/Safety/ST_MCCStatusOut.TcDUT | 27 +++++++++++++++++++ .../DUTs/Safety/ST_MCC_CustomStatus.TcDUT | 16 +++++++++++ .../DUTs/Safety/ST_MCC_CustomStatusIn.TcDUT | 27 +++++++++++++++++++ .../DUTs/Safety/ST_MCC_CustomStatusOut.TcDUT | 27 +++++++++++++++++++ .../DUTs/Safety/ST_PNOZEtherCATIn.TcDUT | 18 ++++++------- .../DUTs/Safety/ST_PNOZEtherCATOut.TcDUT | 16 +++++------ .../DUTs/Safety/ST_PNOZRawIn.TcDUT | 11 -------- .../DUTs/Safety/ST_PNOZRawOut.TcDUT | 11 -------- .../DUTs/Safety/ST_Safety.TcDUT | 5 +++- .../Safety/WIP/ST_SafetyDiagnostics.TcDUT | 11 -------- .../DUTs/Safety/WIP/ST_SafetyFeedback.TcDUT | 11 -------- .../DUTs/Safety/WIP/ST_SafetyStatus.TcDUT | 11 -------- ...ST_SequenceIn.TcDUT => ST_SegmentIn.TcDUT} | 4 +-- .../DUTs/Safety/WIP/ST_Sequence.TcDUT | 13 --------- .../DUTs/Safety/WIP/ST_SequenceOut.TcDUT | 10 ------- .../DUTs/Safety/WIP/ST_SubSystem.TcDUT | 13 --------- .../DUTs/Safety/WIP/ST_SubSystemIn.TcDUT | 11 -------- .../DUTs/Safety/WIP/ST_SubSystemOut.TcDUT | 11 -------- 20 files changed, 162 insertions(+), 134 deletions(-) create mode 100644 solution/tc_project_app/DUTs/Safety/ST_MCCStatus.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/ST_MCCStatusIn.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/ST_MCCStatusOut.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatus.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatusIn.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatusOut.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/ST_PNOZRawIn.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/ST_PNOZRawOut.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyDiagnostics.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyFeedback.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyStatus.TcDUT rename solution/tc_project_app/DUTs/Safety/WIP/{ST_SequenceIn.TcDUT => ST_SegmentIn.TcDUT} (54%) delete mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_Sequence.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_SequenceOut.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystem.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystemIn.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystemOut.TcDUT diff --git a/solution/tc_project_app/DUTs/Safety/ST_MCCStatus.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_MCCStatus.TcDUT new file mode 100644 index 0000000..b93c74a --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/ST_MCCStatus.TcDUT @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_MCCStatusIn.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_MCCStatusIn.TcDUT new file mode 100644 index 0000000..adce859 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/ST_MCCStatusIn.TcDUT @@ -0,0 +1,27 @@ + + + + IPC, will not change from cabinet to cabinet +TYPE ST_MCCStatusIn : +STRUCT + bitHeartbeat: BIT; //PNOZ (safety controller) checks that signal is pulsing every ~200ms + bitEStopOK: BIT; + bitRemote: BIT; + bitReserved3: BIT; + bitReserved4: BIT; + bitReserved5: BIT; + bitReserved6: BIT; + bitReserved7: BIT; + bitReserved8: BIT; + bitReserved9: BIT; + bitReserved10: BIT; + bitReserved11: BIT; + bitReserved12: BIT; + bitReserved13: BIT; + bitReserved14: BIT; + bitReserved15: BIT; +END_STRUCT +END_TYPE +]]> + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_MCCStatusOut.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_MCCStatusOut.TcDUT new file mode 100644 index 0000000..ae13adc --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/ST_MCCStatusOut.TcDUT @@ -0,0 +1,27 @@ + + + + PNOZ, will not change from cabinet to cabinet +TYPE ST_MCCStatusOut : +STRUCT + bitHeartbeat: BIT; //Feedback to the PNOZ (safety contoller) pulsed every ~200ms by the IPC + bitReserved1: BIT; + bitErrAck: BIT; + bitReserved3: BIT; + bitReserved4: BIT; + bitReserved5: BIT; + bitReserved6: BIT; + bitReserved7: BIT; + bitReserved8: BIT; + bitReserved9: BIT; + bitReserved10: BIT; + bitReserved11: BIT; + bitReserved12: BIT; + bitReserved13: BIT; + bitReserved14: BIT; + bitReserved15: BIT; +END_STRUCT +END_TYPE +]]> + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatus.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatus.TcDUT new file mode 100644 index 0000000..52b220b --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatus.TcDUT @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatusIn.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatusIn.TcDUT new file mode 100644 index 0000000..2e71007 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatusIn.TcDUT @@ -0,0 +1,27 @@ + + + + IPC, can be customized depending on cabinet +TYPE ST_MCC_CustomStatusIn : +STRUCT + bitEStopExperiment: BIT; + bitEStopOptical: BIT; + bitEStopExternal: BIT; + bitReserved19: BIT; + bitFocusDoorClosed: BIT; + bitFocusInRemote: BIT; //Allow requests to jog focus changer from NICOS + bitFocusChangerPos: BIT; //Request Changer move positive + bitFocusChangerNeg: BIT; //Request Changer move negative + bitReserved24: BIT; + bitReserved25: BIT; + bitReserved26: BIT; + bitReserved27: BIT; + bitReserved28: BIT; + bitReserved29: BIT; + bitReserved30: BIT; + bitReserved31: BIT; +END_STRUCT +END_TYPE +]]> + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatusOut.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatusOut.TcDUT new file mode 100644 index 0000000..67dd036 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatusOut.TcDUT @@ -0,0 +1,27 @@ + + + + PNOZ, can be customized depending on cabinet +TYPE ST_MCC_CustomStatusOut : +STRUCT + bitReserved16: BIT; + bitReserved17: BIT; + bitReserved18: BIT; + bitReserved19: BIT; + bitReserved20: BIT; + bitReserved21: BIT; + bitChangerMovingPos: BIT; //Set if moving in a positive direction + bitChangerMovingNeg: BIT; //Set if moving in a negative direction + bitReserved24: BIT; + bitReserved25: BIT; + bitReserved26: BIT; + bitReserved27: BIT; + bitReserved28: BIT; + bitReserved29: BIT; + bitReserved30: BIT; + bitReserved31: BIT; +END_STRUCT +END_TYPE +]]> + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT index 287e21b..529d3f4 100644 --- a/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT +++ b/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT @@ -2,20 +2,20 @@ PLC EtherCAT input data copied from the raw %I* process image. + ST_Safety references are linked to this internal mirror by mLinkRefs(). + mReadECATInput() updates this structure cyclically. *) TYPE ST_PNOZEtherCATIn : STRUCT - aSafetyFunctionIn: ARRAY[GVL_SafetyIO.cLOWER_BOUND_SF..GVL_SafetyIO.cUPPER_BOUND_SF] OF ST_SafetyFunctionIn; //Input Byte 04..11 + aMCCStatusIn: ST_MCCStatusIn; //Input Byte 00..01 + aMCC_CustomStatusIn: ST_MCC_CustomStatusIn; //Input Byte 02..03 + aSafetyFunctionIn: ARRAY[1..GVL_SafetyIO.cNBR_OF_SF] OF ST_SafetyFunctionIn; //Input Byte 04..15 stLEDState: ST_LEDState; //Input Byte 16 - stTableNumberIn: ST_TableNumberIn; //Input Byte 17 - stSegmentNumberIn: ST_SegmentNumberIn; //Input Byte 18 - - stSafetyStatus: ST_SafetyStatus; //Placeholder, WIP - aSubSystemIn: ARRAY[1..GVL_SafetyIO.cUPPER_NBR_OF_SS] OF ST_SubSystemIn; //Placeholder, WIP - stSequenceIn: ST_SequenceIn; //Placeholder, WIP + stTableNumberIn: ST_TableNumberIn; //Input Byte 17, Placeholder WIP + stSegmentNumberIn: ST_SegmentNumberIn; //Input Byte 18, Placeholder WIP + stSegmentIn: ST_SegmentIn; //Input Byte 19..31, Placeholder WIP END_STRUCT END_TYPE ]]> diff --git a/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT index c979711..8b7dc91 100644 --- a/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT +++ b/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT @@ -2,19 +2,17 @@ PNOZ EtherCAT output data mapped to the raw %Q* process image. +ST_Safety output references are linked directly to this structure by mLinkRefs(). *) TYPE ST_PNOZEtherCATOut : STRUCT - aSafetyFunctionOut: ARRAY[GVL_SafetyIO.cLOWER_BOUND_SF..GVL_SafetyIO.cUPPER_BOUND_SF] OF ST_SafetyFunctionOut; //Input Byte 04..11 + aMCCStatusOut: ST_MCCStatusOut; //Output Byte 00..01 + aMCC_CustomStatusOut: ST_MCC_CustomStatusOut; //Output Byte 02..03 + aSafetyFunctionOut: ARRAY[1..GVL_SafetyIO.cNBR_OF_SF] OF ST_SafetyFunctionOut; //Output Byte 04..15 - stTableNumberOut: ST_TableNumberOut; //Scanner Output Byte 17, Placeholder, WIP - stSegmentNumberOut: ST_SegmentNumberOut; //Scanner Output Byte 18, Placeholder, WIP - - stSafetyFeedback: ST_SafetyFeedback; //Placeholder, WIP - aSubSystemOut: ARRAY[1..GVL_SafetyIO.cUPPER_NBR_OF_SS] OF ST_SubSystemOut; //Placeholder, WIP - stSequenceOut: ST_SequenceOut; //Placeholder, WIP + stTableNumberOut: ST_TableNumberOut; //Output Byte 17, Placeholder WIP + stSegmentNumberOut: ST_SegmentNumberOut; //Output Byte 18, Placeholder WIP END_STRUCT END_TYPE ]]> diff --git a/solution/tc_project_app/DUTs/Safety/ST_PNOZRawIn.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_PNOZRawIn.TcDUT deleted file mode 100644 index 5b39f76..0000000 --- a/solution/tc_project_app/DUTs/Safety/ST_PNOZRawIn.TcDUT +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_PNOZRawOut.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_PNOZRawOut.TcDUT deleted file mode 100644 index 9fb9b5f..0000000 --- a/solution/tc_project_app/DUTs/Safety/ST_PNOZRawOut.TcDUT +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_Safety.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_Safety.TcDUT index c760177..17ca8c3 100644 --- a/solution/tc_project_app/DUTs/Safety/ST_Safety.TcDUT +++ b/solution/tc_project_app/DUTs/Safety/ST_Safety.TcDUT @@ -8,8 +8,11 @@ information from the raw input data. *) TYPE ST_Safety : STRUCT - aSafetyFunction: ARRAY[GVL_SafetyIO.cLOWER_BOUND_SF..GVL_SafetyIO.cUPPER_BOUND_SF] OF ST_SafetyFunction; + stMCCStatus: ST_MCCStatus; + stMCC_CustomStatus: ST_MCC_CustomStatus; + aSafetyFunction: ARRAY[1..GVL_SafetyIO.cNBR_OF_SF] OF ST_SafetyFunction; refLEDState: REFERENCE TO ST_LEDState; + stTableNumber: ST_TableNumber; //Placeholder, WIP stSegmentNumber: ST_SegmentNumber; //Placeholder, WIP END_STRUCT diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyDiagnostics.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyDiagnostics.TcDUT deleted file mode 100644 index 46d26f3..0000000 --- a/solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyDiagnostics.TcDUT +++ /dev/null @@ -1,11 +0,0 @@ - - - - need to define what purpose this struct serves -TYPE ST_SafetyDiagnostics : -STRUCT -END_STRUCT -END_TYPE -]]> - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyFeedback.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyFeedback.TcDUT deleted file mode 100644 index 1f4f6e1..0000000 --- a/solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyFeedback.TcDUT +++ /dev/null @@ -1,11 +0,0 @@ - - - - need to define what purpose this struct serves -TYPE ST_SafetyFeedback : -STRUCT -END_STRUCT -END_TYPE -]]> - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyStatus.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyStatus.TcDUT deleted file mode 100644 index 6e93bba..0000000 --- a/solution/tc_project_app/DUTs/Safety/WIP/ST_SafetyStatus.TcDUT +++ /dev/null @@ -1,11 +0,0 @@ - - - - need to define what purpose this struct serves -TYPE ST_SafetyStatus : -STRUCT -END_STRUCT -END_TYPE -]]> - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SequenceIn.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentIn.TcDUT similarity index 54% rename from solution/tc_project_app/DUTs/Safety/WIP/ST_SequenceIn.TcDUT rename to solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentIn.TcDUT index ea9f10a..c53456c 100644 --- a/solution/tc_project_app/DUTs/Safety/WIP/ST_SequenceIn.TcDUT +++ b/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentIn.TcDUT @@ -1,7 +1,7 @@  - - + - - - need to define what purpose this struct serves -TYPE ST_Sequence : -STRUCT - refIn: REFERENCE TO ST_SequenceIn; - refOut: REFERENCE TO ST_SequenceOut; -END_STRUCT -END_TYPE -]]> - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SequenceOut.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SequenceOut.TcDUT deleted file mode 100644 index 85a45bb..0000000 --- a/solution/tc_project_app/DUTs/Safety/WIP/ST_SequenceOut.TcDUT +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystem.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystem.TcDUT deleted file mode 100644 index 4db4c3b..0000000 --- a/solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystem.TcDUT +++ /dev/null @@ -1,13 +0,0 @@ - - - - need to define what purpose this struct serves -TYPE ST_SubSystem : -STRUCT - refIn: REFERENCE TO ST_SubSystemIn; - refOut: REFERENCE TO ST_SubSystemOut; -END_STRUCT -END_TYPE -]]> - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystemIn.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystemIn.TcDUT deleted file mode 100644 index b8f7478..0000000 --- a/solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystemIn.TcDUT +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystemOut.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystemOut.TcDUT deleted file mode 100644 index cb6b6ee..0000000 --- a/solution/tc_project_app/DUTs/Safety/WIP/ST_SubSystemOut.TcDUT +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - \ No newline at end of file From 2f69ee7bff3f45804bc028837756848f53328755 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Thu, 21 May 2026 20:43:23 +0200 Subject: [PATCH 19/41] MBP-388: Remove raw input/output layer --- .../tc_project_app/GVLs/GVL_SafetyIO.TcGVL | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL b/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL index 890854c..6b3a65d 100644 --- a/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL +++ b/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL @@ -3,30 +3,25 @@ PLC bytes, Scanner Input Bytes 00..31 - cPNOZ_RXPDO_BYTES: UINT := 19; //Total PLC -> PNOZ bytes, Scanner Output Bytes 00..18 - - cLOWER_BOUND_SF: UINT := 5; //Lower Bound = 5, Virtual Output/Input bytes 04..11, each containing 8 bits - cUPPER_BOUND_SF: UINT := 12; //Upper Bound = 12, Virtual Output/Input bytes 04..11, each containing 8 bits - cUPPER_NBR_OF_SS: UINT := 2; //Number of subsystems, Placeholder, WIP +cNBR_OF_SF: UINT := 12; //Virtual Output/Input bytes 04..15, each containing 8 bits +cNBR_OF_SS: UINT := 2; //Number of subsystems, Placeholder, WIP END_VAR ]]> From 8cdfe9e68ab84ada9f5cfe3486e7557260cc906e Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Thu, 21 May 2026 20:44:21 +0200 Subject: [PATCH 20/41] MBP-388: Remove functions --- .../F_MapRawInputToSafetyFunctionIn.TcPOU | 77 ----------------- .../F_MapSafetyFunctionOutToRawOutput.TcPOU | 85 ------------------- 2 files changed, 162 deletions(-) delete mode 100644 solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_MapRawInputToSafetyFunctionIn.TcPOU delete mode 100644 solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_MapSafetyFunctionOutToRawOutput.TcPOU diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_MapRawInputToSafetyFunctionIn.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_MapRawInputToSafetyFunctionIn.TcPOU deleted file mode 100644 index 379ecbf..0000000 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_MapRawInputToSafetyFunctionIn.TcPOU +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - GVL_SafetyIO.cUPPER_BOUND_SF) THEN - RETURN; -END_IF - -(* -The configured safety function range can start from any index. -Therefore, the selected safety function is converted to a zero-based index. - -Example: -If GVL_SafetyIO.cLOWER_BOUND_SF = 5 -nSafetyFunction = 5 -> nZeroBasedIndex = 0 -nSafetyFunction = 6 -> nZeroBasedIndex = 1 -nSafetyFunction = 7 -> nZeroBasedIndex = 2 -*) -nZeroBasedIndex := nSafetyFunction - GVL_SafetyIO.cLOWER_BOUND_SF; -nByteIndex := (nZeroBasedIndex / 2) + 1; //Two safety functions are stored in each byte -bUpperNibble := (nZeroBasedIndex MOD 2) = 1; //Odd indexes use upper nibble, even indexes use lower nibble - -byRaw := stRawIn.abyInput[nByteIndex]; - -(* -A bit mask is used to check one specific bit in the raw byte. -The expression: (byRaw AND BYTE#16#01) <> BYTE#0 - -Works like this: -1. AND keeps only the bit selected by the mask. -2. All other bits are cleared. -3. If the result is not zero, that bit was set. -4. The comparison returns TRUE or FALSE. - -Example: -bitEnabled -> bit 0 -> mask BYTE#16#01 -> 0000 0001 -bitReady -> bit 1 -> mask BYTE#16#02 -> 0000 0010 -bitFault -> bit 2 -> mask BYTE#16#04 -> 0000 0100 -bitStart -> bit 3 -> mask BYTE#16#08 -> 0000 1000 -*) -IF NOT bUpperNibble THEN - //Lower nibble: bits 0..3 - F_MapRawInputToSafetyFunctionIn.bitEnabled := (byRaw AND BYTE#16#01) <> BYTE#0; - F_MapRawInputToSafetyFunctionIn.bitReady := (byRaw AND BYTE#16#02) <> BYTE#0; - F_MapRawInputToSafetyFunctionIn.bitFault := (byRaw AND BYTE#16#04) <> BYTE#0; - F_MapRawInputToSafetyFunctionIn.bitStart := (byRaw AND BYTE#16#08) <> BYTE#0; -ELSE - //Upper nibble: bits 4..7 - F_MapRawInputToSafetyFunctionIn.bitEnabled := (byRaw AND BYTE#16#10) <> BYTE#0; - F_MapRawInputToSafetyFunctionIn.bitReady := (byRaw AND BYTE#16#20) <> BYTE#0; - F_MapRawInputToSafetyFunctionIn.bitFault := (byRaw AND BYTE#16#40) <> BYTE#0; - F_MapRawInputToSafetyFunctionIn.bitStart := (byRaw AND BYTE#16#80) <> BYTE#0; -END_IF -]]> - - - \ No newline at end of file diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_MapSafetyFunctionOutToRawOutput.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_MapSafetyFunctionOutToRawOutput.TcPOU deleted file mode 100644 index 835dc6a..0000000 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_MapSafetyFunctionOutToRawOutput.TcPOU +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - GVL_SafetyIO.cUPPER_BOUND_SF) THEN - RETURN; -END_IF -(* -The configured safety function range can start from any index. -Therefore, the selected safety function is converted to a zero-based index. - -Example: -If GVL_SafetyIO.cLOWER_BOUND_SF = 5 -nSafetyFunction = 5 -> nZeroBasedIndex = 0 -nSafetyFunction = 6 -> nZeroBasedIndex = 1 -nSafetyFunction = 7 -> nZeroBasedIndex = 2 -*) -nZeroBasedIndex := nSafetyFunction - GVL_SafetyIO.cLOWER_BOUND_SF; -nByteIndex := (nZeroBasedIndex / 2) + 1; //Two safety functions are stored in each byte -bUpperNibble := (nZeroBasedIndex MOD 2) = 1; //Odd indexes use upper nibble, even indexes use lower nibble - -(* -Build one 4-bit value from the safety function output structure. -Each BOOL is written into one bit of byValue using OR. -If the BOOL is TRUE, the corresponding bit is set. -If the BOOL is FALSE, the corresponding bit remains 0. - -Bit layout inside byValue: -bitDiagOk -> bit 0 -> mask BYTE#16#01 -> 0000 0001 -bitOutput -> bit 1 -> mask BYTE#16#02 -> 0000 0010 -bitRequest -> bit 2 -> mask BYTE#16#04 -> 0000 0100 -bitDummy -> bit 3 -> mask BYTE#16#08 -> 0000 1000 -*) -byValue := BYTE#0; - -IF stSafetyFunctionOut.bitDiagOk THEN - byValue := byValue OR BYTE#16#01; -END_IF - -IF stSafetyFunctionOut.bitOutput THEN - byValue := byValue OR BYTE#16#02; -END_IF - -IF stSafetyFunctionOut.bitRequest THEN - byValue := byValue OR BYTE#16#04; -END_IF - -IF stSafetyFunctionOut.bitDummy THEN - byValue := byValue OR BYTE#16#08; -END_IF - -IF NOT bUpperNibble THEN - //Lower nibble: bits 0..3 - stRawOut.abyOutput[nByteIndex] := - (stRawOut.abyOutput[nByteIndex] AND BYTE#16#F0) OR byValue; -ELSE - //Upper nibble: bits 4..7 - stRawOut.abyOutput[nByteIndex] := - (stRawOut.abyOutput[nByteIndex] AND BYTE#16#0F) OR SHL(byValue, 4); -END_IF - -F_MapSafetyFunctionOutToRawOutput := TRUE; -]]> - - - \ No newline at end of file From 82ad5cdf0bc014b6aaed70e1eff2244c983add52 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Thu, 21 May 2026 20:45:14 +0200 Subject: [PATCH 21/41] MBP-388: Clean up motion safety Improves comments and keeps only necessary code to map input/output from the safety controller. --- .../Applications/Safety/FB_MotionSafety.TcPOU | 112 +++++------------- .../Applications/Safety/Motion_Safety.TcPOU | 22 ++-- 2 files changed, 41 insertions(+), 93 deletions(-) diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU index bd6d639..ad4566a 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU @@ -7,29 +7,22 @@ VAR_INPUT stSafety: REFERENCE TO ST_Safety; END_VAR VAR_OUTPUT - stECATIn: ST_PNOZEtherCATIn; - stECATOut: ST_PNOZEtherCATOut; + bDone: BOOL; END_VAR VAR - stSafetyFeedback: ST_SafetyFeedback; //Placeholder, WIP - stSafetyDiagnostics: ST_SafetyDiagnostics; //Placeholder, WIP - + stECATIn: ST_PNOZEtherCATIn; stPNOZCommDiag: ST_PNOZCommDiag; - i: UINT := 1; //Index for, for loops bRefsLinked: BOOL := FALSE; END_VAR ]]> - @@ -51,88 +50,37 @@ END_VAR ]]> PLC - stSafety.aSafetyFunction[i].refIn REF=stECATIn.aSafetyFunctionIn[i]; +(* +PNOZ -> PLC input references +PLC -> PNOZ output references + +Inputs are linked to the internal copied EtherCAT input structure stECATIn. +Outputs are linked directly to the mapped EtherCAT output process image. +*) +stSafety.stMCCStatus.refIn REF=stECATIn.aMCCStatusIn; +stSafety.stMCCStatus.refOut REF=GVL_SafetyIO.stPNOZEtherCATOut.aMCCStatusOut; - //PLC -> PNOZ - stSafety.aSafetyFunction[i].refOut REF=stECATOut.aSafetyFunctionOut[i]; +stSafety.stMCC_CustomStatus.refIn REF=stECATIn.aMCC_CustomStatusIn; +stSafety.stMCC_CustomStatus.refOut REF=GVL_SafetyIO.stPNOZEtherCATOut.aMCC_CustomStatusOut; + +FOR i := 1 TO GVL_SafetyIO.cNBR_OF_SF DO + stSafety.aSafetyFunction[i].refIn REF=stECATIn.aSafetyFunctionIn[i]; + stSafety.aSafetyFunction[i].refOut REF=GVL_SafetyIO.stPNOZEtherCATOut.aSafetyFunctionOut[i]; END_FOR -//PNOZ -> PLC stSafety.refLEDState REF=stECATIn.stLEDState; stSafety.stTableNumber.refIn REF=stECATIn.stTableNumberIn; stSafety.stSegmentNumber.refIn REF=stECATIn.stSegmentNumberIn; -//PLC -> PNOZ -stSafety.stTableNumber.refOut REF=stECATOut.stTableNumberOut; -stSafety.stSegmentNumber.refOut REF=stECATOut.stSegmentNumberOut; +stSafety.stTableNumber.refOut REF=GVL_SafetyIO.stPNOZEtherCATOut.stTableNumberOut; +stSafety.stSegmentNumber.refOut REF=GVL_SafetyIO.stPNOZEtherCATOut.stSegmentNumberOut; mLinkRefs := TRUE; -]]> - - - - - - selects the safety function. -refSafetyIn.bEnabled --> selects the bit/state of that safety function. -*) - -mReadECATInput := FALSE; - -//PNOZ safety function inputs -FOR i := GVL_SafetyIO.cLOWER_BOUND_SF TO GVL_SafetyIO.cUPPER_BOUND_SF DO - stECATIn.aSafetyFunctionIn[i] := F_MapRawInputToSafetyFunctionIn(stRawIn := GVL_SafetyIO.stPNOZRawIn, nSafetyFunction := i); -END_FOR - -//PNOZ LED state -stECATIn.stLEDState.nLEDState := GVL_SafetyIO.stLEDState.nLEDState; - -mReadECATInput := TRUE; -]]> - - - - - - diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU index 4ef1e0d..1d83d84 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU @@ -13,22 +13,22 @@ END_VAR ]]> From 5884657b6c4f384d12952603ad47a489fd345768 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Fri, 22 May 2026 09:51:14 +0200 Subject: [PATCH 22/41] MBP-388: Map using references --- .../Applications/Safety/Motion_Safety.TcPOU | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU index 1d83d84..d33498d 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU @@ -3,7 +3,8 @@ Date: Fri, 22 May 2026 09:52:43 +0200 Subject: [PATCH 23/41] MBP-388: Change to directly copying data --- .../DUTs/Safety/ST_MCCStatus.TcDUT | 4 +- .../DUTs/Safety/ST_MCC_CustomStatus.TcDUT | 4 +- .../DUTs/Safety/ST_PNOZEtherCATIn.TcDUT | 6 +- .../DUTs/Safety/ST_PNOZEtherCATOut.TcDUT | 5 +- .../DUTs/Safety/ST_Safety.TcDUT | 2 +- .../DUTs/Safety/ST_SafetyFunction.TcDUT | 4 +- .../DUTs/Safety/WIP/ST_SegmentNumber.TcDUT | 4 +- .../DUTs/Safety/WIP/ST_TableNumber.TcDUT | 4 +- .../tc_project_app/GVLs/GVL_SafetyIO.TcGVL | 3 - .../Applications/Safety/FB_MotionSafety.TcPOU | 67 ++++++++----------- .../Applications/Safety/Motion_Safety.TcPOU | 10 ++- 11 files changed, 44 insertions(+), 69 deletions(-) diff --git a/solution/tc_project_app/DUTs/Safety/ST_MCCStatus.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_MCCStatus.TcDUT index b93c74a..b1a4350 100644 --- a/solution/tc_project_app/DUTs/Safety/ST_MCCStatus.TcDUT +++ b/solution/tc_project_app/DUTs/Safety/ST_MCCStatus.TcDUT @@ -7,8 +7,8 @@ input/output represents bits 00-15 in safety controller. *) TYPE ST_MCCStatus : STRUCT - refIn: REFERENCE TO ST_MCCStatusIn; - refOut: REFERENCE TO ST_MCCStatusOut; + In: ST_MCCStatusIn; + Out: ST_MCCStatusOut; END_STRUCT END_TYPE ]]> diff --git a/solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatus.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatus.TcDUT index 52b220b..ba8e1cc 100644 --- a/solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatus.TcDUT +++ b/solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatus.TcDUT @@ -7,8 +7,8 @@ input/output represents bits 16-31 in safety controller. *) TYPE ST_MCC_CustomStatus : STRUCT - refIn: REFERENCE TO ST_MCC_CustomStatusIn; - refOut: REFERENCE TO ST_MCC_CustomStatusOut; + In: ST_MCC_CustomStatusIn; + Out: ST_MCC_CustomStatusOut; END_STRUCT END_TYPE ]]> diff --git a/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT index 529d3f4..f9ed4bc 100644 --- a/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT +++ b/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT @@ -1,11 +1,7 @@  - PLC EtherCAT input data copied from the raw %I* process image. - ST_Safety references are linked to this internal mirror by mLinkRefs(). - mReadECATInput() updates this structure cyclically. -*) + PLC EtherCAT input data copied from the raw %I* process image. TYPE ST_PNOZEtherCATIn : STRUCT aMCCStatusIn: ST_MCCStatusIn; //Input Byte 00..01 diff --git a/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT index 8b7dc91..ad50635 100644 --- a/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT +++ b/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT @@ -1,10 +1,7 @@  - PNOZ EtherCAT output data mapped to the raw %Q* process image. -ST_Safety output references are linked directly to this structure by mLinkRefs(). -*) + PNOZ EtherCAT output data mapped to the raw %Q* process image. TYPE ST_PNOZEtherCATOut : STRUCT aMCCStatusOut: ST_MCCStatusOut; //Output Byte 00..01 diff --git a/solution/tc_project_app/DUTs/Safety/ST_Safety.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_Safety.TcDUT index 17ca8c3..c745544 100644 --- a/solution/tc_project_app/DUTs/Safety/ST_Safety.TcDUT +++ b/solution/tc_project_app/DUTs/Safety/ST_Safety.TcDUT @@ -11,7 +11,7 @@ STRUCT stMCCStatus: ST_MCCStatus; stMCC_CustomStatus: ST_MCC_CustomStatus; aSafetyFunction: ARRAY[1..GVL_SafetyIO.cNBR_OF_SF] OF ST_SafetyFunction; - refLEDState: REFERENCE TO ST_LEDState; + stLEDState: ST_LEDState; stTableNumber: ST_TableNumber; //Placeholder, WIP stSegmentNumber: ST_SegmentNumber; //Placeholder, WIP diff --git a/solution/tc_project_app/DUTs/Safety/ST_SafetyFunction.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_SafetyFunction.TcDUT index 86e7268..68fe456 100644 --- a/solution/tc_project_app/DUTs/Safety/ST_SafetyFunction.TcDUT +++ b/solution/tc_project_app/DUTs/Safety/ST_SafetyFunction.TcDUT @@ -3,8 +3,8 @@ diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumber.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumber.TcDUT index be589db..c301398 100644 --- a/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumber.TcDUT +++ b/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumber.TcDUT @@ -4,8 +4,8 @@ need to define what purpose this struct serves TYPE ST_SegmentNumber : STRUCT - refIn: REFERENCE TO ST_SegmentNumberIn; - refOut: REFERENCE TO ST_SegmentNumberOut; + In: ST_SegmentNumberIn; + Out: ST_SegmentNumberOut; END_STRUCT END_TYPE ]]> diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumber.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumber.TcDUT index ea8609c..d1ce545 100644 --- a/solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumber.TcDUT +++ b/solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumber.TcDUT @@ -4,8 +4,8 @@ need to define what purpose this struct serves TYPE ST_TableNumber : STRUCT - refIn: REFERENCE TO ST_TableNumberIn; - refOut: REFERENCE TO ST_TableNumberOut; + In: ST_TableNumberIn; + Out: ST_TableNumberOut; END_STRUCT END_TYPE ]]> diff --git a/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL b/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL index 6b3a65d..28eae8f 100644 --- a/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL +++ b/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL @@ -13,9 +13,6 @@ stPNOZEtherCATIn AT %I*: ST_PNOZEtherCATIn; //Raw EtherCAT input {attribute 'TcLinkTo' := 'TIID^PNOZ (EtherCAT)^Box (PNOZ m ES EtherCAT)^SmPdoVariables^PNOZ_m_ES_EtherCAT__2_2__SM_2^RxPDO'} stPNOZEtherCATOut AT %Q*: ST_PNOZEtherCATOut; //Raw EtherCAT output -//{attribute 'TcLinkTo' := 'TIID^PNOZ (EtherCAT)^Box (PNOZ m ES EtherCAT)^TxPDO^LED State'} -//stLEDState AT %I*: ST_LEDState; - stPNOZEtherCATStatus: ST_PNOZEtherCATStatus; //Status struct for the PNOZ m ES EtherCAT, includes WcState and InfoData END_VAR diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU index ad4566a..e3c7245 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU @@ -3,23 +3,23 @@ - - + - PLC input references -PLC -> PNOZ output references +stSafetyData.stMCCStatus.In := GVL_SafetyIO.stPNOZEtherCATIn.aMCCStatusIn; +stSafetyData.stMCCStatus.Out := GVL_SafetyIO.stPNOZEtherCATOut.aMCCStatusOut; -Inputs are linked to the internal copied EtherCAT input structure stECATIn. -Outputs are linked directly to the mapped EtherCAT output process image. -*) -stSafety.stMCCStatus.refIn REF=stECATIn.aMCCStatusIn; -stSafety.stMCCStatus.refOut REF=GVL_SafetyIO.stPNOZEtherCATOut.aMCCStatusOut; - -stSafety.stMCC_CustomStatus.refIn REF=stECATIn.aMCC_CustomStatusIn; -stSafety.stMCC_CustomStatus.refOut REF=GVL_SafetyIO.stPNOZEtherCATOut.aMCC_CustomStatusOut; +stSafetyData.stMCC_CustomStatus.In := GVL_SafetyIO.stPNOZEtherCATIn.aMCC_CustomStatusIn; +stSafetyData.stMCC_CustomStatus.Out := GVL_SafetyIO.stPNOZEtherCATOut.aMCC_CustomStatusOut; FOR i := 1 TO GVL_SafetyIO.cNBR_OF_SF DO - stSafety.aSafetyFunction[i].refIn REF=stECATIn.aSafetyFunctionIn[i]; - stSafety.aSafetyFunction[i].refOut REF=GVL_SafetyIO.stPNOZEtherCATOut.aSafetyFunctionOut[i]; + stSafetyData.aSafetyFunction[i].In := GVL_SafetyIO.stPNOZEtherCATIn.aSafetyFunctionIn[i]; + stSafetyData.aSafetyFunction[i].Out := GVL_SafetyIO.stPNOZEtherCATOut.aSafetyFunctionOut[i]; END_FOR -stSafety.refLEDState REF=stECATIn.stLEDState; -stSafety.stTableNumber.refIn REF=stECATIn.stTableNumberIn; -stSafety.stSegmentNumber.refIn REF=stECATIn.stSegmentNumberIn; +stSafetyData.stLEDState := GVL_SafetyIO.stPNOZEtherCATIn.stLEDState; +stSafetyData.stTableNumber.In := GVL_SafetyIO.stPNOZEtherCATIn.stTableNumberIn; +stSafetyData.stSegmentNumber.In := GVL_SafetyIO.stPNOZEtherCATIn.stSegmentNumberIn; + +stSafetyData.stTableNumber.Out := GVL_SafetyIO.stPNOZEtherCATOut.stTableNumberOut; +stSafetyData.stSegmentNumber.Out := GVL_SafetyIO.stPNOZEtherCATOut.stSegmentNumberOut; + +mMapSafetyData := TRUE; + -stSafety.stTableNumber.refOut REF=GVL_SafetyIO.stPNOZEtherCATOut.stTableNumberOut; -stSafety.stSegmentNumber.refOut REF=GVL_SafetyIO.stPNOZEtherCATOut.stSegmentNumberOut; -mLinkRefs := TRUE; ]]> diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU index d33498d..16c3ca3 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU @@ -14,19 +14,17 @@ END_VAR ]]> Date: Fri, 22 May 2026 09:55:24 +0200 Subject: [PATCH 24/41] MBP-388: Fix whitespace --- .../Applications/Safety/Motion_Safety.TcPOU | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU index 16c3ca3..4b2e10f 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU @@ -3,8 +3,8 @@ Date: Fri, 22 May 2026 14:44:58 +0200 Subject: [PATCH 25/41] MBP-388: Add files to solution --- solution/tc_project_app/POUs/MAIN.TcPOU | 30 +------ .../tc_project_app/tc_project_app.plcproj | 81 +++++++++++++++++++ 2 files changed, 85 insertions(+), 26 deletions(-) diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 52d14f3..04bdaef 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -27,10 +27,6 @@ VAR fbGetDeviceIdentification: FB_GetDeviceIdentificationEx; nTestNum: UINT :=0 ; //Variable used in ESS's FAT_SAT_tools scripts to keep track of the test number - - // Motion Safety - fbMotionSafety : FB_MotionSafety; - stMCCSafetyFunctions : ST_MCCSafetyFunctions; END_VAR VAR PERSISTENT @@ -38,10 +34,10 @@ VAR PERSISTENT END_VAR ]]> - @@ -296,24 +292,6 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN END_FOR END_CASE END_IF -]]> - - - - - diff --git a/solution/tc_project_app/tc_project_app.plcproj b/solution/tc_project_app/tc_project_app.plcproj index 0f497c1..f5f98b8 100644 --- a/solution/tc_project_app/tc_project_app.plcproj +++ b/solution/tc_project_app/tc_project_app.plcproj @@ -24,6 +24,75 @@ Code + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + Code @@ -31,6 +100,9 @@ Code true + + Code + Code @@ -40,6 +112,12 @@ Code + + Code + + + Code + Code @@ -252,9 +330,12 @@ + + + From 3cafb9ea70a8a598577dd1cfdbcbad729aee5724 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Tue, 14 Jul 2026 09:15:35 +0200 Subject: [PATCH 26/41] MBP-388: Update generic safety code Include only the safety code required by tc_generic. Keep the implementation reusable across different MCCs. --- .../Safety/{ => PNOZ}/E_SafetyFunctions.TcDUT | 13 +- .../DUTs/Safety/PNOZ/ST_LEDState.TcDUT | 19 +++ .../DUTs/Safety/PNOZ/ST_MCCStatusIn.TcDUT | 27 ++++ .../DUTs/Safety/PNOZ/ST_MCCStatusOut.TcDUT | 27 ++++ .../Safety/PNOZ/ST_MCC_CustomStatusIn.TcDUT | 27 ++++ .../Safety/PNOZ/ST_MCC_CustomStatusOut.TcDUT | 27 ++++ .../Safety/{ => PNOZ}/ST_PNOZCommDiag.TcDUT | 0 .../Safety/{ => PNOZ}/ST_PNOZEtherCATIn.TcDUT | 8 +- .../{ => PNOZ}/ST_PNOZEtherCATOut.TcDUT | 7 +- .../Safety/PNOZ/ST_PNOZEtherCATStatus.TcDUT | 25 ++++ .../{ => PNOZ}/ST_SafetyFunctionIn.TcDUT | 2 +- .../{ => PNOZ}/ST_SafetyFunctionOut.TcDUT | 0 .../DUTs/Safety/ST_LEDState.TcDUT | 12 -- .../DUTs/Safety/ST_MCCStatus.TcDUT | 16 -- .../DUTs/Safety/ST_MCCStatusIn.TcDUT | 27 ---- .../DUTs/Safety/ST_MCCStatusOut.TcDUT | 27 ---- .../DUTs/Safety/ST_MCC_CustomStatus.TcDUT | 16 -- .../DUTs/Safety/ST_MCC_CustomStatusIn.TcDUT | 27 ---- .../DUTs/Safety/ST_MCC_CustomStatusOut.TcDUT | 27 ---- .../DUTs/Safety/ST_PNOZEtherCATStatus.TcDUT | 25 ---- .../DUTs/Safety/ST_Safety.TcDUT | 16 +- .../DUTs/Safety/ST_SafetyFunction.TcDUT | 12 -- .../DUTs/Safety/ST_SafetyIn.TcDUT | 17 +++ .../DUTs/Safety/ST_SafetyOut.TcDUT | 16 ++ .../Safety/Technosoft/ST_TechnosoftIn.TcDUT | 42 ++++++ .../Technosoft/ST_TechnosoftMotionError.TcDUT | 26 ++++ .../DUTs/Safety/WIP/ST_SegmentIn.TcDUT | 10 -- .../DUTs/Safety/WIP/ST_SegmentNumber.TcDUT | 13 -- .../DUTs/Safety/WIP/ST_SegmentNumberIn.TcDUT | 10 -- .../DUTs/Safety/WIP/ST_SegmentNumberOut.TcDUT | 10 -- .../DUTs/Safety/WIP/ST_TableNumber.TcDUT | 13 -- .../DUTs/Safety/WIP/ST_TableNumberIn.TcDUT | 10 -- .../DUTs/Safety/WIP/ST_TableNumberOut.TcDUT | 10 -- .../tc_project_app/GVLs/GVL_SafetyIO.TcGVL | 31 ++-- .../Applications/Safety/FB_MotionSafety.TcPOU | 56 ++++--- .../Safety/FB_PulseGenerator.TcPOU | 47 ++++++ .../Applications/Safety/Motion_Safety.TcPOU | 140 ++++++++++++++++-- .../tc_project_app/tc_project_app.plcproj | 58 +++----- 38 files changed, 523 insertions(+), 373 deletions(-) rename solution/tc_project_app/DUTs/Safety/{ => PNOZ}/E_SafetyFunctions.TcDUT (77%) create mode 100644 solution/tc_project_app/DUTs/Safety/PNOZ/ST_LEDState.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCCStatusIn.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCCStatusOut.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCC_CustomStatusIn.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCC_CustomStatusOut.TcDUT rename solution/tc_project_app/DUTs/Safety/{ => PNOZ}/ST_PNOZCommDiag.TcDUT (100%) rename solution/tc_project_app/DUTs/Safety/{ => PNOZ}/ST_PNOZEtherCATIn.TcDUT (59%) rename solution/tc_project_app/DUTs/Safety/{ => PNOZ}/ST_PNOZEtherCATOut.TcDUT (61%) create mode 100644 solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATStatus.TcDUT rename solution/tc_project_app/DUTs/Safety/{ => PNOZ}/ST_SafetyFunctionIn.TcDUT (87%) rename solution/tc_project_app/DUTs/Safety/{ => PNOZ}/ST_SafetyFunctionOut.TcDUT (100%) delete mode 100644 solution/tc_project_app/DUTs/Safety/ST_LEDState.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/ST_MCCStatus.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/ST_MCCStatusIn.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/ST_MCCStatusOut.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatus.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatusIn.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatusOut.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATStatus.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/ST_SafetyFunction.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/ST_SafetyIn.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/ST_SafetyOut.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/Technosoft/ST_TechnosoftIn.TcDUT create mode 100644 solution/tc_project_app/DUTs/Safety/Technosoft/ST_TechnosoftMotionError.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentIn.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumber.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumberIn.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumberOut.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumber.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumberIn.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumberOut.TcDUT create mode 100644 solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_PulseGenerator.TcPOU diff --git a/solution/tc_project_app/DUTs/Safety/E_SafetyFunctions.TcDUT b/solution/tc_project_app/DUTs/Safety/PNOZ/E_SafetyFunctions.TcDUT similarity index 77% rename from solution/tc_project_app/DUTs/Safety/E_SafetyFunctions.TcDUT rename to solution/tc_project_app/DUTs/Safety/PNOZ/E_SafetyFunctions.TcDUT index 5a4b697..93e14ba 100644 --- a/solution/tc_project_app/DUTs/Safety/E_SafetyFunctions.TcDUT +++ b/solution/tc_project_app/DUTs/Safety/PNOZ/E_SafetyFunctions.TcDUT @@ -9,17 +9,14 @@ Add new safety functions to match the incoming safety functions from the PNOZmul Each safety function represents 4-bits of information. However the PLC still stores the incoming 4-bits into 1-byte. *) -TYPE E_SafetyFunctions : +TYPE E_SafetyFunctions: ( eNone, eEStop, - ePSSAccess, - eRestartPreventionExp, - eRestartPreventionOpt, - eStopMiddleFocus, - eEnableMiddleFocus, - eSafeTorqueOff, - eReserved + eSampleStop, + eSampleEnable, + eDetectorArmIsolate, + eDetectorEnable ); END_TYPE ]]> diff --git a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_LEDState.TcDUT b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_LEDState.TcDUT new file mode 100644 index 0000000..803ccbe --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_LEDState.TcDUT @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCCStatusIn.TcDUT b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCCStatusIn.TcDUT new file mode 100644 index 0000000..c84c1c1 --- /dev/null +++ b/solution/tc_project_app/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/solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCCStatusOut.TcDUT b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCCStatusOut.TcDUT new file mode 100644 index 0000000..f65ba8f --- /dev/null +++ b/solution/tc_project_app/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/solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCC_CustomStatusIn.TcDUT b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCC_CustomStatusIn.TcDUT new file mode 100644 index 0000000..405cfe6 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCC_CustomStatusIn.TcDUT @@ -0,0 +1,27 @@ + + + + IPC, can be customized depending on cabinet +TYPE ST_MCC_CustomStatusIn : +STRUCT + bit16_EStopExperimentOK: BIT; //The Expirement caves, bitEStopOK (MCC5) + bit17_EStopOpticalOK: BIT; //The Optical caves, bitEStopOK (MCC3) + bit18_EStopExternalOK: BIT; //The Selene Guides, bitEStopOK (MCC4) = bitEStopOK (MCC3) AND bitEStopOK (MCC5) + bit19_Reserved: BIT; + bit20_Reserved: BIT; + bit21_Reserved: BIT; + bit22_Reserved: BIT; + bit23_Reserved: BIT; + bit24_Reserved: BIT; + bit25_Reserved: BIT; + bit26_Reserved: BIT; + bit27_Reserved: BIT; + bit28_Reserved: BIT; + bit29_Reserved: BIT; + bit30_Reserved: BIT; + bit31_Reserved: BIT; +END_STRUCT +END_TYPE +]]> + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCC_CustomStatusOut.TcDUT b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCC_CustomStatusOut.TcDUT new file mode 100644 index 0000000..4219ac8 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCC_CustomStatusOut.TcDUT @@ -0,0 +1,27 @@ + + + + PNOZ, can be customized depending on cabinet +TYPE ST_MCC_CustomStatusOut : +STRUCT + bit16_Reserved: BIT; + bit17_Reserved: BIT; + bit18_Reserved: BIT; + bit19_Reserved: BIT; + bit20_Reserved: BIT; + bit21_Reserved: BIT; + bit22_Reserved: BIT; + bit23_Reserved: BIT; + bit24_Reserved: BIT; + bit25_Reserved: BIT; + bit26_Reserved: BIT; + bit27_Reserved: BIT; + bit28_Reserved: BIT; + bit29_Reserved: BIT; + bit30_Reserved: BIT; + bit31_Reserved: BIT; +END_STRUCT +END_TYPE +]]> + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_PNOZCommDiag.TcDUT b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZCommDiag.TcDUT similarity index 100% rename from solution/tc_project_app/DUTs/Safety/ST_PNOZCommDiag.TcDUT rename to solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZCommDiag.TcDUT diff --git a/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATIn.TcDUT similarity index 59% rename from solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT rename to solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATIn.TcDUT index f9ed4bc..242c306 100644 --- a/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATIn.TcDUT +++ b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATIn.TcDUT @@ -4,14 +4,10 @@ PLC EtherCAT input data copied from the raw %I* process image. TYPE ST_PNOZEtherCATIn : STRUCT - aMCCStatusIn: ST_MCCStatusIn; //Input Byte 00..01 - aMCC_CustomStatusIn: ST_MCC_CustomStatusIn; //Input Byte 02..03 + stMCCStatusIn: ST_MCCStatusIn; //Input Byte 00..01 + stMCC_CustomStatusIn: ST_MCC_CustomStatusIn; //Input Byte 02..03 aSafetyFunctionIn: ARRAY[1..GVL_SafetyIO.cNBR_OF_SF] OF ST_SafetyFunctionIn; //Input Byte 04..15 stLEDState: ST_LEDState; //Input Byte 16 - - stTableNumberIn: ST_TableNumberIn; //Input Byte 17, Placeholder WIP - stSegmentNumberIn: ST_SegmentNumberIn; //Input Byte 18, Placeholder WIP - stSegmentIn: ST_SegmentIn; //Input Byte 19..31, Placeholder WIP END_STRUCT END_TYPE ]]> diff --git a/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATOut.TcDUT similarity index 61% rename from solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT rename to solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATOut.TcDUT index ad50635..d19ece7 100644 --- a/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATOut.TcDUT +++ b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATOut.TcDUT @@ -4,12 +4,9 @@ PNOZ EtherCAT output data mapped to the raw %Q* process image. TYPE ST_PNOZEtherCATOut : STRUCT - aMCCStatusOut: ST_MCCStatusOut; //Output Byte 00..01 - aMCC_CustomStatusOut: ST_MCC_CustomStatusOut; //Output Byte 02..03 + stMCCStatusOut: ST_MCCStatusOut; //Output Byte 00..01 + stMCC_CustomStatusOut: ST_MCC_CustomStatusOut; //Output Byte 02..03 aSafetyFunctionOut: ARRAY[1..GVL_SafetyIO.cNBR_OF_SF] OF ST_SafetyFunctionOut; //Output Byte 04..15 - - stTableNumberOut: ST_TableNumberOut; //Output Byte 17, Placeholder WIP - stSegmentNumberOut: ST_SegmentNumberOut; //Output Byte 18, Placeholder WIP END_STRUCT END_TYPE ]]> diff --git a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATStatus.TcDUT b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATStatus.TcDUT new file mode 100644 index 0000000..b13ee38 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATStatus.TcDUT @@ -0,0 +1,25 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_SafetyFunctionIn.TcDUT b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_SafetyFunctionIn.TcDUT similarity index 87% rename from solution/tc_project_app/DUTs/Safety/ST_SafetyFunctionIn.TcDUT rename to solution/tc_project_app/DUTs/Safety/PNOZ/ST_SafetyFunctionIn.TcDUT index 972c798..11d425a 100644 --- a/solution/tc_project_app/DUTs/Safety/ST_SafetyFunctionIn.TcDUT +++ b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_SafetyFunctionIn.TcDUT @@ -5,7 +5,7 @@ STRUCT bitEnabled: BIT; bitReady: BIT; //Input TRUE, ready for RESET - bitFault: BIT; //Specific to this Safety Function + bitFault: BIT; //Specific to this safety function bitStart: BIT; //Status of start signal END_STRUCT END_TYPE diff --git a/solution/tc_project_app/DUTs/Safety/ST_SafetyFunctionOut.TcDUT b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_SafetyFunctionOut.TcDUT similarity index 100% rename from solution/tc_project_app/DUTs/Safety/ST_SafetyFunctionOut.TcDUT rename to solution/tc_project_app/DUTs/Safety/PNOZ/ST_SafetyFunctionOut.TcDUT diff --git a/solution/tc_project_app/DUTs/Safety/ST_LEDState.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_LEDState.TcDUT deleted file mode 100644 index a73501c..0000000 --- a/solution/tc_project_app/DUTs/Safety/ST_LEDState.TcDUT +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_MCCStatus.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_MCCStatus.TcDUT deleted file mode 100644 index b1a4350..0000000 --- a/solution/tc_project_app/DUTs/Safety/ST_MCCStatus.TcDUT +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_MCCStatusIn.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_MCCStatusIn.TcDUT deleted file mode 100644 index adce859..0000000 --- a/solution/tc_project_app/DUTs/Safety/ST_MCCStatusIn.TcDUT +++ /dev/null @@ -1,27 +0,0 @@ - - - - IPC, will not change from cabinet to cabinet -TYPE ST_MCCStatusIn : -STRUCT - bitHeartbeat: BIT; //PNOZ (safety controller) checks that signal is pulsing every ~200ms - bitEStopOK: BIT; - bitRemote: BIT; - bitReserved3: BIT; - bitReserved4: BIT; - bitReserved5: BIT; - bitReserved6: BIT; - bitReserved7: BIT; - bitReserved8: BIT; - bitReserved9: BIT; - bitReserved10: BIT; - bitReserved11: BIT; - bitReserved12: BIT; - bitReserved13: BIT; - bitReserved14: BIT; - bitReserved15: BIT; -END_STRUCT -END_TYPE -]]> - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_MCCStatusOut.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_MCCStatusOut.TcDUT deleted file mode 100644 index ae13adc..0000000 --- a/solution/tc_project_app/DUTs/Safety/ST_MCCStatusOut.TcDUT +++ /dev/null @@ -1,27 +0,0 @@ - - - - PNOZ, will not change from cabinet to cabinet -TYPE ST_MCCStatusOut : -STRUCT - bitHeartbeat: BIT; //Feedback to the PNOZ (safety contoller) pulsed every ~200ms by the IPC - bitReserved1: BIT; - bitErrAck: BIT; - bitReserved3: BIT; - bitReserved4: BIT; - bitReserved5: BIT; - bitReserved6: BIT; - bitReserved7: BIT; - bitReserved8: BIT; - bitReserved9: BIT; - bitReserved10: BIT; - bitReserved11: BIT; - bitReserved12: BIT; - bitReserved13: BIT; - bitReserved14: BIT; - bitReserved15: BIT; -END_STRUCT -END_TYPE -]]> - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatus.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatus.TcDUT deleted file mode 100644 index ba8e1cc..0000000 --- a/solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatus.TcDUT +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatusIn.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatusIn.TcDUT deleted file mode 100644 index 2e71007..0000000 --- a/solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatusIn.TcDUT +++ /dev/null @@ -1,27 +0,0 @@ - - - - IPC, can be customized depending on cabinet -TYPE ST_MCC_CustomStatusIn : -STRUCT - bitEStopExperiment: BIT; - bitEStopOptical: BIT; - bitEStopExternal: BIT; - bitReserved19: BIT; - bitFocusDoorClosed: BIT; - bitFocusInRemote: BIT; //Allow requests to jog focus changer from NICOS - bitFocusChangerPos: BIT; //Request Changer move positive - bitFocusChangerNeg: BIT; //Request Changer move negative - bitReserved24: BIT; - bitReserved25: BIT; - bitReserved26: BIT; - bitReserved27: BIT; - bitReserved28: BIT; - bitReserved29: BIT; - bitReserved30: BIT; - bitReserved31: BIT; -END_STRUCT -END_TYPE -]]> - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatusOut.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatusOut.TcDUT deleted file mode 100644 index 67dd036..0000000 --- a/solution/tc_project_app/DUTs/Safety/ST_MCC_CustomStatusOut.TcDUT +++ /dev/null @@ -1,27 +0,0 @@ - - - - PNOZ, can be customized depending on cabinet -TYPE ST_MCC_CustomStatusOut : -STRUCT - bitReserved16: BIT; - bitReserved17: BIT; - bitReserved18: BIT; - bitReserved19: BIT; - bitReserved20: BIT; - bitReserved21: BIT; - bitChangerMovingPos: BIT; //Set if moving in a positive direction - bitChangerMovingNeg: BIT; //Set if moving in a negative direction - bitReserved24: BIT; - bitReserved25: BIT; - bitReserved26: BIT; - bitReserved27: BIT; - bitReserved28: BIT; - bitReserved29: BIT; - bitReserved30: BIT; - bitReserved31: BIT; -END_STRUCT -END_TYPE -]]> - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATStatus.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATStatus.TcDUT deleted file mode 100644 index 1bb573e..0000000 --- a/solution/tc_project_app/DUTs/Safety/ST_PNOZEtherCATStatus.TcDUT +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_Safety.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_Safety.TcDUT index c745544..09f0993 100644 --- a/solution/tc_project_app/DUTs/Safety/ST_Safety.TcDUT +++ b/solution/tc_project_app/DUTs/Safety/ST_Safety.TcDUT @@ -1,20 +1,10 @@  - diff --git a/solution/tc_project_app/DUTs/Safety/ST_SafetyFunction.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_SafetyFunction.TcDUT deleted file mode 100644 index 68fe456..0000000 --- a/solution/tc_project_app/DUTs/Safety/ST_SafetyFunction.TcDUT +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_SafetyIn.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_SafetyIn.TcDUT new file mode 100644 index 0000000..287adf7 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/ST_SafetyIn.TcDUT @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_SafetyOut.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_SafetyOut.TcDUT new file mode 100644 index 0000000..5386e35 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/ST_SafetyOut.TcDUT @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/Technosoft/ST_TechnosoftIn.TcDUT b/solution/tc_project_app/DUTs/Safety/Technosoft/ST_TechnosoftIn.TcDUT new file mode 100644 index 0000000..3c0552c --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/Technosoft/ST_TechnosoftIn.TcDUT @@ -0,0 +1,42 @@ + + + + STO active (no power permission), 1 --> STO deactivated (power permission) + bit4: BIT; + bit5: BIT; + bit6: BIT; + bit7: BIT; + bit8: BIT; + bit9: BIT; + bit10: BIT; + bit11: BIT; + bit12: BIT; + bit13: BIT; + bit14: BIT; + bit15: BIT; + bit16: BIT; + bit17: BIT; + bit18: BIT; + bit19: BIT; + bit20: BIT; + bit21: BIT; + bit22: BIT; + bit23: BIT; + bit24: BIT; + bit25: BIT; + bit26: BIT; + bit27: BIT; + bit28: BIT; + bit29: BIT; + bit30: BIT; + bit31: BIT; +END_STRUCT +END_TYPE +]]> + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/Technosoft/ST_TechnosoftMotionError.TcDUT b/solution/tc_project_app/DUTs/Safety/Technosoft/ST_TechnosoftMotionError.TcDUT new file mode 100644 index 0000000..4f40bd9 --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/Technosoft/ST_TechnosoftMotionError.TcDUT @@ -0,0 +1,26 @@ + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentIn.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentIn.TcDUT deleted file mode 100644 index c53456c..0000000 --- a/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentIn.TcDUT +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumber.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumber.TcDUT deleted file mode 100644 index c301398..0000000 --- a/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumber.TcDUT +++ /dev/null @@ -1,13 +0,0 @@ - - - - need to define what purpose this struct serves -TYPE ST_SegmentNumber : -STRUCT - In: ST_SegmentNumberIn; - Out: ST_SegmentNumberOut; -END_STRUCT -END_TYPE -]]> - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumberIn.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumberIn.TcDUT deleted file mode 100644 index af9616a..0000000 --- a/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumberIn.TcDUT +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumberOut.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumberOut.TcDUT deleted file mode 100644 index 40665d9..0000000 --- a/solution/tc_project_app/DUTs/Safety/WIP/ST_SegmentNumberOut.TcDUT +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumber.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumber.TcDUT deleted file mode 100644 index d1ce545..0000000 --- a/solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumber.TcDUT +++ /dev/null @@ -1,13 +0,0 @@ - - - - need to define what purpose this struct serves -TYPE ST_TableNumber : -STRUCT - In: ST_TableNumberIn; - Out: ST_TableNumberOut; -END_STRUCT -END_TYPE -]]> - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumberIn.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumberIn.TcDUT deleted file mode 100644 index f5e7b1a..0000000 --- a/solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumberIn.TcDUT +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumberOut.TcDUT b/solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumberOut.TcDUT deleted file mode 100644 index 9118b31..0000000 --- a/solution/tc_project_app/DUTs/Safety/WIP/ST_TableNumberOut.TcDUT +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL b/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL index 28eae8f..889a9aa 100644 --- a/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL +++ b/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL @@ -3,22 +3,31 @@ diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU index e3c7245..b26e5b7 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU @@ -13,7 +13,7 @@ VAR_IN_OUT END_VAR VAR stPNOZCommDiag: ST_PNOZCommDiag; - i: UINT := 1; //Index for, for loops + i: INT := 1; //Index for, for loops END_VAR ]]> @@ -33,41 +33,61 @@ IF (stPNOZCommDiag.bitWcState = 1) THEN RETURN; END_IF -bDone := mMapSafetyData(stSafetyData := stSafety); +bDone := mReadInputs(stSafetyData := stSafety); ]]> - - + - + + + + + + diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_PulseGenerator.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_PulseGenerator.TcPOU new file mode 100644 index 0000000..134e5ce --- /dev/null +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_PulseGenerator.TcPOU @@ -0,0 +1,47 @@ + + + + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU index 4b2e10f..a569216 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU @@ -3,32 +3,152 @@ stSafety.stSafetyOut.stMCCStatusOut.bit0_Heartbeat, + bWatchdogFault => bMCCWatchdogFault +); + +bAxisEnableAllowed := + stSafety.stSafetyIn.stMCCStatusIn.bit1_EStopOK + AND bMCC_OK; -// Mapping complete, example usage: -IF fbMotionSafety.bDone THEN - bEStopEnabled := stSafety.aSafetyFunction[E_SafetyFunctions.eEStop].In.bitEnabled; - ELSE - bEStopEnabled := FALSE; +IF NOT bAxisEnableAllowed THEN + FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO + GVL.astAxes[iAxes].stControl.bEnable := FALSE; + END_FOR END_IF +//***INSERT APPLICATION SPECIFIC CODE HERE*** + +fbMotionSafety.mWriteOutputs(stSafetyData := stSafety); ]]> + + + + 100.0 THEN + fPWClamped := 100.0; +END_IF + +//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 tHeartbeatElapsed >= tHeartbeatPeriod THEN + tHeartbeatElapsed := tHeartbeatElapsed - tHeartbeatPeriod; +END_IF + +bHeartbeatOut := tHeartbeatElapsed < tHeartbeatOnTime; + +//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; + +mCheckMCCHeartbeat := NOT bWatchdogFault; +]]> + + \ No newline at end of file diff --git a/solution/tc_project_app/tc_project_app.plcproj b/solution/tc_project_app/tc_project_app.plcproj index f5f98b8..ac4696e 100644 --- a/solution/tc_project_app/tc_project_app.plcproj +++ b/solution/tc_project_app/tc_project_app.plcproj @@ -24,73 +24,55 @@ Code - + Code - + Code - + Code - + Code - + Code - + Code - + Code - + Code - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - + Code - + Code - + Code - + Code - + Code - + Code - + Code - + Code - + Code @@ -115,6 +97,9 @@ Code + + Code + Code @@ -330,8 +315,9 @@ + + - From 45f80e96794b6de57d79e559beea3f044057a1aa Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Tue, 14 Jul 2026 09:20:24 +0200 Subject: [PATCH 27/41] MBP-388: Fix whitespace --- .../Safety/FB_PulseGenerator.TcPOU | 90 ++++++++++++++----- .../Applications/Safety/Motion_Safety.TcPOU | 2 +- 2 files changed, 71 insertions(+), 21 deletions(-) diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_PulseGenerator.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_PulseGenerator.TcPOU index 134e5ce..7c3825c 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_PulseGenerator.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_PulseGenerator.TcPOU @@ -1,47 +1,97 @@  - + + fbTimer: 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 +]]> - 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 -//Run timer for current period -fbTimer(IN := TRUE, PT := tActiveTime); +//Start new timer phase +IF NOT bTimerRun THEN + bTimerRun := TRUE; + fbTimer(IN := FALSE, PT := tActiveTime); +END_IF +//Run timer +fbTimer(IN := TRUE, PT := tActiveTime); -//When current period is finished, toggle output and reset timer +//Phase complete IF fbTimer.Q THEN - bOut := NOT bOut; - - //Reset TON so the next ON/OFF phase starts cleanly fbTimer(IN := FALSE, PT := tActiveTime); -END_IF]]> + 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/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU index a569216..c0a061c 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU @@ -14,7 +14,7 @@ VAR bMCCHeartbeatInOld: BOOL; bMCCHeartbeatInit: BOOL; bMCCWatchdogFault: BOOL; - bMCC_OK: BOOL; + bMCC_OK: BOOL; END_VAR VAR CONSTANT tPLC_CYCLE_TIME: TIME := T#10MS; //PLC task cycle time From be7ea5c4100ac57cd7ca643024f3c07b66f3901b Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Tue, 8 Sep 2026 09:18:36 +0200 Subject: [PATCH 28/41] MBP-388: Update tc_project_app --- solution/tc_project_app/tc_project_app.plcproj | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/solution/tc_project_app/tc_project_app.plcproj b/solution/tc_project_app/tc_project_app.plcproj index ac4696e..4cf040c 100644 --- a/solution/tc_project_app/tc_project_app.plcproj +++ b/solution/tc_project_app/tc_project_app.plcproj @@ -24,6 +24,9 @@ Code + + Code + Code @@ -69,9 +72,6 @@ Code - - Code - Code @@ -100,9 +100,18 @@ Code + + Code + Code + + Code + + + Code + Code @@ -322,6 +331,7 @@ + From 7d6d940e0781fc95815ae1054fd5ca2fde9defa1 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Tue, 8 Sep 2026 09:19:05 +0200 Subject: [PATCH 29/41] MBP-388: Add interface I_SafetyProvider --- .../DUTs/Safety/I_SafetyProvider.TcIO | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 solution/tc_project_app/DUTs/Safety/I_SafetyProvider.TcIO diff --git a/solution/tc_project_app/DUTs/Safety/I_SafetyProvider.TcIO b/solution/tc_project_app/DUTs/Safety/I_SafetyProvider.TcIO new file mode 100644 index 0000000..c7c34cd --- /dev/null +++ b/solution/tc_project_app/DUTs/Safety/I_SafetyProvider.TcIO @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 8a9f0c4930a2972b0886c911aac87c076f018d33 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Tue, 8 Sep 2026 09:24:23 +0200 Subject: [PATCH 30/41] MBP-388: Cleanup and fix whitespace --- .../DUTs/Safety/I_SafetyProvider.TcIO | 18 +++++--- .../DUTs/Safety/PNOZ/ST_PNOZEtherCATIn.TcDUT | 2 +- .../DUTs/Safety/ST_SafetyIn.TcDUT | 2 - .../Safety/Technosoft/ST_TechnosoftIn.TcDUT | 42 ------------------- .../tc_project_app/GVLs/GVL_SafetyIO.TcGVL | 6 +-- 5 files changed, 14 insertions(+), 56 deletions(-) delete mode 100644 solution/tc_project_app/DUTs/Safety/Technosoft/ST_TechnosoftIn.TcDUT diff --git a/solution/tc_project_app/DUTs/Safety/I_SafetyProvider.TcIO b/solution/tc_project_app/DUTs/Safety/I_SafetyProvider.TcIO index c7c34cd..e9b025f 100644 --- a/solution/tc_project_app/DUTs/Safety/I_SafetyProvider.TcIO +++ b/solution/tc_project_app/DUTs/Safety/I_SafetyProvider.TcIO @@ -4,21 +4,27 @@ - + - + - + - + - + - + diff --git a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATIn.TcDUT b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATIn.TcDUT index 242c306..19f6067 100644 --- a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATIn.TcDUT +++ b/solution/tc_project_app/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 - aSafetyFunctionIn: ARRAY[1..GVL_SafetyIO.cNBR_OF_SF] OF ST_SafetyFunctionIn; //Input Byte 04..15 + astSafetyFunctionIn: ARRAY[1..GVL_SafetyIO.cNBR_OF_SF] OF ST_SafetyFunctionIn; //Input Byte 04..15 stLEDState: ST_LEDState; //Input Byte 16 END_STRUCT END_TYPE diff --git a/solution/tc_project_app/DUTs/Safety/ST_SafetyIn.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_SafetyIn.TcDUT index 287adf7..7a838c8 100644 --- a/solution/tc_project_app/DUTs/Safety/ST_SafetyIn.TcDUT +++ b/solution/tc_project_app/DUTs/Safety/ST_SafetyIn.TcDUT @@ -7,8 +7,6 @@ STRUCT stMCC_CustomStatusIn: ST_MCC_CustomStatusIn; astSafetyFunctionIn: ARRAY[1..GVL_SafetyIO.cNBR_OF_SF] OF ST_SafetyFunctionIn; stLEDState: ST_LEDState; - - astTechnosoftIn: ARRAY[1..GVL_SafetyIO.cNBR_OF_TECHNOSOFT] OF ST_TechnosoftIn; astTechnosoftMotionError: ARRAY[1..GVL_SafetyIO.cNBR_OF_TECHNOSOFT] OF ST_TechnosoftMotionError; END_STRUCT END_TYPE diff --git a/solution/tc_project_app/DUTs/Safety/Technosoft/ST_TechnosoftIn.TcDUT b/solution/tc_project_app/DUTs/Safety/Technosoft/ST_TechnosoftIn.TcDUT deleted file mode 100644 index 3c0552c..0000000 --- a/solution/tc_project_app/DUTs/Safety/Technosoft/ST_TechnosoftIn.TcDUT +++ /dev/null @@ -1,42 +0,0 @@ - - - - STO active (no power permission), 1 --> STO deactivated (power permission) - bit4: BIT; - bit5: BIT; - bit6: BIT; - bit7: BIT; - bit8: BIT; - bit9: BIT; - bit10: BIT; - bit11: BIT; - bit12: BIT; - bit13: BIT; - bit14: BIT; - bit15: BIT; - bit16: BIT; - bit17: BIT; - bit18: BIT; - bit19: BIT; - bit20: BIT; - bit21: BIT; - bit22: BIT; - bit23: BIT; - bit24: BIT; - bit25: BIT; - bit26: BIT; - bit27: BIT; - bit28: BIT; - bit29: BIT; - bit30: BIT; - bit31: BIT; -END_STRUCT -END_TYPE -]]> - - \ No newline at end of file diff --git a/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL b/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL index 889a9aa..ec07147 100644 --- a/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL +++ b/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL @@ -11,10 +11,6 @@ VAR_GLOBAL stPNOZEtherCATStatus: ST_PNOZEtherCATStatus; //Status struct for the PNOZ m ES EtherCAT, includes WcState and InfoData - //Inputs from the Technosoft drives - {attribute 'TcLinkTo' := '[1] := TIID^Device 2 (EtherCAT)^TA701 (iPOS8020 BX-CAT)^Transmit PDO 2 mapping parameters^Digital inputs; - [2] := TIID^Device 2 (EtherCAT)^TA702 (iPOS8020 BX-CAT)^Transmit PDO 2 mapping parameters^Digital inputs'} - astTechnosoftIn AT %I*: ARRAY[1..cNBR_OF_TECHNOSOFT] OF ST_TechnosoftIn; //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; @@ -22,7 +18,7 @@ VAR_GLOBAL astTechnosoftMotionError AT %I*: ARRAY[1..cNBR_OF_TECHNOSOFT] OF ST_TechnosoftMotionError; {attribute 'TcLinkTo' := 'TIID^Device 2 (EtherCAT)^KF201 (EK1100)^KF208 (EL2014)^DIG Outputs^Channel 3^Output'} - bSafetyAcknowlegeButtonLamp AT %Q*: BOOL; + bSafetyAcknowledgeLED AT %Q*: BOOL; END_VAR VAR_GLOBAL CONSTANT From e868ada7383b107ed175b1eb9de56926804a902a Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Tue, 8 Sep 2026 09:27:44 +0200 Subject: [PATCH 31/41] MBP-388: Add zone monitoring and safety provider Add Zone_Monitoring and implement the I_SafetyProvider properties in FB_MotionSafety. --- .../Applications/Safety/FB_MotionSafety.TcPOU | 73 ++++++++++++++++++- solution/tc_project_app/POUs/MAIN.TcPOU | 2 + 2 files changed, 71 insertions(+), 4 deletions(-) diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU index b26e5b7..16d45cc 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU @@ -1,19 +1,22 @@  - @@ -33,6 +36,8 @@ IF (stPNOZCommDiag.bitWcState = 1) THEN RETURN; END_IF +_bReadFromSafetyController := bEnable; + bDone := mReadInputs(stSafetyData := stSafety); ]]> @@ -53,16 +58,19 @@ stSafetyData.stSafetyIn.stMCC_CustomStatusIn := FOR i := 1 TO GVL_SafetyIO.cNBR_OF_SF DO stSafetyData.stSafetyIn.astSafetyFunctionIn[i] := - GVL_SafetyIO.stPNOZEtherCATIn.aSafetyFunctionIn[i]; + GVL_SafetyIO.stPNOZEtherCATIn.astSafetyFunctionIn[i]; END_FOR stSafetyData.stSafetyIn.stLEDState := GVL_SafetyIO.stPNOZEtherCATIn.stLEDState; FOR i := 1 TO GVL_SafetyIO.cNBR_OF_TECHNOSOFT DO - stSafety.stSafetyIn.astTechnosoftMotionError[i] := GVL_SafetyIO.astTechnosoftMotionError[i]; + stSafetyData.stSafetyIn.astTechnosoftMotionError[i] := + GVL_SafetyIO.astTechnosoftMotionError[i]; END_FOR +_bEStopOK := stSafetyData.stSafetyIn.stMCCStatusIn.bit1_EStopOK; + mReadInputs := TRUE; ]]> @@ -76,6 +84,7 @@ END_VAR + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 04bdaef..f0f1ebc 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -38,6 +38,8 @@ END_VAR //PROG(); //AXES(); Motion_Safety(); +Zone_Monitoring(); + ]]> From d9a19a16c56ace10ef4e7a3ac6e36d3f114030e0 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Tue, 8 Sep 2026 09:33:47 +0200 Subject: [PATCH 32/41] MBP-388: Refactor Motion_Safety into methods Extract generic logic into smaller methods to support reuse in the generic template. --- .../Safety/FB_ZoneMonitoring.TcPOU | 310 ++++++++++++++++++ .../Safety/F_TechnosoftErrorActive.TcPOU | 29 ++ .../Applications/Safety/Motion_Safety.TcPOU | 137 ++++++-- 3 files changed, 440 insertions(+), 36 deletions(-) create mode 100644 solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_ZoneMonitoring.TcPOU create mode 100644 solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_TechnosoftErrorActive.TcPOU diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_ZoneMonitoring.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_ZoneMonitoring.TcPOU new file mode 100644 index 0000000..eb02126 --- /dev/null +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_ZoneMonitoring.TcPOU @@ -0,0 +1,310 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 AND_THEN iSafetyProvider.P_ReadFromSafetyController THEN + bEStopReleased := iSafetyProvider.P_EStopOK; + bSTOReleased := iSafetyProvider.P_STO_OK; +END_IF; + +EStopReleased := bEStopReleased;]]> + + + + + + 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/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_TechnosoftErrorActive.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_TechnosoftErrorActive.TcPOU new file mode 100644 index 0000000..0318ef3 --- /dev/null +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_TechnosoftErrorActive.TcPOU @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU index c0a061c..1a1969a 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU @@ -6,7 +6,7 @@ VAR fbMotionSafety: FB_MotionSafety; stSafety: ST_Safety; bAxisEnableAllowed: BOOL; - iAxes: UINT; //Index for Axis + ftrigAxisEnableAllowed: F_TRIG; //Heartbeat tHeartbeatElapsed: TIME; @@ -15,6 +15,7 @@ VAR bMCCHeartbeatInit: BOOL; bMCCWatchdogFault: BOOL; bMCC_OK: BOOL; + fbSafetyAckLedPulse: FB_PulseGenerator; END_VAR VAR CONSTANT tPLC_CYCLE_TIME: TIME := T#10MS; //PLC task cycle time @@ -24,51 +25,23 @@ VAR CONSTANT END_VAR ]]> - stSafety.stSafetyOut.stMCCStatusOut.bit0_Heartbeat, - bWatchdogFault => bMCCWatchdogFault -); - -bAxisEnableAllowed := - stSafety.stSafetyIn.stMCCStatusIn.bit1_EStopOK - AND bMCC_OK; - -IF NOT bAxisEnableAllowed THEN - FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO - GVL.astAxes[iAxes].stControl.bEnable := FALSE; - END_FOR -END_IF - -//***INSERT APPLICATION SPECIFIC CODE HERE*** - +mMCCStatus(); //Heartbeat generation and MCC watchdog check +mTechnosoftStatus(); +mUpdateFaultFeedback(); +mHandleMotionPermission(); fbMotionSafety.mWriteOutputs(stSafetyData := stSafety); ]]> @@ -147,6 +120,98 @@ END_IF bWatchdogFault := tMCCWatchdogElapsed >= tWatchdogTime; mCheckMCCHeartbeat := NOT bWatchdogFault; +]]> + + + + + + + + + + + + stSafety.stSafetyOut.stMCCStatusOut.bit0_Heartbeat, + bWatchdogFault => bMCCWatchdogFault +); + +bAxisEnableAllowed := + stSafety.stSafetyIn.stMCCStatusIn.bit1_EStopOK + AND bMCC_OK; +]]> + + + + + + + + + + + + + + + + + + GVL_SafetyIO.bSafetyAcknowledgeLED); ]]> From 6e493fa10f9fe99e857d0ae43646db7cc779e35a Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Tue, 8 Sep 2026 09:35:22 +0200 Subject: [PATCH 33/41] MBP-388: Add Zone_Monitoring --- .../Applications/Safety/Zone_Monitoring.TcPOU | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Zone_Monitoring.TcPOU diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Zone_Monitoring.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Zone_Monitoring.TcPOU new file mode 100644 index 0000000..d688e9d --- /dev/null +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Zone_Monitoring.TcPOU @@ -0,0 +1,18 @@ + + + + + + , + aErrorMsg =>, + nAlarmGrpBitNumber =>); +]]> + + + \ No newline at end of file From a939fea8bf8586c4abcefb599f3ea282173f9a44 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Tue, 8 Sep 2026 09:39:23 +0200 Subject: [PATCH 34/41] MBP-388: Double square brackets --- .../Safety/FB_ZoneMonitoring.TcPOU | 22 +++++++++++++------ .../Applications/Safety/Zone_Monitoring.TcPOU | 3 ++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_ZoneMonitoring.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_ZoneMonitoring.TcPOU index eb02126..5c1655a 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_ZoneMonitoring.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_ZoneMonitoring.TcPOU @@ -63,10 +63,13 @@ END_VAR ]]> - + - + +END_VAR +]]> +END_CASE +]]> @@ -155,7 +160,8 @@ IF iSafetyProvider <> 0 AND_THEN iSafetyProvider.P_ReadFromSafetyController THEN bSTOReleased := iSafetyProvider.P_STO_OK; END_IF; -EStopReleased := bEStopReleased;]]> +EStopReleased := bEStopReleased; +]]> @@ -172,7 +178,8 @@ VAR_INST fbFastBlinkOff: TON; fbSlowBlinkOn: TON; fbSlowBlinkOff: TON; -END_VAR]]> +END_VAR +]]> + strArg := sErrorMessage); +]]> diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Zone_Monitoring.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Zone_Monitoring.TcPOU index d688e9d..ef5a344 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Zone_Monitoring.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Zone_Monitoring.TcPOU @@ -4,7 +4,8 @@ +END_VAR +]]> Date: Thu, 10 Sep 2026 13:05:09 +0200 Subject: [PATCH 35/41] MBP-388: Update tc_generic structure --- .../{Safety/PNOZ => }/E_SafetyFunctions.TcDUT | 12 +- .../PNOZ => }/ST_MCC_CustomStatusIn.TcDUT | 17 +- .../PNOZ => }/ST_MCC_CustomStatusOut.TcDUT | 6 +- .../DUTs/Safety/I_SafetyProvider.TcIO | 31 -- .../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 - .../Safety/PNOZ/ST_PNOZEtherCATStatus.TcDUT | 25 -- .../Safety/PNOZ/ST_SafetyFunctionIn.TcDUT | 14 - .../Safety/PNOZ/ST_SafetyFunctionOut.TcDUT | 14 - .../DUTs/Safety/ST_Safety.TcDUT | 12 - .../DUTs/Safety/ST_SafetyIn.TcDUT | 15 - .../DUTs/Safety/ST_SafetyOut.TcDUT | 16 - .../Technosoft/ST_TechnosoftMotionError.TcDUT | 26 -- solution/tc_project_app/GVLs/GVL_APP.TcGVL | 13 +- .../tc_project_app/GVLs/GVL_SafetyIO.TcGVL | 30 -- .../Applications/Cabinet_Monitoring.TcPOU | 27 +- .../Applications/Safety/FB_MotionSafety.TcPOU | 160 --------- .../Safety/FB_PulseGenerator.TcPOU | 97 ------ .../Safety/FB_ZoneMonitoring.TcPOU | 318 ------------------ .../Safety/F_TechnosoftErrorActive.TcPOU | 29 -- .../Applications/Safety/Motion_Safety.TcPOU | 219 ------------ .../{Safety => }/Zone_Monitoring.TcPOU | 6 +- 26 files changed, 47 insertions(+), 1155 deletions(-) rename solution/tc_project_app/DUTs/{Safety/PNOZ => }/E_SafetyFunctions.TcDUT (83%) rename solution/tc_project_app/DUTs/{Safety/PNOZ => }/ST_MCC_CustomStatusIn.TcDUT (53%) rename solution/tc_project_app/DUTs/{Safety/PNOZ => }/ST_MCC_CustomStatusOut.TcDUT (79%) delete mode 100644 solution/tc_project_app/DUTs/Safety/I_SafetyProvider.TcIO delete mode 100644 solution/tc_project_app/DUTs/Safety/PNOZ/ST_LEDState.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCCStatusIn.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCCStatusOut.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZCommDiag.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATIn.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATOut.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATStatus.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/PNOZ/ST_SafetyFunctionIn.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/PNOZ/ST_SafetyFunctionOut.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/ST_Safety.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/ST_SafetyIn.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/ST_SafetyOut.TcDUT delete mode 100644 solution/tc_project_app/DUTs/Safety/Technosoft/ST_TechnosoftMotionError.TcDUT delete mode 100644 solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL delete mode 100644 solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU delete mode 100644 solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_PulseGenerator.TcPOU delete mode 100644 solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_ZoneMonitoring.TcPOU delete mode 100644 solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_TechnosoftErrorActive.TcPOU delete mode 100644 solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU rename solution/tc_project_app/POUs/Application_Specific/Applications/{Safety => }/Zone_Monitoring.TcPOU (64%) diff --git a/solution/tc_project_app/DUTs/Safety/PNOZ/E_SafetyFunctions.TcDUT b/solution/tc_project_app/DUTs/E_SafetyFunctions.TcDUT similarity index 83% rename from solution/tc_project_app/DUTs/Safety/PNOZ/E_SafetyFunctions.TcDUT rename to solution/tc_project_app/DUTs/E_SafetyFunctions.TcDUT index 93e14ba..5aeaf4c 100644 --- a/solution/tc_project_app/DUTs/Safety/PNOZ/E_SafetyFunctions.TcDUT +++ b/solution/tc_project_app/DUTs/E_SafetyFunctions.TcDUT @@ -9,14 +9,16 @@ Add new safety functions to match the incoming safety functions from the PNOZmul Each safety function represents 4-bits of information. However the PLC still stores the incoming 4-bits into 1-byte. *) -TYPE E_SafetyFunctions: +TYPE E_SafetyFunctions : ( eNone, eEStop, - eSampleStop, - eSampleEnable, - eDetectorArmIsolate, - eDetectorEnable + ePSSAccess, + eStartExp, + eStartOpt, + eMFStop, + eMFEnable, + eReserved ); END_TYPE ]]> diff --git a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCC_CustomStatusIn.TcDUT b/solution/tc_project_app/DUTs/ST_MCC_CustomStatusIn.TcDUT similarity index 53% rename from solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCC_CustomStatusIn.TcDUT rename to solution/tc_project_app/DUTs/ST_MCC_CustomStatusIn.TcDUT index 405cfe6..2988630 100644 --- a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCC_CustomStatusIn.TcDUT +++ b/solution/tc_project_app/DUTs/ST_MCC_CustomStatusIn.TcDUT @@ -1,18 +1,17 @@  - IPC, can be customized depending on cabinet -TYPE ST_MCC_CustomStatusIn : + - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_LEDState.TcDUT b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_LEDState.TcDUT deleted file mode 100644 index 803ccbe..0000000 --- a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_LEDState.TcDUT +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCCStatusIn.TcDUT b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCCStatusIn.TcDUT deleted file mode 100644 index c84c1c1..0000000 --- a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCCStatusIn.TcDUT +++ /dev/null @@ -1,27 +0,0 @@ - - - - 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/solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCCStatusOut.TcDUT b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCCStatusOut.TcDUT deleted file mode 100644 index f65ba8f..0000000 --- a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_MCCStatusOut.TcDUT +++ /dev/null @@ -1,27 +0,0 @@ - - - - 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/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZCommDiag.TcDUT b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZCommDiag.TcDUT deleted file mode 100644 index 5b32501..0000000 --- a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZCommDiag.TcDUT +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATIn.TcDUT b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATIn.TcDUT deleted file mode 100644 index 19f6067..0000000 --- a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATIn.TcDUT +++ /dev/null @@ -1,15 +0,0 @@ - - - - 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_SafetyIO.cNBR_OF_SF] 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/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATOut.TcDUT b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATOut.TcDUT deleted file mode 100644 index d19ece7..0000000 --- a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATOut.TcDUT +++ /dev/null @@ -1,14 +0,0 @@ - - - - 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_SafetyIO.cNBR_OF_SF] OF ST_SafetyFunctionOut; //Output Byte 04..15 -END_STRUCT -END_TYPE -]]> - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATStatus.TcDUT b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATStatus.TcDUT deleted file mode 100644 index b13ee38..0000000 --- a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_PNOZEtherCATStatus.TcDUT +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_SafetyFunctionIn.TcDUT b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_SafetyFunctionIn.TcDUT deleted file mode 100644 index 11d425a..0000000 --- a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_SafetyFunctionIn.TcDUT +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_SafetyFunctionOut.TcDUT b/solution/tc_project_app/DUTs/Safety/PNOZ/ST_SafetyFunctionOut.TcDUT deleted file mode 100644 index ff8ff01..0000000 --- a/solution/tc_project_app/DUTs/Safety/PNOZ/ST_SafetyFunctionOut.TcDUT +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_Safety.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_Safety.TcDUT deleted file mode 100644 index 09f0993..0000000 --- a/solution/tc_project_app/DUTs/Safety/ST_Safety.TcDUT +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_SafetyIn.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_SafetyIn.TcDUT deleted file mode 100644 index 7a838c8..0000000 --- a/solution/tc_project_app/DUTs/Safety/ST_SafetyIn.TcDUT +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/ST_SafetyOut.TcDUT b/solution/tc_project_app/DUTs/Safety/ST_SafetyOut.TcDUT deleted file mode 100644 index 5386e35..0000000 --- a/solution/tc_project_app/DUTs/Safety/ST_SafetyOut.TcDUT +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/DUTs/Safety/Technosoft/ST_TechnosoftMotionError.TcDUT b/solution/tc_project_app/DUTs/Safety/Technosoft/ST_TechnosoftMotionError.TcDUT deleted file mode 100644 index 4f40bd9..0000000 --- a/solution/tc_project_app/DUTs/Safety/Technosoft/ST_TechnosoftMotionError.TcDUT +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/GVLs/GVL_APP.TcGVL b/solution/tc_project_app/GVLs/GVL_APP.TcGVL index 1c9a49e..f8c8e0b 100644 --- a/solution/tc_project_app/GVLs/GVL_APP.TcGVL +++ b/solution/tc_project_app/GVLs/GVL_APP.TcGVL @@ -4,19 +4,22 @@ diff --git a/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL b/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL deleted file mode 100644 index ec07147..0000000 --- a/solution/tc_project_app/GVLs/GVL_SafetyIO.TcGVL +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Cabinet_Monitoring.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Cabinet_Monitoring.TcPOU index 1af68a5..95a206e 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Cabinet_Monitoring.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Cabinet_Monitoring.TcPOU @@ -8,15 +8,24 @@ END_VAR ]]> , - aErrorMsg=> , - nEcMasterFramesLost=> , - nCPULoad=> , - fCycleExecTime_ms=> , - nAlarmGrpBitNumber=> ); -*) +fbCabinetMonitoring( + nEcMasterNetId := '10.102.116.36.3.1', //AMS NetId of Device (EtherCAT) from I/Os, + iSafetyProvider := Motion_Safety.fbMotionSafety, + aErrorID => , + aErrorMsg => , + nEcMasterFramesLost => , + nCPULoad => , + fCycleExecTime_ms => , + nAlarmGrpBitNumber => +); + + + + + + + + ]]> diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU deleted file mode 100644 index 16d45cc..0000000 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_MotionSafety.TcPOU +++ /dev/null @@ -1,160 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_PulseGenerator.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_PulseGenerator.TcPOU deleted file mode 100644 index 7c3825c..0000000 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_PulseGenerator.TcPOU +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - 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/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_ZoneMonitoring.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_ZoneMonitoring.TcPOU deleted file mode 100644 index 5c1655a..0000000 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/FB_ZoneMonitoring.TcPOU +++ /dev/null @@ -1,318 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 AND_THEN iSafetyProvider.P_ReadFromSafetyController THEN - bEStopReleased := iSafetyProvider.P_EStopOK; - bSTOReleased := iSafetyProvider.P_STO_OK; -END_IF; - -EStopReleased := bEStopReleased; -]]> - - - - - - 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/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_TechnosoftErrorActive.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_TechnosoftErrorActive.TcPOU deleted file mode 100644 index 0318ef3..0000000 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/F_TechnosoftErrorActive.TcPOU +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU deleted file mode 100644 index 1a1969a..0000000 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Motion_Safety.TcPOU +++ /dev/null @@ -1,219 +0,0 @@ - - - - - - - - - - - 100.0 THEN - fPWClamped := 100.0; -END_IF - -//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 tHeartbeatElapsed >= tHeartbeatPeriod THEN - tHeartbeatElapsed := tHeartbeatElapsed - tHeartbeatPeriod; -END_IF - -bHeartbeatOut := tHeartbeatElapsed < tHeartbeatOnTime; - -//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; - -mCheckMCCHeartbeat := NOT bWatchdogFault; -]]> - - - - - - - - - - - - stSafety.stSafetyOut.stMCCStatusOut.bit0_Heartbeat, - bWatchdogFault => bMCCWatchdogFault -); - -bAxisEnableAllowed := - stSafety.stSafetyIn.stMCCStatusIn.bit1_EStopOK - AND bMCC_OK; -]]> - - - - - - - - - - - - - - - - - - GVL_SafetyIO.bSafetyAcknowledgeLED); -]]> - - - - \ No newline at end of file diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Zone_Monitoring.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Zone_Monitoring.TcPOU similarity index 64% rename from solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Zone_Monitoring.TcPOU rename to solution/tc_project_app/POUs/Application_Specific/Applications/Zone_Monitoring.TcPOU index ef5a344..f24463e 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Safety/Zone_Monitoring.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Zone_Monitoring.TcPOU @@ -1,15 +1,15 @@  - + - , aErrorMsg =>, nAlarmGrpBitNumber =>); From d2da91e4a7418674e772d8bd646987b9172c9961 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Fri, 11 Sep 2026 08:42:10 +0200 Subject: [PATCH 36/41] MBP-388: Update to defualt config --- solution/tc_project_app/GVLs/GVL_APP.TcGVL | 16 +++++------ .../Applications/Cabinet_Monitoring.TcPOU | 28 +++++++------------ solution/tc_project_app/POUs/MAIN.TcPOU | 9 ++---- 3 files changed, 21 insertions(+), 32 deletions(-) diff --git a/solution/tc_project_app/GVLs/GVL_APP.TcGVL b/solution/tc_project_app/GVLs/GVL_APP.TcGVL index f8c8e0b..dbfb540 100644 --- a/solution/tc_project_app/GVLs/GVL_APP.TcGVL +++ b/solution/tc_project_app/GVLs/GVL_APP.TcGVL @@ -4,22 +4,22 @@ diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Cabinet_Monitoring.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Cabinet_Monitoring.TcPOU index 95a206e..fe9df9d 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Cabinet_Monitoring.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Cabinet_Monitoring.TcPOU @@ -8,24 +8,16 @@ END_VAR ]]> , - aErrorMsg => , - nEcMasterFramesLost => , - nCPULoad => , - fCycleExecTime_ms => , - nAlarmGrpBitNumber => -); - - - - - - - - +//fbCabinetMonitoring( +// nEcMasterNetId := '10.102.116.36.3.1', //AMS NetId of Device (EtherCAT) from I/Os, +// iSafetyProvider := Motion_Safety.fbMotionSafety, +// aErrorID => , +// aErrorMsg => , +// nEcMasterFramesLost => , +// nCPULoad => , +// fCycleExecTime_ms => , +// nAlarmGrpBitNumber => +//); ]]> diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index f0f1ebc..2a1aff0 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -34,12 +34,9 @@ VAR PERSISTENT END_VAR ]]> - From a5203d6b38dce5ec26910637528bed1698d0d31b Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Fri, 11 Sep 2026 08:45:00 +0200 Subject: [PATCH 37/41] MBP-388: Fix index and whitespace --- .../Applications/Motion_Safety.TcPOU | 31 +++++++++++++++++++ .../Applications/Zone_Monitoring.TcPOU | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 solution/tc_project_app/POUs/Application_Specific/Applications/Motion_Safety.TcPOU diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Motion_Safety.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Motion_Safety.TcPOU new file mode 100644 index 0000000..3e7023c --- /dev/null +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Motion_Safety.TcPOU @@ -0,0 +1,31 @@ + + + + + + bMCC_OK, + bAxisEnableAllowed => bAxisEnableAllowed, + bMCCWatchdogFault => bMCCWatchdogFault); + +//Specific Application + + +fbMotionSafety.mWriteOutputs(stSafetyData := stSafety); +]]> + + + \ No newline at end of file diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Zone_Monitoring.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Zone_Monitoring.TcPOU index f24463e..8c70b6d 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Zone_Monitoring.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Zone_Monitoring.TcPOU @@ -9,7 +9,7 @@ END_VAR , aErrorMsg =>, nAlarmGrpBitNumber =>); From 0f07354fe544e6ce4407b527b4527b0efd954979 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Fri, 11 Sep 2026 12:35:36 +0200 Subject: [PATCH 38/41] MBP-388: Update tc_project_app.xti --- solution/_Config/PLC/tc_project_app.xti | 772 +++++++++++++++++++++++- 1 file changed, 771 insertions(+), 1 deletion(-) diff --git a/solution/_Config/PLC/tc_project_app.xti b/solution/_Config/PLC/tc_project_app.xti index 5ee5506..8a9f3fb 100644 --- a/solution/_Config/PLC/tc_project_app.xti +++ b/solution/_Config/PLC/tc_project_app.xti @@ -1,7 +1,744 @@ + + + ST_MCCStatusIn + IPC, will not change from cabinet to cabinet]]> + 16 + + bHeartbeat + BIT + + 1 + 0 + + + bEStopOK + BIT + + 1 + 1 + + + bRemote + BIT + + 1 + 2 + + + bFault + BIT + + 1 + 3 + + + bReserved4 + BIT + 1 + 4 + + + bReserved5 + BIT + 1 + 5 + + + bReserved6 + BIT + 1 + 6 + + + bReserved7 + BIT + 1 + 7 + + + bReserved8 + BIT + 1 + 8 + + + bReserved9 + BIT + 1 + 9 + + + bReserved10 + BIT + 1 + 10 + + + bReserved11 + BIT + 1 + 11 + + + bReserved12 + BIT + 1 + 12 + + + bReserved13 + BIT + 1 + 13 + + + bReserved14 + BIT + 1 + 14 + + + bReserved15 + BIT + 1 + 15 + + + + ST_MCC_CustomStatusIn + 16 + + bEStopExperimentOK + BIT + + 1 + 0 + + + bEStopOpticsOK + BIT + + 1 + 1 + + + bEStopExternalOK + BIT + + 1 + 2 + + + bReserved19 + BIT + 1 + 3 + + + bFocusDoorClosed + BIT + 1 + 4 + + + bOptCaveInRemote + BIT + + 1 + 5 + + + bFocusChangerPos + BIT + + 1 + 6 + + + bFocusChangerNeg + BIT + + 1 + 7 + + + bChangerStandstill + BIT + 1 + 8 + + + bReserved25 + BIT + 1 + 9 + + + bReserved26 + BIT + 1 + 10 + + + bReserved27 + BIT + 1 + 11 + + + bReserved28 + BIT + 1 + 12 + + + bReserved29 + BIT + 1 + 13 + + + bReserved30 + BIT + 1 + 14 + + + bReserved31 + BIT + 1 + 15 + + + + ST_SafetyFunctionIn + 8 + + bEnabled + BIT + 1 + 0 + + + bReady + BIT + + 1 + 1 + + + bFault + BIT + + 1 + 2 + + + bStart + BIT + + 1 + 3 + + + + ST_LEDState + + 8 + + bLED_OFAULT + BIT + + 1 + 0 + + + bLED_IFAULT + BIT + + 1 + 1 + + + bLED_FAULT + BIT + + 1 + 2 + + + bLED_DIAG + BIT + + 1 + 3 + + + bLED_RUN + BIT + + 1 + 4 + + + bReserved6 + BIT + + 1 + 5 + + + bReserved7 + BIT + + 1 + 6 + + + bReserved8 + BIT + + 1 + 7 + + + + ST_PNOZEtherCATIn + PLC EtherCAT input data copied from the raw %I* process image.]]> + 104 + + stMCCStatusIn + ST_MCCStatusIn + + 16 + 0 + + + stMCC_CustomStatusIn + ST_MCC_CustomStatusIn + + 16 + 16 + + + astSafetyFunctionIn + ST_SafetyFunctionIn + + 1 + 8 + + + 64 + 32 + + + stLEDState + ST_LEDState + + 8 + 96 + + + + ST_TechnosoftMotionError + 16 + + bEtherCATCommunicationError + BIT + + 1 + 0 + + + bShortCircuit + BIT + + 1 + 1 + + + bInvalidSetupData + BIT + + 1 + 2 + + + bControlError + BIT + + 1 + 3 + + + bCommunicationError + BIT + + 1 + 4 + + + bFeedbackError + BIT + + 1 + 5 + + + bPositiveLimitSwitchActive + BIT + + 1 + 6 + + + bNegativeLimitSwitchActive + BIT + + 1 + 7 + + + bOverCurrent + BIT + + 1 + 8 + + + bI2TProtection + BIT + + 1 + 9 + + + bMotorOverTemperature + BIT + + 1 + 10 + + + bDriveOverTemperature + BIT + + 1 + 11 + + + bOverVoltage + BIT + + 1 + 12 + + + bUnderVoltage + BIT + + 1 + 13 + + + bCommandError + BIT + + 1 + 14 + + + bSTOActive + BIT + + 1 + 15 + + + + ARRAY [1..0] OF ST_TechnosoftMotionError + + 0 + ST_TechnosoftMotionError + + 1 + 0 + + + + ST_MCCStatusOut + PNOZ, will not change from cabinet to cabinet]]> + 16 + + bHeartbeat + BIT + + 1 + 0 + + + bReserved1 + BIT + 1 + 1 + + + bReserved2 + BIT + 1 + 2 + + + bErrAck + BIT + + 1 + 3 + + + bReserved4 + BIT + 1 + 4 + + + bReserved5 + BIT + 1 + 5 + + + bSTOFbk + BIT + 1 + 6 + + + bSTO_OK + BIT + 1 + 7 + + + bReserved8 + BIT + 1 + 8 + + + bReserved9 + BIT + 1 + 9 + + + bReserved10 + BIT + 1 + 10 + + + bReserved11 + BIT + 1 + 11 + + + bReserved12 + BIT + 1 + 12 + + + bReserved13 + BIT + 1 + 13 + + + bReserved14 + BIT + 1 + 14 + + + bReserved15 + BIT + 1 + 15 + + + + ST_MCC_CustomStatusOut + PNOZ, can be customized depending on cabinet]]> + 16 + + bReserved16 + BIT + + 1 + 0 + + + bReserved17 + BIT + 1 + 1 + + + bReserved18 + BIT + 1 + 2 + + + bReserved19 + BIT + 1 + 3 + + + bFocusDoorLocked + BIT + 1 + 4 + + + bReserved21 + BIT + 1 + 5 + + + bChangerMovingPos + BIT + + 1 + 6 + + + bChangerMovingNeg + BIT + + 1 + 7 + + + bReserved24 + BIT + 1 + 8 + + + bReserved25 + BIT + 1 + 9 + + + bReserved26 + BIT + 1 + 10 + + + bReserved27 + BIT + 1 + 11 + + + bReserved28 + BIT + 1 + 12 + + + bReserved29 + BIT + 1 + 13 + + + bReserved30 + BIT + 1 + 14 + + + bReserved31 + BIT + 1 + 15 + + + + ST_SafetyFunctionOut + 8 + + bDiagOk + BIT + + 1 + 0 + + + bOutput + BIT + + 1 + 1 + + + bRequest + BIT + 1 + 2 + + + bDummy + BIT + + 1 + 3 + + + + ST_PNOZEtherCATOut + PNOZ EtherCAT output data mapped to the raw %Q* process image.]]> + 96 + + stMCCStatusOut + ST_MCCStatusOut + + 16 + 0 + + + stMCC_CustomStatusOut + ST_MCC_CustomStatusOut + + 16 + 16 + + + aSafetyFunctionOut + ST_SafetyFunctionOut + + 1 + 8 + + + 64 + 32 + + + - + tc_project_app Instance {08500001-0000-0000-F000-000000000064} @@ -16,6 +753,20 @@ BOOL + + Motion_Safety.fbMotionSafety.stPNOZEtherCATIn + + ST_PNOZEtherCATIn + + + Motion_Safety.fbMotionSafety.bWcState + BOOL + + + Motion_Safety.fbMotionSafety.astTechnosoftMotionError + + ARRAY [1..0] OF ST_TechnosoftMotionError + GVL.nAirPressureSensorGroup1 @@ -45,6 +796,25 @@ BOOL + + Motion_Safety.fbMotionSafety.stPNOZEtherCATOut + + ST_PNOZEtherCATOut + + + Motion_Safety.fbMotionSafety.bSafetyAcknowledgeLED + BOOL + + + GVL_Safety.bOpticalCaveLED + + BOOL + + + GVL_Safety.bExperimentCaveLED + + BOOL + From 804e69ebe3f7bbe327e7ec012a2a2b8cc4623ca1 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Fri, 11 Sep 2026 12:40:48 +0200 Subject: [PATCH 39/41] MBP-388: Update tc_project_app.plcproj --- .../tc_project_app/tc_project_app.plcproj | 129 ++++++++---------- 1 file changed, 60 insertions(+), 69 deletions(-) diff --git a/solution/tc_project_app/tc_project_app.plcproj b/solution/tc_project_app/tc_project_app.plcproj index 4cf040c..c6c6809 100644 --- a/solution/tc_project_app/tc_project_app.plcproj +++ b/solution/tc_project_app/tc_project_app.plcproj @@ -30,49 +30,7 @@ Code - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - + Code @@ -82,9 +40,6 @@ Code true - - Code - Code @@ -94,22 +49,7 @@ Code - - Code - - - Code - - - Code - - - Code - - - Code - - + Code @@ -121,6 +61,9 @@ Code + + Code + Code @@ -250,18 +193,59 @@ Code - Code - + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + Code Code + + Code + Code + + Code + + + Code + Code @@ -286,6 +270,9 @@ Code + + Code + Code @@ -301,6 +288,12 @@ Code + + Code + + + Code + Code @@ -324,21 +317,19 @@ - - - - - + + + From 509c427e75e9faddc16d2e1d662374f15eb5f7d2 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Fri, 11 Sep 2026 12:42:19 +0200 Subject: [PATCH 40/41] MBP-388: Update to follow coding standard --- .../DUTs/E_SafetyFunctions.TcDUT | 3 +- .../DUTs/ST_MCC_CustomStatusIn.TcDUT | 34 ++++++++++--------- .../DUTs/ST_MCC_CustomStatusOut.TcDUT | 34 ++++++++++--------- solution/tc_project_app/GVLs/GVL_APP.TcGVL | 4 +-- .../tc_project_app/tc_project_app.plcproj | 4 +-- 5 files changed, 42 insertions(+), 37 deletions(-) diff --git a/solution/tc_project_app/DUTs/E_SafetyFunctions.TcDUT b/solution/tc_project_app/DUTs/E_SafetyFunctions.TcDUT index 5aeaf4c..9363b40 100644 --- a/solution/tc_project_app/DUTs/E_SafetyFunctions.TcDUT +++ b/solution/tc_project_app/DUTs/E_SafetyFunctions.TcDUT @@ -10,7 +10,8 @@ Each safety function represents 4-bits of information. However the PLC still sto into 1-byte. *) TYPE E_SafetyFunctions : -( +( + //Note: This is just an example eNone, eEStop, ePSSAccess, diff --git a/solution/tc_project_app/DUTs/ST_MCC_CustomStatusIn.TcDUT b/solution/tc_project_app/DUTs/ST_MCC_CustomStatusIn.TcDUT index 2988630..2bd01f0 100644 --- a/solution/tc_project_app/DUTs/ST_MCC_CustomStatusIn.TcDUT +++ b/solution/tc_project_app/DUTs/ST_MCC_CustomStatusIn.TcDUT @@ -3,22 +3,24 @@ diff --git a/solution/tc_project_app/DUTs/ST_MCC_CustomStatusOut.TcDUT b/solution/tc_project_app/DUTs/ST_MCC_CustomStatusOut.TcDUT index 586e362..9c999e9 100644 --- a/solution/tc_project_app/DUTs/ST_MCC_CustomStatusOut.TcDUT +++ b/solution/tc_project_app/DUTs/ST_MCC_CustomStatusOut.TcDUT @@ -4,22 +4,24 @@ PNOZ, can be customized depending on cabinet TYPE ST_MCC_CustomStatusOut : STRUCT - bit16_Reserved: BIT; - bit17_Reserved: BIT; - bit18_Reserved: BIT; - bit19_Reserved: BIT; - bit20_FocusDoorLocked: BIT; - bit21_Reserved: BIT; - bit22_ChangerMovingPos: BIT; //Set if moving in a positive direction - bit23_ChangerMovingNeg: BIT; //Set if moving in a negative direction - bit24_Reserved: BIT; - bit25_Reserved: BIT; - bit26_Reserved: BIT; - bit27_Reserved: BIT; - bit28_Reserved: BIT; - bit29_Reserved: BIT; - bit30_Reserved: BIT; - bit31_Reserved: BIT; + //Note: This is just an example, move status bits into tc_mca_std_lib make it a UDINT. + //Map the bits in specific application code. + bReserved16: BIT; + bReserved17: BIT; + bReserved18: BIT; + bReserved19: BIT; + bFocusDoorLocked: BIT; + bReserved21: BIT; + bChangerMovingPos: BIT; //Set if moving in a positive direction + bChangerMovingNeg: BIT; //Set if moving in a negative direction + bReserved24: BIT; + bReserved25: BIT; + bReserved26: BIT; + bReserved27: BIT; + bReserved28: BIT; + bReserved29: BIT; + bReserved30: BIT; + bReserved31: BIT; END_STRUCT END_TYPE ]]> diff --git a/solution/tc_project_app/GVLs/GVL_APP.TcGVL b/solution/tc_project_app/GVLs/GVL_APP.TcGVL index dbfb540..174370e 100644 --- a/solution/tc_project_app/GVLs/GVL_APP.TcGVL +++ b/solution/tc_project_app/GVLs/GVL_APP.TcGVL @@ -18,8 +18,8 @@ VAR_GLOBAL CONSTANT fLOW_LIMIT_AIR_PRESSURE2: REAL := 1; //User defined value in bar for low limit air pressure value for pneumatic axes group 2 fHIGH_LIMIT_AIR_PRESSURE2: REAL := 6; //User defined value in bar for high limit air pressure value for pneumatic axes group 2 - cNUM_OF_SAFETY_FUNCTIONS: UINT := 0; //Virtual Output/Input bytes 04..15, each containing 8 bits - cNUM_OF_TECHNOSOFT: UINT := 0; //Number of Technosoft axises + nNUM_OF_SAFETY_FUNCTIONS: UINT := 8; //Virtual Output/Input bytes 04..15, each containing 8 bits + nNUM_OF_TECHNOSOFT: UINT := 0; //Number of Technosoft axises END_VAR ]]> diff --git a/solution/tc_project_app/tc_project_app.plcproj b/solution/tc_project_app/tc_project_app.plcproj index c6c6809..8bcb403 100644 --- a/solution/tc_project_app/tc_project_app.plcproj +++ b/solution/tc_project_app/tc_project_app.plcproj @@ -24,10 +24,10 @@ Code - + Code - + Code From 09a14bad721b755319220cf08b29df0ade83d9e1 Mon Sep 17 00:00:00 2001 From: aslanliafichev Date: Fri, 11 Sep 2026 12:44:58 +0200 Subject: [PATCH 41/41] MBP-388: Fix whitespace --- solution/tc_project_app/DUTs/E_SafetyFunctions.TcDUT | 4 ++-- solution/tc_project_app/DUTs/ST_MCC_CustomStatusIn.TcDUT | 4 ++-- solution/tc_project_app/DUTs/ST_MCC_CustomStatusOut.TcDUT | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/solution/tc_project_app/DUTs/E_SafetyFunctions.TcDUT b/solution/tc_project_app/DUTs/E_SafetyFunctions.TcDUT index 9363b40..71193eb 100644 --- a/solution/tc_project_app/DUTs/E_SafetyFunctions.TcDUT +++ b/solution/tc_project_app/DUTs/E_SafetyFunctions.TcDUT @@ -10,8 +10,8 @@ Each safety function represents 4-bits of information. However the PLC still sto into 1-byte. *) TYPE E_SafetyFunctions : -( - //Note: This is just an example +( + //Note: This is just an example eNone, eEStop, ePSSAccess, diff --git a/solution/tc_project_app/DUTs/ST_MCC_CustomStatusIn.TcDUT b/solution/tc_project_app/DUTs/ST_MCC_CustomStatusIn.TcDUT index 2bd01f0..73ea759 100644 --- a/solution/tc_project_app/DUTs/ST_MCC_CustomStatusIn.TcDUT +++ b/solution/tc_project_app/DUTs/ST_MCC_CustomStatusIn.TcDUT @@ -3,8 +3,8 @@ PNOZ, can be customized depending on cabinet TYPE ST_MCC_CustomStatusOut : STRUCT - //Note: This is just an example, move status bits into tc_mca_std_lib make it a UDINT. - //Map the bits in specific application code. + //Note: This is just an example, move status bits into tc_mca_std_lib make it a UDINT. + //Map the bits in specific application code. bReserved16: BIT; bReserved17: BIT; bReserved18: BIT;