From 238a47f38e9e52d7a08d1526789409ab72550def Mon Sep 17 00:00:00 2001 From: smathis Date: Tue, 10 Feb 2026 12:57:52 +0100 Subject: [PATCH 1/3] Ignore limit switch errors when the motor is homing or has been homed --- Makefile | 2 ++ src/masterMacsAxis.cpp | 75 +++++++++++++++++++++++------------------- 2 files changed, 44 insertions(+), 33 deletions(-) diff --git a/Makefile b/Makefile index e93cf38..4bbf8c3 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,8 @@ ARCH_FILTER=RHEL% # Specify the version of asynMotor we want to build against motorBase_VERSION=7.2.2 +LIBVERSION=homeerror + # These headers allow to depend on this library for derived drivers. HEADERS += src/masterMacsAxis.h HEADERS += src/masterMacsController.h diff --git a/src/masterMacsAxis.cpp b/src/masterMacsAxis.cpp index 254040e..67d7cd0 100644 --- a/src/masterMacsAxis.cpp +++ b/src/masterMacsAxis.cpp @@ -629,42 +629,51 @@ asynStatus masterMacsAxis::doPoll(bool *moving) { } /* - Either the software limits or the end switches of the controller - have been hit. Since the EPICS limits are derived from the software - limits and are a little bit smaller, these error cases can only - happen if either the axis has an incremental encoder which is not - properly homed or if a bug occured. - */ - if (positiveLimitSwitch() || negativeLimitSwitch() || - positiveSoftwareLimit() || negativeSoftwareLimit()) { + If the motor is homing or has been homed, ignore limit switch errors. + */ + int homing = 0; + int homed = 0; + getAxisParamChecked(this, motorStatusHome, &homing); + getAxisParamChecked(this, motorStatusHomed, &homed); + if (homing || homed) { + /* + Either the software limits or the end switches of the controller + have been hit. Since the EPICS limits are derived from the software + limits and are a little bit smaller, these error cases can only + happen if either the axis has an incremental encoder which is not + properly homed or if a bug occured. + */ + if (positiveLimitSwitch() || negativeLimitSwitch() || + positiveSoftwareLimit() || negativeSoftwareLimit()) { - // Distinction for developers - if (positiveLimitSwitch()) { - appendErrorMessage(shellMessage, sizeof(shellMessage), - "Positive limit switch."); - } - if (negativeLimitSwitch()) { - appendErrorMessage(shellMessage, sizeof(shellMessage), - "Negative limit switch."); - } - if (positiveSoftwareLimit()) { - appendErrorMessage(shellMessage, sizeof(shellMessage), - "Positive software limit."); - } - if (negativeSoftwareLimit()) { - appendErrorMessage(shellMessage, sizeof(shellMessage), - "Negative software limit."); - } + // Distinction for developers + if (positiveLimitSwitch()) { + appendErrorMessage(shellMessage, sizeof(shellMessage), + "Positive limit switch."); + } + if (negativeLimitSwitch()) { + appendErrorMessage(shellMessage, sizeof(shellMessage), + "Negative limit switch."); + } + if (positiveSoftwareLimit()) { + appendErrorMessage(shellMessage, sizeof(shellMessage), + "Positive software limit."); + } + if (negativeSoftwareLimit()) { + appendErrorMessage(shellMessage, sizeof(shellMessage), + "Negative software limit."); + } - // Generic error message for user - appendErrorMessage( - errorMessage, sizeof(errorMessage), - "Software limits or end switch hit. Try homing the motor, " - "moving in the opposite direction or check the SPS for " - "errors (if available). Otherwise please call the " - "support."); + // Generic error message for user + appendErrorMessage( + errorMessage, sizeof(errorMessage), + "Software limits or end switch hit. Try homing the motor, " + "moving in the opposite direction or check the SPS for " + "errors (if available). Otherwise please call the " + "support."); - poll_status = asynError; + poll_status = asynError; + } } if (overCurrent()) { From 516b8e7d681267b0026a06ec0e980f135c37c1ad Mon Sep 17 00:00:00 2001 From: smathis Date: Wed, 11 Feb 2026 10:19:44 +0100 Subject: [PATCH 2/3] added debug print --- sinqMotor | 2 +- src/masterMacsAxis.cpp | 43 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/sinqMotor b/sinqMotor index 4e30331..2ef20e1 160000 --- a/sinqMotor +++ b/sinqMotor @@ -1 +1 @@ -Subproject commit 4e30331c92a1c212e4b5f46996e4b7853c559136 +Subproject commit 2ef20e1bc2138decc1ba314690ec246a628b2bb9 diff --git a/src/masterMacsAxis.cpp b/src/masterMacsAxis.cpp index 67d7cd0..aed95c5 100644 --- a/src/masterMacsAxis.cpp +++ b/src/masterMacsAxis.cpp @@ -635,13 +635,52 @@ asynStatus masterMacsAxis::doPoll(bool *moving) { int homed = 0; getAxisParamChecked(this, motorStatusHome, &homing); getAxisParamChecked(this, motorStatusHomed, &homed); - if (homing || homed) { + + // DEBUG + if (axisNo_ == 11) { + asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR, + "Homing: %d, homed: %d, moving: %d\n", homing, homed, + *moving); + } + + /* + Ignore limit switch errors when homing / motor has been homed or when + the motor is moving. + + Background: + MasterMACS controllers move the motor outside the allowed range defined + by the "software limits" defined within the controllers because they + need to hit the physical end switch to determine the motor position. The + motor then rests close to the end switch, which might be outside the + controller-side software limits. This leads to this error, which is then + forwarded to the user even though nothing went wrong. The three checks + are here to prevent this: + - "homing": Is set at the start of a homing maneuver and removed once + the motor does not move anymore => Prevents the error from showing up + during the homing procedure + - "homed": Is set after a homing maneuver has been finished => Prevents + the error from showing up while the motor is resting idle outside the + software limits. + - "moving": Prevents the error from showing up when moving out of the + homing position. + + If the motor hits the limits during normal operation, it is stopped by + the controller. Once stopped, moving is false and then the error is + shown to the user (because "homed" is not set). + + Note: strictly speaking, it is not necessary to check homing because + moving would be set to true anyway. The check is here for clarity / + being explicit. + */ + if (!homing && !homed && !(*moving)) { /* Either the software limits or the end switches of the controller have been hit. Since the EPICS limits are derived from the software limits and are a little bit smaller, these error cases can only happen if either the axis has an incremental encoder which is not - properly homed or if a bug occured. + properly homed or if the motor moved outside the limits while homing + (but in that case, the error is not shown, see previous + if-statement). */ if (positiveLimitSwitch() || negativeLimitSwitch() || positiveSoftwareLimit() || negativeSoftwareLimit()) { From d24d2da50a0bb5c4f3de0c451a72847b21c07e4c Mon Sep 17 00:00:00 2001 From: smathis Date: Wed, 11 Feb 2026 10:23:46 +0100 Subject: [PATCH 3/3] Removed debug prints --- sinqMotor | 2 +- src/masterMacsAxis.cpp | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/sinqMotor b/sinqMotor index 2ef20e1..95bc899 160000 --- a/sinqMotor +++ b/sinqMotor @@ -1 +1 @@ -Subproject commit 2ef20e1bc2138decc1ba314690ec246a628b2bb9 +Subproject commit 95bc899114f90fa0b5925054d1eb374db9678bd7 diff --git a/src/masterMacsAxis.cpp b/src/masterMacsAxis.cpp index aed95c5..cc14997 100644 --- a/src/masterMacsAxis.cpp +++ b/src/masterMacsAxis.cpp @@ -636,13 +636,6 @@ asynStatus masterMacsAxis::doPoll(bool *moving) { getAxisParamChecked(this, motorStatusHome, &homing); getAxisParamChecked(this, motorStatusHomed, &homed); - // DEBUG - if (axisNo_ == 11) { - asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR, - "Homing: %d, homed: %d, moving: %d\n", homing, homed, - *moving); - } - /* Ignore limit switch errors when homing / motor has been homed or when the motor is moving.