Add min and max position on a motor move and output

This commit is contained in:
Douglas Clowes
2013-07-15 13:38:25 +10:00
parent 23f53b8a4c
commit 627b840c38

View File

@@ -187,6 +187,8 @@ struct __MoDriv {
double origTime; /**< Time at motor start */ double origTime; /**< Time at motor start */
int origSteps; int origSteps;
int origCounts; int origCounts;
double minPosition; /**< min position during move */
double maxPosition; /**< max position during move */
double minRatio; double minRatio;
double maxRatio; double maxRatio;
int thread0; /**< last read of _XQ0 */ int thread0; /**< last read of _XQ0 */
@@ -1545,6 +1547,10 @@ static int rspStatus(pDMC2280Driv self, const char* text) {
iCounts = (iCounts + self->bias_bias) & ((1 << self->bias_bits) - 1); iCounts = (iCounts + self->bias_bias) & ((1 << self->bias_bits) - 1);
self->currCounts = iCounts; self->currCounts = iCounts;
self->currPosition = motPosit(self); self->currPosition = motPosit(self);
if (self->currPosition < self->minPosition)
self->minPosition = self->currPosition;
if (self->currPosition > self->maxPosition)
self->maxPosition = self->currPosition;
self->thread0 = iXQ0; self->thread0 = iXQ0;
self->stopCode = iStopCode; self->stopCode = iStopCode;
self->inputByte = iIOByte; self->inputByte = iIOByte;
@@ -2446,6 +2452,8 @@ static void DMCState_MotorOn(pDMC2280Driv self, pEvtEvent event) {
cmdAccel(self); /* No Response */ cmdAccel(self); /* No Response */
cmdDecel(self); /* No Response */ cmdDecel(self); /* No Response */
#endif #endif
self->minPosition = self->currPosition;
self->maxPosition = self->currPosition;
if (self->testing) { if (self->testing) {
self->myNextState = NULL; self->myNextState = NULL;
if (self->backlash_offset != 0) { if (self->backlash_offset != 0) {
@@ -3073,10 +3081,13 @@ static void DMCState_StepMove(pDMC2280Driv self, pEvtEvent event) {
double time = DoubleTime() - self->origTime; double time = DoubleTime() - self->origTime;
char line[CMDLEN]; char line[CMDLEN];
if (true /*self->debug*/) { if (true /*self->debug*/) {
snprintf(line, CMDLEN, "Motor=%s stopped: units=%.6f," snprintf(line, CMDLEN, "Motor=%s stopped: p=%.6f(%.6f-%.6f), u=%.6f,"
" steps=%ld, counts=%ld, stepsPerX=%.6f," " s=%ld, c=%ld, s/X=%.6f,"
" ratio=(%.6f-%.6f), time=%.3f", " r=(%.6f-%.6f), t=%.3fS",
self->name, self->name,
self->currPosition,
self->minPosition,
self->maxPosition,
units, units,
steps, steps,
counts, counts,
@@ -5148,6 +5159,22 @@ int DMC2280Action(SConnection *pCon, SicsInterp *pSics, void *pData,
} }
return 1; return 1;
} }
else if(strcasecmp("minPosition", argv[1]) == 0) {
char line[132];
snprintf(line, 132, "%s.minPosition = %.6f",
self->name,
self->minPosition);
SCWrite(pCon, line, eValue);
return 1;
}
else if(strcasecmp("maxPosition", argv[1]) == 0) {
char line[132];
snprintf(line, 132, "%s.maxPosition = %.6f",
self->name,
self->maxPosition);
SCWrite(pCon, line, eValue);
return 1;
}
else if(strcasecmp("testing", argv[1]) == 0) { else if(strcasecmp("testing", argv[1]) == 0) {
if (argc > 2) { if (argc > 2) {
if (strcasecmp("on", argv[2]) == 0) { if (strcasecmp("on", argv[2]) == 0) {
@@ -5190,7 +5217,7 @@ int DMC2280Action(SConnection *pCon, SicsInterp *pSics, void *pData,
} }
return 1; return 1;
} }
else if(strcasecmp("unit2count", argv[1]) == 0) { else if(self->abs_encoder && strcasecmp("unit2count", argv[1]) == 0) {
char line[132]; char line[132];
if (argc > 2) { if (argc > 2) {
double target; double target;
@@ -5204,7 +5231,7 @@ int DMC2280Action(SConnection *pCon, SicsInterp *pSics, void *pData,
SCWrite(pCon, line, eValue); SCWrite(pCon, line, eValue);
return 1; return 1;
} }
else if(strcasecmp("count2unit", argv[1]) == 0) { else if(self->abs_encoder && strcasecmp("count2unit", argv[1]) == 0) {
char line[132]; char line[132];
if (argc > 2) { if (argc > 2) {
long long target; long long target;