From 4ab244925dbd429c4e442b74551ec17e3538de37 Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Fri, 21 Jun 2024 14:18:49 -0500 Subject: [PATCH 1/8] Updated serial port to USB adapter. --- iocs/dsmIOC/iocBoot/iocDsm/st.cmd.md90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iocs/dsmIOC/iocBoot/iocDsm/st.cmd.md90 b/iocs/dsmIOC/iocBoot/iocDsm/st.cmd.md90 index 28be557..3a8a2a4 100644 --- a/iocs/dsmIOC/iocBoot/iocDsm/st.cmd.md90 +++ b/iocs/dsmIOC/iocBoot/iocDsm/st.cmd.md90 @@ -8,7 +8,7 @@ dsm_registerRecordDeviceDriver(pdbbase) # Network device #!drvAsynIPPortConfigure("serial0", "192.168.1.16:4002",0,0,0) # Local serial port -#!drvAsynSerialPortConfigure("serial0", "/dev/ttyS0", 0, 0, 0) +#!drvAsynSerialPortConfigure("serial0", "/dev/ttyUSB0", 0, 0, 0) drvAsynSerialPortConfigure("serial0", "/tmp/motorport", 0, 0, 0) asynSetOption("serial0", 0, "baud", "115200") asynSetOption("serial0", 0, "bits", "8") From 8c053dfa624d5b65f34a6d80129f19ffb344fae2 Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Fri, 21 Jun 2024 14:53:50 -0500 Subject: [PATCH 2/8] Reordered status polling commands. --- dsmApp/src/MD90Driver.cpp | 42 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index b043323..bedc801 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -293,13 +293,24 @@ asynStatus MD90Axis::poll(bool *moving) // TODO: Will need to add some more error handling for the motor return codes. - // Read the current motor position in encoder steps (10 nm) - sprintf(pC_->outString_, "GEC"); + // Read the drive power on status + sprintf(pC_->outString_, "GPS"); 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, &position); - setDoubleParam(pC_->motorPosition_, position); + // 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); + + // Read the home status + sprintf(pC_->outString_, "GHS"); + comStatus = pC_->writeReadController(); + if (comStatus) goto skip; + // The response string is of the form "0: Home status: 1" + sscanf (pC_->inString_, "%d: %[^:]: %d", &replyStatus, replyString, &replyValue); + homed = (replyValue == '1') ? 1:0; + setIntegerParam(pC_->motorStatusHomed_, homed); // Read the moving status of this motor sprintf(pC_->outString_, "STA"); @@ -350,24 +361,13 @@ asynStatus MD90Axis::poll(bool *moving) break; } - // Read the home status - sprintf(pC_->outString_, "GHS"); + // Read the current motor position in encoder steps (10 nm) + sprintf(pC_->outString_, "GEC"); comStatus = pC_->writeReadController(); if (comStatus) goto skip; - // The response string is of the form "0: Home status: 1" - sscanf (pC_->inString_, "%d: %[^:]: %d", &replyStatus, replyString, &replyValue); - homed = (replyValue == '1') ? 1:0; - setIntegerParam(pC_->motorStatusHomed_, homed); - - // Read the drive power on status - sprintf(pC_->outString_, "GPS"); - comStatus = pC_->writeReadController(); - if (comStatus) goto skip; - // 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); + // The response string is of the form "0: Current position in encoder counts: 1000" + sscanf (pC_->inString_, "%d: %[^:]: %lf", &replyStatus, replyString, &position); + setDoubleParam(pC_->motorPosition_, position); skip: setIntegerParam(pC_->motorStatusProblem_, comStatus ? 1:0); From 37d22e58ddd86aca6cef5b3ac7302d06c9330634 Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Fri, 21 Jun 2024 14:56:48 -0500 Subject: [PATCH 3/8] Removed step frequency limits. --- dsmApp/src/MD90Driver.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index bedc801..21be12f 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -155,8 +155,6 @@ asynStatus MD90Axis::sendAccelAndVelocity(double acceleration, double velocity) // 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(); From df98f6667ab5cb79a7b3e74ea6bb155d3cad1e2f Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Fri, 21 Jun 2024 15:30:00 -0500 Subject: [PATCH 4/8] Changed iGain range from 1-100 to 1-1000. --- 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 21be12f..aba0b70 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -253,9 +253,9 @@ asynStatus MD90Axis::setIGain(double iGain) asynStatus status; //static const char *functionName = "MD90Axis::setIGain"; - iGain = iGain * 100; + iGain = iGain * 1000; if (iGain < 1) iGain = 1.0; - if (iGain > 100) iGain = 100.0; + if (iGain > 1000) iGain = 1000.0; sprintf(pC_->outString_, "SGN %d", NINT(iGain)); status = pC_->writeReadController(); return status; From c930a778111d4603a5188bde2103debf1c6bcb2c Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Fri, 21 Jun 2024 15:37:33 -0500 Subject: [PATCH 5/8] Added gain checking to the poll method. --- dsmApp/src/MD90Driver.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index aba0b70..6aaf1ef 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -367,6 +367,14 @@ asynStatus MD90Axis::poll(bool *moving) sscanf (pC_->inString_, "%d: %[^:]: %lf", &replyStatus, replyString, &position); setDoubleParam(pC_->motorPosition_, position); + // Read the current motor integral gain (range 1-1000) + sprintf(pC_->outString_, "GGN"); + comStatus = pC_->writeReadController(); + if (comStatus) goto skip; + // The response string is of the form "0: Gain: 1000" + sscanf (pC_->inString_, "%d: %[^:]: %d", &replyStatus, replyString, &replyValue); + setDoubleParam(pC_->motorIGain_, replyValue); + skip: setIntegerParam(pC_->motorStatusProblem_, comStatus ? 1:0); callParamCallbacks(); From 29a78e1023ea691807945d7f1e8bbea058796a9c Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Fri, 21 Jun 2024 16:07:54 -0500 Subject: [PATCH 6/8] Moved line back to fix status update problem. --- dsmApp/src/MD90Driver.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index 6aaf1ef..e8a45de 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -299,7 +299,6 @@ asynStatus MD90Axis::poll(bool *moving) sscanf (pC_->inString_, "%d: %[^:]: %d", &replyStatus, replyString, &replyValue); driveOn = (replyValue == '1') ? 1:0; setIntegerParam(pC_->motorStatusPowerOn_, driveOn); - setIntegerParam(pC_->motorStatusProblem_, 0); // Read the home status sprintf(pC_->outString_, "GHS"); @@ -375,6 +374,8 @@ asynStatus MD90Axis::poll(bool *moving) sscanf (pC_->inString_, "%d: %[^:]: %d", &replyStatus, replyString, &replyValue); setDoubleParam(pC_->motorIGain_, replyValue); + setIntegerParam(pC_->motorStatusProblem_, 0); + skip: setIntegerParam(pC_->motorStatusProblem_, comStatus ? 1:0); callParamCallbacks(); From bdec17808a5e34dd6f60a4fc14a34922730579cd Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Fri, 21 Jun 2024 16:31:17 -0500 Subject: [PATCH 7/8] Added home position status to poll. --- dsmApp/src/MD90Driver.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index e8a45de..b522fb9 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -291,6 +291,8 @@ asynStatus MD90Axis::poll(bool *moving) // TODO: Will need to add some more error handling for the motor return codes. + setIntegerParam(pC_->motorStatusProblem_, 0); + // Read the drive power on status sprintf(pC_->outString_, "GPS"); comStatus = pC_->writeReadController(); @@ -345,11 +347,13 @@ asynStatus MD90Axis::poll(bool *moving) break; case 10: // End of travel error setIntegerParam(pC_->motorStatusProblem_, 1); + /* if (position > 0) { setIntegerParam(pC_->motorStatusHighLimit_, 1); } else { setIntegerParam(pC_->motorStatusLowLimit_, 1); } + */ break; case 11: // Ramp move error setIntegerParam(pC_->motorStatusProblem_, 1); @@ -365,6 +369,8 @@ asynStatus MD90Axis::poll(bool *moving) // The response string is of the form "0: Current position in encoder counts: 1000" sscanf (pC_->inString_, "%d: %[^:]: %lf", &replyStatus, replyString, &position); setDoubleParam(pC_->motorPosition_, position); + setIntegerParam(pC_->motorStatusAtHome_, (position == 0) ? 1:0); // home limit switch + setIntegerParam(pC_->motorStatusHome_, (position == 0) ? 1:0); // at home position // Read the current motor integral gain (range 1-1000) sprintf(pC_->outString_, "GGN"); @@ -374,8 +380,6 @@ asynStatus MD90Axis::poll(bool *moving) sscanf (pC_->inString_, "%d: %[^:]: %d", &replyStatus, replyString, &replyValue); setDoubleParam(pC_->motorIGain_, replyValue); - setIntegerParam(pC_->motorStatusProblem_, 0); - skip: setIntegerParam(pC_->motorStatusProblem_, comStatus ? 1:0); callParamCallbacks(); From 75514657331774211cae2e885bf6cdc0ac9fb897 Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Fri, 21 Jun 2024 16:36:48 -0500 Subject: [PATCH 8/8] Set hasEncoder and gainSupport to true. Can now set motor gain. --- dsmApp/src/MD90Driver.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dsmApp/src/MD90Driver.cpp b/dsmApp/src/MD90Driver.cpp index b522fb9..afdeeb6 100644 --- a/dsmApp/src/MD90Driver.cpp +++ b/dsmApp/src/MD90Driver.cpp @@ -380,6 +380,10 @@ asynStatus MD90Axis::poll(bool *moving) sscanf (pC_->inString_, "%d: %[^:]: %d", &replyStatus, replyString, &replyValue); setDoubleParam(pC_->motorIGain_, replyValue); + // set some default params + setIntegerParam(pC_->motorStatusHasEncoder_, 1); + setIntegerParam(pC_->motorStatusGainSupport_, 1); + skip: setIntegerParam(pC_->motorStatusProblem_, comStatus ? 1:0); callParamCallbacks();