From f92ed6f4fc7c8364ec3d4349394b48977148fc58 Mon Sep 17 00:00:00 2001 From: Kevin Peterson Date: Mon, 15 May 2023 11:04:01 -0500 Subject: [PATCH 1/3] Added a missing }, probably caused by merging --- modules/Makefile | 4 ++++ motorApp/MotorSrc/motorRecord.dbd | 1 + 2 files changed, 5 insertions(+) diff --git a/modules/Makefile b/modules/Makefile index 5c3054ac..13b5cdc5 100644 --- a/modules/Makefile +++ b/modules/Makefile @@ -85,6 +85,10 @@ ifdef LUA $(ECHO) Creating $@, LUA = $(LUA) @echo LUA = $(LUA)>> $@ endif +ifdef AUTOSAVE + $(ECHO) Creating $@, AUTOSAVE = $(AUTOSAVE) + @echo AUTOSAVE = $(AUTOSAVE)>> $@ +endif ifdef MODBUS $(ECHO) Creating $@, MODBUS = $(MODBUS) @echo MODBUS = $(MODBUS)>> $@ diff --git a/motorApp/MotorSrc/motorRecord.dbd b/motorApp/MotorSrc/motorRecord.dbd index 4877b2cd..ba8cdb38 100644 --- a/motorApp/MotorSrc/motorRecord.dbd +++ b/motorApp/MotorSrc/motorRecord.dbd @@ -73,6 +73,7 @@ menu(motorRSTM) { choice(motorRSTM_Always, "Always") choice(motorRSTM_NearZero, "NearZero") choice(motorRSTM_Conditional, "Conditional") +} menu(motorACCSused) { choice(motorACCSused_Undef,"Undef") choice(motorACCSused_Accl, "Accl") From 63bfe5d07772096d3d8a25c486494b5ac2468764 Mon Sep 17 00:00:00 2001 From: Kevin Peterson Date: Thu, 18 May 2023 15:32:42 -0500 Subject: [PATCH 2/3] Changed ACCU from a readback to a control. ACCU can be optionally specified when motor databases are loaded and is autosaved by default. --- docs/motorRecord.html | 30 ++++++++++++++++++++-- motorApp/Db/asyn_motor.db | 1 + motorApp/Db/asyn_motor_model2.db | 1 + motorApp/Db/basic_asyn_motor.db | 1 + motorApp/Db/basic_asyn_motor_model2.db | 1 + motorApp/Db/basic_motor.db | 1 + motorApp/Db/basic_motor_settings.req | 1 + motorApp/Db/motor.db | 1 + motorApp/MotorSrc/motorRecord.cc | 35 +++++++------------------- motorApp/MotorSrc/motorRecord.dbd | 14 +++++------ 10 files changed, 51 insertions(+), 35 deletions(-) diff --git a/docs/motorRecord.html b/docs/motorRecord.html index 0bd14e2b..dd4d9367 100644 --- a/docs/motorRecord.html +++ b/docs/motorRecord.html @@ -272,6 +272,13 @@ below.
+ + ACCU + R/W + Acceleration used + RECCHOICE + (0:"Use ACCL", 1:"Use ACCS") + ADEL R/W @@ -1718,11 +1725,30 @@ below. motor motion. - The motor record expects the hardware to produce a trapezoidal + ACCS + R/W + Acceleration (EGU/s^2) + DOUBLE + Valid range; 0 <= ACCS + + + ACCU + R/W + Acceleration used + RECCHOICE + (0:"Use ACCL", 1:"Use ACCS")  This field determines whether the ACCL or ACCS field + is used in the calculation of the acceleration that is sent to device support. The field + that is not used changes with VELO. The default value is "Use ACCL"  + + + + The motor record expects the hardware to produce a trapezoidal speed profile. That is, the motor speed is expected to increase linearly with time from the base speed, VBAS, to the full speed, VELO, in ACCL seconds. At the end of a motion, the speed is expected to decrease similarly to VBAS. - Note that the ACCS field can be use to specify the acceleration in EGU/s^2.  +

Note that the ACCS field can be use to specify the acceleration in EGU/s^2.

+

Velocity and acceleration are related by the following equation:
+ VELO - VBAS = ACCL * ACCS  

JVEL diff --git a/motorApp/Db/asyn_motor.db b/motorApp/Db/asyn_motor.db index e7089228..fefe379f 100644 --- a/motorApp/Db/asyn_motor.db +++ b/motorApp/Db/asyn_motor.db @@ -10,6 +10,7 @@ record(motor, "$(P)$(M)") { field(VELO, "$(VELO)") field(VBAS, "$(VBAS)") field(ACCL, "$(ACCL)") + field(ACCU, "$(ACCU=0)") field(BDST, "$(BDST)") field(BVEL, "$(BVEL)") field(BACC, "$(BACC)") diff --git a/motorApp/Db/asyn_motor_model2.db b/motorApp/Db/asyn_motor_model2.db index 7cd664f4..3fa391a5 100644 --- a/motorApp/Db/asyn_motor_model2.db +++ b/motorApp/Db/asyn_motor_model2.db @@ -10,6 +10,7 @@ record(motor, "$(P)$(M)") { field(VELO, "$(VELO)") field(VBAS, "$(VBAS)") field(ACCL, "$(ACCL)") + field(ACCU, "$(ACCU=0)") field(BDST, "$(BDST)") field(BVEL, "$(BVEL)") field(BACC, "$(BACC)") diff --git a/motorApp/Db/basic_asyn_motor.db b/motorApp/Db/basic_asyn_motor.db index a1859804..b678741b 100644 --- a/motorApp/Db/basic_asyn_motor.db +++ b/motorApp/Db/basic_asyn_motor.db @@ -6,6 +6,7 @@ record(motor,"$(P)$(M)") field(VELO,"$(VELO)") field(VBAS,"$(VBAS)") field(ACCL,"$(ACCL)") + field(ACCU,"$(ACCU=0)") field(BDST,"$(BDST)") field(BVEL,"$(BVEL)") field(BACC,"$(BACC)") diff --git a/motorApp/Db/basic_asyn_motor_model2.db b/motorApp/Db/basic_asyn_motor_model2.db index 84dba5ce..84e7c1fe 100644 --- a/motorApp/Db/basic_asyn_motor_model2.db +++ b/motorApp/Db/basic_asyn_motor_model2.db @@ -6,6 +6,7 @@ record(motor,"$(P)$(M)") field(VELO,"$(VELO)") field(VBAS,"$(VBAS)") field(ACCL,"$(ACCL)") + field(ACCU,"$(ACCU=0)") field(BDST,"$(BDST)") field(BVEL,"$(BVEL)") field(BACC,"$(BACC)") diff --git a/motorApp/Db/basic_motor.db b/motorApp/Db/basic_motor.db index 98e55ec9..87c70bea 100644 --- a/motorApp/Db/basic_motor.db +++ b/motorApp/Db/basic_motor.db @@ -6,6 +6,7 @@ grecord(motor,"$(P)$(M)") field(VELO,"$(VELO)") field(VBAS,"$(VBAS)") field(ACCL,"$(ACCL)") + field(ACCU,"$(ACCU=0)") field(BDST,"$(BDST)") field(BVEL,"$(BVEL)") field(BACC,"$(BACC)") diff --git a/motorApp/Db/basic_motor_settings.req b/motorApp/Db/basic_motor_settings.req index 5e3eb551..9072214a 100644 --- a/motorApp/Db/basic_motor_settings.req +++ b/motorApp/Db/basic_motor_settings.req @@ -11,6 +11,7 @@ $(P)$(M).RRES $(P)$(M).VBAS $(P)$(M).VELO $(P)$(M).ACCL +$(P)$(M).ACCU $(P)$(M).BDST $(P)$(M).BVEL $(P)$(M).BACC diff --git a/motorApp/Db/motor.db b/motorApp/Db/motor.db index 3b6c0e5d..7b5b4712 100644 --- a/motorApp/Db/motor.db +++ b/motorApp/Db/motor.db @@ -10,6 +10,7 @@ record(motor, "$(P)$(M)") { field(VELO, "$(VELO)") field(VBAS, "$(VBAS)") field(ACCL, "$(ACCL)") + field(ACCU, "$(ACCU=0)") field(BDST, "$(BDST)") field(BVEL, "$(BVEL)") field(BACC, "$(BACC)") diff --git a/motorApp/MotorSrc/motorRecord.cc b/motorApp/MotorSrc/motorRecord.cc index 4fb5ee4f..cf98e10b 100644 --- a/motorApp/MotorSrc/motorRecord.cc +++ b/motorApp/MotorSrc/motorRecord.cc @@ -486,7 +486,7 @@ static double accEGUfromVelo(motorRecord *pmr, double veloEGU) double vmax = fabs(veloEGU); double acc; /* ACCL or ACCS */ - if (pmr->accu == motorACCSused_Accs) + if (pmr->accu == motorACCU_Accs) acc = pmr->accs; else if (vmax > vmin) acc = (vmax - vmin) / pmr->accl; @@ -498,14 +498,9 @@ static double accEGUfromVelo(motorRecord *pmr, double veloEGU) static void updateACCLfromACCS(motorRecord *pmr) { - if (pmr->accu != motorACCSused_Accs) - { - pmr->accu = motorACCSused_Accs; - db_post_events(pmr, &pmr->accu, DBE_VAL_LOG); - } if (pmr->accs > 0.0) { - double temp_dbl = pmr->velo / pmr->accs; + double temp_dbl = (pmr->velo > pmr->vbas) ? (pmr->velo - pmr->vbas) / pmr->accs : pmr->velo / pmr->accs; if (pmr->accl != temp_dbl) { pmr->accl = temp_dbl; @@ -517,12 +512,7 @@ static void updateACCLfromACCS(motorRecord *pmr) static void updateACCSfromACCL(motorRecord *pmr) { double temp_dbl; - if (pmr->accu != motorACCSused_Accl) - { - pmr->accu = motorACCSused_Accl; - db_post_events(pmr, &pmr->accu, DBE_VAL_LOG); - } - temp_dbl = pmr->velo / pmr->accl; + temp_dbl = (pmr->velo > pmr->vbas) ? (pmr->velo - pmr->vbas) / pmr->accl : pmr->velo / pmr->accl; if (pmr->accs != temp_dbl) { pmr->accs = temp_dbl; @@ -532,11 +522,11 @@ static void updateACCSfromACCL(motorRecord *pmr) static void updateACCL_ACCSfromVELO(motorRecord *pmr) { - if (pmr->accu == motorACCSused_Accs) + if (pmr->accu == motorACCU_Accs) { if (pmr->accs > 0.0) { - double temp_dbl = pmr->velo / pmr->accs; + double temp_dbl = (pmr->velo > pmr->vbas) ? (pmr->velo - pmr->vbas) / pmr->accs : pmr->velo / pmr->accs; if (pmr->accl != temp_dbl) { pmr->accl = temp_dbl; @@ -546,7 +536,7 @@ static void updateACCL_ACCSfromVELO(motorRecord *pmr) } else { - double temp_dbl = pmr->velo / pmr->accl; + double temp_dbl = (pmr->velo > pmr->vbas) ? (pmr->velo - pmr->vbas) / pmr->accl : pmr->velo / pmr->accl; if (pmr->accs != temp_dbl) { pmr->accs = temp_dbl; @@ -3984,14 +3974,6 @@ static void check_speed_and_resolution(motorRecord * pmr) db_post_events(pmr, &pmr->sbak, DBE_VAL_LOG); db_post_events(pmr, &pmr->bvel, DBE_VAL_LOG); - if (pmr->accs && !pmr->accl) - { - /* ACCL == 0.0, ACCS is != 0.0 -> Use ACCS - This is a (possible) new way to configure a database. - Existing Db files will have ACCS == 0.0 and this - is backwards compatible and behaves as before */ - updateACCLfromACCS(pmr); - } /* Sanity check on acceleration time. */ if (pmr->accl == 0.0) { @@ -4017,8 +3999,9 @@ static void check_speed_and_resolution(motorRecord * pmr) pmr->hvel = pmr->vbas; else range_check(pmr, &pmr->hvel, pmr->vbas, pmr->vmax); - /* Make sure that ACCS/ACCU are initialized */ - if (pmr->accu == motorACCSused_Undef) + + /* Make sure that ACCS is initialized */ + if (pmr->accs == 0.0) { updateACCSfromACCL(pmr); } diff --git a/motorApp/MotorSrc/motorRecord.dbd b/motorApp/MotorSrc/motorRecord.dbd index ba8cdb38..b112dda3 100644 --- a/motorApp/MotorSrc/motorRecord.dbd +++ b/motorApp/MotorSrc/motorRecord.dbd @@ -74,10 +74,9 @@ menu(motorRSTM) { choice(motorRSTM_NearZero, "NearZero") choice(motorRSTM_Conditional, "Conditional") } -menu(motorACCSused) { - choice(motorACCSused_Undef,"Undef") - choice(motorACCSused_Accl, "Accl") - choice(motorACCSused_Accs, "Accs") +menu(motorACCU) { + choice(motorACCU_Accl, "Use ACCL") + choice(motorACCU_Accs, "Use ACCS") } include "menuOmsl.dbd" @@ -191,9 +190,10 @@ recordtype(motor) { interest(1) } field(ACCU,DBF_MENU) { - prompt("ACCS used") - special(SPC_NOMOD) - menu(motorACCSused) + prompt("Acceleration used") + special(SPC_MOD) + menu(motorACCU) + initial("0") } field(BDST,DBF_DOUBLE) { prompt("BL Distance (EGU)") From 7291b5569be4084831fca363673acb5a9d59ac2b Mon Sep 17 00:00:00 2001 From: Kevin Peterson Date: Fri, 19 May 2023 15:50:09 -0500 Subject: [PATCH 3/3] Improved ACCS initialization. Update ACCS or ACCL (determined by ACCU) when VBAS (or SBAS) changes. --- motorApp/MotorSrc/motorRecord.cc | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/motorApp/MotorSrc/motorRecord.cc b/motorApp/MotorSrc/motorRecord.cc index cf98e10b..58fd459c 100644 --- a/motorApp/MotorSrc/motorRecord.cc +++ b/motorApp/MotorSrc/motorRecord.cc @@ -2629,6 +2629,7 @@ static long special(DBADDR *paddr, int after) pmr->sbas = temp_dbl; db_post_events(pmr, &pmr->sbas, DBE_VAL_LOG); } + updateACCL_ACCSfromVELO(pmr); break; /* new sbas: make vbas agree */ @@ -2644,6 +2645,7 @@ static long special(DBADDR *paddr, int after) pmr->vbas = temp_dbl; db_post_events(pmr, &pmr->vbas, DBE_VAL_LOG); } + updateACCL_ACCSfromVELO(pmr); break; /* new vmax: make smax agree */ @@ -2734,7 +2736,11 @@ static long special(DBADDR *paddr, int after) /* new accs */ case motorRecordACCS: - db_post_events(pmr, &pmr->accs, DBE_VAL_LOG); + if (pmr->accs <= 0.0) + { + updateACCSfromACCL(pmr); + } + //db_post_events(pmr, &pmr->accs, DBE_VAL_LOG); updateACCLfromACCS(pmr); break; @@ -3974,12 +3980,22 @@ static void check_speed_and_resolution(motorRecord * pmr) db_post_events(pmr, &pmr->sbak, DBE_VAL_LOG); db_post_events(pmr, &pmr->bvel, DBE_VAL_LOG); - /* Sanity check on acceleration time. */ - if (pmr->accl == 0.0) + /* ACCS (EGU/sec^2) <--> ACCL (sec) */ + if (pmr->accs > 0.0) { - pmr->accl = 0.1; - db_post_events(pmr, &pmr->accl, DBE_VAL_LOG); + updateACCLfromACCS(pmr); } + else + { + /* Sanity check on acceleration time. */ + if (pmr->accl == 0.0) + { + pmr->accl = 0.1; + db_post_events(pmr, &pmr->accl, DBE_VAL_LOG); + } + updateACCSfromACCL(pmr); + } + /* Sanity check on backlash acceleration time. */ if (pmr->bacc == 0.0) { pmr->bacc = 0.1; @@ -3999,12 +4015,6 @@ static void check_speed_and_resolution(motorRecord * pmr) pmr->hvel = pmr->vbas; else range_check(pmr, &pmr->hvel, pmr->vbas, pmr->vmax); - - /* Make sure that ACCS is initialized */ - if (pmr->accs == 0.0) - { - updateACCSfromACCL(pmr); - } } /*