Compare commits

...

5 Commits

Author SHA1 Message Date
488d9c1279 Updated sinqMotor to new 1.6.0
Some checks failed
Test And Build / Lint (push) Failing after 4s
Test And Build / Build (push) Successful in 7s
2026-02-11 11:05:48 +01:00
41c1dad208 Motor now ignores limit switch hit errors when homing
Some checks failed
Test And Build / Lint (push) Failing after 3s
Test And Build / Build (push) Failing after 6s
See comment in src/masterMacsAxis.cpp, line 640ff.
2026-02-11 10:38:22 +01:00
4e3694977d Updated sinqMotor version 2026-02-11 10:38:15 +01:00
d24d2da50a Removed debug prints 2026-02-11 10:23:46 +01:00
516b8e7d68 added debug print 2026-02-11 10:19:44 +01:00
2 changed files with 35 additions and 36 deletions

View File

@@ -190,9 +190,7 @@ asynStatus masterMacsAxis::init() {
double motVelocity = 0.0; double motVelocity = 0.0;
double motVmax = 0.0; double motVmax = 0.0;
double motAccel = 0.0; double motAccel = 0.0;
int motMode = 0;
int dynamicLimits = 0; int dynamicLimits = 0;
int motCanSetMode = 0;
// ========================================================================= // =========================================================================
@@ -306,37 +304,6 @@ asynStatus masterMacsAxis::init() {
} }
pMasterMacsA_->dynamicLimits = bool(dynamicLimits); pMasterMacsA_->dynamicLimits = bool(dynamicLimits);
// Check the current motor mode
status = pC_->read(axisNo_, 07, response);
if (status != asynSuccess) {
return status;
}
nvals = sscanf(response, "%d", &motMode);
if (nvals != 1) {
return pC_->couldNotParseResponse("R07", response, axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
// If the readback value from the controller is 3, it is in velocity mode,
// which sinqMotor encodes as a 1. Otherwise, it is in position mode.
setAxisParamChecked(this, motorMode, motMode == 3);
// Check if the motor can switch its mode
status = pC_->read(axisNo_, 31, response);
if (status != asynSuccess) {
return status;
}
nvals = sscanf(response, "%d", &motCanSetMode);
if (nvals != 1) {
return pC_->couldNotParseResponse("R31", response, axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
// If the readback value from the controller is 3, the motor supports both
// velocity and position mode, otherwise just one of them (the one read out
// with motMode).
setAxisParamChecked(this, motorCanSetMode, motCanSetMode == 3);
status = readEncoderType(); status = readEncoderType();
if (status != asynSuccess) { if (status != asynSuccess) {
return status; return status;
@@ -635,13 +602,45 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
int homed = 0; int homed = 0;
getAxisParamChecked(this, motorStatusHome, &homing); getAxisParamChecked(this, motorStatusHome, &homing);
getAxisParamChecked(this, motorStatusHomed, &homed); getAxisParamChecked(this, motorStatusHomed, &homed);
if (homing || homed) {
/*
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 Either the software limits or the end switches of the controller
have been hit. Since the EPICS limits are derived from the software have been hit. Since the EPICS limits are derived from the software
limits and are a little bit smaller, these error cases can only limits and are a little bit smaller, these error cases can only
happen if either the axis has an incremental encoder which is not 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() || if (positiveLimitSwitch() || negativeLimitSwitch() ||
positiveSoftwareLimit() || negativeSoftwareLimit()) { positiveSoftwareLimit() || negativeSoftwareLimit()) {