Tweak the resolver wrap around bias code to let us simply set a mask to

bias off the high bits on multiturn encoders because these bits can
increment if you unplug a resolver.

r3307 | ffr | 2011-12-02 12:49:54 +1100 (Fri, 02 Dec 2011) | 4 lines
This commit is contained in:
Ferdi Franceschini
2011-12-02 12:49:54 +11:00
committed by Douglas Clowes
parent 4707f319b9
commit b58a6fdaf1

View File

@@ -886,7 +886,7 @@ static int readAbsEnc(pDMC2280Driv self, long *pos) {
return FAILURE; return FAILURE;
long iCounts = atol(reply); long iCounts = atol(reply);
if (self->bias_bits > 0 && self->bias_bias != 0) if (self->bias_bits > 0)
iCounts = (iCounts + self->bias_bias) & ((1 << self->bias_bits) - 1); iCounts = (iCounts + self->bias_bias) & ((1 << self->bias_bits) - 1);
*pos = iCounts; *pos = iCounts;
return SUCCESS; return SUCCESS;
@@ -1317,7 +1317,7 @@ static int rspStatus(pDMC2280Driv self, const char* text) {
} }
self->currFlags = iFlags; self->currFlags = iFlags;
self->currSteps = iSteps; self->currSteps = iSteps;
if (self->bias_bits > 0 && self->bias_bias != 0) if (self->bias_bits > 0)
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);
@@ -3835,7 +3835,7 @@ MotorDriver *CreateDMC2280(SConnection *pCon, char *motor, char *params) {
/* BIAS for encoder - mask this many bits */ /* BIAS for encoder - mask this many bits */
if ((pPtr=getParam(pCon, interp, params,"bias_bits",_OPTIONAL)) == NULL) if ((pPtr=getParam(pCon, interp, params,"bias_bits",_OPTIONAL)) == NULL)
pNew->bias_bits = 0.0; pNew->bias_bits = 0;
else { else {
sscanf(pPtr, "%d", &(pNew->bias_bits)); sscanf(pPtr, "%d", &(pNew->bias_bits));
if (pNew->bias_bits < 0) if (pNew->bias_bits < 0)