Skip to content

Commit

Permalink
Added homing max distance, homing offset positive, and homing offset …
Browse files Browse the repository at this point in the history
…negative.
  • Loading branch information
kmpeters committed Jun 6, 2023
1 parent a1419b6 commit ab6d9ab
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 10 deletions.
24 changes: 24 additions & 0 deletions acsMotionApp/Db/SPiiPlusHoming.db
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
}
17 changes: 16 additions & 1 deletion acsMotionApp/src/SPiiPlusDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
}
Expand Down
8 changes: 8 additions & 0 deletions acsMotionApp/src/SPiiPlusDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -275,6 +279,10 @@ class epicsShareClass SPiiPlusController : public asynMotorController
//
int SPiiPlusFWVersion_;
//
int SPiiPlusHomingMaxDist_;
int SPiiPlusHomingOffsetPos_;
int SPiiPlusHomingOffsetNeg_;
//
int SPiiPlusTest_;
#define LAST_SPIIPLUS_PARAM SPiiPlusTest_

Expand Down
18 changes: 9 additions & 9 deletions iocs/acsMotionIOC/iocBoot/iocAcsMotion/AcsMotion.substitutions
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit ab6d9ab

Please sign in to comment.