From ab6d9aba9a501f2579babc1ef33e60509ecda364 Mon Sep 17 00:00:00 2001 From: Kevin Peterson Date: Wed, 8 Feb 2023 09:02:39 -0600 Subject: [PATCH] Added homing max distance, homing offset positive, and homing offset negative. --- acsMotionApp/Db/SPiiPlusHoming.db | 24 +++++++++++++++++++ acsMotionApp/src/SPiiPlusDriver.cpp | 17 ++++++++++++- acsMotionApp/src/SPiiPlusDriver.h | 8 +++++++ .../iocAcsMotion/AcsMotion.substitutions | 18 +++++++------- 4 files changed, 57 insertions(+), 10 deletions(-) diff --git a/acsMotionApp/Db/SPiiPlusHoming.db b/acsMotionApp/Db/SPiiPlusHoming.db index a770d31..7f384bd 100644 --- a/acsMotionApp/Db/SPiiPlusHoming.db +++ b/acsMotionApp/Db/SPiiPlusHoming.db @@ -23,3 +23,27 @@ record(mbbo, "$(P)$(M):homingMethod") field(VAL, "$(VAL=0)") field(PINI, "YES") } + +record(ao,"$(P)$(M):homingMaxDist") { + field(DESC, "Homing Max Distance") + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),$(ADDR))SPIIPLUS_HOMING_MAX_DIST") + field(VAL, "$(MAX_DIST=0)") + field(PREC, "$(PREC=4)") +} + +record(ao,"$(P)$(M):homingOffsetPos") { + field(DESC, "Homing Offset Pos") + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),$(ADDR))SPIIPLUS_HOMING_OFFSET_POS") + field(VAL, "$(OFFSET_POS=0)") + field(PREC, "$(PREC=4)") +} + +record(ao,"$(P)$(M):homingOffsetNeg") { + field(DESC, "Homing Offset Neg") + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),$(ADDR))SPIIPLUS_HOMING_OFFSET_NEG") + field(VAL, "$(OFFSET_NEG=0)") + field(PREC, "$(PREC=4)") +} diff --git a/acsMotionApp/src/SPiiPlusDriver.cpp b/acsMotionApp/src/SPiiPlusDriver.cpp index 4ce92ad..ba6e2ec 100644 --- a/acsMotionApp/src/SPiiPlusDriver.cpp +++ b/acsMotionApp/src/SPiiPlusDriver.cpp @@ -94,6 +94,10 @@ SPiiPlusController::SPiiPlusController(const char* ACSPortName, const char* asyn // createParam(SPiiPlusFWVersionString, asynParamOctet, &SPiiPlusFWVersion_); // + createParam(SPiiPlusHomingMaxDistString, asynParamFloat64, &SPiiPlusHomingMaxDist_); + createParam(SPiiPlusHomingOffsetPosString, asynParamFloat64, &SPiiPlusHomingOffsetPos_); + createParam(SPiiPlusHomingOffsetNegString, asynParamFloat64, &SPiiPlusHomingOffsetNeg_); + // createParam(SPiiPlusTestString, asynParamInt32, &SPiiPlusTest_); // Initialize this variable to avoid freeing random memory @@ -975,9 +979,20 @@ asynStatus SPiiPlusAxis::home(double minVelocity, double maxVelocity, double acc std::stringstream cmd; epicsInt32 mbboHomingMethod; epicsInt32 homingMethod; + epicsFloat64 homingMaxDistance; + epicsFloat64 homingOffset; static const char *functionName = "home"; controller->getIntegerParam(axisNo_, controller->SPiiPlusHomingMethod_, &mbboHomingMethod); + controller->getDoubleParam(axisNo_, controller->SPiiPlusHomingMaxDist_, &homingMaxDistance); + if (forwards == 0) + { + controller->getDoubleParam(axisNo_, controller->SPiiPlusHomingOffsetNeg_, &homingOffset); + } + else + { + controller->getDoubleParam(axisNo_, controller->SPiiPlusHomingOffsetPos_, &homingOffset); + } switch(mbboHomingMethod) { @@ -1046,7 +1061,7 @@ asynStatus SPiiPlusAxis::home(double minVelocity, double maxVelocity, double acc else { // HOME Axis, [opt]HomingMethod,[opt]HomingVel,[opt]MaxDistance,[opt]HomingOffset,[opt]HomingCurrLimit,[opt]HardStopThreshold - cmd << "HOME " << axisNo_ << "," << homingMethod << "," << (maxVelocity * resolution_); + cmd << "HOME " << axisNo_ << "," << homingMethod << "," << (maxVelocity * resolution_) << "," << homingMaxDistance << "," << homingOffset; //asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, "%s:%s: home command = %s\n", driverName, functionName, cmd.str().c_str()); status = controller->pComm_->writeReadAck(cmd); } diff --git a/acsMotionApp/src/SPiiPlusDriver.h b/acsMotionApp/src/SPiiPlusDriver.h index 00fc235..43815fb 100644 --- a/acsMotionApp/src/SPiiPlusDriver.h +++ b/acsMotionApp/src/SPiiPlusDriver.h @@ -136,6 +136,10 @@ // #define SPiiPlusFWVersionString "SPIIPLUS_FW_VERSION" // +#define SPiiPlusHomingMaxDistString "SPIIPLUS_HOMING_MAX_DIST" +#define SPiiPlusHomingOffsetPosString "SPIIPLUS_HOMING_OFFSET_POS" +#define SPiiPlusHomingOffsetNegString "SPIIPLUS_HOMING_OFFSET_NEG" +// #define SPiiPlusTestString "SPIIPLUS_TEST" struct SPiiPlusDrvUser_t { @@ -275,6 +279,10 @@ class epicsShareClass SPiiPlusController : public asynMotorController // int SPiiPlusFWVersion_; // + int SPiiPlusHomingMaxDist_; + int SPiiPlusHomingOffsetPos_; + int SPiiPlusHomingOffsetNeg_; + // int SPiiPlusTest_; #define LAST_SPIIPLUS_PARAM SPiiPlusTest_ diff --git a/iocs/acsMotionIOC/iocBoot/iocAcsMotion/AcsMotion.substitutions b/iocs/acsMotionIOC/iocBoot/iocAcsMotion/AcsMotion.substitutions index f84973c..0e4112a 100644 --- a/iocs/acsMotionIOC/iocBoot/iocAcsMotion/AcsMotion.substitutions +++ b/iocs/acsMotionIOC/iocBoot/iocAcsMotion/AcsMotion.substitutions @@ -62,15 +62,15 @@ pattern file "$(TOP)/db/SPiiPlusHoming.db" { pattern -{M, PORT, ADDR, TIMEOUT, VAL} -{m1, ACS1, 0, 2.0, 0} -{m2, ACS1, 1, 2.0, 0} -{m3, ACS1, 2, 2.0, 0} -{m4, ACS1, 3, 2.0, 0} -{m5, ACS1, 4, 2.0, 0} -{m6, ACS1, 5, 2.0, 0} -{m7, ACS1, 6, 2.0, 0} -{m8, ACS1, 7, 2.0, 0} +{M, PORT, ADDR, TIMEOUT, VAL, MAX_DIST, OFFSET_POS, OFFSET_NEG} +{m1, ACS1, 0, 2.0, 0, 0.0, 0.0, 0.0} +{m2, ACS1, 1, 2.0, 0, 0.0, 0.0, 0.0} +{m3, ACS1, 2, 2.0, 0, 0.0, 0.0, 0.0} +{m4, ACS1, 3, 2.0, 0, 0.0, 0.0, 0.0} +{m5, ACS1, 4, 2.0, 0, 0.0, 0.0, 0.0} +{m6, ACS1, 5, 2.0, 0, 0.0, 0.0, 0.0} +{m7, ACS1, 6, 2.0, 0, 0.0, 0.0, 0.0} +{m8, ACS1, 7, 2.0, 0, 0.0, 0.0, 0.0} } file "$(TOP)/db/SPiiPlusJogging.db"