Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ce23d261be | |||
| 89740d3956 | |||
| d94341e1c0 | |||
| df7a15eeb2 | |||
| 5165923595 | |||
| c7a2a32c73 | |||
| 21cd9320ee | |||
| 9098a932fa | |||
| b96605916f | |||
| 4d65dd238d |
+1
-1
Submodule sinqMotor updated: 95bc899114...f971101976
+34
-17
@@ -38,7 +38,7 @@ A special communication timeout is used in the following two cases:
|
||||
2) First move command after enabling the motor
|
||||
This is due to MasterMACS running a powerup cycle, which can delay the answer.
|
||||
*/
|
||||
#define PowerCycleTimeout 10.0 // Value in seconds
|
||||
#define PowerCycleTimeout 6.0 // Value in seconds
|
||||
|
||||
/*
|
||||
Contains all instances of turboPmacAxis which have been created and is used in
|
||||
@@ -532,9 +532,9 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
|
||||
|
||||
} else {
|
||||
|
||||
// If we wait for a handshake, but the motor was moving in its last poll
|
||||
// cycle and has reached its target, it is not moving. Otherwise it is
|
||||
// considered moving, even if we're still waiting for the handshake.
|
||||
// If the motor hasn't moved after being enabled, we cannot trust
|
||||
// targetReached. Hence, the targetReachedUninitialized flag guards
|
||||
// against invalid detection of the "moving" status.
|
||||
if (pMasterMacsA_->targetReachedUninitialized) {
|
||||
*moving = false;
|
||||
} else {
|
||||
@@ -545,7 +545,13 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
|
||||
}
|
||||
}
|
||||
|
||||
if (targetReached()) {
|
||||
// If the motor is not switched on, the targetReached bit is set to
|
||||
// true. targetReachedUninitialized is set to true in the enable
|
||||
// function, which is in a separate thread than doPoll. Therefore,
|
||||
// doPoll can reset targetReachedUninitialized, which then can lead to
|
||||
// a false "moving" status. Therefore, we only trust targetReached if
|
||||
// the motor is switched on.
|
||||
if (targetReached() && switchedOn()) {
|
||||
pMasterMacsA_->targetReachedUninitialized = false;
|
||||
}
|
||||
}
|
||||
@@ -782,9 +788,22 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
|
||||
}
|
||||
}
|
||||
|
||||
// Update the enable PV
|
||||
setAxisParamChecked(this, motorEnableRBV,
|
||||
readyToBeSwitchedOn() && switchedOn());
|
||||
/*
|
||||
If the motor just got enabled, we need to initialize it, because some
|
||||
parameters like the limits on the motor controllers are lost during a power
|
||||
cycle and are rewritten from the masterMacs "meta-controller" when enabling.
|
||||
*/
|
||||
int wasEnabled = 0;
|
||||
int isEnabled = readyToBeSwitchedOn() && switchedOn();
|
||||
|
||||
getAxisParamChecked(this, motorEnableRBV, &wasEnabled);
|
||||
if (isEnabled && !wasEnabled) {
|
||||
rwStatus = init();
|
||||
if (rwStatus != asynSuccess) {
|
||||
return rwStatus;
|
||||
}
|
||||
}
|
||||
setAxisParamChecked(this, motorEnableRBV, isEnabled);
|
||||
|
||||
if (*moving) {
|
||||
// If the axis is moving, evaluate the movement direction
|
||||
@@ -1119,7 +1138,6 @@ asynStatus masterMacsAxis::readEncoderType() {
|
||||
|
||||
asynStatus masterMacsAxis::enable(bool on) {
|
||||
|
||||
int timeout_enable_disable = 2;
|
||||
char msg[pC_->MAXBUF_];
|
||||
|
||||
// =========================================================================
|
||||
@@ -1177,8 +1195,7 @@ asynStatus masterMacsAxis::enable(bool on) {
|
||||
// hence we wait for a custom timespan in seconds instead of
|
||||
// pC_->comTimeout_
|
||||
double timeout = pC_->comTimeout();
|
||||
if (pMasterMacsA_->targetReachedUninitialized &&
|
||||
timeout < PowerCycleTimeout) {
|
||||
if (timeout < PowerCycleTimeout) {
|
||||
timeout = PowerCycleTimeout;
|
||||
}
|
||||
|
||||
@@ -1190,7 +1207,7 @@ asynStatus masterMacsAxis::enable(bool on) {
|
||||
// Query the axis status every few milliseconds until the axis has been
|
||||
// enabled or until the timeout has been reached
|
||||
int startTime = time(NULL);
|
||||
while (time(NULL) < startTime + timeout_enable_disable) {
|
||||
while (time(NULL) < startTime + PowerCycleTimeout) {
|
||||
|
||||
// Read the axis status
|
||||
usleep(100000);
|
||||
@@ -1207,17 +1224,17 @@ asynStatus masterMacsAxis::enable(bool on) {
|
||||
}
|
||||
}
|
||||
|
||||
// Failed to change axis status within timeout_enable_disable => Send a
|
||||
// Failed to change axis status within PowerCycleTimeout => Send a
|
||||
// corresponding message
|
||||
asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR,
|
||||
"Controller \"%s\", axis %d => %s, line %d:\nFailed to %s axis "
|
||||
"within %d seconds\n",
|
||||
"within %f seconds\n",
|
||||
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
||||
on ? "enable" : "disable", timeout_enable_disable);
|
||||
on ? "enable" : "disable", PowerCycleTimeout);
|
||||
|
||||
// Output message to user
|
||||
snprintf(msg, sizeof(msg), "Failed to %s within %d seconds",
|
||||
on ? "enable" : "disable", timeout_enable_disable);
|
||||
snprintf(msg, sizeof(msg), "Failed to %s within %f seconds",
|
||||
on ? "enable" : "disable", PowerCycleTimeout);
|
||||
|
||||
setAxisParamChecked(this, motorMessageText, msg);
|
||||
return asynError;
|
||||
|
||||
@@ -493,7 +493,7 @@ asynStatus masterMacsController::parseResponse(
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
return asynDisconnected;
|
||||
} else if (fullResponse[i] == '\x18') {
|
||||
// CAN
|
||||
snprintf(drvMessageText, MAXBUF_,
|
||||
|
||||
@@ -67,7 +67,7 @@ the next value can be typed in. Type 'quit' to close the prompt.
|
||||
if __name__ == "__main__":
|
||||
from sys import argv
|
||||
|
||||
if "-h" or "--help" in argv:
|
||||
if "-h" in argv or "--help" in argv:
|
||||
print(help)
|
||||
|
||||
if len(argv) == 1:
|
||||
|
||||
@@ -18,7 +18,7 @@ from decodeCommon import interactive, decode, print_decoded
|
||||
interpretation = [
|
||||
("Not ready to be switched on", "Ready to be switched on"), # Bit 0
|
||||
("Not switched on", "Switched on"), # Bit 1
|
||||
("Disabled", "Enabled"), # Bit 2
|
||||
("Operation disabled (no current)", "Operation enabled (current)"), # Bit 2
|
||||
("Ok", "Fault condition set"), # Bit 3
|
||||
("Motor supply voltage absent ", "Motor supply voltage present"), # Bit 4
|
||||
("Motor performs quick stop", "Ok"), # Bit 5
|
||||
@@ -68,7 +68,7 @@ the next value can be typed in. Type 'quit' to close the prompt.
|
||||
if __name__ == "__main__":
|
||||
from sys import argv
|
||||
|
||||
if "-h" or "--help" in argv:
|
||||
if "-h" in argv or "--help" in argv:
|
||||
print(help)
|
||||
|
||||
if len(argv) == 1:
|
||||
|
||||
Reference in New Issue
Block a user