From 192b396a993264ac935b2dc7fcbe6b5bbd574a5f Mon Sep 17 00:00:00 2001 From: kpetersn Date: Fri, 23 Mar 2018 16:21:49 -0500 Subject: [PATCH] Made the setClosedLoop function do nothing. Tried to send the clear command error command,but that caused a command error from which I couldn't recover (presumably reconfiguring the axis would have resolved that problem. --- motorApp/AMCISrc/ANF2Driver.cpp | 55 ++++++++++++++------------------- 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/motorApp/AMCISrc/ANF2Driver.cpp b/motorApp/AMCISrc/ANF2Driver.cpp index c46e6610..865dbc14 100644 --- a/motorApp/AMCISrc/ANF2Driver.cpp +++ b/motorApp/AMCISrc/ANF2Driver.cpp @@ -724,34 +724,26 @@ asynStatus ANF2Axis::setPosition(double position) asynStatus ANF2Axis::setClosedLoop(bool closedLoop) { asynStatus status; - int enable = 0x8000; - int disable = 0x0000; - int cmd; - - printf(" ** setClosedLoop called \n"); + epicsInt32 clReg[5]; + //static const char *functionName = "ANF2Axis::setClosedLoop"; + + // The ANF2 doesn't have a closed-loop enable/disable command, so do nothing. + // The configuration of an axis: + // * can be changed so that an axis is disabled, but that doesn't disable torque + // * can be changed to disable the use of encoder inputs, but that isn't currently allowed on-the-fly + + /*printf(" ** setClosedLoop called \n"); if (closedLoop) { - printf("setting enable %X\n", enable); - // Let's reset errors first - cmd = 0x0; - status = pC_->writeReg16(axisNo_, CMD_MSW, cmd, DEFAULT_CONTROLLER_TIMEOUT); - - cmd = 0x400; - status = pC_->writeReg16(axisNo_, CMD_MSW, cmd, DEFAULT_CONTROLLER_TIMEOUT); - - cmd = 0x0; - status = pC_->writeReg16(axisNo_, CMD_MSW, cmd, DEFAULT_CONTROLLER_TIMEOUT); - /* - status = pC_->writeReg16(axisNo_, CMD_LSW, enable, DEFAULT_CONTROLLER_TIMEOUT); - setIntegerParam(pC_->motorStatusPowerOn_, 1); - */ - + printf("setting enable true\n"); + + setIntegerParam(pC_->motorStatusPowerOn_, 1); } else { - printf("setting disable %X\n", disable); - status = pC_->writeReg16(axisNo_, CMD_LSW, disable, DEFAULT_CONTROLLER_TIMEOUT); + printf("setting disable false\n"); setIntegerParam(pC_->motorStatusPowerOn_, 0); } + return status;*/ - return status; + return asynSuccess; } // POLL @@ -805,6 +797,14 @@ asynStatus ANF2Axis::poll(bool *moving) setIntegerParam(pC_->motorStatusDone_, done); *moving = done ? false:true; //printf("done is %d\n", done); + + // Check for enable/disable (not actually the torque status) and set accordingly. + // Enable/disable is determined by the configuration and it isn't obvious why one would disable an axis. + enabled = (read_val & 0x4000); + if (enabled) + setIntegerParam(pC_->motorStatusPowerOn_, 1); + else + setIntegerParam(pC_->motorStatusPowerOn_, 0); // Read the limit status // @@ -837,15 +837,6 @@ asynStatus ANF2Axis::poll(bool *moving) // Should be in init routine? Allows CNEN to be used. setIntegerParam(pC_->motorStatusGainSupport_, 1); - // Check for the torque status and set accordingly. - // The ANG1 driver does the wrong thing for torque enable/disable - //enabled = (read_val & 0x8000); - enabled = 1; - if (enabled) - setIntegerParam(pC_->motorStatusPowerOn_, 1); - else - setIntegerParam(pC_->motorStatusPowerOn_, 0); - // Notify asynMotorController polling routine that we're ready callParamCallbacks();