From 56f386aad01b919e7639da81420d805b511eaf76 Mon Sep 17 00:00:00 2001 From: Jack Harper Date: Thu, 3 Sep 2026 10:11:05 +0100 Subject: [PATCH 1/4] conditionally forward velocities for TC --- TC/TC-IOC-01App/Db/Makefile | 1 + TC/TC-IOC-01App/Db/velo_monitor.db | 21 +++++++++++++++++++++ TC/iocBoot/iocTC-IOC-01/config.xml | 1 + TC/iocBoot/iocTC-IOC-01/st-common.lua | 9 ++++++++- 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 TC/TC-IOC-01App/Db/velo_monitor.db diff --git a/TC/TC-IOC-01App/Db/Makefile b/TC/TC-IOC-01App/Db/Makefile index c8ac22675..6b0db4521 100644 --- a/TC/TC-IOC-01App/Db/Makefile +++ b/TC/TC-IOC-01App/Db/Makefile @@ -13,6 +13,7 @@ include $(TOP)/configure/CONFIG DB += single_axis.db DB += axis_monitors.db DB += autoonoff.db +DB += velo_monitor.db #---------------------------------------------------- # If .db template is not named *.template add diff --git a/TC/TC-IOC-01App/Db/velo_monitor.db b/TC/TC-IOC-01App/Db/velo_monitor.db new file mode 100644 index 000000000..ed6e32608 --- /dev/null +++ b/TC/TC-IOC-01App/Db/velo_monitor.db @@ -0,0 +1,21 @@ +# DB to forward velocities from the beckhoff to the motor record. +# This was previously removed in https://github.com/ISISComputingGroup/EPICS-ioc/commit/7b9360a00f855225a5be585981c8d36b12af6d5c due to +# issues where the beckhoff would sometimes set velocity to zero and then this code would forward it and prevent moves. +# ISIS Beckhoffs before IMAT's recomission in 2026 still run the problematic code, so this is conditionally loaded by the IOC based on the FORWARD_VELO macro. + +record(dfanout, "$(P)MOT:$(MOTOR_PV):VELO_SEND") +{ + field(DESC, "Forward device velo SP to mtr rec") + field(DOL, "$(P)$(I):ASTAXES_$(AXIS_NUM):STCONTROL-FVELOCITY:RBV CP") + field(OUTA, "$(P)MOT:$(MOTOR_PV).VMAX") + field(OUTB, "$(P)MOT:$(MOTOR_PV).VELO") + field(OMSL, "closed_loop") +} + +record(dfanout, "$(P)MOT:$(MOTOR_PV):JVEL_SEND") +{ + field(DESC, "Forward device jog velo SP to mtr rec") + field(DOL, "$(P)$(I):ASTAXES_$(AXIS_NUM):STCONTROL-FJOGVELOCITY:RBV CP") + field(OMSL, "closed_loop") + field(OUTA, "$(P)MOT:$(MOTOR_PV).JVEL") +} diff --git a/TC/iocBoot/iocTC-IOC-01/config.xml b/TC/iocBoot/iocTC-IOC-01/config.xml index 6bded790a..afc0badff 100644 --- a/TC/iocBoot/iocTC-IOC-01/config.xml +++ b/TC/iocBoot/iocTC-IOC-01/config.xml @@ -9,6 +9,7 @@ + diff --git a/TC/iocBoot/iocTC-IOC-01/st-common.lua b/TC/iocBoot/iocTC-IOC-01/st-common.lua index 36582690e..262032c18 100644 --- a/TC/iocBoot/iocTC-IOC-01/st-common.lua +++ b/TC/iocBoot/iocTC-IOC-01/st-common.lua @@ -10,6 +10,7 @@ function twincat_stcommon_main() local plc_version = ibex_utils.getMacroValue{macro="PLC_VERSION", default="1"} local ads_port = ibex_utils.getMacroValue{macro="ADS_PORT"} local forward_desc = ibex_utils.getMacroValue{macro="FORWARD_DESC", default="0"} + local forward_velo = ibex_utils.getMacroValue{macro="FORWARD_VELO", default="0"} local enable_frozen_offsets = ibex_utils.getMacroValue{macro="ALLOW_FROZEN_OFFSETS", default="0"} local enable_auto_on_off = ibex_utils.getMacroValue{macro="ENABLE_AUTO_ON_OFF", default="0"} @@ -65,8 +66,14 @@ function twincat_stcommon_main() axis_monitors = "$(TOP)/db/axis_monitors.db" axis_monitors_args = string.format("P=%s,I=%s,AXIS_NUM=%s,MOTOR_PV=%s", pv_prefix, ioc_name, axis_num, motor_pv) iocsh.dbLoadRecords(axis_monitors, axis_monitors_args) + + if forward_velo == "1" then + local forward_velo_args = string.format("P=%s,I=%s,AXIS_NUM=%s,MOTOR_PV=%s", pv_prefix, ioc_name, axis_num, motor_pv) + iocsh.dbLoadRecords("$(TOP)/db/velo_monitor.db", forward_velo_args) + end autosave_file:write(string.format("file \"motor_settings.req\" P=%s, M=MOT:%s\n", pv_prefix, motor_pv)) - -- wrap around to next MTRCTRL - this is so we can show >8 axes in the IBEX table of motors. + -- wrap around to next MTRCTRL and alias - this is so we can show >8 axes in the IBEX table of motors. + -- for example, MTR0109 is also aliased to MTR0201, MTR0110 is aliased to MTR0202, etc. if axis_num > 8 then alias_args_orig = string.format("$(MYPVPREFIX)MOT:%s(.*)", motor_pv) alias_args_aliased = string.format("$(MYPVPREFIX)MOT:MTR%02i%02i\\1", ((axis_num-1)//8) + mtrctrl, (axis_num-1)%8 + 1) From f7a1346b3e995dac52fed4f8c9f332ce44b59c7b Mon Sep 17 00:00:00 2001 From: Jack Harper Date: Thu, 3 Sep 2026 14:27:23 +0100 Subject: [PATCH 2/4] add sampleChanger --- TC/TC-IOC-01App/src/build.mak | 4 ++++ TC/configure/RELEASE | 2 ++ 2 files changed, 6 insertions(+) diff --git a/TC/TC-IOC-01App/src/build.mak b/TC/TC-IOC-01App/src/build.mak index 3e350e875..d32cf7b66 100644 --- a/TC/TC-IOC-01App/src/build.mak +++ b/TC/TC-IOC-01App/src/build.mak @@ -38,6 +38,8 @@ $(APPNAME)_DBD += adsMotorSupport.dbd $(APPNAME)_DBD += luaSupport.dbd $(APPNAME)_DBD += asubFunctions.dbd $(APPNAME)_DBD += ads.dbd +$(APPNAME)_DBD += sampleChanger.dbd + # Add all the support libraries needed by this IOC @@ -67,6 +69,8 @@ $(APPNAME)_LIBS += utilities pugixml libjson zlib $(APPNAME)_LIBS += calc sscan $(APPNAME)_LIBS += pcrecpp pcre $(APPNAME)_LIBS += seq pv +$(APPNAME)_LIBS += sampleChanger +$(APPNAME)_LIBS += TinyXML # TC-IOC-01_registerRecordDeviceDriver.cpp derives from TC-IOC-01.dbd $(APPNAME)_SRCS += $(APPNAME)_registerRecordDeviceDriver.cpp diff --git a/TC/configure/RELEASE b/TC/configure/RELEASE index 485ca5e10..ee86275e4 100644 --- a/TC/configure/RELEASE +++ b/TC/configure/RELEASE @@ -72,6 +72,8 @@ SSCAN=$(SUPPORT)/sscan/master STREAMDEVICE=$(SUPPORT)/StreamDevice/master UTILITIES=$(SUPPORT)/utilities/master ZLIB=$(SUPPORT)/zlib/master +SAMPLECHANGER=$(SUPPORT)/sampleChanger/master +TINYXML=$(SUPPORT)/TinyXML/master # optional extra local definitions here -include $(TOP)/configure/RELEASE.private From 9e875e56aa02efa58d32147f6e38fbb754b2fe16 Mon Sep 17 00:00:00 2001 From: Jack Harper Date: Thu, 3 Sep 2026 16:18:36 +0100 Subject: [PATCH 3/4] add forward_units macro --- TC/TC-IOC-01App/Db/axis_monitors.db | 8 ++++++++ TC/iocBoot/iocTC-IOC-01/config.xml | 1 + TC/iocBoot/iocTC-IOC-01/st-common.lua | 8 ++++++++ 3 files changed, 17 insertions(+) diff --git a/TC/TC-IOC-01App/Db/axis_monitors.db b/TC/TC-IOC-01App/Db/axis_monitors.db index bdbc4e1fe..e77fe531f 100644 --- a/TC/TC-IOC-01App/Db/axis_monitors.db +++ b/TC/TC-IOC-01App/Db/axis_monitors.db @@ -23,6 +23,14 @@ record(stringout, "$(P)MOT:$(MOTOR_PV):DESC_SEND") field(OMSL, "closed_loop") } +record(stringout, "$(P)MOT:$(MOTOR_PV):UNITS_SEND") +{ + field(DESC, "Forward axis units to mtr rec") + field(DOL, "$(P)$(I):ASTAXES_$(AXIS_NUM):STDESC-SUNITS CP") + field(OUT, "$(P)MOT:$(MOTOR_PV).EGU") + field(OMSL, "closed_loop") +} + record(longin, "$(P)MOT:$(MOTOR_PV)_AXIS_NUM") { field(DESC, "Beckhoff axis number") diff --git a/TC/iocBoot/iocTC-IOC-01/config.xml b/TC/iocBoot/iocTC-IOC-01/config.xml index afc0badff..acc17c1be 100644 --- a/TC/iocBoot/iocTC-IOC-01/config.xml +++ b/TC/iocBoot/iocTC-IOC-01/config.xml @@ -10,6 +10,7 @@ + diff --git a/TC/iocBoot/iocTC-IOC-01/st-common.lua b/TC/iocBoot/iocTC-IOC-01/st-common.lua index 262032c18..13680086e 100644 --- a/TC/iocBoot/iocTC-IOC-01/st-common.lua +++ b/TC/iocBoot/iocTC-IOC-01/st-common.lua @@ -11,6 +11,7 @@ function twincat_stcommon_main() local ads_port = ibex_utils.getMacroValue{macro="ADS_PORT"} local forward_desc = ibex_utils.getMacroValue{macro="FORWARD_DESC", default="0"} local forward_velo = ibex_utils.getMacroValue{macro="FORWARD_VELO", default="0"} + local forward_units = ibex_utils.getMacroValue{macro="FORWARD_UNITS", default="0"} local enable_frozen_offsets = ibex_utils.getMacroValue{macro="ALLOW_FROZEN_OFFSETS", default="0"} local enable_auto_on_off = ibex_utils.getMacroValue{macro="ENABLE_AUTO_ON_OFF", default="0"} @@ -40,6 +41,12 @@ function twincat_stcommon_main() iocsh.dbLoadRecords("$(MOTOREXT)/db/desc_tc.db", desc_tc_args) end + + if forward_units == "1" then + local units_tc_args = string.format("P=%s,AXIS_NUM=%s,ADSPORT=%s,PORT=%s", ioc_prefix, axis_num, ads_port, asyn_port) + iocsh.dbLoadRecords("$(MOTOREXT)/db/units_tc.db", units_tc_args) + end + if enable_frozen_offsets == "1" then local frozen_offsets_db_args = string.format("P=%s,AXIS_NUM=%s,ADSPORT=%s,PORT=%s", ioc_prefix, axis_num, ads_port, asyn_port) iocsh.dbLoadRecords("$(MOTOREXT)/db/frozen_offsets.db", frozen_offsets_db_args) @@ -71,6 +78,7 @@ function twincat_stcommon_main() local forward_velo_args = string.format("P=%s,I=%s,AXIS_NUM=%s,MOTOR_PV=%s", pv_prefix, ioc_name, axis_num, motor_pv) iocsh.dbLoadRecords("$(TOP)/db/velo_monitor.db", forward_velo_args) end + autosave_file:write(string.format("file \"motor_settings.req\" P=%s, M=MOT:%s\n", pv_prefix, motor_pv)) -- wrap around to next MTRCTRL and alias - this is so we can show >8 axes in the IBEX table of motors. -- for example, MTR0109 is also aliased to MTR0201, MTR0110 is aliased to MTR0202, etc. From ab93c4ce6655259fe367bf199401fbc045d48ab4 Mon Sep 17 00:00:00 2001 From: Jack Harper Date: Tue, 8 Sep 2026 11:57:53 +0100 Subject: [PATCH 4/4] add homing configuration toggle and db load --- TC/iocBoot/iocTC-IOC-01/config.xml | 1 + TC/iocBoot/iocTC-IOC-01/st-common.lua | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/TC/iocBoot/iocTC-IOC-01/config.xml b/TC/iocBoot/iocTC-IOC-01/config.xml index acc17c1be..8f532ee2e 100644 --- a/TC/iocBoot/iocTC-IOC-01/config.xml +++ b/TC/iocBoot/iocTC-IOC-01/config.xml @@ -13,6 +13,7 @@ + diff --git a/TC/iocBoot/iocTC-IOC-01/st-common.lua b/TC/iocBoot/iocTC-IOC-01/st-common.lua index 13680086e..9b05bb0a0 100644 --- a/TC/iocBoot/iocTC-IOC-01/st-common.lua +++ b/TC/iocBoot/iocTC-IOC-01/st-common.lua @@ -14,6 +14,7 @@ function twincat_stcommon_main() local forward_units = ibex_utils.getMacroValue{macro="FORWARD_UNITS", default="0"} local enable_frozen_offsets = ibex_utils.getMacroValue{macro="ALLOW_FROZEN_OFFSETS", default="0"} local enable_auto_on_off = ibex_utils.getMacroValue{macro="ENABLE_AUTO_ON_OFF", default="0"} + local enable_homing = ibex_utils.getMacroValue{macro="ENABLE_HOMING_PVS", default="0"} asyn_port = ibex_utils.getMacroValue{macro="PORT"} @@ -52,6 +53,11 @@ function twincat_stcommon_main() iocsh.dbLoadRecords("$(MOTOREXT)/db/frozen_offsets.db", frozen_offsets_db_args) end + if enable_homing == "1" then + local homing_pvs_db_args = string.format("P=%s,AXIS_NUM=%s,ADSPORT=%s,PORT=%s", ioc_prefix, axis_num, ads_port, asyn_port) + iocsh.dbLoadRecords("$(MOTOREXT)/db/homing_tc.db", homing_pvs_db_args) + end + motor_pv = string.format("MTR%02i%02i", mtrctrl, axis_num) if enable_auto_on_off == "1" then