From 07f07d16ad5ad3054ddb78fdbb9d814deeefd815 Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Thu, 23 May 2024 14:05:25 -0500 Subject: [PATCH 1/7] Updated to read md90 position. --- dsmApp/src/MD90Driver.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index 9a83b03..7ae10c1 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -260,6 +260,9 @@ asynStatus MD90Axis::setClosedLoop(bool closedLoop) * \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; + char replyString[256]; + double replyValue; int done; int driveOn; int limit; @@ -267,11 +270,12 @@ asynStatus MD90Axis::poll(bool *moving) asynStatus comStatus; // Read the current motor position - sprintf(pC_->outString_, "#%02dP", axisNo_); + sprintf(pC_->outString_, "GEE"); comStatus = pC_->writeReadController(); if (comStatus) goto skip; - // The response string is of the form "#01P=+1000" - position = atof(&pC_->inString_[5]); + // The response string is of the form "0: Current position in nanometers: 1000" + sscanf (pC_->inString_, "%d: %[^:]: %lf", &replyStatus, replyString, &replyValue); + position = replyValue; setDoubleParam(pC_->motorPosition_, position); // Read the moving status of this motor From a4d5388531b34096989c0d096900254155f889cb Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Thu, 23 May 2024 14:12:04 -0500 Subject: [PATCH 2/7] Updated to read md90 moving status. --- dsmApp/src/MD90Driver.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index 7ae10c1..24b363a 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -269,6 +269,8 @@ asynStatus MD90Axis::poll(bool *moving) double position; asynStatus comStatus; + // TODO: Will need to add some more error handling for the motor return codes. + // Read the current motor position sprintf(pC_->outString_, "GEE"); comStatus = pC_->writeReadController(); @@ -279,11 +281,12 @@ asynStatus MD90Axis::poll(bool *moving) setDoubleParam(pC_->motorPosition_, position); // Read the moving status of this motor - sprintf(pC_->outString_, "#%02dX", axisNo_); + sprintf(pC_->outString_, "STA"); comStatus = pC_->writeReadController(); if (comStatus) goto skip; - // The response string is of the form "#01X=1" - done = (pC_->inString_[5] == '0') ? 1:0; + // The response string is of the form "0: Current status value: 0" + sscanf (pC_->inString_, "%d: %[^:]: %lf", &replyStatus, replyString, &replyValue); + done = (replyValue == '2') ? 0:1; setIntegerParam(pC_->motorStatusDone_, done); *moving = done ? false:true; From 67eee854c0a640bd890012a0f4ddc6b332eaf23e Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Thu, 23 May 2024 14:19:43 -0500 Subject: [PATCH 3/7] Changed engineering units to encoder counts for get position. --- dsmApp/src/MD90Driver.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index 24b363a..064ccb9 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -272,10 +272,10 @@ asynStatus MD90Axis::poll(bool *moving) // TODO: Will need to add some more error handling for the motor return codes. // Read the current motor position - sprintf(pC_->outString_, "GEE"); + sprintf(pC_->outString_, "GEC"); comStatus = pC_->writeReadController(); if (comStatus) goto skip; - // The response string is of the form "0: Current position in nanometers: 1000" + // The response string is of the form "0: Current position in encoder counts: 1000" sscanf (pC_->inString_, "%d: %[^:]: %lf", &replyStatus, replyString, &replyValue); position = replyValue; setDoubleParam(pC_->motorPosition_, position); From 1205814767caca1fe5a7fd7133330f619fc8565e Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Thu, 23 May 2024 15:47:39 -0500 Subject: [PATCH 4/7] Updated to read md90 home status. --- dsmApp/src/MD90Driver.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index 064ccb9..c7e278d 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -265,7 +265,7 @@ asynStatus MD90Axis::poll(bool *moving) double replyValue; int done; int driveOn; - int limit; + int home; double position; asynStatus comStatus; @@ -290,17 +290,14 @@ asynStatus MD90Axis::poll(bool *moving) setIntegerParam(pC_->motorStatusDone_, done); *moving = done ? false:true; - // Read the limit status - sprintf(pC_->outString_, "#%02dE", axisNo_); + // Read the home status + sprintf(pC_->outString_, "GHS"); comStatus = pC_->writeReadController(); if (comStatus) goto skip; - // The response string is of the form "#01E=1" - limit = (pC_->inString_[5] == '1') ? 1:0; - setIntegerParam(pC_->motorStatusHighLimit_, limit); - limit = (pC_->inString_[6] == '1') ? 1:0; - setIntegerParam(pC_->motorStatusLowLimit_, limit); - limit = (pC_->inString_[7] == '1') ? 1:0; - setIntegerParam(pC_->motorStatusAtHome_, limit); + // The response string is of the form "0: Home status: 1" + sscanf (pC_->inString_, "%d: %[^:]: %lf", &replyStatus, replyString, &replyValue); + home = (replyValue == '1') ? 1:0; + setIntegerParam(pC_->motorStatusAtHome_, home); // Read the drive power on status sprintf(pC_->outString_, "#%02dW", axisNo_); From 0841ff3e1558b4a71f605ad500fd574eebf2e7a5 Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Thu, 23 May 2024 15:54:46 -0500 Subject: [PATCH 5/7] Fixed incorrectly reading ints as doubles. --- dsmApp/src/MD90Driver.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index c7e278d..87ef9de 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -262,7 +262,7 @@ asynStatus MD90Axis::poll(bool *moving) { int replyStatus; char replyString[256]; - double replyValue; + int replyValue; int done; int driveOn; int home; @@ -276,8 +276,7 @@ asynStatus MD90Axis::poll(bool *moving) comStatus = pC_->writeReadController(); if (comStatus) goto skip; // The response string is of the form "0: Current position in encoder counts: 1000" - sscanf (pC_->inString_, "%d: %[^:]: %lf", &replyStatus, replyString, &replyValue); - position = replyValue; + sscanf (pC_->inString_, "%d: %[^:]: %lf", &replyStatus, replyString, &position); setDoubleParam(pC_->motorPosition_, position); // Read the moving status of this motor @@ -285,7 +284,7 @@ asynStatus MD90Axis::poll(bool *moving) comStatus = pC_->writeReadController(); if (comStatus) goto skip; // The response string is of the form "0: Current status value: 0" - sscanf (pC_->inString_, "%d: %[^:]: %lf", &replyStatus, replyString, &replyValue); + sscanf (pC_->inString_, "%d: %[^:]: %d", &replyStatus, replyString, &replyValue); done = (replyValue == '2') ? 0:1; setIntegerParam(pC_->motorStatusDone_, done); *moving = done ? false:true; @@ -295,7 +294,7 @@ asynStatus MD90Axis::poll(bool *moving) comStatus = pC_->writeReadController(); if (comStatus) goto skip; // The response string is of the form "0: Home status: 1" - sscanf (pC_->inString_, "%d: %[^:]: %lf", &replyStatus, replyString, &replyValue); + sscanf (pC_->inString_, "%d: %[^:]: %d", &replyStatus, replyString, &replyValue); home = (replyValue == '1') ? 1:0; setIntegerParam(pC_->motorStatusAtHome_, home); From 0c32dd28eb2d503e0e0a67f7190091f64c625669 Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Thu, 23 May 2024 16:02:03 -0500 Subject: [PATCH 6/7] Updated to read md90 power state. --- dsmApp/src/MD90Driver.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index 87ef9de..36310c2 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -299,10 +299,12 @@ asynStatus MD90Axis::poll(bool *moving) setIntegerParam(pC_->motorStatusAtHome_, home); // Read the drive power on status - sprintf(pC_->outString_, "#%02dW", axisNo_); + sprintf(pC_->outString_, "GPS"); comStatus = pC_->writeReadController(); if (comStatus) goto skip; - driveOn = (pC_->inString_[5] == '1') ? 1:0; + // The response string is of the form "0: Power supply enabled state: 1" + sscanf (pC_->inString_, "%d: %[^:]: %d", &replyStatus, replyString, &replyValue); + driveOn = (replyValue == '1') ? 1:0; setIntegerParam(pC_->motorStatusPowerOn_, driveOn); setIntegerParam(pC_->motorStatusProblem_, 0); From 4837e8f597a9ed68fc9950dc37de17b2e847130e Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Thu, 23 May 2024 17:04:37 -0500 Subject: [PATCH 7/7] Added switch case table template for possible status codes. --- dsmApp/src/MD90Driver.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index 36310c2..522a6b4 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -288,6 +288,34 @@ asynStatus MD90Axis::poll(bool *moving) done = (replyValue == '2') ? 0:1; setIntegerParam(pC_->motorStatusDone_, done); *moving = done ? false:true; + switch(replyValue) { + case 0: // Idle + break; + case 1: // Open loop move complete + break; + case 2: // Move in progress + break; + case 3: // Move stopped + break; + case 4: // Homing error + break; + case 5: // Stance error + break; + case 6: // Stance complete + break; + case 7: // Open loop move error + break; + case 8: // Closed loop move error + break; + case 9: // Closed loop move complete + break; + case 10: // End of travel error + break; + case 11: // Ramp move error + break; + default: + break; + } // Read the home status sprintf(pC_->outString_, "GHS");