From bf680d0c6f03a0ba36b4660dc39f3a6a0beb4eed Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Tue, 6 Aug 2024 12:30:38 -0500 Subject: [PATCH 1/3] Updated homing routine to set initial direction. --- dsmApp/src/MD90Driver.cpp | 27 +++++++++++++++++++++++++++ dsmApp/src/MD90Driver.h | 4 +++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index 4d56f56..7a9f860 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -12,6 +12,8 @@ March 1, 2012 #include #include #include +#include +#include #include #include @@ -219,11 +221,36 @@ asynStatus MD90Axis::move(double position, int relative, double minVelocity, dou asynStatus MD90Axis::home(double minVelocity, double maxVelocity, double acceleration, int forwards) { + int sleepTime; asynStatus status; static const char *functionName = "MD90Axis::home"; status = sendAccelAndVelocity(acceleration, maxVelocity); + // The MD-90 will start the home routine in the direction of the last move + // Here we first make a small move to set the desired direction before homing + + sprintf(pC_->outString_, "SNS %d", SMALL_NSTEPS); + status = pC_->writeReadController(); + if (!status) { + status = parseReply(functionName, pC_->inString_); + } + + if (forwards) { + sprintf(pC_->outString_, "ESF"); + } else { + sprintf(pC_->outString_, "ESB"); + } + status = pC_->writeReadController(); + if (!status) { + status = parseReply(functionName, pC_->inString_); + } + + // Wait for the move to complete, then home + + sleepTime = SLEEP_MARGIN * SMALL_NSTEPS * COUNTS_PER_STEP / maxVelocity; + std::this_thread::sleep_for(std::chrono::seconds(sleepTime)); + sprintf(pC_->outString_, "HOM"); status = pC_->writeReadController(); if (!status) { diff --git a/dsmApp/src/MD90Driver.h b/dsmApp/src/MD90Driver.h index b3b018e..6fb992a 100644 --- a/dsmApp/src/MD90Driver.h +++ b/dsmApp/src/MD90Driver.h @@ -12,7 +12,9 @@ USAGE... Motor driver support for the DSM MD-90 controller. // No controller-specific parameters yet #define NUM_MD90_PARAMS 0 -#define COUNTS_PER_STEP 1000.0 //Number of encoder counts per motor step (measured by testing) +#define SLEEP_MARGIN 1.2 // Extra factor to wait after stepping before homing +#define SMALL_NSTEPS 5 // Number of steps to take to set direction for homing routine +#define COUNTS_PER_STEP 1000.0 // Number of encoder counts per motor step (measured by testing) class epicsShareClass MD90Axis : public asynMotorAxis { From 5e36582ecc05768dd6d498fad23d797121ad8841 Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Tue, 6 Aug 2024 12:46:22 -0500 Subject: [PATCH 2/3] Added error status checking to home routine. --- dsmApp/src/MD90Driver.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index 7a9f860..e257d93 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -230,8 +230,10 @@ asynStatus MD90Axis::home(double minVelocity, double maxVelocity, double acceler // The MD-90 will start the home routine in the direction of the last move // Here we first make a small move to set the desired direction before homing - sprintf(pC_->outString_, "SNS %d", SMALL_NSTEPS); - status = pC_->writeReadController(); + if (!status) { + sprintf(pC_->outString_, "SNS %d", SMALL_NSTEPS); + status = pC_->writeReadController(); + } if (!status) { status = parseReply(functionName, pC_->inString_); } @@ -241,18 +243,21 @@ asynStatus MD90Axis::home(double minVelocity, double maxVelocity, double acceler } else { sprintf(pC_->outString_, "ESB"); } - status = pC_->writeReadController(); + if (!status) { + status = pC_->writeReadController(); + } if (!status) { status = parseReply(functionName, pC_->inString_); } - // Wait for the move to complete, then home + if (!status) { + // Wait for the move to complete, then home + sleepTime = SLEEP_MARGIN * SMALL_NSTEPS * COUNTS_PER_STEP / maxVelocity; + std::this_thread::sleep_for(std::chrono::seconds(sleepTime)); - sleepTime = SLEEP_MARGIN * SMALL_NSTEPS * COUNTS_PER_STEP / maxVelocity; - std::this_thread::sleep_for(std::chrono::seconds(sleepTime)); - - sprintf(pC_->outString_, "HOM"); - status = pC_->writeReadController(); + sprintf(pC_->outString_, "HOM"); + status = pC_->writeReadController(); + } if (!status) { status = parseReply(functionName, pC_->inString_); } From c6edb953a54e56e7a0c10833b99802d7f0affeac Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Tue, 6 Aug 2024 15:39:09 -0500 Subject: [PATCH 3/3] Updated multi-motor ioc config file with new velocities. --- iocs/dsmIOC/iocBoot/iocDsm/st.cmd.md90.multi | 24 +++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/iocs/dsmIOC/iocBoot/iocDsm/st.cmd.md90.multi b/iocs/dsmIOC/iocBoot/iocDsm/st.cmd.md90.multi index c2550f6..b14985f 100644 --- a/iocs/dsmIOC/iocBoot/iocDsm/st.cmd.md90.multi +++ b/iocs/dsmIOC/iocBoot/iocDsm/st.cmd.md90.multi @@ -147,32 +147,40 @@ iocInit # This IOC does not use save/restore, so set values of some PVs dbpf("DSM:m0.RTRY", "0") dbpf("DSM:m0.TWV", "0.1") -dbpf("DSM:m0.VMAX", "0.625") +dbpf("DSM:m0.VMAX", "1.0") +dbpf("DSM:m0.HVEL", "1.0") dbpf("DSM:m1.RTRY", "0") dbpf("DSM:m1.TWV", "0.1") -dbpf("DSM:m1.VMAX", "0.625") +dbpf("DSM:m1.VMAX", "1.0") +dbpf("DSM:m1.HVEL", "1.0") dbpf("DSM:m2.RTRY", "0") dbpf("DSM:m2.TWV", "0.1") -dbpf("DSM:m2.VMAX", "0.625") +dbpf("DSM:m2.VMAX", "1.0") +dbpf("DSM:m2.HVEL", "1.0") dbpf("DSM:m3.RTRY", "0") dbpf("DSM:m3.TWV", "0.1") -dbpf("DSM:m3.VMAX", "0.625") +dbpf("DSM:m3.VMAX", "1.0") +dbpf("DSM:m3.HVEL", "1.0") dbpf("DSM:m4.RTRY", "0") dbpf("DSM:m4.TWV", "0.1") -dbpf("DSM:m4.VMAX", "0.625") +dbpf("DSM:m4.VMAX", "1.0") +dbpf("DSM:m4.HVEL", "1.0") dbpf("DSM:m5.RTRY", "0") dbpf("DSM:m5.TWV", "0.1") -dbpf("DSM:m5.VMAX", "0.625") +dbpf("DSM:m5.VMAX", "1.0") +dbpf("DSM:m5.HVEL", "1.0") dbpf("DSM:m6.RTRY", "0") dbpf("DSM:m6.TWV", "0.1") -dbpf("DSM:m6.VMAX", "0.625") +dbpf("DSM:m6.VMAX", "1.0") +dbpf("DSM:m6.HVEL", "1.0") dbpf("DSM:m7.RTRY", "0") dbpf("DSM:m7.TWV", "0.1") -dbpf("DSM:m7.VMAX", "0.625") +dbpf("DSM:m7.VMAX", "1.0") +dbpf("DSM:m7.HVEL", "1.0")