Merge branch 'dev'

This commit is contained in:
2024-06-21 16:55:30 -05:00
2 changed files with 37 additions and 22 deletions

View File

@@ -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. // 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. // Motor controller accepts step frequency in Hz.
freq = NINT(fabs(velocity / 500.)); freq = NINT(fabs(velocity / 500.));
if (freq < 5) freq=5;
if (freq > 125) freq = 125;
sprintf(pC_->outString_, "SSF %d", freq); sprintf(pC_->outString_, "SSF %d", freq);
status = pC_->writeReadController(); status = pC_->writeReadController();
@@ -255,9 +253,9 @@ asynStatus MD90Axis::setIGain(double iGain)
asynStatus status; asynStatus status;
//static const char *functionName = "MD90Axis::setIGain"; //static const char *functionName = "MD90Axis::setIGain";
iGain = iGain * 100; iGain = iGain * 1000;
if (iGain < 1) iGain = 1.0; 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)); sprintf(pC_->outString_, "SGN %d", NINT(iGain));
status = pC_->writeReadController(); status = pC_->writeReadController();
return status; return status;
@@ -293,13 +291,25 @@ asynStatus MD90Axis::poll(bool *moving)
// TODO: Will need to add some more error handling for the motor return codes. // TODO: Will need to add some more error handling for the motor return codes.
// Read the current motor position in encoder steps (10 nm) setIntegerParam(pC_->motorStatusProblem_, 0);
sprintf(pC_->outString_, "GEC");
// Read the drive power on status
sprintf(pC_->outString_, "GPS");
comStatus = pC_->writeReadController(); comStatus = pC_->writeReadController();
if (comStatus) goto skip; if (comStatus) goto skip;
// The response string is of the form "0: Current position in encoder counts: 1000" // The response string is of the form "0: Power supply enabled state: 1"
sscanf (pC_->inString_, "%d: %[^:]: %lf", &replyStatus, replyString, &position); sscanf (pC_->inString_, "%d: %[^:]: %d", &replyStatus, replyString, &replyValue);
setDoubleParam(pC_->motorPosition_, position); driveOn = (replyValue == '1') ? 1:0;
setIntegerParam(pC_->motorStatusPowerOn_, driveOn);
// 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 // Read the moving status of this motor
sprintf(pC_->outString_, "STA"); sprintf(pC_->outString_, "STA");
@@ -337,11 +347,13 @@ asynStatus MD90Axis::poll(bool *moving)
break; break;
case 10: // End of travel error case 10: // End of travel error
setIntegerParam(pC_->motorStatusProblem_, 1); setIntegerParam(pC_->motorStatusProblem_, 1);
/*
if (position > 0) { if (position > 0) {
setIntegerParam(pC_->motorStatusHighLimit_, 1); setIntegerParam(pC_->motorStatusHighLimit_, 1);
} else { } else {
setIntegerParam(pC_->motorStatusLowLimit_, 1); setIntegerParam(pC_->motorStatusLowLimit_, 1);
} }
*/
break; break;
case 11: // Ramp move error case 11: // Ramp move error
setIntegerParam(pC_->motorStatusProblem_, 1); setIntegerParam(pC_->motorStatusProblem_, 1);
@@ -350,24 +362,27 @@ asynStatus MD90Axis::poll(bool *moving)
break; break;
} }
// Read the home status // Read the current motor position in encoder steps (10 nm)
sprintf(pC_->outString_, "GHS"); sprintf(pC_->outString_, "GEC");
comStatus = pC_->writeReadController(); comStatus = pC_->writeReadController();
if (comStatus) goto skip; if (comStatus) goto skip;
// The response string is of the form "0: Home status: 1" // The response string is of the form "0: Current position in encoder counts: 1000"
sscanf (pC_->inString_, "%d: %[^:]: %d", &replyStatus, replyString, &replyValue); sscanf (pC_->inString_, "%d: %[^:]: %lf", &replyStatus, replyString, &position);
homed = (replyValue == '1') ? 1:0; setDoubleParam(pC_->motorPosition_, position);
setIntegerParam(pC_->motorStatusHomed_, homed); setIntegerParam(pC_->motorStatusAtHome_, (position == 0) ? 1:0); // home limit switch
setIntegerParam(pC_->motorStatusHome_, (position == 0) ? 1:0); // at home position
// Read the drive power on status // Read the current motor integral gain (range 1-1000)
sprintf(pC_->outString_, "GPS"); sprintf(pC_->outString_, "GGN");
comStatus = pC_->writeReadController(); comStatus = pC_->writeReadController();
if (comStatus) goto skip; if (comStatus) goto skip;
// The response string is of the form "0: Power supply enabled state: 1" // The response string is of the form "0: Gain: 1000"
sscanf (pC_->inString_, "%d: %[^:]: %d", &replyStatus, replyString, &replyValue); sscanf (pC_->inString_, "%d: %[^:]: %d", &replyStatus, replyString, &replyValue);
driveOn = (replyValue == '1') ? 1:0; setDoubleParam(pC_->motorIGain_, replyValue);
setIntegerParam(pC_->motorStatusPowerOn_, driveOn);
setIntegerParam(pC_->motorStatusProblem_, 0); // set some default params
setIntegerParam(pC_->motorStatusHasEncoder_, 1);
setIntegerParam(pC_->motorStatusGainSupport_, 1);
skip: skip:
setIntegerParam(pC_->motorStatusProblem_, comStatus ? 1:0); setIntegerParam(pC_->motorStatusProblem_, comStatus ? 1:0);

View File

@@ -8,7 +8,7 @@ dsm_registerRecordDeviceDriver(pdbbase)
# Network device # Network device
#!drvAsynIPPortConfigure("serial0", "192.168.1.16:4002",0,0,0) #!drvAsynIPPortConfigure("serial0", "192.168.1.16:4002",0,0,0)
# Local serial port # Local serial port
#!drvAsynSerialPortConfigure("serial0", "/dev/ttyS0", 0, 0, 0) #!drvAsynSerialPortConfigure("serial0", "/dev/ttyUSB0", 0, 0, 0)
drvAsynSerialPortConfigure("serial0", "/tmp/motorport", 0, 0, 0) drvAsynSerialPortConfigure("serial0", "/tmp/motorport", 0, 0, 0)
asynSetOption("serial0", 0, "baud", "115200") asynSetOption("serial0", 0, "baud", "115200")
asynSetOption("serial0", 0, "bits", "8") asynSetOption("serial0", 0, "bits", "8")