diff --git a/motorApp/AMCISrc/ANF2Driver.cpp b/motorApp/AMCISrc/ANF2Driver.cpp index 9332b723..1424c204 100644 --- a/motorApp/AMCISrc/ANF2Driver.cpp +++ b/motorApp/AMCISrc/ANF2Driver.cpp @@ -54,6 +54,7 @@ ANF2Controller::ANF2Controller(const char *portName, const char *ANF2InPortName, inputDriver_ = epicsStrDup(ANF2InPortName); // Set this before calls to create Axis objects // Create controller-specific parameters + createParam(ANF2ResetErrorsString, asynParamInt32, &ANF2ResetErrors_); createParam(ANF2GetInfoString, asynParamInt32, &ANF2GetInfo_); createParam(ANF2ReconfigString, asynParamInt32, &ANF2Reconfig_); @@ -230,7 +231,15 @@ asynStatus ANF2Controller::writeInt32(asynUser *pasynUser, epicsInt32 value) /* Set the parameter and readback in the parameter library. */ status = setIntegerParam(pAxis->axisNo_, function, value); - if (function == ANF2GetInfo_) + if (function == ANF2ResetErrors_) + { + // Only reset errors when value is 1 + if (value == 1) { + printf("ANF2Controller:writeInt32: Resetting errors for axis = %d\n", pAxis->axisNo_); + pAxis->resetErrors(); + + } + } else if (function == ANF2GetInfo_) { // Only get info when value is 1 if (value == 1) { @@ -476,6 +485,22 @@ void ANF2Axis::zeroRegisters(epicsInt32 *reg) } } +asynStatus ANF2Axis::resetErrors() +{ + asynStatus status; + epicsInt32 errorReg[5]; + //static const char *functionName = "ANF2Axis::resetErrors"; + + zeroRegisters(errorReg); + + errorReg[0] = 0x800 << 16; + + // Send the reset error command + status = pC_->writeReg32Array(axisNo_, errorReg, 5, DEFAULT_CONTROLLER_TIMEOUT); + + return status; +} + void ANF2Axis::getInfo() { asynStatus status; diff --git a/motorApp/AMCISrc/ANF2Driver.h b/motorApp/AMCISrc/ANF2Driver.h index a46f18c2..d7e99cdb 100644 --- a/motorApp/AMCISrc/ANF2Driver.h +++ b/motorApp/AMCISrc/ANF2Driver.h @@ -55,11 +55,12 @@ K. Goetze 2014-03-24 #define CONFIG_REG_4 4 // No. of controller-specific parameters -#define NUM_ANF2_PARAMS 2 +#define NUM_ANF2_PARAMS 3 /** drvInfo strings for extra parameters that the ACR controller supports */ +#define ANF2ResetErrorsString "ANF2_RESET_ERRORS" #define ANF2GetInfoString "ANF2_GET_INFO" -#define ANF2ReconfigString "ANF2_RECONFIG" +#define ANF2ReconfigString "ANF2_RECONFIG" class ANF2Axis : public asynMotorAxis { @@ -80,6 +81,7 @@ private: * Abbreviated because it is used very frequently */ asynStatus sendAccelAndVelocity(double accel, double velocity); double correctAccel(double minVelocity, double maxVelocity, double acceleration); + asynStatus resetErrors(); void getInfo(); epicsInt32 inputReg_[10]; void reconfig(epicsInt32 value); @@ -135,8 +137,9 @@ public: /* These are the methods that are new to this class */ protected: - int ANF2GetInfo_; /**< Jerk time parameter index */ - int ANF2Reconfig_; /**< Jerk time parameter index */ + int ANF2ResetErrors_; /** Reset Errors parameter index */ + int ANF2GetInfo_; /**< Get Info parameter index */ + int ANF2Reconfig_; /**< Reconfig parameter index */ private: diff --git a/motorApp/Db/ANF2Aux.template b/motorApp/Db/ANF2Aux.template index c506c89e..aeaeace6 100644 --- a/motorApp/Db/ANF2Aux.template +++ b/motorApp/Db/ANF2Aux.template @@ -1,5 +1,15 @@ # Database for extra PVs for AMCI ANG1 controllers +record(bo,"$(P)$(R)ResetErrors") { + field(DESC,"Reset Errors") + field(PINI, "0") + field(VAL,"0") + field(DTYP, "asynInt32") + field(OUT,"@asyn($(PORT),$(ADDR))ANF2_RESET_ERRORS") + field(ZNAM, "Done") + field(ONAM, "Reset") +} + record(bo,"$(P)$(R)GetInfo") { field(DESC,"Get Info") field(PINI, "0")