From 0ea2d9ec870d751480e4e15b83a33ed1f5c465ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Tue, 20 Nov 2018 08:51:49 +0100 Subject: [PATCH] Add field SPDB, "Set Point Dead Band" This is from Matthew Pearson, pearsonmr@ornl.gov A number of users and staff have requested that the motor record have a setpoint deadband field (eg. SPDB), which prevents any motion from happening if the readback position is within SPDB. Without a SPDB we have issues with motors moving unnecessarily. For example, if the RBV is 0.001 and we set VAL to 0.0, if we have a non-zero backlash correction then the motor will move unnecessarily to take out backlash. Even without backlash correction we often enable and disable the drive amplifier for no good reason. Currently the effective setpoint deadband is equal to MRES, but this is often too small to be an effective setpoint deadband. The new SPDB field would default to 0.0 The new code hooks into do_work(): When the new setpoint is within DPDB, set too_small and don't move. The new code does not use snipptes like "abs(npos - rpos)", these already produce warnings on 64 bit sytems. abs() is declared to work on int, but we feed long values. Simply compare the coordinates in engineering units. --- docs/motorRecord.html | 18 ++++++++++++++++++ motorApp/MotorSrc/motorRecord.cc | 12 ++++++++++++ motorApp/MotorSrc/motorRecord.dbd | 6 ++++++ 3 files changed, 36 insertions(+) diff --git a/docs/motorRecord.html b/docs/motorRecord.html index df4721b9..75ccf804 100644 --- a/docs/motorRecord.html +++ b/docs/motorRecord.html @@ -867,6 +867,14 @@ below.
+ + SPBD + R/W + Set Point Deadband (EGU) + DOUBLE +
+ + RDBL R @@ -1830,6 +1838,16 @@ below. performed (see RTRY).  + SPBD + R/W + Set Point Deadband (EGU) + DOUBLE + Before the motor is commanded a move, a check is done if the move is to small. + It is to small when the distance is less the the step size defined in MRES. + When a bigger deadband is wanted than MRES, set the value into SPDB. + + + RTRY R/W Max retry count diff --git a/motorApp/MotorSrc/motorRecord.cc b/motorApp/MotorSrc/motorRecord.cc index dd8cacb7..9fefca4b 100644 --- a/motorApp/MotorSrc/motorRecord.cc +++ b/motorApp/MotorSrc/motorRecord.cc @@ -2239,6 +2239,18 @@ static RTN_STATUS do_work(motorRecord * pmr, CALLBACK_VALUE proc_ind) { if (abs(npos - rpos) < 1) too_small = true; + if (!too_small) + { + double spdb = pmr->spdb; + if (spdb > 0) { + /* Don't move if new setpoint is within SPDB of DRBV */ + double drbv = pmr->drbv; + double dval = pmr->dval; + if (((dval - spdb) < drbv) && ((dval + spdb) > drbv)) { + too_small = true; + } + } + } } else if (abs(npos - rpos) < rdbdpos) too_small = true; diff --git a/motorApp/MotorSrc/motorRecord.dbd b/motorApp/MotorSrc/motorRecord.dbd index aa455cba..0e2d11c6 100644 --- a/motorApp/MotorSrc/motorRecord.dbd +++ b/motorApp/MotorSrc/motorRecord.dbd @@ -415,6 +415,12 @@ recordtype(motor) { special(SPC_MOD) interest(1) } + field(SPDB,DBF_DOUBLE) { + prompt("Setpoint Deadband (EGU)") + promptgroup(GUI_COMMON) + special(SPC_MOD) + interest(1) + } field(RCNT,DBF_SHORT) { prompt("Retry count") special(SPC_NOMOD)