From a3e849f38663a14dcd445efa463d9d79e23518eb Mon Sep 17 00:00:00 2001 From: smathis Date: Fri, 28 Mar 2025 14:53:04 +0100 Subject: [PATCH] Changed to the "motorPosition" and "setMotorPosition" functions provided by sinqMotor. --- Makefile | 2 +- README.md | 2 ++ src/masterMacsAxis.cpp | 54 +++++++++++++++--------------------------- src/masterMacsAxis.h | 4 ++-- 4 files changed, 24 insertions(+), 38 deletions(-) diff --git a/Makefile b/Makefile index fa60d1a..7dd9222 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ REQUIRED+=sinqMotor motorBase_VERSION=7.2.2 # Specify the version of sinqMotor we want to build against -sinqMotor_VERSION=0.9.0 +sinqMotor_VERSION=mathis_s # These headers allow to depend on this library for derived drivers. HEADERS += src/masterMacsAxis.h diff --git a/README.md b/README.md index d6ad25a..1a14a37 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # masterMacs +## Please read the documentation of sinqMotor first: https://git.psi.ch/sinq-epics-modules/sinqmotor + ## Overview This is a driver for the masterMacs motion controller with the SINQ communication protocol. It is based on the sinqMotor shared library (https://git.psi.ch/sinq-epics-modules/sinqmotor). The header files contain detailed documentation for all public functions. The headers themselves are exported when building the library to allow other drivers to depend on this one. diff --git a/src/masterMacsAxis.cpp b/src/masterMacsAxis.cpp index 8516120..b1adcf6 100644 --- a/src/masterMacsAxis.cpp +++ b/src/masterMacsAxis.cpp @@ -190,7 +190,7 @@ asynStatus masterMacsAxis::init() { } nvals = sscanf(response, "%lf", &motorPosition); if (nvals != 1) { - return pC_->errMsgCouldNotParseResponse("R12", response, axisNo_, + return pC_->couldNotParseResponse("R12", response, axisNo_, __PRETTY_FUNCTION__, __LINE__); } @@ -201,7 +201,7 @@ asynStatus masterMacsAxis::init() { } nvals = sscanf(response, "%lf", &motorVelocity); if (nvals != 1) { - return pC_->errMsgCouldNotParseResponse("R05", response, axisNo_, + return pC_->couldNotParseResponse("R05", response, axisNo_, __PRETTY_FUNCTION__, __LINE__); } @@ -212,7 +212,7 @@ asynStatus masterMacsAxis::init() { } nvals = sscanf(response, "%lf", &motorVmax); if (nvals != 1) { - return pC_->errMsgCouldNotParseResponse("R26", response, axisNo_, + return pC_->couldNotParseResponse("R26", response, axisNo_, __PRETTY_FUNCTION__, __LINE__); } @@ -223,7 +223,7 @@ asynStatus masterMacsAxis::init() { } nvals = sscanf(response, "%lf", &motorAccel); if (nvals != 1) { - return pC_->errMsgCouldNotParseResponse("R06", response, axisNo_, + return pC_->couldNotParseResponse("R06", response, axisNo_, __PRETTY_FUNCTION__, __LINE__); } @@ -232,15 +232,10 @@ asynStatus masterMacsAxis::init() { // MasterMACS. lastSetSpeed_ = motorVelocity; - // Transform from motor to parameter library coordinates - motorPosition = motorPosition / motorRecResolution; - - // Store these values in the parameter library - pl_status = - pC_->setDoubleParam(axisNo_, pC_->motorPosition(), motorPosition); + // Store the motor position in the parameter library + pl_status = setMotorPosition(motorPosition); if (pl_status != asynSuccess) { - return pC_->paramLibAccessFailed(pl_status, "motorPosition_", axisNo_, - __PRETTY_FUNCTION__, __LINE__); + return pl_status; } // Write to the motor record fields @@ -338,7 +333,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) { nvals = sscanf(response, "%lf", &handshakePerformed); if (nvals != 1) { - return pC_->errMsgCouldNotParseResponse( + return pC_->couldNotParseResponse( "R86", response, axisNo_, __PRETTY_FUNCTION__, __LINE__); } @@ -379,17 +374,11 @@ asynStatus masterMacsAxis::doPoll(bool *moving) { } // Read the previous motor position - pl_status = - pC_->getDoubleParam(axisNo_, pC_->motorPosition(), &previousPosition); + pl_status = motorPosition(&previousPosition); if (pl_status != asynSuccess) { - return pC_->paramLibAccessFailed(pl_status, "motorPosition_", axisNo_, - __PRETTY_FUNCTION__, __LINE__); + return pl_status; } - // Transform from EPICS to motor coordinates (see comment in - // masterMacsAxis::readConfig()) - previousPosition = previousPosition * motorRecResolution; - // Update the axis status rw_status = readAxisStatus(); if (rw_status != asynSuccess) { @@ -411,7 +400,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) { } nvals = sscanf(response, "%lf", ¤tPosition); if (nvals != 1) { - return pC_->errMsgCouldNotParseResponse("R12", response, axisNo_, + return pC_->couldNotParseResponse("R12", response, axisNo_, __PRETTY_FUNCTION__, __LINE__); } @@ -619,7 +608,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) { } nvals = sscanf(response, "%lf", &lowLimit); if (nvals != 1) { - return pC_->errMsgCouldNotParseResponse( + return pC_->couldNotParseResponse( "R34", response, axisNo_, __PRETTY_FUNCTION__, __LINE__); } @@ -629,7 +618,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) { } nvals = sscanf(response, "%lf", &highLimit); if (nvals != 1) { - return pC_->errMsgCouldNotParseResponse( + return pC_->couldNotParseResponse( "R33", response, axisNo_, __PRETTY_FUNCTION__, __LINE__); } @@ -719,14 +708,9 @@ asynStatus masterMacsAxis::doPoll(bool *moving) { __LINE__); } - // Transform from motor to EPICS coordinates (see comment in - // masterMacsAxis::init()) - currentPosition = currentPosition / motorRecResolution; - - pl_status = setDoubleParam(pC_->motorPosition(), currentPosition); + pl_status = setMotorPosition(currentPosition); if (pl_status != asynSuccess) { - return pC_->paramLibAccessFailed(pl_status, "motorPosition_", axisNo_, - __PRETTY_FUNCTION__, __LINE__); + return pl_status; } return poll_status; @@ -894,7 +878,7 @@ asynStatus masterMacsAxis::stop(double acceleration) { return rw_status; } -asynStatus masterMacsAxis::reset() { +asynStatus masterMacsAxis::doReset() { // Status of read-write-operations of ASCII commands to the controller asynStatus rw_status = asynSuccess; @@ -994,7 +978,7 @@ asynStatus masterMacsAxis::readEncoderType() { nvals = sscanf(response, "%d", &encoder_id); if (nvals != 1) { - return pC_->errMsgCouldNotParseResponse(command, response, axisNo_, + return pC_->couldNotParseResponse(command, response, axisNo_, __PRETTY_FUNCTION__, __LINE__); } @@ -1154,7 +1138,7 @@ asynStatus masterMacsAxis::readAxisStatus() { float axisStatus = 0; int nvals = sscanf(response, "%f", &axisStatus); if (nvals != 1) { - return pC_->errMsgCouldNotParseResponse( + return pC_->couldNotParseResponse( "R10", response, axisNo_, __PRETTY_FUNCTION__, __LINE__); } @@ -1175,7 +1159,7 @@ asynStatus masterMacsAxis::readAxisError() { float axisError = 0; int nvals = sscanf(response, "%f", &axisError); if (nvals != 1) { - return pC_->errMsgCouldNotParseResponse( + return pC_->couldNotParseResponse( "R11", response, axisNo_, __PRETTY_FUNCTION__, __LINE__); } axisError_ = toBitset(axisError); diff --git a/src/masterMacsAxis.h b/src/masterMacsAxis.h index 98c55cb..4eb2b83 100644 --- a/src/masterMacsAxis.h +++ b/src/masterMacsAxis.h @@ -70,12 +70,12 @@ class masterMacsAxis : public sinqAxis { asynStatus stop(double acceleration); /** - * @brief Reset the axis error + * @brief Implementation of the `doReset` function from sinqAxis. * * @param on * @return asynStatus */ - asynStatus reset(); + asynStatus doReset(); /** * @brief Readout of some values from the controller at IOC startup