From e53a205927be6d154f362ecc01910c8beb99eb94 Mon Sep 17 00:00:00 2001 From: Jens Eden Date: Wed, 17 Dec 2014 16:31:53 +0000 Subject: [PATCH] avoid command error, if new velocity is less than previous base velocity or new base velocity is greater than previous velocity --- motorApp/OmsAsynSrc/omsBaseAxis.cpp | 23 +++++++++++++++++++---- motorApp/OmsAsynSrc/omsBaseAxis.h | 1 + 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/motorApp/OmsAsynSrc/omsBaseAxis.cpp b/motorApp/OmsAsynSrc/omsBaseAxis.cpp index 2ddf7b74..cc6d1377 100644 --- a/motorApp/OmsAsynSrc/omsBaseAxis.cpp +++ b/motorApp/OmsAsynSrc/omsBaseAxis.cpp @@ -31,6 +31,7 @@ omsBaseAxis::omsBaseAxis(omsBaseController *pController, int axis, char axisChar pC_ = pController; stepper = 1; invertLimit = 0; + lastminvelo = 0; } asynStatus omsBaseAxis::move(double position, int relative, double min_velocity, double max_velocity, double acceleration) @@ -75,7 +76,12 @@ asynStatus omsBaseAxis::move(double position, int relative, double min_velocity, acc = 1; /* move to the specified position */ - sprintf(buff, "A%1c AC%d; VB%d; VL%d; %s%d; GO ID", axisChar, acc, minvelo, velo, relabs[rela], pos); + if (velo < lastminvelo) + sprintf(buff, "A%1c;AC%d;VB%d;VL%d;%s%d;GO;ID;", axisChar, acc, minvelo, velo, relabs[rela], pos); + else + sprintf(buff, "A%1c;AC%d;VL%d;VB%d;%s%d;GO;ID;", axisChar, acc, velo, minvelo, relabs[rela], pos); + lastminvelo = minvelo; + status = pC_->sendOnlyLock(buff); asynPrint(pasynUser_, ASYN_TRACE_FLOW, @@ -92,7 +98,7 @@ asynStatus omsBaseAxis::home(double min_velocity, double max_velocity, double ac asynStatus status = asynError; char buff[60]; char *direction[2] = {(char*) "HR", (char*) "HM"}; - epicsInt32 velo, acc, fw = 0; + epicsInt32 minvelo, velo, acc, fw = 0; if (forwards) fw = 1; @@ -100,14 +106,23 @@ asynStatus omsBaseAxis::home(double min_velocity, double max_velocity, double ac if (velo < 1) velo = 1; else if (velo > 1000000) velo = 1000000; - acc = abs((epicsInt32) acceleration); + minvelo = (epicsInt32) (min_velocity + 0.5); + if (minvelo < 0) minvelo = 0; + else if (minvelo >= velo) minvelo = velo - 1; + + acc = abs((epicsInt32) acceleration); if (acc > 8000000) acc = 8000000; else if (acc < 1) acc = 1; /* do a home run and move to the home position */ - sprintf(buff, "A%1c AC%d; VL%d; %s; MA0 GO ID", axisChar, acc, velo, direction[forwards]); + if (velo < lastminvelo) + sprintf(buff, "A%1c;AC%d;VB%d;VL%d;%s;MA0;GO;ID;", axisChar, acc, minvelo, velo, direction[forwards]); + else + sprintf(buff, "A%1c;AC%d;VL%d;VB%d;%s;MA0;GO;ID;", axisChar, acc, velo, minvelo, direction[forwards]); + lastminvelo = minvelo; + status = pC_->sendOnlyLock(buff); homing = 1; diff --git a/motorApp/OmsAsynSrc/omsBaseAxis.h b/motorApp/OmsAsynSrc/omsBaseAxis.h index c8936abc..0f5dc6d1 100644 --- a/motorApp/OmsAsynSrc/omsBaseAxis.h +++ b/motorApp/OmsAsynSrc/omsBaseAxis.h @@ -48,6 +48,7 @@ private: omsBaseController *pC_; int stepper; int invertLimit; + epicsInt32 lastminvelo; friend class omsBaseController; };