From ba71c79a92df33698fbadde06daa599d233eb768 Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Wed, 5 Jun 2024 14:34:59 -0500 Subject: [PATCH 1/9] Updated moveVelocity command for md90. --- dsmApp/src/MD90Driver.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index a0e5976..2099cf8 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -208,13 +208,14 @@ asynStatus MD90Axis::moveVelocity(double minVelocity, double maxVelocity, double status = sendAccelAndVelocity(acceleration, maxVelocity); - /* MD-90 does not have jog command. Move 1 million steps */ + /* MD-90 does not have jog command. Move max 6000 steps */ + sprintf(pC_->outString_, "SNS 6000"); if (maxVelocity > 0.) { /* This is a positive move in MD90 coordinates */ - sprintf(pC_->outString_, "#%02dI+1000000", axisNo_); + sprintf(pC_->outString_, "ESF"); } else { - /* This is a negative move in MD90 coordinates */ - sprintf(pC_->outString_, "#%02dI-1000000", axisNo_); + /* This is a negative move in MD90 coordinates */ + sprintf(pC_->outString_, "ESB"); } status = pC_->writeReadController(); return status; From 273e545759001204f40e4bf47d4f36e6a51a66b2 Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Wed, 5 Jun 2024 14:39:35 -0500 Subject: [PATCH 2/9] Added missing call to writeReadController to set max jog steps. --- dsmApp/src/MD90Driver.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index 2099cf8..c08f0c5 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -210,6 +210,7 @@ asynStatus MD90Axis::moveVelocity(double minVelocity, double maxVelocity, double /* MD-90 does not have jog command. Move max 6000 steps */ sprintf(pC_->outString_, "SNS 6000"); + status = pC_->writeReadController(); if (maxVelocity > 0.) { /* This is a positive move in MD90 coordinates */ sprintf(pC_->outString_, "ESF"); From b8b090a804f4e4b519271d2425e6f6cdcf128741 Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Wed, 5 Jun 2024 14:50:52 -0500 Subject: [PATCH 3/9] Removed setPosition method as not supported by md90. --- dsmApp/src/MD90Driver.cpp | 10 ---------- dsmApp/src/MD90Driver.h | 1 - 2 files changed, 11 deletions(-) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index c08f0c5..2b7529d 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -232,16 +232,6 @@ asynStatus MD90Axis::stop(double acceleration ) return status; } -asynStatus MD90Axis::setPosition(double position) -{ - asynStatus status; - //static const char *functionName = "MD90Axis::setPosition"; - - sprintf(pC_->outString_, "#%02dP=%+d", axisNo_, NINT(position)); - status = pC_->writeReadController(); - return status; -} - asynStatus MD90Axis::setClosedLoop(bool closedLoop) { asynStatus status; diff --git a/dsmApp/src/MD90Driver.h b/dsmApp/src/MD90Driver.h index f98f3c2..28717cc 100644 --- a/dsmApp/src/MD90Driver.h +++ b/dsmApp/src/MD90Driver.h @@ -26,7 +26,6 @@ public: asynStatus home(double min_velocity, double max_velocity, double acceleration, int forwards); asynStatus stop(double acceleration); asynStatus poll(bool *moving); - asynStatus setPosition(double position); asynStatus setClosedLoop(bool closedLoop); private: From 71ae063b230513a777306ce4f2b14aa44f78885d Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Wed, 5 Jun 2024 15:32:14 -0500 Subject: [PATCH 4/9] Updated to use the setClosedLoop method to set persistent move. --- dsmApp/src/MD90Driver.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index 2b7529d..ec4f9ed 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -232,12 +232,18 @@ asynStatus MD90Axis::stop(double acceleration ) return status; } +/** The ACS driver used this to turn on/off the motor winding current, so + * we'll use this for enabling/disabling the persistent move state. */ asynStatus MD90Axis::setClosedLoop(bool closedLoop) { asynStatus status; //static const char *functionName = "MD90Axis::setClosedLoop"; - sprintf(pC_->outString_, "#%02dW=%d", axisNo_, closedLoop ? 1:0); + if (closedLoop == 1) { + sprintf(pC_->outString_, "EPM"); + } else { + sprintf(pC_->outString_, "DPM"); + } status = pC_->writeReadController(); return status; } From 341bbb5980faf9dfbeb4684b156ebacf22395049 Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Wed, 5 Jun 2024 15:38:57 -0500 Subject: [PATCH 5/9] Changed motor status from atHome to Homed when GHS returns 1. --- dsmApp/src/MD90Driver.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index ec4f9ed..52dc57a 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -261,7 +261,7 @@ asynStatus MD90Axis::poll(bool *moving) int replyValue; int done; int driveOn; - int home; + int homed; double position; asynStatus comStatus; @@ -330,8 +330,8 @@ asynStatus MD90Axis::poll(bool *moving) if (comStatus) goto skip; // The response string is of the form "0: Home status: 1" sscanf (pC_->inString_, "%d: %[^:]: %d", &replyStatus, replyString, &replyValue); - home = (replyValue == '1') ? 1:0; - setIntegerParam(pC_->motorStatusAtHome_, home); + homed = (replyValue == '1') ? 1:0; + setIntegerParam(pC_->motorStatusHomed_, homed); // Read the drive power on status sprintf(pC_->outString_, "GPS"); From c5eebd95972de822dc3045127b5f3e378361290a Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Wed, 5 Jun 2024 16:04:30 -0500 Subject: [PATCH 6/9] Added setIGain method. --- dsmApp/src/MD90Driver.cpp | 16 ++++++++++++++++ dsmApp/src/MD90Driver.h | 1 + 2 files changed, 17 insertions(+) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index 52dc57a..2e02278 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -248,6 +248,22 @@ asynStatus MD90Axis::setClosedLoop(bool closedLoop) return status; } +/** Set the I Gain of the motor control loop. The motor is an I- controller + * and has no P or D terms. + * \param[in] iGain The current I gain in the control loop */ +asynStatus MD90Axis::setIGain(double iGain) +{ + asynStatus status; + //static const char *functionName = "MD90Axis::setIGain"; + + iGain = iGain * 100; + if (iGain < 1) iGain = 1.0; + if (iGain > 100) iGain = 100.0; + sprintf(pC_->outString_, "SGN %d", NINT(iGain)); + status = pC_->writeReadController(); + return status; +} + /** Polls the axis. * This function reads the motor position, the limit status, the home status, the moving status, * and the drive power-on status. diff --git a/dsmApp/src/MD90Driver.h b/dsmApp/src/MD90Driver.h index 28717cc..5062b4f 100644 --- a/dsmApp/src/MD90Driver.h +++ b/dsmApp/src/MD90Driver.h @@ -27,6 +27,7 @@ public: asynStatus stop(double acceleration); asynStatus poll(bool *moving); asynStatus setClosedLoop(bool closedLoop); + asynStatus setIGain(double iGain); private: MD90Controller *pC_; /**< Pointer to the asynMotorController to which this axis belongs. From 402584345f82a128fa3ae366762828bc0b8fb664 Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Wed, 5 Jun 2024 16:14:40 -0500 Subject: [PATCH 7/9] Added doMoveToHome method. --- dsmApp/src/MD90Driver.cpp | 10 ++++++++++ dsmApp/src/MD90Driver.h | 1 + 2 files changed, 11 insertions(+) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index 2e02278..999cb23 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -264,6 +264,16 @@ asynStatus MD90Axis::setIGain(double iGain) return status; } +asynStatus MD90Axis::doMoveToHome() +{ + asynStatus status; + //static const char *functionName = "MD90Axis::doMoveToHome"; + + sprintf(pC_->outString_, "CLM 0"); + status = pC_->writeReadController(); + return status; +} + /** Polls the axis. * This function reads the motor position, the limit status, the home status, the moving status, * and the drive power-on status. diff --git a/dsmApp/src/MD90Driver.h b/dsmApp/src/MD90Driver.h index 5062b4f..12795ec 100644 --- a/dsmApp/src/MD90Driver.h +++ b/dsmApp/src/MD90Driver.h @@ -28,6 +28,7 @@ public: asynStatus poll(bool *moving); asynStatus setClosedLoop(bool closedLoop); asynStatus setIGain(double iGain); + asynStatus doMoveToHome(); private: MD90Controller *pC_; /**< Pointer to the asynMotorController to which this axis belongs. From 19467e5b5bab1ab5de951cd6cc7cbb703661f0fe Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Thu, 6 Jun 2024 14:20:47 -0500 Subject: [PATCH 8/9] Updated method to set velocity and removed acceleration. --- dsmApp/src/MD90Driver.cpp | 36 +++++++++---------- .../iocBoot/iocDsm/motor.substitutions.md90 | 4 +-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index 999cb23..b043323 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -140,29 +140,26 @@ void MD90Axis::report(FILE *fp, int level) asynMotorAxis::report(fp, level); } +/** Acceleration currently unsupported with MD-90 controller + * \param[in] acceleration The accelerations to ramp up to max velocity + * \param[in] velocity Motor velocity in steps / sec + */ asynStatus MD90Axis::sendAccelAndVelocity(double acceleration, double velocity) { asynStatus status; - int ival; + int freq; // static const char *functionName = "MD90::sendAccelAndVelocity"; // Send the velocity - ival = NINT(fabs(115200./velocity)); - if (ival < 2) ival=2; - if (ival > 255) ival = 255; - sprintf(pC_->outString_, "#%02dV=%d", axisNo_, ival); + // Velocity provided in steps/sec + // Our unit step size of the encoder is 10 nm, but the motor moves in steps approx. 5 micrometers. + // Motor controller accepts step frequency in Hz. + freq = NINT(fabs(velocity / 500.)); + if (freq < 5) freq=5; + if (freq > 125) freq = 125; + sprintf(pC_->outString_, "SSF %d", freq); status = pC_->writeReadController(); - // Send the acceleration - // acceleration is in steps/sec/sec - // MD-90 is programmed with Ramp Index (R) where: - // dval (steps/sec/sec) = 720,000/(256-R) */ - // or R=256-(720,000/dval) */ - ival = NINT(256-(720000./acceleration)); - if (ival < 1) ival=1; - if (ival > 255) ival=255; - sprintf(pC_->outString_, "#%02dR=%d", axisNo_, ival); - status = pC_->writeReadController(); return status; } @@ -233,7 +230,8 @@ asynStatus MD90Axis::stop(double acceleration ) } /** The ACS driver used this to turn on/off the motor winding current, so - * we'll use this for enabling/disabling the persistent move state. */ + * we'll use this for enabling/disabling the persistent move state. + */ asynStatus MD90Axis::setClosedLoop(bool closedLoop) { asynStatus status; @@ -250,7 +248,8 @@ asynStatus MD90Axis::setClosedLoop(bool closedLoop) /** Set the I Gain of the motor control loop. The motor is an I- controller * and has no P or D terms. - * \param[in] iGain The current I gain in the control loop */ + * \param[in] iGain The current I gain in the control loop + */ asynStatus MD90Axis::setIGain(double iGain) { asynStatus status; @@ -279,7 +278,8 @@ asynStatus MD90Axis::doMoveToHome() * and the drive power-on status. * It calls setIntegerParam() and setDoubleParam() for each item that it polls, * and then calls callParamCallbacks() at the end. - * \param[out] moving A flag that is set indicating that the axis is moving (true) or done (false). */ + * \param[out] moving A flag that is set indicating that the axis is moving (true) or done (false). + */ asynStatus MD90Axis::poll(bool *moving) { int replyStatus; diff --git a/iocs/dsmIOC/iocBoot/iocDsm/motor.substitutions.md90 b/iocs/dsmIOC/iocBoot/iocDsm/motor.substitutions.md90 index 40e4e4a..6c21e47 100644 --- a/iocs/dsmIOC/iocBoot/iocDsm/motor.substitutions.md90 +++ b/iocs/dsmIOC/iocBoot/iocDsm/motor.substitutions.md90 @@ -14,9 +14,9 @@ pattern # DESC Description # EGU Engineering units # DIR Direction -# VELO Velocity (EGU / s) +# VELO Velocity (EGU / s) (note: jog velocity set separately by JVEL) # VBAS Minimum velocity (EGU / s) -# VMAX Maximum velocity (EGU / s) (not getting set here with basic_asyn_motor.db) +# VMAX Maximum velocity (EGU / s) (note: not getting set here with basic_asyn_motor.db) # ACCL Acceleration (time in seconds until VELO) # BDST Backlash distance # MRES Motor step size (EGU) From 0d84bb4a2900108443e39f3eaca3c3b56d8056c3 Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Thu, 6 Jun 2024 14:27:15 -0500 Subject: [PATCH 9/9] Changed to max 1 axis. --- dsmApp/src/MD90Driver.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dsmApp/src/MD90Driver.h b/dsmApp/src/MD90Driver.h index 12795ec..45715d1 100644 --- a/dsmApp/src/MD90Driver.h +++ b/dsmApp/src/MD90Driver.h @@ -10,7 +10,7 @@ March 1, 2012 #include "asynMotorController.h" #include "asynMotorAxis.h" -#define MAX_MD90_AXES 4 +#define MAX_MD90_AXES 1 // No controller-specific parameters yet #define NUM_MD90_PARAMS 0