diff --git a/motorApp/AMCISrc/ANF2Driver.cpp b/motorApp/AMCISrc/ANF2Driver.cpp index 6552cea5..74566314 100644 --- a/motorApp/AMCISrc/ANF2Driver.cpp +++ b/motorApp/AMCISrc/ANF2Driver.cpp @@ -55,7 +55,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(ANF2JerkString, asynParamInt32, &ANF2Jerk_); + createParam(ANF2GetInfoString, asynParamInt32, &ANF2GetInfo_); if (numAxes > MAX_AXES) { numAxes = MAX_AXES; @@ -159,23 +159,19 @@ asynStatus ANF2Controller::writeInt32(asynUser *pasynUser, epicsInt32 value) /* Set the parameter and readback in the parameter library. */ status = setIntegerParam(pAxis->axisNo_, function, value); - // The ANF controller doesn't have a jerk variable - // Could probably just not overload writeInt32 at all - /* - if (function == ANF2Jerk_) + if (function == ANF2GetInfo_) { - // Jerk in units steps/sec/sec/sec (0 - 5000) - printf("Jerk = %d\n", value); - status = writeReg16(JERK, value, DEFAULT_CONTROLLER_TIMEOUT); + // Only get info when value is 1 + if (value == 1) { + printf("ANF2Controller:writeInt32: Getting info for axis = %d\n", pAxis->axisNo_); + pAxis->getInfo(); -// sprintf(outString_, "%s JOG JRK %f", pAxis->axisName_, value); -// status = writeController(); - + } } else { // Call base class method status = asynMotorController::writeInt32(pasynUser, value); } - */ + // Call base class method status = asynMotorController::writeInt32(pasynUser, value); @@ -483,24 +479,28 @@ asynStatus ANF2Axis::move(double position, int relative, double minVelocity, dou if (relative) { printf(" ** relative move called\n"); //status = pC_->writeReg32(axisNo_, SPD_UPR, velo, DEFAULT_CONTROLLER_TIMEOUT); - //distance = position * SOM_OTHER_SCALE_FACTOR; - distance = NINT(position); + //distance = position * SOM_OTHER_SCALE_FACTOR; + distance = NINT(position); status = pC_->writeReg32(axisNo_, POS_WR_UPR, distance, DEFAULT_CONTROLLER_TIMEOUT); - move_bit = 0x0; - status = pC_->writeReg16(axisNo_, CMD_MSW, move_bit, DEFAULT_CONTROLLER_TIMEOUT); - move_bit = 0x2; + + //move_bit = 0x0; + //status = pC_->writeReg16(axisNo_, CMD_MSW, move_bit, DEFAULT_CONTROLLER_TIMEOUT); + + move_bit = 0x2; status = pC_->writeReg16(axisNo_, CMD_MSW, move_bit, DEFAULT_CONTROLLER_TIMEOUT); } else { // absolute printf(" ** absolute move called\n"); //status = pC_->writeReg32(axisNo_, SPD_UPR, velo, DEFAULT_CONTROLLER_TIMEOUT); - //distance = position * SOM_OTHER_SCALE_FACTOR; - distance = NINT(position); - printf(" ** distance = %d\n", distance); + //distance = position * SOM_OTHER_SCALE_FACTOR; + distance = NINT(position); + printf(" ** distance = %d\n", distance); status = pC_->writeReg32(axisNo_, POS_WR_UPR, distance, DEFAULT_CONTROLLER_TIMEOUT); - move_bit = 0x0; - status = pC_->writeReg16(axisNo_, CMD_MSW, move_bit, DEFAULT_CONTROLLER_TIMEOUT); - move_bit = 0x1; + + //move_bit = 0x0; + //status = pC_->writeReg16(axisNo_, CMD_MSW, move_bit, DEFAULT_CONTROLLER_TIMEOUT); + + move_bit = 0x1; status = pC_->writeReg16(axisNo_, CMD_MSW, move_bit, DEFAULT_CONTROLLER_TIMEOUT); } // Delay the first status read, give the controller some time to return moving status @@ -665,6 +665,8 @@ asynStatus ANF2Axis::poll(bool *moving) return asynSuccess; } + //getInfo(); + // Force a read operation //printf(" . . . . . Calling pasynInt32SyncIO->write\n"); //printf("Calling pasynInt32SyncIO->write(pasynUserForceRead_, 1, TIMEOUT), pasynUserForceRead_->reason=%d\n", pasynUserForceRead_->reason); @@ -672,6 +674,8 @@ asynStatus ANF2Axis::poll(bool *moving) //printf(" . . . . . status = %d\n", status); // if status goto end + //getInfo(); + // Read the current motor position // //readReg32(int reg, epicsInt32 *combo, double timeout) @@ -697,7 +701,7 @@ asynStatus ANF2Axis::poll(bool *moving) status = pC_->readReg16(axisNo_, STATUS_2, &read_val, DEFAULT_CONTROLLER_TIMEOUT); //printf("status 2 is 0x%X\n", read_val); - limit = (read_val & 0x1); // a cw limit has been reached + limit = (read_val & 0x8); // a cw limit has been reached setIntegerParam(pC_->motorStatusHighLimit_, limit); //printf("+limit %d\n", limit); if (limit) { // reset error and set position so we can move off of the limit @@ -708,7 +712,7 @@ asynStatus ANF2Axis::poll(bool *moving) setPosition(position); } - limit = (read_val & 0x2); // a ccw limit has been reached + limit = (read_val & 0x10); // a ccw limit has been reached setIntegerParam(pC_->motorStatusLowLimit_, limit); //printf("-limit %d\n", limit); if (limit) { // reset error and set position so we can move off of the limit diff --git a/motorApp/AMCISrc/ANF2Driver.h b/motorApp/AMCISrc/ANF2Driver.h index c1d604a0..9062f5a6 100644 --- a/motorApp/AMCISrc/ANF2Driver.h +++ b/motorApp/AMCISrc/ANF2Driver.h @@ -58,7 +58,7 @@ K. Goetze 2014-03-24 #define NUM_ANF2_PARAMS 1 /** drvInfo strings for extra parameters that the ACR controller supports */ -#define ANF2JerkString "ANF2_JERK" +#define ANF2GetInfoString "ANF2_GET_INFO" class ANF2Axis : public asynMotorAxis { @@ -106,7 +106,7 @@ public: /* These are the methods that are new to this class */ protected: - int ANF2Jerk_; /**< Jerk time parameter index */ + int ANF2GetInfo_; /**< Jerk time parameter index */ private: diff --git a/motorApp/Db/ANF2Aux.template b/motorApp/Db/ANF2Aux.template new file mode 100644 index 00000000..0cf8bb4f --- /dev/null +++ b/motorApp/Db/ANF2Aux.template @@ -0,0 +1,9 @@ +# Database for extra PVs for AMCI ANG1 controllers + +record(bo,"$(P)$(R)GetInfo") { + field(DESC,"Get Info") + field(PINI, "0") + field(VAL,"0") + field(DTYP, "asynInt32") + field(OUT,"@asyn($(PORT),$(ADDR))ANF2_GET_INFO") +}