From 2766f0c6675a50d2808d579a36756bcaa07c59a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Sandstr=C3=B6m?= Date: Mon, 17 Aug 2020 16:02:24 +0200 Subject: [PATCH 1/9] Autosave: Add setPosition method in axis (instead of use movehome(15,...)). --- devEcmcSup/motion/ecmcAxisBase.cpp | 31 ++++++++++++++++++++++++ devEcmcSup/motion/ecmcAxisBase.h | 1 + devEcmcSup/motion/ecmcAxisSequencer.cpp | 6 ++--- devEcmcSup/motion/ecmcMotion.cpp | 16 ++++++++++++ devEcmcSup/motion/ecmcMotion.h | 12 +++++++++ devEcmcSup/motor/ecmcMotorRecordAxis.cpp | 19 ++------------- 6 files changed, 65 insertions(+), 20 deletions(-) diff --git a/devEcmcSup/motion/ecmcAxisBase.cpp b/devEcmcSup/motion/ecmcAxisBase.cpp index b314a019..1605620c 100644 --- a/devEcmcSup/motion/ecmcAxisBase.cpp +++ b/devEcmcSup/motion/ecmcAxisBase.cpp @@ -1442,6 +1442,37 @@ int ecmcAxisBase::moveHome(int nCmdData, return 0; } +int ecmcAxisBase::setPosition(double homePositionSet) { + + int errorCode = getErrorID(); + if (errorCode) { + return errorCode; + } + + errorCode = setExecute(0); + if (errorCode) { + return errorCode; + } + + errorCode = setCommand(ECMC_CMD_HOMING); + if (errorCode) { + return errorCode; + } + errorCode = setCmdData(ECMC_SEQ_HOME_SET_POS); + + if (errorCode) { + return errorCode; + } + getSeq()->setHomePosition(homePositionSet); + errorCode = setExecute(1); + + if (errorCode) { + return errorCode; + } + return 0; +} + + int ecmcAxisBase::stopMotion(int killAmplifier) { int errorCode = setExecute(0); diff --git a/devEcmcSup/motion/ecmcAxisBase.h b/devEcmcSup/motion/ecmcAxisBase.h index 6370fdf1..f0082f64 100644 --- a/devEcmcSup/motion/ecmcAxisBase.h +++ b/devEcmcSup/motion/ecmcAxisBase.h @@ -234,6 +234,7 @@ class ecmcAxisBase : public ecmcError { double velocityOffCamSet, double accelerationSet, double decelerationSet); + int setPosition(double homePositionSet); // Autosave int stopMotion(int killAmplifier); protected: diff --git a/devEcmcSup/motion/ecmcAxisSequencer.cpp b/devEcmcSup/motion/ecmcAxisSequencer.cpp index 26fd770a..d0c0b94c 100644 --- a/devEcmcSup/motion/ecmcAxisSequencer.cpp +++ b/devEcmcSup/motion/ecmcAxisSequencer.cpp @@ -2100,7 +2100,7 @@ int ecmcAxisSequencer::setAxisDataRef(ecmcAxisData *data) { } int ecmcAxisSequencer::checkVelAccDec() { - if (data_->command_.command == ECMC_CMD_HOMING) { + if (data_->command_.command == ECMC_CMD_HOMING && data_->command_.cmdData != ECMC_SEQ_HOME_SET_POS) { if ((std::abs(homeVelTwordsCam_) == 0) || (std::abs(homeVelOffCam_) == 0)) { return setErrorID(__FILE__, @@ -2123,7 +2123,7 @@ int ecmcAxisSequencer::checkVelAccDec() { } // Sanity check of acceleration - if (traj_->getAcc() <= 0) { + if (traj_->getAcc() <= 0 && data_->command_.cmdData != ECMC_SEQ_HOME_SET_POS) { return setErrorID(__FILE__, __FUNCTION__, __LINE__, @@ -2131,7 +2131,7 @@ int ecmcAxisSequencer::checkVelAccDec() { } // Sanity check of deceleration - if (traj_->getDec() <= 0) { + if (traj_->getDec() <= 0 && data_->command_.cmdData != ECMC_SEQ_HOME_SET_POS) { return setErrorID(__FILE__, __FUNCTION__, __LINE__, diff --git a/devEcmcSup/motion/ecmcMotion.cpp b/devEcmcSup/motion/ecmcMotion.cpp index f80b1877..3c54fd8e 100644 --- a/devEcmcSup/motion/ecmcMotion.cpp +++ b/devEcmcSup/motion/ecmcMotion.cpp @@ -147,6 +147,22 @@ LOGINFO4( decelerationSet); } +int setPosition(int axisIndex, + double homePositionSet) { +LOGINFO4( + "%s/%s:%d axisIndex=%d,homePositionSet=%lf\n", + __FILE__, + __FUNCTION__, + __LINE__, + axisIndex, + homePositionSet); + + CHECK_AXIS_RETURN_IF_ERROR_AND_BLOCK_COM(axisIndex); + CHECK_AXIS_SEQ_RETURN_IF_ERROR(axisIndex); + CHECK_AXIS_TRAJ_RETURN_IF_ERROR(axisIndex); + + return axes[axisIndex]->setPosition(homePositionSet); +} int stopMotion(int axisIndex, int killAmplifier) { LOGINFO4("%s/%s:%d axisIndex=%d, killAmplifier=%d\n", diff --git a/devEcmcSup/motion/ecmcMotion.h b/devEcmcSup/motion/ecmcMotion.h index 5d5fdf9c..65fae1a7 100644 --- a/devEcmcSup/motion/ecmcMotion.h +++ b/devEcmcSup/motion/ecmcMotion.h @@ -186,6 +186,18 @@ int moveHome(int axisIndex, double accelerationSet, double decelerationSet); +/** \brief set position.\n + * used by epics autosave to restore axis value after ioc reboot. + * + * \param[in] axisIndex Axis index.\n + * \param[in] homePositionSet Position to set at homing.\n + + * + * \return 0 if success or otherwise an error code.\n + */ +int setPosition(int axisIndex, + double homePositionSet); + /** \brief Get axis error state.\n * * \param[in] axisIndex Axis index.\n diff --git a/devEcmcSup/motor/ecmcMotorRecordAxis.cpp b/devEcmcSup/motor/ecmcMotorRecordAxis.cpp index f3ad04e4..60a44ecb 100644 --- a/devEcmcSup/motor/ecmcMotorRecordAxis.cpp +++ b/devEcmcSup/motor/ecmcMotorRecordAxis.cpp @@ -675,25 +675,10 @@ asynStatus ecmcMotorRecordAxis::setPosition(double value) drvlocal.eeAxisWarning = eeAxisWarningNoWarning; - // Read from records / params - double homPos = 0.0; /* The homPos may be undefined, then use 0.0 */ - - // Home proc should always be 15 for this function (just set value) - //int cmdData = -1; - // nCmdData (sequence number) Must be "manual cmddata (=15)" - // asynStatus status = pC_->getIntegerParam(axisNo_, pC_->ecmcMotorRecordHomProc_,&cmdData); - // if (cmdData != ECMC_SEQ_HOME_SET_POS || status != asynSuccess) { - // return asynError; - // } - - // Home position - (void)pC_->getDoubleParam(axisNo_, pC_->ecmcMotorRecordHomPos_, &homPos); - - // always use home sequence 15 for setPosition if(ecmcRTMutex) epicsMutexLock(ecmcRTMutex); - int errorCode = drvlocal.ecmcAxis->moveHome(ECMC_SEQ_HOME_SET_POS, - homPos,0,0,0,0); + int errorCode = drvlocal.ecmcAxis->setPosition(value); if(ecmcRTMutex) epicsMutexUnlock(ecmcRTMutex); + return errorCode == 0 ? asynSuccess:asynError; } From e68fe763abec91585cf93c4781d17f5eb7e760ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Sandstr=C3=B6m?= Date: Tue, 18 Aug 2020 20:43:26 +0200 Subject: [PATCH 2/9] Sequencer: update traj velo. --- devEcmcSup/motion/ecmcAxisSequencer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/devEcmcSup/motion/ecmcAxisSequencer.cpp b/devEcmcSup/motion/ecmcAxisSequencer.cpp index d0c0b94c..3bfe557b 100644 --- a/devEcmcSup/motion/ecmcAxisSequencer.cpp +++ b/devEcmcSup/motion/ecmcAxisSequencer.cpp @@ -241,6 +241,7 @@ void ecmcAxisSequencer::execute() { } int ecmcAxisSequencer::setExecute(bool execute) { + int errorCode=0; if (traj_ == NULL) { return setErrorID(__FILE__, __FUNCTION__, __LINE__, ERROR_SEQ_TRAJ_NULL); @@ -521,6 +522,7 @@ double ecmcAxisSequencer::getTargetPos() { void ecmcAxisSequencer::setTargetVel(double velTarget) { data_->command_.velocityTarget = velTarget; + traj_->setTargetVel(velTarget); } double ecmcAxisSequencer::getTargetVel() { From abc6d4fb264fd1101b09de2ab2a7d90649a6b233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Sandstr=C3=B6m?= Date: Tue, 18 Aug 2020 20:44:32 +0200 Subject: [PATCH 3/9] Movevelo: Alow update of target velocity if already moving velo. --- devEcmcSup/motion/ecmcAxisBase.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/devEcmcSup/motion/ecmcAxisBase.cpp b/devEcmcSup/motion/ecmcAxisBase.cpp index 1605620c..42064574 100644 --- a/devEcmcSup/motion/ecmcAxisBase.cpp +++ b/devEcmcSup/motion/ecmcAxisBase.cpp @@ -1377,6 +1377,14 @@ int ecmcAxisBase::moveVelocity( return errorCode; } + // check if already moveVelo then just update vel and acc + if(getExecute() && getCommand() == ECMC_CMD_MOVEVEL) { + getSeq()->setTargetVel(velocitySet); + getTraj()->setAcc(accelerationSet); + getTraj()->setDec(decelerationSet); + return 0; + } + errorCode = setExecute(0); if (errorCode) { return errorCode; From a383f3a0b4fcba62f96fa2b7f5e5ec612b4bacd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Sandstr=C3=B6m?= Date: Tue, 18 Aug 2020 22:31:32 +0200 Subject: [PATCH 4/9] ecmcTrajectoryTrapetz.cpp: Allow JVEL change when in moveVelo --- devEcmcSup/motion/ecmcTrajectoryTrapetz.cpp | 25 +++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/devEcmcSup/motion/ecmcTrajectoryTrapetz.cpp b/devEcmcSup/motion/ecmcTrajectoryTrapetz.cpp index e792e7a2..eee35f37 100644 --- a/devEcmcSup/motion/ecmcTrajectoryTrapetz.cpp +++ b/devEcmcSup/motion/ecmcTrajectoryTrapetz.cpp @@ -212,14 +212,21 @@ double ecmcTrajectoryTrapetz::moveVel(double currSetpoint, *trajBusy = true; - if (std::abs(currVelo) < std::abs(targetVelo)) { - positionStep = std::abs(prevStepSize_) + stepACC_; + if(std::abs(prevStepSize_) > stepNOM_) { + positionStep = std::abs(prevStepSize_) - stepDEC_; + if(positionStep < stepNOM_) { + positionStep = stepNOM_; + } } else { - positionStep = stepNOM_; - } - - if(positionStep > stepNOM_) { - positionStep = stepNOM_; + if(std::abs(prevStepSize_) < stepNOM_) { + positionStep = std::abs(prevStepSize_) + stepACC_; + if(positionStep > stepNOM_) { + positionStep = stepNOM_; + } + } + else { + positionStep = stepNOM_; + } } if (setDirection_ == ECMC_DIR_FORWARD) { @@ -257,7 +264,7 @@ double ecmcTrajectoryTrapetz::movePos(double currSetpoint, } else { positionStep = stepNOM_; } - } else { + } else { //Stopping positionStep = std::abs(prevStepSize_) - stepDEC_; } @@ -659,4 +666,4 @@ double ecmcTrajectoryTrapetz::checkModuloPos(double pos, } return posSetTemp; -} \ No newline at end of file +} From 2458773243b35295b9ea478345ee1f27768e8544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Sandstr=C3=B6m?= Date: Tue, 18 Aug 2020 22:42:24 +0200 Subject: [PATCH 5/9] ecmcTrajectoryTrapetz.cpp: Current velo setpoint calc fix. --- devEcmcSup/motion/ecmcTrajectoryTrapetz.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/devEcmcSup/motion/ecmcTrajectoryTrapetz.cpp b/devEcmcSup/motion/ecmcTrajectoryTrapetz.cpp index eee35f37..537434c1 100644 --- a/devEcmcSup/motion/ecmcTrajectoryTrapetz.cpp +++ b/devEcmcSup/motion/ecmcTrajectoryTrapetz.cpp @@ -361,16 +361,6 @@ int ecmcTrajectoryTrapetz::getIndex() { } double ecmcTrajectoryTrapetz::getVel() { - double absVelTarget = std::abs(velocityTarget_); - - if ((velocity_ >= absVelTarget) && (setDirection_ == ECMC_DIR_FORWARD)) { - return absVelTarget; - } - - if ((velocity_ <= -absVelTarget) && (setDirection_ == ECMC_DIR_BACKWARD)) { - return -absVelTarget; - } - return velocity_; } From ff60427af1640dc504d748017e8fa463c1853f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Sandstr=C3=B6m?= Date: Tue, 18 Aug 2020 22:51:40 +0200 Subject: [PATCH 6/9] ecmcTrajectoryTrapetz.cpp: Start deceleration earlier in positioning mode. --- devEcmcSup/motion/ecmcTrajectoryTrapetz.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/devEcmcSup/motion/ecmcTrajectoryTrapetz.cpp b/devEcmcSup/motion/ecmcTrajectoryTrapetz.cpp index 537434c1..a3a347b7 100644 --- a/devEcmcSup/motion/ecmcTrajectoryTrapetz.cpp +++ b/devEcmcSup/motion/ecmcTrajectoryTrapetz.cpp @@ -255,8 +255,8 @@ double ecmcTrajectoryTrapetz::movePos(double currSetpoint, double distToTargetOld = dist(currSetpoint,targetSetpoint,setDirection_); - stopping = stopDistance > std::abs(distToTargetOld); /*|| - changeDir;*/ + stopping = stopDistance >= std::abs(distToTargetOld) - std::abs(prevStepSize_); // compesate for this motion step + /*changeDir;*/ if (!stopping) { if (std::abs(currVelo) < std::abs(targetVelo)) { From fe9a51640e5dced5dbc3397fc608bc85ceff2190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Sandstr=C3=B6m?= Date: Tue, 18 Aug 2020 22:55:01 +0200 Subject: [PATCH 7/9] ecmcTrajectoryTrapetz.cpp: Minor cleanup. --- devEcmcSup/motion/ecmcTrajectoryTrapetz.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/devEcmcSup/motion/ecmcTrajectoryTrapetz.cpp b/devEcmcSup/motion/ecmcTrajectoryTrapetz.cpp index a3a347b7..4132b127 100644 --- a/devEcmcSup/motion/ecmcTrajectoryTrapetz.cpp +++ b/devEcmcSup/motion/ecmcTrajectoryTrapetz.cpp @@ -247,16 +247,12 @@ double ecmcTrajectoryTrapetz::movePos(double currSetpoint, double positionStep = 0; double posSetTemp = 0; bool stopping = false; - //bool changeDir = false; *trajBusy = true; - /*changeDir = - ((targetSetpoint - currSetpoint) * currVelo < 0 && std::abs(currVelo)) > 0;*/ double distToTargetOld = dist(currSetpoint,targetSetpoint,setDirection_); - stopping = stopDistance >= std::abs(distToTargetOld) - std::abs(prevStepSize_); // compesate for this motion step - /*changeDir;*/ + stopping = stopDistance >= std::abs(distToTargetOld) - std::abs(prevStepSize_); // compensate for this motion step if (!stopping) { if (std::abs(currVelo) < std::abs(targetVelo)) { From ad57b5de087c5f9adb33b581200faeb597b8598e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Sandstr=C3=B6m?= Date: Wed, 19 Aug 2020 11:05:41 +0200 Subject: [PATCH 8/9] ecmcAxisBase.cpp: Update so jog cmd resets execute at new jog cmd if interlocked. --- devEcmcSup/motion/ecmcAxisBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devEcmcSup/motion/ecmcAxisBase.cpp b/devEcmcSup/motion/ecmcAxisBase.cpp index 42064574..020c40a1 100644 --- a/devEcmcSup/motion/ecmcAxisBase.cpp +++ b/devEcmcSup/motion/ecmcAxisBase.cpp @@ -1378,7 +1378,7 @@ int ecmcAxisBase::moveVelocity( } // check if already moveVelo then just update vel and acc - if(getExecute() && getCommand() == ECMC_CMD_MOVEVEL) { + if(getExecute() && getCommand() == ECMC_CMD_MOVEVEL && getBusy()) { getSeq()->setTargetVel(velocitySet); getTraj()->setAcc(accelerationSet); getTraj()->setDec(decelerationSet); From 02d176d2a2cf84916fcdf8c692615edcfd980905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Sandstr=C3=B6m?= Date: Wed, 19 Aug 2020 11:12:59 +0200 Subject: [PATCH 9/9] Update RELEASE.md --- RELEASE.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/RELEASE.md b/RELEASE.md index 06d7391b..584b1ef6 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,5 +1,11 @@ Release Notes === + +# ECMC 6.2.2 +* Allow JVEL change while jogging +* Smoother trajectory at stopping (start stop seq. one cycle earlier than before to avoid small jerk at stop) +* Update to support autosave of motor position + # ECMC 6.2.1 * Add exprtk support for plc functions with stings as args (need ess-exprtk 1.2.1) * Add possabilty ti use plc-functions with strings a sarguments in plugins