Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some fixes #25

Merged
merged 12 commits into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
39 changes: 39 additions & 0 deletions devEcmcSup/motion/ecmcAxisBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 && getBusy()) {
getSeq()->setTargetVel(velocitySet);
getTraj()->setAcc(accelerationSet);
getTraj()->setDec(decelerationSet);
return 0;
}

errorCode = setExecute(0);
if (errorCode) {
return errorCode;
Expand Down Expand Up @@ -1442,6 +1450,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);
Expand Down
1 change: 1 addition & 0 deletions devEcmcSup/motion/ecmcAxisBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ class ecmcAxisBase : public ecmcError {
double velocityOffCamSet,
double accelerationSet,
double decelerationSet);
int setPosition(double homePositionSet); // Autosave
int stopMotion(int killAmplifier);

protected:
Expand Down
8 changes: 5 additions & 3 deletions devEcmcSup/motion/ecmcAxisSequencer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -521,6 +522,7 @@ double ecmcAxisSequencer::getTargetPos() {

void ecmcAxisSequencer::setTargetVel(double velTarget) {
data_->command_.velocityTarget = velTarget;
traj_->setTargetVel(velTarget);
}

double ecmcAxisSequencer::getTargetVel() {
Expand Down Expand Up @@ -2100,7 +2102,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__,
Expand All @@ -2123,15 +2125,15 @@ 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__,
ERROR_SEQ_ERROR_ACCELERATION_ZERO);
}

// 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__,
Expand Down
16 changes: 16 additions & 0 deletions devEcmcSup/motion/ecmcMotion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions devEcmcSup/motion/ecmcMotion.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 17 additions & 24 deletions devEcmcSup/motion/ecmcTrajectoryTrapetz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -240,24 +247,20 @@ 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); /*||
changeDir;*/
stopping = stopDistance >= std::abs(distToTargetOld) - std::abs(prevStepSize_); // compensate for this motion step

if (!stopping) {
if (std::abs(currVelo) < std::abs(targetVelo)) {
positionStep = std::abs(prevStepSize_) + stepACC_;
} else {
positionStep = stepNOM_;
}
} else {
} else { //Stopping
positionStep = std::abs(prevStepSize_) - stepDEC_;
}

Expand Down Expand Up @@ -354,16 +357,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_;
}

Expand Down Expand Up @@ -659,4 +652,4 @@ double ecmcTrajectoryTrapetz::checkModuloPos(double pos,
}

return posSetTemp;
}
}
19 changes: 2 additions & 17 deletions devEcmcSup/motor/ecmcMotorRecordAxis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down